Dispose of Shop if the InventoryOpenEvent gets cancelled
This commit is contained in:
parent
2008dae57b
commit
ee64ff2bf6
@ -5,24 +5,22 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.npc.event.NpcDamageByEntityEvent;
|
||||
import mineplex.core.npc.event.NpcInteractEntityEvent;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
@ -159,6 +157,25 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
OpenedShop.remove(event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryOpen(InventoryOpenEvent event)
|
||||
{
|
||||
if (!event.isCancelled())
|
||||
return;
|
||||
|
||||
if (PlayerPageMap.containsKey(event.getPlayer().getName()) && PlayerPageMap.get(event.getPlayer().getName()).getTitle() != null && PlayerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle()))
|
||||
{
|
||||
PlayerPageMap.get(event.getPlayer().getName()).PlayerClosed();
|
||||
PlayerPageMap.get(event.getPlayer().getName()).Dispose();
|
||||
|
||||
PlayerPageMap.remove(event.getPlayer().getName());
|
||||
|
||||
CloseShopForPlayer((Player)event.getPlayer());
|
||||
|
||||
OpenedShop.remove(event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean CanOpenShop(Player player)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user