First Plugin does not work anymore

Discussion in 'Plugin Development' started by Freak1992, Feb 27, 2011.

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

    Freak1992

    Hi :)
    Sry for my bad english

    I have a problem with my first plugin.
    I only get errors ;(
    With the old bukkit version it has work

    Error:

    2011-02-27 18:31:14 [SEVERE] Could not load plugins\ucpreg.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:85)
    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:58)
    at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:187)
    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:174)
    at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:120)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:227)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    Caused by: java.lang.ClassNotFoundException: freak1992.ucpreg
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:30)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)

    src:

    main class:

    Code:
    package freak1992.ucpreg;
    
    import java.io.File;
    import java.util.HashMap;
    import org.bukkit.entity.Player;
    import org.bukkit.Server;
    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;
    
    /**
     * ucpreg for Bukkit
     *
     * @author freak1992
     */
    public class ucpreg extends JavaPlugin {
        private final ucpregPlayerListener playerListener = new ucpregPlayerListener(this);
        private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
    
        public ucpreg(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 events
    
            // Register our events
            PluginManager pm = getServer().getPluginManager();
    
            pm.registerEvent(Event.Type.PLAYER_COMMAND, this.playerListener, 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);
        }
    }
    
    
    class

    Code:
    package freak1992.ucpreg;
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.MalformedURLException;
    import java.net.URI;
    import java.net.URL;
    
    import org.bukkit.Location;
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerChatEvent;
    import org.bukkit.event.player.PlayerEvent;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.event.player.PlayerMoveEvent;
    
    /**
     * Handle events for all Player related events
     * @author freak1992
     */
    public class ucpregPlayerListener extends PlayerListener {
        private final ucpreg plugin;
    
        public ucpregPlayerListener(ucpreg instance) {
            plugin = instance;
        }
    
        public void onCommand(PlayerChatEvent event) {
            String[] split = event.getMessage().split(" ");
            Player player = event.getPlayer();
    
            if (split[0].equalsIgnoreCase("/register")) {
                if(!split[1].equalsIgnoreCase("")){
    
                }else{
                    player.sendMessage("Bitte /register <Passwort> verwenden");
                }
                event.setCancelled(true);
            }
    
        }
    
        public boolean register(String name, String passwort) throws IOException{
            URL url = new URL("http://localhost/api.php");
            BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        url.openStream()));
    
            String inputLine;
    
            inputLine = in.readLine();
            in.close();
            if(inputLine.equals("1")){
                return true;
            }else{
                return false;
            }
        }
    }
    
    
     
  2. Offline

    Edward Hand

    Remove:
    Code:
        public ucpreg(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

    Freak1992

    does not work ;(

    edit:
    full src:
    http://ul.to/1r58tz

    2011-02-27 18:46:17 [SEVERE] Could not load plugins\ucpreg.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:85)
    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:58)
    at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:187)
    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:174)
    at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:120)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:227)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    Caused by: java.lang.ClassNotFoundException: freak1992.ucpreg
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:30)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:72)
    ... 8 more
    2011-02-27 18:46:17 [INFO] Done (1219913114ns)! For help, type "help" or "?"
     
  4. Offline

    DiaAWAY

    PLAYER_COMMAND does not exist anymore.

    the entire structure of your plugin is now deprecated, there has been major changes to how commands work, read the "ooops i broke your plugin" threads.

    basicly, all commands are now interpreted in the main class file (in your case the ucpreg class), override onCommand there and implement your onCommand functionality from the PlayerListener
     
Thread Status:
Not open for further replies.

Share This Page