From 191ef7afad79f6d1f218cfca3dc5a6e7eedfa3b8 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 20:22:52 +0200 Subject: [PATCH] Make game gates unwalkable during a game (fixes #312) --- .../gates/InteractionBattleBanzaiGate.java | 15 ++++++++------ .../freeze/gates/InteractionFreezeGate.java | 20 ++++++++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java index 5948ec9e..04def885 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameState; import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeamColors; @@ -28,17 +29,19 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate { } @Override - public boolean isWalkable() { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if (room == null) - return false; + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - return (this.getExtradata() == null || this.getExtradata().isEmpty() || Integer.valueOf(this.getExtradata()) < 5) && ((room.getGame(BattleBanzaiGame.class))) == null || ((BattleBanzaiGame) (room.getGame(BattleBanzaiGame.class))).state.equals(GameState.IDLE); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + public boolean isWalkable() { + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + if (room == null) return false; + + Game game = room.getGame(BattleBanzaiGame.class); + + return game == null || game.getState() == GameState.IDLE; } //TODO: Move to upper class diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java index 96daf1d2..ec583fde 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java @@ -1,5 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameState; import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeamColors; @@ -27,18 +29,18 @@ public class InteractionFreezeGate extends InteractionGameGate { } @Override - public boolean isWalkable() { - if (this.getRoomId() == 0) - return false; - - return (this.getExtradata().isEmpty() || - Integer.valueOf(this.getExtradata()) < 5); - //((Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))) == null || - //!((FreezeGame)(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))).isRunning; + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + public boolean isWalkable() { + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + + if (room == null) return false; + + Game game = room.getGame(FreezeGame.class); + + return game == null || game.getState() == GameState.IDLE; } @Override