mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-28 10:21:22 +01:00
Clear registered hooks on disable. + comments + messages.
This commit is contained in:
parent
7169788554
commit
616e5436a2
@ -25,13 +25,13 @@ public class ProtocolLibComponent implements DisableListener{
|
|||||||
public ProtocolLibComponent(Plugin plugin) {
|
public ProtocolLibComponent(Plugin plugin) {
|
||||||
// Register with ProtocolLib
|
// Register with ProtocolLib
|
||||||
final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
LogUtil.logInfo("[NoCheatPlus] ProtocolLib seems to be available.");
|
LogUtil.logInfo("[NoCheatPlus] ProtocolLib seems to be available, attempt to add packet level hooks...");
|
||||||
// Classes having a constructor with Plugin as argument.
|
// Classes having a constructor with Plugin as argument.
|
||||||
List<Class<? extends PacketAdapter>> adapterClasses = Arrays.asList(
|
List<Class<? extends PacketAdapter>> adapterClasses = Arrays.asList(
|
||||||
FlyingFrequency.class,
|
FlyingFrequency.class,
|
||||||
SoundDistance.class
|
SoundDistance.class // Need too: SPAWN_ENTITY_WEATHER, wither/dragon: WORLD_EVENT
|
||||||
);
|
);
|
||||||
// TODO: Configurability.
|
// TODO: Configurability (INotifyConfig, method to set up hooks).
|
||||||
for (Class<? extends PacketAdapter> clazz : adapterClasses) {
|
for (Class<? extends PacketAdapter> clazz : adapterClasses) {
|
||||||
try {
|
try {
|
||||||
// Construct a new instance using reflection.
|
// Construct a new instance using reflection.
|
||||||
@ -52,13 +52,10 @@ public class ProtocolLibComponent implements DisableListener{
|
|||||||
try {
|
try {
|
||||||
protocolManager.removePacketListener(adapter);
|
protocolManager.removePacketListener(adapter);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
LogUtil.logWarning("[NoCheatPlus] Failed to unregister protocol listener: " + adapter.getClass().getName());
|
LogUtil.logWarning("[NoCheatPlus] Failed to unregister packet level hook: " + adapter.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
registeredPacketAdapters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user