perFnBEt
Język: Java
|
Autor: Anonimowy
public class InventoryListener implements Listener { @EventHandler public boolean onInventoryClick(InventoryClickEvent e){ Player p = (Player) e.getWhoClicked(); String name = Main.getInst().getConfig().getString("ShopGUIName"); if(e.getInventory().getTitle().equals(Utils.fixColor(name))){ if(e.getCurrentItem().getItemMeta() !=null){ if(e.getCurrentItem().getItemMeta().getDisplayName() != null){ if(e.getCurrentItem().getItemMeta().getDisplayName().equals(Utils.fixColor("&a&lKUPNO PRZEDMIOTOW"))) { e.setCancelled(true); //inventory String BuyName = Main.getInst().getConfig().getString("BuyGUIName"); Inventory inv = Bukkit.createInventory(null, 27, Utils.fixColor(BuyName)); //boots String bootsName = Main.getInst().getConfig().getString("boots.Name"); String bootsLore = String.join("\n", Main.getInst().getConfig().getStringList("boots.Lore")); List<String> LoreBoots = new ArrayList<>(); LoreBoots.add(Utils.fixColor(bootsLore)); ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS); ItemMeta meta = boots.getItemMeta(); meta.setDisplayName(Utils.fixColor(bootsName)); meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 4, true); meta.addEnchant(Enchantment.DURABILITY, 3, true); meta.addEnchant(Enchantment.PROTECTION_FALL, 4, true); meta.setLore(LoreBoots); boots.setItemMeta(meta); //leggings String leggingsName = Main.getInst().getConfig().getString("leggings.Name"); String leggingsLore = String.join("\n", Main.getInst().getConfig().getStringList("leggings.Lore")); List<String> LoreLeggings = new ArrayList<>(); LoreLeggings.add(Utils.fixColor(leggingsLore)); ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS); ItemMeta meta1 = leggings.getItemMeta(); meta1.setDisplayName(Utils.fixColor(leggingsName)); meta1.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 4, true); meta1.addEnchant(Enchantment.DURABILITY, 3, true); meta1.setLore(LoreLeggings); leggings.setItemMeta(meta1); //chestplate String chestplateName = Main.getInst().getConfig().getString("chestplate.Name"); String chestplateLore = String.join("\n", Main.getInst().getConfig().getStringList("chestplate.Lore")); List<String> LoreChestplate = new ArrayList<>(); LoreChestplate.add(Utils.fixColor(chestplateLore)); ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE); ItemMeta meta2 = leggings.getItemMeta(); meta2.setDisplayName(Utils.fixColor(chestplateName)); meta2.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 4, true); meta2.addEnchant(Enchantment.DURABILITY, 3, true); meta2.setLore(LoreChestplate); chestplate.setItemMeta(meta2); //helmet String helmetName = Main.getInst().getConfig().getString("helmet.Name"); String helmetLore = String.join("\n", Main.getInst().getConfig().getStringList("helmet.Lore")); List<String> LoreHelmet = new ArrayList<>(); LoreHelmet.add(Utils.fixColor(helmetLore)); ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET); ItemMeta meta3 = leggings.getItemMeta(); meta3.setDisplayName(Utils.fixColor(helmetName)); meta3.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 4, true); meta3.addEnchant(Enchantment.DURABILITY, 3, true); helmet.setItemMeta(meta3); //sword String swordName = Main.getInst().getConfig().getString("sword.Name"); String swordLore = String.join("\n", Main.getInst().getConfig().getStringList("sword.Lore")); List<String> LoreSword = new ArrayList<>(); LoreSword.add(Utils.fixColor(swordLore)); ItemStack sword = new ItemStack(Material.DIAMOND_SWORD); ItemMeta meta4 = sword.getItemMeta(); meta4.setDisplayName(Utils.fixColor(swordName)); meta4.addEnchant(Enchantment.DAMAGE_ALL, 5, true); meta4.addEnchant(Enchantment.DURABILITY, 3, true); meta4.addEnchant(Enchantment.FIRE_ASPECT, 2, true); meta4.setLore(LoreSword); sword.setItemMeta(meta4); inv.setItem(0, boots); inv.setItem(1, leggings); inv.setItem(2, chestplate); inv.setItem(3, helmet); inv.setItem(4, sword); p.openInventory(inv); return true; }else if(e.getCurrentItem().getItemMeta().getDisplayName().equals(Utils.fixColor("&c&lSPRZEDAZ PRZEDMIOTOW"))) { } } } } return false; } }