MOAR AND MOAR CODE HELP!!!

Discussion in 'Plugin Development' started by theosaman, Jul 5, 2012.

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

    theosaman

    Today I have a new error.....
    my server say's: at me.theosaman.BlockChanger2.BlockChanger2.<init>(BlockChanger2.java:20
    And then it repeats for about 40 lines..
    Can someine figure out what is going on?
    please note. I have compiled it correctly, all the code has no errors, there are two class files BlockChanger.java and BlockChangerListener.java.
     
  2. no cplie code != no runtimke errors, its called RUNTIMEerrors for an reason....
     
  3. Offline

    theosaman

    What dose cplie code mean?
     
  4. compile, I made ,much typos this time
     
  5. Offline

    Jnorr44

    Haha you made much typos again this time.
    It's alright, you type fast! haha
     
    ferrybig likes this.
  6. Some code would be usefull, and the full stack trace(the error) because this is not telling us what we need...

    greetz blackwolf12333
     
  7. Offline

    theosaman

    Here is the code from the main class...
    Code:
    package me.theosaman.BlockChanger2;
     
    import java.util.ArrayList;
     
    import java.util.logging.Logger;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
     
    public class BlockChanger2 extends JavaPlugin
    {
       
        private static final Logger log = Logger.getLogger("Minecraft");
        private final BlockChanger2 blockListener = new BlockChanger2();
        public final ArrayList<Player> BlockChangerUsers = new ArrayList<Player>();
       
        @Override
        public void onEnable()
        {
            log.info("[BlockChanger] has been enabled!");
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents((Listener) this.blockListener, this);
        }
     
           
        @Override
        public void onDisable()
        {
            log.info("[BlockChanger] has been disabled!");
        }
       
        @Override
        public boolean onCommand(CommandSender sender, Command amd, String commandLabel, String[] args)
        {
            if(commandLabel.equalsIgnoreCase("BlockChanger"))
                toggleBlockChanger(sender);
       
            return true;
       
        }   
       
        private void toggleBlockChanger(CommandSender sender)
        {
            if( !enabled((Player) sender) )   
            {
                BlockChangerUsers.add((Player) sender);
                ((Player)sender).sendMessage(ChatColor.BLUE + "[BlockChanger] has been enabled!");
            }
           
            else
            {
                BlockChangerUsers.remove((Player) sender);
                ((Player) sender).sendMessage(ChatColor.RED + "[BlockChanger] has been disabled!");}
            }
       
       
        public boolean enabled(Player player)
        {
            return BlockChangerUsers.contains(player);
        }
        }    
     
  8. Offline

    pd9937

    If the plugin class is called "BlockChanger2", why do you add itself as a member?
    I think (especially because you say that the error repeats itself) that the server if cqught in an infinite loop, because the class creates a new instance of itself every time you create a new instance of it!

    Oh and the class you register as a listener doesn't even implement the Listener interface. You'd better look at http://wiki.bukkit.org/Plugin_Tutorial#Java_IDEs and http://wiki.bukkit.org/Introduction_to_the_New_Event_System
     
    ferrybig likes this.
Thread Status:
Not open for further replies.

Share This Page