Update stuff
Dieser Commit ist enthalten in:
Ursprung
1e2a3030ca
Commit
ce88e69ed0
@ -1,20 +1,16 @@
|
|||||||
package de.steamwar;
|
package de.steamwar;
|
||||||
|
|
||||||
import de.steamwar.command.TestCommand;
|
import de.steamwar.listener.SteamwarConnectionListener;
|
||||||
import de.steamwar.listener.TestListener;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
|
||||||
public final class SteamWarBungeeTeamserver extends Plugin {
|
public final class SteamWarBungeeTeamserver extends Plugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getProxy().getPluginManager().registerListener(this, new TestListener());
|
getProxy().getPluginManager().registerListener(this, new SteamwarConnectionListener());
|
||||||
getProxy().getPluginManager().registerCommand(this, new TestCommand());
|
|
||||||
// Plugin startup logic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Plugin shutdown logic
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import net.md_5.bungee.api.plugin.Command;
|
|||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
public class TestCommand extends Command {
|
public class TestCommand extends Command { // TODO: This will be removed later on
|
||||||
|
|
||||||
public TestCommand() {
|
public TestCommand() {
|
||||||
super("test");
|
super("test");
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package de.steamwar.listener;
|
package de.steamwar.listener;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
|
||||||
import net.md_5.bungee.api.event.PreLoginEvent;
|
import net.md_5.bungee.api.event.PreLoginEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.protocol.Protocol;
|
import net.md_5.bungee.protocol.Protocol;
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
import net.md_5.bungee.protocol.packet.Handshake;
|
import net.md_5.bungee.protocol.packet.Handshake;
|
||||||
@ -13,16 +13,17 @@ import net.md_5.bungee.protocol.packet.Handshake;
|
|||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class TestListener implements Listener {
|
public class SteamwarConnectionListener implements Listener {
|
||||||
|
|
||||||
private Field handShakeField;
|
private Field chField;
|
||||||
|
|
||||||
private static class SteamwarHandshake extends Handshake {
|
private static class SteamwarHandshake extends Handshake {
|
||||||
public void read(ByteBuf buf) {
|
public void read(ByteBuf buf) {
|
||||||
System.out.println("read");
|
|
||||||
setProtocolVersion(readVarInt(buf));
|
setProtocolVersion(readVarInt(buf));
|
||||||
setHost(readString(buf));
|
setHost(readString(buf));
|
||||||
setPort(buf.readUnsignedShort());
|
setPort(buf.readUnsignedShort());
|
||||||
@ -58,8 +59,8 @@ public class TestListener implements Listener {
|
|||||||
}
|
}
|
||||||
}, protocolMappingArray);
|
}, protocolMappingArray);
|
||||||
|
|
||||||
handShakeField = InitialHandler.class.getDeclaredField("handshake");
|
chField = InitialHandler.class.getDeclaredField("ch");
|
||||||
handShakeField.setAccessible(true);
|
chField.setAccessible(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -67,20 +68,29 @@ public class TestListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preLoginEvent(PreLoginEvent preLoginEvent) {
|
public void preLoginEvent(PreLoginEvent preLoginEvent) {
|
||||||
PendingConnection pendingConnection = preLoginEvent.getConnection();
|
|
||||||
System.out.println("PreLoginEvent " + preLoginEvent);
|
|
||||||
String address = preLoginEvent.getConnection().getSocketAddress().toString();
|
String address = preLoginEvent.getConnection().getSocketAddress().toString();
|
||||||
if (address.startsWith("/78.31.71.136:")) {
|
if (address.startsWith("/78.31.71.136:")) {
|
||||||
SteamwarHandshake handshake;
|
InitialHandler initialHandler = (InitialHandler) preLoginEvent.getConnection();
|
||||||
|
String extraData = initialHandler.getExtraDataInHandshake();
|
||||||
|
String[] split = extraData.split("\0");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
handshake = (SteamwarHandshake) handShakeField.get(pendingConnection);
|
ChannelWrapper channelWrapper = ((ChannelWrapper) chField.get(initialHandler));
|
||||||
|
channelWrapper.setRemoteAddress(new InetSocketAddress(split[1], ((InetSocketAddress) channelWrapper.getRemoteAddress()).getPort()));
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.out.println(Arrays.toString(handshake.getHost().split("\0")));
|
|
||||||
// 0: host, 1: address, 2: uuid, (3): mojangProfile (properties, so skin data)
|
// 0: host, 1: address, 2: uuid, (3): mojangProfile (properties, so skin data)
|
||||||
preLoginEvent.getConnection().setOnlineMode(false);
|
preLoginEvent.getConnection().setOnlineMode(false);
|
||||||
|
|
||||||
|
StringBuilder st = new StringBuilder(split[2]);
|
||||||
|
st.insert(8, '-');
|
||||||
|
st.insert(13, '-');
|
||||||
|
st.insert(18, '-');
|
||||||
|
st.insert(23, '-');
|
||||||
|
initialHandler.setUniqueId(UUID.fromString(st.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren