Solved How to make Spaces in commands!

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

Thread Status:
Not open for further replies.
  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. Offline

    _diam

    You need to make a command argument for /help in your onCommand() method.
     
  3. Offline

    Zombie_Striker

    @Terminator_sN
    1. Create an arraylist of strings. This contains call the commands and usages.
    2. When the class is created, add all the commands to the list.
    3. When a player issues the /help command:
    4. Create an integer. This will start at 1. This represents the page.
    5. Create another int. This represents the amount of commands per page.
    6. If no args exist, do not do anything. If there is an arg, try to turn it into an integer. This will represent the page the player is trying to reach. Make sure the index is not less than 1, and make sure it is not greater than the arraylist's size / #5. This will make sure the player can't break your system.
    7. Create a for int loop. the int will be equal to #5 * (#4 - 1), and will loop up until it is equal to #5 * #4. This will return a chunk of commands in order.
    8. Get the string from the arraylist at index #6 and send the message.
    9. When you want to list the page id, display #4 for the current index, and the arrays size / #5 for the a mximum pages.
     
  4. Offline

    Horsey

    Since I recently faced the same problem, ill post some code to get ya started.
    Code:java
    1.  
    2. if (args[0].equalsIgnoreCase("list")){
    3.  
    4. try {
    5. int i = Integer.parseInt(args[1]);
    6. sender.sendMessage("§6>--------- §cNPC List§6 ---------<");
    7.  
    8. for (int o = ((i)*10)-9; o < i*10+1 ; o++){
    9. try{
    10. try{
    11. if (o <= npcs.size()){
    12. sender.sendMessage("§c"+o+".§6 "+npcs.get(o-1));
    13. }
    14. }
    15.  
    16. }catch(NullPointerException npe){
    17. }
    18. }
    19. int pages = (npcs.size() / 10 ) + (npcs.size() % 10 == 0 ? 0 : 1);
    20. sender.sendMessage("§6>------- Page §c"+i+"§6 of §c"+pages+"§6 --------<");
    21.  
    22. }catch(NumberFormatException nfe){try {
    23. sender.sendMessage("§cCouldn't resolve number §4"+args[2]);
    24. sender.sendMessage("§cThe argument contains invalid characters!");
    25. }
    26.  
    27. }
    28.  

    Just a small note: npcs is a list.
    And a tip: Don't use the section symbol for colors :/ I'm just lazy
     
Thread Status:
Not open for further replies.

Share This Page