Argument problems

Discussion in 'Plugin Development' started by nehuskerfan2, Jul 5, 2012.

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

    nehuskerfan2

    Pun? No.

    I was watching this tutorial and I just found out how to make commands more easier, the tutorial was on a banning plugin, but I am doing things different. Here is my code in all 3 classes.

    Supermarket.class
    Code:java
    1.  
    2. package com.nehuskerfan2.Supermarket;
    3.  
    4. import org.bukkit.plugin.PluginDescriptionFile;
    5. import org.bukkit.plugin.java.JavaPlugin;
    6.  
    7. import com.nehuskerfan2.Supermarket.commands.*;
    8.  
    9. public class Supermarket extends JavaPlugin {
    10.  
    11. protected SupermarketLogger log;
    12. private Supermarket plugin;
    13.  
    14. public void onEnable(){
    15. this.log = new SupermarketLogger(this);
    16.  
    17. this.getCommand("supermarket").setExecutor(new CommandSupermarket(this));
    18.  
    19. }
    20. public void onDisable(){
    21.  
    22. }
    23.  
    24. }
    25.  


    SupermarketLogger.class
    Code:java
    1.  
    2. package com.nehuskerfan2.Supermarket;
    3.  
    4. import java.util.logging.Logger;
    5.  
    6. import org.bukkit.plugin.PluginDescriptionFile;
    7.  
    8. public class SupermarketLogger {
    9.  
    10. private Supermarket plugin;
    11. private Logger log;
    12.  
    13. public SupermarketLogger(Supermarket plugin){
    14. this.plugin = plugin;
    15. this.log = Logger.getLogger("Minecraft");
    16. }
    17.  
    18. private String getFormattedMessage(String message){
    19.  
    20. return "[Supermarket] " + message;
    21. }
    22.  
    23. public void info(String message){
    24. this.log.info(this.getFormattedMessage(message));
    25. }
    26.  
    27. }
    28.  

    commands/CommandSupermarket.class
    Code:java
    1.  
    2. package com.nehuskerfan2.Supermarket.commands;
    3.  
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandExecutor;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.plugin.PluginDescriptionFile;
    9.  
    10. import com.nehuskerfan2.Supermarket.Supermarket;
    11.  
    12. public class CommandSupermarket implements CommandExecutor {
    13.  
    14. private Supermarket plugin;
    15.  
    16. public CommandSupermarket(Supermarket plugin) {
    17. this.plugin = plugin;
    18. }
    19.  
    20. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    21. PluginDescriptionFile pdf = plugin.getDescription();
    22. if(args.length == 0){
    23. sender.sendMessage(ChatColor.BLUE + pdf.getName() + " v" + pdf.getVersion());
    24. sender.sendMessage(ChatColor.BLUE + "Created by nehuskerfan2");
    25. sender.sendMessage("");
    26. sender.sendMessage(ChatColor.BLUE + "/supermarket help");
    27. return true;
    28. }else if (args.length == 1 && args[0] == "help"){
    29. sender.sendMessage(ChatColor.GOLD + "You may use '" + ChatColor.GREEN + "/sm" + ChatColor.GOLD + "' as a shortcut for commands.");
    30. sender.sendMessage(ChatColor.GREEN + "/sm help " + ChatColor.GOLD + "- Displays this help screen");
    31. sender.sendMessage(ChatColor.GREEN + "/sm help salesman" + ChatColor.GOLD + " - Displays salesman help(needs " + ChatColor.RED + "supermarket.salesman" + ChatColor.GREEN + "!)");
    32. return true;
    33. }
    34. return true;
    35. }
    36.  
    37. }
    38.  
    (note I'll make a site sometime I wasn't willing to start over and change com. to me.)

    I tabbed the spaces so its going to be in a line when this post is up.
    Anyway, my problem is that when I do /supermarket help it appears the same as /supermarket.
     
  2. Offline

    CorrieKay

    what do you mean "appears the same as" ?
     
  3. Offline

    nehuskerfan2

    Like when I do /supermarket it shows

    Code:
    Supermarket v0.1
    Created by nehuskerfan2
     
    /supermarket help
    Same thing shows when I apply help as args[0]
     
  4. args[0] == "help"
    The above stament is always returning false, this may by an bug, try using args[0].equals("help")
     
Thread Status:
Not open for further replies.

Share This Page