From 23ae60119b08de083be14033ec6d4da1764e0ef9 Mon Sep 17 00:00:00 2001 From: Beny Date: Tue, 14 May 2019 18:47:57 +0100 Subject: [PATCH] Potential issue in RoomTile removeUnit fixed. --- .../eu/habbo/habbohotel/rooms/RoomTile.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java index 6b0f4918..c284d37a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -2,7 +2,6 @@ package com.eu.habbo.habbohotel.rooms; import gnu.trove.set.hash.THashSet; -import java.lang.reflect.Array; import java.util.ArrayList; import java.util.List; @@ -21,7 +20,7 @@ public class RoomTile private short gCosts; private short hCosts; - private THashSet units; + private final THashSet units; public RoomTile(short x, short y, short z, RoomTileState state, boolean allowStack) @@ -210,20 +209,28 @@ public class RoomTile } public List getUnits() { - return new ArrayList(this.units); + synchronized (this.units) { + return new ArrayList(this.units); + } } public void addUnit(RoomUnit unit) { - if(!this.units.contains(unit)) { - this.units.add(unit); + synchronized (this.units) { + if (!this.units.contains(unit)) { + this.units.add(unit); + } } } public void removeUnit(RoomUnit unit) { - this.units.remove(unit); + synchronized (this.units) { + this.units.remove(unit); + } } public boolean hasUnits() { - return this.units.size() > 0; + synchronized (this.units) { + return this.units.size() > 0; + } } } \ No newline at end of file