Search in sources :

Example 11 with Chest

use of com.bgsoftware.wildchests.api.objects.chests.Chest in project WildChests by BG-Software-LLC.

the class InventoryListener method onChestOpen.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChestOpen(PlayerInteractEvent e) {
    if (e instanceof LinkedChestInteractEvent || e.getAction() != Action.RIGHT_CLICK_BLOCK || e.getClickedBlock().getType() != Material.CHEST)
        return;
    if (buyNewPage.containsKey(e.getPlayer().getUniqueId())) {
        e.setCancelled(true);
        return;
    }
    Chest chest = plugin.getChestsManager().getChest(e.getClickedBlock().getLocation());
    if (chest == null)
        return;
    plugin.getNMSInventory().updateTileEntity(chest);
    chest.onOpen(e);
}
Also used : WChest(com.bgsoftware.wildchests.objects.chests.WChest) Chest(com.bgsoftware.wildchests.api.objects.chests.Chest) LinkedChestInteractEvent(com.bgsoftware.wildchests.utils.LinkedChestInteractEvent) EventHandler(org.bukkit.event.EventHandler)

Example 12 with Chest

use of com.bgsoftware.wildchests.api.objects.chests.Chest in project WildChests by BG-Software-LLC.

the class InventoryListener method onChestInteract.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChestInteract(InventoryClickEvent e) {
    Inventory clickedInventory = e.getView().getTopInventory();
    if (!(clickedInventory instanceof CraftWildInventory))
        return;
    Chest chest = ((CraftWildInventory) clickedInventory).getOwner();
    chest.onInteract(e);
}
Also used : WChest(com.bgsoftware.wildchests.objects.chests.WChest) Chest(com.bgsoftware.wildchests.api.objects.chests.Chest) CraftWildInventory(com.bgsoftware.wildchests.objects.inventory.CraftWildInventory) CraftWildInventory(com.bgsoftware.wildchests.objects.inventory.CraftWildInventory) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Chest (com.bgsoftware.wildchests.api.objects.chests.Chest)12 WChest (com.bgsoftware.wildchests.objects.chests.WChest)7 ChestData (com.bgsoftware.wildchests.api.objects.data.ChestData)6 ArrayList (java.util.ArrayList)6 EventHandler (org.bukkit.event.EventHandler)6 LinkedChest (com.bgsoftware.wildchests.api.objects.chests.LinkedChest)4 Chunk (org.bukkit.Chunk)4 StorageChest (com.bgsoftware.wildchests.api.objects.chests.StorageChest)3 WLinkedChest (com.bgsoftware.wildchests.objects.chests.WLinkedChest)3 WRegularChest (com.bgsoftware.wildchests.objects.chests.WRegularChest)3 WStorageChest (com.bgsoftware.wildchests.objects.chests.WStorageChest)3 Material (org.bukkit.Material)3 World (org.bukkit.World)3 Block (org.bukkit.block.Block)3 Player (org.bukkit.entity.Player)3 Inventory (org.bukkit.inventory.Inventory)3 WildChestsPlugin (com.bgsoftware.wildchests.WildChestsPlugin)2 Executor (com.bgsoftware.wildchests.utils.Executor)2 LinkedChestInteractEvent (com.bgsoftware.wildchests.utils.LinkedChestInteractEvent)2 LocationUtils (com.bgsoftware.wildchests.utils.LocationUtils)2