Search in sources :

Example 1 with BukkitPlayer

use of com.plotsquared.bukkit.player.BukkitPlayer in project PlotSquared by IntellectualSites.

the class BukkitInventoryUtil method setItemChecked.

@Override
public boolean setItemChecked(PlotInventory inv, int index, PlotItemStack item) {
    BukkitPlayer bp = (BukkitPlayer) inv.getPlayer();
    InventoryView opened = bp.player.getOpenInventory();
    ItemStack stack = getItem(item);
    if (stack == null) {
        return false;
    }
    if (!inv.isOpen()) {
        return true;
    }
    opened.setItem(index, stack);
    bp.player.updateInventory();
    return true;
}
Also used : InventoryView(org.bukkit.inventory.InventoryView) PlotItemStack(com.plotsquared.core.plot.PlotItemStack) ItemStack(org.bukkit.inventory.ItemStack) BukkitPlayer(com.plotsquared.bukkit.player.BukkitPlayer)

Example 2 with BukkitPlayer

use of com.plotsquared.bukkit.player.BukkitPlayer in project PlotSquared by IntellectualSites.

the class BukkitInventoryUtil method isOpen.

// #getTitle is needed for Spigot compatibility
@SuppressWarnings("deprecation")
@Override
public boolean isOpen(PlotInventory plotInventory) {
    if (!plotInventory.isOpen()) {
        return false;
    }
    BukkitPlayer bp = (BukkitPlayer) plotInventory.getPlayer();
    InventoryView opened = bp.player.getOpenInventory();
    if (plotInventory.isOpen()) {
        if (opened.getType() == InventoryType.CRAFTING) {
            opened.getTitle();
        }
    }
    return false;
}
Also used : InventoryView(org.bukkit.inventory.InventoryView) BukkitPlayer(com.plotsquared.bukkit.player.BukkitPlayer)

Example 3 with BukkitPlayer

use of com.plotsquared.bukkit.player.BukkitPlayer in project PlotSquared by IntellectualSites.

the class PlaceholderFormatter method format.

@Override
public void format(@NonNull final ChatContext context) {
    final PlotPlayer<?> recipient = context.getRecipient();
    if (recipient instanceof BukkitPlayer) {
        if (context.isRawOutput()) {
            context.setMessage(context.getMessage().replace('%', '\u2010'));
        } else {
            final Player player = ((BukkitPlayer) recipient).player;
            context.setMessage(PlaceholderAPI.setPlaceholders(player, context.getMessage()));
        }
    }
}
Also used : PlotPlayer(com.plotsquared.core.player.PlotPlayer) Player(org.bukkit.entity.Player) BukkitPlayer(com.plotsquared.bukkit.player.BukkitPlayer) BukkitPlayer(com.plotsquared.bukkit.player.BukkitPlayer)

Example 4 with BukkitPlayer

use of com.plotsquared.bukkit.player.BukkitPlayer 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 5 with BukkitPlayer

use of com.plotsquared.bukkit.player.BukkitPlayer in project PlotSquared by IntellectualSites.

the class BukkitInventoryUtil method close.

@Override
public void close(PlotInventory inv) {
    if (!inv.isOpen()) {
        return;
    }
    BukkitPlayer bp = (BukkitPlayer) inv.getPlayer();
    bp.player.closeInventory();
}
Also used : BukkitPlayer(com.plotsquared.bukkit.player.BukkitPlayer)

Aggregations

BukkitPlayer (com.plotsquared.bukkit.player.BukkitPlayer)6 PlotItemStack (com.plotsquared.core.plot.PlotItemStack)3 InventoryView (org.bukkit.inventory.InventoryView)3 PlotPlayer (com.plotsquared.core.player.PlotPlayer)2 PlotInventory (com.plotsquared.core.plot.PlotInventory)2 Inventory (org.bukkit.inventory.Inventory)2 ItemStack (org.bukkit.inventory.ItemStack)2 PlayerInventory (org.bukkit.inventory.PlayerInventory)2 Singleton (com.google.inject.Singleton)1 InventoryUtil (com.plotsquared.core.util.InventoryUtil)1 BukkitAdapter (com.sk89q.worldedit.bukkit.BukkitAdapter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IntStream (java.util.stream.IntStream)1 Component (net.kyori.adventure.text.Component)1 Bukkit (org.bukkit.Bukkit)1 ChatColor (org.bukkit.ChatColor)1 Material (org.bukkit.Material)1 Player (org.bukkit.entity.Player)1 InventoryType (org.bukkit.event.inventory.InventoryType)1