Weird Problem

Discussion in 'Plugin Development' started by Flappie, Oct 8, 2011.

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

    Flappie

    Ok, i've had this problem for a while now.

    Each time i try to compile my plugin, it seems that only the main class is working the one with the onEnable and onDisable, and my listeners are not created when they should, i would really appeciate if someone could help me, i've seen other people with this problem but i've never found a fix.

    for some reason it does load in the console, but the actual code isnt working ..

    MainClass (this loads properly to some extend.)

    Code:
    package nick.bukkit.tntnote;
    
    import java.util.logging.Logger;
    
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class TNTNote extends JavaPlugin {
    
        private Logger log = Logger.getLogger("Minecraft");
    
        public void onEnable() {
            PluginManager pm = getServer().getPluginManager();
    
            pm.registerEvent(Event.Type.BLOCK_PLACE, new TNTNoteBlockListener(), Priority.Highest, this);
     
            this.logMessage("Enabled");
        }
    
        public void onDisable() {
            this.logMessage("Disabled");
        }
    
        protected void logMessage(String msg){
            PluginDescriptionFile pdFile = this.getDescription();
            this.log.info(pdFile.getName() + " " + pdFile.getVersion() + ": " + msg);
        }
    }
    This wont work at all..

    Code:
    package nick.bukkit.tntnote;
    
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.event.block.BlockListener;
    import org.bukkit.event.block.BlockPlaceEvent;
    
    public class TNTNoteBlockListener extends BlockListener {
    
        public void OnBlockPlace(BlockPlaceEvent event){
            if(event.isCancelled()) return;
    
            Block block = event.getBlock();
    
            if(block.getType() == Material.DIRT){
                block.setType(Material.CAKE_BLOCK);
            }
        }
    
    }
    for the hell of it..

    Code:
    name: Lols
    main: nick.bukkit.tntnote.TNTNote
    version: 0.1
    description: >
                 Hello World!
    commands:
     
  2. Offline

    vaiquero

    public void OnBlockPlace(BlockPlaceEvent event){

    to

    public void onBlockPlace(BlockPlaceEvent event){
     
  3. Offline

    FenixAzul

    try replacing ur registers to
    pm.registerEvent(Event.Type.BLOCK_PLACE, NAMEOFCLASS , Priority.Highest, this);
     
  4. Offline

    vaiquero

    That is incorrect syntax, however we can do something like this:
    BlockListener blockListen = new TNTNoteBlockListener();
    pm.registerEvent(Event.Type.BLOCK_PLACE, blockListen, Priority.Highest, this);

    Although, that will not the fix the issue here, the methods overrided in the block listener are case sensitive, so it has to be from OnBlockPlace to onBlockPlace.
     
  5. Offline

    FenixAzul

    it work for me =) , i missed the listener object creation my bad lol its like vaiquero says
     
Thread Status:
Not open for further replies.

Share This Page