solved

Discussion in 'Spigot Plugin Development' started by DogeDebugger, May 19, 2015.

  1. Used this resource: https://bukkit.org/threads/tutorial-create-a-inventory-menu.173571/

    So I have this:
    Code (Java):
    @EventHandler
        public void openShops(InventoryClickEvent event) {
            final Player p = (Player) event.getWhoClicked();
            final ItemStack i = event.getCurrentItem();
            if(i.getItemMeta() != null)
                if(i.getItemMeta().getDisplayName().equals(ChatColor.AQUA + "Weapon Shop")) {
                p.sendMessage("y");
                p.openInventory(WeaponShop.weaponshop);
            } else {
                p.sendMessage("n");
            }
        }
    I do get sent the "y" message, so im clicking the right thing, but when i click it, it just exits out and doesn't do anything.

    WeaponShop:
    Code (Java):
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;

    public class WeaponShop {

        public static Inventory weaponshop = Bukkit.createInventory(null, 9, "Weapon Shop");
     
        public static ItemStack stonesword = new ItemStack(Material.STONE_SWORD, 1);
        public static ItemStack ironsword = new ItemStack(Material.IRON_SWORD, 1);
        public static ItemStack escrima = new ItemStack(Material.BLAZE_ROD, 1);

        static {
            stonesword.getItemMeta().setDisplayName(ChatColor.AQUA + "Stone Sword");
            ironsword.getItemMeta().setDisplayName(ChatColor.AQUA + "Iron Sword");
            escrima.getItemMeta().setDisplayName(ChatColor.YELLOW + "Escrima Stick");
            escrima.addUnsafeEnchantment(Enchantment.KNOCKBACK, 3);
            escrima.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 4);
         
            weaponshop.setItem(0, stonesword);
            weaponshop.setItem(1, ironsword);
            weaponshop.setItem(2, escrima);
        }
     
    }
     
     
  2. Where is it failing?

    Are there any errors received?
     
  3. It is failing at

    Code (Text):
    p.openInventory(WeaponShop.weaponshop);
    No errors
     
  4. eqx

    eqx

    Any errors in console?
     
  5. I just said no lmao

    No
     
  6. Make this thread [Solved] please.
    Thanks