Added unregister method to AuthMeInventoryPacketAdapter class.

more reload compatibility.
This commit is contained in:
DNx5 2015-11-26 03:40:30 +07:00
parent 2162a4abe4
commit 25ed44f801
3 changed files with 43 additions and 24 deletions

View File

@ -691,7 +691,7 @@ public class AuthMe extends JavaPlugin {
} }
} else { } else {
if (inventoryProtector != null) { if (inventoryProtector != null) {
ProtocolLibrary.getProtocolManager().removePacketListener(inventoryProtector); inventoryProtector.unregister();
inventoryProtector = null; inventoryProtector = null;
} }
} }

View File

@ -78,6 +78,10 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
ProtocolLibrary.getProtocolManager().addPacketListener(this); ProtocolLibrary.getProtocolManager().addPacketListener(this);
} }
public void unregister() {
ProtocolLibrary.getProtocolManager().removePacketListener(this);
}
/** /**
* Method sendInventoryPacket. * Method sendInventoryPacket.
* *

View File

@ -36,20 +36,26 @@ public class AuthMeServerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onServerPing(ServerListPingEvent event) { public void onServerPing(ServerListPingEvent event) {
if (!Settings.enableProtection) if (!Settings.enableProtection) {
return; return;
if (Settings.countries.isEmpty())
return;
if (!Settings.countriesBlacklist.isEmpty()) {
if (Settings.countriesBlacklist.contains(GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress())))
event.setMotd(m.send("country_banned")[0]);
} }
if (Settings.countries.contains(GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress()))) {
String countryCode = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
if (!Settings.countriesBlacklist.isEmpty()) {
if (Settings.countriesBlacklist.contains(countryCode)) {
event.setMotd(m.send("country_banned")[0]);
return;
}
}
if (!Settings.countries.isEmpty()) {
if (Settings.countries.contains(countryCode)) {
event.setMotd(plugin.getServer().getMotd()); event.setMotd(plugin.getServer().getMotd());
} else { } else {
event.setMotd(m.send("country_banned")[0]); event.setMotd(m.send("country_banned")[0]);
} }
} }
}
/** /**
* Method onPluginDisable. * Method onPluginDisable.
@ -58,16 +64,18 @@ public class AuthMeServerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPluginDisable(PluginDisableEvent event) { public void onPluginDisable(PluginDisableEvent event) {
// Make sure the plugin instance isn't null
if (event.getPlugin() == null) {
return;
}
// Get the plugin instance // Get the plugin instance
Plugin pluginInstance = event.getPlugin(); Plugin pluginInstance = event.getPlugin();
// Make sure the plugin instance isn't null
if (pluginInstance == null)
return;
// Make sure it's not this plugin itself // Make sure it's not this plugin itself
if (pluginInstance.equals(this.plugin)) if (pluginInstance.equals(this.plugin)) {
return; return;
}
// Call the onPluginDisable method in the permissions manager // Call the onPluginDisable method in the permissions manager
this.plugin.getPermissionsManager().onPluginDisable(event); this.plugin.getPermissionsManager().onPluginDisable(event);
@ -91,6 +99,7 @@ public class AuthMeServerListener implements Listener {
if (pluginName.equalsIgnoreCase("CombatTagPlus")) { if (pluginName.equalsIgnoreCase("CombatTagPlus")) {
plugin.combatTagPlus = null; plugin.combatTagPlus = null;
ConsoleLogger.info("CombatTagPlus has been disabled, unhook!"); ConsoleLogger.info("CombatTagPlus has been disabled, unhook!");
return;
} }
if (pluginName.equalsIgnoreCase("ProtocolLib")) { if (pluginName.equalsIgnoreCase("ProtocolLib")) {
plugin.inventoryProtector = null; plugin.inventoryProtector = null;
@ -109,12 +118,18 @@ public class AuthMeServerListener implements Listener {
this.plugin.getPermissionsManager().onPluginEnable(event); this.plugin.getPermissionsManager().onPluginEnable(event);
String pluginName = event.getPlugin().getName(); String pluginName = event.getPlugin().getName();
if (pluginName.equalsIgnoreCase("Essentials") || pluginName.equalsIgnoreCase("EssentialsSpawn")) if (pluginName.equalsIgnoreCase("Essentials") || pluginName.equalsIgnoreCase("EssentialsSpawn")) {
plugin.checkEssentials(); plugin.checkEssentials();
if (pluginName.equalsIgnoreCase("Multiverse-Core")) return;
}
if (pluginName.equalsIgnoreCase("Multiverse-Core")) {
plugin.checkMultiverse(); plugin.checkMultiverse();
if (pluginName.equalsIgnoreCase("CombatTagPlus")) return;
}
if (pluginName.equalsIgnoreCase("CombatTagPlus")) {
plugin.checkCombatTagPlus(); plugin.checkCombatTagPlus();
return;
}
if (pluginName.equalsIgnoreCase("ProtocolLib")) { if (pluginName.equalsIgnoreCase("ProtocolLib")) {
plugin.checkProtocolLib(); plugin.checkProtocolLib();
} }