Plugin error cmd can't be resolved

Discussion in 'Plugin Development' started by Niels15, Dec 29, 2011.

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

    Niels15

    Hi,

    I was making a plugin but I've got this error:

    Code:
    [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'ticket' in plugin Ticket v0.1
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:165)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:378)
        at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:757)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:722)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:715)
        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:93)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:108)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:527)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    Caused by: java.lang.Error: Unresolved compilation problems:
        cmd cannot be resolved
        cmd cannot be resolved
    
        at nl.niels15.ticket.TicketCommandExecutor.onCommand(TicketCommandExecutor.java:21)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40)
        ... 12 more
    Cmd cannot be resolved, but i can't import cmd.getName.
    This is my TicketCommandExecutor class:
    Code:
    package nl.niels15.ticket;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class TicketCommandExecutor implements CommandExecutor {
    
        private Ticket plugin;
    
        public TicketCommandExecutor(Ticket plugin) {
            this.plugin = plugin;
        }
    
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player player = null;
            if (sender instanceof Player) {
                player = (Player) sender;
            }
            if (cmd.getName().equalsIgnoreCase("ticket")){ // If the player typed /basic then do the following...
                sender.sendMessage("Je ticket/report is verzonden!");
                return true;
            } else if (cmd.getName().equalsIgnoreCase("ticket2")) {
                if (player == null) {
                    sender.sendMessage("Dit command kan alleen in-game worden uitgevoerd!");
                } else {
                    sender.sendMessage("Typ /ticket <tekst> om je report te verzenden!");
                }
                return true;
            }
            return false;
        }
    }
    I hope somebody can help me :)

    Niels15

    Sorry for my bad English
     
  2. Offline

    tkausl

    Look into the Method.
    You get the Parameter Command command, and in the Method-Body you try to use cmd
     
  3. Offline

    Niels15

    Thnx, he works now :D
     
  4. Offline

    ItsHarry

    Obviously dutch, can tell from the grammar :D
     
Thread Status:
Not open for further replies.

Share This Page