basic problem with the block listener

Discussion in 'Plugin Development' started by darknesschaos, Jan 25, 2011.

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


    I don't know why, but this doesn't work.

    package com.bukkit.darknesschaos.Picasso;
    import java.util.HashMap;
    import org.bukkit.Server;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginLoader;
    import org.bukkit.plugin.PluginManager;
     * VoidMage for Bukkit
     * @author Darknesschaos
    public class Picasso extends JavaPlugin {
        private final PicassoBlockListener blockListener = new PicassoBlockListener(this);
        private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
        public Picasso(PluginLoader pluginLoader, Server instance,
                PluginDescriptionFile desc, File folder, File plugin,
                ClassLoader cLoader) {
            super(pluginLoader, instance, desc, folder, plugin, cLoader);
            // TODO: Place any custom initialisation code here
            // NOTE: Event registration should be done in onEnable not here as all events are unregistered when a plugin is disabled
        public void onEnable() {
            // TODO: Place any custom enable code here including the registration of any event
            // Register our events
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.BLOCK_DAMAGED, this.blockListener, Event.Priority.Normal, this);
            // EXAMPLE: Custom code, here we just output some info so we can check all is well
            PluginDescriptionFile pdfFile = this.getDescription();
            System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
        public void onDisable() {
            // TODO: Place any custom disable code here
            // NOTE: All registered events are automatically unregistered when a plugin is disabled
            // EXAMPLE: Custom code, here we just output some info so we can check all is well
            System.out.println("Goodbye world!");
        public boolean isDebugging(final Player player) {
            if (debugees.containsKey(player)) {
                return debugees.get(player);
            } else {
                return false;
        public void setDebugging(final Player player, final boolean value) {
            debugees.put(player, value);
    The listener
    package com.bukkit.darknesschaos.Picasso;
    import org.bukkit.Material;
    import org.bukkit.block.BlockDamageLevel;
    import org.bukkit.event.block.BlockDamageEvent;
    import org.bukkit.event.block.BlockListener;
     * <pluginname> block listener
     * @author <yourname>
    public class PicassoBlockListener extends BlockListener {
        private final Picasso plugin;
        public PicassoBlockListener(final Picasso plugin) {
            this.plugin = plugin;
        public void onBlockDamaged(BlockDamageEvent event)
        if (event.getDamageLevel()==BlockDamageLevel.BROKEN
                && event.getBlock().getType() == Material.WOOL)
               event.getPlayer().sendMessage("punch that wool.");
    What could I be doing wrong?
  2. Offline


    without reading everything, check if it should be onBlockDamage or onBlockDamaged, same throughout
  3. Offline


    nope, still cant get it to work...
    --- merged: Jan 26, 2011 5:02 PM ---
    false alarm. got it to work.
Thread Status:
Not open for further replies.

Share This Page