Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. @EventHandler(priority = EventPriority.HIGH)
  2. public void onInventroyClick(InventoryClickEvent e){
  3.  
  4. Player p = (Player) e.getWhoClicked();
  5.  
  6. if(e.getSlotType() != SlotType.OUTSIDE){
  7.  
  8. if(e.getCurrentItem() != null | e.getCurrentItem().getType() == Material.AIR){
  9.  
  10. if(!e.getCurrentItem().hasItemMeta()){
  11. return;
  12. }
  13.  
  14. if(e.getInventory().getName() == "§9Spiel auswählen"){
  15.  
  16. ConfigurationSection publicSection = MainClass.cfg.getConfigurationSection("GamePoints");
  17. ArrayList<GamePoint> gl = new ArrayList<GamePoint>();
  18.  
  19. gl.clear();
  20.  
  21. for (String g : publicSection.getKeys(false)){
  22.  
  23. String c = "GamePoints." + g + ".";
  24. String ci = "GamePoints." + g + ".Item.";
  25.  
  26. GamePoint gp = new GamePoint(g, null, null, 0);
  27. gp.setName(g);
  28. GameItem gi = new GameItem(g, null, 0, null);
  29.  
  30. String ChatName = MainClass.cfg.getString(c + "ChatName");
  31. int Slot = MainClass.cfg.getInt(c + "Slot");
  32.  
  33. double x = MainClass.cfg.getDouble(c + "X");
  34. double y = MainClass.cfg.getDouble(c + "Y");
  35. double z = MainClass.cfg.getDouble(c + "Z");
  36. double yaw = MainClass.cfg.getDouble(c + "Yaw");
  37. double pitch = MainClass.cfg.getDouble(c + "Pitch");
  38. World w = Bukkit.getWorld(MainClass.cfg.getString(c + "World"));
  39.  
  40. Location Loc = new Location(w, x, y, z,(float) yaw,(float) pitch);
  41.  
  42. String Displayname = MainClass.cfg.getString(ci + "DisplayName");
  43. String Lore1 = MainClass.cfg.getString(ci + "Lore1");
  44. String Lore2 = MainClass.cfg.getString(ci + "Lore2");
  45. ArrayList<String> Lore = new ArrayList<String>();
  46. if(Lore1 != null & Lore1 != ""){Lore.add(Lore1);}
  47. if(Lore2 != null & Lore2 != ""){Lore.add(Lore2);}
  48. Integer Amount = MainClass.cfg.getInt(ci + "Amount");
  49. Integer ID = MainClass.cfg.getInt(ci + "Material");
  50. short Short = (short) MainClass.cfg.getInt(ci + "Short");
  51.  
  52. gi.setDisplayName(Displayname.toString());
  53. gi.setLore(Lore);
  54. gi.setMaterial(ID);
  55. gi.setShort(Short);
  56. gi.setAmount(Amount);
  57.  
  58. gp.setChatName(ChatName);
  59. gp.setSlot(Slot);
  60. gp.setLocation(Loc);
  61. gp.setGameItem(gi);
  62.  
  63. gl.add(gp);
  64.  
  65. Bukkit.broadcastMessage("GL: " + gp);
  66.  
  67. }
  68.  
  69.  
  70.  
  71. ItemStack i = e.getCurrentItem();
  72.  
  73. for(GamePoint gp : gl){
  74.  
  75. if(gp.getGameItem().getDisplayName() == i.getItemMeta().getDisplayName()){
  76.  
  77. p.teleport(gp.getLocation());
  78. p.sendMessage("§aDu wurdest zum Spiel §e"+gp.getChatName()+"§a teleportiert.");
  79.  
  80. return;
  81. }
  82.  
  83. }
  84.  
  85. }
  86.  
  87. }
  88.  
  89. } else {
  90.  
  91. p.closeInventory();
  92. e.setCancelled(true);
  93. return;
  94.  
  95. }
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement