New command interface! Everything is broken!

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

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

    madcap

  2. Offline

    speeddemon92

    Wow the changes that happen when you go away from trying to develop a plugin for a week.

    I just want to get this straight, If I have this:
    Code:
    public void onEnable()
    {
        getCommand("kerberos").setExecutor(new KPListener(this));
        // blah blah blah
    }
    
    Then i have to have a onCommand inside the "KPListener" class to catch the use of the "/kerberos" command, correct?
     
  3. Offline

    vanwed94

    ok so I am VERY new to plugin coding and i just wanted to make a simple /god plugin on my own and i think i have this correct but it gives me this when i execute the command
    Code:
    2011-08-22 11:24:10 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'god' in plugin God v0.1
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:129)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:352)
        at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:737)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:701)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:694)
        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:89)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:454)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:363)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Caused by: java.lang.NullPointerException
        at god.God$1.onCommand(God.java:33)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
        ... 12 more
    i have no idea what is going on I am using Netbeans and i says that it is fine this is the code that i have
    Code:
    package god;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class God extends JavaPlugin{
    private PluginManager manager;
    private PluginDescriptionFile info;
        public static void main(String[] args) {
    
        }
            Player player;
        @Override
        public void onDisable() {
        }
    
        @Override
        public void onEnable() {
            manager = getServer(). getPluginManager();
            info = getDescription();
            System.out.println(info.getName() + " Version " + info.getVersion()
                    + " Has been Enabled");
    
            getCommand("god").setExecutor(new CommandExecutor() {
                @Override
                public boolean onCommand(CommandSender sender, Command command, String string, String[] args) {
                    sender.sendMessage("God");
                    player.setHealth(2000);
                    return true;
                }
            });
    
             getCommand("ungod").setExecutor(new CommandExecutor() {
                @Override
                public boolean onCommand(CommandSender sender, Command command, String string, String[] args) {
                    sender.sendMessage("God");
                    player.setHealth(20);
                    return true;
                }
                });
    
            }
        }
    And this is my plugin.yml
    Code:
    name: God
    version: 0.1
    main: god.God
    author: vanwed94
    commands:
      god:
        description: God Mode
        permission: God.god
        usage: |
           Usage /<command>
      ungod:
        description: Ungod Yourself
        permission: God.ungod
        usage: |
           Usage /<command>
    I need help cause i have no idea what is going on
    Edit: I have no other files i wanted to keep it all in one place
     
  4. Offline

    Shamebot

    @vanwed94 This doesn't belong in this thread. The problem is that your player variable is never initialized. If the CommanSender is a Player you can get it with
    Code:
    Player player = (Player)sender;
    If you need more help start a new thread.
     
  5. Offline

    vanwed94

    @Shamebot
    ooohhh that explains alot thanks for the help that fast
     
  6. Offline

    Jaker232

    That looks cool. Thanks for the fixes. My plugin doesn't run on commands yet.
     
  7. Offline

    sddddgjd

    This thread was made in february...who the hell bumped it?
     
  8. Offline

    Jaker232

    Not me. Someone bumped it and it caused more people to post.
     
  9. Offline

    Windwaker

    I dun liek change
     
  10. Any news about that?
     
Thread Status:
Not open for further replies.

Share This Page