ProtocolSupport support added
This commit is contained in:
1 parent
0ed112b6fc
commit
4852e4bfca
8 files changed
+14
-68
No files matched your search
@@ -60,7 +60,7 @@ import java.net.InetSocketAddress;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class PacketEvents implements Listener, EventManager {
|
||||
//TODO finish unfinished wrappers, add protocolsupport support atm it won't let you join...
|
||||
//TODO finish unfinished wrappers, fix packetplayoutposition on 1.16 with new constr argument
|
||||
private static PacketEvents instance;
|
||||
private final PEVersion version = new PEVersion(1, 7, 9, 5);
|
||||
private final EventManager eventManager = new PEEventManager();
|
||||
|
||||
@@ -3,11 +3,13 @@ package io.github.retrooper.packetevents.injector;
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.event.impl.PlayerEjectEvent;
|
||||
import io.github.retrooper.packetevents.event.impl.PlayerInjectEvent;
|
||||
import io.github.retrooper.packetevents.injector.earlyinjector.EarlyInjector;
|
||||
import io.github.retrooper.packetevents.injector.earlyinjector.legacy.EarlyChannelInjectorLegacy;
|
||||
import io.github.retrooper.packetevents.injector.earlyinjector.modern.EarlyChannelInjector;
|
||||
import io.github.retrooper.packetevents.injector.lateinjector.legacy.LateChannelInjectorLegacy;
|
||||
import io.github.retrooper.packetevents.injector.lateinjector.modern.LateChannelInjector;
|
||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||
import io.github.retrooper.packetevents.utils.versionlookup.protocolsupport.ProtocolSupportVersionLookupUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GlobalChannelInjector implements ChannelInjector {
|
||||
|
||||
+6
@@ -25,8 +25,14 @@
|
||||
package io.github.retrooper.packetevents.injector.earlyinjector;
|
||||
|
||||
import io.github.retrooper.packetevents.injector.ChannelInjector;
|
||||
import io.github.retrooper.packetevents.utils.list.ConcurrentList;
|
||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface EarlyInjector extends ChannelInjector {
|
||||
void updatePlayerObject(Player player, Object channel);
|
||||
|
||||
|
||||
-31
@@ -122,10 +122,6 @@ public class EarlyChannelInjectorLegacy implements EarlyInjector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ProtocolSupportVersionLookupUtils.isAvailable()) {
|
||||
patchLists();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -177,33 +173,6 @@ public class EarlyChannelInjectorLegacy implements EarlyInjector {
|
||||
|
||||
}
|
||||
|
||||
public void patchLists() {
|
||||
Object connection = NMSUtils.getMinecraftServerConnection();
|
||||
if (connection == null) {
|
||||
throw new IllegalStateException("Server connection is null?");
|
||||
}
|
||||
|
||||
for (Field field : connection.getClass().getDeclaredFields()) {
|
||||
field.setAccessible(true);
|
||||
Object value = null;
|
||||
try {
|
||||
value = field.get(connection);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!(value instanceof List)) continue;
|
||||
if (value instanceof ConcurrentList) continue;
|
||||
|
||||
ConcurrentList list = new ConcurrentList();
|
||||
list.addAll((Collection) value);
|
||||
try {
|
||||
field.set(connection, list);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eject() {
|
||||
Field childHandlerField = null;
|
||||
|
||||
-31
@@ -122,10 +122,6 @@ public class EarlyChannelInjector implements EarlyInjector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ProtocolSupportVersionLookupUtils.isAvailable()) {
|
||||
patchLists();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -177,33 +173,6 @@ public class EarlyChannelInjector implements EarlyInjector {
|
||||
|
||||
}
|
||||
|
||||
public void patchLists() {
|
||||
Object connection = NMSUtils.getMinecraftServerConnection();
|
||||
if (connection == null) {
|
||||
throw new IllegalStateException("Server connection is null?");
|
||||
}
|
||||
|
||||
for (Field field : connection.getClass().getDeclaredFields()) {
|
||||
field.setAccessible(true);
|
||||
Object value = null;
|
||||
try {
|
||||
value = field.get(connection);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!(value instanceof List)) continue;
|
||||
if (value instanceof ConcurrentList) continue;
|
||||
|
||||
ConcurrentList list = new ConcurrentList();
|
||||
list.addAll((Collection) value);
|
||||
try {
|
||||
field.set(connection, list);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eject() {
|
||||
Field childHandlerField = null;
|
||||
|
||||
+1
@@ -89,6 +89,7 @@ public final class WrappedPacketOutPosition extends WrappedPacket implements Sen
|
||||
} catch (NoSuchMethodException e) {
|
||||
constructorMode = 1;
|
||||
try {
|
||||
net.minecraft.server.v1_16_R2.PacketPlayOutPosition packetPlayOutPosition;
|
||||
//1.8 and above
|
||||
packetConstructor = PacketTypeClasses.Play.Server.POSITION.getConstructor(double.class, double.class, double.class, float.class, float.class, Set.class);
|
||||
} catch (NoSuchMethodException e2) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class PlayerUtils {
|
||||
/**
|
||||
* This is where the most recent non-smoothed player ping that PacketEvents calculates is stored.
|
||||
*/
|
||||
public final Map<UUID, Integer> playerPingMap = new HashMap<>();
|
||||
public final Map<UUID, Integer> playerPingMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* This is where the most recent smoothed player ping that PacketEvents calculates is stored.
|
||||
@@ -59,7 +59,7 @@ public final class PlayerUtils {
|
||||
* Use this to receive a smoothed ping value.
|
||||
* PacketEvents smooths in the same way minecraft does.
|
||||
*/
|
||||
public final Map<UUID, Integer> playerSmoothedPingMap = new HashMap<>();
|
||||
public final Map<UUID, Integer> playerSmoothedPingMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* This map stores the client version of a player only when it has been confirmed.
|
||||
@@ -75,7 +75,7 @@ public final class PlayerUtils {
|
||||
* guaranteed to work!
|
||||
* ProtocolSupport MIGHT work.
|
||||
*/
|
||||
public final HashMap<InetSocketAddress, ClientVersion> clientVersionsMap = new HashMap<>();
|
||||
public final Map<InetSocketAddress, ClientVersion> clientVersionsMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* This is a temporary client version.
|
||||
@@ -86,7 +86,7 @@ public final class PlayerUtils {
|
||||
* ProtocolSupport compatibility might not work.
|
||||
* If ViaVersion or ProtocolSupport aren't available, we will trust this one.
|
||||
*/
|
||||
public final HashMap<InetSocketAddress, ClientVersion> tempClientVersionMap = new HashMap<>();
|
||||
public final Map<InetSocketAddress, ClientVersion> tempClientVersionMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Use reflection to read the ping value NMS calculates for the player.
|
||||
|
||||
-1
@@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class SpigotVersionLookup_1_7 {
|
||||
public static int getProtocolVersion(Player player) {
|
||||
System.out.println("yes");
|
||||
net.minecraft.server.v1_7_R4.EntityPlayer entityPlayer = ((org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer) player).getHandle();
|
||||
return entityPlayer.playerConnection.networkManager.getVersion();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user