From 483e7cad69bcf919c210ef42b67db58308639644 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 30 Jul 2019 14:03:50 +0300 Subject: [PATCH] Fix NullPointerExceptions --- .../java/com/eu/habbo/habbohotel/games/GamePlayer.java | 8 +++----- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 4 +++- src/main/java/com/eu/habbo/habbohotel/users/Habbo.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java index 8aabcf90..edc62fb4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java @@ -27,11 +27,9 @@ public class GamePlayer { public synchronized void addScore(int amount) { - if (habbo.getHabboInfo().getGamePlayer() != null || this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { - if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { - this.score += amount; - WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount}); - } + if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { + this.score += amount; + WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount}); } } 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 1dd10859..61c409df 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2136,9 +2136,11 @@ public class Room implements Comparable, ISerialize, Runnable { } public Game getGame(Class gameType) { + if (gameType == null) return null; + synchronized (this.games) { for (Game game : this.games) { - if (gameType.isInstance(game)) { + if (game != null && gameType.isInstance(game)) { return game; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index 84396d67..0876aec3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -109,7 +109,7 @@ public class Habbo implements Runnable { public void connect() { - if (!Emulator.getConfig().getBoolean("networking.tcp.proxy")) { + if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) { this.habboInfo.setIpLogin(((InetSocketAddress) this.client.getChannel().remoteAddress()).getAddress().getHostAddress()); }