Nocx

ncmenu inv

Jun 27th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.43 KB | None | 0 0
  1. package fr.ncmenu.events;
  2.  
  3. import java.awt.Desktop;
  4. import java.net.URI;
  5.  
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Material;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.inventory.InventoryClickEvent;
  12. import org.bukkit.inventory.ItemStack;
  13.  
  14. import fr.ncmenu.gui.MainGUI;
  15. import fr.ncmenu.gui.PortalsGUI;
  16. import fr.ncmenu.gui.TpGUI;
  17. import fr.ncmenu.gui.WarzoneGUI;
  18. import fr.ncmenu.main.MainMenu;
  19.  
  20. public class Inventory implements Listener{
  21.  
  22.     public MainMenu mm;
  23.    
  24.     public Inventory(MainMenu mm)
  25.     {
  26.         this.mm = mm;
  27.     }
  28.    
  29.     @EventHandler
  30.     public void onInv(InventoryClickEvent e)
  31.     {
  32.         Player p = (Player) e.getWhoClicked();
  33.        
  34.        
  35.    
  36.        
  37.         if(ChatColor.stripColor(e.getInventory().getTitle()).equalsIgnoreCase("NetsCraft - Menu")
  38.                 || ChatColor.stripColor(e.getInventory().getTitle()).equalsIgnoreCase("NetsCraft - Téléportation")
  39.                 || ChatColor.stripColor(e.getInventory().getTitle()).equalsIgnoreCase("NetsCraft - Warzone")
  40.                 || ChatColor.stripColor(e.getInventory().getTitle()).equalsIgnoreCase("NetsCraft - Portails"))
  41.                
  42.         {
  43.             try{
  44.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("spawn"))
  45.             {
  46.                 p.chat("/spawn");
  47.                 p.closeInventory();
  48.             }
  49.            
  50.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains(p.getName()))
  51.             {
  52.                 p.chat("/stats");
  53.                 p.closeInventory();
  54.             }
  55.            
  56.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("shop"))
  57.             {
  58.                 p.chat("/shop");
  59.                 p.closeInventory();
  60.             }
  61.            
  62.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("Guide"))
  63.             {
  64.                 p.chat("/help");
  65.                 p.closeInventory();
  66.             }
  67.            
  68.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Warps"))
  69.             {
  70.                 new TpGUI(p);
  71.             }  
  72.            
  73.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("Enderchest"))
  74.             {
  75.                 p.closeInventory();
  76.                 p.chat("/enderchest");
  77.             }
  78.            
  79.             if(mm.Menu.containsKey(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName())))
  80.             {
  81.                 p.closeInventory();
  82.                 p.chat(mm.Menu.get(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName())));
  83.             }
  84.            
  85.             if(mm.Menu.containsKey("Vote") && ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).startsWith("Vote"))
  86.             {
  87.                 p.closeInventory();
  88.                 p.chat(mm.Menu.get("Vote"));
  89.             }
  90.            
  91.             e.setCancelled(true);
  92.             }catch(NullPointerException npe){}
  93.        
  94.         }
  95.        
  96.         if(ChatColor.stripColor(e.getInventory().getTitle()).contains("Téléportation"))
  97.         {
  98.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("Warzone"))
  99.             {
  100.                 new WarzoneGUI(p);
  101.             }
  102.        
  103.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("Portails"))
  104.             {
  105.                 new PortalsGUI(p);
  106.             }
  107.            
  108.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("Shop"))
  109.             {
  110.                 p.chat("/warp shop");
  111.                 p.closeInventory();
  112.             }
  113.            
  114.            
  115.             _LocalUtilsMenu(mm, p, e.getCurrentItem());
  116.         }
  117.        
  118.         if(ChatColor.stripColor(e.getInventory().getTitle()).contains("Warzone"))
  119.         {
  120.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("Nord"))
  121.             {
  122.                 p.chat("/nord");
  123.                 p.closeInventory();
  124.             }
  125.        
  126.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("Sud"))
  127.             {
  128.                 p.chat("/sud");
  129.                 p.closeInventory();
  130.             }
  131.            
  132.            
  133.             _LocalUtilsMenu(mm, p, e.getCurrentItem());
  134.         }
  135.        
  136.         if(ChatColor.stripColor(e.getInventory().getTitle()).contains("Portails"))
  137.         {
  138.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("Nether"))
  139.             {
  140.                 p.chat("/warp nether");
  141.                 p.closeInventory();
  142.             }
  143.        
  144.             if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).contains("End"))
  145.             {
  146.                 p.chat("/warp end");
  147.                 p.closeInventory();
  148.             }
  149.            
  150.             _LocalUtilsMenu(mm, p, e.getCurrentItem());
  151.         }
  152.        
  153.        
  154.        
  155.     }
  156.  
  157.    
  158.     public void _LocalUtilsMenu(MainMenu main, Player p, ItemStack e)
  159.     {
  160.         if(ChatColor.stripColor(e.getItemMeta().getDisplayName()).contains("Quitter"))
  161.         {
  162.             p.closeInventory();
  163.         }
  164.         if(ChatColor.stripColor(e.getItemMeta().getDisplayName()).contains("Menu"))
  165.         {
  166.             new MainGUI(p, main);
  167.         }
  168.     }
  169.    
  170. }
Advertisement
Add Comment
Please, Sign In to add comment