public class Utils extends Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static org.bukkit.inventory.ItemStack |
decode(String string)
Decodes an
ItemStack from a Base64 String |
static String |
encode(org.bukkit.inventory.ItemStack itemStack)
Encodes an
ItemStack in a Base64 String |
static int |
getAmount(org.bukkit.inventory.Inventory inventory,
org.bukkit.inventory.ItemStack itemStack)
Gets the amount of items in an inventory
|
static Class<?> |
getCraftClass(String className) |
static int |
getFreeSpaceForItem(org.bukkit.inventory.Inventory inventory,
org.bukkit.inventory.ItemStack itemStack)
Get the amount of the given item, that fits in the given inventory
|
static org.bukkit.inventory.ItemStack |
getItemInMainHand(org.bukkit.entity.Player p) |
static org.bukkit.inventory.ItemStack |
getItemInOffHand(org.bukkit.entity.Player p) |
static int |
getMajorVersion() |
static Class<?> |
getNMSClass(String className) |
static org.bukkit.inventory.ItemStack |
getPreferredItemInHand(org.bukkit.entity.Player p) |
static int |
getRevision() |
static String |
getServerVersion() |
static boolean |
hasAxeInHand(org.bukkit.entity.Player p) |
static boolean |
hasPermissionToCreateShop(org.bukkit.entity.Player player,
org.bukkit.inventory.ItemStack item,
boolean buy,
boolean sell)
Check if a player is allowed to create a shop that sells or buys the given item.
|
static boolean |
isFlagAllowedOnPlot(com.intellectualcrafters.plot.object.Plot plot,
com.intellectualcrafters.plot.flag.Flag flag,
org.bukkit.entity.Player p)
Check if a flag is allowed for a player on a plot from PlotSquared
|
static boolean |
isItemSimilar(org.bukkit.inventory.ItemStack itemStack1,
org.bukkit.inventory.ItemStack itemStack2)
Check if two items are similar to each other
|
static boolean |
sendPacket(ShopChest plugin,
Object packet,
org.bukkit.entity.Player player)
Send a packet to a player
|
public static boolean isItemSimilar(org.bukkit.inventory.ItemStack itemStack1, org.bukkit.inventory.ItemStack itemStack2)
itemStack1
- The first itemitemStack2
- The second itemtrue
if the given items are similar or false
if notpublic static int getAmount(org.bukkit.inventory.Inventory inventory, org.bukkit.inventory.ItemStack itemStack)
inventory
- The inventory, in which the items are counteditemStack
- The items to countpublic static int getFreeSpaceForItem(org.bukkit.inventory.Inventory inventory, org.bukkit.inventory.ItemStack itemStack)
inventory
- Inventory, where to search for free spaceitemStack
- Item, of which the amount that fits in the inventory should be returnedpublic static org.bukkit.inventory.ItemStack getItemInMainHand(org.bukkit.entity.Player p)
p
- Player whose item in his main hand should be returnedItemStack
in his main hand, or null
if he doesn't hold onepublic static org.bukkit.inventory.ItemStack getItemInOffHand(org.bukkit.entity.Player p)
p
- Player whose item in his off hand should be returnedItemStack
in his off hand, or null
if he doesn't hold one or the server version is below 1.9public static org.bukkit.inventory.ItemStack getPreferredItemInHand(org.bukkit.entity.Player p)
p
- Player whose item in his hand should be returnednull
if he doesn't have one in both handspublic static boolean hasAxeInHand(org.bukkit.entity.Player p)
p
- Player to check if he has an axe in one of his handspublic static boolean isFlagAllowedOnPlot(com.intellectualcrafters.plot.object.Plot plot, com.intellectualcrafters.plot.flag.Flag flag, org.bukkit.entity.Player p)
plot
- Plot from PlotSquaredflag
- Flag to checkp
- Player to checkpublic static boolean hasPermissionToCreateShop(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item, boolean buy, boolean sell)
Check if a player is allowed to create a shop that sells or buys the given item.
player
- Player to checkitem
- Item to be sold or boughtbuy
- Whether buying should be enabledsell
- Whether selling should be enabledpublic static Class<?> getNMSClass(String className)
className
- Name of the classnet.minecraft.server.[VERSION]
package with the specified name or null
if the class was not foundpublic static Class<?> getCraftClass(String className)
className
- Name of the classorg.bukkit.craftbukkit.[VERSION]
package with the specified name or null
if the class was not foundpublic static boolean sendPacket(ShopChest plugin, Object packet, org.bukkit.entity.Player player)
packet
- Packet to sendplayer
- Player to which the packet should be senttrue
if the packet was sent, or false
if an exception was thrownpublic static String getServerVersion()
public static int getRevision()
public static int getMajorVersion()
public static String encode(org.bukkit.inventory.ItemStack itemStack)
ItemStack
in a Base64 StringitemStack
- ItemStack
to encodepublic static org.bukkit.inventory.ItemStack decode(String string)
ItemStack
from a Base64 Stringstring
- Base64 encoded String to decodeItemStack
Copyright © 2017. All rights reserved.