Solved Multiple Arguments not working?

Discussion in 'Spigot Plugin Help' started by TechyScientist, May 28, 2016.

  1. Hi, I fon't know if this is wrong, but my command will not do multiple arguments. Is this code right, or do I just have to use words for the other args?
    Code (Text):
    package com.techyscientist.plugin.commands;

    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;

    public class Test implements CommandExecutor {
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.DARK_RED + "Only Players can access the admin contact system!");
                return false;
            }
            if (args.length == 0) {
                sender.sendMessage(ChatColor.GREEN
                        + "Welcome to the Administration Contact System! Please choose from the following options:");
                sender.sendMessage(ChatColor.AQUA + "/1: Contact Staff Members");
                sender.sendMessage(ChatColor.BLUE + "/2: Report a Player");
                sender.sendMessage(ChatColor.LIGHT_PURPLE + "/3: Request a Player Record");
                sender.sendMessage(ChatColor.GRAY + "/4: Request a feature");
                return false;
            }
            if (args.length == 1) {
             
                if (args[0] == "1") {
                    sender.sendMessage(ChatColor.GREEN + "Choose a staff member:");
                    sender.sendMessage(ChatColor.AQUA + "1: PlayerName1");
                    sender.sendMessage(ChatColor.BLUE + "2: PlayerName2");
                    sender.sendMessage(ChatColor.LIGHT_PURPLE + "3: PlayerName3");
                    sender.sendMessage(ChatColor.GRAY + "4: PlayerName4");
                    return false;
                }
                if (args[0] == "2") {
                    sender.sendMessage(ChatColor.GREEN + "To report a player, please contact ");
                    return true;
                }
                if (args[0] == "3") {
                    sender.sendMessage(ChatColor.DARK_GREEN + "To get a copy of your player Record, please contact ");
                    return true;

                }
                if (args[0] == "4") {
                    sender.sendMessage(ChatColor.DARK_GREEN + "To request a feature, contact ");
                    return true;

                }
                if (args[0] == "5"){
                    sender.sendMessage(ChatColor.DARK_GREEN + "To request a reveiw of your player record, contact ");
                    return true;

                }
            }
            if (args.length == 2) {
                if (args[0] == "1" && args[1] == "1") {
                    sender.sendMessage(ChatColor.WHITE + "----------> PlayerName1 <----------" + System.lineSeparator() + ChatColor.GOLD + "Position on server: Headmaster" + System.lineSeparator() +ChatColor.AQUA + "You can contact PlayerName1 at" + System.lineSeparator() +ChatColor.WHITE + "-------------------------------------");
                    return true;
                }
                if (args[0] == "1" && args[1] == "2") {
                    sender.sendMessage(ChatColor.WHITE + "---------->PlayerName2 <----------" + System.lineSeparator() + ChatColor.GOLD +"Position om Server: Headmaster" + System.lineSeparator() + ChatColor.BLUE + "You can contact PlayerName2 at" + System.lineSeparator() + ChatColor.WHITE +"-----------------------------------");
                    return true;
                }
                if (args[0] == "1" && args[1] == "2") {
                    sender.sendMessage(ChatColor.WHITE + "----------> PlayerName3 <----------" + System.lineSeparator() + ChatColor.GOLD + "Position on Server: Prefect"+ System.lineSeparator() + ChatColor.LIGHT_PURPLE +  "You can contact PlayerName3 at his enjin profile at "+ System.lineSeparator() + ChatColor.WHITE + "--------------------------------");
                    return true;
                }
                if (args[0] == "1" && args[1] == "2") {
                    sender.sendMessage(ChatColor.WHITE + "----------> PlayerName4 <----------" + System.lineSeparator() + ChatColor.GOLD + "Position on Server: Prefect" + System.lineSeparator() + ChatColor.GRAY + "You can contact PlayerName4 at " + System.lineSeparator() + ChatColor.WHITE + "------------------------------------");
                    return true;
                }
            }
            return true;
        }
    }
     
    #1 TechyScientist, May 28, 2016
    Last edited: May 28, 2016
    • Winner Winner x 1
  2. EDIT: Solved the problem myself. I needed to change the =='s tp .equalsgnoreCase()'s.
     
  3. Just saying this might be the one of the best codes I've come across. Good job