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