How to get players from an array list?

Discussion in 'Spigot Plugin Development' started by ZevoGaems, May 16, 2017.

  1. I need to title all of the players that are in a certain array list. How would I do this where it gets the array list and then get their name and use that and use my title api to send them a title. Please help, thank you!
     
  2. Show what you've attempted first.
     
  3. Do you wanna broadcast the title to everyone from an arraylist? Then use something similar to this:

    Code (Text):

    for(Player player : yourArrayList){
    //TitleAPI.send(player);
    }
     
     
  4. Can someone please explain to me why this part is showing errors????
    Code (Text):
        public void displayCount(){
            for(String queuedplayer : queue) {
                if(cd >0 && cd < 11) {
                    int count = cd.intValue();
                    Titles.sendFullTitle(queuedplayer, 5, 10, 5, ChatColor.RED + "" + ChatColor.BOLD + "Starting Soon...", ChatColor.DARK_RED + count);  
                    }
                }
               }
     
  5. If you're asking for help with an error it would help if you shared the error with us. (also we have no clue of what Titles#sendFullTitle does)
     
  6. You could learn java and learn how to read errors.. Or even show us the error, that would help.
     
  7. The errors I am getting at the part where it says chatcolor.red + count I get the error The operator + is undefined for the argument type(s) ChatColor, int

    Thats the only error. The way it works is it sends a full title so it goes
    Titles.sendFullTitle(player, fadein, stay, fadeout, mainmessage, submessage);
     
  8. Oh yeah. You're adding a chat color and an int, which is just not possible. You have to add it to a string. In other words, either make count a string or set the color up elsewhere in the code. Specifically the problem is with "ChatColor.DARK_RED + count" (removing chat color would probably make it work)
     
  9. Well is there a way I can get it as a string so I can have the chat color?
     
  10. It would require changing the Titles class and the sendFullTitle method so they can accept a string instead of an integer in the constructor.
     
    • Funny Funny x 1
  11. Is there a way I can convert the integer into a string?
     
  12. I'm going to assume that the thing you posted allows both strings an integers equally.

    String.valueOf(count)
     
  13. Basically, the problem here is you need to learn beginner java to stop wasting your/our time.
    Integer.toString(int);
     
    • Agree Agree x 1
  14. How many times did I tell you to learn Java? You don't even try or think before asking a question. I like to try and test for about an hour before I even think about asking a question.
     
    • Agree Agree x 1
    • Winner Winner x 1
  15. One does simply not learn to make plugins, if you have no clue what you are doing.

    You're basically writing a code from the API that was made from Java. If you want to learn to make plugins, learn to understand the concept of Java. Everything from the api that you are using, inherits from Java. Think or try to learn how to use Google search. Did you attempt to find another way? Why do you ignore our advice? Could you explain why you will not learn Java?
     
  16. Use String.valueOf(int);
    That would convert the type of int to string.
     
  17. Just to mention

    Code (Text):

    Integer.toString(yourInt);
     
    is basically a better idea like @FlyingLlama already mentioned, otherwise you still need to cast your int as a String because an Integer is still not a String.
     
  18. You're right.
     
  19. Code (Text):
    ChatColor.RED + "" + 42
     
  20. Just split the the two with some quotations like -> 'ChatColor.RED + "" + count'