Guest User

Menu.java

a guest
Jul 9th, 2015
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.96 KB | None | 0 0
  1. package net.wandnetwork;
  2.  
  3. import java.util.Arrays;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.GameMode;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. import org.bukkit.World;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.Listener;
  13. import org.bukkit.event.inventory.InventoryClickEvent;
  14. import org.bukkit.inventory.Inventory;
  15. import org.bukkit.inventory.ItemStack;
  16. import org.bukkit.inventory.meta.ItemMeta;
  17.  
  18. public class Menu
  19.   implements Listener
  20.  
  21. {
  22.  
  23.   public static Main main;
  24.   private static ItemStack skywars;
  25.   private static ItemStack survival;
  26.   private static ItemStack gamemode;
  27.   private static ItemStack desaparecer;
  28.   private static ItemStack desativarchat;
  29.   private static ItemStack realnick;
  30.   private static ItemStack reaparecer;
  31.   private static ItemStack ativarchat;
  32.   private static ItemStack lobby1;
  33.   private static ItemStack lobby2;
  34.   private static ItemStack lobby3;
  35.   public static Inventory staff = Bukkit.createInventory(null, 18, "§f§l► §9Staff");
  36.   public static Inventory lobby = Bukkit.createInventory(null, 9, "§f§l► §9Lobbys");
  37.   public static Inventory menu = Bukkit.createInventory(null, 9, "§f§l► §9Games");
  38.  
  39.   static{
  40.         skywars = item1("§f§l= §aSkyWars §f§l=");
  41.         survival = item2("§f§l= §aSurvivalGames §f§l=");
  42.  
  43.         menu.setItem(2, skywars);
  44.         menu.setItem(6, survival);
  45.      
  46.         gamemode = ite1("§9GameMode");
  47.         desaparecer = ite2("§9Desaparecer");
  48.         desativarchat = ite3("§9Desativar Chat");
  49.         realnick = ite4("§9Nick Real");
  50.         ativarchat = ite5("§9Ativar Chat");
  51.         reaparecer = ite6("§9Aparecer");
  52.        
  53.         staff.setItem(2, gamemode);
  54.         staff.setItem(4, desativarchat);
  55.         staff.setItem(6, desaparecer);
  56.         staff.setItem(9, realnick);
  57.         staff.setItem(11, ativarchat);
  58.         staff.setItem(13, reaparecer);
  59.        
  60.         lobby1 = lb1("§7§l= §9Lobby 1 §7§l=");
  61.         lobby2 = lb2("§7§l= §9Lobby 2 §7§l=");
  62.         lobby3 = lb3("§7§l= §9Lobby 3 §7§l=");
  63.        
  64.         lobby.setItem(2, lobby1);
  65.         lobby.setItem(4, lobby2);
  66.         lobby.setItem(6, lobby3);
  67.   }
  68.  
  69.   private static ItemStack item1(String name)
  70.   {
  71.     ItemStack i = new ItemStack(new ItemStack(Material.FEATHER, 1));
  72.     ItemMeta im = i.getItemMeta();
  73.     im.setDisplayName(name);
  74.     im.setLore(Arrays.asList(new String[] { "§9Lobby §f§l► §7SkyWars.  §81.7 à 1.8" }));
  75.     i.setItemMeta(im);
  76.     return i;
  77.   }
  78.  
  79.   private static ItemStack item2(String name2) {
  80.     ItemStack i2 = new ItemStack(new ItemStack(Material.CHEST, 1));
  81.     ItemMeta im2 = i2.getItemMeta();
  82.     im2.setDisplayName(name2);
  83.     im2.setLore(Arrays.asList(new String[] { "§9Lobby §f§l► §7Survival Games.  §81.7 à 1.8" }));
  84.     i2.setItemMeta(im2);
  85.     return i2;
  86.   }
  87.  
  88.  
  89.  
  90.  
  91.   private static ItemStack ite1(String nome)
  92.   {
  93.     ItemStack a = new ItemStack(new ItemStack(Material.COMMAND, 1));
  94.     ItemMeta am = a.getItemMeta();
  95.     am.setDisplayName(nome);
  96.     am.setLore(Arrays.asList(new String[] { "§f§l► §9Mudar de Gamemode" }));
  97.     a.setItemMeta(am);
  98.     return a;
  99.   }
  100.  
  101.   private static ItemStack ite2(String nome2) {
  102.     ItemStack a2 = new ItemStack(new ItemStack(Material.CHEST, 1));
  103.     ItemMeta am2 = a2.getItemMeta();
  104.     am2.setDisplayName(nome2);
  105.     am2.setLore(Arrays.asList(new String[] { "§f§l► §9Desaparecer para outros jogadores" }));
  106.     a2.setItemMeta(am2);
  107.     return a2;
  108.   }
  109.  
  110.   private static ItemStack ite3(String nome3) {
  111.         ItemStack a3 = new ItemStack(new ItemStack(Material.REDSTONE, 1));
  112.         ItemMeta am3 = a3.getItemMeta();
  113.         am3.setDisplayName(nome3);
  114.         am3.setLore(Arrays.asList(new String[] { "§f§l► §9Desativar o chat do lobby" }));
  115.         a3.setItemMeta(am3);
  116.         return a3;
  117.       }
  118.  
  119.   private static ItemStack ite4(String nome4) {
  120.         ItemStack a4 = new ItemStack(new ItemStack(Material.DIAMOND, 1));
  121.         ItemMeta am4 = a4.getItemMeta();
  122.         am4.setDisplayName(nome4);
  123.         am4.setLore(Arrays.asList(new String[] { "§f§l► §9Voltar ao nick real" }));
  124.         a4.setItemMeta(am4);
  125.         return a4;
  126.       }
  127.   private static ItemStack ite5(String nome5) {
  128.         ItemStack a5 = new ItemStack(new ItemStack(Material.DIAMOND_BLOCK, 1));
  129.         ItemMeta am5 = a5.getItemMeta();
  130.         am5.setDisplayName(nome5);
  131.         am5.setLore(Arrays.asList(new String[] { "§f§l► §9Ativar Chat" }));
  132.         a5.setItemMeta(am5);
  133.         return a5;
  134.       }
  135.   private static ItemStack ite6(String nome6) {
  136.         ItemStack a6 = new ItemStack(new ItemStack(Material.REDSTONE_BLOCK, 1));
  137.         ItemMeta am6 = a6.getItemMeta();
  138.         am6.setDisplayName(nome6);
  139.         am6.setLore(Arrays.asList(new String[] { "§f§l► §9Aparecer" }));
  140.         a6.setItemMeta(am6);
  141.         return a6;
  142.       }
  143.  
  144.  
  145.   private static ItemStack lb1(String nime1) {
  146.         ItemStack l = new ItemStack(new ItemStack(Material.NETHER_STAR, 1));
  147.         ItemMeta lm = l.getItemMeta();
  148.         lm.setDisplayName(nime1);
  149.         lm.setLore(Arrays.asList(new String[] { "§f§l► §cVocê ja está nesse lobby!" }));
  150.         l.setItemMeta(lm);
  151.         return l;
  152.       }
  153.   private static ItemStack lb2(String nime2) {
  154.         ItemStack l2 = new ItemStack(new ItemStack(Material.NETHER_STAR, 2));
  155.         ItemMeta lm2 = l2.getItemMeta();
  156.         lm2.setDisplayName(nime2);
  157.         lm2.setLore(Arrays.asList(new String[] { "§f§l► §aClique para ir ao lobby 2!" }));
  158.         l2.setItemMeta(lm2);
  159.         return l2;
  160.       }
  161.   private static ItemStack lb3(String nime3) {
  162.         ItemStack l3 = new ItemStack(new ItemStack(Material.NETHER_STAR, 3));
  163.         ItemMeta lm3 = l3.getItemMeta();
  164.         lm3.setDisplayName(nime3);
  165.         lm3.setLore(Arrays.asList(new String[] { "§f§l► §aClique para ir ao lobby 3!" }));
  166.         l3.setItemMeta(lm3);
  167.         return l3;
  168.       }
  169.  
  170.   @EventHandler
  171.   public void onInventoryClick(InventoryClickEvent e) {
  172.     World w = e.getWhoClicked().getWorld();
  173.     Player p = (Player)e.getWhoClicked();
  174.  
  175.     if (!e.getInventory().getName().equalsIgnoreCase(menu.getName())) return;
  176.     if (e.getCurrentItem().getItemMeta() == null) return;
  177.    
  178.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§f§l= §aSkyWars §f§l=")) {
  179.       e.setCancelled(true);
  180.       p.teleport(new Location(w, 99.5D, 100.0D, 101.5D, 45.0F, 0F));
  181.       p.sendMessage("§9Teleporte > §7Teleportado para o SkyWars");
  182.       p.closeInventory();
  183.     }
  184.    
  185.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§f§l= §aSurvivalGames §f§l=")) {
  186.       e.setCancelled(true);
  187.       p.teleport(new Location(w, 286.5D, 28.0D, 541.5D, 180.0F, 2.0F));
  188.       p.sendMessage("§9Teleporte > §7Teleportado para o Survival Games");
  189.       p.closeInventory();
  190.     }
  191.   }
  192.  
  193.   @EventHandler
  194.   public void onInventoryClick2(InventoryClickEvent e) {
  195.     Player p = (Player)e.getWhoClicked();
  196.  
  197.     if (!e.getInventory().getName().equalsIgnoreCase(staff.getName())) return;
  198.     if (e.getCurrentItem().getItemMeta() == null) return;
  199.    
  200.    
  201.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§9GameMode")) {
  202.         e.setCancelled(true);
  203.         if(!p.hasPermission("wand.mod")){
  204.             p.sendMessage("§9Erro > §7Sem permissão.");
  205.             return;
  206.         }
  207.         if(p.getGameMode() == GameMode.CREATIVE){
  208.             p.setGameMode(GameMode.SURVIVAL);
  209.             p.sendMessage("§9Staff > §7Modo mudado para sobrevivencia.");
  210.         }
  211.         else{
  212.             p.setGameMode(GameMode.CREATIVE);
  213.             p.sendMessage("§9Staff > §7Modo mudado para criativo.");
  214.         }
  215.       p.closeInventory();
  216.     }
  217.    
  218.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§9Desaparecer")) {
  219.         e.setCancelled(true);
  220.         if(!p.hasPermission("wand.mod")){
  221.             p.sendMessage("§9Erro > §7Sem permissão.");
  222.             return;
  223.         }
  224.       for (Player todos : Bukkit.getOnlinePlayers()){
  225.           todos.hidePlayer(p);
  226.           p.sendMessage("§9Staff > §7Desaparecido para todos.");
  227.       }
  228.       p.closeInventory();
  229.     }
  230.    
  231.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§9Desativar Chat")) {
  232.         e.setCancelled(true);
  233.         if(!p.hasPermission("wand.mod")){
  234.             p.sendMessage("§9Erro > §7Sem permissão.");
  235.             return;
  236.         }
  237.           p.chat("/desativarchat");
  238.         p.closeInventory();
  239.       }
  240.    
  241.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§9Nick Real")) {
  242.         e.setCancelled(true);
  243.         if(!p.hasPermission("wand.mod")){
  244.             p.sendMessage("§9Erro > §7Sem permissão.");
  245.             return;
  246.         }
  247.         p.chat("/real");
  248.         p.closeInventory();
  249.         }
  250.    
  251.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§9Ativar Chat")) {
  252.         e.setCancelled(true);
  253.         if(!p.hasPermission("wand.mod")){
  254.             p.sendMessage("§9Erro > §7Sem permissão.");
  255.             return;
  256.         }
  257.         p.chat("/ativarchat");
  258.         p.closeInventory();
  259.         }
  260.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§9Aparecer")) {
  261.         e.setCancelled(true);
  262.         if(!p.hasPermission("wand.mod")){
  263.             p.sendMessage("§9Erro > §7Sem permissão.");
  264.             return;
  265.         }
  266.         p.chat("/aparecer");
  267.         p.closeInventory();
  268.         }
  269.    
  270.   }
  271.     @EventHandler
  272.     public void onInventoryClick3(InventoryClickEvent e) {
  273.       Player p = (Player)e.getWhoClicked();
  274.  
  275.       if (!e.getInventory().getName().equalsIgnoreCase(lobby.getName())) return;
  276.       if (e.getCurrentItem().getItemMeta() == null) return;
  277.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§7§l= §9Lobby 1 §7§l=")) {
  278.         e.setCancelled(true);
  279.         p.chat("/lobby1");
  280.         p.closeInventory();
  281.         }
  282.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§7§l= §9Lobby 2 §7§l=")) {
  283.         e.setCancelled(true);
  284.         p.sendMessage("§9Server > §7Teleportando para o lobby 2 ...");
  285.         p.chat("/lobby2");
  286.         p.closeInventory();
  287.         }
  288.     if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§7§l= §9Lobby 3 §7§l=")) {
  289.         e.setCancelled(true);
  290.         p.sendMessage("§9Server > §7Teleportando para o lobby 3 ...");
  291.         p.chat("/lobby3");
  292.         p.closeInventory();
  293.         }
  294.     }
  295.              
  296.  
  297.  
  298.  
  299. }
Advertisement
Add Comment
Please, Sign In to add comment