From e060fd359e6be8cab3abf0c80c8ee9ac56654088 Mon Sep 17 00:00:00 2001 From: Jascha Starke Date: Mon, 21 Oct 2013 08:49:42 +0200 Subject: [PATCH] Removed AuthMe3-Integration on Xephis explicit wish... .. as everything now is handled by AuthMe without issues --- .../minecraft/limitedcreative/Hooks.java | 14 ---- .../limitedcreative/ModBlockStates.java | 3 + .../limitedcreative/ModInventories.java | 5 -- .../minecraft/limitedcreative/ModRegions.java | 4 -- .../limitedcreative/hooks/AuthMe3Hooks.java | 69 ------------------- .../inventories/AuthMe3Inventories.java | 52 -------------- 6 files changed, 3 insertions(+), 144 deletions(-) delete mode 100644 src/main/java/de/jaschastarke/minecraft/limitedcreative/hooks/AuthMe3Hooks.java delete mode 100644 src/main/java/de/jaschastarke/minecraft/limitedcreative/inventories/AuthMe3Inventories.java diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/Hooks.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/Hooks.java index 8c4266f..009e323 100644 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/Hooks.java +++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/Hooks.java @@ -4,7 +4,6 @@ import org.bukkit.Bukkit; import de.jaschastarke.hooking.BooleanHooker; import de.jaschastarke.hooking.GetHooker; -import de.jaschastarke.minecraft.limitedcreative.hooks.AuthMe3Hooks; import de.jaschastarke.minecraft.limitedcreative.hooks.AuthMeHooks; import de.jaschastarke.minecraft.limitedcreative.hooks.MultiVerseHooks; import de.jaschastarke.minecraft.limitedcreative.hooks.PlayerCheckHooker; @@ -29,8 +28,6 @@ public final class Hooks { if (isAuthMePresent()) { new AuthMeHooks(plugin); - } else if (isAuthMe3Present()) { - plugin.getModules().addSharedModule(new AuthMe3Hooks(plugin)); } if (isXAuth20Present()) { new xAuthHooks(plugin); @@ -64,17 +61,6 @@ public final class Hooks { return false; } - public static boolean isAuthMe3Present() { - if (isPluginEnabled("AuthMe")) { - try { - return Class.forName("fr.xephi.authme.api.API") != null; - } catch (ClassNotFoundException e) { - return false; - } - } - return false; - } - public static boolean isXAuth20Present() { if (isPluginEnabled("xAuth")) { try { diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModBlockStates.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModBlockStates.java index f47c21e..105c5fe 100644 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModBlockStates.java +++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModBlockStates.java @@ -90,6 +90,9 @@ public class ModBlockStates extends CoreModule { if (model != null && model instanceof Listener) listeners.removeListener((Listener) model); model = null; + + plugin.getCommandHandler().removeCommand(command); + plugin.getMainCommand().removeCommand(command); } public BlockStateConfig getConfig() { diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModInventories.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModInventories.java index 3fcbc30..e26cd41 100644 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModInventories.java +++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModInventories.java @@ -9,9 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import de.jaschastarke.bukkit.lib.CoreModule; -import de.jaschastarke.minecraft.limitedcreative.hooks.AuthMe3Hooks; import de.jaschastarke.minecraft.limitedcreative.inventories.ArmoryConfig; -import de.jaschastarke.minecraft.limitedcreative.inventories.AuthMe3Inventories; import de.jaschastarke.minecraft.limitedcreative.inventories.AuthMeInventories; import de.jaschastarke.minecraft.limitedcreative.inventories.Inventory; import de.jaschastarke.minecraft.limitedcreative.inventories.InventoryConfig; @@ -45,9 +43,6 @@ public class ModInventories extends CoreModule { if (Hooks.isAuthMePresent()) { addModule(new AuthMeInventories(plugin, this)); - } else if (Hooks.isAuthMe3Present()) { - modules.linkSharedModule(AuthMe3Hooks.class, plugin.getModules()); - addModule(new AuthMe3Inventories(plugin, this)); } String incomp = Hooks.InventoryIncompatible.test(); if (config.getEnabled() && incomp != null) { diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModRegions.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModRegions.java index 8f1ce93..4ebffc9 100644 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModRegions.java +++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModRegions.java @@ -6,7 +6,6 @@ import org.bukkit.entity.Player; import de.jaschastarke.bukkit.lib.CoreModule; import de.jaschastarke.bukkit.lib.commands.AliasHelpedCommand; -import de.jaschastarke.minecraft.limitedcreative.hooks.AuthMe3Hooks; import de.jaschastarke.minecraft.limitedcreative.regions.BlockListener; import de.jaschastarke.minecraft.limitedcreative.regions.IWorldGuardIntegration; import de.jaschastarke.minecraft.limitedcreative.regions.PlayerData; @@ -50,9 +49,6 @@ public class ModRegions extends CoreModule { entry.deactivateUsage(); return; } - if (Hooks.isAuthMe3Present()) { - modules.linkSharedModule(AuthMe3Hooks.class, plugin.getModules()); - } command = new RegionsCommand(this); diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/hooks/AuthMe3Hooks.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/hooks/AuthMe3Hooks.java deleted file mode 100644 index 9a894bf..0000000 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/hooks/AuthMe3Hooks.java +++ /dev/null @@ -1,69 +0,0 @@ -package de.jaschastarke.minecraft.limitedcreative.hooks; - -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.plugin.IllegalPluginAccessException; - -import de.jaschastarke.bukkit.lib.SimpleModule; -import de.jaschastarke.minecraft.limitedcreative.Hooks; -import de.jaschastarke.minecraft.limitedcreative.LimitedCreative; -import fr.xephi.authme.api.API; -import fr.xephi.authme.events.LoginEvent; - -public class AuthMe3Hooks extends SimpleModule implements Listener { - private Map users = new HashMap(); - private PlayerCheckHooker.Check check; - public AuthMe3Hooks(final LimitedCreative plugin) { - super(plugin); - check = new PlayerCheckHooker.Check() { - @Override - public boolean test(Player player) { - if (users.containsKey(player.getName())) { - if (plugin.isDebug()) // not nessesary, but so no string concation without debug needed - plugin.getLog().debug("AuthMe: "+player.getName()+": Event logged in: "+users.get(player.getName())); - return users.get(player.getName()); - } else { - boolean li = API.isAuthenticated(player); - if (plugin.isDebug()) // not nessesary, but so no string concation without debug needed - plugin.getLog().debug("AuthMe: "+player.getName()+": logged in: "+li); - return li; - } - } - }; - } - - @Override - public void onEnable() { - try { - super.onEnable(); - } catch (IllegalPluginAccessException e) { - enabled = true; - plugin.getLog().warn("AuthMe 3.0 Bug detected. Update AuthMe to a newer version as soon as avilable."); - } - Hooks.IsLoggedIn.register(check); - } - - @Override - public void onDisable() { - super.onDisable(); - Hooks.IsLoggedIn.unregister(check); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerLogin(PlayerLoginEvent event) { - if (event.getPlayer() == null) - return; - users.put(event.getPlayer().getName(), API.isAuthenticated(event.getPlayer())); - } - - @EventHandler - public void onAuthMeLogin(LoginEvent event) { - users.put(event.getPlayer().getName(), true); - } -} diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/inventories/AuthMe3Inventories.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/inventories/AuthMe3Inventories.java deleted file mode 100644 index 3707bdd..0000000 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/inventories/AuthMe3Inventories.java +++ /dev/null @@ -1,52 +0,0 @@ -package de.jaschastarke.minecraft.limitedcreative.inventories; - -import org.bukkit.GameMode; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -import de.jaschastarke.bukkit.lib.SimpleModule; -import de.jaschastarke.minecraft.limitedcreative.LimitedCreative; -import de.jaschastarke.minecraft.limitedcreative.ModInventories; -import fr.xephi.authme.events.RestoreInventoryEvent; -import fr.xephi.authme.events.StoreInventoryEvent; - -public class AuthMe3Inventories extends SimpleModule implements Listener { - ModInventories invmod; - public AuthMe3Inventories(LimitedCreative plugin, ModInventories modInventories) { - super(plugin); - invmod = modInventories; - } - - @EventHandler - public void onStoreInventory(StoreInventoryEvent event) { - if (isDebug()) - getLog().debug("AuthMe Store Event: "+event.getPlayer().getName()); - - event.getPlayer().closeInventory(); - GameMode cgm = event.getPlayer().getGameMode(); - - if (cgm == GameMode.ADVENTURE && !invmod.getConfig().getSeparateAdventure()) - cgm = GameMode.SURVIVAL; - - if (cgm != GameMode.CREATIVE || invmod.getConfig().getStoreCreative()) { - invmod.getInventory(event.getPlayer()).save(cgm); - } - } - @EventHandler - public void onRestoreInventory(RestoreInventoryEvent event) { - if (isDebug()) - getLog().debug("AuthMe Restore Event: "+event.getPlayer().getName()); - - event.getPlayer().closeInventory(); - GameMode cgm = event.getPlayer().getGameMode(); - - if (cgm == GameMode.ADVENTURE && !invmod.getConfig().getSeparateAdventure()) - cgm = GameMode.SURVIVAL; - - Inventory inv = invmod.getInventory(event.getPlayer()); - if (inv.isStored(cgm)) { - inv.load(cgm); - event.setCancelled(true); - } - } -}