Queue System.

Discussion in 'Plugin Development' started by WolfMage1, Dec 16, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    WolfMage1

    Currently the only idea I have of creating a queue system is by using java's Queue (java.util.Queue) and creating a runnable that goes every second and checks if the size is >= to 2 and then pairing the first 2 players together that way. Just curious if anyone has any better ideas of how to do this. (also there's 3 separate queues, 1v1, 3v3 and 6v6)
     
  2. Offline

    timtower Administrator Administrator Moderator

    @WolfMage1 You can keep lists, when somebody joins one check the size of it
     
  3. Offline

    WolfMage1

    A follow up to that, with 3v3 and 6v6 queues, before a player gets added to a queue, they get a prompt to select ? players to join them in the fight and I want to send a request to a player saying "BlahBlah123 has invited you to join them in battle" "[Accept] [Decline]" I already know how to do the requests bit as I've done requests before, but how would I stop players from being added to the queue until all requests have been accepted
     
  4. Offline

    timtower Administrator Administrator Moderator

    @WolfMage1 Make a new list for those.
    Or use a hashmap<uuid, boolean>, uuid is player, boolean is accepted
     
  5. Offline

    WolfMage1

    I dont understand....
     
  6. Offline

    WolfMage1

  7. Offline

    Zombie_Striker

    @WolfMage1
    For the request issue, I would recommend doing the following:
    1. Create a new class called "PlayerRequest". This will store who sent the request, who the request is for, and an int which represents what should happen (waiting, accepted, declined). Automatically, set this int to 0.
    2. In the main class (or wherever you handle the requests), create a hashmap. The keys will be UUIDs, the values will be the PlayerRequests.
    3. When a request is sent, create a new entry in the Hashmap with all the data you need.
    4. When a player needs to accept/decline, check if the player is in the map. If they are, get the playerrequest and set the int equal to a value (1 being accepted, 2 being declined)
    5. Then, in your runnable, loop through all the entries in the map. If an entries int is equal to 0, continue. If it is 1 or 2, either accept or decline the request (send the message and do what you need) and then remove the value.
     
    WolfMage1 likes this.
  8. Offline

    WolfMage1

    What about for 3v3 and 6v6, where I need to send the request to 3 or 6 people.
    And you said the key will be UUID's, but who's uuid will it be, sender of the request I'm guessing?

    EDIT: nevermind, I'm just being a dumbass, instead of storing individual requests I just store a list and iterate over it.
     
    Last edited: Dec 18, 2016
Thread Status:
Not open for further replies.

Share This Page