Solved How to make Spaces in commands!

Discussion in 'Spigot Plugin Development' started by Terminator_sN, Apr 25, 2017.

  1. So i wanted to make a plugin with /help 1/2/3/4/5 For my network and I find all the ones I have seen has only been in 1 Main class and i tried some different things from them non of them worked so i decided to come here and put a thread about it so my main class looks like this please not to forget about the Plugin Hider bit.

    and i want to add more commands with /Help 2 but i have tryed so many things like add _ for the space what did not work so please help
     
  2. The spaces you mean are args?!
     
    • Funny Funny x 2
  3. Hi, there is something called args! Please learn java before you make plugins
     
    • Agree Agree x 2
    • Optimistic Optimistic x 1
  4. Yeah i do mean that
    but all the stuff i do i cant get them to work
     
  5. Private message me I can help you :)
     
  6. lol a quick Google search brought me to this: https://bukkit.org/threads/tutorial-command-arguments.186497/
    Please learn the basics before you start developing a plugin... and based on this, I assume you also don't know basic Java, so please read up on that as well. You can't just into development before you know the basics man.
     
  7. btw i Just found out like 1/2 hours ago and btw Not knowing that does not mean i am bad at Java
     
  8. Actually, it does. You clearly didn't read anything before you started coding your plugin, so it's safe to assume you didn't read anything before starting Java either.
     
  9. Ehhh. That's kind of a basic aspect of Java.
     
    • Agree Agree x 1
  10. That is why i have like 3 books of Java sitting right next to me and i use to code Java around 4/5 years ago because i use to make guis and shit but past that time i have forgotten and in that time i started to code Websites and do a lot of Youtube but i just started to get back in Java
     
    • Funny Funny x 1
  11. If you can't remember args, then I recommend picking one of those books up and start reading as you have lost almost all knowledge of Java. I am currently in the early learning stages as well, but you should know how to use args in a command or at least use google before coding a plugin. I'm saying this so you can learn and not just have us tell you everything and feed you code when you could learn how these actually work by reading.
     
    • Agree Agree x 1
  12. I am learning again that is the problem i have just got to the args page before i posted this and tbh now i feel stupid of this post.
     
  13. All good as long as you're learning :)
     
  14. Waldxn As u are here might as well ask I have got /help and /help 2 but i have tried like 4 types of codes what i found it and non of them work when i do /help 3 idk why idk if it is how i layed it out or something because i uses Else if and if
     
  15. Code please? You need to check how many arguments there are, and then check for a specific argument (in your case, args[0] should be "3").
     
  16. package mc.SlimieSlime.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 Help implements CommandExecutor {

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

    if (!(sender instanceof Player)) {
    sender.sendMessage("You must be a player to use this command!");
    return false;
    }

    Player player = (Player) sender;
    if (args.length == 0) {
    player.sendMessage(ChatColor.AQUA + "Help(1/5)");
    player.sendMessage(ChatColor.AQUA + "/Developer to show the Developers");
    player.sendMessage(ChatColor.AQUA + "/Ah For auction house");
    player.sendMessage(ChatColor.AQUA + "/Shop for the shop");
    player.sendMessage(ChatColor.AQUA + "/Plot auto for a plot");
    player.sendMessage(ChatColor.AQUA + "/Ranks for the ranks");
    } else if (args.length == 1) {
    player.sendMessage(ChatColor.AQUA + "Help(1/5)");
    player.sendMessage(ChatColor.AQUA + "/Developer to show the Developers");
    player.sendMessage(ChatColor.AQUA + "/Ah For auction house");
    player.sendMessage(ChatColor.AQUA + "/Shop for the shop");
    player.sendMessage(ChatColor.AQUA + "/Plot auto for a plot");
    player.sendMessage(ChatColor.AQUA + "/Ranks for the ranks");
    if (args[0].equalsIgnoreCase("2")) {
    player.sendMessage(ChatColor.AQUA + "Help(2/5)");
    player.sendMessage(ChatColor.AQUA + "/Plot Trust to trust players");
    player.sendMessage(ChatColor.AQUA + "/Plot add to add players");
    }
    }

    return true;
    }
    }
     
  17. Code (Text):
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
           
            if (cmd.getName().equalsIgnoreCase("help")) {
                if (args.length == 0) {
                    sender.sendMessage(ChatColor.GREEN + "/help <page>");
                   
                } else {
                   
                    if (plugin.getConfig().getString("Help" + "." + args[0]) != null) {
                        List<String> helppage = plugin.getConfig().getStringList("Help" + "." + args[0]);
                        for (String hp: helppage) {
                            sender.sendMessage(hp.replace("&", "§"));
                        }
                       
                    } else {
                       
                        sender.sendMessage(ChatColor.RED + "This help page could not be found.");
                    }
                }
            }
            return true;
        }
    Here is how I make a configurable help plugin with unlimited pages.
    #Spoonfeed
     
    • Optimistic Optimistic x 3
    • Friendly Friendly x 1
  18. Why would you just spoon-feed code? That accomplishes nothing at all. :/
     
    • Agree Agree x 1
    • Informative Informative x 1
  19. Fastest way and also best way performance whise