Ensure that ProtocolLib discoveres mod-specific packets.
Dieser Commit ist enthalten in:
Ursprung
224b5d7f3e
Commit
351dc7f3df
@ -133,8 +133,8 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
|
|||||||
private AsyncFilterManager asyncFilterManager;
|
private AsyncFilterManager asyncFilterManager;
|
||||||
|
|
||||||
// Valid server and client packets
|
// Valid server and client packets
|
||||||
private Set<Integer> serverPackets;
|
private boolean knowsServerPackets;
|
||||||
private Set<Integer> clientPackets;
|
private boolean knowsClientPackets;
|
||||||
|
|
||||||
// Ensure that we're not performing too may injections
|
// Ensure that we're not performing too may injections
|
||||||
private AtomicInteger phaseLoginCount = new AtomicInteger(0);
|
private AtomicInteger phaseLoginCount = new AtomicInteger(0);
|
||||||
@ -214,8 +214,8 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
|
|||||||
|
|
||||||
// Attempt to load the list of server and client packets
|
// Attempt to load the list of server and client packets
|
||||||
try {
|
try {
|
||||||
this.serverPackets = PacketRegistry.getServerPackets();
|
knowsServerPackets = PacketRegistry.getServerPackets() != null;
|
||||||
this.clientPackets = PacketRegistry.getClientPackets();
|
knowsClientPackets = PacketRegistry.getClientPackets() != null;
|
||||||
} catch (FieldAccessException e) {
|
} catch (FieldAccessException e) {
|
||||||
reporter.reportWarning(this, "Cannot load server and client packet list.", e);
|
reporter.reportWarning(this, "Cannot load server and client packet list.", e);
|
||||||
}
|
}
|
||||||
@ -466,7 +466,8 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
|
|||||||
for (int packetID : packets) {
|
for (int packetID : packets) {
|
||||||
// Only register server packets that are actually supported by Minecraft
|
// Only register server packets that are actually supported by Minecraft
|
||||||
if (side.isForServer()) {
|
if (side.isForServer()) {
|
||||||
if (serverPackets != null && serverPackets.contains(packetID))
|
// Note that we may update the packet list here
|
||||||
|
if (!knowsServerPackets || PacketRegistry.getServerPackets().contains(packetID))
|
||||||
playerInjection.addPacketHandler(packetID);
|
playerInjection.addPacketHandler(packetID);
|
||||||
else
|
else
|
||||||
reporter.reportWarning(this, String.format(
|
reporter.reportWarning(this, String.format(
|
||||||
@ -477,7 +478,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
|
|||||||
|
|
||||||
// As above, only for client packets
|
// As above, only for client packets
|
||||||
if (side.isForClient() && packetInjector != null) {
|
if (side.isForClient() && packetInjector != null) {
|
||||||
if (clientPackets != null && clientPackets.contains(packetID))
|
if (!knowsClientPackets || PacketRegistry.getClientPackets().contains(packetID))
|
||||||
packetInjector.addPacketHandler(packetID);
|
packetInjector.addPacketHandler(packetID);
|
||||||
else
|
else
|
||||||
reporter.reportWarning(this, String.format(
|
reporter.reportWarning(this, String.format(
|
||||||
|
@ -47,8 +47,12 @@ public class PacketRegistry {
|
|||||||
private static Map<Class, Integer> packetToID;
|
private static Map<Class, Integer> packetToID;
|
||||||
|
|
||||||
// Whether or not certain packets are sent by the client or the server
|
// Whether or not certain packets are sent by the client or the server
|
||||||
private static Set<Integer> serverPackets;
|
private static ImmutableSet<Integer> serverPackets;
|
||||||
private static Set<Integer> clientPackets;
|
private static ImmutableSet<Integer> clientPackets;
|
||||||
|
|
||||||
|
// The underlying sets
|
||||||
|
private static Set<Integer> serverPacketsRef;
|
||||||
|
private static Set<Integer> clientPacketsRef;
|
||||||
|
|
||||||
// New proxy values
|
// New proxy values
|
||||||
private static Map<Integer, Class> overwrittenPackets = new HashMap<Integer, Class>();
|
private static Map<Integer, Class> overwrittenPackets = new HashMap<Integer, Class>();
|
||||||
@ -120,21 +124,21 @@ public class PacketRegistry {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static void initializeSets() throws FieldAccessException {
|
private static void initializeSets() throws FieldAccessException {
|
||||||
if (serverPackets == null || clientPackets == null) {
|
if (serverPacketsRef == null || clientPacketsRef == null) {
|
||||||
List<Field> sets = getPacketRegistry().getFieldListByType(Set.class);
|
List<Field> sets = getPacketRegistry().getFieldListByType(Set.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (sets.size() > 1) {
|
if (sets.size() > 1) {
|
||||||
serverPackets = (Set<Integer>) FieldUtils.readStaticField(sets.get(0), true);
|
serverPacketsRef = (Set<Integer>) FieldUtils.readStaticField(sets.get(0), true);
|
||||||
clientPackets = (Set<Integer>) FieldUtils.readStaticField(sets.get(1), true);
|
clientPacketsRef = (Set<Integer>) FieldUtils.readStaticField(sets.get(1), true);
|
||||||
|
|
||||||
// Impossible
|
// Impossible
|
||||||
if (serverPackets == null || clientPackets == null)
|
if (serverPacketsRef == null || clientPacketsRef == null)
|
||||||
throw new FieldAccessException("Packet sets are in an illegal state.");
|
throw new FieldAccessException("Packet sets are in an illegal state.");
|
||||||
|
|
||||||
// NEVER allow callers to modify the underlying sets
|
// NEVER allow callers to modify the underlying sets
|
||||||
serverPackets = ImmutableSet.copyOf(serverPackets);
|
serverPackets = ImmutableSet.copyOf(serverPacketsRef);
|
||||||
clientPackets = ImmutableSet.copyOf(clientPackets);
|
clientPackets = ImmutableSet.copyOf(clientPacketsRef);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new FieldAccessException("Cannot retrieve packet client/server sets.");
|
throw new FieldAccessException("Cannot retrieve packet client/server sets.");
|
||||||
@ -143,6 +147,13 @@ public class PacketRegistry {
|
|||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new FieldAccessException("Cannot access field.", e);
|
throw new FieldAccessException("Cannot access field.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Copy over again if it has changed
|
||||||
|
if (serverPacketsRef != null && serverPacketsRef.size() != serverPackets.size())
|
||||||
|
serverPackets = ImmutableSet.copyOf(serverPacketsRef);
|
||||||
|
if (clientPacketsRef != null && clientPacketsRef.size() != clientPackets.size())
|
||||||
|
clientPackets = ImmutableSet.copyOf(clientPacketsRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren