SteamWar/BungeeCore
Archiviert
13
2

Fixing 1.13+ support for forge modblocker

Dieser Commit ist enthalten in:
Lixfel 2019-12-31 10:56:11 +01:00
Ursprung 8f553a663b
Commit 312f5b96b7

Datei anzeigen

@ -20,7 +20,9 @@ import java.util.concurrent.TimeUnit;
public class Forge extends BasicListener {
private static final String FMLHS = "FML|HS";
private static final String FMLHS13 = "fml:handshake";
private static final byte[] REGISTER;
private static final byte[] REGISTER13;
private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0};
private static final Set<UUID> unlocked = new HashSet<>();
@ -30,6 +32,12 @@ public class Forge extends BasicListener {
buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8);
REGISTER = new byte[buf.readableBytes()];
buf.readBytes(REGISTER);
buf.clear();
buf.writeByte(13);
buf.writeCharSequence(FMLHS13, StandardCharsets.UTF_8);
REGISTER13 = new byte[buf.readableBytes()];
buf.readBytes(REGISTER13);
}
@EventHandler
@ -43,17 +51,18 @@ public class Forge extends BasicListener {
}
}
if(player.getPendingConnection().getVersion() > 340)
player.sendData("minecraft:register", REGISTER); //1.13+
else
if(player.getPendingConnection().getVersion() > 340) {
player.sendData("minecraft:register", REGISTER13); //1.13+
player.sendData(FMLHS13, Forge.HELLO);
}else{
player.sendData("REGISTER", REGISTER); //1.12-
player.sendData(FMLHS, HELLO);
player.sendData(FMLHS, Forge.HELLO);
}
}
@EventHandler
public void onPluginMessageEvent(PluginMessageEvent e){
if(!e.getTag().equals(FMLHS))
if(!e.getTag().equals(FMLHS) && !e.getTag().equals(FMLHS13))
return;
e.setCancelled(true);
@ -64,37 +73,33 @@ public class Forge extends BasicListener {
return;
ProxiedPlayer p = (ProxiedPlayer) sender;
switch(data[0]){
case 2:
Pair<Integer, Integer> numMods = Utils.readVarInt(data, 1);
List<Mod> mods = new LinkedList<>();
if (data[0] == 2) {
Pair<Integer, Integer> numMods = Utils.readVarInt(data, 1);
List<Mod> mods = new LinkedList<>();
int bytePos = 1 + numMods.getKey();
for(int i = 0; i < numMods.getValue(); i++){
byte[] name = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
bytePos += 1 + data[bytePos];
byte[] version = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
bytePos += 1 + data[bytePos];
int bytePos = 1 + numMods.getKey();
for (int i = 0; i < numMods.getValue(); i++) {
byte[] name = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
bytePos += 1 + data[bytePos];
//Version information is unused
bytePos += 1 + data[bytePos];
mods.add(Mod.get(new String(name), Mod.Platform.FORGE));
mods.add(Mod.get(new String(name), Mod.Platform.FORGE));
}
if (Utils.handleMods(p, mods)) {
synchronized (unlocked) {
unlocked.add(p.getUniqueId());
}
if(Utils.handleMods(p, mods)){
synchronized (unlocked){
unlocked.add(p.getUniqueId());
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(),
() -> p.disconnect(BungeeCore.stringToText("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten")),
2, TimeUnit.SECONDS);
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
synchronized (unlocked) {
unlocked.remove(p.getUniqueId());
}
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(),
() -> p.disconnect(BungeeCore.stringToText("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten")),
2, TimeUnit.SECONDS);
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
synchronized (unlocked) {
unlocked.remove(p.getUniqueId());
}
}, 30, TimeUnit.SECONDS);
}
break;
default:
break;
}, 30, TimeUnit.SECONDS);
}
}
}
}