Move entry fee refund to after join/leave rollback.

This moves the refunding of the entry fee to after the join/leave process for the player has been rolled back, i.e. after the inventory is restored. Before this change, the refund would happen before restoring the player's inventory, which resulted in the refund getting overwritten.
This commit is contained in:
Andreas Troelsen 2018-05-04 20:54:12 +02:00
parent 7aad81e33f
commit 5ac83b6898

View File

@ -774,9 +774,7 @@ public class ArenaImpl implements Arena
removeClassPermissions(p);
removePotionEffects(p);
if (inLobby(p) || inArena(p)) {
refund(p);
}
boolean refund = inLobby(p) || inArena(p);
if (inLobby(p)) {
ArenaPlayer ap = arenaPlayerMap.get(p);
@ -791,6 +789,10 @@ public class ArenaImpl implements Arena
}
discardPlayer(p);
if (refund) {
refund(p);
}
endArena();
@ -1522,12 +1524,7 @@ public class ArenaImpl implements Arena
@Override
public boolean refund(Player p) {
if (entryFee.isEmpty()) return true;
if (!inLobby(p)) return false;
for (Thing fee : entryFee) {
fee.giveTo(p);
}
entryFee.forEach(fee -> fee.giveTo(p));
return true;
}