Solved BlockListener help!

Discussion in 'Plugin Development' started by CraftyMclovin, Oct 10, 2012.

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

    CraftyMclovin

    slight problem, jenkins requires a username and password to access So Bukkit: http://ci.bukkit.org isn't available!

    also if you get the bukkit from, http://dl.bukkit.org/downloads/bukkit/view/01433_1.3.2-R1.0/ There is no BlockListener associated with this .jar.. I tried making a plugin and i got the errors
    "Type and Priority saying that it cannot be resolved or is not a field" and there was no option to import BlockListener from bukkit, only create a new class.

    I would appreciate any help in resolving this, i am fairly new to java and am using eclipse to do my coding. So please reply in lamens terms as everything i know so far has been through tutorials but i am a very very fast learner and can follow instructions pretty easily.

    Regards
    Crafty
     
  2. Offline

    javoris767

    The bukkit jenkins has been down for a while... Also, are you doing the old event system? The new one would be.
    Code:
    Bukkit.getPluginManager().registerEvents(new BlockListener, this);
    and it registers every event.
     
  3. Offline

    Drkmaster83

    BlockListener and PlayerListener no longer exist. This confuses many new BukkitDevs because of the outdated tutorials. Instead of using PlayerListener and BlockListener, the new event system class would be:
    Code:
    public class EverythingListener implements Listener{
        @EventHandler
        public void onBlockBreak(BlockBreakEvent event){
            Block block = (Block) event.getBlock();
            Entity blockBreaker = (Entity) event.getEntity();
            if(block.getType() == Material.STONE && blockBreaker instanceof Player){
                Player blockBreakerPlayer = (Player) blockBreaker;
                blockBreakerPlayer.sendMessage("You have just broken a piece of stone. You proud of that BRO?");
            }
            else if(blockBreaker instanceof Player){
                Player blockBreakerPlayer = (Player) blockBreaker;
                blockBreakerPlayer.sendMessage("You have broken another block other than stone. WOW BRO!");
            }
        }
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent e){ //This will spam the player I think XD
            Player mover = (Player) e.getPlayer();
            mover.sendMessage("OMG YOU JUST MOVED!");
        }
    }
    After this, in your main class, in your onEnable() method, you would put:
    Code:
    // Above your onEnable:
    public final EverythingListener EL = new EverythingListener(this);
    public void onEnable(){
        PluginManager PM = this.getServer().getPluginManager();
        PM.registerEvents(EL, this);
        // Whatever more code
    }
     
  4. Offline

    Sagacious_Zed Bukkit Docs

Thread Status:
Not open for further replies.

Share This Page