Search in sources :

Example 6 with PlotItemStack

use of com.plotsquared.core.plot.PlotItemStack in project PlotSquared by IntellectualSites.

the class BukkitInventoryUtil method getItems.

@Override
public PlotItemStack[] getItems(PlotPlayer<?> player) {
    BukkitPlayer bp = (BukkitPlayer) player;
    PlayerInventory inv = bp.player.getInventory();
    return IntStream.range(0, 36).mapToObj(i -> getItem(inv.getItem(i))).toArray(PlotItemStack[]::new);
}
Also used : PlotItemStack(com.plotsquared.core.plot.PlotItemStack) IntStream(java.util.stream.IntStream) InventoryType(org.bukkit.event.inventory.InventoryType) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Inventory(org.bukkit.inventory.Inventory) ItemStack(org.bukkit.inventory.ItemStack) ArrayList(java.util.ArrayList) InventoryView(org.bukkit.inventory.InventoryView) PlotInventory(com.plotsquared.core.plot.PlotInventory) List(java.util.List) PlotPlayer(com.plotsquared.core.player.PlotPlayer) InventoryUtil(com.plotsquared.core.util.InventoryUtil) BukkitAdapter(com.sk89q.worldedit.bukkit.BukkitAdapter) Component(net.kyori.adventure.text.Component) PlayerInventory(org.bukkit.inventory.PlayerInventory) ChatColor(org.bukkit.ChatColor) BukkitPlayer(com.plotsquared.bukkit.player.BukkitPlayer) Material(org.bukkit.Material) Nullable(org.checkerframework.checker.nullness.qual.Nullable) Singleton(com.google.inject.Singleton) Bukkit(org.bukkit.Bukkit) PlayerInventory(org.bukkit.inventory.PlayerInventory) BukkitPlayer(com.plotsquared.bukkit.player.BukkitPlayer)

Example 7 with PlotItemStack

use of com.plotsquared.core.plot.PlotItemStack in project PlotSquared by IntellectualSites.

the class BukkitInventoryUtil method open.

// Paper deprecation
@SuppressWarnings("deprecation")
@Override
public void open(PlotInventory inv) {
    BukkitPlayer bp = (BukkitPlayer) inv.getPlayer();
    Inventory inventory = Bukkit.createInventory(null, inv.getLines() * 9, ChatColor.translateAlternateColorCodes('&', inv.getTitle()));
    PlotItemStack[] items = inv.getItems();
    for (int i = 0; i < inv.getLines() * 9; i++) {
        PlotItemStack item = items[i];
        if (item != null) {
            inventory.setItem(i, getItem(item));
        }
    }
    bp.player.openInventory(inventory);
}
Also used : PlotItemStack(com.plotsquared.core.plot.PlotItemStack) Inventory(org.bukkit.inventory.Inventory) PlotInventory(com.plotsquared.core.plot.PlotInventory) PlayerInventory(org.bukkit.inventory.PlayerInventory) BukkitPlayer(com.plotsquared.bukkit.player.BukkitPlayer)

Aggregations

PlotItemStack (com.plotsquared.core.plot.PlotItemStack)7 PlotInventory (com.plotsquared.core.plot.PlotInventory)4 BukkitPlayer (com.plotsquared.bukkit.player.BukkitPlayer)3 ArrayList (java.util.ArrayList)3 Material (org.bukkit.Material)3 ItemStack (org.bukkit.inventory.ItemStack)3 ItemMeta (org.bukkit.inventory.meta.ItemMeta)3 Nullable (org.checkerframework.checker.nullness.qual.Nullable)3 Plot (com.plotsquared.core.plot.Plot)2 Component (net.kyori.adventure.text.Component)2 Inventory (org.bukkit.inventory.Inventory)2 InventoryView (org.bukkit.inventory.InventoryView)2 PlayerInventory (org.bukkit.inventory.PlayerInventory)2 Singleton (com.google.inject.Singleton)1 PlotFlagAddEvent (com.plotsquared.core.events.PlotFlagAddEvent)1 PlotFlagRemoveEvent (com.plotsquared.core.events.PlotFlagRemoveEvent)1 Location (com.plotsquared.core.location.Location)1 PlotPlayer (com.plotsquared.core.player.PlotPlayer)1 PlotFlag (com.plotsquared.core.plot.flag.PlotFlag)1 MusicFlag (com.plotsquared.core.plot.flag.implementations.MusicFlag)1