First Plugin - some Problems (German)

Discussion in 'Plugin Development' started by Kajiakuma, Jul 21, 2011.

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

    Kajiakuma

    Hallo,
    ich habe ein Problem mit meinem ersten Bukkit Problem. Und zwar startet es
    nicht. Ich packe das Projekt als .jar (nicht executable jar!), kopiere die
    Resurection.jar ins Plugin Verzeichnis, lade die Plugins am Server neu
    (/reload) und teste den Befehl der die Hilfe meines Plugins anzeigen sollte
    (/res) und ich bekomme die Meldung, dass der Befehl nicht existiert
    und das wars. Im Server Log müsste bei Plugin Start eine Rückmeldung des
    Plugins zu lesen sein: "[Resurection]: Version 1.0 enabled" aber die
    ist im Server Log ebenfalls nicht zu sehen.

    Erklärung zum Plugin:
    Ich will ein Plugin zur erstellung Multipler Respawnpunkte erstellen, ähnlich wie das veraltete Plugin Graveyards. Ich habe es in Version 1.0 auf einen Respawnpunkt vereinfacht um eine testbare Vorabversion schneller parat zu haben. Mit Version 1.1 wollte ich die Multiplen Respawnpunkte einführen und mit 1.2 Multiworld Support. Soweit der Plan.^^

    Resurection.class (Main):
    Code:
    package de.Kajiakuma.Resurection;
    
    import org.bukkit.Location;
    import org.bukkit.event.Event;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    /*
     * @author Kajiakuma
     * @version 1.0
     */
    public class Resurection extends JavaPlugin{
    
    	private ResurectionPlayerListener playerlistener = new ResurectionPlayerListener(this);
    	static String maindirectory = "Resurection/";
    	static Object [] graveyard;
    
    
    	public void onEnable() {
    		PluginManager pm = getServer().getPluginManager();
    
    		loadGraveyard();
    
    		// Once you have a reference to your PluginManager object, use it to register each event you want to use.
    		pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerlistener, Event.Priority.Low, this);
    
    		getCommand("res").setExecutor(new ResurectionCommand(this));
    		getCommand("res set").setExecutor(new ResurectionCommand(this));
    		getCommand("res add").setExecutor(new ResurectionCommand(this));
    
    		PluginDescriptionFile pdfFile = this.getDescription();
    		System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
    	}
    
    	public void onDisable() {
    		System.out.println("[Resurection]: Version 1.0 disabled");
    	}
    
    	public static void setGraveyard(String name, Location respawnLocation){
    		graveyard[0]=name;
    		graveyard[1]=respawnLocation;
    	}
    
    
    	public void loadGraveyard(){
    		LoadSettings.loadMain();
    	}
    }
    
    
    ResurectionCommand.class:
    Code:
    package de.Kajiakuma.Resurection;
    
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class ResurectionCommand implements CommandExecutor{
    
    	@SuppressWarnings("unused")
    	private final Resurection plugin;
    
    	public ResurectionCommand(Resurection plugin){
    		this.plugin = plugin;
    	}
    
    	public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
    
            if (!(sender instanceof Player)) {
                return false;
            }
    
            Player player = (Player) sender;
    
            if (split.length == 0) {
            	player.sendMessage("===Resurection Help===");
    			player.sendMessage(" /res #shows this Help");
    			player.sendMessage(" /res set <name> #set the Respawn location");
    			player.sendMessage(" The /res add <name> #command will comming soon with multiple Respawn Locations!");
            }
    
            if(split.length >= 2 && split[0].equalsIgnoreCase("/res") && split[1].equalsIgnoreCase("set")){
    
    			Location respawnLocation = ((Player) sender).getLocation();
    			Resurection.setGraveyard(split[2],respawnLocation);
            }
    
    		if (split[0].equalsIgnoreCase("/res") && split[1].equalsIgnoreCase("set") && split[2].equalsIgnoreCase("")){
    			player.sendMessage(" /res set <name> #set the Respawn location");
    		}
    
    		if (split[0].equalsIgnoreCase("/res") && split[0].equalsIgnoreCase("add")){
    			player.sendMessage("===Command will comming soon!===");
    			player.sendMessage("Syntax: /res add <name>");
    		}
    
    		return true;
    	}
    
    }
    
    
    Ich wette, dass es ein Grundlegender Fehler im Zusammenhang mit Bukkit ist,
    aber ich seh es nicht >.< Sagt bescheid, wenn ihr die anderen Klassen bzw. die Plugin.yml braucht.
     
  2. Offline

    Sacaldur

    translated:
    He cant start his plugin using "/reload", "/res" causes an error message (unknown command) and "[Resurection]: Version 1.0 enabled" wont print by the server

    Der Serevrlog wird dir auch nur das zeigen, was dir die Konsole ausgibt (the log file contains only the server console outputs)
    soweit ich weiß, ist der Befehl "/reload" kein Standardbefehl des Servers (for all I know, "reload" isn't a default server command)
    hast du das entsprechende Plugin installiert? (do you have installed the corresponding plugin?)
    hast du schonmal versucht, den Server neu zu starten? (did you tried to restart the server?)

    beachte die Namenskonventionen in Java für Package-Namen! (note javas package name convention)
    sie werden immer klein geschrieben! (Klassen beginnen mit einem großen Buchstaben, keine Packages) (they're always lowercase (class names starts with a capital letter, but not packages))

    Bitte stelle deine Fragen demnächst auf englisch, damit hier auch mehr Leute antworten können (ask in the next time in english, please, so other people can help you, too)

    Sacaldur
     
  3. Offline

    RedFoxRedI

    Ich habs mal copy/paste gemacht und dann exportiert. Scheint grundsätzlich zu funktionieren. Falls du den Fehler noch nicht gefunden hast, poste doch mal die anderen Klassen und die plugin.yml.

    Übrigens Resurection schreibt man eigentlich: Resurrection

    And in English: I've copy/pasted it and then made an export. Seems to work correctly. If you haven't found the error by now, you should poste the other classes and the plugin.yml.

    By the way resurection is spelled: resurrection

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  4. Offline

    Kajiakuma

    Na schön, also in Zukunft nur Englisch, ok. Fair enough, next time only in English.
    I tried to restart the Server instead of the /reload command (Yes I have the needed plugin), but without changes.
    I considered the java package name convention, didn't I? I haven't found the error, so I post the other classes now:

    Plugin.yml:
    Code:
    name: Resurection
    version: 1.0
    main: de.Kajiakuma.Resurection.Resurection
    website:
    description: >
        Multiple Player Respawn Locations
    commands:
      res:
        description: Info
        usage: /res
      res set:
        description: Set Respawn location (Version 1.0, becomes dispensable in later versions)
        usage: /res set <name>
      res add:
        description: Adds a respawn location (Version 1.1 and higher)
        usage: /res add <name>
    
    ResurectionPlayerListener.class:
    Code:
    package de.Kajiakuma.Resurection;
    
    import org.bukkit.Location;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.event.player.PlayerRespawnEvent;
    
    public class ResurectionPlayerListener extends PlayerListener{
    
        public static Resurection plugin;
    
        public ResurectionPlayerListener(Resurection instance) {
            plugin = instance;
        }
    
        @Override
        public void onPlayerRespawn(PlayerRespawnEvent event){
            event.setRespawnLocation((Location) Resurection.graveyard[1]);
        }
    }
    
    
    Ignore funktion "loadGraveyard" in class Resurection, I'am not finished with class LoadSettings. But that don't triggered the error.

    I know, that Resurection is spelled Resurrection. I will change it bevore I release it, but not now. Anyone an idea why the plugin don't load?
     
  5. Commands can't have a space. "/res set" and "/res add" would be sub-commands for you, but they aren't handled by the plugin.yml. Writing it with spaces like you did makes the yml invalid, thus it won't load correctly.
    You register your res-command and check in onCommand for the first argument.
     
  6. Offline

    RedFoxRedI

    I've copied the plugin.yml and the other class and it's working fine.

    Server log:
     
  7. Offline

    Kajiakuma

    Alright I get the following error message:
    Code:
    2011-07-22 13:55:36 [SEVERE] Could not load 'plugins/Resurection.jar' in folder 'plugins': 
    java.io.FileNotFoundException: Jar does not contain plugin.yml
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:64)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:207)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:130)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:128)
        at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:378)
        at org.bukkit.command.SimpleCommandMap$ReloadCommand.execute(SimpleCommandMap.java:281)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:129)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:320)
        at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:713)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:677)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:670)
        at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:33)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:85)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    
    The file "plugin.yml" exists. I tried to rename it from Plugin.yml to plugin.yml but no change. Why does he not find the file? *confused*

    Problem solved: I'am to stupid to export the plugin into the .jar file XD

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
Thread Status:
Not open for further replies.

Share This Page