-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to 1.20.4, bug fixes, add port-reusing, address detecting auto…
…host provider, make resource pack generation path configurable
- Loading branch information
Showing
26 changed files
with
623 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/AutoHostConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/AutoHostTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package eu.pb4.polymer.autohost.impl; | ||
|
||
import net.minecraft.network.packet.Packet; | ||
import net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket; | ||
import net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.network.ServerConfigurationNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerConfigurationTask; | ||
import net.minecraft.text.Text; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
import java.util.function.Consumer; | ||
|
||
public class AutoHostTask implements ServerPlayerConfigurationTask { | ||
public static final Key KEY = new Key("polymer:autohost/send_packs"); | ||
private final Collection<MinecraftServer.ServerResourcePackProperties> packs; | ||
|
||
private final Set<UUID> requiredPacks = new HashSet<>(); | ||
private final Set<UUID> waitingFor = new HashSet<>(); | ||
|
||
public AutoHostTask(Collection<MinecraftServer.ServerResourcePackProperties> properties) { | ||
this.packs = properties; | ||
for (var pack : packs) { | ||
if (pack.isRequired()) { | ||
requiredPacks.add(pack.id()); | ||
} | ||
waitingFor.add(pack.id()); | ||
} | ||
} | ||
|
||
@Override | ||
public void sendPacket(Consumer<Packet<?>> sender) { | ||
for (var pack : packs) { | ||
sender.accept(new ResourcePackSendS2CPacket(pack.id(), pack.url(), pack.hash(), pack.isRequired(), pack.prompt())); | ||
} | ||
} | ||
|
||
@Override | ||
public Key getKey() { | ||
return KEY; | ||
} | ||
|
||
public boolean onStatus(ServerConfigurationNetworkHandler handler, UUID id, ResourcePackStatusC2SPacket.Status status) { | ||
switch (status) { | ||
case DECLINED, FAILED_RELOAD, FAILED_DOWNLOAD, INVALID_URL -> { | ||
if (this.requiredPacks.contains(id)) { | ||
handler.disconnect(Text.translatable("multiplayer.requiredTexturePrompt.disconnect")); | ||
} | ||
} | ||
} | ||
|
||
if (status.hasFinished()) { | ||
this.waitingFor.remove(id); | ||
} | ||
|
||
return this.waitingFor.isEmpty(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
polymer-autohost/src/main/java/eu/pb4/polymer/autohost/impl/ClientConnectionExt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package eu.pb4.polymer.autohost.impl; | ||
|
||
public interface ClientConnectionExt { | ||
void polymerAutoHost$setAddress(String address, int port); | ||
|
||
String polymerAutoHost$getAddress(); | ||
int polymerAutoHost$getPort(); | ||
|
||
default String polymerAutoHost$getFullAddress() { | ||
return polymerAutoHost$getAddress() + ":" + polymerAutoHost$getPort(); | ||
} | ||
} |
Oops, something went wrong.