Solved Am i blind?

Discussion in 'Plugin Development' started by MinecraftChicken, Sep 17, 2014.

Thread Status:
Not open for further replies.
  1. Hello,

    A friend of mine is trying to learn java, So i am helping her a little bit.
    But for a unkown reason it just doesnt work.

    Code:java
    1. package me.stacy.main;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9.  
    10. public class main extends JavaPlugin {
    11.  
    12. public boolean onCommand(CommandSender s, Command cmd, String Label, String[] args) {
    13. if (s instanceof Player) {
    14. Player p = (Player) s;
    15. if (cmd.getName().equalsIgnoreCase("kitty")) {
    16. p.sendMessage(ChatColor.BLUE + "jij gebruikte /kitty");
    17. }
    18. }
    19. return false;
    20. }
    21. }



    Code:
    name: main
     
    version: 1
    author: Stacy
     
    description: >
                StacyTestPlugin
    main: me.stacy.main.main
     
    commands:
      kitty:
        description: random message!

    Error message: 'Unkown Command'.
     
  2. Offline

    bennie3211

    bwfcwalshy this is the main class i think xD

    You have to extends CommandExecutor I think :)
     
  3. bennie3211 You need to implement it and also register it in onEnable.
     
  4. Since when is that?
     
  5. Offline

    JWhy

  6. JWhy It still does and you still have to register it.

    MinecraftChicken Make an onEnable and add that.
    Code:java
    1. getCommand("kitty").setExecutor(this);
     
  7. Offline

    Techy4198

    JWhy don't you still have to do something like Bukkit.getCommand("kitty").setCommandExecutor(this); ?
     
  8. Techy4198 Yes you do, but not Bukkit because it is the main class.
     
  9. Offline

    Techy4198

    bwfcwalshy Yep,
    Code:
    getCommand("commandname").setExecutor(this);
    and 'implements CommandExecutor' after 'extends JavaPlugin'. Then no other changes.
     
    bwfcwalshy likes this.
  10. bwfcwalshy i did exactly as you said but it still doesnt work:

    Code:java
    1. package me.stacy.main;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandExecutor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10.  
    11. public class main extends JavaPlugin implements CommandExecutor {
    12.  
    13. @Override
    14. public void onEnable() {
    15. getCommand("kitty").setExecutor(this);
    16. }
    17.  
    18. @Override
    19. public void onDisable() {
    20. }
    21.  
    22. public boolean onCommand(CommandSender s, Command cmd, String Label, String[] args) {
    23. if (s instanceof Player) {
    24. Player p = (Player) s;
    25. if (cmd.getName().equalsIgnoreCase("kitty")) {
    26. p.sendMessage(ChatColor.BLUE + "jij gebruikte /kitty");
    27. }
    28. }
    29. return false;
    30. }
    31. }
     
  11. I actually am blind.. i did read the console for error logs but i didnt find 1 earlier... now i start reading again and it appears the plugin.yml is wrong... Can somebody pls tel me how to do it?

    Plugin.yml:
    Code:
    name: main
     
    version: 1
    author: Stacy
     
    description: >
                StacyTestPlugin
    main: me.stacy.main.main
     
    commands:
      kitty:
        description: random message!
     
  12. Offline

    Kassestral

    This should work :), just make sure to remove the "<any words in here>" and replace it with the correct details :)
    also remove the (case sensitive) haha
    Code:
    name: <plugin name>
    version: 1
    author: Stacy
    description: <description>
    main: <path> (case sensitive)
    commands:
      kitty:
        description: <description>
        usage: /<command>
     
  13. Offline

    Kassestral

  14. thx it worked :)
     
  15. Offline

    Kassestral

    No problem :)
     
  16. Offline

    Jaaakee224

    Just gonna add this: You don't need to implement CommandExecutor since JavaPlugin is in the main class.
    Although CommandExecutor may work, just using JavaPlugin is good practice. I only use CommandExecutor when there are commands in other classes.
     
    Kassestral likes this.
  17. Offline

    ChipDev

    I have Never, ever implemented CommandExecutor and used getCommand("commandname").setExecutor(this);
     
    es359 likes this.
  18. Offline

    _Filip

    "friend" LOL
     
    shmkane likes this.
  19. Offline

    Kassestral

    Jaaakee224
    Exactly what he said :)
     
  20. Offline

    Techy4198

    ChipDev In that case you have Never, ever set up a command where the basic setup is guaranteed 100% to work in any future Bukkit version.
     
Thread Status:
Not open for further replies.

Share This Page