geforkt von SteamWar/BungeeCore
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 {
|
||||
|
||||
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,23 +73,22 @@ public class Forge extends BasicListener {
|
||||
return;
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
|
||||
switch(data[0]){
|
||||
case 2:
|
||||
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++){
|
||||
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);
|
||||
//Version information is unused
|
||||
bytePos += 1 + data[bytePos];
|
||||
|
||||
mods.add(Mod.get(new String(name), Mod.Platform.FORGE));
|
||||
}
|
||||
|
||||
if(Utils.handleMods(p, mods)){
|
||||
synchronized (unlocked){
|
||||
if (Utils.handleMods(p, mods)) {
|
||||
synchronized (unlocked) {
|
||||
unlocked.add(p.getUniqueId());
|
||||
}
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(),
|
||||
@ -92,9 +100,6 @@ public class Forge extends BasicListener {
|
||||
}
|
||||
}, 30, TimeUnit.SECONDS);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren