From 37010f7ab3b40d4825409dd2b2bfdb1d1b15c1ea Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sat, 4 May 2019 02:25:43 +0100 Subject: [PATCH] Fixed NullPointer in Rollers --- .../com/eu/habbo/habbohotel/rooms/Room.java | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index a5b9d623..9c677d16 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1617,7 +1617,14 @@ public class Room implements Comparable, ISerialize, Runnable HabboItem newRoller = null; THashSet habbosOnRoller = Room.this.getHabbosAt(roller.getX(), roller.getY()); - THashSet itemsOnRoller = new THashSet<>(getItemsAt(roller.getX(), roller.getY())); + THashSet itemsOnRoller = new THashSet<>(); + + RoomTile rollerTile = Room.this.layout.getTile(roller.getX(), roller.getY()); + + for(HabboItem item : getItemsAt(rollerTile)) + { + itemsOnRoller.add(item); + } itemsOnRoller.remove(roller); @@ -1628,7 +1635,6 @@ public class Room implements Comparable, ISerialize, Runnable } RoomTile tileInFront = Room.this.layout.getTileInFront(Room.this.layout.getTile(roller.getX(), roller.getY()), roller.getRotation()); - RoomTile rollerTile = Room.this.layout.getTile(roller.getX(), roller.getY()); if (tileInFront == null) return true; @@ -1646,7 +1652,13 @@ public class Room implements Comparable, ISerialize, Runnable if (Room.this.hasHabbosAt(tileInFront.x, tileInFront.y)) return true; - THashSet itemsNewTile = new THashSet<>(getItemsAt(tileInFront.x, tileInFront.y)); + THashSet itemsNewTile = new THashSet<>(); + + for(HabboItem item : getItemsAt(tileInFront)) + { + itemsNewTile.add(item); + } + itemsNewTile.removeAll(itemsOnRoller); List toRemove = new ArrayList<>(); for (HabboItem item : itemsOnRoller) @@ -2593,7 +2605,7 @@ public class Room implements Comparable, ISerialize, Runnable public int getUserCount() { - return this.currentHabbos.size(); + return this.currentHabbos.size(); } public ConcurrentHashMap getCurrentHabbos() @@ -3110,7 +3122,7 @@ public class Room implements Comparable, ISerialize, Runnable - return items; + return items; } @@ -3140,13 +3152,13 @@ public class Room implements Comparable, ISerialize, Runnable public void addHabbo(Habbo habbo) { - synchronized (this.roomUnitLock) - { - habbo.getRoomUnit().setId(this.unitCounter); - this.currentHabbos.put(habbo.getHabboInfo().getId(), habbo); - this.unitCounter++; - this.updateDatabaseUserCount(); - } + synchronized (this.roomUnitLock) + { + habbo.getRoomUnit().setId(this.unitCounter); + this.currentHabbos.put(habbo.getHabboInfo().getId(), habbo); + this.unitCounter++; + this.updateDatabaseUserCount(); + } } public void kickHabbo(Habbo habbo, boolean alert) @@ -3921,7 +3933,7 @@ public class Room implements Comparable, ISerialize, Runnable for(RoomTile tile : lockedTiles) { if(tile.x == item.getX() && - tile.y == item.getY()) + tile.y == item.getY()) { found = true; break; @@ -5385,12 +5397,12 @@ public class Room implements Comparable, ISerialize, Runnable return FurnitureMovementError.INVALID_MOVE; THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - for (RoomTile t : occupiedTiles) { + for (RoomTile t : occupiedTiles) { - if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; - if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; - if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; - } + if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; + if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; + if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; + } List>> tileFurniList = new ArrayList<>(); for (RoomTile t : occupiedTiles) @@ -5626,4 +5638,4 @@ public class Room implements Comparable, ISerialize, Runnable } -} +} \ No newline at end of file