When 2 people or more type the same command

Discussion in 'Plugin Development' started by xXPumperNickleXx, Dec 17, 2013.

Thread Status:
Not open for further replies.
  1. Hello! Its my 3rd post in a day, and I am really sorry if I'm bugging some people, but... I was wondering, how do you tell if more than one person typed the same command? For instance:
    Dontjudgeme1243: /join_red
    neontree13: /join_blue

    So maybe when 2 people "join" it will send a message to console saying "I like pumper nickles"
     
  2. Offline

    NinjaWAffles

    You could easily do this by storing the players that execute the command in an Arraylist, and then check the length each time someone else executes the command. From there, see if the length is 2 (or whatever); and if it is, do whatever you want to.
     
  3. NinjaWAffles

    1. Umm... I'm really new... Could you give an example? I get the basics of array lists and java and stuff btw.
     
  4. Offline

    xTrollxDudex

  5. Offline

    JRL1004

    xXPumperNickleXx NinjaWAffles Also, use a HashSet since an ArrayList could end up storing the same player's name multiple times (unless you add a check)
     
  6. xTrollxDudex

    What, you think I didn't already try that?
     
  7. Offline

    NinjaWAffles

    I was assuming he'd add a check, but I didn't think of HashSet. :D
     
  8. Offline

    xTrollxDudex

  9. Offline

    The_Doctor_123

    Seriously, I need to start pushing this to people. Read the JavaDocs, they give you all the information you'd ever need, supposing you know the language. And as xTrollxDudex said, Google will find you answers on almost everything you can think of.
     
Thread Status:
Not open for further replies.

Share This Page