My plugin won't load (anymore)

Discussion in 'Plugin Development' started by AaronLLF, Feb 26, 2011.

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

    AaronLLF

    So, I made a plugin for CraftBukkit build 439 called AFK. But I got some reports saying that it doesn't work for CB build 452+. This is the error code:
    Code:
    2011-02-26 23:45:49 [SEVERE] Could not load plugins\AFK.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:80)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:129)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:94)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:59)
    at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:204)
    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:191)
    at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:131)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:246)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    Caused by: java.lang.NoSuchMethodException: com.aaronllf.afk.AFK.<init>()
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.getConstructor(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:75)
    ... 8 more
    This is my AFK class (AFK.java):
    Code:
    package com.aaronllf.afk;
    
    import java.io.File;
    import java.util.HashMap;
    import org.bukkit.entity.Player;
    import org.bukkit.Server;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.event.Event;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginLoader;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.plugin.PluginManager;
    
    /**
    *
    * @author AaronLLF
    */
    public class AFK extends JavaPlugin {
        private final AFKPlayerListener playerListener = new AFKPlayerListener(this);
        private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
    
        public AFK(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 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("AFK disabled.");
        }
    
        public void onEnable() {
            // TODO: Place any custom enable code here including the registration of any events
    
            // Register our events
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, 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 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);
        }
    }
    
    
    If anyone can tell me what's wrong with it I'd really appreciate it. I also just don't want to give out AFKPlayerListener because it clearly has nothing to do with the problem.
     
  2. Offline

    Edward Hand

    You need to delete this bit:
    Code:
    public AFK(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
        }
    
    That should be it.
     
  3. Offline

    AaronLLF

    Um... so... I got it to load, but this line:
    Code:
    pm.registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
    
    Gives me an error, so I changed PLAYER_COMMAND to PLAYER_COMMAND_PREPROCESS. But now the player cannot use the /afk command. Help please? =(
     
  4. Offline

    Saturisk

    PLAYER_COMMAND_PREPROCESS is not one of the availabe event types. See here for more info: http://wiki.bukkit.org/Event_Types.
    --- merged: Feb 27, 2011 5:27 AM ---
    And 'it gives me an error' isn't all that helpful when trying to get an answer!
     
  5. Offline

    AaronLLF

    Yeah, well, I got it to work, so nevermind...
     
  6. Offline

    pocketpcer

    How did you get it working? I'm having the same problem. I think the BUKKIT update is where the PLAYER_COMMAND was removed or something...
     
Thread Status:
Not open for further replies.

Share This Page