summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-03-16 11:01:56 +0000
committerKHobbits <rob@khobbits.co.uk>2013-03-16 11:01:56 +0000
commitd9a238fb80f01d599df285ee0edaf3955fbbb8a3 (patch)
tree9ed3721da77894e649d8199733ae13bba80a59ee
parent3ddf883d5dff6af67bf31331286bd3a5189ffc17 (diff)
downloadEssentials-d9a238fb80f01d599df285ee0edaf3955fbbb8a3.tar
Essentials-d9a238fb80f01d599df285ee0edaf3955fbbb8a3.tar.gz
Essentials-d9a238fb80f01d599df285ee0edaf3955fbbb8a3.tar.lz
Essentials-d9a238fb80f01d599df285ee0edaf3955fbbb8a3.tar.xz
Essentials-d9a238fb80f01d599df285ee0edaf3955fbbb8a3.zip
Cleanup open inventories
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java29
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandenchant.java3
2 files changed, 28 insertions, 4 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java
index 56cabf6cb..1cb89d532 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java
@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import java.util.logging.Level;
+import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -11,7 +12,7 @@ import org.bukkit.event.server.PluginEnableEvent;
public class EssentialsPluginListener implements Listener, IConf
{
private final transient IEssentials ess;
-
+
public EssentialsPluginListener(final IEssentials ess)
{
this.ess = ess;
@@ -20,7 +21,8 @@ public class EssentialsPluginListener implements Listener, IConf
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(final PluginEnableEvent event)
{
- if (event.getPlugin().getName().equals("EssentialsChat")) {
+ if (event.getPlugin().getName().equals("EssentialsChat"))
+ {
ess.getSettings().setEssentialsChatActive(true);
}
ess.getPermissionsHandler().checkPermissions();
@@ -31,10 +33,31 @@ public class EssentialsPluginListener implements Listener, IConf
}
}
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void cleanupOpenInventories(final PluginDisableEvent event)
+ {
+ for (Player player : ess.getServer().getOnlinePlayers())
+ {
+ User user = ess.getUser(player);
+ if (user.isRecipeSee())
+ {
+ user.getPlayer().getOpenInventory().getTopInventory().clear();
+ user.getPlayer().getOpenInventory().close();
+ user.setRecipeSee(false);
+ }
+ if (user.isInvSee())
+ {
+ user.getPlayer().getOpenInventory().close();
+ user.setInvSee(false);
+ }
+ }
+ }
+
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(final PluginDisableEvent event)
{
- if (event.getPlugin().getName().equals("EssentialsChat")) {
+ if (event.getPlugin().getName().equals("EssentialsChat"))
+ {
ess.getSettings().setEssentialsChatActive(false);
}
ess.getPermissionsHandler().checkPermissions();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
index 1eb895b84..f95b777a2 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
@@ -9,6 +9,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@@ -26,7 +27,7 @@ public class Commandenchant extends EssentialsCommand
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final ItemStack stack = user.getItemInHand();
- if (stack == null)
+ if (stack == null || stack.getType() == Material.AIR)
{
throw new Exception(_("nothingInHand"));
}