register Event problem

Discussion in 'Plugin Development' started by jdjack, Jan 18, 2012.

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

    jdjack

    i have got a problem that i can't work out. Could some one please help me with it. The plugin is meant to plant a tree when you right click on a dirt block with a blaze rod. The "pm.registerEvent..." has an error on it saying "The method registerEvent(Event.Type, Listener, Event.Priority, Plugin) in the type PluginManager is not applicable for the arguments (Event.Type, TMListener, Event.Priority, TMMain)". Here is the code for my main class:
    Code:
    package treeMaker;
     
    import java.util.logging.Logger;
     
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class TMMain extends JavaPlugin{
        private final TMListener pllistener = new TMListener();
     
       
        Logger log = Logger.getLogger("Minecraft");
        @Override
        public void onDisable() {
            log.info("[TreeMendous]: has now been disabled");
           
        }
     
        @Override
        public void onEnable() {
            log.info("[TreeMendous]: has now been enabled");
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.PLAYER_INTERACT, pllistener, Priority.Normal, this);
           
        }
     
    }
    
    Code:
    package treeMaker;
     
    import org.bukkit.Material;
    import org.bukkit.TreeType;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.inventory.ItemStack;
     
    public class TMListener extends PlayerListener {
       
        public void onPlayerInteract (PlayerInteractEvent event){
            Player player = event.getPlayer();
            Block block = event.getClickedBlock();
            ItemStack itemInHand = player.getItemInHand();
            Material itemInHandType = itemInHand.getType();
            World world = player.getWorld();
           
            if(event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType()==Material.DIRT && itemInHandType==Material.getMaterial(369)){
                world.generateTree(block.getLocation(), TreeType.TREE);
               
            }
        }
     
    }
    
     
  2. Offline

    tkausl

    I think this is an Bug in Eclipse (Do you use Eclipse?).
    Remove the line
    Code:
    pm.registerEvent(Event.Type.PLAYER_INTERACT, pllistener, Priority.Normal, this);
    and retype it.
     
  3. Newest bukkit version? if so, there's a new event-system.
     
  4. Offline

    tkausl

    I Think, the old System is only Deprecated, but not removed.
     
  5. Offline

    jdjack

    no, nothing working atm, I'm using the 1.0.1 API (recommended Build)
     
  6. Offline

    ArcheCane

    use the new system.
     
  7. Offline

    edocsyl

    ArcheCane How to use the new system? Any exemple or what changed ?
     
  8. Offline

    desht

  9. Offline

    jdjack

    Still doesn't work. Really Stuck. :(

    i have back tracked to the 1.0.0 API and all seems good so i shall work with that!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
Thread Status:
Not open for further replies.

Share This Page