mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-27 03:28:30 +01:00
Cleanup open inventories
This commit is contained in:
parent
3ddf883d5d
commit
d9a238fb80
@ -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();
|
||||
|
@ -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"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user