This commit is contained in:
brenoepic 2022-04-30 22:35:42 -03:00
parent 8a75cf6c73
commit 6713eb1e77
23 changed files with 68 additions and 78 deletions

View File

@ -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);

View File

@ -22,7 +22,7 @@ public class GuardianTicket {
private final Habbo reporter;
private final Habbo reported;
private final Date date;
private ArrayList<ModToolChatLog> chatLogs;
private final ArrayList<ModToolChatLog> 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);
}

View File

@ -29,6 +29,11 @@ public class GuardianVote implements Comparable<GuardianVote> {
return false;
}
@Override
public int hashCode() {
return this.id;
}
public void ignore() {
this.ignore = true;
}

View File

@ -72,6 +72,10 @@ public class GuildMember implements Comparable<GuildMember> {
return false;
}
@Override
public int hashCode() {
return this.userId;
}
public GuildMembershipStatus getMembershipStatus() {
if (this.rank == GuildRank.DELETED) return GuildMembershipStatus.NOT_MEMBER;

View File

@ -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);
}

View File

@ -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);

View File

@ -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<Integer> invalidTriggers = new ArrayList<>();
room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure<InteractionWiredTrigger>() {
@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) {

View File

@ -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<ArrayList<PetBreedingReward>> offspringList = this.breedingReward.get(pet.getPetData().getType());
offspringList.forEachEntry(new TIntObjectProcedure<ArrayList<PetBreedingReward>>() {
@Override
public boolean execute(int i, ArrayList<PetBreedingReward> 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()

View File

@ -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<Room> getRoomsVisited(Habbo habbo, boolean includeSelf, int limit) {
ArrayList<Room> 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()));

View File

@ -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<RoomUnit> getUnits() {
synchronized (this.units) {
return new ArrayList<RoomUnit>(this.units);
return new ArrayList<>(this.units);
}
}

View File

@ -72,7 +72,7 @@ public class WiredHandler {
return false;
long millis = System.currentTimeMillis();
THashSet<InteractionWiredEffect> effectsToExecute = new THashSet<InteractionWiredEffect>();
THashSet<InteractionWiredEffect> effectsToExecute = new THashSet<>();
List<RoomTile> triggeredTiles = new ArrayList<>();
for (InteractionWiredTrigger trigger : triggers) {
@ -81,7 +81,7 @@ public class WiredHandler {
if (triggeredTiles.contains(tile))
continue;
THashSet<InteractionWiredEffect> tEffectsToExecute = new THashSet<InteractionWiredEffect>();
THashSet<InteractionWiredEffect> 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);

View File

@ -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);
}

View File

@ -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);
}
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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!");
}

View File

@ -31,7 +31,7 @@ public class CameraClient {
this.bootstrap.option(ChannelOption.SO_KEEPALIVE, false);
this.bootstrap.handler(new ChannelInitializer<SocketChannel>() {
@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();
}
}

View File

@ -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;

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}