Fix TexturePackSystem for newer versions

This commit is contained in:
2026-08-13 09:39:42 +02:00
parent 8dc101639d
commit 683236bb59
@@ -39,22 +39,28 @@ public class TexturePackSystem extends BasicListener {
private static final File PACKS_DIR = new File("/var/www/packs");
private static final String BASE_ULR = "https://packs.steamwar.de/";
private TreeMap<Integer, Integer> protocolVersionToPackVersion = new TreeMap<>();
private TreeMap<Integer, String> protocolVersionToPackVersion = new TreeMap<>();
public TexturePackSystem() {
// https://minecraft.wiki/w/Pack_format#List_of_resource_pack_formats
// https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Protocol_version_numbers
protocolVersionToPackVersion.put(759, 9);
protocolVersionToPackVersion.put(761, 12);
protocolVersionToPackVersion.put(762, 13);
protocolVersionToPackVersion.put(763, 15);
protocolVersionToPackVersion.put(764, 18);
protocolVersionToPackVersion.put(765, 22);
protocolVersionToPackVersion.put(766, 32);
protocolVersionToPackVersion.put(767, 34);
protocolVersionToPackVersion.put(768, 42);
protocolVersionToPackVersion.put(769, 46);
protocolVersionToPackVersion.put(770, 55);
protocolVersionToPackVersion.put(759, "9");
protocolVersionToPackVersion.put(761, "12");
protocolVersionToPackVersion.put(762, "13");
protocolVersionToPackVersion.put(763, "15");
protocolVersionToPackVersion.put(764, "18");
protocolVersionToPackVersion.put(765, "22");
protocolVersionToPackVersion.put(766, "32");
protocolVersionToPackVersion.put(767, "34");
protocolVersionToPackVersion.put(768, "42");
protocolVersionToPackVersion.put(769, "46");
protocolVersionToPackVersion.put(770, "55");
protocolVersionToPackVersion.put(771, "63");
protocolVersionToPackVersion.put(772, "64");
protocolVersionToPackVersion.put(773, "69.0");
protocolVersionToPackVersion.put(774, "75.0");
protocolVersionToPackVersion.put(775, "84.0");
protocolVersionToPackVersion.put(776, "88.0");
}
@Subscribe
@@ -63,20 +69,19 @@ public class TexturePackSystem extends BasicListener {
return;
}
VelocityCore.schedule(() -> {
TreeMap<Integer, File> fileTreeMap = new TreeMap<>();
TreeMap<String, File> fileTreeMap = new TreeMap<>();
for (File fileEntry : PACKS_DIR.listFiles()) {
try {
int packVersion = Integer.parseInt(fileEntry.getName().split("_")[0]);
fileTreeMap.put(packVersion, fileEntry);
fileTreeMap.put(fileEntry.getName().split("_")[0], fileEntry);
} catch (NumberFormatException e) {
// Ignore
}
}
int playerVersion = event.getPlayer().getProtocolVersion().getProtocol();
Map.Entry<Integer, Integer> packVersionEntry = protocolVersionToPackVersion.floorEntry(playerVersion);
Map.Entry<Integer, String> packVersionEntry = protocolVersionToPackVersion.floorEntry(playerVersion);
if (packVersionEntry == null) return;
Map.Entry<Integer, File> selectedPackEntry = fileTreeMap.floorEntry(packVersionEntry.getValue());
Map.Entry<String, File> selectedPackEntry = fileTreeMap.floorEntry(packVersionEntry.getValue());
if (selectedPackEntry == null) return;
File selectedPack = selectedPackEntry.getValue();