SHARE
TWEET

Untitled

a guest Dec 5th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  extends Menu {
  2.  
  3.     public CosmeticTrailMenu(Player player) {
  4.         super(player, "§8Cosmetics §7| §fTrails", 27);
  5.     }
  6.  
  7.     @Override
  8.     public void click(Profile profile, InventoryClickEvent event) {
  9.         event.setCancelled(true);
  10.  
  11.         ItemStack item = event.getCurrentItem();
  12.  
  13.         String fixed = ChatColor.stripColor(item.getItemMeta().getDisplayName()).replace(" (Active)", "");
  14.  
  15.         Cosmetic cosmetic = getPlugin().getCosmeticHandler().getCosmetic(fixed, TrailCosmetic.class);
  16.  
  17.         ServerUtil.debug("Parsed name: " + fixed, this.getClass(), ServerUtil.getLineOfCode());
  18.  
  19.         if(cosmetic == null || !cosmetic.hasPermission(getPlayer())) {
  20.             return;
  21.         }
  22.  
  23.         ServerUtil.debug("Passed on cosmetic: " + cosmetic.getName(), this.getClass(), ServerUtil.getLineOfCode());
  24.  
  25.         if(profile.getCosmetic() != null) {
  26.             ServerUtil.debug("Cosmetic is not null: " + cosmetic.getName(), this.getClass(), ServerUtil.getLineOfCode());
  27.             if(profile.getCosmetic().equals(cosmetic)) {
  28.                 ServerUtil.debug("Cosmetic does equal: " + cosmetic.getName(), this.getClass(), ServerUtil.getLineOfCode());
  29.                 profile.deactivateCosmetic(getPlayer(), cosmetic);
  30.                 this.getPlayer().closeInventory();
  31.                 this.close(profile, null);
  32.                 return;
  33.             }
  34.  
  35.             profile.deactivateCosmetic(getPlayer(), cosmetic);
  36.         }
  37.  
  38.         profile.activateCosmetic(getPlayer(), cosmetic);
  39.  
  40.         this.getPlayer().closeInventory();
  41.         this.close(profile, null);
  42.     }
  43.  
  44.     @Override
  45.     public void close(Profile profile, InventoryCloseEvent inventoryCloseEvent) {
  46.         profile.setMenu(null);
  47.     }
  48.  
  49.     @Override
  50.     public void open(Profile profile) {
  51.         Inventory inventory = Bukkit.createInventory(null, this.getSize(), this.getTitle());
  52.  
  53.         for(Cosmetic cosmetic : getPlugin().getCosmeticHandler().filterCosmetics(TrailCosmetic.class)) {
  54.             inventory.addItem(cosmetic.getItem(this.getPlayer()));
  55.         }
  56.  
  57.         this.getPlayer().openInventory(inventory);
  58.         profile.setMenu(this);
  59.     }
  60. }
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