[Solved] Everytime I Type My Custom Command it appears on the chat and nothing happenes

Discussion in 'Spigot Plugin Development' started by DimoKouli, May 17, 2015.

  1. So, everytime i try to run my command i just get it back in the chat with white letters like this /tt
    public boolean OnCommand(CommandSender sender, Command cmd, String label, String[] args){

    if(cmd.getName().equalsIgnoreCase("tt")){
    if(args.length == 1){
    if(args[0].equalsIgnoreCase("enable")){
    usePlayerListener = true;
    sender.sendMessage(ChatColor.GREEN + "Bot Attack Preventer Has Been Enabled!");

    }
    else if(args[0].equalsIgnoreCase("disable")){
    usePlayerListener = false;
    sender.sendMessage(ChatColor.GREEN + "Bot Attack Preventer Has Been Disabled!");
    }

    else if(args.length == 0){
    sender.sendMessage(ChatColor.RED + "Enter A Valid Number Of Arguements!");
    }
    }

    }


    return false;
    }
     
  2. Do [ CODE ] [/CODE ] without the spaces and in between paste your code.

    Edit:
    Code (Text):

    public boolean OnCommand(CommandSender sender, Command cmd, String label, String[] args){
             
         if(cmd.getName().equalsIgnoreCase("tt")){
             if(args.length == 1){
                 if(args[0].equalsIgnoreCase("enable")){
                     usePlayerListener = true;
                    sender.sendMessage(ChatColor.GREEN + "Bot Attack Preventer Has Been Enabled!");
                           
                 }
                 else if(args[0].equalsIgnoreCase("disable")){
                     usePlayerListener = false;
                     sender.sendMessage(ChatColor.GREEN + "Bot Attack Preventer Has Been Disabled!");
                 }

                 else if(args.length == 0){
                     sender.sendMessage(ChatColor.RED + "Enter A Valid Number Of Arguements!");
                 }
                 }
           
         }
           
       
        return true;
      }
    That's his code
     
  3. Code (Text):

    public boolean OnCommand(CommandSender sender, Command cmd, String label, String[] args){
             
         if(cmd.getName().equalsIgnoreCase("tt")){
             if(args.length == 1){
                 if(args[0].equalsIgnoreCase("enable")){
                     usePlayerListener = true;
                    sender.sendMessage(ChatColor.GREEN + "Bot Attack Preventer Has Been Enabled!");
                           
                 }
                 else if(args[0].equalsIgnoreCase("disable")){
                     usePlayerListener = false;
                     sender.sendMessage(ChatColor.GREEN + "Bot Attack Preventer Has Been Disabled!");
                 }
     
                 else if(args.length == 0){
                     sender.sendMessage(ChatColor.RED + "Enter A Valid Number Of Arguements!");
                 }
                 }
           
         }
           
       
        return false;
      }
     
     
  4. Thanks man i thought its like html :)
     
    • Funny Funny x 1
  5. I don't understand, what is
    Code (Text):
    usePlayerListener = true
    .. What is the string behind it?
    Edit: The code you have shown us obviously only seems to want to send a player message :/
     
  6. tho what can i do with the problem :D ?
     
  7. Actually, copy and paste all the code into a [code ] [/code ] insert and I'll see what I can help you with
     
  8. @Exus-Kun Its a boolean that if it is true it allows the events in playerlistener class to take place if its not PlayerListener stops working so its enable disable commands..
     
  9. Ah, could you paste the PlayerListener class in for us then? That'd be lovely.
     
  10. And this isnt the problem,, i am sure i tried it without it.. i have a doubt about this line
    Code (Text):
    public class Main extends JavaPlugin
    maybe should i make more implemets or something /.? command excecutor?
     
  11. thats basicly the idea

    Code (Text):

    public void onQuit(PlayerQuitEvent event)
      {
         if(Main.usePlayerListener == true){
     
     
  12. OH, I SEE -- I READ IT WRONG.
    I make this mistake all the time; nothing to do with your code.
    In your plugin YML, get rid of all usage: things in your commands (they are unneeded) and will fix the problem.
    Make sure to edit the title of solved with [Solved] and report the thread or post with the reason "Solved" to have it locked.
     
  13. @Exus-Kun man thanks a lot i am trying 2 days to fix this fuck thing :)
     
    • Like Like x 1
  14. Haha no problem, Start a conversation with me if you need any more help later on as Im happy to do so, or even just send me a message and ask for my SKYPE (I don't usually give it out haha)
     
    • Like Like x 1
  15. @Exus-Kun wow feeling extra lucky :D and respect of couse ty for ur offer i will try to complete this plugin myself if i dont make it i will surely send u a message:)
     
  16. @Exus-Kun Happy to disturb u faster than what i expected :D I fixed the problems with the command showing in chat but it doesnt seem to work....