Skip to content

Commit

Permalink
Clear registered hooks on disable. + comments + messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Jul 16, 2014
1 parent 7169788 commit 616e543
Showing 1 changed file with 5 additions and 8 deletions.
Expand Up @@ -25,13 +25,13 @@ public class ProtocolLibComponent implements DisableListener{
public ProtocolLibComponent(Plugin plugin) {
// Register with ProtocolLib
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.
List<Class<? extends PacketAdapter>> adapterClasses = Arrays.asList(
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) {
try {
// Construct a new instance using reflection.
Expand All @@ -52,13 +52,10 @@ public void onDisable() {
try {
protocolManager.removePacketListener(adapter);
} 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();
}





}

0 comments on commit 616e543

Please sign in to comment.