Stacker

Discussion in 'Plugin Development' started by TheDiamond06, Jun 12, 2015.

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

    TheDiamond06

    So I am making a stacker plugin that stacks players on top of players. I am trying to make it like mineplex. However I can find no way to keep setting passengers on top of the passengers already in a loop. I could keep doing getPassenger() to keep getting the passengers, but how could I put it inside of a loop.
     
  2. Offline

    LeePMC

    use numbers to count how many riders are on a player, and then make the next player ride the number of riders E.g if you have 4 people onto of each other, their would be 3 riders, 0 being the person riding on no one, 1, being the next etc all the way up to the last of 3, so what someone else wants to join, you make that rider rider player 3, which can be stored in either a hasp or array list i forget which one... just getting back into things, but here are some problems you will run into doing this, if the player with riders on them decides to ride another person, a whole new thing will have to come in play to re stack everyone without 'un riding' them if you get what i mean, not posting code ATM sorry
     
  3. Offline

    I Al Istannen

    @LeePMC @TheDiamond06 What about (code isn't syntactially correct, just to show):
    Code:
    while(entity.getPassenger() != null) {
       set entity to "entity.getPassenger"
    }
    //now we have the entity on the top as "entity.getPassenger()" was null and entity was set to the last entity.
    
    make the new player the passenger of "entity"
    
     
  4. Offline

    LeePMC

    Use a method to call to count the amount of riders a player has, when the person riding no one gets on another entity, call a method that counts how many riders the player has, and store there names (doesn't have to be UUID because this only takes half a second) in a hash map with the order they were stacked next to the name, then re stack the players adding the number of riders on the new pack to the order because there is one extra player underneath.

    The above is how you would handle when the bottom rider rides someone else, the following is how you would handle adding a rider to the pack.

    First reffer to the method that counts the amount of riders which stores the names in a hash map, then get the name of the highest rider and make the player wanting to ride, ride on top of that player

    This doesn't have to be players it can also be entities but in that case your going to want to make the entity have like a UUID to make sure the player doesn't ride eg all the pigs in a world
     
Thread Status:
Not open for further replies.

Share This Page