From 5ac83b689822f745500c4ff7b5e68a67d3096d00 Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Fri, 4 May 2018 20:54:12 +0200 Subject: [PATCH] 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. --- .../java/com/garbagemule/MobArena/ArenaImpl.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java index 39771da..a1cd10b 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java @@ -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; }