what on earth

Discussion in 'Plugin Development' started by XxZHALO13Xx, Jan 1, 2015.

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

    XxZHALO13Xx

    why doesn't this work??

    Code:
    public class Core extends JavaPlugin implements Listener{
       
        public void onEnable(){
            getServer().getPluginManager().registerEvents(this, this);
            getLogger().info("odjawdawd");
        }
    
        @EventHandler
        public void onMove(PlayerMoveEvent e){
            Player p = e.getPlayer();
           
            if(p.getInventory().getItemInHand().equals(Material.STICK)){
                Block b = p.getLocation().getBlock();
               
                if(!(b.getRelative(BlockFace.DOWN).getType().equals(Material.TNT))){
                    b.setType(Material.TNT);
                    p.sendMessage(ChatColor.GREEN + "[Tnt] Placed block of tnt");
                }
            }
        }
    }
    
     
  2. Offline

    567legodude

    First, I believe you need to override the onEnable and you also need to add onDisable and override that too.
    Thats just from a quick look.
     
  3. Offline

    Rocoty

    Again, don't expect us to magically know exactly what you're thinking. Doesn't work how? What is it supposed to do and what does it actually do?

    EDIT: Another quick look and I see you are comparing an ItemStack with a Material. Those will never be equal and the condition is always false.

    None of what you've mentioned will make a difference.
     
    timtower likes this.
  4. Offline

    Monkey_Swag

    #getType == Material.STICK

     
  5. Offline

    Cycryl

    add in an if statement to check if player.getItemInHand()!=null then do that toher stuff
     
Thread Status:
Not open for further replies.

Share This Page