Fix NullPointerExceptions

This commit is contained in:
Alejandro 2019-07-30 14:03:50 +03:00
parent a0d5e92f1a
commit 483e7cad69
3 changed files with 7 additions and 7 deletions

View File

@ -27,13 +27,11 @@ public class GamePlayer {
public synchronized void addScore(int amount) { 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().getCurrentGame() != 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; 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}); 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});
} }
} }
}
public Habbo getHabbo() { public Habbo getHabbo() {
return this.habbo; return this.habbo;

View File

@ -2136,9 +2136,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public Game getGame(Class<? extends Game> gameType) { public Game getGame(Class<? extends Game> gameType) {
if (gameType == null) return null;
synchronized (this.games) { synchronized (this.games) {
for (Game game : this.games) { for (Game game : this.games) {
if (gameType.isInstance(game)) { if (game != null && gameType.isInstance(game)) {
return game; return game;
} }
} }

View File

@ -109,7 +109,7 @@ public class Habbo implements Runnable {
public void connect() { 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()); this.habboInfo.setIpLogin(((InetSocketAddress) this.client.getChannel().remoteAddress()).getAddress().getHostAddress());
} }