SHARE
TWEET

Untitled

a guest Apr 20th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.pattyxdhd.varoxrand.listener;
  2.  
  3. import com.google.common.collect.Lists;
  4. import com.intellectualcrafters.plot.object.PlotPlayer;
  5. import de.pattyxdhd.varoxrand.VaroxRand;
  6. import de.pattyxdhd.varoxrand.data.Data;
  7. import de.pattyxdhd.varoxrand.utils.inventorys.Inventorys;
  8. import de.pattyxdhd.varoxrand.utils.itembuilder.ItemBuilder;
  9. import de.pattyxdhd.varoxrand.utils.itempoint.ItemPoint;
  10. import de.pattyxdhd.varoxrand.utils.plotsquared.PlotAPI;
  11. import de.pattyxdhd.varoxrand.utils.randitem.RandItems;
  12. import org.bukkit.Sound;
  13. import org.bukkit.entity.Player;
  14. import org.bukkit.event.EventHandler;
  15. import org.bukkit.event.Listener;
  16. import org.bukkit.event.inventory.InventoryClickEvent;
  17. import org.bukkit.event.inventory.InventoryCloseEvent;
  18.  
  19. import java.util.List;
  20. import java.util.Random;
  21.  
  22. public class InventoryClickListener implements Listener {
  23.  
  24.  
  25.  
  26.     @EventHandler
  27.     public void onClick(final InventoryClickEvent event){
  28.  
  29.         Player player = ((Player) event.getWhoClicked());
  30.  
  31.         if(event.getClickedInventory() != null){
  32.             if(event.getCurrentItem() != null){
  33.                 if(event.getInventory() != null){
  34.                     if(event.getCurrentItem().getItemMeta() != null){
  35.                         if(Inventorys.getOpened().contains(player)){
  36.                             event.setCancelled(true);
  37.                             if(event.getCurrentItem().getItemMeta().getDisplayName() != null){
  38.                                 RandItems randItems = RandItems.getItemByName(event.getCurrentItem().getItemMeta().getDisplayName());
  39.                                 if(randItems != null){
  40.                                     startAction(player, randItems);
  41.                                 }
  42.                             }
  43.                         }
  44.                     }
  45.                 }
  46.             }
  47.         }
  48.     }
  49.  
  50.     @EventHandler
  51.     public void onClose(final InventoryCloseEvent event){
  52.         if(Inventorys.getOpened().contains(event.getPlayer())){
  53.             Inventorys.getOpened().remove(event.getPlayer());
  54.         }
  55.     }
  56.  
  57.     private void startAction(final Player player, final RandItems randItems){
  58.  
  59.         PlotPlayer plotPlayer = VaroxRand.getApi().wrapPlayer(player);
  60.         String perm = randItems.getName().replace(" ", "");
  61.  
  62.         if(perm.startsWith("ยง")){
  63.             perm = perm.substring(2);
  64.         }
  65.  
  66.         switch (randItems.getWorkingmode()){
  67.             //Main Menu
  68.             case 0:
  69.                 List<ItemPoint> list = Lists.new
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top