Solved Command returning command name when used, doesn't work either.

Discussion in 'Plugin Development' started by ipodtouch0218, May 10, 2016.

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

    ipodtouch0218

    Hey, I've been making a plugin and I've run into an error with a command.

    Code:
    if (cmd.getName().equalsIgnoreCase("lag")) {
                if (!(sender instanceof Player)) {
                    Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Only players can use this Command!");
                    return true;
                }
                Player player = (Player) sender;
                if (args.length == 0) {
                    CraftPlayer cp = (CraftPlayer) player;
                    EntityPlayer ep = cp.getHandle();
                    sender.sendMessage(ChatColor.BOLD + "Your Ping: " + ChatColor.WHITE + ep.ping + "ms");
                    return true;
                }
                if (args.length == 1) {
                    String target = args[0];
                    Player tp = Bukkit.getServer().getPlayer(target);
                    if (tp == null) {
                        sender.sendMessage(ChatColor.GOLD + "Player not found!");
                        return true;
                    } else {
                        if (player == tp) {
                            CraftPlayer cp = (CraftPlayer) player;
                               EntityPlayer ep = cp.getHandle();
                               sender.sendMessage(ChatColor.GOLD + "Your Ping: " + ChatColor.WHITE + ep.ping + "ms");
                               return true;
                        } else {
                        CraftPlayer cp = (CraftPlayer) tp;
                        EntityPlayer ep = cp.getHandle();
                        sender.sendMessage(ChatColor.GOLD + target + "'s Ping: " + ChatColor.WHITE + ep.ping + "ms");
                        return true;
                        }
                    }
                    }
                sender.sendMessage(ChatColor.GOLD + "Too many arguments!");
                return true;
                }
            }
    No error shows up in the console or chat, it just echos.

    Any help?

    Thanks in advance.
     
  2. Offline

    WolfMage1

  3. Offline

    ipodtouch0218

    Last edited: May 10, 2016
  4. Offline

    ipodtouch0218

    @WolfMage1

    Updating the imports to 1.9_R1 doesn't help, still the same result.
    This happened on 1.8, too
     
  5. Online

    timtower Administrator Administrator Moderator

  6. Offline

    ipodtouch0218

    Closest thing I have to a server log is the plugin starting up:

    [Server] INFO Disabling PluginExtras v1.1
    [Server] INFO Enabling PluginExtras v1.1
    [Server] INFO PluginExtras has been reloaded.

    When the command is used (and aliases, so plugin.yml isn't at fault):
    [Server] INFO /lag
    [Server] INFO /ping
    [Server] INFO /pingtest
     
  7. Online

    timtower Administrator Administrator Moderator

  8. Offline

    ipodtouch0218

  9. Online

    timtower Administrator Administrator Moderator

    @ipodtouch0218 Could you remove Citizens anyways? It is kinda filling up your log.
    And could you provide a log where the commands are actually used and throw errors?
     
  10. Offline

    ipodtouch0218

    Removed citizens

    http://pastebin.com/H7Cd1Wba

    /nv is a night vision command, which is why it isn't able to be used by the console. Same .class as /ping
    /pinfo works. Same .class as /ping as well

    The commands themselves don't throw errors, which is why I haven't been able to fix it.
     
  11. Offline

    Zombie_Striker

    Code:
    [09:52:28] [Server thread/WARN]: [WorldEdit]
    **********************************************
    ** This WorldEdit version does not fully support your version of Bukkit.
    **
    ** When working with blocks or undoing, chests will be empty, signs
    ** will be blank, and so on. There will be no support for entity
    ** and biome-related functions.
    **
    ** Please see http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters
    **********************************************
    You should download the new version of Worldedit.

    Have you debugged? Do you know which line 'breaks' your command?
     
  12. Offline

    ipodtouch0218

    Yeah I know, just haven't gotten around to it.


    Also, I've managed to fix it myself. The braces were unbalanced for the command. Fixed it by adding 1 for open and subtracting 1 for closed.

    Thanks for the help.

    Ready for locking the thread, @timtower
     
  13. Offline

    Zombie_Striker

    @ipodtouch0218
    No need to lock it. Just mark this thread as solved. Go to the top of the page > ThreadTools > EditTitle > add the Solved prefix
     
    timtower likes this.
  14. Offline

    ipodtouch0218

    Thought you had to lock it. Thanks again
     
Thread Status:
Not open for further replies.

Share This Page