SHARE
TWEET

Untitled

a guest May 26th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.mrcookies.pvpsword.listeners;
  2.  
  3. import fr.cocoraid.prodigygadget.ProdigyPlayer;
  4. import me.mrcookies.pvpsword.Core;
  5. import me.mrcookies.pvpsword.utility.ToolbarManager;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.block.Action;
  10. import org.bukkit.event.player.PlayerInteractEvent;
  11. import org.bukkit.inventory.ItemStack;
  12.  
  13. public class ItemClickListener implements Listener {
  14.  
  15.     private Core core = Core.getPlugin(Core.class);
  16.     private ToolbarManager tool;
  17.  
  18.     @EventHandler
  19.     public void onItemClick(PlayerInteractEvent e) {
  20.  
  21.         Player p = e.getPlayer();
  22.         tool = new ToolbarManager(p);
  23.         ItemStack item = e.getItem();
  24.         Action action = e.getAction();
  25.  
  26.         if (item == null) {
  27.             return;
  28.         }
  29.  
  30.         if (action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK)) {
  31.  
  32.             if (item.equals(core.toggle.getTogglePvP())) {
  33.  
  34.                 if (core.getServer().getPluginManager().isPluginEnabled("ProdigyGadget")) {
  35.  
  36.                     ProdigyPlayer pp = ProdigyPlayer.instanceOf(p);
  37.  
  38.                     if (pp.hasCosmetic()) {
  39.                         pp.clearPlayerCosmetics();
  40.                     }
  41.  
  42.                 }
  43.  
  44.                 tool.getToolbar();
  45.                 p.getInventory().clear();
  46.                 core.activePVP.add(p.getName());
  47.                 core.inventory.getInvPvP(p);
  48.                 core.mes.sendMessage(true, "Messages.pvp-enabled", p);
  49.  
  50.             }
  51.  
  52.             if (item.equals(core.exit.getExitPvP())) {
  53.  
  54.                 core.activePVP.remove(p.getName());
  55.                 tool.setToolbar();
  56.                 core.mes.sendMessage(true, "Messages.pvp-disabled", p);
  57.  
  58.             }
  59.  
  60.         }
  61.  
  62.     }
  63.  
  64. }
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