Why this runtime error?

Discussion in 'Plugin Development' started by Canownueasy, Apr 4, 2011.

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

    Canownueasy

    Code:
    17:04:35 [INFO] Starting minecraft server version Beta 1.4
    17:04:35 [INFO] Loading properties
    17:04:35 [INFO] Starting Minecraft server on *:25565
    17:04:35 [WARNING] **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
    17:04:35 [WARNING] The server will make no attempt to authenticate usernames. Be
    ware.
    17:04:35 [WARNING] While this makes the game possible to play without internet a
    ccess, it also opens up the ability for hackers to connect with any username the
    y choose.
    17:04:35 [WARNING] To change this, set "online-mode" to "true" in the server.set
    tings file.
    17:04:35 [INFO] This server is running Craftbukkit version git-Bukkit-0.0.0-612-
    g4c7a9e7-b617jnks (MC: 1.4)
    17:04:35 [INFO] Preparing level "world"
    17:04:35 [INFO] Preparing start region
    17:04:35 [INFO] 144 recipes
    17:04:36 [SEVERE] null loading NappoNameChange v0.1 (Is it up to date?)
    java.lang.NullPointerException
            at com.nappo.bukkit.NameChangePlugin.onEnable(NameChangePlugin.java:15)
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:118)
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:514)
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:216)
            at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:94)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:72)
            at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:215)
            at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:202)
            at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:142)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:257)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:375)
    17:04:36 [INFO] Done (0.109s)! For help, type "help" or "?"
    >
    Here is the plugin code:
    Code:
    package com.nappo.bukkit;
    import org.bukkit.plugin.java.JavaPlugin;
    
    /**
     * Allows players to change their display names.
     * @author Canownueasy
     */
    public class NameChangePlugin extends JavaPlugin {
    
    	@Override
    	public void onDisable() {}
    
    	@Override
    	public void onEnable() {
    		getCommand("name").setExecutor(new NameChangeCommand());
    	}
    
    }
    Code:
    package com.nappo.bukkit;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    /**
     * Executes the name change command.
     * @author Canownueasy
     */
    public class NameChangeCommand implements CommandExecutor {
    
    	@Override
    	public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    		if(sender instanceof Player) {
    			Player player = (Player) sender;
    			if(player.isOnline()) {
    				player.setDisplayName(args[0]);
    				sender.sendMessage("Your display name has been set to: " + args[0]);
    			}
    			return true;
    		}
    		return false;
    	}
    
    }
     
  2. Offline

    Edward Hand

    Did you register the command in your plugin.yml?
     
  3. Offline

    Canownueasy

    No. How would I go about doing that?
     
  4. Offline

    opez

    I just started making plugins so not 100% sure but this seems to work (from looking at other plugins). I dont know where this is documented but if someone could point out where it is, I would be grateful.

    In the plugin.yml you need to add a section for commands in this format
    Code:
    commands:
      [the_command]:
        description: [a_description_of_the_command]
        aliases: [any_alias]
        usage: /<command> [arguments]
      [the_command2]:
        description: [a_description_of_the_command2]
        aliases: [any_alias2]
        usage: /<command> [arguments2]
    
    etc.

    So for your case.
    Code:
    commands:
      name:
        description: Change your display name
        aliases: name      (Not sure if this line is necessary)
        usage: /<command> [new_name]
    
     
  5. Offline

    Canownueasy

    It's okay I just read the plugin loader but thanks anyway :p
     
  6. Offline

    opez

    Would you be so kind to point to where this info is? tia!
     
  7. Offline

    Canownueasy

    In the Bukkit source code.
     
Thread Status:
Not open for further replies.

Share This Page