Search in sources :

Example 11 with ChestData

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

the class WRegularChest method setPage.

@Override
public Inventory setPage(int page, int size, String title) {
    ChestData chestData = getData();
    checkCapacity(page + 1, chestData.getDefaultSize(), chestData.getDefaultTitle());
    CraftWildInventory inventory = plugin.getNMSInventory().createInventory(this, size, title, page);
    inventories.set(page, inventory);
    updateTitles();
    return inventory;
}
Also used : ChestData(com.bgsoftware.wildchests.api.objects.data.ChestData) CraftWildInventory(com.bgsoftware.wildchests.objects.inventory.CraftWildInventory)

Example 12 with ChestData

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

the class ChestsHandler method loadChest.

public WChest loadChest(UUID placer, Location location, ChestData chestData) {
    WChest chest;
    switch(chestData.getChestType()) {
        case CHEST:
            chest = new WRegularChest(placer, location, chestData);
            break;
        case LINKED_CHEST:
            chest = new WLinkedChest(placer, location, chestData);
            break;
        case STORAGE_UNIT:
            chest = new WStorageChest(placer, location, chestData);
            break;
        default:
            throw new IllegalArgumentException("Invalid chest at " + location);
    }
    chests.put(location, chest);
    chestsByChunks.computeIfAbsent(ChunkPosition.of(location), s -> Sets.newConcurrentHashSet()).add(chest);
    return chest;
}
Also used : ChestData(com.bgsoftware.wildchests.api.objects.data.ChestData) RegularChest(com.bgsoftware.wildchests.api.objects.chests.RegularChest) HashMap(java.util.HashMap) ChunkPosition(com.bgsoftware.wildchests.utils.ChunkPosition) ArrayList(java.util.ArrayList) LinkedChest(com.bgsoftware.wildchests.api.objects.chests.LinkedChest) Location(org.bukkit.Location) WChestData(com.bgsoftware.wildchests.objects.data.WChestData) Executor(com.bgsoftware.wildchests.utils.Executor) Map(java.util.Map) WRegularChest(com.bgsoftware.wildchests.objects.chests.WRegularChest) Chunk(org.bukkit.Chunk) LocationUtils(com.bgsoftware.wildchests.utils.LocationUtils) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) ChestsManager(com.bgsoftware.wildchests.api.handlers.ChestsManager) StorageChest(com.bgsoftware.wildchests.api.objects.chests.StorageChest) Set(java.util.Set) UUID(java.util.UUID) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) WChest(com.bgsoftware.wildchests.objects.chests.WChest) Sets(com.google.common.collect.Sets) ItemStack(org.bukkit.inventory.ItemStack) WildChestsPlugin(com.bgsoftware.wildchests.WildChestsPlugin) List(java.util.List) WLinkedChest(com.bgsoftware.wildchests.objects.chests.WLinkedChest) WStorageChest(com.bgsoftware.wildchests.objects.chests.WStorageChest) Collections(java.util.Collections) Chest(com.bgsoftware.wildchests.api.objects.chests.Chest) WLinkedChest(com.bgsoftware.wildchests.objects.chests.WLinkedChest) WChest(com.bgsoftware.wildchests.objects.chests.WChest) WRegularChest(com.bgsoftware.wildchests.objects.chests.WRegularChest) WStorageChest(com.bgsoftware.wildchests.objects.chests.WStorageChest)

Aggregations

ChestData (com.bgsoftware.wildchests.api.objects.data.ChestData)12 Chest (com.bgsoftware.wildchests.api.objects.chests.Chest)5 WChest (com.bgsoftware.wildchests.objects.chests.WChest)4 WChestData (com.bgsoftware.wildchests.objects.data.WChestData)3 UUID (java.util.UUID)3 Location (org.bukkit.Location)3 Player (org.bukkit.entity.Player)3 EventHandler (org.bukkit.event.EventHandler)3 LinkedChest (com.bgsoftware.wildchests.api.objects.chests.LinkedChest)2 StorageChest (com.bgsoftware.wildchests.api.objects.chests.StorageChest)2 InventoryData (com.bgsoftware.wildchests.api.objects.data.InventoryData)2 WLinkedChest (com.bgsoftware.wildchests.objects.chests.WLinkedChest)2 WRegularChest (com.bgsoftware.wildchests.objects.chests.WRegularChest)2 WStorageChest (com.bgsoftware.wildchests.objects.chests.WStorageChest)2 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 Material (org.bukkit.Material)2 Block (org.bukkit.block.Block)2 ItemStack (org.bukkit.inventory.ItemStack)2