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 String |
getServerVersion() |
static boolean |
isUUID(String string)
Checks if a given String is a UUID
|
static boolean |
sendPacket(ShopChest plugin,
Object packet,
org.bukkit.entity.Player player)
Send a packet to a player
|
public 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 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 getMajorVersion()
public static boolean isUUID(String string)
string
- String to checkpublic 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 © 2016. All rights reserved.