Advertisement
iSach

Get Full Id String Spigot

Jul 23rd, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. /**
  2. * Gets the full ID of an ItemStack. ID:DATA
  3. *
  4. * @param itemStack The {@see org.bukkit.inventory.ItemStack}.
  5. * @return the full ID of an {@see org.bukkit.inventory.ItemStack}.
  6. */
  7. public String getFullId(ItemStack itemStack) {
  8. // Define a new String builder to append the ID and the data.
  9. StringBuilder stringBuilder = new StringBuilder();
  10.  
  11. // Append the ID.
  12. stringBuilder.append(itemStack.getTypeId());
  13.  
  14. // If the item has a data, we add it.
  15. if (itemStack.getData() != null && itemStack.getData().getData() != 0)
  16. stringBuilder.append(":" + itemStack.getData().getData());
  17.  
  18. // Return the StringBuilder as a String.
  19. return stringBuilder.toString();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement