ItemMeta bug

Discussion in 'Plugin Development' started by xXCapzXx, Jun 22, 2015.

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

    xXCapzXx

    So I am trying to make a plugin when you right click the blaze rod which has the item meta Reload Stick in gold, it will reload the server, and if it doesn't have the item meta, it won't reload the server:

    Code:
    Code:
    
     public boolean onCommand2(CommandSender sender, Command cmd, String commandLabel, String[] args) {
       
        Player player = (Player) sender;
       
        ItemStack rod = new ItemStack(Material.BLAZE_ROD);
       
        ItemMeta meta = rod.getItemMeta();
       
        meta.setDisplayName(ChatColor.GOLD + "Reload Stick");
       
        rod.setItemMeta(meta);
       
        List<String> lore = new ArrayList<String>();
        lore.add(ChatColor.AQUA + "Very nice stick you have there :)");
        meta.setLore(lore);
       
        if(cmd.getName().equalsIgnoreCase("reloadstick")) {
       
            if(sender.hasPermission("stick.use")) {
       
                player.getInventory().addItem(new ItemStack(rod));
                if(rod.hasItemMeta());
                return true;
       
            }else{
           
                if(!rod.hasItemMeta());
           
                return false;
                 
            }
             
        }
         
        return true;
         
     }
    
     @EventHandler
    
     public void interact(PlayerInteractEvent e) {
    
        Player player = e.getPlayer();
         
        ItemStack rod = new ItemStack(Material.BLAZE_ROD);
           
        ItemMeta meta = rod.getItemMeta();
       
        meta.setDisplayName(ChatColor.GOLD + "Reload Stick");
       
        rod.setItemMeta(meta);
       
        player.getInventory().addItem(rod);
         
        Location loc = player.getLocation();
    
        if(e.getAction() == Action.LEFT_CLICK_AIR) return;
    
        if(e.getItem().getType() == Material.BLAZE_ROD && e.getItem().getType().equals(rod)) return;
       
         
       
        Bukkit.getServer().reload();
    
        Bukkit.broadcastMessage(ChatColor.AQUA + "Server reloaded by " + player.getName());
    
        player.playSound(loc, Sound.FIREWORK_BLAST, 4, 4);
       
        player.playSound(loc, Sound.AMBIENCE_RAIN, 4, 4);
    
     }
    
    }
    
    
    
     
  2. Offline

    xTrollxDudex

    What is the problem with your code?
     
  3. Offline

    caderape

    @xXCapzXx Anyone can reload your server. Why are u adding the blazrod everytime a player interact ? You will have thousand of blazrod in just one day.
     
  4. Offline

    xXCapzXx

    Not helping...
     
  5. Offline

    caderape

    @xXCapzXx It's hard to help. Your problem is logic.

    "onCommand2" Remove the 2 if you want this command works.
     
    Ozeir likes this.
Thread Status:
Not open for further replies.

Share This Page