Compare commits
1 Commits
Bungee1.21
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 8172bf50e1 |
11
build.gradle
11
build.gradle
@ -5,8 +5,8 @@ plugins {
|
||||
group = 'de.steamwar'
|
||||
version = ''
|
||||
|
||||
sourceCompatibility = 8
|
||||
targetCompatibility = 8
|
||||
sourceCompatibility = 11
|
||||
targetCompatibility = 11
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
@ -36,8 +36,7 @@ dependencies {
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||
|
||||
compileOnly 'net.md-5:bungeecord-api:1.21-R0.1-SNAPSHOT'
|
||||
compileOnly 'net.md-5:bungeecord-proxy:1.21-R0.1-SNAPSHOT'
|
||||
// compileOnly 'codecrafter47.bungeetablistplus:bungeetablistplus-api-bungee:3.5.2'
|
||||
implementation 'it.unimi.dsi:fastutil-core:8.5.15'
|
||||
compileOnly 'net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT'
|
||||
compileOnly 'net.md-5:bungeecord-proxy:1.20-R0.3-SNAPSHOT'
|
||||
// implementation 'codecrafter47.bungeetablistplus:bungeetablistplus-api-bungee:3.5.2'
|
||||
}
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
name: SteamWarTeamserverIntegration
|
||||
version: '1.0.0'
|
||||
version: 1.0.0
|
||||
main: de.steamwar.SteamWarBungeeTeamserver
|
||||
|
||||
softDepends:
|
||||
- BungeeTabListPlus
|
||||
|
||||
@ -20,9 +20,8 @@
|
||||
package de.steamwar.listener;
|
||||
|
||||
import de.steamwar.ConfigSystem;
|
||||
import de.steamwar.utils.BungeeTabListPlusFixer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
@ -32,14 +31,15 @@ import net.md_5.bungee.connection.InitialHandler;
|
||||
import net.md_5.bungee.connection.LoginResult;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.Handshake;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
@ -61,33 +61,31 @@ public class SteamwarConnectionListener implements Listener {
|
||||
|
||||
{
|
||||
try {
|
||||
Protocol.DirectionData directionData = Protocol.HANDSHAKE.TO_SERVER;
|
||||
Field directionDataProtocols = Protocol.DirectionData.class.getDeclaredField("protocols");
|
||||
directionDataProtocols.setAccessible(true);
|
||||
Int2ObjectMap protocols = (Int2ObjectMap) directionDataProtocols.get(directionData);
|
||||
|
||||
Class<?> protocolDataClass = Class.forName("net.md_5.bungee.protocol.Protocol$ProtocolData");
|
||||
Field protocolDataPacketMap = protocolDataClass.getDeclaredField("packetMap");
|
||||
protocolDataPacketMap.setAccessible(true);
|
||||
Field protocolDataPacketConstructors = protocolDataClass.getDeclaredField("packetConstructors");
|
||||
protocolDataPacketConstructors.setAccessible(true);
|
||||
|
||||
Method mapMethod = Protocol.class.getDeclaredMethod("map", int.class, int.class);
|
||||
mapMethod.setAccessible(true);
|
||||
Object protocolMapping = mapMethod.invoke(null, ProtocolConstants.MINECRAFT_1_8, 0x00);
|
||||
Field protocolMappingPacketId = protocolMapping.getClass().getDeclaredField("packetID");
|
||||
protocolMappingPacketId.setAccessible(true);
|
||||
int packetID = protocolMappingPacketId.getInt(protocolMapping);
|
||||
|
||||
for (int version : ProtocolConstants.SUPPORTED_VERSION_IDS) {
|
||||
Object protocolData = protocols.get(version);
|
||||
|
||||
Object2IntMap<Class<? extends DefinedPacket>> packetMap = (Object2IntMap<Class<? extends DefinedPacket>>) protocolDataPacketMap.get(protocolData);
|
||||
Supplier<? extends DefinedPacket>[] packetConstructors = (Supplier<? extends DefinedPacket>[]) protocolDataPacketConstructors.get(protocolData);
|
||||
|
||||
packetMap.put(Handshake.class, packetID);
|
||||
packetConstructors[packetID] = SteamwarHandshake::new;
|
||||
Class<?> directionDataClazz = Class.forName("net.md_5.bungee.protocol.Protocol$DirectionData");
|
||||
Class<?> protocolMappingClazz = Class.forName("net.md_5.bungee.protocol.Protocol$ProtocolMapping");
|
||||
Field field = Protocol.class.getDeclaredField("TO_SERVER");
|
||||
field.setAccessible(true);
|
||||
Object o = field.get(Protocol.HANDSHAKE);
|
||||
Method method = Arrays.stream(directionDataClazz.getDeclaredMethods())
|
||||
.filter(m -> m.getName().equals("registerPacket"))
|
||||
.filter(m -> m.getParameterCount() == 3)
|
||||
.filter(m -> m.getParameterTypes()[0] == Class.class)
|
||||
.filter(m -> m.getParameterTypes()[1] == Supplier.class)
|
||||
.filter(m -> m.getParameterTypes()[2].isArray())
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new RuntimeException("Could not find registerPacket method"));
|
||||
method.setAccessible(true);
|
||||
Object protocolMappingArray = Array.newInstance(protocolMappingClazz, 1);
|
||||
Array.set(protocolMappingArray, 0, protocolMapping);
|
||||
method.invoke(o, Handshake.class, new Supplier<Handshake>() {
|
||||
@Override
|
||||
public Handshake get() {
|
||||
return new SteamwarHandshake();
|
||||
}
|
||||
}, protocolMappingArray);
|
||||
|
||||
chField = InitialHandler.class.getDeclaredField("ch");
|
||||
chField.setAccessible(true);
|
||||
@ -160,10 +158,8 @@ public class SteamwarConnectionListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
if (BungeeCord.getInstance().getPluginManager().getPlugin("BungeeTabListPlus") != null) {
|
||||
BungeeTabListPlusFixer.remove(postLoginEvent.getPlayer());
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,18 +19,25 @@
|
||||
|
||||
package de.steamwar.utils;
|
||||
|
||||
import codecrafter47.bungeetablistplus.api.bungee.BungeeTabListPlusAPI;
|
||||
import de.codecrafter47.taboverlay.TabView;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@UtilityClass
|
||||
public class BungeeTabListPlusFixer {
|
||||
|
||||
public static void remove(ProxiedPlayer player) {
|
||||
TabView tabView = BungeeTabListPlusAPI.getTabViewForPlayer(player);
|
||||
try {
|
||||
Class clazz = Class.forName("codecrafter47.bungeetablistplus.api.bungee.BungeeTabListPlusAPI");
|
||||
Method getTabViewForPlayer = clazz.getMethod("getTabViewForPlayer", ProxiedPlayer.class);
|
||||
Object tabView = getTabViewForPlayer.invoke(null, player);
|
||||
if (tabView != null) {
|
||||
tabView.deactivate();
|
||||
Method deactivate = getTabViewForPlayer.getReturnType().getMethod("deactivate");
|
||||
deactivate.invoke(tabView);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user