SHARE
TWEET

Untitled

a guest Aug 12th, 2017 68 in 1 day
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     @Listener
  2.     public void onUse(InteractItemEvent.Primary.MainHand event, @First Player player)
  3.     {
  4.         if((player.hasPermission(Reference.USE) || !Reference.use_perm))
  5.         {
  6.             ItemStack stack = event.getItemStack().createStack();
  7.             String id = Reference.getID(event.getItemStack().createStack());
  8.             List<Text> itemLore = new ArrayList<>();
  9.             char hand = 'm';
  10.             System.out.println(hand+" MAIN USE");
  11.             HandUse(player, stack, id, itemLore, hand);
  12.         }
  13.     }
  14.     private void HandUse(Player player, ItemStack stack, String id, List<Text> itemLore, char hand)
  15.     {
  16.         if (stack.get(Keys.ITEM_LORE).isPresent())
  17.         {
  18.             for(int i=0; i<stack.get(Keys.ITEM_LORE).get().size();i++)
  19.             {
  20.                 if(stack.get(Keys.ITEM_LORE).get().get(i).toPlain().startsWith("UUID: "))
  21.                 {
  22.                     String UUID = stack.get(Keys.ITEM_LORE).get().get(i).toPlain().substring(6);
  23.                     if(!(UUID.equals(player.getUniqueId().toString()))) {
  24.                         errorMessage(player);
  25.                     }
  26.                     break;
  27.                 }
  28.             }
  29.         }
  30.         else if (Reference.sb_use.contains(id))
  31.         {
  32.             itemLore.add(Text.of("Bound to: "+player.getName()));
  33.             itemLore.add(Text.of("UUID: "+player.getUniqueId()));
  34.             stack.offer(Keys.ITEM_LORE, itemLore);
  35.             retHand(player, stack, hand);
  36.         }
  37.     }
  38.    private void retHand(Player player, ItemStack stack, char hand)
  39.     {
  40.         if(hand == 'm')
  41.             player.setItemInHand(HandTypes.MAIN_HAND, stack);
  42.         else if(hand == 'o')
  43.             player.setItemInHand(HandTypes.OFF_HAND, stack);
  44.         else
  45.             player.sendMessage(Text.of(TextColors.DARK_RED, "ERROR HAS OCCURRED"));
  46.     }
  47.     private void errorMessage(Player player)
  48.     {
  49.         player.sendMessage(Text.of(TextColors.DARK_RED, "This Item is not Soulbound to you!"));
  50.     }
  51. }
RAW Paste Data
Top