Warning with Version <1.12 + First forge analyzer attempts
Dieser Commit ist enthalten in:
Ursprung
0f1240faf1
Commit
7b2cc88718
@ -1,5 +1,7 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import de.steamwar.bungeecore.arenasystem.Arena;
|
||||
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
||||
import de.steamwar.bungeecore.bausystem.BauServer;
|
||||
@ -15,13 +17,14 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.*;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
@ -67,6 +70,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -114,12 +118,22 @@ public class PlayerListener implements Listener {
|
||||
break;
|
||||
}
|
||||
|
||||
Map<String, String> modlist = player.getModList();
|
||||
for(String key : modlist.keySet()){
|
||||
System.out.println(key + " > " + modlist.get(key));
|
||||
if(player.getPendingConnection().getVersion() < 335){
|
||||
player.sendMessage(BungeeCore.ChatPrefix + "§cWir empfehlen die Minecraft-Version 1.12.2");
|
||||
}
|
||||
if(player.isForgeUser())
|
||||
System.out.println("Forge user!");
|
||||
|
||||
ByteArrayDataOutput output = ByteStreams.newDataOutput();
|
||||
output.writeUTF("FML|HS");
|
||||
|
||||
if(player.getPendingConnection().getVersion() > 340){
|
||||
//1.13+
|
||||
player.sendData("minecraft:register", output.toByteArray());
|
||||
}else{
|
||||
//1.12-
|
||||
player.sendData("REGISTER", output.toByteArray());
|
||||
}
|
||||
|
||||
player.sendData("FML|HS", new byte[]{0, 2, 0, 0, 0, 0});
|
||||
}
|
||||
|
||||
/** To redirect players to the lobby in case of server closure. */
|
||||
@ -251,4 +265,93 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessageEvent(PluginMessageEvent e){
|
||||
System.out.println(e.getSender().getAddress().getHostString() + " " + e.getTag() + " " + Arrays.toString(e.getData()));
|
||||
|
||||
if(!e.getTag().equals("FML|HS")){
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
byte[] data = e.getData();
|
||||
ProxiedPlayer p = getPlayer(e.getSender());
|
||||
switch(data[0]){
|
||||
case 2:
|
||||
int numMods = readVarInt(data, 1);
|
||||
System.out.println("Number of mods: " + numMods);
|
||||
int bytePos = 1 + readVarIntLength(data, 1);
|
||||
for(int i = 0; i < numMods; 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];
|
||||
|
||||
System.out.println(new String(name) + " " + new String(version));
|
||||
}
|
||||
|
||||
p.sendData("FML|HS", new byte[]{2, 0});
|
||||
//p.sendData("FML|HS", new byte[]{2, 1, 9, 109, 105, 110, 101, 99, 114, 97, 102, 116, 6, 49, 46, 49, 50, 46, 50});
|
||||
break;
|
||||
case -1:
|
||||
switch(data[1]){
|
||||
case 2:
|
||||
p.sendData("FML|HS", new byte[]{3, 0, 1, 97, 0, 0, 0});
|
||||
break;
|
||||
case 3:
|
||||
p.sendData("FML|HS", new byte[]{-1, 2});
|
||||
break;
|
||||
case 4:
|
||||
p.sendData("FML|HS", new byte[]{-1, 3});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static ProxiedPlayer getPlayer(Connection c){
|
||||
for(ProxiedPlayer p : ProxyServer.getInstance().getPlayers()){
|
||||
if(p.getPendingConnection().getAddress().equals(c.getAddress())){
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int readVarInt(byte[] array, int startPos) {
|
||||
int numRead = 0;
|
||||
int result = 0;
|
||||
byte read;
|
||||
do {
|
||||
read = array[startPos + numRead];
|
||||
int value = (read & 0b01111111);
|
||||
result |= (value << (7 * numRead));
|
||||
|
||||
numRead++;
|
||||
if (numRead > 5) {
|
||||
break;
|
||||
}
|
||||
} while ((read & 0b10000000) != 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int readVarIntLength(byte[] array, int startPos) {
|
||||
int numRead = 0;
|
||||
byte read;
|
||||
do {
|
||||
read = array[startPos + numRead];
|
||||
numRead++;
|
||||
if (numRead > 5) {
|
||||
break;
|
||||
}
|
||||
} while ((read & 0b10000000) != 0);
|
||||
|
||||
return numRead;
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren