Plugin issues...

Discussion in 'Plugin Development' started by Rmarmorstein, Feb 4, 2013.

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

    Rmarmorstein

    Hi Everyone,

    I am having some issues, with a simple plugin of mine. What i am expecting to happen is that when someone does the commands, they will get a message explaining some commands, and chat channels.

    I think it has something to do with my plugin.yml, i have run it through the YML parser, and it looked like it would for any normal YML file.

    Here is the plugin.yml: http://pastebin.com/s3mgNKWW

    And my Code:

    Code:java
    1.  
    2. package us.craftville.chat;
    3.  
    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 final class Chat extends JavaPlugin {
    10. @Override
    11. public void onDisable(){
    12.  
    13. }
    14.  
    15. @Override
    16. public void onEnable() {
    17.  
    18. }
    19.  
    20. public boolean onCommand(CommandSender cdsend, Command cmd, String label, String[] args){
    21. if(cmd.getName().equalsIgnoreCase("Chat")){
    22. if(args[0] == "channels"){
    23. cdsend.sendMessage(ChatColor.AQUA + "~~CraftVille Chat Channels: ~~");
    24. cdsend.sendMessage(ChatColor.WHITE + "G: Global chat (General Chat) - /g");
    25. cdsend.sendMessage(ChatColor.YELLOW + "H: Help Chat (Server Questions) - /h");
    26. cdsend.sendMessage(ChatColor.DARK_AQUA + "TC: Town Chat (Chat to town) - /tc");
    27. cdsend.sendMessage(ChatColor.AQUA +"~~~ END ~~~");
    28. }
    29. else if(args[0] == "commands" ){
    30. cdsend.sendMessage(ChatColor.AQUA + "~~ CraftVille Chat Commands ~~");
    31. cdsend.sendMessage(ChatColor.WHITE + "/ignore - Ignore a player");
    32. cdsend.sendMessage(ChatColor.WHITE + "/<channel> - Focus on <channel> Chat Channel");
    33. }
    34. else if(args.length == 0){
    35. cdsend.sendMessage(ChatColor.RED + "~~ CraftVille Chat ~~");
    36. cdsend.sendMessage(ChatColor.WHITE + "Please use one of the following Commands:");
    37. cdsend.sendMessage(ChatColor.AQUA + "/chat Channels - For a list of channels");
    38. cdsend.sendMessage(ChatColor.AQUA + "/chat commands - For a list of commands");
    39. }
    40.  
    41. }
    42.  
    43. return true;
    44. }
    45. }
    46.  


    I appreciate the help, sorry if it is something really silly, i have worked on this for hours though.
     
  2. Offline

    teunie75

    I think the usage in the plugin.yml is wrong.
     
  3. Offline

    ZeusAllMighty11 Retired Staff

    You need to check args.length ...

    teunie75 that means nothing.
     
  4. Offline

    Rmarmorstein

    I just updated it, is this what it should have been?

    Code:java
    1.  
    2. package us.craftville.chat;
    3.  
    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 final class Chat extends JavaPlugin {
    10. @Override
    11. public void onDisable(){
    12.  
    13. }
    14.  
    15. @Override
    16. public void onEnable() {
    17.  
    18. }
    19.  
    20. public boolean onCommand(CommandSender cdsend, Command cmd, String label, String[] args){
    21. if(cmd.getName().equalsIgnoreCase("Chat")){
    22. if (args.length == 1) {
    23. if(args[0] == "channels"){
    24. cdsend.sendMessage(ChatColor.AQUA + "~~CraftVille Chat Channels: ~~");
    25. cdsend.sendMessage(ChatColor.WHITE + "G: Global chat (General Chat) - /g");
    26. cdsend.sendMessage(ChatColor.YELLOW + "H: Help Chat (Server Questions) - /h");
    27. cdsend.sendMessage(ChatColor.DARK_AQUA + "TC: Town Chat (Chat to town) - /tc");
    28. cdsend.sendMessage(ChatColor.AQUA +"~~~ END ~~~");
    29. }
    30. else if(args[0] == "commands" ){
    31. cdsend.sendMessage(ChatColor.AQUA + "~~ CraftVille Chat Commands ~~");
    32. cdsend.sendMessage(ChatColor.WHITE + "/ignore - Ignore a player");
    33. cdsend.sendMessage(ChatColor.WHITE + "/<channel> - Focus on <channel> Chat Channel");
    34. }
    35.  
    36. }
    37. else{
    38. cdsend.sendMessage(ChatColor.RED + "~~ CraftVille Chat ~~");
    39. cdsend.sendMessage(ChatColor.WHITE + "Please use one of the following Commands:");
    40. cdsend.sendMessage(ChatColor.AQUA + "/chat Channels - For a list of channels");
    41. cdsend.sendMessage(ChatColor.AQUA + "/chat commands - For a list of commands");
    42. }
    43.  


    What is wrong though, This does not help me get anywhere?
     
  5. Offline

    ZeusAllMighty11 Retired Staff

    Looks good to me.

    Edit: You are missing brackets { } and booleans need to return a, well, boolean.

    Add 'return false; ' before the last bracket
     
Thread Status:
Not open for further replies.

Share This Page