Help Commands not working!

Discussion in 'Plugin Development' started by Chibbey, Aug 26, 2013.

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

    Chibbey

    Hello, I just started developing and was bored so i thought i should make a random plugin i have never seen, its a GG (Good Game) plugin, so when you type /gg it sends a broadcasts a message saying "(Name) says good game to everyone!" but when i type /gg in game it doesnt do anything and sends a message to me saying /gg and it happends to all my plugins also, do u know why, heres my code:

    Code:
    package me.chibbey.gg;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class GG extends JavaPlugin {
       
        public boolean onCommand(CommandSender sender, Command cmd, String[] commandLabel, String[] args) {
            if (cmd.getName().equalsIgnoreCase("gg"));
            Bukkit.getServer().broadcastMessage(ChatColor.AQUA + sender.getName() + " says good game to everyone!");
            return false;
        }
     
    }
    
    Please help me!

    Oh Also my plugin.yml says

    name: GG
    main: me.chibbey.gg.GG
    version: 1.0
    description: Say goodgame to everyone!

    commands:
    gg:
    usage: /<command>
    description: Say good game to everyone!

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

    metalhedd

    did you list the command in your plugin.yml file? the "/gg" will happen when you return false from onCommand, so you should be returning true if you successfully handled the command. But in this case, you're not getting the broadcast message either, so that means it's probably not getting that far. paste your full plugin.yml
     
  3. Offline

    etaxi341

    Chibbey Remove the ; behind the if statement.
     
    metalhedd likes this.
  4. Offline

    metalhedd


    didn't see that! good catch
     
  5. Offline

    Chibbey

    etaxi341 so you want me to remove the ; behind the command so now command says
    if (cmd.getName().equalsIgnoreCase("gg"))

    metalhedd i posted my plugin.yml

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

    metalhedd


    Yes I was typing my post as you added that sorry. ignore me anyway, etaxi341 is correct
     
  7. Offline

    Chibbey

    metalhedd ok so i removed my ; after the command and its still happening
     
  8. Offline

    AirWick

    Add a {
     
  9. Offline

    etaxi341

    Chibbey In what game do you want to use this command? Maybe the creator of the Plugin/Game blocked all commands beside his commands while you are in a Game. And to remove the /gg message after the Message you broadcast, just return true inside of the if statement.
     
  10. Offline

    Chibbey

    etaxi341 lol its my plugin and on my server

    metalhedd its still happening sending me a white message heres the code now that i changed it

    Code:
    package me.chibbey.gg;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class GG extends JavaPlugin {
       
        public boolean onCommand(CommandSender sender, Command cmd, String[] commandLabel, String[] args) {
            if (cmd.getName().equalsIgnoreCase("gg")) {
            Bukkit.getServer().broadcastMessage(ChatColor.AQUA + sender.getName() + " says good game to everyone!");
            return false;
        }
            return false;
     
    }
    }
    
    can someone help me please

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

    boss86741

    Chibbey

    Try this:

    Code:
    package me.chibbey.gg;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class GG extends JavaPlugin {
     
        public boolean onCommand(CommandSender sender, Command cmd, String[] commandLabel, String[] args) {
            if (cmd.getName().equalsIgnoreCase("gg")) {
                Bukkit.getServer().broadcastMessage(ChatColor.AQUA + sender.getName() + " says good game to everyone!");
            return true;
            }
        return false;
        }
    }
     
  12. Offline

    Chibbey

  13. Offline

    boss86741

    Maybe try making it implement CommandExecutor and set the CommandExecutor as the main class.
     
  14. Offline

    metalhedd

    the plugin.yml must be malformed. make sure its all properly indented with tabs and not spaces.
     
  15. Chibbey
    Code:java
    1. package me.chibbey.gg;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class GG extends JavaPlugin {
    10.  
    11. public boolean onCommand(CommandSender sender, Command cmd, String[] commandLabel, String[] args) {
    12. if (cmd.getName().equalsIgnoreCase("gg")){
    13. Bukkit.getServer().broadcastMessage(ChatColor.AQUA + sender.getName() + " says good game to everyone!");
    14. }
    15. return false;
    16. }
    17. }



    Try this for the plugin.yml


    Code:
    name: GG
    version: 1.0
    main: me.chibbey.gg.GG
    description: Says good game to everyone!
    commands:
      gg:
        description: Says gg to everyone!
    
    Let me know if this works :)
     
  16. Offline

    boss86741

    He is making commands not return true though.
     
  17. Offline

    metalhedd



    read the thread, that's not the problem.
     
  18. Offline

    Chibbey

    metalhedd boss86741 Hey i remade plugin and its doing same thing heres the code:

    Code:
    package me.chibbey.goodgame;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class GoodGame extends JavaPlugin {
       
        public void onEnable() {
           
        }
       
        public void onDisable() {
           
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String[] commandLabel, String[] args) {
            if (cmd.getName().equalsIgnoreCase("gg")) {
                Bukkit.getServer().broadcastMessage(ChatColor.AQUA + sender.getName() + " says good game to everyone!");
                return true;
            }
            return true;
        }
     
    }
    and heres plugin.yml

    Code:
    name: GoodGame
    main: me.chibbey.goodgame.GoodGame
    version: 1.0
     
    commands:
            gg:
              usage: /<command>
              description: Say GoodGame to everyone!
     
  19. Offline

    metalhedd

    can you paste your complete server startup log? that way we can be sure the plugin is actually loading without any errors.
     
  20. Offline

    Chibbey

    metalhedd i know theres no errors, it says all the normal stuff then says loading GoodGame v1.0
    then says its enabled so there is no errors
     
  21. Offline

    xTrollxDudex

    Chibbey
    Remove [] from String[] commandLabel
     
  22. Offline

    Techy4198

    also I think you still need to implement CommandExecutor and register the command in onEnable
     
  23. Offline

    xTrollxDudex

    Techy4198
    onCommand is inherited from JavaPlugin, and as long as the main points to the class extending JavaPlugin you don't need to register commands.
     
  24. Offline

    Techy4198

    not what I was told before. but nevermind, since I never put commands in the main class anyway, I didn't have any experience to know better.

    (ps. go learn English, internet explorer! it doesn't like the word 'nevermind')
     
  25. Offline

    metalhedd


    You'll have to excuse me if I don't take your word for it. please paste the full log. There's nothing wrong with the code you've posted. so the problem is in something you haven't shown us yet.
     
  26. Offline

    Chibbey

    metalhedd Techy4198 xTrollxDudex Hello, ty xTrollxDudex so much, all i needed to do was remove the [] from String commandLabel, ty metalhedd for trying and taking alot of time in trying to help me out, and Techy, i didnt get a word you said :p, ty guys, your the best!
     
Thread Status:
Not open for further replies.

Share This Page