Fixing 1.13+ support for forge modblocker
Dieser Commit ist enthalten in:
Ursprung
8f553a663b
Commit
312f5b96b7
@ -20,7 +20,9 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class Forge extends BasicListener {
|
public class Forge extends BasicListener {
|
||||||
|
|
||||||
private static final String FMLHS = "FML|HS";
|
private static final String FMLHS = "FML|HS";
|
||||||
|
private static final String FMLHS13 = "fml:handshake";
|
||||||
private static final byte[] REGISTER;
|
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 byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0};
|
||||||
private static final Set<UUID> unlocked = new HashSet<>();
|
private static final Set<UUID> unlocked = new HashSet<>();
|
||||||
|
|
||||||
@ -30,6 +32,12 @@ public class Forge extends BasicListener {
|
|||||||
buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8);
|
buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8);
|
||||||
REGISTER = new byte[buf.readableBytes()];
|
REGISTER = new byte[buf.readableBytes()];
|
||||||
buf.readBytes(REGISTER);
|
buf.readBytes(REGISTER);
|
||||||
|
|
||||||
|
buf.clear();
|
||||||
|
buf.writeByte(13);
|
||||||
|
buf.writeCharSequence(FMLHS13, StandardCharsets.UTF_8);
|
||||||
|
REGISTER13 = new byte[buf.readableBytes()];
|
||||||
|
buf.readBytes(REGISTER13);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -43,17 +51,18 @@ public class Forge extends BasicListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.getPendingConnection().getVersion() > 340)
|
if(player.getPendingConnection().getVersion() > 340) {
|
||||||
player.sendData("minecraft:register", REGISTER); //1.13+
|
player.sendData("minecraft:register", REGISTER13); //1.13+
|
||||||
else
|
player.sendData(FMLHS13, Forge.HELLO);
|
||||||
|
}else{
|
||||||
player.sendData("REGISTER", REGISTER); //1.12-
|
player.sendData("REGISTER", REGISTER); //1.12-
|
||||||
|
player.sendData(FMLHS, Forge.HELLO);
|
||||||
player.sendData(FMLHS, HELLO);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPluginMessageEvent(PluginMessageEvent e){
|
public void onPluginMessageEvent(PluginMessageEvent e){
|
||||||
if(!e.getTag().equals(FMLHS))
|
if(!e.getTag().equals(FMLHS) && !e.getTag().equals(FMLHS13))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -64,8 +73,7 @@ public class Forge extends BasicListener {
|
|||||||
return;
|
return;
|
||||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
switch(data[0]){
|
if (data[0] == 2) {
|
||||||
case 2:
|
|
||||||
Pair<Integer, Integer> numMods = Utils.readVarInt(data, 1);
|
Pair<Integer, Integer> numMods = Utils.readVarInt(data, 1);
|
||||||
List<Mod> mods = new LinkedList<>();
|
List<Mod> mods = new LinkedList<>();
|
||||||
|
|
||||||
@ -73,7 +81,7 @@ public class Forge extends BasicListener {
|
|||||||
for (int i = 0; i < numMods.getValue(); i++) {
|
for (int i = 0; i < numMods.getValue(); i++) {
|
||||||
byte[] name = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
|
byte[] name = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
|
||||||
bytePos += 1 + data[bytePos];
|
bytePos += 1 + data[bytePos];
|
||||||
byte[] version = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
|
//Version information is unused
|
||||||
bytePos += 1 + data[bytePos];
|
bytePos += 1 + data[bytePos];
|
||||||
|
|
||||||
mods.add(Mod.get(new String(name), Mod.Platform.FORGE));
|
mods.add(Mod.get(new String(name), Mod.Platform.FORGE));
|
||||||
@ -92,9 +100,6 @@ public class Forge extends BasicListener {
|
|||||||
}
|
}
|
||||||
}, 30, TimeUnit.SECONDS);
|
}, 30, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren