Not getting items - No errors

Discussion in 'Plugin Development' started by CrazymanJR, Sep 28, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    CrazymanJR

    I'm basically trying to make a plugin when you right click a chest, you will get specific items (cosmetic items) and when you click on the trapped chest you will give your normal inventory back. I already registered my events in the onEnable and it doesn't give an error. When they do click the chest, it sends the message.

    Code:
    Code:
    @EventHandler
        public void onLoginItems(PlayerJoinEvent event) {
            Player player = event.getPlayer();
            PlayerInventory pi = player.getInventory();
            ArrayList<String> cosmeticlore = new ArrayList<String>();
           
            player.getInventory().clear();
           
            ItemStack cosmetic = new ItemStack(Material.CHEST);
            ItemMeta cosmeticmeta = cosmetic.getItemMeta();
            cosmeticmeta.setDisplayName(ChatColor.GREEN + "Cosmetic Menu");
            cosmeticlore.add(ChatColor.GRAY + "Right-click to toggle your cosmetic items!");
            cosmeticmeta.setLore(cosmeticlore);
            cosmetic.setItemMeta(cosmeticmeta);
            pi.setItem(8, cosmetic);
     
        }
       
        @EventHandler
        public void PlayerInteract(PlayerInteractEvent event) {
            Player player = event.getPlayer();
            Material mat = player.getItemInHand().getType();
           
            if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
               
                if(mat == Material.CHEST) {
                    ArrayList<String> cosmeticlore = new ArrayList<String>();
                    player.sendMessage(ChatColor.GREEN + "You are now in cosmetic mode!");
                   
                    ItemStack bow = new ItemStack(Material.BOW);
                    ItemMeta bowmeta = bow.getItemMeta();
                    bowmeta.setDisplayName(ChatColor.GREEN + "Teleport Bow");
                    bow.setItemMeta(bowmeta);
                    player.getInventory().setItem(0, bow);
                   
                    ItemStack cosmetic = new ItemStack(Material.TRAPPED_CHEST);
                    ItemMeta cosmeticmeta = cosmetic.getItemMeta();
                    cosmeticmeta.setDisplayName(ChatColor.GREEN + "Cosmetic Menu");
                    cosmeticlore.add(ChatColor.GRAY + "Right-click to toggle your cosmetic items!");
                    cosmeticmeta.setLore(cosmeticlore);
                    cosmetic.setItemMeta(cosmeticmeta);
                    player.getInventory().setItem(8, cosmetic);
                }
                if (mat == Material.TRAPPED_CHEST) {
                    ArrayList<String> cosmeticlore = new ArrayList<String>();
                    player.sendMessage(ChatColor.GREEN + "You are now in regular mode!");
                   
                    ItemStack cosmetic = new ItemStack(Material.CHEST);
                    ItemMeta cosmeticmeta = cosmetic.getItemMeta();
                    cosmeticmeta.setDisplayName(ChatColor.GREEN + "Cosmetic Menu");
                    cosmeticlore.add(ChatColor.GRAY + "Right-click to toggle your cosmetic items!");
                    cosmeticmeta.setLore(cosmeticlore);
                    cosmetic.setItemMeta(cosmeticmeta);
                    player.getInventory().setItem(8, cosmetic);
                }
               
            }
        }
     
  2. Offline

    Skionz

    Have you tried debugging?
     
  3. Offline

    CrazymanJR

    Skionz
    Yes i have. I just doesn't work...
     
  4. Offline

    teej107

Thread Status:
Not open for further replies.

Share This Page