From 6713eb1e779d809c3bbdf77e60003ca7f95a28da Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Sat, 30 Apr 2022 22:35:42 -0300 Subject: [PATCH] Fixes --- .../habbo/habbohotel/catalog/ClubOffer.java | 4 +-- .../habbohotel/guides/GuardianTicket.java | 4 +-- .../habbo/habbohotel/guides/GuardianVote.java | 5 ++++ .../habbo/habbohotel/guilds/GuildMember.java | 4 +++ .../interactions/pets/InteractionPetToy.java | 2 +- .../wired/effects/WiredEffectBotTeleport.java | 6 ++-- .../wired/effects/WiredEffectTeleport.java | 13 ++++---- .../eu/habbo/habbohotel/pets/PetManager.java | 30 +++++++++---------- .../habbo/habbohotel/rooms/RoomManager.java | 4 +-- .../eu/habbo/habbohotel/rooms/RoomTile.java | 6 ++-- .../habbo/habbohotel/wired/WiredHandler.java | 22 +++++++------- .../incoming/modtool/ModAlertEvent.java | 6 +--- .../incoming/modtool/ModBanEvent.java | 6 +--- .../incoming/modtool/ModTradingLockEvent.java | 6 +--- .../items/SetCustomStackingHeightEvent.java | 2 +- .../java/com/eu/habbo/networking/Server.java | 1 + .../habbo/networking/camera/CameraClient.java | 9 ++---- .../runnables/AchievementUpdater.java | 4 +-- .../RoomUnitTeleportWalkToAction.java | 2 +- .../RoomUnitVendingMachineAction.java | 2 +- .../threading/runnables/YouAreAPirate.java | 4 +-- .../runnables/YoutubeAdvanceVideo.java | 2 +- .../runnables/teleport/TeleportActionTwo.java | 2 +- 23 files changed, 68 insertions(+), 78 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java b/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java index 3be967be..b7654416 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java @@ -92,7 +92,7 @@ public class ClubOffer implements ISerialize { message.appendInt(this.pointsType); message.appendBoolean(this.vip); - long seconds = this.days * 86400; + long seconds = this.days * 86400L; long secondsTotal = seconds; @@ -103,7 +103,7 @@ public class ClubOffer implements ISerialize { seconds -= totalMonths * (86400 * 31); int totalDays = (int) Math.floor((int) seconds / 86400.0); - seconds -= totalDays * 86400; + seconds -= totalDays * 86400L; message.appendInt((int) secondsTotal / 86400 / 31); message.appendInt((int) seconds); diff --git a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java index a0cbd115..4e2caa19 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianTicket.java @@ -22,7 +22,7 @@ public class GuardianTicket { private final Habbo reporter; private final Habbo reported; private final Date date; - private ArrayList chatLogs; + private final ArrayList chatLogs; private GuardianVoteType verdict; private int timeLeft = 120; private int resendCount = 0; @@ -45,7 +45,7 @@ public class GuardianTicket { this.votes.put(guardian, new GuardianVote(this.guardianCount, guardian)); - Emulator.getThreading().run(new GuardianNotAccepted(this, guardian), Emulator.getConfig().getInt("guardians.accept.timer") * 1000); + Emulator.getThreading().run(new GuardianNotAccepted(this, guardian), Emulator.getConfig().getInt("guardians.accept.timer") * 1000L); } diff --git a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVote.java b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVote.java index 0066bc33..6c7dc673 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVote.java +++ b/src/main/java/com/eu/habbo/habbohotel/guides/GuardianVote.java @@ -29,6 +29,11 @@ public class GuardianVote implements Comparable { return false; } + @Override + public int hashCode() { + return this.id; + } + public void ignore() { this.ignore = true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java index 95e0ea80..5b0d9ee3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java @@ -72,6 +72,10 @@ public class GuildMember implements Comparable { return false; } + @Override + public int hashCode() { + return this.userId; + } public GuildMembershipStatus getMembershipStatus() { if (this.rank == GuildRank.DELETED) return GuildMembershipStatus.NOT_MEMBER; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java index 4925e4fe..9cb0c9c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java @@ -71,7 +71,7 @@ public class InteractionPetToy extends InteractionDefault { pet.getRoomUnit().clearStatus(); new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run(); pet.packetUpdate = true; - }, 2500 + (Emulator.getRandom().nextInt(20) * 500)); + }, ((long)(Emulator.getRandom().nextInt(20) * 500) + 2500)); this.setExtradata("1"); room.updateItemState(this); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java index 8087d3b3..3374dc57 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java @@ -56,7 +56,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit)); room.sendComposer(new AvatarEffectMessageComposer(roomUnit, 4).compose()); - Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000); + Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), (long) WiredHandler.TELEPORT_DELAY + 1000); if (tile == roomUnit.getCurrentLocation()) { return; @@ -218,14 +218,14 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { String[] wiredDataSplit = set.getString("wired_data").split("\t"); if (wiredDataSplit.length >= 2) { - this.setDelay(Integer.valueOf(wiredDataSplit[0])); + this.setDelay(Integer.parseInt(wiredDataSplit[0])); String[] data = wiredDataSplit[1].split(";"); if (data.length > 1) { this.botName = data[0]; for (int i = 1; i < data.length; i++) { - HabboItem item = room.getHabboItem(Integer.valueOf(data[i])); + HabboItem item = room.getHabboItem(Integer.parseInt(data[i])); if (item != null) this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java index f794e674..5fa59787 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java @@ -57,7 +57,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit)); room.sendComposer(new AvatarEffectMessageComposer(roomUnit, 4).compose()); - Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000); + Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), (long) WiredHandler.TELEPORT_DELAY + 1000); if (tile == roomUnit.getCurrentLocation()) { return; @@ -111,14 +111,11 @@ public class WiredEffectTeleport extends InteractionWiredEffect { message.appendInt(this.getDelay()); if (this.requiresTriggeringUser()) { List invalidTriggers = new ArrayList<>(); - room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() { - @Override - public boolean execute(InteractionWiredTrigger object) { - if (!object.isTriggeredByRoomUnit()) { - invalidTriggers.add(object.getId()); - } - return true; + room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> { + if (!object.isTriggeredByRoomUnit()) { + invalidTriggers.add(object.getId()); } + return true; }); message.appendInt(invalidTriggers.size()); for (Integer i : invalidTriggers) { diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index f1da909d..592027bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -15,6 +15,7 @@ import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TIntObjectProcedure; import gnu.trove.set.hash.THashSet; +import org.apache.commons.lang3.EnumUtils; import org.apache.commons.math3.distribution.NormalDistribution; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -142,7 +143,7 @@ public class PetManager { } public static NormalDistribution getNormalDistributionForBreeding(int levelOne, int levelTwo) { - return getNormalDistributionForBreeding((levelOne + levelTwo) / 2); + return getNormalDistributionForBreeding( (levelOne + levelTwo) / 2.0); } public static NormalDistribution getNormalDistributionForBreeding(double avgLevel) { @@ -236,7 +237,7 @@ public class PetManager { while (set.next()) { if (set.getInt("pet_id") >= 0) { if (this.petData.containsKey(set.getInt("pet_id"))) { - PetVocalsType petVocalsType = PetVocalsType.valueOf(set.getString("type").toUpperCase()); + PetVocalsType petVocalsType = EnumUtils.getEnum(PetVocalsType.class, set.getString("type").toUpperCase());; if (petVocalsType != null) { this.petData.get(set.getInt("pet_id")).petVocals.get(petVocalsType).add(new PetVocal(set.getString("message"))); @@ -315,7 +316,7 @@ public class PetManager { } try { - int petId = Integer.valueOf(petName.split("t")[1]); + int petId = Integer.parseInt(petName.split("t")[1]); return this.petRaces.get(petId); } catch (Exception e) { LOGGER.error("Caught exception", e); @@ -333,18 +334,15 @@ public class PetManager { TIntObjectHashMap> offspringList = this.breedingReward.get(pet.getPetData().getType()); - offspringList.forEachEntry(new TIntObjectProcedure>() { - @Override - public boolean execute(int i, ArrayList petBreedingRewards) { - for (PetBreedingReward reward : petBreedingRewards) { - if (reward.breed == pet.getRace()) { - rarityLevel[0] = i; - return false; - } + offspringList.forEachEntry((i, petBreedingRewards) -> { + for (PetBreedingReward reward : petBreedingRewards) { + if (reward.breed == pet.getRace()) { + rarityLevel[0] = i; + return false; } - - return true; } + + return true; }); return 4 - rarityLevel[0]; @@ -399,17 +397,17 @@ public class PetManager { } public Pet createPet(Item item, String name, String race, String color, GameClient client) { - int type = Integer.valueOf(item.getName().toLowerCase().replace("a0 pet", "")); + int type = Integer.parseInt(item.getName().toLowerCase().replace("a0 pet", "")); if (this.petData.containsKey(type)) { Pet pet; if (type == 15) - pet = new HorsePet(type, Integer.valueOf(race), color, name, client.getHabbo().getHabboInfo().getId()); + pet = new HorsePet(type, Integer.parseInt(race), color, name, client.getHabbo().getHabboInfo().getId()); else if (type == 16) pet = this.createMonsterplant(null, client.getHabbo(), false, null, 0); else pet = new Pet(type, - Integer.valueOf(race), + Integer.parseInt(race), color, name, client.getHabbo().getHabboInfo().getId() diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index fd8f1fe5..8d48bf07 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -952,7 +952,7 @@ public class RoomManager { habbo.getRoomUnit().isKicked = false; if (room.getOwnerId() != habbo.getHabboInfo().getId()) { - AchievementManager.progressAchievement(room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int) Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000)); + AchievementManager.progressAchievement(room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int) Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000.0)); } habbo.getMessenger().connectionChanged(habbo, habbo.isOnline(), false); @@ -1220,7 +1220,7 @@ public class RoomManager { public ArrayList getRoomsVisited(Habbo habbo, boolean includeSelf, int limit) { ArrayList rooms = new ArrayList<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM room_enter_log INNER JOIN rooms ON room_enter_log.room_id = rooms.id WHERE user_id = ? AND timestamp >= ? AND rooms.owner_id != ? GROUP BY rooms.id ORDER BY timestamp DESC LIMIT " + limit)) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM room_enter_log INNER JOIN rooms ON room_enter_log.room_id = rooms.id WHERE user_id = ? AND timestamp >= ? AND rooms.owner_id != ? GROUP BY rooms.id AND timestamp ORDER BY timestamp DESC LIMIT " + limit)) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, Emulator.getIntUnixTimestamp() - 259200); statement.setInt(3, (includeSelf ? 0 : habbo.getHabboInfo().getId())); 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 d3978d8d..574dfa0c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -115,8 +115,8 @@ public class RoomTile { } public double distance(RoomTile roomTile) { - double x = this.x - roomTile.x; - double y = this.y - roomTile.y; + double x = (double) this.x - roomTile.x; + double y = (double) this.y - roomTile.y; return Math.sqrt(x * x + y * y); } @@ -186,7 +186,7 @@ public class RoomTile { public List getUnits() { synchronized (this.units) { - return new ArrayList(this.units); + return new ArrayList<>(this.units); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index c2e3bb86..c510352a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -72,7 +72,7 @@ public class WiredHandler { return false; long millis = System.currentTimeMillis(); - THashSet effectsToExecute = new THashSet(); + THashSet effectsToExecute = new THashSet<>(); List triggeredTiles = new ArrayList<>(); for (InteractionWiredTrigger trigger : triggers) { @@ -81,7 +81,7 @@ public class WiredHandler { if (triggeredTiles.contains(tile)) continue; - THashSet tEffectsToExecute = new THashSet(); + THashSet tEffectsToExecute = new THashSet<>(); if (handle(trigger, roomUnit, room, stuff, tEffectsToExecute)) { effectsToExecute.addAll(tEffectsToExecute); @@ -244,7 +244,7 @@ public class WiredHandler { effect.activateBox(room, roomUnit, millis); } - }, effect.getDelay() * 500); + }, effect.getDelay() * 500L); } } @@ -327,23 +327,23 @@ public class WiredHandler { return; if (rewardReceived.type.equalsIgnoreCase("credits")) { - int credits = Integer.valueOf(rewardReceived.value); + int credits = Integer.parseInt(rewardReceived.value); habbo.giveCredits(credits); } else if (rewardReceived.type.equalsIgnoreCase("pixels")) { - int pixels = Integer.valueOf(rewardReceived.value); + int pixels = Integer.parseInt(rewardReceived.value); habbo.givePixels(pixels); } else if (rewardReceived.type.startsWith("points")) { - int points = Integer.valueOf(rewardReceived.value); + int points = Integer.parseInt(rewardReceived.value); int type = 5; try { - type = Integer.valueOf(rewardReceived.type.replace("points", "")); - } catch (Exception e) { + type = Integer.parseInt(rewardReceived.type.replace("points", "")); + } catch (Exception ignored) { } habbo.givePoints(type, points); } else if (rewardReceived.type.equalsIgnoreCase("furni")) { - Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(Integer.valueOf(rewardReceived.value)); + Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(Integer.parseInt(rewardReceived.value)); if (baseItem != null) { HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), baseItem, 0, 0, ""); @@ -356,9 +356,9 @@ public class WiredHandler { } } } else if (rewardReceived.type.equalsIgnoreCase("respect")) { - habbo.getHabboStats().respectPointsReceived += Integer.valueOf(rewardReceived.value); + habbo.getHabboStats().respectPointsReceived += Integer.parseInt(rewardReceived.value); } else if (rewardReceived.type.equalsIgnoreCase("cata")) { - CatalogItem item = Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(Integer.valueOf(rewardReceived.value)); + CatalogItem item = Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(Integer.parseInt(rewardReceived.value)); if (item != null) { Emulator.getGameEnvironment().getCatalogManager().purchaseItem(null, item, habbo, 1, "", true); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java index 911ab462..73af83bf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java @@ -41,11 +41,7 @@ public class ModAlertEvent extends MessageHandler { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); if (item == null) return; - if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); - } else { - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); - } + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java index bf0a8f62..6cb5b35d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModBanEvent.java @@ -66,12 +66,8 @@ public class ModBanEvent extends MessageHandler { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); if (item == null) return; + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); - if (item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); - } else { - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); - } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java index 8f7b79ec..198b308f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModTradingLockEvent.java @@ -31,12 +31,8 @@ public class ModTradingLockEvent extends MessageHandler { if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0); - if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0); - } else { - modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0); - } } else { modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, duration, false, 0); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java index e0143630..7958b0e0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java @@ -34,7 +34,7 @@ public class SetCustomStackingHeightEvent extends MessageHandler { } } } else { - stackerHeight = Math.min(Math.max(stackerHeight, (long) itemTile.z * 100), Room.MAXIMUM_FURNI_HEIGHT * 100); + stackerHeight = Math.min(Math.max(stackerHeight, itemTile.z * 100.0), Room.MAXIMUM_FURNI_HEIGHT * 100); } double height = 0; diff --git a/src/main/java/com/eu/habbo/networking/Server.java b/src/main/java/com/eu/habbo/networking/Server.java index 3b6d17f8..49d3d0e1 100644 --- a/src/main/java/com/eu/habbo/networking/Server.java +++ b/src/main/java/com/eu/habbo/networking/Server.java @@ -69,6 +69,7 @@ public abstract class Server { this.bossGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).sync(); } catch(InterruptedException e) { LOGGER.error("Exception during {} shutdown... HARD STOP", this.name, e); + Thread.currentThread().interrupt(); } LOGGER.info("GameServer Stopped!"); } diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraClient.java b/src/main/java/com/eu/habbo/networking/camera/CameraClient.java index 5635d9c9..2a5bb499 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraClient.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraClient.java @@ -31,7 +31,7 @@ public class CameraClient { this.bootstrap.option(ChannelOption.SO_KEEPALIVE, false); this.bootstrap.handler(new ChannelInitializer() { @Override - public void initChannel(SocketChannel ch) throws Exception { + public void initChannel(SocketChannel ch) { ch.pipeline().addLast(new CameraDecoder()); ch.pipeline().addLast(new CameraHandler()); } @@ -44,10 +44,6 @@ public class CameraClient { public void connect() { CameraClient.channelFuture = this.bootstrap.connect(host, port); - - while (!CameraClient.channelFuture.isDone()) { - } - if (CameraClient.channelFuture.isSuccess()) { CameraClient.attemptReconnect = false; CameraClient.channel = channelFuture.channel(); @@ -68,7 +64,8 @@ public class CameraClient { channelFuture.channel().close().sync(); channelFuture = null; } catch (Exception e) { - e.printStackTrace(); + LOGGER.error("Caught Exception: ", e); + Thread.currentThread().interrupt(); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/AchievementUpdater.java b/src/main/java/com/eu/habbo/threading/runnables/AchievementUpdater.java index 2ee1dcbf..55865a60 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/AchievementUpdater.java +++ b/src/main/java/com/eu/habbo/threading/runnables/AchievementUpdater.java @@ -14,7 +14,7 @@ public class AchievementUpdater implements Runnable { @Override public void run() { if (!Emulator.isShuttingDown) { - Emulator.getThreading().run(this, INTERVAL * 1000); + Emulator.getThreading().run(this, INTERVAL * 1000L); } if (Emulator.isReady) { @@ -27,7 +27,7 @@ public class AchievementUpdater implements Runnable { if (habbo.getHabboInfo().getLastOnline() > this.lastExecutionTimestamp) { timeOnlineSinceLastInterval = timestamp - habbo.getHabboInfo().getLastOnline(); } - AchievementManager.progressAchievement(habbo, onlineTime, (int) Math.floor((timeOnlineSinceLastInterval) / 60)); + AchievementManager.progressAchievement(habbo, onlineTime, (int) Math.floor((timeOnlineSinceLastInterval) / 60.0)); } this.lastExecutionTimestamp = timestamp; diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java index 61c65c74..32c393eb 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java @@ -38,7 +38,7 @@ public class RoomUnitTeleportWalkToAction implements Runnable { } else { if (tile.isWalkable()) { this.habbo.getRoomUnit().setGoalLocation(tile); - Emulator.getThreading().run(this, this.habbo.getRoomUnit().getPath().size() + 2 * 510); + Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java index 926e38f3..ab5c1e3a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java @@ -37,7 +37,7 @@ public class RoomUnitVendingMachineAction implements Runnable { } else { if (this.room.getLayout().getTile(tile.x, tile.y).isWalkable()) { this.habbo.getRoomUnit().setGoalLocation(tile); - Emulator.getThreading().run(this, this.habbo.getRoomUnit().getPath().size() + 2 * 510); + Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java index a9eb50a0..b500ffb4 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java @@ -75,7 +75,7 @@ public class YouAreAPirate implements Runnable { public final Room room; private int index = 0; - private int oldEffect; + private final int oldEffect; public YouAreAPirate(Habbo habbo, Room room) { this.habbo = habbo; @@ -97,7 +97,7 @@ public class YouAreAPirate implements Runnable { return; } - Emulator.getThreading().run(this, iamapirate[this.index - 1].length() * 100); + Emulator.getThreading().run(this, iamapirate[this.index - 1].length() * 100L); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java b/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java index c1eb576d..40ecf450 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/YoutubeAdvanceVideo.java @@ -28,6 +28,6 @@ public class YoutubeAdvanceVideo implements Runnable { room.updateItem(this.tv); room.sendComposer(new YoutubeDisplayVideoMessageComposer(tv.getId(), tv.currentVideo, true, 0).compose()); - tv.autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo(this.tv), tv.currentVideo.getDuration() * 1000); + tv.autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo(this.tv), tv.currentVideo.getDuration() * 1000L); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java index c448f2ef..332d9fb2 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java @@ -90,7 +90,7 @@ class TeleportActionTwo implements Runnable { } Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "2"), delayOffset); - Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), delayOffset + 1000); + Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), delayOffset + 1000L); Emulator.getThreading().run(new TeleportActionThree(this.currentTeleport, this.room, this.client), delayOffset); } }