Solved what does this error means

Discussion in 'Plugin Development' started by abdrnasr, Apr 13, 2015.

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

    abdrnasr

    i have created a new bukkit plugin but when i try to use the code i t gives me this error
    so now how can i test my plugin

    10:28:10 [INFO] nasrgamer issued server command: /basic
     
  2. Offline

    TheEntropy

    @abdrnasr What you have supplied is not an "error." From what I understand, that message is just printed in the console for logging purposes.

    When you run '/basic' command, does it throw any errors in the form of stack-traces, or does it simply not do anything?
     
  3. Offline

    mythbusterma

  4. Offline

    abdrnasr

  5. Offline

    chingo247

    Its not an error, you forgot to register the command /basic
    This needs to be done in plugin.yml and also in your plugin main class (if you are using the command executor that is)

    Just to be sure u need to have something like this in your plugin.yml:
    Code:
    commands:
        basic:
            description: basic command
            usage: /basic
     
  6. Offline

    TheEntropy

    @abdrnasr What have you done so far? Also, like @chingo247 mentioned, did you add the command to your plugin's config.yml? One more question: Is the code handling your command in a separate class? If so, be sure to use the PluginManager to register it.
     
  7. Offline

    abdrnasr

    yea it was there but there was spacing prob but now iam facing new prob when ever i write the code it give
    the code /basic in chat
    idk why it is not able to read it
    @chingo247
    @TheEntropy
    Code:
    @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("basic")&& sender instanceof Player ) {
                Player player =(Player)sender;
                player.sendMessage("help me pls");
                player.setExp(111111.0f);
                return true;
            }
            return false; 
     
    Last edited: Apr 13, 2015
  8. Offline

    I Al Istannen

    @abdrnasr You return false every time. This shows the in the plugin.yml defined usage message.
     
  9. Offline

    TheEntropy

    @abdrnasr If I understand what you're saying correctly, you mean that is actually prints out the text "/basic" in chat. If that is the case, I believe that means your onCommand method is returning false. Is your onCommand method in the same class that you extends JavaPlugin in? If it isn't, you must set it:

    Code:
    // this code is only needed if your onCommand() method is in another class
    
    // make sure to put this inside the class that you extended JavaPlugin in
    this.getCommand("basic").setExecutor(new YourClassName());
    
    
    
     
  10. Offline

    I Al Istannen

    TheEntropy likes this.
  11. Offline

    abdrnasr

    @TheEntropy so now i replace all with the code u have put ?
     
  12. Offline

    TheEntropy

    @abdrnasr Definitely not! :p That is something you would add to your plugin's 'main' class to tell it where the onCommand() method is for a certain command. Could you post all of your code that is relevant to your problem? I'm sure we would be able to give you a much more solid answer.
     
    I Al Istannen likes this.
  13. Offline

    I Al Istannen

    @abdrnasr You set the executor like @TheEntropy showed. Do this in your Main class(like he/she said). And then either write a good Usage message or return true in your onCommand in every case.

    EDIT: TheEntropy was faster
     
  14. Offline

    TheEntropy

  15. Offline

    abdrnasr

    but when i went to the wiki they said to write it as i wrote it up in only main classes
    @TheEntropy
    @I Al Istannen
     
  16. Offline

    I Al Istannen

    @abdrnasr Lets Start at the beginning. Do you have different classes for the CommandExecutor and your Main?
     
    TheEntropy likes this.
  17. Offline

    abdrnasr

  18. Offline

    TheEntropy

    @abdrnasr That snippet from the wiki agrees with what I have said. Here is a smalls summary: If your command executor IS inside your plugins main class, you don't need to set the executor. If your command executor ISN'T inside your plugins main class, you need to set its executor. Also, IF your command is handled in a different class, that class needs to extend CommandExecutor.

    Edit: Okay, so now we know that your onEnable() method is inside your main class. Now try and debug your onCommand() method.
     
    I Al Istannen likes this.
  19. Offline

    abdrnasr

    xD I am not understanding u @TheEntropy
    iam just doing this for training
     
  20. Offline

    I Al Istannen

    Could you show your whole code?
     
  21. Offline

    travja

    @abdrnasr Basically, in your main class, if the command executor is inside of that, you don't need to use the #setExecutor method. If your command executor is in another class, you have to use #setExecutor in the onEnable.
     
    TheEntropy likes this.
  22. Offline

    TheEntropy

    @abdrnasr That's fine; I'll try and explain it differently. You can debug your onCommand() method for your '/basic' command by sending a message to the sender in every instance. Try this, for example:

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        sender.sendMessage("My onCommand method works");
    }
    
    If that prints the message, then your onCommand() method is working fine. Once you know the onCommand() method is working as it should, continue on from there.
     
  23. Offline

    abdrnasr

    now i got it @tavaja now what should i do
     
  24. Offline

    I Al Istannen

    @TheEntropy You can probably explain it better than me :) Good night ;)
     
  25. Offline

    abdrnasr

    Code:
    package me.abdrnasr.goal;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class goal extends JavaPlugin {
      
      
        public static goal plugin;
        @Override
        public void onEnable(){
            getLogger().info("plugin started");
            this.getCommand("basic").setExecutor(new goal());
        }
        @Override
        public void onDisable(){
            getLogger().info("plugin disabled");
    }
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("basic")&& sender instanceof Player ) {
                Player player =(Player)sender;
                player.sendMessage("help me pls");
                player.setExp(111111.0f);
                return true;
            }
            return false;
        }
      
          
          
          
      
    }
    @I Al Istannen
    @TheEntropy
    @travja
     
  26. Offline

    I Al Istannen

    @abdrnasr You dont need the onEnable and onDisable logger. Bukkit does that for you. @TheEntropy can you explain the rest :)
     
    TheEntropy likes this.
  27. Offline

    TheEntropy

    @abdrnasr Since your onCommand() method is in your plugin's main class, you don't need line 17. Also, I don't know what you are planning on doing with that static variable you created on line 13.

    @I Al Istannen I'm going to head out soon, as well. It's time for lunch. :eek:
     
  28. Offline

    abdrnasr

    see i got the problem after the exporting the file it shows me diffrent code
    @TheEntropy

    ayayyayayayayyayayayy i worked fine now omg
    ty all
    @TheEntropy
    @I Al Istannen
    @travja
    the problem was just the compiling it self
     
    Last edited by a moderator: Apr 13, 2015
  29. Offline

    ChipDev

    Why say ay?
    Oh! You meant to say yay!
     
  30. @abdrnasr
    Glad that your problem is solved. Please set this thread to solved by going to Thread Tools (at the top) > Edit Title > Prefix > Solved. :)
     
Thread Status:
Not open for further replies.

Share This Page