mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-02-22 13:02:36 +01:00
Followup of code improvement
This commit is contained in:
parent
0a6355996a
commit
362a03830b
@ -630,11 +630,7 @@ public class CatalogManager {
|
||||
boolean isVisiblePage = object.visible;
|
||||
boolean hasRightRank = object.getRank() <= habbo.getHabboInfo().getRank().getId();
|
||||
|
||||
boolean clubRightsOkay = true;
|
||||
|
||||
if(object.isClubOnly() && !habbo.getHabboInfo().getHabboStats().hasActiveClub()) {
|
||||
clubRightsOkay = false;
|
||||
}
|
||||
boolean clubRightsOkay = !object.isClubOnly() || habbo.getHabboInfo().getHabboStats().hasActiveClub();
|
||||
|
||||
if (isVisiblePage && hasRightRank && clubRightsOkay) {
|
||||
pages.add(object);
|
||||
|
@ -122,10 +122,7 @@ public class FreezeGamePlayer extends GamePlayer {
|
||||
}
|
||||
|
||||
public boolean canGetFrozen() {
|
||||
if (this.isFrozen() || this.isProtected())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return !this.isFrozen() && !this.isProtected();
|
||||
}
|
||||
|
||||
public void addProtection() {
|
||||
|
@ -123,7 +123,7 @@ public class ForumThread implements Runnable, ISerialize {
|
||||
THashSet<ForumThread> threads = null;
|
||||
|
||||
if (guildThreadsCache.containsKey(guildId)) {
|
||||
guildThreadsCache.get(guildId);
|
||||
threads = guildThreadsCache.get(guildId);
|
||||
}
|
||||
|
||||
if (threads != null)
|
||||
@ -141,8 +141,8 @@ public class ForumThread implements Runnable, ISerialize {
|
||||
"WHERE `id` IN (" +
|
||||
"SELECT MAX(id) " +
|
||||
"FROM `guilds_forums_comments` B " +
|
||||
"GROUP BY `thread_id` " +
|
||||
"ORDER BY B.`id` ASC " +
|
||||
"GROUP BY `thread_id` AND B.`id` " +
|
||||
"ORDER BY B.`id` " +
|
||||
") " +
|
||||
"ORDER BY `id` DESC " +
|
||||
") B ON A.`id` = B.`thread_id` " +
|
||||
@ -182,8 +182,8 @@ public class ForumThread implements Runnable, ISerialize {
|
||||
"WHERE `id` IN (" +
|
||||
"SELECT MAX(id) " +
|
||||
"FROM `guilds_forums_comments` B " +
|
||||
"GROUP BY `thread_id` " +
|
||||
"ORDER BY B.`id` ASC " +
|
||||
"GROUP BY `thread_id` AND b.`id`" +
|
||||
"ORDER BY B.`id` " +
|
||||
") " +
|
||||
"ORDER BY `id` DESC " +
|
||||
") B ON A.`id` = B.`thread_id` " +
|
||||
@ -219,10 +219,7 @@ public class ForumThread implements Runnable, ISerialize {
|
||||
guildThreadsCache.put(thread.guildId, guildThreads);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (guildThreads) {
|
||||
guildThreads.add(thread);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
|
@ -202,10 +202,7 @@ public class InteractionTeleport extends HabboItem {
|
||||
if (unit == null)
|
||||
return false;
|
||||
|
||||
if (habbo.getHabboInfo().getRiding() != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return habbo.getHabboInfo().getRiding() == null;
|
||||
}
|
||||
|
||||
public void startTeleport(Room room, Habbo habbo) {
|
||||
|
@ -115,9 +115,7 @@ public abstract class InteractionWired extends InteractionDefault {
|
||||
} else {
|
||||
if (this.userExecutionCache.containsKey((long)roomUnitId)) {
|
||||
long lastTimestamp = this.userExecutionCache.get((long)roomUnitId);
|
||||
if (timestamp - lastTimestamp < Math.max(100L, this.requiredCooldown())) {
|
||||
return false;
|
||||
}
|
||||
return timestamp - lastTimestamp >= Math.max(100L, this.requiredCooldown());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -81,7 +81,7 @@ public class InteractionWiredHighscore extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
|
||||
if (room == null || !((client != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
|
||||
return;
|
||||
|
||||
if (this.getExtradata() == null || this.getExtradata().isEmpty() || this.getExtradata().length() == 0) {
|
||||
|
@ -63,8 +63,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
|
||||
|
||||
@Override
|
||||
public int getNextRollDelay(int currentStep, int totalSteps) {
|
||||
int t = 2500;
|
||||
return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100);
|
||||
return (totalSteps == 1) ? 500 : 100 + (currentStep * 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,7 +51,7 @@ public class InteractionTotemLegs extends InteractionDefault {
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
|
||||
if (room == null || !((client != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
|
||||
return;
|
||||
|
||||
updateHead(room, room.getLayout().getTile(this.getX(), this.getY()));
|
||||
|
@ -390,9 +390,7 @@ public class Pet implements ISerialize, Runnable {
|
||||
keys.put(RoomUnitStatus.GESTURE, this.roomUnit.getStatus(RoomUnitStatus.GESTURE));
|
||||
|
||||
if (this.task == null) {
|
||||
boolean isDead = false;
|
||||
if (this.roomUnit.hasStatus(RoomUnitStatus.RIP))
|
||||
isDead = true;
|
||||
boolean isDead = this.roomUnit.hasStatus(RoomUnitStatus.RIP);
|
||||
|
||||
this.roomUnit.clearStatus();
|
||||
|
||||
|
@ -59,10 +59,7 @@ public class RoomLayout {
|
||||
if (outerSquare.x + outerSquare.width < innerSquare.x + innerSquare.width)
|
||||
return false;
|
||||
|
||||
if (outerSquare.y + outerSquare.height < innerSquare.y + innerSquare.height)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return outerSquare.y + outerSquare.height >= innerSquare.y + innerSquare.height;
|
||||
}
|
||||
|
||||
public static boolean tileInSquare(Rectangle square, RoomTile tile) {
|
||||
|
@ -1035,7 +1035,7 @@ public class RoomManager {
|
||||
|
||||
Collections.sort(rooms);
|
||||
|
||||
return new ArrayList<>(rooms.subList(0, (rooms.size() < count ? rooms.size() : count)));
|
||||
return new ArrayList<>(rooms.subList(0, (Math.min(rooms.size(), count))));
|
||||
}
|
||||
|
||||
public ArrayList<Room> getPopularRooms(int count, int category) {
|
||||
@ -1053,7 +1053,7 @@ public class RoomManager {
|
||||
|
||||
Collections.sort(rooms);
|
||||
|
||||
return new ArrayList<>(rooms.subList(0, (rooms.size() < count ? rooms.size() : count)));
|
||||
return new ArrayList<>(rooms.subList(0, (Math.min(rooms.size(), count))));
|
||||
}
|
||||
|
||||
public Map<Integer, List<Room>> getPopularRoomsByCategory(int count) {
|
||||
@ -1077,7 +1077,7 @@ public class RoomManager {
|
||||
|
||||
Collections.sort(set.getValue());
|
||||
|
||||
result.put(set.getKey(), new ArrayList<>(set.getValue().subList(0, (set.getValue().size() < count ? set.getValue().size() : count))));
|
||||
result.put(set.getKey(), new ArrayList<>(set.getValue().subList(0, (Math.min(set.getValue().size(), count)))));
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -1294,7 +1294,7 @@ public class RoomManager {
|
||||
|
||||
Collections.sort(rooms);
|
||||
|
||||
return rooms.subList(0, (rooms.size() > limit ? limit : rooms.size()));
|
||||
return rooms.subList(0, (Math.min(rooms.size(), limit)));
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsWithRights(Habbo habbo) {
|
||||
|
@ -630,11 +630,7 @@ public class RoomSpecialTypes {
|
||||
}
|
||||
|
||||
public InteractionFreezeExitTile getFreezeExitTile() {
|
||||
for (InteractionFreezeExitTile t : this.freezeExitTile.values()) {
|
||||
return t;
|
||||
}
|
||||
|
||||
return null;
|
||||
return this.freezeExitTile.values().stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public InteractionFreezeExitTile getRandomFreezeExitTile() {
|
||||
|
@ -20,10 +20,7 @@ public class RequestOffersEvent extends MessageHandler {
|
||||
String query = this.packet.readString();
|
||||
int type = this.packet.readInt();
|
||||
|
||||
boolean tryCache = false;
|
||||
if (min == -1 && max == -1 && query.isEmpty()) {
|
||||
tryCache = true;
|
||||
}
|
||||
boolean tryCache = min == -1 && max == -1 && query.isEmpty();
|
||||
|
||||
if (tryCache) {
|
||||
ServerMessage message = cachedResults.get(type);
|
||||
|
@ -13,11 +13,7 @@ public class RequestRoomDataEvent extends MessageHandler {
|
||||
int something = this.packet.readInt();
|
||||
int something2 = this.packet.readInt();
|
||||
if (room != null) {
|
||||
boolean unknown = true;
|
||||
|
||||
if (something == 0 && something2 == 1) {
|
||||
unknown = false;
|
||||
}
|
||||
boolean unknown = something != 0 || something2 != 1;
|
||||
|
||||
//this.client.getHabbo().getHabboInfo().getCurrentRoom() != room
|
||||
this.client.sendResponse(new RoomDataComposer(room, this.client.getHabbo(), true, unknown));
|
||||
|
@ -43,7 +43,7 @@ public class AchievementListComposer extends MessageComposer {
|
||||
this.response.appendInt(nextLevel != null ? nextLevel.progress : -1); //Progress needed
|
||||
this.response.appendInt(nextLevel != null ? nextLevel.rewardAmount : -1); //Reward amount
|
||||
this.response.appendInt(nextLevel != null ? nextLevel.rewardType : -1); //Reward currency ID
|
||||
this.response.appendInt(achievementProgress <= 0 ? 0 : achievementProgress); //Current progress
|
||||
this.response.appendInt(Math.max(achievementProgress, 0)); //Current progress
|
||||
this.response.appendBoolean(AchievementManager.hasAchieved(this.habbo, achievement)); //Achieved? (Current Progress == MaxLevel.Progress)
|
||||
this.response.appendString(achievement.category.toString().toLowerCase()); //Category
|
||||
this.response.appendString(""); //Empty, completly unused in client code
|
||||
|
@ -32,7 +32,7 @@ public class GuildForumListComposer extends MessageComposer {
|
||||
this.response.appendInt(this.index);
|
||||
|
||||
Iterator<Guild> it = guilds.iterator();
|
||||
int count = guilds.size() > 20 ? 20 : guilds.size();
|
||||
int count = Math.min(guilds.size(), 20);
|
||||
|
||||
this.response.appendInt(count);
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class GuildForumThreadsComposer extends MessageComposer {
|
||||
Collections.reverse(threads);
|
||||
|
||||
Iterator<ForumThread> it = threads.iterator();
|
||||
int count = threads.size() > 20 ? 20 : threads.size();
|
||||
int count = Math.min(threads.size(), 20);
|
||||
|
||||
this.response.init(Outgoing.GuildForumThreadsComposer);
|
||||
this.response.appendInt(this.guild.getId());
|
||||
|
@ -21,7 +21,7 @@ public class BonusRareComposer extends MessageComposer {
|
||||
this.response.appendInt(Emulator.getConfig().getInt("hotelview.promotional.points", 120)); //Total Required
|
||||
//this.response.appendInt(this.habbo.getHabboInfo().getBonusRarePoints() >= Emulator.getConfig().getInt("hotelview.promotinal.points", 120) ? Emulator.getConfig().getInt("hotelview.promotinal.points", 120) : this.habbo.getHabboInfo().getBonusRarePoints() ); //Total To Gain
|
||||
int points = Emulator.getConfig().getInt("hotelview.promotional.points", 120) - this.habbo.getHabboInfo().getBonusRarePoints();
|
||||
this.response.appendInt(points < 0 ? 0 : points);
|
||||
this.response.appendInt(Math.max(points, 0));
|
||||
|
||||
return this.response;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class GiveRespect extends RCONMessage<GiveRespect.JSONGiveRespect> {
|
||||
habbo.getHabboStats().respectPointsToGive += object.daily_respects;
|
||||
habbo.getClient().sendResponse(new UserDataComposer(habbo));
|
||||
} else {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET respects_given = respects_give + ?, respects_received = respects_received + ?, daily_respect_points = daily_respect_points + ? WHERE user_id = ? LIMIT 1")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET respects_given = respects_given + ?, respects_received = respects_received + ?, daily_respect_points = daily_respect_points + ? WHERE user_id = ? LIMIT 1")) {
|
||||
statement.setInt(1, object.respect_received);
|
||||
statement.setInt(2, object.respect_given);
|
||||
statement.setInt(3, object.daily_respects);
|
||||
|
@ -22,7 +22,7 @@ class QueryDeleteHabboBadge implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM user_badges WHERE users_id = ? AND badge_code = ?")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_badges WHERE user_id = ? AND badge_code = ?")) {
|
||||
statement.setInt(1, this.habbo.getHabboInfo().getId());
|
||||
statement.setString(2, this.name);
|
||||
statement.execute();
|
||||
|
Loading…
x
Reference in New Issue
Block a user