daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class WorkbenchMenuClickEvent implements Listener {
  2.  
  3.      static Map<UUID, Workbench> inWorkbenchMenu = new HashMap<>();
  4.  
  5.     @EventHandler
  6.     public void onClick(InventoryClickEvent event){
  7.         if(event.getWhoClicked() instanceof Player){
  8.             Player clicker = (Player) event.getWhoClicked();
  9.             Inventory clicked = event.getView().getTopInventory();
  10.  
  11.             boolean namesMatch = false;
  12.             for(int x = 1; x < 3; x++){
  13.                 if(event.getView().getTitle().equals("Workbench Level: "+ x)) namesMatch = true;
  14.             }
  15.  
  16.             if(namesMatch){
  17.                 // in the inventory
  18.                 if(event.getCursor() != null){
  19.                     BluePrintData data = BluePrintData.getSingleton();
  20.                     if(inWorkbenchMenu.keySet().contains(clicker.getUniqueId())){
  21.                         Workbench bench = inWorkbenchMenu.get(clicker.getUniqueId());
  22.                         int level = bench.getLevel();
  23.                         Material material = data.getWorkbenchInputs().get(level).keySet().iterator().next();
  24.                         int amount  = data.getWorkbenchInputs().get(level).get(material);
  25.                         ItemStack cursor = event.getCursor();
  26.                         if(event.getSlot() == 0 || event.getSlot() == 1){
  27.                             if(cursor.getType() == material && cursor.getAmount() >= amount){
  28.                                 RustifiedPlayer player = Rustified.getPlayerObjectFor(clicker);
  29.                                 BluePrint print = data.getRandomBluePrintFor(player, level);
  30.                                 InventoryType.SlotType slotType = event.getView().getSlotType(2);
  31.  
  32.  
  33.                                 //setting the item to slot 2, where the recipes would go iirc
  34.                                 clicked.setItem(2, print.getItem());
  35.  
  36.                                 //sends
  37.                                 Bukkit.broadcastMessage("got here");
  38.                             }
  39.                         }
  40.  
  41.                     }
  42.  
  43.  
  44.                 }
  45.  
  46.             }
  47.  
  48.         }
  49.     }
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top