From f2d13298835073a9e7e15a1a1e788365ce23c26e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 15 Jul 2019 10:42:00 +0300 Subject: [PATCH 01/77] Use RTRIM instead of TRIM in chat messages --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 38555728..d8748aca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3065,7 +3065,11 @@ public class Room implements Comparable, ISerialize, Runnable { Rectangle show = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation()); - roomChatMessage.setMessage(roomChatMessage.getMessage().trim()); + String trimmedMessage = roomChatMessage.getMessage().replaceAll("\\s+$",""); + + if (trimmedMessage.isEmpty()) trimmedMessage = " "; + + roomChatMessage.setMessage(trimmedMessage); if (chatType == RoomChatType.WHISPER) { if (roomChatMessage.getTargetHabbo() == null) { From c1d4630ee097a576657af5e5358ec59b7dca305d Mon Sep 17 00:00:00 2001 From: Harmonic Date: Tue, 16 Jul 2019 20:33:19 -0400 Subject: [PATCH 02/77] Add rank currency timers --- pom.xml | 2 +- sqlupdates/2_1_1_TO_2_2_0-RC-1.sql | 12 +++ src/main/java/com/eu/habbo/Emulator.java | 31 +++----- .../com/eu/habbo/core/CreditsScheduler.java | 9 +-- .../eu/habbo/core/GotwPointsScheduler.java | 78 +++++++++++++++++++ .../com/eu/habbo/core/PixelScheduler.java | 33 +------- .../com/eu/habbo/core/PointsScheduler.java | 34 +------- .../eu/habbo/habbohotel/GameEnvironment.java | 12 ++- .../eu/habbo/habbohotel/permissions/Rank.java | 21 +++++ .../com/eu/habbo/plugin/PluginManager.java | 2 + 10 files changed, 139 insertions(+), 95 deletions(-) create mode 100644 sqlupdates/2_1_1_TO_2_2_0-RC-1.sql create mode 100644 src/main/java/com/eu/habbo/core/GotwPointsScheduler.java diff --git a/pom.xml b/pom.xml index 51d02e18..33253bbb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eu.habbo Habbo - 2.1.0 + 2.2.0 UTF-8 diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql new file mode 100644 index 00000000..63c682f3 --- /dev/null +++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql @@ -0,0 +1,12 @@ +ALTER TABLE `permissions` +ADD COLUMN `auto_credits_amount` INT DEFAULT '0'; +ADD COLUMN `auto_pixels_amount` INT DEFAULT '0'; +ADD COLUMN `auto_gotw_amount` INT DEFAULT '0'; +ADD COLUMN `auto_points_amount` INT DEFAULT '0'; + +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.enabled', '0'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.interval', '600'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.ignore.idled', '1'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.ignore.hotelview', '1'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.type', '4'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.name', 'shell'); diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index bdebafe6..9cdd1324 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -34,13 +34,13 @@ public final class Emulator { public final static int MAJOR = 2; - public final static int MINOR = 1; + public final static int MINOR = 2; - public final static int BUILD = 1; + public final static int BUILD = 0; - public final static String PREVIEW = "Stable"; + public final static String PREVIEW = "RC-1"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -137,15 +137,12 @@ public final class Emulator { } - Emulator.getThreading().run(new Runnable() { - @Override - public void run() { - Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a stable 2.1.0 build, it should be more than stable for daily use on hotels, if you find any bugs please place them on our git repository."); - Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: "); - Emulator.getLogging().logStart("https://discord.gg/syuqgN"); - Emulator.getLogging().logStart("Please report bugs on our git at Krews.org. Not on our discord!!"); - System.out.println("Waiting for commands: "); - } + Emulator.getThreading().run(() -> { + Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a 2.2.0 RC-1 Build. If you find any bugs please place them on our git repository."); + Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: "); + Emulator.getLogging().logStart("https://discord.gg/syuqgN"); + Emulator.getLogging().logStart("Please report bugs on our git at Krews.org. Not on our discord!!"); + System.out.println("Waiting for commands: "); }, 3500); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); @@ -169,24 +166,14 @@ public final class Emulator { } private static void setBuild() { - if (Emulator.class.getProtectionDomain().getCodeSource() == null) { - build = "UNKNOWN"; - return; - } StringBuilder sb = new StringBuilder(); try { - String filepath = new File(Emulator.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath(); MessageDigest md = MessageDigest.getInstance("MD5");// MD5 - FileInputStream fis = new FileInputStream(filepath); byte[] dataBytes = new byte[1024]; int nread = 0; - - while ((nread = fis.read(dataBytes)) != -1) md.update(dataBytes, 0, nread); - byte[] mdbytes = md.digest(); - for (int i = 0; i < mdbytes.length; i++) sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1)); } catch (Exception e) { diff --git a/src/main/java/com/eu/habbo/core/CreditsScheduler.java b/src/main/java/com/eu/habbo/core/CreditsScheduler.java index 4c2a44a1..ce136ede 100644 --- a/src/main/java/com/eu/habbo/core/CreditsScheduler.java +++ b/src/main/java/com/eu/habbo/core/CreditsScheduler.java @@ -8,14 +8,10 @@ import java.util.Map; public class CreditsScheduler extends Scheduler { public static boolean IGNORE_HOTEL_VIEW; - - public static boolean IGNORE_IDLED; - - public static int CREDITS; - public CreditsScheduler() { + super(Emulator.getConfig().getInt("hotel.auto.credits.interval")); this.reloadConfig(); } @@ -24,7 +20,6 @@ public class CreditsScheduler extends Scheduler { if (Emulator.getConfig().getBoolean("hotel.auto.credits.enabled")) { IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.hotelview"); IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.idled"); - CREDITS = Emulator.getConfig().getInt("hotel.auto.credits.amount"); if (this.disposed) { this.disposed = false; this.run(); @@ -50,7 +45,7 @@ public class CreditsScheduler extends Scheduler { if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) continue; - habbo.giveCredits(CREDITS); + habbo.giveCredits(habbo.getHabboInfo().getRank().getCreditsTimerAmount()); } } catch (Exception e) { Emulator.getLogging().logErrorLine(e); diff --git a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java new file mode 100644 index 00000000..4a85969e --- /dev/null +++ b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java @@ -0,0 +1,78 @@ +package com.eu.habbo.core; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.users.Habbo; + +import java.util.Map; + +public class GotwPointsScheduler extends Scheduler { + + public static boolean IGNORE_HOTEL_VIEW; + public static boolean IGNORE_IDLED; + public static String GOTW_POINTS_NAME; + + public GotwPointsScheduler() { //TODO MOVE TO A PLUGIN. IS NOT PART OF OFFICIAL HABBO. + + super(Emulator.getConfig().getInt("hotel.auto.gotwpoints.interval")); + this.reloadConfig(); + } + + public void reloadConfig() { + if (Emulator.getConfig().getBoolean("hotel.auto.gotwpoints.enabled")) { + IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.gotwpoints.ignore.hotelview"); + IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.gotwpoints.ignore.idled"); + GOTW_POINTS_NAME = Emulator.getConfig().getValue("hotel.auto.gotwpoints.name"); + + if (this.disposed) { + this.disposed = false; + this.run(); + } + } else { + this.disposed = true; + } + } + + @Override + public void run() { + super.run(); + + Habbo habbo; + for (Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + habbo = map.getValue(); + + try { + if (habbo != null) { + if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) + continue; + + if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) + continue; + + int type; + boolean found = false; + for (String s : Emulator.getConfig().getValue("seasonal.currency.names").split(";")) { + if (s.equalsIgnoreCase(GOTW_POINTS_NAME) || (GOTW_POINTS_NAME.startsWith(s) && Math.abs(s.length() - GOTW_POINTS_NAME.length()) < 3)) { + found = true; + break; + } + } + type = Emulator.getConfig().getInt("seasonal.currency." + GOTW_POINTS_NAME, -1); + if (found || type != -1) { + + habbo.givePoints(type, habbo.getHabboInfo().getRank().getGotwTimerAmount()); + } + } + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } + } + } + + public boolean isDisposed() { + return this.disposed; + } + + public void setDisposed(boolean disposed) { + this.disposed = disposed; + } +} diff --git a/src/main/java/com/eu/habbo/core/PixelScheduler.java b/src/main/java/com/eu/habbo/core/PixelScheduler.java index 285df17c..13a0cf3d 100644 --- a/src/main/java/com/eu/habbo/core/PixelScheduler.java +++ b/src/main/java/com/eu/habbo/core/PixelScheduler.java @@ -8,47 +8,17 @@ import java.util.Map; public class PixelScheduler extends Scheduler { public static boolean IGNORE_HOTEL_VIEW; - - public static boolean IGNORE_IDLED; - - private static int PIXELS; - public PixelScheduler() { super(Emulator.getConfig().getInt("hotel.auto.pixels.interval")); this.reloadConfig(); } - public static boolean isIgnoreHotelView() { - return IGNORE_HOTEL_VIEW; - } - - public static void setIgnoreHotelView(boolean ignoreHotelView) { - IGNORE_HOTEL_VIEW = ignoreHotelView; - } - - public static boolean isIgnoreIdled() { - return IGNORE_IDLED; - } - - public static void setIgnoreIdled(boolean ignoreIdled) { - IGNORE_IDLED = ignoreIdled; - } - - public static int getPIXELS() { - return PIXELS; - } - - public static void setPIXELS(int PIXELS) { - PixelScheduler.PIXELS = PIXELS; - } - public void reloadConfig() { if (Emulator.getConfig().getBoolean("hotel.auto.pixels.enabled")) { IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.hotelview"); IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.idled"); - PIXELS = Emulator.getConfig().getInt("hotel.auto.pixels.amount"); if (this.disposed) { this.disposed = false; this.run(); @@ -65,7 +35,6 @@ public class PixelScheduler extends Scheduler { Habbo habbo; for (Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { habbo = map.getValue(); - try { if (habbo != null) { if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) @@ -74,7 +43,7 @@ public class PixelScheduler extends Scheduler { if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) continue; - habbo.givePixels(PIXELS); + habbo.givePixels(habbo.getHabboInfo().getRank().getPixelsTimerAmount()); } } catch (Exception e) { Emulator.getLogging().logErrorLine(e); diff --git a/src/main/java/com/eu/habbo/core/PointsScheduler.java b/src/main/java/com/eu/habbo/core/PointsScheduler.java index 529d004d..f5c8042d 100644 --- a/src/main/java/com/eu/habbo/core/PointsScheduler.java +++ b/src/main/java/com/eu/habbo/core/PointsScheduler.java @@ -8,47 +8,18 @@ import java.util.Map; public class PointsScheduler extends Scheduler { public static boolean IGNORE_HOTEL_VIEW; - - public static boolean IGNORE_IDLED; - - private static int POINTS; - public PointsScheduler() { + super(Emulator.getConfig().getInt("hotel.auto.points.interval")); this.reloadConfig(); } - public static boolean isIgnoreHotelView() { - return IGNORE_HOTEL_VIEW; - } - - public static void setIgnoreHotelView(boolean ignoreHotelView) { - IGNORE_HOTEL_VIEW = ignoreHotelView; - } - - public static boolean isIgnoreIdled() { - return IGNORE_IDLED; - } - - public static void setIgnoreIdled(boolean ignoreIdled) { - IGNORE_IDLED = ignoreIdled; - } - - public static int getPOINTS() { - return POINTS; - } - - public static void setPOINTS(int POINTS) { - PointsScheduler.POINTS = POINTS; - } - public void reloadConfig() { if (Emulator.getConfig().getBoolean("hotel.auto.points.enabled")) { IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.hotelview"); IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.idled"); - POINTS = Emulator.getConfig().getInt("hotel.auto.points.amount"); if (this.disposed) { this.disposed = false; this.run(); @@ -74,7 +45,8 @@ public class PointsScheduler extends Scheduler { if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) continue; - habbo.givePoints(POINTS); + //habbo.givePoints(POINTS); + habbo.givePoints(habbo.getHabboInfo().getRank().getDiamondsTimerAmount()); } } catch (Exception e) { Emulator.getLogging().logErrorLine(e); diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java index 99302c6a..02704bd3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java +++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel; import com.eu.habbo.Emulator; import com.eu.habbo.core.CreditsScheduler; +import com.eu.habbo.core.GotwPointsScheduler; import com.eu.habbo.core.PixelScheduler; import com.eu.habbo.core.PointsScheduler; import com.eu.habbo.habbohotel.achievements.AchievementManager; @@ -26,6 +27,7 @@ public class GameEnvironment { public CreditsScheduler creditsScheduler; public PixelScheduler pixelScheduler; public PointsScheduler pointsScheduler; + public GotwPointsScheduler gotwPointsScheduler; private HabboManager habboManager; private NavigatorManager navigatorManager; private GuildManager guildManager; @@ -76,6 +78,9 @@ public class GameEnvironment { Emulator.getThreading().run(this.pixelScheduler); this.pointsScheduler = new PointsScheduler(); Emulator.getThreading().run(this.pointsScheduler); + this.gotwPointsScheduler = new GotwPointsScheduler(); + Emulator.getThreading().run(this.gotwPointsScheduler); + Emulator.getLogging().logStart("GameEnvironment -> Loaded!"); } @@ -84,6 +89,7 @@ public class GameEnvironment { this.pointsScheduler.setDisposed(true); this.pixelScheduler.setDisposed(true); this.creditsScheduler.setDisposed(true); + this.gotwPointsScheduler.setDisposed(true); this.craftingManager.dispose(); this.habboManager.dispose(); this.commandHandler.dispose(); @@ -171,7 +177,9 @@ public class GameEnvironment { return this.pixelScheduler; } - public PointsScheduler getPointsScheduler() { - return this.pointsScheduler; + public PointsScheduler getPointsScheduler() { return this.pointsScheduler; + } + + public GotwPointsScheduler getGotwPointsScheduler() { return this.gotwPointsScheduler; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java b/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java index 068f050e..20929cd7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java @@ -29,12 +29,20 @@ public class Rank { private boolean hasPrefix; + private int diamondsTimerAmount; + private int creditsTimerAmount; + private int pixelsTimerAmount; + private int gotwTimerAmount; public Rank(ResultSet set) throws SQLException { this.permissions = new THashMap<>(); this.variables = new THashMap<>(); this.id = set.getInt("id"); this.level = set.getInt("level"); + this.diamondsTimerAmount = 1; + this.creditsTimerAmount = 1; + this.pixelsTimerAmount = 1; + this.gotwTimerAmount = 1; this.load(set); } @@ -47,6 +55,10 @@ public class Rank { this.logCommands = set.getString("log_commands").equals("1"); this.prefix = set.getString("prefix"); this.prefixColor = set.getString("prefix_color"); + this.diamondsTimerAmount = set.getInt("auto_points_amount"); + this.creditsTimerAmount = set.getInt("auto_credits_amount"); + this.pixelsTimerAmount = set.getInt("auto_pixels_amount"); + this.gotwTimerAmount = set.getInt("auto_gotw_amount"); this.hasPrefix = !this.prefix.isEmpty(); for (int i = 1; i < meta.getColumnCount() + 1; i++) { String columnName = meta.getColumnName(i); @@ -115,4 +127,13 @@ public class Rank { public boolean hasPrefix() { return this.hasPrefix; } + + public int getDiamondsTimerAmount() { return this.diamondsTimerAmount; } + + public int getCreditsTimerAmount() { return this.creditsTimerAmount; } + + public int getPixelsTimerAmount() { return this.pixelsTimerAmount; } + + public int getGotwTimerAmount() { return this.gotwTimerAmount; } } + diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 80f56a9b..d1ecfbef 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -126,6 +126,8 @@ public class PluginManager { Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig(); Emulator.getGameEnvironment().getPointsScheduler().reloadConfig(); Emulator.getGameEnvironment().getPixelScheduler().reloadConfig(); + Emulator.getGameEnvironment().getGotwPointsScheduler().reloadConfig(); + } } From 06d8300886d31fe3c80e13d17a6918913bf0468b Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 21 Jul 2019 20:16:27 +0300 Subject: [PATCH 03/77] Add reporting photos --- .../modtool/ModToolChatRecordDataContext.java | 3 +- .../habbohotel/modtool/ModToolIssue.java | 2 + .../com/eu/habbo/messages/PacketManager.java | 1 + .../eu/habbo/messages/incoming/Incoming.java | 1 + .../ModToolRequestIssueChatlogEvent.java | 6 ++ .../incoming/modtool/ReportPhotoEvent.java | 63 +++++++++++++++++++ .../modtool/ModToolIssueChatlogComposer.java | 9 ++- 7 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java index 45a8db9f..37908488 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java @@ -7,7 +7,8 @@ public enum ModToolChatRecordDataContext { ROOM_ID("roomId", 1), GROUP_ID("groupId", 1), THREAD_ID("threadId", 1), - MESSAGE_ID("messageId", 1); + MESSAGE_ID("messageId", 1), + PHOTO_ID("extraDataId", 2); public final String key; public final int type; diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java index 531ffb7c..172e29e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.UpdateModToolIssue; @@ -28,6 +29,7 @@ public class ModToolIssue implements ISerialize { public int groupId = -1; public int threadId = -1; public int commentId = -1; + public HabboItem photoItem = null; public ModToolIssue(ResultSet set) throws SQLException { this.id = set.getInt("id"); diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index c49fe1b3..989a6e6d 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -468,6 +468,7 @@ public class PacketManager { this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class); this.registerHandler(Incoming.ReportThreadEvent, ReportThreadEvent.class); this.registerHandler(Incoming.ReportCommentEvent, ReportCommentEvent.class); + this.registerHandler(Incoming.ReportPhotoEvent, ReportPhotoEvent.class); } void registerTrading() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index ee4ed6d5..0b70e95b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -292,6 +292,7 @@ public class Incoming { public static final int UpdateUIFlagsEvent = 2313; public static final int ReportThreadEvent = 534; public static final int ReportCommentEvent = 1412; + public static final int ReportPhotoEvent = 2492; public static final int RequestCraftingRecipesEvent = 1173; public static final int RequestCraftingRecipesAvailableEvent = 3086; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java index 50757290..4eb2756e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java @@ -43,6 +43,12 @@ public class ModToolRequestIssueChatlogEvent extends MessageHandler { chatlog = thread.getComments().stream().map(c -> new ModToolChatLog(c.getCreatedAt(), c.getHabbo().getHabboInfo().getId(), c.getHabbo().getHabboInfo().getUsername(), c.getMessage(), c.getCommentId() == issue.commentId)).collect(Collectors.toList()); } } + } else if (issue.type == ModToolTicketType.PHOTO) { + if (issue.photoItem != null) { + chatlogType = ModToolIssueChatlogType.PHOTO; + + chatlog = Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(issue.roomId); + } } else { chatlogType = ModToolIssueChatlogType.CHAT; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java new file mode 100644 index 00000000..04b75b4f --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java @@ -0,0 +1,63 @@ +package com.eu.habbo.messages.incoming.modtool; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionExternalImage; +import com.eu.habbo.habbohotel.modtool.CfhTopic; +import com.eu.habbo.habbohotel.modtool.ModToolIssue; +import com.eu.habbo.habbohotel.modtool.ModToolTicketType; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboInfo; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.modtool.ModToolReportReceivedAlertComposer; +import com.eu.habbo.threading.runnables.InsertModToolIssue; +import com.google.gson.JsonParser; + +public class ReportPhotoEvent extends MessageHandler { + @Override + public void handle() throws Exception { + boolean hasExtradataId = this.packet.readShort() != 0; + + this.packet.getBuffer().resetReaderIndex(); + + if (hasExtradataId) { + String extradataId = this.packet.readString(); + } + + int roomId = this.packet.readInt(); + int reportedUserId = this.packet.readInt(); + int topicId = this.packet.readInt(); + int itemId = this.packet.readInt(); + + CfhTopic topic = Emulator.getGameEnvironment().getModToolManager().getCfhTopic(topicId); + + if (topic == null) return; + + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId); + + if (room == null) return; + + HabboItem item = room.getHabboItem(itemId); + + if (item == null || !(item instanceof InteractionExternalImage)) return; + + InteractionExternalImage photoItem = (InteractionExternalImage) item; + + String photoCreatorId = new JsonParser().parse(photoItem.getExtradata()).getAsJsonObject().get("u").getAsString(); + + if (photoCreatorId == null) return; + + HabboInfo photoCreator = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(Integer.valueOf(photoCreatorId)); + + if (photoCreator == null) return; + + ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), photoCreator.getId(), photoCreator.getUsername(), roomId, "", ModToolTicketType.PHOTO); + issue.photoItem = photoItem; + + new InsertModToolIssue(issue).run(); + + this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, "")); + Emulator.getGameEnvironment().getModToolManager().addTicket(issue); + Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); + } +} diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java index 8eef3dc8..dd73279a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java @@ -8,7 +8,6 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -65,6 +64,14 @@ public class ModToolIssueChatlogComposer extends MessageComposer { ModToolChatRecordDataContext.GROUP_ID.append(this.response); this.response.appendInt(this.issue.commentId); } + } else if (this.issue.type == ModToolTicketType.PHOTO) { + this.response.appendShort(2); + + ModToolChatRecordDataContext.ROOM_NAME.append(this.response); + this.response.appendString(this.roomName); + + ModToolChatRecordDataContext.PHOTO_ID.append(this.response); + this.response.appendString(this.issue.photoItem.getId() + ""); } else { this.response.appendShort(3); //Context Count From b9b77d35156b13afef5415e5001146efe4964df6 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 21 Jul 2019 20:29:19 +0300 Subject: [PATCH 04/77] Fix update SQL --- sqlupdates/2_1_1_TO_2_2_0-RC-1.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql index 63c682f3..5ca7ca4a 100644 --- a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql +++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql @@ -1,7 +1,7 @@ ALTER TABLE `permissions` -ADD COLUMN `auto_credits_amount` INT DEFAULT '0'; -ADD COLUMN `auto_pixels_amount` INT DEFAULT '0'; -ADD COLUMN `auto_gotw_amount` INT DEFAULT '0'; +ADD COLUMN `auto_credits_amount` INT DEFAULT '0', +ADD COLUMN `auto_pixels_amount` INT DEFAULT '0', +ADD COLUMN `auto_gotw_amount` INT DEFAULT '0', ADD COLUMN `auto_points_amount` INT DEFAULT '0'; INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.enabled', '0'); From bda19d759fa7ddf8d989d1e1b1726e04799e600e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 21 Jul 2019 20:35:00 +0300 Subject: [PATCH 05/77] Fix `Parent Page not found for null (ID: 0, parent_id: 0)` --- .../habbohotel/catalog/CatalogManager.java | 23 ++++++++----------- .../catalog/layouts/CatalogRootLayout.java | 11 +++++++++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 99296bb2..5e1e81c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -283,22 +283,19 @@ public class CatalogManager { Emulator.getLogging().logSQLException(e); } - pages.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(CatalogPage object) { - CatalogPage page = pages.get(object.parentId); + pages.forEachValue((object) -> { + CatalogPage page = pages.get(object.parentId); - if (page != null) { - if (page.id != object.id) { - page.addChildPage(object); - } - } else { - if (object.parentId != -2) { - Emulator.getLogging().logStart("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")"); - } + if (page != null) { + if (page.id != object.id) { + page.addChildPage(object); + } + } else { + if (object.parentId != -2) { + Emulator.getLogging().logStart("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")"); } - return true; } + return true; }); this.catalogPages.putAll(pages); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java index d219baf4..d73e77a6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java @@ -9,6 +9,17 @@ import java.sql.SQLException; public class CatalogRootLayout extends CatalogPage { public CatalogRootLayout() { super(); + + this.id = -1; + this.parentId = -2; + this.rank = 0; + this.caption = "root"; + this.pageName = "root"; + this.iconColor = 0; + this.iconImage = 0; + this.orderNum = -10; + this.visible = true; + this.enabled = true; } public CatalogRootLayout(ResultSet set) throws SQLException { From 966737a5b8216e95e40078e78146889302a46836 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 21 Jul 2019 20:42:36 +0300 Subject: [PATCH 06/77] Fix changing username to your own username --- .../incoming/users/ChangeNameCheckUsernameEvent.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java index 285f1f97..a287e651 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ChangeNameCheckUsernameEvent.java @@ -19,12 +19,6 @@ public class ChangeNameCheckUsernameEvent extends MessageHandler { String name = this.packet.readString(); - if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername())) { - this.client.getHabbo().getHabboStats().allowNameChange = false; - this.client.sendResponse(new RoomUserNameChangedComposer(this.client.getHabbo())); - return; - } - int errorCode = ChangeNameCheckResultComposer.AVAILABLE; List suggestions = new ArrayList<>(4); @@ -32,7 +26,7 @@ public class ChangeNameCheckUsernameEvent extends MessageHandler { errorCode = ChangeNameCheckResultComposer.TOO_SHORT; } else if (name.length() > 15) { errorCode = ChangeNameCheckResultComposer.TOO_LONG; - } else if (HabboManager.getOfflineHabboInfo(name) != null || ConfirmChangeNameEvent.changingUsernames.contains(name.toLowerCase())) { + } else if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername()) || HabboManager.getOfflineHabboInfo(name) != null || ConfirmChangeNameEvent.changingUsernames.contains(name.toLowerCase())) { errorCode = ChangeNameCheckResultComposer.TAKEN_WITH_SUGGESTIONS; suggestions.add(name + Emulator.getRandom().nextInt(9999)); suggestions.add(name + Emulator.getRandom().nextInt(9999)); From 08551ecff7af02e934c0b5f498e2cad8cf084719 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Mon, 22 Jul 2019 11:47:32 +0100 Subject: [PATCH 07/77] FloorPlanValidation is now like Habbo. Doesn't allow different lengths from line 1. --- .../floorplaneditor/FloorPlanEditorSaveEvent.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java index e7212745..f1bdd0a5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java @@ -50,6 +50,21 @@ public class FloorPlanEditorSaveEvent extends MessageHandler { errors.add("${notification.floorplan_editor.error.title}"); } + boolean rowCountCorrect = true; + int rowCount = 0; + String[] splitMap = map.split(((char) 13) + ""); + for (String s : splitMap) { + if(rowCount > 0 && rowCount != s.length()) { + rowCountCorrect = false; + } + rowCount = s.length(); + } + + if (!rowCountCorrect && Emulator.getConfig().getBoolean("hotel.room.floorplan.check.enabled")) + { + errors.add("Invalid Rowcount"); + } + if (map.isEmpty() || map.replace("x", "").replace(((char) 13) + "", "").length() == 0) { errors.add("${notification.floorplan_editor.error.message.effective_height_is_0}"); From bb1e8842764fd4892730bb379c530fe5e8a8c309 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Mon, 22 Jul 2019 07:03:36 -0400 Subject: [PATCH 08/77] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b9d405d0..96ade2e7 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). ## Versions ## -![image](https://img.shields.io/badge/VERSION-2.0.0-success.svg?style=for-the-badge&logo=appveyor) -![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/VERSION-2.2.0-success.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor) Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases From a538fc260740a4bffa30923620b0b5695800a570 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Wed, 24 Jul 2019 12:12:53 +0100 Subject: [PATCH 09/77] Fixed commands in the console. --- src/main/java/com/eu/habbo/Emulator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 9cdd1324..cf4ae169 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -143,11 +143,11 @@ public final class Emulator { Emulator.getLogging().logStart("https://discord.gg/syuqgN"); Emulator.getLogging().logStart("Please report bugs on our git at Krews.org. Not on our discord!!"); System.out.println("Waiting for commands: "); - }, 3500); + }, 1500); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); - while (!isShuttingDown && isReady && reader.ready()) { + while (!isShuttingDown && isReady) { try { String line = reader.readLine(); From 806d747d3b70a79783e92804bff5a6cfb539b833 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 24 Jul 2019 15:59:20 +0300 Subject: [PATCH 10/77] Refactor floor plan editor saving --- src/main/java/com/eu/habbo/Emulator.java | 9 +- .../FloorPlanEditorSaveEvent.java | 90 +++++-------------- 2 files changed, 28 insertions(+), 71 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index cf4ae169..12b0a3d6 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -18,10 +18,7 @@ import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent; import com.eu.habbo.threading.ThreadPooling; import com.eu.habbo.util.imager.badges.BadgeImager; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; +import java.io.*; import java.security.MessageDigest; import java.sql.Timestamp; import java.text.SimpleDateFormat; @@ -157,7 +154,9 @@ public final class Emulator { } System.out.println("Waiting for command: "); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) { + Emulator.getLogging().logErrorLine(e); + } } } } catch (Exception e) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java index f1bdd0a5..58d4a8cc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java @@ -13,14 +13,11 @@ import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.*; public class FloorPlanEditorSaveEvent extends MessageHandler { public static int MAXIMUM_FLOORPLAN_WIDTH_LENGTH = 64; public static int MAXIMUM_FLOORPLAN_SIZE = 64 * 64; - public static final String VALID_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; @Override public void handle() throws Exception { @@ -35,81 +32,46 @@ public class FloorPlanEditorSaveEvent extends MessageHandler { return; if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { - List errors = new ArrayList<>(); + StringJoiner errors = new StringJoiner("
"); String map = this.packet.readString(); map = map.replace("X", "x"); - String checkMap = map.replace(((char) 13) + "", "").toUpperCase(); - for (char c : VALID_CHARACTERS.toCharArray()) - { - checkMap = checkMap.replace(c + "", ""); - } + String[] mapRows = map.split("\r"); - if (!checkMap.isEmpty() && Emulator.getConfig().getBoolean("hotel.room.floorplan.check.enabled")) - { - errors.add("${notification.floorplan_editor.error.title}"); - } + int firstRowSize = mapRows[0].length(); - boolean rowCountCorrect = true; - int rowCount = 0; - String[] splitMap = map.split(((char) 13) + ""); - for (String s : splitMap) { - if(rowCount > 0 && rowCount != s.length()) { - rowCountCorrect = false; + if (Emulator.getConfig().getBoolean("hotel.room.floorplan.check.enabled")) { + if (!map.matches("[a-zA-Z0-9\r]+")) errors.add("${notification.floorplan_editor.error.title}"); + + Arrays.stream(mapRows) + .filter(line -> line.length() != firstRowSize) + .findAny() + .ifPresent(s -> errors.add("(General): Line " + (Arrays.asList(mapRows).indexOf(s) + 1) + " is of different length than line 1")); + + if (map.isEmpty() || map.replace("x", "").replace("\r", "").isEmpty()) { + errors.add("${notification.floorplan_editor.error.message.effective_height_is_0}"); } - rowCount = s.length(); - } - if (!rowCountCorrect && Emulator.getConfig().getBoolean("hotel.room.floorplan.check.enabled")) - { - errors.add("Invalid Rowcount"); - } - - - if (map.isEmpty() || map.replace("x", "").replace(((char) 13) + "", "").length() == 0) { - errors.add("${notification.floorplan_editor.error.message.effective_height_is_0}"); - } - - int lengthX = -1; - int lengthY = -1; - - String[] data = map.split(((char) 13) + ""); - - if (errors.isEmpty()) { if (map.length() > 64 * 64) { errors.add("${notification.floorplan_editor.error.message.too_large_area}"); } - - lengthY = data.length; - if (data.length > 64) { - errors.add("${notification.floorplan_editor.error.message.too_large_height}"); - } else { - for (String s : data) { - if (lengthX == -1) { - lengthX = s.length(); - } - - if (s.length() != lengthX) { - break; - } - - if (s.length() > 64 || s.length() == 0) { - errors.add("${notification.floorplan_editor.error.message.too_large_width}"); - } - } - } + if (mapRows.length > 64) errors.add("${notification.floorplan_editor.error.message.too_large_height}"); + else if (Arrays.stream(mapRows).anyMatch(l -> l.length() > 64 || l.length() == 0)) errors.add("${notification.floorplan_editor.error.message.too_large_width}"); } int doorX = this.packet.readInt(); int doorY = this.packet.readInt(); - if (doorX < 0 || doorX > lengthX || doorY < 0 || doorY > lengthY || data[doorY].charAt(doorX) == 'x') { + if (doorX < 0 || doorX > firstRowSize || doorY < 0 || doorY >= mapRows.length) { errors.add("${notification.floorplan_editor.error.message.entry_tile_outside_map}"); } - int doorRotation = this.packet.readInt(); + if (doorY < mapRows.length && doorX < mapRows[doorY].length() && mapRows[doorY].charAt(doorX) == 'x') { + errors.add("${notification.floorplan_editor.error.message.entry_not_on_tile}"); + } + int doorRotation = this.packet.readInt(); if (doorRotation < 0 || doorRotation > 7) { errors.add("${notification.floorplan_editor.error.message.invalid_entry_tile_direction}"); } @@ -123,8 +85,8 @@ public class FloorPlanEditorSaveEvent extends MessageHandler { if (floorSize < -2 || floorSize > 1) { errors.add("${notification.floorplan_editor.error.message.invalid_floor_thickness}"); } - int wallHeight = -1; + int wallHeight = -1; if (this.packet.bytesAvailable() >= 4) wallHeight = this.packet.readInt(); @@ -132,12 +94,8 @@ public class FloorPlanEditorSaveEvent extends MessageHandler { errors.add("${notification.floorplan_editor.error.message.invalid_walls_fixed_height}"); } - if (!errors.isEmpty()) { - StringBuilder errorMessage = new StringBuilder(); - for (String s : errors) { - errorMessage.append(s).append("
"); - } - this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errorMessage.toString())); + if (errors.length() > 0) { + this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errors.toString())); return; } From bfda48c22e242d94736bccb4053d30d38b2f9669 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 24 Jul 2019 19:34:31 +0300 Subject: [PATCH 11/77] Do not flood when triggering a wired --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index d8748aca..ba34a047 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2989,8 +2989,6 @@ public class Room implements Comparable, ISerialize, Runnable { return; } - habbo.getHabboStats().chatCounter += 2; - if (habbo.getHabboInfo().getCurrentRoom() != this) return; @@ -3002,6 +3000,7 @@ public class Room implements Comparable, ISerialize, Runnable { } habbo.getHabboStats().lastChat = millis; if (roomChatMessage != null && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) { + habbo.getHabboStats().chatCounter += 2; Emulator.getThreading().run(new YouAreAPirate(habbo, this)); return; } @@ -3060,6 +3059,8 @@ public class Room implements Comparable, ISerialize, Runnable { } } + habbo.getHabboStats().chatCounter += 2; + ServerMessage prefixMessage = roomChatMessage.getHabbo().getHabboInfo().getRank().hasPrefix() ? new RoomUserNameChangedComposer(habbo, true).compose() : null; ServerMessage clearPrefixMessage = prefixMessage != null ? new RoomUserNameChangedComposer(habbo).compose() : null; From 31711bd2f91f116c34dcc709ccce10bfdde95452 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 30 Jul 2019 13:45:39 +0300 Subject: [PATCH 12/77] Minor fixes --- sqlupdates/2_1_1_TO_2_2_0-RC-1.sql | 10 ++ .../com/eu/habbo/habbohotel/games/Game.java | 12 +- .../habbo/habbohotel/items/ItemManager.java | 9 + .../InteractionWiredHighscore.java | 73 +++----- .../com/eu/habbo/habbohotel/rooms/Room.java | 66 ------- .../habbohotel/wired/WiredHighscoreData.java | 16 -- .../WiredHighscoreClearType.java | 2 +- .../highscores/WiredHighscoreDataEntry.java | 51 ++++++ .../highscores/WiredHighscoreManager.java | 167 ++++++++++++++++++ .../WiredHighscoreMidnightUpdater.java | 33 ++++ .../wired/highscores/WiredHighscoreRow.java | 32 ++++ .../WiredHighscoreScoreType.java | 2 +- 12 files changed, 337 insertions(+), 136 deletions(-) delete mode 100644 src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java rename src/main/java/com/eu/habbo/habbohotel/wired/{ => highscores}/WiredHighscoreClearType.java (80%) create mode 100644 src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreRow.java rename src/main/java/com/eu/habbo/habbohotel/wired/{ => highscores}/WiredHighscoreScoreType.java (79%) diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql index 5ca7ca4a..7d4b4451 100644 --- a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql +++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql @@ -10,3 +10,13 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.i INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.ignore.hotelview', '1'); INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.type', '4'); INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.name', 'shell'); + +CREATE TABLE `items_highscore_data` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `item_id` int(11) NOT NULL, + `user_ids` varchar(500) NOT NULL, + `score` int(11) NOT NULL, + `is_win` tinyint(1) NULL DEFAULT 0, + `timestamp` int(11) NOT NULL, + PRIMARY KEY (`id`) +); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index c52d5115..e2b2a2ae 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -5,13 +5,13 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreDataEntry; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.games.GameHabboJoinEvent; import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent; @@ -21,6 +21,7 @@ import com.eu.habbo.threading.runnables.SaveScoreForTeam; import gnu.trove.map.hash.THashMap; import java.util.Map; +import java.util.stream.Collectors; public abstract class Game implements Runnable { @@ -164,16 +165,25 @@ public abstract class Game implements Runnable { } } + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { + Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), winningTeam.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), winningTeam.getTotalScore(), true, Emulator.getIntUnixTimestamp())); + } + for (GameTeam team : this.teams.values()) { if (team == winningTeam) continue; for (GamePlayer player : winningTeam.getMembers()) { WiredHandler.handleCustomTrigger(WiredTriggerTeamLoses.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this}); } + + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { + Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), winningTeam.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), winningTeam.getTotalScore(), false, Emulator.getIntUnixTimestamp())); + } } } for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { + ((InteractionWiredHighscore) item).reloadData(); this.room.updateItem(item); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index b475fb1e..ce313579 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -43,6 +43,7 @@ import com.eu.habbo.habbohotel.items.interactions.wired.effects.*; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; @@ -69,6 +70,7 @@ public class ItemManager { private final THashSet interactionsList; private final THashMap soundTracks; private final YoutubeManager youtubeManager; + private final WiredHighscoreManager highscoreManager; private final TreeMap newuserGifts; public ItemManager() { @@ -77,6 +79,7 @@ public class ItemManager { this.interactionsList = new THashSet<>(); this.soundTracks = new THashMap<>(); this.youtubeManager = new YoutubeManager(); + this.highscoreManager = new WiredHighscoreManager(); this.newuserGifts = new TreeMap<>(); } @@ -90,6 +93,7 @@ public class ItemManager { this.loadCrackable(); this.loadSoundTracks(); this.youtubeManager.load(); + this.highscoreManager.load(); this.loadNewUserGifts(); Emulator.getLogging().logStart("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); @@ -784,8 +788,13 @@ public class ItemManager { return this.youtubeManager; } + public WiredHighscoreManager getHighscoreManager() { + return highscoreManager; + } + public void dispose() { this.items.clear(); + this.highscoreManager.dispose(); Emulator.getLogging().logShutdownLine("Item Manager -> Disposed!"); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java index 9da022e9..054ce7d8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java @@ -3,24 +3,23 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreRow; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.habbohotel.wired.WiredHighscoreClearType; -import com.eu.habbo.habbohotel.wired.WiredHighscoreData; -import com.eu.habbo.habbohotel.wired.WiredHighscoreScoreType; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreClearType; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreScoreType; import com.eu.habbo.messages.ServerMessage; -import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; public class InteractionWiredHighscore extends HabboItem { public WiredHighscoreScoreType scoreType; public WiredHighscoreClearType clearType; - private THashSet data; - private int lastUpdate; + private List data; public InteractionWiredHighscore(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -37,13 +36,7 @@ public class InteractionWiredHighscore extends HabboItem { Emulator.getLogging().logErrorLine(e); } - if (this.getRoomId() > 0) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - - if (room != null) { - this.reloadData(room); - } - } + this.reloadData(); } public InteractionWiredHighscore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { @@ -60,6 +53,8 @@ public class InteractionWiredHighscore extends HabboItem { } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } + + this.reloadData(); } @Override @@ -86,7 +81,6 @@ public class InteractionWiredHighscore extends HabboItem { try { int state = Integer.valueOf(this.getExtradata()); this.setExtradata(Math.abs(state - 1) + ""); - this.reloadData(room); room.updateItem(this); } catch (Exception e) { Emulator.getLogging().logErrorLine(e); @@ -98,43 +92,22 @@ public class InteractionWiredHighscore extends HabboItem { public void serializeExtradata(ServerMessage serverMessage) { serverMessage.appendInt(6); serverMessage.appendString(this.getExtradata()); - serverMessage.appendInt(this.scoreType.type); //score type - serverMessage.appendInt(this.clearType.type); //clear type + serverMessage.appendInt(this.scoreType.type); + serverMessage.appendInt(this.clearType.type); - if (this.getRoomId() == 0) { - serverMessage.appendInt(0); - } else { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + if (this.data != null) { + serverMessage.appendInt(this.data.size()); - if (room == null) { - serverMessage.appendInt(0); - } else { - if (Emulator.getIntUnixTimestamp() - this.lastUpdate > 60 * 60) { - this.reloadData(room); - } + for (WiredHighscoreRow row : this.data) { + serverMessage.appendInt(row.getValue()); - if (this.data != null) { - serverMessage.appendInt(this.data.size()); //count - - for (WiredHighscoreData dataSet : this.data) { - if (this.scoreType == WiredHighscoreScoreType.PERTEAM) { - serverMessage.appendInt(dataSet.teamScore); //Team score - } else if (dataSet.usernames.length == 1) { - serverMessage.appendInt(dataSet.score); - } else { - serverMessage.appendInt(dataSet.totalScore); - } - - serverMessage.appendInt(dataSet.usernames.length); //Users count - - for (String codeDragon : dataSet.usernames) { - serverMessage.appendString(codeDragon); - } - } - } else { - serverMessage.appendInt(0); + serverMessage.appendInt(row.getUsers().size()); + for (String username : row.getUsers()) { + serverMessage.appendString(username); } } + } else { + serverMessage.appendInt(0); } super.serializeExtradata(serverMessage); @@ -142,7 +115,7 @@ public class InteractionWiredHighscore extends HabboItem { @Override public void onPlace(Room room) { - this.reloadData(room); + this.reloadData(); super.onPlace(room); } @@ -151,11 +124,9 @@ public class InteractionWiredHighscore extends HabboItem { if (this.data != null) { this.data.clear(); } - this.lastUpdate = 0; } - private void reloadData(Room room) { - this.data = room.getWiredHighscoreData(this.scoreType, this.clearType); - this.lastUpdate = Emulator.getIntUnixTimestamp(); + public void reloadData() { + this.data = Emulator.getGameEnvironment().getItemManager().getHighscoreManager().getHighscoreRowsForItem(this.getId(), this.clearType, this.scoreType); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index ba34a047..1dd10859 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -135,7 +135,6 @@ public class Room implements Comparable, ISerialize, Runnable { private final TIntObjectMap moodlightData; private final THashSet wordFilterWords; private final TIntObjectMap roomItems; - private final THashMap>> wiredHighscoreData; private final Object loadLock = new Object(); //Use appropriately. Could potentially cause memory leaks when used incorrectly. public volatile boolean preventUnloading = false; @@ -289,7 +288,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.activeTrades = new THashSet<>(0); this.rights = new TIntArrayList(); - this.wiredHighscoreData = new THashMap<>(); this.userVotes = new ArrayList<>(); } @@ -4211,70 +4209,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - public THashSet getWiredHighscoreData(WiredHighscoreScoreType scoreType, WiredHighscoreClearType clearType) { - if (!this.wiredHighscoreData.containsKey(scoreType)) { - this.loadWiredHighscoreData(scoreType, clearType); - } - - return this.wiredHighscoreData.get(scoreType).get(clearType); - } - - public void loadWiredHighscoreData(WiredHighscoreScoreType scoreType, WiredHighscoreClearType clearType) { - this.wiredHighscoreData.clear(); - THashSet wiredData = new THashSet<>(); - - try { - String query = "SELECT " + - "SUM(score + team_score) as total_score, " + - "COUNT(*) as wins, " + - "users.username, " + - "room_game_scores.*, " + - "GROUP_CONCAT(users.username) as usernames " + - "FROM room_game_scores " + - "INNER JOIN users ON room_game_scores.user_id = users.id " + - "WHERE room_id = ? AND game_start_timestamp >= ? "; - - int timestamp = 0; - if (clearType != WiredHighscoreClearType.ALLTIME) { - if (clearType == WiredHighscoreClearType.MONTHLY) { - timestamp = Emulator.getIntUnixTimestamp() - (31 * 24 * 60 * 60); - } else if (clearType == WiredHighscoreClearType.WEEKLY) { - timestamp = Emulator.getIntUnixTimestamp() - (7 * 24 * 60 * 60); - } else if (clearType == WiredHighscoreClearType.DAILY) { - timestamp = Emulator.getIntUnixTimestamp() - (24 * 60 * 60); - } - } - - - if (scoreType == WiredHighscoreScoreType.CLASSIC) { - query += "GROUP BY game_start_timestamp, user_id, team_id ORDER BY total_score DESC"; - } else if (scoreType == WiredHighscoreScoreType.MOSTWIN) { - query += "GROUP BY game_start_timestamp, game_name, team_id ORDER BY wins DESC, total_score ASC"; - } else if (scoreType == WiredHighscoreScoreType.PERTEAM) { - query += "GROUP BY game_start_timestamp, team_id ORDER BY team_score DESC"; - } - - query += " LIMIT " + Emulator.getConfig().getValue("wired.highscores.displaycount"); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) { - statement.setInt(1, this.id); - statement.setInt(2, timestamp); - - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - wiredData.add(new WiredHighscoreData(set.getString("usernames").split(","), set.getInt("score"), set.getInt("team_score"), set.getInt("total_score"))); - } - } - } - } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); - } - - THashMap> dataMap = new THashMap<>(); - dataMap.put(clearType, wiredData); - this.wiredHighscoreData.put(scoreType, dataMap); - } - public void handleWordQuiz(Habbo habbo, String answer) { synchronized (this.userVotes) { if (!this.wordQuiz.isEmpty() && !this.hasVotedInWordQuiz(habbo)) { diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java deleted file mode 100644 index 07221e5b..00000000 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.eu.habbo.habbohotel.wired; - -public class WiredHighscoreData { - public String[] usernames; - public int score; - public int teamScore; - public int totalScore; - - public WiredHighscoreData(String[] usernames, int score, int teamScore, int totalScore) { - this.usernames = usernames; - - this.score = score; - this.teamScore = teamScore; - this.totalScore = totalScore; - } -} diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java similarity index 80% rename from src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java rename to src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java index aead67bd..602daa09 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.wired; +package com.eu.habbo.habbohotel.wired.highscores; public enum WiredHighscoreClearType { ALLTIME(0), diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java new file mode 100644 index 00000000..e063d05e --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java @@ -0,0 +1,51 @@ +package com.eu.habbo.habbohotel.wired.highscores; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class WiredHighscoreDataEntry { + private final int itemId; + private final List userIds; + private final int score; + private final boolean isWin; + private final int timestamp; + + public WiredHighscoreDataEntry(int itemId, List userIds, int score, boolean isWin, int timestamp) { + this.itemId = itemId; + this.userIds = userIds; + this.score = score; + this.isWin = isWin; + this.timestamp = timestamp; + } + + public WiredHighscoreDataEntry(ResultSet set) throws SQLException { + this.itemId = set.getInt("item_id"); + this.userIds = Arrays.stream(set.getString("user_ids").split(",")).map(Integer::valueOf).collect(Collectors.toList()); + this.score = set.getInt("score"); + this.isWin = set.getInt("is_win") == 1; + this.timestamp = set.getInt("timestamp"); + } + + public int getItemId() { + return itemId; + } + + public List getUserIds() { + return userIds; + } + + public int getScore() { + return score; + } + + public boolean isWin() { + return isWin; + } + + public int getTimestamp() { + return timestamp; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java new file mode 100644 index 00000000..aa5935ef --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -0,0 +1,167 @@ +package com.eu.habbo.habbohotel.wired.highscores; + +import com.eu.habbo.Emulator; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.*; +import java.time.temporal.TemporalAdjusters; +import java.time.temporal.WeekFields; +import java.util.*; +import java.util.concurrent.ScheduledFuture; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class WiredHighscoreManager { + private final HashMap> data = new HashMap<>(); + + private final static DayOfWeek firstDayOfWeek = WeekFields.of(new Locale(System.getProperty("user.language"), System.getProperty("user.country"))).getFirstDayOfWeek(); + private final static DayOfWeek lastDayOfWeek = DayOfWeek.of(((firstDayOfWeek.getValue() + 5) % DayOfWeek.values().length) + 1); + private final static ZoneId zoneId = ZoneId.systemDefault(); + + public static ScheduledFuture midnightUpdater = null; + + public void load() { + long millis = System.currentTimeMillis(); + + this.data.clear(); + this.loadHighscoreData(); + + if (midnightUpdater != null) { + midnightUpdater.cancel(true); + } + midnightUpdater = Emulator.getThreading().run(new WiredHighscoreMidnightUpdater(), WiredHighscoreMidnightUpdater.getNextUpdaterRun()); + + Emulator.getLogging().logStart("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); + } + + public void dispose() { + if (midnightUpdater != null) { + midnightUpdater.cancel(true); + } + + this.data.clear(); + } + + private void loadHighscoreData() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_highscore_data")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + WiredHighscoreDataEntry entry = new WiredHighscoreDataEntry(set); + + if (!this.data.containsKey(entry.getItemId())) { + this.data.put(entry.getItemId(), new ArrayList<>()); + } + + this.data.get(entry.getItemId()).add(entry); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public void addHighscoreData(WiredHighscoreDataEntry entry) { + if (!this.data.containsKey(entry.getItemId())) { + this.data.put(entry.getItemId(), new ArrayList<>()); + } + + this.data.get(entry.getItemId()).add(entry); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `items_highscore_data` (`item_id`, `user_ids`, `score`, `is_win`, `timestamp`) VALUES (?, ?, ?, ?, ?)")) { + statement.setInt(1, entry.getItemId()); + statement.setString(2, String.join(",", entry.getUserIds().stream().map(Object::toString).collect(Collectors.toList()))); + statement.setInt(3, entry.getScore()); + statement.setInt(4, entry.isWin() ? 1 : 0); + statement.setInt(5, entry.getTimestamp()); + + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public List getHighscoreRowsForItem(int itemId, WiredHighscoreClearType clearType, WiredHighscoreScoreType scoreType) { + if (!this.data.containsKey(itemId)) return null; + + Stream highscores = this.data.get(itemId).stream() + .filter(entry -> this.timeMatchesEntry(entry, clearType) && (scoreType != WiredHighscoreScoreType.MOSTWIN || entry.isWin())) + .map(entry -> new WiredHighscoreRow( + entry.getUserIds().stream() + .map(id -> Emulator.getGameEnvironment().getHabboManager().getHabboInfo(id).getUsername()) + .collect(Collectors.toList()), + entry.getScore() + )); + + if (scoreType == WiredHighscoreScoreType.CLASSIC) { + return highscores.sorted(WiredHighscoreRow::compareTo).collect(Collectors.toList()); + } + + if (scoreType == WiredHighscoreScoreType.PERTEAM) { + return highscores + .collect(Collectors.groupingBy(h -> h.getUsers().hashCode())) + .entrySet() + .stream() + .map(e -> e.getValue().stream() + .sorted(WiredHighscoreRow::compareTo) + .collect(Collectors.toList()) + .get(0) + ) + .sorted(WiredHighscoreRow::compareTo) + .collect(Collectors.toList()); + } + + if (scoreType == WiredHighscoreScoreType.MOSTWIN) { + return highscores + .collect(Collectors.groupingBy(h -> h.getUsers().hashCode())) + .entrySet() + .stream() + .map(e -> new WiredHighscoreRow(e.getValue().get(0).getUsers(), e.getValue().size())) + .sorted(WiredHighscoreRow::compareTo) + .collect(Collectors.toList()); + } + + return null; + } + + private boolean timeMatchesEntry(WiredHighscoreDataEntry entry, WiredHighscoreClearType timeType) { + switch (timeType) { + case DAILY: + return entry.getTimestamp() > this.getTodayStartTimestamp() && entry.getTimestamp() < this.getTodayEndTimestamp(); + case WEEKLY: + return entry.getTimestamp() > this.getWeekStartTimestamp() && entry.getTimestamp() < this.getWeekEndTimestamp(); + case MONTHLY: + return entry.getTimestamp() > this.getMonthStartTimestamp() && entry.getTimestamp() < this.getMonthEndTimestamp(); + case ALLTIME: + return true; + } + + return false; + } + + private long getTodayStartTimestamp() { + return LocalDateTime.now().with(LocalTime.MIDNIGHT).atZone(zoneId).toEpochSecond(); + } + + private long getTodayEndTimestamp() { + return LocalDateTime.now().with(LocalTime.MIDNIGHT).plusDays(1).plusSeconds(-1).atZone(zoneId).toEpochSecond(); + } + + private long getWeekStartTimestamp() { + return LocalDateTime.now().with(LocalTime.MIDNIGHT).with(TemporalAdjusters.previousOrSame(firstDayOfWeek)).atZone(zoneId).toEpochSecond(); + } + + private long getWeekEndTimestamp() { + return LocalDateTime.now().with(LocalTime.MIDNIGHT).plusDays(1).plusSeconds(-1).with(TemporalAdjusters.nextOrSame(lastDayOfWeek)).atZone(zoneId).toEpochSecond(); + } + + private long getMonthStartTimestamp() { + return LocalDateTime.now().with(LocalTime.MIDNIGHT).with(TemporalAdjusters.firstDayOfMonth()).atZone(zoneId).toEpochSecond(); + } + + private long getMonthEndTimestamp() { + return LocalDateTime.now().with(LocalTime.MIDNIGHT).plusDays(1).plusSeconds(-1).with(TemporalAdjusters.lastDayOfMonth()).atZone(zoneId).toEpochSecond(); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java new file mode 100644 index 00000000..4a24f569 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java @@ -0,0 +1,33 @@ +package com.eu.habbo.habbohotel.wired.highscores; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import gnu.trove.set.hash.THashSet; + +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.util.List; + +public class WiredHighscoreMidnightUpdater implements Runnable { + @Override + public void run() { + List rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRooms(); + + for (Room room : rooms) { + THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class); + for (HabboItem item : items) { + ((InteractionWiredHighscore) item).reloadData(); + room.updateItem(item); + } + } + + WiredHighscoreManager.midnightUpdater = Emulator.getThreading().run(new WiredHighscoreMidnightUpdater(), getNextUpdaterRun()); + } + + public static int getNextUpdaterRun() { + return Math.toIntExact(LocalDateTime.now().with(LocalTime.MIDNIGHT).plusDays(1).plusSeconds(-1).atZone(ZoneId.systemDefault()).toEpochSecond() - Emulator.getIntUnixTimestamp()) + 5; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreRow.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreRow.java new file mode 100644 index 00000000..1282a1bc --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreRow.java @@ -0,0 +1,32 @@ +package com.eu.habbo.habbohotel.wired.highscores; + +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +public class WiredHighscoreRow implements Comparable { + public static final Comparator COMPARATOR = Comparator.comparing(WiredHighscoreRow::getValue).reversed(); + + private final List users; + private final int value; + + public WiredHighscoreRow(List users, int value) { + Collections.sort(users); + + this.users = users; + this.value = value; + } + + public List getUsers() { + return users; + } + + public int getValue() { + return value; + } + + @Override + public int compareTo(WiredHighscoreRow otherRow) { + return COMPARATOR.compare(this, otherRow); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java similarity index 79% rename from src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java rename to src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java index cc2e50a0..d70e07ed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.wired; +package com.eu.habbo.habbohotel.wired.highscores; public enum WiredHighscoreScoreType { PERTEAM(0), From 8870145948683198118fd7a5dfc07d451e3b3f86 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 30 Jul 2019 13:52:29 +0300 Subject: [PATCH 13/77] Fix NullPointerExceptions --- .../games/InteractionGameTimer.java | 20 ++++++++++--------- .../rooms/users/RoomUserWalkEvent.java | 2 +- .../inventory/UserEffectsListComposer.java | 16 ++++++++------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index da2a6c73..94e01be1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -16,6 +16,7 @@ import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Arrays; public class InteractionGameTimer extends HabboItem implements Runnable { private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 }; @@ -77,16 +78,17 @@ public class InteractionGameTimer extends HabboItem implements Runnable { parseCustomParams(item); } - public void parseCustomParams(Item baseItem) { + private void parseCustomParams(Item baseItem) { try { - String[] intervalSteps = baseItem.getCustomParams().split(","); - int[] finalSteps = new int[intervalSteps.length]; - for (int i = 0; i < intervalSteps.length; i++) { - finalSteps[i] = Integer.parseInt(intervalSteps[i]); - } - TIMER_INTERVAL_STEPS = finalSteps; - } - catch (Exception e) { + TIMER_INTERVAL_STEPS = Arrays.stream(baseItem.getCustomParams().split(",")) + .mapToInt(s -> { + try { + return Integer.parseInt(s); + } catch (NumberFormatException e) { + return 0; + } + }).toArray(); + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index 08966a11..c8eb815d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -80,7 +80,7 @@ public class RoomUserWalkEvent extends MessageHandler { if (!event.isCancelled()) { if (!event.idle) { - roomUnit.getRoom().unIdle(habbo); + if (roomUnit.getRoom() != null) roomUnit.getRoom().unIdle(habbo); roomUnit.resetIdleTimer(); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java index ddf8bd80..9fa470af 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java @@ -19,11 +19,12 @@ public class UserEffectsListComposer extends MessageComposer { public ServerMessage compose() { this.response.init(Outgoing.UserEffectsListComposer); - synchronized (this.habbo.getInventory().getEffectsComponent().effects) { - this.response.appendInt(this.habbo.getInventory().getEffectsComponent().effects.size()); - this.habbo.getInventory().getEffectsComponent().effects.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(EffectsComponent.HabboEffect effect) { + if (this.habbo == null || this.habbo.getInventory() == null || this.habbo.getInventory().getEffectsComponent() == null || this.habbo.getInventory().getEffectsComponent().effects == null) { + this.response.appendInt(0); + } else { + synchronized (this.habbo.getInventory().getEffectsComponent().effects) { + this.response.appendInt(this.habbo.getInventory().getEffectsComponent().effects.size()); + this.habbo.getInventory().getEffectsComponent().effects.forEachValue(effect -> { UserEffectsListComposer.this.response.appendInt(effect.effect); UserEffectsListComposer.this.response.appendInt(0); UserEffectsListComposer.this.response.appendInt(effect.duration); @@ -31,9 +32,10 @@ public class UserEffectsListComposer extends MessageComposer { UserEffectsListComposer.this.response.appendInt(effect.activationTimestamp >= 0 ? Emulator.getIntUnixTimestamp() - effect.activationTimestamp : -1); UserEffectsListComposer.this.response.appendBoolean(effect.isActivated()); return true; - } - }); + }); + } } + return this.response; } } From a0d5e92f1a522083338ca53733923ebe20455dd6 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 30 Jul 2019 13:56:54 +0300 Subject: [PATCH 14/77] Minor updates --- .../rooms/users/RoomUserWalkEvent.java | 59 ++++++++----------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index c8eb815d..815fe3e0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -11,32 +11,29 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.plugin.events.users.UserIdleEvent; -import gnu.trove.set.hash.THashSet; public class RoomUserWalkEvent extends MessageHandler { @Override - public void handle() throws Exception - { - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) - { - int x = this.packet.readInt(); ///< Position X - int y = this.packet.readInt(); /// Date: Tue, 30 Jul 2019 14:03:50 +0300 Subject: [PATCH 15/77] Fix NullPointerExceptions --- .../java/com/eu/habbo/habbohotel/games/GamePlayer.java | 8 +++----- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 4 +++- src/main/java/com/eu/habbo/habbohotel/users/Habbo.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java index 8aabcf90..edc62fb4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java @@ -27,11 +27,9 @@ public class GamePlayer { 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().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { - 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}); - } + if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { + 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}); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 1dd10859..61c409df 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2136,9 +2136,11 @@ public class Room implements Comparable, ISerialize, Runnable { } public Game getGame(Class gameType) { + if (gameType == null) return null; + synchronized (this.games) { for (Game game : this.games) { - if (gameType.isInstance(game)) { + if (game != null && gameType.isInstance(game)) { return game; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index 84396d67..0876aec3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -109,7 +109,7 @@ public class Habbo implements Runnable { 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()); } From e2c56e6efe911795a512be547cc2770c2d9db435 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 30 Jul 2019 17:51:27 +0300 Subject: [PATCH 16/77] Dispose games properly upon room disposal --- .../commands/ReloadRoomCommand.java | 21 ++++++++----------- .../com/eu/habbo/habbohotel/games/Game.java | 8 +++++++ .../eu/habbo/habbohotel/games/GameTeam.java | 13 ++++++++++++ .../com/eu/habbo/habbohotel/rooms/Room.java | 3 ++- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java index de2768e1..1ccd20d0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java @@ -17,18 +17,15 @@ public class ReloadRoomCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { - Emulator.getThreading().run(new Runnable() { - @Override - public void run() { - Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) { - Collection habbos = new ArrayList<>(room.getHabbos()); - Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); - room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); - ServerMessage message = new ForwardToRoomComposer(room.getId()).compose(); - for (Habbo habbo : habbos) { - habbo.getClient().sendResponse(message); - } + Emulator.getThreading().run(() -> { + Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); + if (room != null) { + Collection habbos = new ArrayList<>(room.getHabbos()); + Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); + room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); + ServerMessage message = new ForwardToRoomComposer(room.getId()).compose(); + for (Habbo habbo : habbos) { + habbo.getClient().sendResponse(message); } } }, 100); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index e2b2a2ae..1336c272 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -223,6 +223,14 @@ public abstract class Game implements Runnable { } } + public void dispose() { + for (GameTeam team : this.teams.values()) { + team.clearMembers(); + } + this.teams.clear(); + + this.stop(); + } private void saveScores() { if (this.room == null) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java index 38748c8e..67fa54e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java @@ -1,6 +1,9 @@ package com.eu.habbo.habbohotel.games; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.plugin.Event; +import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent; import gnu.trove.set.hash.THashSet; public class GameTeam { @@ -65,6 +68,16 @@ public class GameTeam { } } + public void clearMembers() { + for (GamePlayer player : this.members) { + player.getHabbo().getHabboInfo().getGamePlayer().reset(); + player.getHabbo().getHabboInfo().setCurrentGame(null); + player.getHabbo().getHabboInfo().setGamePlayer(null); + } + + this.members.clear(); + } + public THashSet getMembers() { return this.members; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 61c409df..ffd420a6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -853,7 +853,7 @@ public class Room implements Comparable, ISerialize, Runnable { } for (Game game : this.games) { - game.stop(); + game.dispose(); } this.games.clear(); @@ -2130,6 +2130,7 @@ public class Room implements Comparable, ISerialize, Runnable { public boolean deleteGame(Game game) { game.stop(); + game.dispose(); synchronized (this.games) { return this.games.remove(game); } From 222bdb5b1cf5ea3103a2e2a2f472610b46ab5535 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 30 Jul 2019 22:05:29 +0300 Subject: [PATCH 17/77] Minor updates --- .../java/com/eu/habbo/habbohotel/games/Game.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index 1336c272..359792d8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -165,19 +165,23 @@ public abstract class Game implements Runnable { } } - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { - Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), winningTeam.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), winningTeam.getTotalScore(), true, Emulator.getIntUnixTimestamp())); + if (winningTeam.getMembers().size() > 0) { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { + Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), winningTeam.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), winningTeam.getTotalScore(), true, Emulator.getIntUnixTimestamp())); + } } for (GameTeam team : this.teams.values()) { if (team == winningTeam) continue; - for (GamePlayer player : winningTeam.getMembers()) { + for (GamePlayer player : team.getMembers()) { WiredHandler.handleCustomTrigger(WiredTriggerTeamLoses.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this}); } - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { - Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), winningTeam.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), winningTeam.getTotalScore(), false, Emulator.getIntUnixTimestamp())); + if (team.getMembers().size() > 0) { + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) { + Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), team.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), team.getTotalScore(), false, Emulator.getIntUnixTimestamp())); + } } } } From 67abfddb11ca59814b7153444d8cd47587442561 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 30 Jul 2019 22:46:33 +0300 Subject: [PATCH 18/77] Fix NullPointerException --- .../wired/highscores/WiredHighscoreMidnightUpdater.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java index 4a24f569..7b60b22c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java @@ -17,6 +17,8 @@ public class WiredHighscoreMidnightUpdater implements Runnable { List rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRooms(); for (Room room : rooms) { + if (room == null || room.getRoomSpecialTypes() == null) continue; + THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class); for (HabboItem item : items) { ((InteractionWiredHighscore) item).reloadData(); From fdb367966bc287f44f1c5b4235839f6b8f52ad58 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Wed, 31 Jul 2019 12:59:58 +0100 Subject: [PATCH 19/77] Calendar is now fixed. Credits to ItsGiuseppe. --- .../catalog/CalendarRewardObject.java | 32 +++++++++++-------- .../habbohotel/catalog/CatalogManager.java | 17 +++++----- .../AdventCalendarForceOpenEvent.java | 3 ++ .../calendar/AdventCalendarOpenDayEvent.java | 2 +- .../calendar/AdventCalendarDataComposer.java | 25 ++++++--------- .../AdventCalendarProductComposer.java | 5 +-- 6 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java index 6940f759..f2b135b5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java @@ -1,30 +1,32 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; +import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import java.sql.ResultSet; import java.sql.SQLException; public class CalendarRewardObject { private final int id; - private final String name; private final String customImage; private final int credits; private final int points; private final int pointsType; private final String badge; - private final int catalogItemId; + private final int itemId; public CalendarRewardObject(ResultSet set) throws SQLException { this.id = set.getInt("id"); - this.name = set.getString("name"); this.customImage = set.getString("custom_image"); this.credits = set.getInt("credits"); this.points = set.getInt("points"); this.pointsType = set.getInt("points_type"); this.badge = set.getString("badge"); - this.catalogItemId = set.getInt("catalog_item_id"); + this.itemId = set.getInt("item_id"); } public void give(Habbo habbo) { @@ -40,11 +42,19 @@ public class CalendarRewardObject { habbo.addBadge(this.badge); } - if (this.catalogItemId > 0) { - CatalogItem item = this.getCatalogItem(); + if (this.itemId > 0) { + Item item = getItem(); if (item != null) { - Emulator.getGameEnvironment().getCatalogManager().purchaseItem(null, item, habbo, 1, "", true); + HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem( + habbo.getHabboInfo().getId(), + item, + 0, + 0, + ""); + habbo.getInventory().getItemsComponent().addItem(habboItem); + habbo.getClient().sendResponse(new AddHabboItemComposer(habboItem)); + habbo.getClient().sendResponse(new InventoryRefreshComposer()); } } } @@ -53,10 +63,6 @@ public class CalendarRewardObject { return this.id; } - public String getName() { - return this.name; - } - public String getCustomImage() { return this.customImage; } @@ -77,7 +83,7 @@ public class CalendarRewardObject { return this.badge; } - public CatalogItem getCatalogItem() { - return Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(this.catalogItemId); + public Item getItem() { + return Emulator.getGameEnvironment().getItemManager().getItem(this.itemId); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 5e1e81c1..f5dc975e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -31,6 +31,7 @@ import com.eu.habbo.plugin.events.emulator.EmulatorLoadCatalogManagerEvent; import com.eu.habbo.plugin.events.users.catalog.UserCatalogFurnitureBoughtEvent; import com.eu.habbo.plugin.events.users.catalog.UserCatalogItemPurchasedEvent; import gnu.trove.TCollections; +import gnu.trove.iterator.TIntIterator; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; @@ -1119,15 +1120,15 @@ public class CatalogManager { return offers; } - public void claimCalendarReward(Habbo habbo, int day) { + public void claimCalendarReward(Habbo habbo, int day, boolean force) { if (!habbo.getHabboStats().calendarRewardsClaimed.contains(day)) { - habbo.getHabboStats().calendarRewardsClaimed.add(day); - CalendarRewardObject object = this.calendarRewards.get(day); - - if (object != null) { - object.give(habbo); - habbo.getClient().sendResponse(new InventoryRefreshComposer()); + CalendarRewardObject object = this.calendarRewards.get((day+1)); + int actualDay = (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400); + int diff = (actualDay - day); + if (((diff <= 2 && diff >= 0) || force) && object != null) { + habbo.getHabboStats().calendarRewardsClaimed.add(day); habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object)); + object.give(habbo); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, reward_id, timestamp) VALUES (?, ?, ?)")) { statement.setInt(1, habbo.getHabboInfo().getId()); @@ -1138,8 +1139,6 @@ public class CatalogManager { Emulator.getLogging().logSQLException(e); } } - - } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java index 99f87ad0..1ab77c2c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java @@ -1,5 +1,6 @@ package com.eu.habbo.messages.incoming.events.calendar; +import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; public class AdventCalendarForceOpenEvent extends MessageHandler { @@ -7,5 +8,7 @@ public class AdventCalendarForceOpenEvent extends MessageHandler { public void handle() throws Exception { String campaign = this.packet.readString(); int day = this.packet.readInt(); + + Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, true); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java index 51cbd07a..9c68cfd0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java @@ -9,6 +9,6 @@ public class AdventCalendarOpenDayEvent extends MessageHandler { String campaign = this.packet.readString(); int day = this.packet.readInt(); - Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day); + Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, false); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java index 6ac6c009..d171c3b2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java @@ -28,33 +28,28 @@ public class AdventCalendarDataComposer extends MessageComposer { this.response.appendString(""); this.response.appendInt(this.currentDay); this.response.appendInt(this.totalDays); - this.response.appendInt(this.unlocked.size()); TIntArrayList expired = new TIntArrayList(); for (int i = 0; i < this.totalDays; i++) { expired.add(i); - expired.remove(this.currentDay); } + expired.remove(this.currentDay); + if(this.currentDay > 1) expired.remove(this.currentDay - 2); + if(this.currentDay > 0) expired.remove(this.currentDay - 1); - this.unlocked.forEach(new TIntProcedure() { - @Override - public boolean execute(int value) { - AdventCalendarDataComposer.this.response.appendInt(value); - expired.remove(value); - return true; - } + this.unlocked.forEach(value -> { + AdventCalendarDataComposer.this.response.appendInt(value); + expired.remove(value); + return true; }); if (this.lockExpired) { this.response.appendInt(expired.size()); - expired.forEach(new TIntProcedure() { - @Override - public boolean execute(int value) { - AdventCalendarDataComposer.this.response.appendInt(value); - return true; - } + expired.forEach(value -> { + AdventCalendarDataComposer.this.response.appendInt(value); + return true; }); } else { this.response.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java index 5352d886..15c08771 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java @@ -1,6 +1,7 @@ package com.eu.habbo.messages.outgoing.events.calendar; import com.eu.habbo.habbohotel.catalog.CalendarRewardObject; +import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -18,9 +19,9 @@ public class AdventCalendarProductComposer extends MessageComposer { public ServerMessage compose() { this.response.init(Outgoing.AdventCalendarProductComposer); this.response.appendBoolean(this.visible); - this.response.appendString(this.rewardObject.getName()); + this.response.appendString(this.rewardObject.getItem().getName()); this.response.appendString(this.rewardObject.getCustomImage()); - this.response.appendString(this.rewardObject.getCatalogItem() != null ? this.rewardObject.getCatalogItem().getName() : this.rewardObject.getName()); + this.response.appendString(this.rewardObject.getItem().getName()); return this.response; } } \ No newline at end of file From 8d7c9aff70b6fbf3eff791e5520e13a76d10d988 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Wed, 31 Jul 2019 13:01:47 +0100 Subject: [PATCH 20/77] Calendar is now fixed. Credits to ItsGiuseppe. --- .../eu/habbo/messages/incoming/handshake/UsernameEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java index 62b4d631..aa4d946f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java @@ -83,8 +83,8 @@ public class UsernameEvent extends MessageHandler { } } - if (calendar && Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { - this.client.sendResponse(new AdventCalendarDataComposer("xmas11", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), this.client.getHabbo().getHabboStats().calendarRewardsClaimed, true)); + if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { + this.client.sendResponse(new AdventCalendarDataComposer("xmas15", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), this.client.getHabbo().getHabboStats().calendarRewardsClaimed, true)); this.client.sendResponse(new NuxAlertComposer("openView/calendar")); } From 4f5795e9d087d73a4bbb58affd8f8941c20c003f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 31 Jul 2019 18:06:30 +0300 Subject: [PATCH 21/77] Make saved searches chronological --- src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java | 6 +++--- .../navigator/NewNavigatorSavedSearchesComposer.java | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java index f8238ca5..0632c0b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -50,7 +50,7 @@ public class HabboInfo implements Runnable { private String photoJSON; private int webPublishTimestamp; private String machineID; - private HashSet savedSearches = new HashSet<>(); + private List savedSearches = new ArrayList<>(); public HabboInfo(ResultSet set) { try { @@ -125,7 +125,7 @@ public class HabboInfo implements Runnable { } private void loadSavedSearches() { - this.savedSearches = new HashSet<>(); + this.savedSearches = new ArrayList<>(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_saved_searches WHERE user_id = ?")) { statement.setInt(1, this.id); @@ -470,7 +470,7 @@ public class HabboInfo implements Runnable { this.machineID = machineID; } - public HashSet getSavedSearches() { + public List getSavedSearches() { return this.savedSearches; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java index 5fbe97bc..93845f71 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java @@ -6,11 +6,12 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import java.util.HashSet; +import java.util.List; public class NewNavigatorSavedSearchesComposer extends MessageComposer { - private final HashSet searches; + private final List searches; - public NewNavigatorSavedSearchesComposer(HashSet searches) { + public NewNavigatorSavedSearchesComposer(List searches) { this.searches = searches; } From 3075228c2ea7c1d0498982e9338178737a8edea0 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 31 Jul 2019 19:01:10 +0300 Subject: [PATCH 22/77] Add voucher limits and amounts --- sqlupdates/2_1_1_TO_2_2_0-RC-1.sql | 14 +++- .../habbohotel/catalog/CatalogManager.java | 67 ++++++++++++------- .../eu/habbo/habbohotel/catalog/Voucher.java | 60 +++++++++++++---- .../catalog/VoucherHistoryEntry.java | 34 ++++++++++ 4 files changed, 137 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql index 7d4b4451..408a2bf6 100644 --- a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql +++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql @@ -19,4 +19,16 @@ CREATE TABLE `items_highscore_data` ( `is_win` tinyint(1) NULL DEFAULT 0, `timestamp` int(11) NOT NULL, PRIMARY KEY (`id`) -); \ No newline at end of file +); + +CREATE TABLE `voucher_history` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `voucher_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `timestamp` int(11) NOT NULL, + PRIMARY KEY (`id`) +); + +ALTER TABLE `vouchers` +ADD COLUMN `amount` int(11) NOT NULL DEFAULT 1, +ADD COLUMN `limit` int(11) NOT NULL DEFAULT -1; diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index f5dc975e..68db8eea 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -24,6 +24,7 @@ import com.eu.habbo.messages.outgoing.inventory.AddBotComposer; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.AddPetComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; +import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer; import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer; import com.eu.habbo.messages.outgoing.users.UserCreditsComposer; import com.eu.habbo.messages.outgoing.users.UserPointsComposer; @@ -31,7 +32,6 @@ import com.eu.habbo.plugin.events.emulator.EmulatorLoadCatalogManagerEvent; import com.eu.habbo.plugin.events.users.catalog.UserCatalogFurnitureBoughtEvent; import com.eu.habbo.plugin.events.users.catalog.UserCatalogItemPurchasedEvent; import gnu.trove.TCollections; -import gnu.trove.iterator.TIntIterator; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; @@ -534,35 +534,52 @@ public class CatalogManager { public void redeemVoucher(GameClient client, String voucherCode) { Voucher voucher = Emulator.getGameEnvironment().getCatalogManager().getVoucher(voucherCode); - if (voucher != null) { - if (Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) { - client.getHabbo().getHabboInfo().addCredits(voucher.credits); + if (voucher == null) { + client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.INVALID_CODE)); + return; + } - if (voucher.points > 0) { - client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points); - client.sendResponse(new UserPointsComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.pointsType), voucher.points, voucher.pointsType)); - } + Habbo habbo = client.getHabbo(); + if (habbo == null) return; - if (voucher.credits > 0) { - client.getHabbo().getHabboInfo().addCredits(voucher.credits); - client.sendResponse(new UserCreditsComposer(client.getHabbo())); - } - - if (voucher.catalogItemId > 0) { - CatalogItem item = this.getCatalogItem(voucher.catalogItemId); - - if (item != null) { - this.purchaseItem(null, item, client.getHabbo(), 1, "", true); - } - } - - client.sendResponse(new RedeemVoucherOKComposer()); - - return; + if (voucher.isExhausted()) { + if (!Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) { + client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.TECHNICAL_ERROR)); } } - client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.INVALID_CODE)); + if (voucher.hasUserExhausted(habbo.getHabboInfo().getId())) { + client.sendResponse(new ModToolIssueHandledComposer("You have exceeded the limit for redeeming this voucher.")); + return; + } + + voucher.addHistoryEntry(habbo.getHabboInfo().getId()); + + if (voucher.isExhausted()) { + if (!Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) { + client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.TECHNICAL_ERROR)); + } + } + + if (voucher.points > 0) { + client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points); + client.sendResponse(new UserPointsComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.pointsType), voucher.points, voucher.pointsType)); + } + + if (voucher.credits > 0) { + client.getHabbo().getHabboInfo().addCredits(voucher.credits); + client.sendResponse(new UserCreditsComposer(client.getHabbo())); + } + + if (voucher.catalogItemId > 0) { + CatalogItem item = this.getCatalogItem(voucher.catalogItemId); + + if (item != null) { + this.purchaseItem(null, item, client.getHabbo(), 1, "", true); + } + } + + client.sendResponse(new RedeemVoucherOKComposer()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java index 643a3d1d..7291e193 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java @@ -1,27 +1,24 @@ package com.eu.habbo.habbohotel.catalog; +import com.eu.habbo.Emulator; + +import java.sql.Connection; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class Voucher { - public final int id; - - public final String code; - - public final int credits; - - public final int points; - - public final int pointsType; - - public final int catalogItemId; - + public final int amount; + public final int limit; + private final List history = new ArrayList<>(); public Voucher(ResultSet set) throws SQLException { this.id = set.getInt("id"); @@ -30,5 +27,44 @@ public class Voucher { this.points = set.getInt("points"); this.pointsType = set.getInt("points_type"); this.catalogItemId = set.getInt("catalog_item_id"); + this.amount = set.getInt("amount"); + this.limit = set.getInt("limit"); + + this.loadHistory(); + } + + private void loadHistory() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM voucher_history")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + this.history.add(new VoucherHistoryEntry(set)); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public boolean hasUserExhausted(int userId) { + return this.limit > 0 && Math.toIntExact(this.history.stream().filter(h -> h.getUserId() == userId).count()) >= this.limit; + } + + public boolean isExhausted() { + return this.amount > 0 && this.history.size() >= this.amount; + } + + public void addHistoryEntry(int userId) { + int timestamp = Emulator.getIntUnixTimestamp(); + this.history.add(new VoucherHistoryEntry(this.id, userId, timestamp)); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO voucher_history (`voucher_id`, `user_id`, `timestamp`) VALUES (?, ?, ?)")) { + statement.setInt(1, this.id); + statement.setInt(2, userId); + statement.setInt(3, timestamp); + + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java b/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java new file mode 100644 index 00000000..300c7c8f --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java @@ -0,0 +1,34 @@ +package com.eu.habbo.habbohotel.catalog; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class VoucherHistoryEntry { + private final int voucherId; + private final int userId; + private final int timestamp; + + public VoucherHistoryEntry(ResultSet set) throws SQLException { + this.voucherId = set.getInt("voucher_id"); + this.userId = set.getInt("user_id"); + this.timestamp = set.getInt("timestamp"); + } + + public VoucherHistoryEntry(int voucherId, int userId, int timestamp) { + this.voucherId = voucherId; + this.userId = userId; + this.timestamp = timestamp; + } + + public int getVoucherId() { + return voucherId; + } + + public int getUserId() { + return userId; + } + + public int getTimestamp() { + return timestamp; + } +} From 5bce15b44135ba4e12e04d8d6ea660f7b98bc620 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 1 Aug 2019 12:14:06 +0100 Subject: [PATCH 23/77] Pushed Calendar SQL. --- sqlupdates/2_1_1_TO_2_2_0-RC-1.sql | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql index 408a2bf6..b787eb68 100644 --- a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql +++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql @@ -21,14 +21,16 @@ CREATE TABLE `items_highscore_data` ( PRIMARY KEY (`id`) ); -CREATE TABLE `voucher_history` ( +DROP TABLE IF EXISTS `calendar_rewards`; +CREATE TABLE `calendar_rewards` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `voucher_id` int(11) NOT NULL, - `user_id` int(11) NOT NULL, - `timestamp` int(11) NOT NULL, - PRIMARY KEY (`id`) -); + `custom_image` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `credits` int(11) NOT NULL DEFAULT 0, + `points` int(11) NOT NULL DEFAULT 0, + `points_type` int(3) NOT NULL DEFAULT 0, + `badge` varchar(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `item_id` int(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = MyISAM AUTO_INCREMENT = 3 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; -ALTER TABLE `vouchers` -ADD COLUMN `amount` int(11) NOT NULL DEFAULT 1, -ADD COLUMN `limit` int(11) NOT NULL DEFAULT -1; +SET FOREIGN_KEY_CHECKS = 1; From 3bad985f11bf1471cf5873d7feab0ca67bdeed06 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 1 Aug 2019 12:19:45 +0100 Subject: [PATCH 24/77] Updated RC-1 SQL --- sqlupdates/2_1_1_TO_2_2_0-RC-1.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql index b787eb68..7688d9ed 100644 --- a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql +++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql @@ -34,3 +34,16 @@ CREATE TABLE `calendar_rewards` ( ) ENGINE = MyISAM AUTO_INCREMENT = 3 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; SET FOREIGN_KEY_CHECKS = 1; + +CREATE TABLE `voucher_history` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `voucher_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `timestamp` int(11) NOT NULL, + PRIMARY KEY (`id`) +); + +ALTER TABLE `vouchers` +ADD COLUMN `amount` int(11) NOT NULL DEFAULT 1, +ADD COLUMN `limit` int(11) NOT NULL DEFAULT -1; + From 12507e9b430c55fcf04a021785709618ae37e804 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 1 Aug 2019 20:40:49 +0300 Subject: [PATCH 25/77] Store death status of monsterplants --- sqlupdates/2_1_1_TO_2_2_0-RC-1.sql | 2 ++ .../eu/habbo/habbohotel/pets/MonsterplantPet.java | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql index 7688d9ed..0e934e61 100644 --- a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql +++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql @@ -47,3 +47,5 @@ ALTER TABLE `vouchers` ADD COLUMN `amount` int(11) NOT NULL DEFAULT 1, ADD COLUMN `limit` int(11) NOT NULL DEFAULT -1; +ALTER TABLE `users_pets` +ADD COLUMN `mp_is_dead` tinyint(1) NOT NULL DEFAULT 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java index beea7293..19bb4181 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -71,6 +71,7 @@ public class MonsterplantPet extends Pet implements IPetLook { private boolean canBreed = true; private boolean publiclyBreedable = false; private int growthStage = 0; + private boolean hasDied = false; public MonsterplantPet(ResultSet set) throws SQLException { super(set); @@ -85,6 +86,7 @@ public class MonsterplantPet extends Pet implements IPetLook { this.deathTimestamp = set.getInt("mp_death_timestamp"); this.publiclyBreedable = set.getString("mp_allow_breed").equals("1"); this.canBreed = set.getString("mp_breedable").equals("1"); + this.hasDied = set.getInt("mp_is_dead") == 1; } public MonsterplantPet(int userId, int type, int hue, int nose, int noseColor, int mouth, int mouthColor, int eyes, int eyesColor) { @@ -120,7 +122,7 @@ public class MonsterplantPet extends Pet implements IPetLook { if (this.needsUpdate) { super.run(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET mp_type = ?, mp_color = ?, mp_nose = ?, mp_eyes = ?, mp_mouth = ?, mp_nose_color = ?, mp_eyes_color = ?, mp_mouth_color = ?, mp_death_timestamp = ?, mp_breedable = ?, mp_allow_breed = ? WHERE id = ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET mp_type = ?, mp_color = ?, mp_nose = ?, mp_eyes = ?, mp_mouth = ?, mp_nose_color = ?, mp_eyes_color = ?, mp_mouth_color = ?, mp_death_timestamp = ?, mp_breedable = ?, mp_allow_breed = ?, mp_is_dead = ? WHERE id = ?")) { statement.setInt(1, this.type); statement.setInt(2, this.hue); statement.setInt(3, this.nose); @@ -132,7 +134,8 @@ public class MonsterplantPet extends Pet implements IPetLook { statement.setInt(9, this.deathTimestamp); statement.setString(10, this.canBreed ? "1" : "0"); statement.setString(11, this.publiclyBreedable ? "1" : "0"); - statement.setInt(12, this.id); + statement.setInt(12, this.hasDied ? 1 : 0); + statement.setInt(13, this.id); statement.execute(); } catch (SQLException e) { Emulator.getLogging().logSQLException(e); @@ -146,8 +149,11 @@ public class MonsterplantPet extends Pet implements IPetLook { if (this.isDead()) { this.roomUnit.removeStatus(RoomUnitStatus.GESTURE); - if (!this.roomUnit.hasStatus(RoomUnitStatus.RIP)) { + if (!this.hasDied) { AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantGardenOfDeath")); + + this.hasDied = true; + this.needsUpdate = true; } this.roomUnit.clearStatus(); From db8987678f0a590f66b9ec5e1cd45acf91ff4160 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 1 Aug 2019 20:42:12 +0300 Subject: [PATCH 26/77] Fix NullPointerException in BadgeImager --- .../com/eu/habbo/util/imager/badges/BadgeImager.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java b/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java index fb9436ec..2872cad8 100644 --- a/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java +++ b/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java @@ -53,18 +53,9 @@ public class BadgeImager { float red = (color.getRed() / 255.0F) * (maskColor.getRed() / 255.0F); float green = (color.getGreen() / 255.0F) * (maskColor.getGreen() / 255.0F); float blue = (color.getBlue() / 255.0F) * (maskColor.getBlue() / 255.0F); -// - - -// - - -// - color = new Color(red, green, blue, alpha); - int rgb = color.getRGB(); image.setRGB(x, y, rgb); } @@ -209,6 +200,8 @@ public class BadgeImager { part = Emulator.getGameEnvironment().getGuildManager().getPart(GuildPartType.SYMBOL, id); } + if (part == null) continue; + BufferedImage imagePart = BadgeImager.deepCopy(this.cachedImages.get(part.valueA)); Point point; From e2577f88945819ca97d2862786b9dfb5552de547 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 1 Aug 2019 20:45:08 +0300 Subject: [PATCH 27/77] Use utf8 in items --- sqlupdates/2_1_1_TO_2_2_0-RC-1.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql index 0e934e61..2c51b344 100644 --- a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql +++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql @@ -49,3 +49,5 @@ ADD COLUMN `limit` int(11) NOT NULL DEFAULT -1; ALTER TABLE `users_pets` ADD COLUMN `mp_is_dead` tinyint(1) NOT NULL DEFAULT 0; + +ALTER TABLE `items` CHARACTER SET = utf8, COLLATE = utf8_general_ci; From 27b6766940eb437fde7a04ef2a1df4f58f6a3977 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 1 Aug 2019 21:10:42 +0300 Subject: [PATCH 28/77] Fix pet walking --- src/main/java/com/eu/habbo/habbohotel/pets/Pet.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 29240ad9..965584c4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -217,7 +217,7 @@ public class Pet implements ISerialize, Runnable { int time = Emulator.getIntUnixTimestamp(); if (this.roomUnit != null && this.task != PetTasks.RIDE) { - if (time - this.gestureTickTimeout > 5) { + if (time - this.gestureTickTimeout > 5 && this.roomUnit.hasStatus(RoomUnitStatus.GESTURE)) { this.roomUnit.removeStatus(RoomUnitStatus.GESTURE); this.packetUpdate = true; } @@ -236,8 +236,6 @@ public class Pet implements ISerialize, Runnable { } if (!this.roomUnit.isWalking()) { - this.roomUnit.removeStatus(RoomUnitStatus.MOVE); - if (this.roomUnit.getWalkTimeOut() < time && this.canWalk()) { RoomTile tile = this.room.getRandomWalkableTile(); @@ -399,9 +397,9 @@ public class Pet implements ISerialize, Runnable { for (Map.Entry entry : keys.entrySet()) { this.roomUnit.setStatus(entry.getKey(), entry.getValue()); } - } - this.packetUpdate = true; + if (!keys.isEmpty()) this.packetUpdate = true; + } } public void updateGesture(int time) { From 430a86701e1225fb6a217e400f919216ea549c50 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 1 Aug 2019 21:23:20 +0300 Subject: [PATCH 29/77] Fix tag game effects --- .../java/com/eu/habbo/habbohotel/games/tag/TagGame.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java index ff5a8d52..f256cce5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java @@ -140,14 +140,16 @@ public abstract class TagGame extends Game { TObjectHashIterator iterator = poles.iterator(); if ((iterator.hasNext())) { HabboItem item = iterator.next(); - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1); + habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1); + this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1)); this.taggers.put(habbo, (InteractionTagPole) item); return true; } } } else { if (this.taggers.isEmpty()) { - habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1); + habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1); + this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1)); this.taggers.put(habbo, null); return true; } From f2b2fc8d991ff19953d45904dc82d7c40d82d313 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 1 Aug 2019 21:31:10 +0300 Subject: [PATCH 30/77] Show pending membership requests to admins --- .../messages/incoming/guilds/RequestGuildMembersEvent.java | 2 +- .../eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java index 0a449e62..b1c1e873 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java @@ -21,7 +21,7 @@ public class RequestGuildMembersEvent extends MessageHandler { boolean isAdmin = this.client.getHabbo().hasPermission("acc_guild_admin"); if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(g, this.client.getHabbo()); - isAdmin = member != null && member.getRank().equals(GuildRank.ADMIN); + isAdmin = member != null && (member.getRank().equals(GuildRank.ADMIN) || member.getRank().equals(GuildRank.MOD)); } this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), this.client.getHabbo(), pageId, levelId, query, isAdmin, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(g, pageId, levelId, query))); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java index fea8a93e..f52c7dff 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java @@ -52,7 +52,7 @@ public class GuildMembersComposer extends MessageComposer { this.response.appendString(member.getRank().type < 3 && member.getRank().type > 0 ? cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR) : ""); } - this.response.appendBoolean(this.isAdmin); //Is owner + this.response.appendBoolean(this.isAdmin); this.response.appendInt(14); this.response.appendInt(this.pageId); this.response.appendInt(this.level); From 4389a19ae5bda42083dfa7f924d4278e2ce311c4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 1 Aug 2019 22:02:15 +0300 Subject: [PATCH 31/77] Update guild badge when removed --- .../messages/incoming/guilds/GuildRemoveFavoriteEvent.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java index 5aaf3e7f..9f92df68 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java @@ -3,6 +3,8 @@ package com.eu.habbo.messages.incoming.guilds; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.guilds.GuildFavoriteRoomUserUpdateComposer; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersAddGuildBadgeComposer; import com.eu.habbo.messages.outgoing.users.UserProfileComposer; import com.eu.habbo.plugin.events.guilds.GuildRemovedFavoriteEvent; @@ -20,6 +22,10 @@ public class GuildRemoveFavoriteEvent extends MessageHandler { this.client.getHabbo().getHabboStats().guild = 0; + if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && guild != null) { + this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(this.client.getHabbo().getRoomUnit(), guild).compose()); + } + this.client.sendResponse(new UserProfileComposer(this.client.getHabbo(), this.client)); } } From ad3002209dcd15b242f8e9daf580bc6b2035b371 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 1 Aug 2019 23:05:01 +0300 Subject: [PATCH 32/77] Add equipping clothing when walking on furni --- sqlupdates/2_1_1_TO_2_2_0-RC-1.sql | 3 +++ .../com/eu/habbo/habbohotel/items/Item.java | 5 +++++ .../eu/habbo/habbohotel/users/HabboItem.java | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql index 2c51b344..e959f808 100644 --- a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql +++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql @@ -51,3 +51,6 @@ ALTER TABLE `users_pets` ADD COLUMN `mp_is_dead` tinyint(1) NOT NULL DEFAULT 0; ALTER TABLE `items` CHARACTER SET = utf8, COLLATE = utf8_general_ci; + +ALTER TABLE `items_base` +ADD COLUMN `clothing_on_walk` varchar(255) NOT NULL DEFAULT ''; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/Item.java b/src/main/java/com/eu/habbo/habbohotel/items/Item.java index 8584e582..caf8932a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java @@ -33,6 +33,7 @@ public class Item { private TIntArrayList vendingItems; private double[] multiHeights; private String customParams; + private String clothingOnWalk; private ItemInteraction interactionType; @@ -93,6 +94,8 @@ public class Item { this.effectM = set.getShort("effect_id_male"); this.effectF = set.getShort("effect_id_female"); this.customParams = set.getString("customparams"); + this.clothingOnWalk = set.getString("clothing_on_walk"); + if (!set.getString("vending_ids").isEmpty()) { this.vendingItems = new TIntArrayList(); String[] vendingIds = set.getString("vending_ids").replace(";", ",").split(","); @@ -215,4 +218,6 @@ public class Item { public String getCustomParams() { return customParams; } + + public String getClothingOnWalk() { return clothingOnWalk; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java index 213b3124..5ac1bc7c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -18,7 +18,11 @@ import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; +import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer; +import com.eu.habbo.util.figure.FigureUtil; import gnu.trove.set.hash.THashSet; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.math3.util.Pair; import java.sql.Connection; @@ -26,6 +30,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public abstract class HabboItem implements Runnable, IEventTriggers { @@ -294,6 +299,20 @@ public abstract class HabboItem implements Runnable, IEventTriggers { roomUnit.setDanceType(DanceType.NONE); room.sendComposer(new RoomUserDanceComposer(roomUnit).compose()); } + + if (!this.getBaseItem().getClothingOnWalk().isEmpty() && roomUnit.getPreviousLocation() != roomUnit.getGoal() && roomUnit.getGoal() == room.getLayout().getTile(this.x, this.y)) { + Habbo habbo = room.getHabbo(roomUnit); + + if (habbo != null && habbo.getClient() != null) { + String[] clothingKeys = Arrays.stream(this.getBaseItem().getClothingOnWalk().split("\\.")).map(k -> k.split("-")[0]).toArray(String[]::new); + habbo.getHabboInfo().setLook(String.join(".", Arrays.stream(habbo.getHabboInfo().getLook().split("\\.")).filter(k -> !ArrayUtils.contains(clothingKeys, k.split("-")[0])).toArray(String[]::new)) + "." + this.getBaseItem().getClothingOnWalk()); + + habbo.getClient().sendResponse(new UpdateUserLookComposer(habbo)); + if (habbo.getHabboInfo().getCurrentRoom() != null) { + habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose()); + } + } + } } @Override From 1f3e81a8e420079eb73a12f191c915c2ed66f242 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 4 Aug 2019 16:42:18 +0300 Subject: [PATCH 33/77] Fix WiredGame --- .../habbohotel/games/wired/WiredGame.java | 21 +++++++++++++------ .../effects/WiredEffectGiveScoreToTeam.java | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java index 24511b32..21cd5469 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java @@ -1,26 +1,25 @@ package com.eu.habbo.habbohotel.games.wired; -import com.eu.habbo.habbohotel.games.Game; -import com.eu.habbo.habbohotel.games.GamePlayer; -import com.eu.habbo.habbohotel.games.GameTeam; -import com.eu.habbo.habbohotel.games.GameTeamColors; +import com.eu.habbo.habbohotel.games.*; import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; public class WiredGame extends Game { + public GameState state = GameState.RUNNING; + public WiredGame(Room room) { super(GameTeam.class, GamePlayer.class, room, false); } @Override public void initialise() { - + this.state = GameState.RUNNING; } @Override public void run() { - + this.state = GameState.RUNNING; } @Override @@ -34,4 +33,14 @@ public class WiredGame extends Game { super.removeHabbo(habbo); this.room.giveEffect(habbo, 0, -1); } + + @Override + public void stop() { + this.state = GameState.RUNNING; + } + + @Override + public GameState getState() { + return GameState.RUNNING; + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index 2a094d98..738fc508 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -120,7 +120,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { this.points = packet.readInt(); this.count = packet.readInt(); - this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; + this.teamColor = GameTeamColors.values()[packet.readInt()]; packet.readString(); packet.readInt(); this.setDelay(packet.readInt()); From 184a426af5fe919fe25bc85ebc9c12753a19bc40 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 4 Aug 2019 16:54:32 +0300 Subject: [PATCH 34/77] Fix stackability check --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index ffd420a6..05fb6c0d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4429,7 +4429,8 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); if (topItem != item) { for (RoomTile t : occupiedTiles) { - if (!magicTile && ((this.getTopItemAt(t.x, t.y) != item ? t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() : this.calculateTileState(t, item).equals(RoomTileState.INVALID)))) + HabboItem tileTopItem = this.getTopItemAt(t.x, t.y); + if (!magicTile && ((tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)))) return FurnitureMovementError.CANT_STACK; if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; From 7abdb2815e2ae1ca83609c411bf14d521e00fa86 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 4 Aug 2019 17:23:04 +0300 Subject: [PATCH 35/77] Fix HC gates --- .../InteractionHabboClubGate.java | 21 ++++++++----------- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 13 +++++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java index e6103f97..95c0c496 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java @@ -12,7 +12,7 @@ import com.eu.habbo.threading.runnables.CloseGate; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionHabboClubGate extends InteractionGate { +public class InteractionHabboClubGate extends InteractionDefault { public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); @@ -24,19 +24,16 @@ public class InteractionHabboClubGate extends InteractionGate { } @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Habbo habbo = room.getHabbo(roomUnit); - - if (habbo != null) { - return habbo.getHabboStats().hasActiveClub(); - } - - return false; + public boolean isWalkable() { + return true; } @Override - public boolean isWalkable() { - return true; + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + Habbo habbo = room.getHabbo(roomUnit); + + System.out.println(habbo != null && habbo.getHabboStats().hasActiveClub()); + return habbo != null && habbo.getHabboStats().hasActiveClub(); } @Override @@ -72,6 +69,6 @@ public class InteractionHabboClubGate extends InteractionGate { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Emulator.getThreading().run(new CloseGate(this, room), 500); + Emulator.getThreading().run(new CloseGate(this, room), 1000); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index d1c6aa6c..79ba7fab 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -2,15 +2,13 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate; -import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport; -import com.eu.habbo.habbohotel.items.interactions.InteractionWater; -import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem; +import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.outgoing.generic.alerts.CustomNotificationComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; @@ -285,12 +283,17 @@ public class RoomUnit { if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) { if (item.canWalkOn(this, room, null)) { item.onWalkOn(this, room, null); - } else if (item instanceof InteractionGuildGate) { + } else if (item instanceof InteractionGuildGate || item instanceof InteractionHabboClubGate) { this.setRotation(oldRotation); this.tilesWalked--; this.setGoalLocation(this.currentLocation); this.status.remove(RoomUnitStatus.MOVE); room.sendComposer(new RoomUserStatusComposer(this).compose()); + + if (item instanceof InteractionHabboClubGate && habbo != null) { + habbo.getClient().sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC)); + } + return false; } } else { From 8a7dff3770cb46d149c0175f7cc4813d0bc695be Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 4 Aug 2019 17:32:11 +0300 Subject: [PATCH 36/77] Fix NullPointerException --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 05fb6c0d..a0cffa30 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4430,7 +4430,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (topItem != item) { for (RoomTile t : occupiedTiles) { HabboItem tileTopItem = this.getTopItemAt(t.x, t.y); - if (!magicTile && ((tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)))) + if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)))) return FurnitureMovementError.CANT_STACK; if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; From 80bde942c6538fb03d8a117a8cd2e29edae7b756 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 4 Aug 2019 17:32:36 +0300 Subject: [PATCH 37/77] Add checking of blocking furniture in floorplan editor --- .../floorplaneditor/FloorPlanEditorSaveEvent.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java index 58d4a8cc..ac8902e4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java @@ -94,6 +94,16 @@ public class FloorPlanEditorSaveEvent extends MessageHandler { errors.add("${notification.floorplan_editor.error.message.invalid_walls_fixed_height}"); } + blockingRoomItemScan: + for (int y = 0; y < mapRows.length; y++) { + for (int x = 0; x < firstRowSize; x++) { + if (mapRows[y].charAt(x) == "x".charAt(0) && room.getTopItemAt(x, y) != null) { + errors.add("${notification.floorplan_editor.error.message.change_blocked_by_room_item}"); + break blockingRoomItemScan; + } + } + } + if (errors.length() > 0) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errors.toString())); return; From d06b9bae11be30fbf9cdff6a19644728db7945e1 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 4 Aug 2019 18:03:02 +0300 Subject: [PATCH 38/77] Fix trading stats in trading window --- .../outgoing/trading/TradeUpdateComposer.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java index 07e0556f..87f579d5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java @@ -20,8 +20,8 @@ public class TradeUpdateComposer extends MessageComposer { this.response.init(Outgoing.TradeUpdateComposer); for (RoomTradeUser roomTradeUser : this.roomTrade.getRoomTradeUsers()) { this.response.appendInt(roomTradeUser.getUserId()); - this.response.appendInt(roomTradeUser.getItems().size()); + this.response.appendInt(roomTradeUser.getItems().size()); for (HabboItem item : roomTradeUser.getItems()) { this.response.appendInt(item.getId()); this.response.appendString(item.getBaseItem().getType().code); @@ -38,9 +38,19 @@ public class TradeUpdateComposer extends MessageComposer { this.response.appendInt(0); } - this.response.appendInt(0); - this.response.appendInt(0); + this.response.appendInt(roomTradeUser.getItems().size()); + this.response.appendInt(roomTradeUser.getItems().stream().mapToInt(this::getCreditsByItem).sum()); } return this.response; } + + private int getCreditsByItem(HabboItem item) { + if (!item.getBaseItem().getName().startsWith("CF_") && !item.getBaseItem().getName().startsWith("CFC_")) return 0; + + try { + return Integer.valueOf(item.getBaseItem().getName().split("_")[1]); + } catch (Exception e) { + return 0; + } + } } From 948669cbffc6ece74d3b1895a9d3f4eb033a95e4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 4 Aug 2019 18:11:11 +0300 Subject: [PATCH 39/77] Automatically convert credit redeemables on trade confirm --- .../eu/habbo/habbohotel/rooms/RoomTrade.java | 38 +++++++++++++++++++ .../outgoing/trading/TradeUpdateComposer.java | 12 +----- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java index ba56a8e1..0b17cbd7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -8,6 +8,7 @@ import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.messages.outgoing.trading.*; +import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import gnu.trove.set.hash.THashSet; import java.sql.*; @@ -214,6 +215,33 @@ public class RoomTrade { userOne.clearItems(); userTwo.clearItems(); + int creditsForUserTwo = 0; + THashSet creditFurniUserOne = new THashSet<>(); + for (HabboItem item : itemsUserOne) { + int worth = RoomTrade.getCreditsByItem(item); + if (worth > 0) { + creditsForUserTwo += worth; + creditFurniUserOne.add(item); + new QueryDeleteHabboItem(item); + } + } + itemsUserOne.removeAll(creditFurniUserOne); + + int creditsForUserOne = 0; + THashSet creditFurniUserTwo = new THashSet<>(); + for (HabboItem item : itemsUserTwo) { + int worth = RoomTrade.getCreditsByItem(item); + if (worth > 0) { + creditsForUserOne += worth; + creditFurniUserTwo.add(item); + new QueryDeleteHabboItem(item); + } + } + itemsUserTwo.removeAll(creditFurniUserTwo); + + userOne.getHabbo().giveCredits(creditsForUserOne); + userTwo.getHabbo().giveCredits(creditsForUserTwo); + userOne.getHabbo().getInventory().getItemsComponent().addItems(itemsUserTwo); userTwo.getHabbo().getInventory().getItemsComponent().addItems(itemsUserOne); @@ -287,4 +315,14 @@ public class RoomTrade { public List getRoomTradeUsers() { return this.users; } + + public static int getCreditsByItem(HabboItem item) { + if (!item.getBaseItem().getName().startsWith("CF_") && !item.getBaseItem().getName().startsWith("CFC_")) return 0; + + try { + return Integer.valueOf(item.getBaseItem().getName().split("_")[1]); + } catch (Exception e) { + return 0; + } + } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java index 87f579d5..3f28f45c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java @@ -39,18 +39,8 @@ public class TradeUpdateComposer extends MessageComposer { } this.response.appendInt(roomTradeUser.getItems().size()); - this.response.appendInt(roomTradeUser.getItems().stream().mapToInt(this::getCreditsByItem).sum()); + this.response.appendInt(roomTradeUser.getItems().stream().mapToInt(RoomTrade::getCreditsByItem).sum()); } return this.response; } - - private int getCreditsByItem(HabboItem item) { - if (!item.getBaseItem().getName().startsWith("CF_") && !item.getBaseItem().getName().startsWith("CFC_")) return 0; - - try { - return Integer.valueOf(item.getBaseItem().getName().split("_")[1]); - } catch (Exception e) { - return 0; - } - } } From 9807d52403d66b1286bcba57824303180419e5f6 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 4 Aug 2019 18:13:14 +0300 Subject: [PATCH 40/77] Fix converting credit furni --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java index 0b17cbd7..eb6ac5cd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -222,7 +222,7 @@ public class RoomTrade { if (worth > 0) { creditsForUserTwo += worth; creditFurniUserOne.add(item); - new QueryDeleteHabboItem(item); + new QueryDeleteHabboItem(item).run(); } } itemsUserOne.removeAll(creditFurniUserOne); @@ -234,7 +234,7 @@ public class RoomTrade { if (worth > 0) { creditsForUserOne += worth; creditFurniUserTwo.add(item); - new QueryDeleteHabboItem(item); + new QueryDeleteHabboItem(item).run(); } } itemsUserTwo.removeAll(creditFurniUserTwo); From 96f6e1b9affd011c6e3e6db3e47e08480ed6dee3 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 5 Aug 2019 19:19:47 +0300 Subject: [PATCH 41/77] Add plugin event for room voting --- .../eu/habbo/habbohotel/rooms/RoomManager.java | 4 ++++ .../plugin/events/rooms/UserVoteRoomEvent.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/main/java/com/eu/habbo/plugin/events/rooms/UserVoteRoomEvent.java 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 0d8e5da1..d1c9a692 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -42,6 +42,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer; import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent; import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent; +import com.eu.habbo.plugin.events.rooms.UserVoteRoomEvent; import com.eu.habbo.plugin.events.users.HabboAddedToRoomEvent; import com.eu.habbo.plugin.events.users.UserEnterRoomEvent; import com.eu.habbo.plugin.events.users.UserExitRoomEvent; @@ -432,6 +433,9 @@ public class RoomManager { if (this.hasVotedForRoom(habbo, room)) return; + UserVoteRoomEvent event = new UserVoteRoomEvent(room, habbo); + if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return; + room.setScore(room.getScore() + 1); room.setNeedsUpdate(true); habbo.getHabboStats().votedRooms.push(room.getId()); diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/UserVoteRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/UserVoteRoomEvent.java new file mode 100644 index 00000000..cac45ea8 --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/rooms/UserVoteRoomEvent.java @@ -0,0 +1,15 @@ +package com.eu.habbo.plugin.events.rooms; + +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.plugin.Event; + +public class UserVoteRoomEvent extends Event { + public final Room room; + public final Habbo habbo; + + public UserVoteRoomEvent(Room room, Habbo habbo) { + this.room = room; + this.habbo = habbo; + } +} From ce2e3f3eb10a0b7db5498402fda79ea2e31216bb Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 5 Aug 2019 19:22:06 +0300 Subject: [PATCH 42/77] Unidle user when teleporting --- .../items/interactions/wired/effects/WiredEffectTeleport.java | 1 + 1 file changed, 1 insertion(+) 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 81456f98..729c50e4 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 @@ -51,6 +51,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { return; // makes a temporary effect + roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit)); room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose()); Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000); From cb8df7ce6e47266963f086d4155171a9bedefeed Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 5 Aug 2019 19:35:26 +0300 Subject: [PATCH 43/77] Fix exceptions --- .../eu/habbo/habbohotel/commands/UnmuteCommand.java | 4 ++-- .../java/com/eu/habbo/habbohotel/games/GameTeam.java | 2 ++ .../habbohotel/games/freeze/FreezeGameTeam.java | 2 ++ .../eu/habbo/habbohotel/items/CrackableReward.java | 2 ++ .../java/com/eu/habbo/habbohotel/rooms/Room.java | 9 ++++++++- .../java/com/eu/habbo/habbohotel/users/Habbo.java | 12 ++++++++---- .../eu/habbo/habbohotel/users/HabboInventory.java | 8 +++++--- .../rooms/users/RoomUnitOnRollerComposer.java | 2 +- .../runnables/teleport/TeleportActionFive.java | 2 ++ 9 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java index 9e88bd8b..376f8b94 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java @@ -23,12 +23,12 @@ public class UnmuteCommand extends Command { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_unmute.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; } else { - if (!habbo.getHabboStats().allowTalk() || habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) { + if (!habbo.getHabboStats().allowTalk() || (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom().isMuted(habbo))) { if (!habbo.getHabboStats().allowTalk()) { habbo.unMute(); } - if (habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) { + if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) { habbo.getHabboInfo().getCurrentRoom().muteHabbo(habbo, 1); } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java index 67fa54e0..79dbc2aa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java @@ -70,6 +70,8 @@ public class GameTeam { public void clearMembers() { for (GamePlayer player : this.members) { + if (player == null || player.getHabbo() == null) continue; + player.getHabbo().getHabboInfo().getGamePlayer().reset(); player.getHabbo().getHabboInfo().setCurrentGame(null); player.getHabbo().getHabboInfo().setGamePlayer(null); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java index 133cf431..ab57f565 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java @@ -14,6 +14,8 @@ public class FreezeGameTeam extends GameTeam { @Override public void removeMember(GamePlayer gamePlayer) { + if (gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null) return; + Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class); Room room = gamePlayer.getHabbo().getRoomUnit().getRoom(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java index f3dbafe7..87e1caf6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java @@ -43,6 +43,8 @@ public class CrackableReward { if (prize.contains(":") && prize.split(":").length == 2) { itemId = Integer.valueOf(prize.split(":")[0]); chance = Integer.valueOf(prize.split(":")[1]); + } else if (prize.contains(":")) { + Emulator.getLogging().logErrorLine("Invalid configuration of crackable prizes (item id: " + this.itemId + "). '" + prize + "' format should be itemId:chance."); } else { itemId = Integer.valueOf(prize.replace(":", "")); } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index a0cffa30..560e90a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3413,11 +3413,14 @@ public class Room implements Comparable, ISerialize, Runnable { continue; } + if (this.layout == null) continue; + THashSet tiles = this.layout.getTilesAt( this.layout.getTile(habboItem.getX(), habboItem.getY()), habboItem.getBaseItem().getWidth(), habboItem.getBaseItem().getLength(), - habboItem.getRotation()); + habboItem.getRotation() + ); for (RoomTile tile : tiles) { if (((tile.x == x) && (tile.y == y))) { @@ -3682,6 +3685,10 @@ public class Room implements Comparable, ISerialize, Runnable { public void sendComposer(ServerMessage message) { for (Habbo habbo : this.getHabbos()) { + if (habbo.getClient() == null) { + this.removeHabbo(habbo, true); + } + habbo.getClient().sendResponse(message); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index 0876aec3..0838c76f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -22,6 +22,7 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; import java.net.InetSocketAddress; +import java.net.SocketAddress; import java.sql.ResultSet; import java.util.*; import java.util.stream.Collectors; @@ -110,7 +111,9 @@ public class Habbo implements Runnable { public void connect() { if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) { - this.habboInfo.setIpLogin(((InetSocketAddress) this.client.getChannel().remoteAddress()).getAddress().getHostAddress()); + SocketAddress address = this.client.getChannel().remoteAddress(); + + if (address != null) this.habboInfo.setIpLogin(((InetSocketAddress) address).getAddress().getHostAddress()); } this.habboInfo.setMachineID(this.client.getMachineId()); @@ -199,7 +202,8 @@ public class Habbo implements Runnable { return; this.getHabboInfo().addCredits(event.credits); - this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo())); + + if (this.client != null) this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo())); } @@ -213,7 +217,7 @@ public class Habbo implements Runnable { return; this.getHabboInfo().addPixels(event.points); - this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo())); + if (this.client != null) this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo())); } @@ -231,7 +235,7 @@ public class Habbo implements Runnable { return; this.getHabboInfo().addCurrencyAmount(event.type, event.points); - this.client.sendResponse(new UserPointsComposer(this.client.getHabbo().getHabboInfo().getCurrencyAmount(type), event.points, event.type)); + if (this.client != null) this.client.sendResponse(new UserPointsComposer(this.client.getHabbo().getHabboInfo().getCurrencyAmount(type), event.points, event.type)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java index e227aaba..52db8cf6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java @@ -147,9 +147,11 @@ public class HabboInventory { } public MarketPlaceOffer getOffer(int id) { - for (MarketPlaceOffer offer : this.items) { - if (offer.getOfferId() == id) - return offer; + synchronized (this.items) { + for (MarketPlaceOffer offer : this.items) { + if (offer.getOfferId() == id) + return offer; + } } return null; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java index 8537ac4a..9f30152a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java @@ -55,7 +55,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { this.response.appendString(this.oldZ + ""); this.response.appendString(this.newZ + ""); - if (this.roller != null) { + if (this.roller != null && room.getLayout() != null) { RoomTile rollerTile = room.getLayout().getTile(this.roller.getX(), this.roller.getY()); Emulator.getThreading().run(() -> { diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java index f8abd365..674dfba3 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java @@ -37,6 +37,8 @@ class TeleportActionFive implements Runnable { //if (!(this.currentTeleport instanceof InteractionTeleportTile)) + if (this.room.getLayout() == null || this.currentTeleport == null) return; + RoomTile currentLocation = this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY()); RoomTile tile = this.room.getLayout().getTileInFront(currentLocation, this.currentTeleport.getRotation()); From 85831a9df3948052fb65826be4fd74f5961e3800 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 5 Aug 2019 19:47:13 +0300 Subject: [PATCH 44/77] Sort messenger search results --- .../outgoing/friends/UserSearchResultComposer.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java index d27df321..4666d09e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java @@ -7,11 +7,17 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + public class UserSearchResultComposer extends MessageComposer { private final THashSet users; private final THashSet friends; private final Habbo habbo; + private static Comparator COMPARATOR = Comparator.comparing((MessengerBuddy b) -> b.getUsername().length()).thenComparing((MessengerBuddy b, MessengerBuddy b2) -> b.getUsername().compareToIgnoreCase(b2.getUsername())); + public UserSearchResultComposer(THashSet users, THashSet friends, Habbo habbo) { this.users = users; this.friends = friends; @@ -21,7 +27,7 @@ public class UserSearchResultComposer extends MessageComposer { @Override public ServerMessage compose() { this.response.init(Outgoing.UserSearchResultComposer); - THashSet u = new THashSet<>(); + List u = new ArrayList<>(); for (MessengerBuddy buddy : this.users) { if (!buddy.getUsername().equals(this.habbo.getHabboInfo().getUsername()) && !this.inFriendList(buddy)) { @@ -29,6 +35,11 @@ public class UserSearchResultComposer extends MessageComposer { } } + List friends = new ArrayList<>(this.friends); + + u.sort(UserSearchResultComposer.COMPARATOR); + friends.sort(UserSearchResultComposer.COMPARATOR); + this.response.appendInt(this.friends.size()); for (MessengerBuddy buddy : this.friends) { this.response.appendInt(buddy.getId()); From 274ea7f1ad286916ae5e02a7d3fae0dc3204853c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 5 Aug 2019 19:52:28 +0300 Subject: [PATCH 45/77] Make messenger friend list behave properly --- .../java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java | 1 + .../com/eu/habbo/messages/outgoing/friends/FriendsComposer.java | 2 +- .../messages/outgoing/friends/UserSearchResultComposer.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java index 7489fd23..62d7a862 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java @@ -52,6 +52,7 @@ public class MessengerBuddy implements Runnable, ISerialize { try { this.id = set.getInt("id"); this.username = set.getString("username"); + this.look = set.getString("look"); this.relation = 0; this.userOne = 0; } catch (SQLException e) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java index 8f3ccc3b..46caa6b9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java @@ -36,7 +36,7 @@ public class FriendsComposer extends MessageComposer { this.response.appendInt(row.getValue().getGender().equals(HabboGender.M) ? 0 : 1); this.response.appendBoolean(row.getValue().getOnline() == 1); this.response.appendBoolean(row.getValue().inRoom()); //IN ROOM - this.response.appendString(row.getValue().getLook()); + this.response.appendString(row.getValue().getOnline() == 1 ? row.getValue().getLook() : ""); this.response.appendInt(0); this.response.appendString(row.getValue().getMotto()); this.response.appendString(""); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java index 4666d09e..cfa10e69 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java @@ -62,7 +62,7 @@ public class UserSearchResultComposer extends MessageComposer { this.response.appendBoolean(false); this.response.appendString(""); this.response.appendInt(1); - this.response.appendString(buddy.getLook()); + this.response.appendString(buddy.getOnline() == 1 ? buddy.getLook() : ""); this.response.appendString(""); } From 1e7a92e215ffa92d842f1f24b657d7ff739f375e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 5 Aug 2019 19:54:06 +0300 Subject: [PATCH 46/77] Make friend search show the searcher themselves --- .../messages/outgoing/friends/UserSearchResultComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java index cfa10e69..0bb07e6b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java @@ -30,7 +30,7 @@ public class UserSearchResultComposer extends MessageComposer { List u = new ArrayList<>(); for (MessengerBuddy buddy : this.users) { - if (!buddy.getUsername().equals(this.habbo.getHabboInfo().getUsername()) && !this.inFriendList(buddy)) { + if (!this.inFriendList(buddy)) { u.add(buddy); } } From 0ee867a2fae212cd5b84fb90555568f1e911988e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 5 Aug 2019 19:59:52 +0300 Subject: [PATCH 47/77] Make bots walk on beds and chairs --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 560e90a5..dcb66cdc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3646,7 +3646,7 @@ public class Room implements Comparable, ISerialize, Runnable { public RoomTile getRandomWalkableTile() { for (int i = 0; i < 10; i++) { RoomTile tile = this.layout.getTile((short) (Math.random() * this.layout.getMapSizeX()), (short) (Math.random() * this.layout.getMapSizeY())); - if (tile != null && tile.isWalkable()) { + if (tile != null && tile.getState() != RoomTileState.BLOCKED && tile.getState() != RoomTileState.INVALID) { return tile; } } From 732910e3fc8091b9cca05aaae2c2bd78f506a3aa Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 5 Aug 2019 20:14:33 +0300 Subject: [PATCH 48/77] Fix renting spaces --- .../items/interactions/InteractionDefault.java | 14 +++++++++----- .../incoming/rooms/items/RoomPlaceItemEvent.java | 2 -- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java index 72b13092..95308f40 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java @@ -4,10 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.rooms.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboItem; @@ -181,7 +178,14 @@ public class InteractionDefault extends HabboItem { } public boolean canToggle(Habbo habbo, Room room) { - return room.hasRights(habbo); + if (room.hasRights(habbo)) return true; + + if (!habbo.getHabboStats().isRentingSpace()) return false; + + HabboItem rentSpace = room.getHabboItem(habbo.getHabboStats().rentedItemId); + + return rentSpace != null && RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())); + } @Override diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java index d689a80a..bf3842ce 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java @@ -75,8 +75,6 @@ public class RoomPlaceItemEvent extends MessageHandler { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); return; } - - return; } RoomTile tile = room.getLayout().getTile(x, y); From 1c387eff511f432e7cced75e9a6caa1c711f33e2 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 11 Aug 2019 12:13:04 +0300 Subject: [PATCH 49/77] Reset wired game stats on initialization --- src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java | 8 ++++++++ .../com/eu/habbo/habbohotel/games/wired/WiredGame.java | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java index 79dbc2aa..5a5ba98b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java @@ -80,6 +80,14 @@ public class GameTeam { this.members.clear(); } + public void resetScores() { + for (GamePlayer player : this.members) { + if (player == null) continue; + + player.reset(); + } + } + public THashSet getMembers() { return this.members; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java index 21cd5469..80fe874d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java @@ -15,6 +15,10 @@ public class WiredGame extends Game { @Override public void initialise() { this.state = GameState.RUNNING; + + for (GameTeam team : this.teams.values()) { + team.resetScores(); + } } @Override From 79b02b80a6b4c49dbed409b3efa2645b9ab1b53f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 11 Aug 2019 12:15:39 +0300 Subject: [PATCH 50/77] Fix guild admin removing --- .../messages/incoming/guilds/GuildRemoveAdminEvent.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java index 84bbb3fa..a26dbcc5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java @@ -22,19 +22,20 @@ public class GuildRemoveAdminEvent extends MessageHandler { int userId = this.packet.readInt(); Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); - Emulator.getGameEnvironment().getGuildManager().removeAdmin(guild, userId); + Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - Habbo habbo = room.getHabbo(userId); GuildRemovedAdminEvent removedAdminEvent = new GuildRemovedAdminEvent(guild, userId, habbo); Emulator.getPluginManager().fireEvent(removedAdminEvent); if (removedAdminEvent.isCancelled()) return; + Emulator.getGameEnvironment().getGuildManager().removeAdmin(guild, userId); + if (habbo != null) { habbo.getClient().sendResponse(new GuildInfoComposer(guild, this.client, false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), userId))); - room.refreshRightsForHabbo(habbo); + if (room != null && habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom() == room) room.refreshRightsForHabbo(habbo); } GuildMember guildMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId); From 992a961814fd2d87d2c00f14d7cca602c4c87e18 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 11 Aug 2019 12:22:18 +0300 Subject: [PATCH 51/77] Add error to badge command if user is not found --- sqlupdates/2_2_0-RC-1_TO_2_2_0-RC-2.sql | 1 + .../habbo/habbohotel/commands/BadgeCommand.java | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 sqlupdates/2_2_0-RC-1_TO_2_2_0-RC-2.sql diff --git a/sqlupdates/2_2_0-RC-1_TO_2_2_0-RC-2.sql b/sqlupdates/2_2_0-RC-1_TO_2_2_0-RC-2.sql new file mode 100644 index 00000000..14a12715 --- /dev/null +++ b/sqlupdates/2_2_0-RC-1_TO_2_2_0-RC-2.sql @@ -0,0 +1 @@ +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_badge.unknown_user', 'Failed to find the given user.'); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java index 7e5e1208..eac670e7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; +import com.eu.habbo.habbohotel.users.HabboManager; import java.sql.Connection; import java.sql.PreparedStatement; @@ -38,11 +40,18 @@ public class BadgeCommand extends Command { return true; } else { + HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(params[1]); + + if (habboInfo == null) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.unknown_user"), RoomChatMessageBubbles.ALERT); + return true; + } + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { boolean found; - try (PreparedStatement statement = connection.prepareStatement("SELECT `badge_code` FROM `users_badges` INNER JOIN `users` ON `users`.`id` = `user_id` WHERE `users`.`username` = ? AND `badge_code` = ? LIMIT 1")) { - statement.setString(1, params[1]); + try (PreparedStatement statement = connection.prepareStatement("SELECT `badge_code` FROM `users_badges` WHERE `user_id` = ? AND `badge_code` = ? LIMIT 1")) { + statement.setInt(1, habboInfo.getId()); statement.setString(2, params[2]); try (ResultSet set = statement.executeQuery()) { found = set.next(); @@ -53,8 +62,8 @@ public class BadgeCommand extends Command { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.already_owns").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT); return true; } else { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (`id`, `user_id`, `slot_id`, `badge_code`) VALUES (null, (SELECT `id` FROM `users` WHERE `username` = ? LIMIT 1), 0, ?)")) { - statement.setString(1, params[1]); + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (`id`, `user_id`, `slot_id`, `badge_code`) VALUES (null, ?, 0, ?)")) { + statement.setInt(1, habboInfo.getId()); statement.setString(2, params[2]); statement.execute(); } From 1bfc2452b7c60faf7d7382ce16caee1987881784 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 11 Aug 2019 12:26:19 +0300 Subject: [PATCH 52/77] Fix NullPointerExceptions --- .../com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java | 2 +- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java index ab57f565..cb3bd3c8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java @@ -14,7 +14,7 @@ public class FreezeGameTeam extends GameTeam { @Override public void removeMember(GamePlayer gamePlayer) { - if (gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null) return; + if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null) return; Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class); Room room = gamePlayer.getHabbo().getRoomUnit().getRoom(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index dcb66cdc..1450878a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4165,6 +4165,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public void unIdle(Habbo habbo) { + if (habbo == null || habbo.getRoomUnit() == null) return; habbo.getRoomUnit().resetIdleTimer(); this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); WiredHandler.handle(WiredTriggerType.UNIDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); From 3177e199606f53d01e99458818781baf72af924d Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 30 Aug 2019 02:25:54 +0100 Subject: [PATCH 53/77] Fixed Wired Exploit, WiredEffectMatchFurni did not check max height. --- .../wired/effects/WiredEffectMatchFurni.java | 3 ++- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index f542b964..e461c25b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -101,7 +101,8 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { tilesToUpdate.addAll(tiles); double offsetZ = highestZ - item.getZ(); - + double totalHeight = item.getZ() + offsetZ; + if(totalHeight > 40) break; tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation)); if (!slideAnimation) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index dcb66cdc..4e69d73a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1478,12 +1478,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (newRoller == null || topItem == newRoller) { List sortedItems = new ArrayList<>(itemsOnRoller); - sortedItems.sort(new Comparator() { - @Override - public int compare(HabboItem o1, HabboItem o2) { - return o1.getZ() > o2.getZ() ? -1 : 1; - } - }); + sortedItems.sort((o1, o2) -> o1.getZ() > o2.getZ() ? -1 : 1); for (HabboItem item : sortedItems) { if (item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) { @@ -4471,9 +4466,11 @@ public class Room implements Comparable, ISerialize, Runnable { } } //Place at new position + double height = this.getStackHeight(tile.x, tile.y, false); + if(height > 40d) return FurnitureMovementError.CANT_STACK; item.setX(tile.x); item.setY(tile.y); - item.setZ(this.getStackHeight(tile.x, tile.y, false, item)); + item.setZ(height); if (magicTile) { item.setZ(tile.z); item.setExtradata("" + item.getZ() * 100); From 634961e0ddf4b3dcdd3c29c2ebedf7e8bf847ea8 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Tue, 10 Sep 2019 21:37:06 +0100 Subject: [PATCH 54/77] Pushed as RC-2. --- src/main/java/com/eu/habbo/Emulator.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 12b0a3d6..7b2cfa5d 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -37,7 +37,7 @@ public final class Emulator { public final static int BUILD = 0; - public final static String PREVIEW = "RC-1"; + public final static String PREVIEW = "RC-2"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -48,7 +48,8 @@ public final class Emulator { " / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" + " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + - " /____/ \n"; + " /____/ \n" + + " 'RC Stands for Race Car.' \n" ; public static String build = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; @@ -165,12 +166,19 @@ public final class Emulator { } private static void setBuild() { + if (Emulator.class.getProtectionDomain().getCodeSource() == null) { + build = "UNKNOWN"; + return; + } StringBuilder sb = new StringBuilder(); try { + String filepath = new File(Emulator.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath(); MessageDigest md = MessageDigest.getInstance("MD5");// MD5 + FileInputStream fis = new FileInputStream(filepath); byte[] dataBytes = new byte[1024]; int nread = 0; + while ((nread = fis.read(dataBytes)) != -1) md.update(dataBytes, 0, nread); byte[] mdbytes = md.digest(); for (int i = 0; i < mdbytes.length; i++) From 35eefc87ef3080987dffecb8d8e5ff6f2fc1eb5c Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Wed, 11 Sep 2019 11:58:44 +0100 Subject: [PATCH 55/77] Fixed Rotation Bug. --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 4bf6938e..d8873053 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4467,7 +4467,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } //Place at new position - double height = this.getStackHeight(tile.x, tile.y, false); + double height = this.getStackHeight(tile.x, tile.y, false, item); if(height > 40d) return FurnitureMovementError.CANT_STACK; item.setX(tile.x); item.setY(tile.y); From b74cd20c9feabcebf0c4f9e623d1875b037977bc Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 27 Sep 2019 20:04:23 +0300 Subject: [PATCH 56/77] Fix NullPointerException --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index d8873053..44555132 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3682,6 +3682,7 @@ public class Room implements Comparable, ISerialize, Runnable { for (Habbo habbo : this.getHabbos()) { if (habbo.getClient() == null) { this.removeHabbo(habbo, true); + continue; } habbo.getClient().sendResponse(message); From cc5b940a4d891881e37d44b47f72f0733fec311a Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 27 Sep 2019 20:15:21 +0300 Subject: [PATCH 57/77] Fix NullPointerException --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 44555132..7dd1b524 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3244,17 +3244,17 @@ public class Room implements Comparable, ISerialize, Runnable { } public THashSet getItemsAt(RoomTile tile) { + THashSet items = new THashSet<>(0); + + if (tile == null) + return items; + if (this.loaded) { if (this.tileCache.containsKey(tile)) { return this.tileCache.get(tile); } } - THashSet items = new THashSet<>(0); - - if (tile == null) - return items; - TIntObjectIterator iterator = this.roomItems.iterator(); for (int i = this.roomItems.size(); i-- > 0; ) { From a0f8869db40cd5db0fa93fc7c4e68f9972d46d91 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 27 Sep 2019 20:21:25 +0300 Subject: [PATCH 58/77] Fix highscore updater --- .../wired/highscores/WiredHighscoreManager.java | 10 ++++++++-- src/main/java/com/eu/habbo/plugin/PluginManager.java | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java index aa5935ef..1873b2de 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.wired.highscores; import com.eu.habbo.Emulator; +import com.eu.habbo.plugin.EventHandler; +import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent; import java.sql.Connection; import java.sql.PreparedStatement; @@ -29,12 +31,16 @@ public class WiredHighscoreManager { this.data.clear(); this.loadHighscoreData(); + Emulator.getLogging().logStart("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); + } + + @EventHandler + public static void onEmulatorLoaded(EmulatorLoadedEvent event) { if (midnightUpdater != null) { midnightUpdater.cancel(true); } + midnightUpdater = Emulator.getThreading().run(new WiredHighscoreMidnightUpdater(), WiredHighscoreMidnightUpdater.getNextUpdaterRun()); - - Emulator.getLogging().logStart("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); } public void dispose() { diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index d1ecfbef..556ae8d4 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -20,12 +20,14 @@ import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; import com.eu.habbo.messages.PacketManager; import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent; import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent; import com.eu.habbo.messages.incoming.users.ChangeNameCheckUsernameEvent; import com.eu.habbo.messages.outgoing.catalog.DiscountComposer; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; +import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; import com.eu.habbo.plugin.events.users.*; import com.eu.habbo.threading.runnables.RoomTrashing; @@ -322,6 +324,7 @@ public class PluginManager { this.methods.add(InteractionFootballGate.class.getMethod("onUserExitRoomEvent", UserExitRoomEvent.class)); this.methods.add(InteractionFootballGate.class.getMethod("onUserSavedLookEvent", UserSavedLookEvent.class)); this.methods.add(PluginManager.class.getMethod("globalOnConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); + this.methods.add(WiredHighscoreManager.class.getMethod("onEmulatorLoaded", EmulatorLoadedEvent.class)); } catch (NoSuchMethodException e) { Emulator.getLogging().logStart("Failed to define default events!"); Emulator.getLogging().logErrorLine(e); From ecc142418f3989e14185477322c29088b421ac92 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sat, 19 Oct 2019 16:50:26 +0100 Subject: [PATCH 59/77] Commited ArpyAge's user teleport fix. --- .../habbo/threading/runnables/teleport/TeleportActionThree.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 7701a546..036ce89c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -65,7 +65,7 @@ class TeleportActionThree implements Runnable { targetTeleport.setExtradata("2"); targetRoom.updateItem(targetTeleport); - targetRoom.updateHabbo(this.client.getHabbo()); + //targetRoom.updateHabbo(this.client.getHabbo()); //System.out.println(targetTeleport.getX() + " | " + targetTeleport.getY()); this.client.getHabbo().getHabboInfo().setCurrentRoom(targetRoom); //Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500); From d77d18b27fadecce859b755a95291962bd7ea79f Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Tue, 17 Dec 2019 12:41:18 +0000 Subject: [PATCH 60/77] Started fixing teleporters - credits to quadral --- src/main/java/com/eu/habbo/Emulator.java | 4 +- .../habbohotel/gameclients/GameClient.java | 169 +++++++++++------- .../interactions/InteractionTeleport.java | 23 ++- .../com/eu/habbo/habbohotel/rooms/Room.java | 62 +++++++ .../teleport/TeleportActionThree.java | 5 +- 5 files changed, 192 insertions(+), 71 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 7b2cfa5d..8130ceaa 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -37,7 +37,7 @@ public final class Emulator { public final static int BUILD = 0; - public final static String PREVIEW = "RC-2"; + public final static String PREVIEW = "RC-3"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -49,7 +49,7 @@ public final class Emulator { " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + " /____/ \n" + - " 'RC Stands for Race Car.' \n" ; + " 'the only emulator with broken teleporters' \n" ; public static String build = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java index 376f910c..943e1b14 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -1,3 +1,22 @@ +/* + * Morning Star + * Copyright (C) 2019 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + package com.eu.habbo.habbohotel.gameclients; import com.eu.habbo.Emulator; @@ -16,114 +35,134 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; -public class GameClient { - - public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); - private final Channel channel; - public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); - private Habbo habbo; - private String machineId = ""; - - public GameClient(Channel channel) { - this.channel = channel; +public class GameClient +{ + /// Constructor + /// @p_Channel : Channel + public GameClient(Channel p_Channel) { + this.m_Channel = p_Channel; } - public void sendResponse(MessageComposer composer) { - if (this.channel.isOpen()) { - try { - ServerMessage msg = composer.compose(); - this.sendResponse(msg); - } catch (Exception e) { - Emulator.getLogging().logPacketError(e); + /// Composer class - Abstract class + /// @p_Composer : Composer + public void sendResponse(MessageComposer p_Composer) { + if (this.m_Channel.isOpen()) + { + try + { + ServerMessage l_ServerMessage = p_Composer.compose(); + this.sendResponse(l_ServerMessage); + + } catch (Exception l_Exception) + { + Emulator.getLogging().logPacketError(l_Exception); } } } - - public void sendResponse(ServerMessage response) { - if (this.channel.isOpen()) { - if (response == null || response.getHeader() <= 0) { + /// Send Raw Response + /// @p_Response : Response + public void sendResponse(ServerMessage p_Response) + { + if (this.m_Channel.isOpen()) + { + if (p_Response == null || p_Response.getHeader() <= 0) + { return; } if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + p_Response.getHeader() + "] -> " + p_Response.getBodyString()); - this.channel.write(response.get(), this.channel.voidPromise()); - this.channel.flush(); + this.m_Channel.write(p_Response.get(), this.m_Channel.voidPromise()); + this.m_Channel.flush(); } } + /// Send packed response + /// @p_Responses : Response Array + public void sendResponses(ArrayList p_Responses) + { + ByteBuf l_Buffer = Unpooled.buffer(); - public void sendResponses(ArrayList responses) { - ByteBuf buffer = Unpooled.buffer(); - - if (this.channel.isOpen()) { - for (ServerMessage response : responses) { - if (response == null || response.getHeader() <= 0) { + if (this.m_Channel.isOpen()) { + for (ServerMessage l_Itr : p_Responses) + { + if (l_Itr == null || l_Itr.getHeader() <= 0) { return; } if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + l_Itr.getHeader() + "] -> " + l_Itr.getBodyString()); - buffer.writeBytes(response.get()); + l_Buffer.writeBytes(l_Itr.get()); } - this.channel.write(buffer.copy(), this.channel.voidPromise()); - this.channel.flush(); + this.m_Channel.write(l_Buffer.copy(), this.m_Channel.voidPromise()); + this.m_Channel.flush(); } - buffer.release(); + l_Buffer.release(); } - + /// Dispose Habbo public void dispose() { - try { - this.channel.close(); - if (this.habbo != null) { - if (this.habbo.isOnline()) { - this.habbo.getHabboInfo().setOnline(false); - this.habbo.disconnect(); + try + { + this.m_Channel.close(); + + if (this.m_Habbo != null) { + if (this.m_Habbo.isOnline()) + { + this.m_Habbo.getHabboInfo().setOnline(false); + this.m_Habbo.disconnect(); } - this.habbo = null; + this.m_Habbo = null; } - } catch (Exception e) { + } catch (Exception e) + { Emulator.getLogging().logErrorLine(e); } } - public Channel getChannel() { - return this.channel; - } + /////////////////////////////////////////// + // GETTERS/SETTERS + /////////////////////////////////////////// - public Habbo getHabbo() { - return this.habbo; - } + public Channel getChannel() { return this.m_Channel; } + public String getMachineId() { return this.m_MachineId; } + public Habbo getHabbo() { return this.m_Habbo; } - public void setHabbo(Habbo habbo) { - this.habbo = habbo; - } - - public String getMachineId() { - return this.machineId; - } - - public void setMachineId(String machineId) { - if (machineId == null) { + public void setHabbo(Habbo p_Habbo) { this.m_Habbo = p_Habbo; } + public void setMachineId(String p_MachineId) + { + if (p_MachineId == null) + { throw new RuntimeException("Cannot set machineID to NULL"); } - this.machineId = machineId; + this.m_MachineId = p_MachineId; - if (this.habbo != null) { + if (this.m_MachineId != null) + { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET machine_id = ? WHERE id = ? LIMIT 1")) { - statement.setString(1, this.machineId); - statement.setInt(2, this.habbo.getHabboInfo().getId()); + statement.setString(1, this.m_MachineId); + statement.setInt(2, this.m_Habbo.getHabboInfo().getId()); statement.execute(); - } catch (SQLException e) { + } catch (SQLException e) + { Emulator.getLogging().logSQLException(e); } } } + + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + + public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); + public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); + + private final Channel m_Channel; + private Habbo m_Habbo; + private String m_MachineId; } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 0106e1b8..041b10cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -17,6 +17,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; + +/// how u find files? where is file search bar on this ide public class InteractionTeleport extends HabboItem { private int targetId; private int targetRoomId; @@ -62,27 +64,37 @@ public class InteractionTeleport extends HabboItem { Habbo habbo = client.getHabbo(); + /// Habbo must exist if (habbo == null) return; + /// Get Unit of habbo (extension class) RoomUnit unit = habbo.getRoomUnit(); + /// Unit must exit - this should be logged as this should never happen if (unit == null) return; + /// Get current tile habbo is standing on RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY()); + /// dont proceed is our current tile is null - this should never happen if (currentLocation == null) return; + /// Get the tile infront RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation()); + /// Check whether we can use the teleport if (!canUseTeleport(client, room)) return; - if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { + if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) + { startTeleport(room, habbo); - } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { + + } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) + { // set state 1 and walk on item this.roomUnitID = unit.getId(); this.setExtradata("1"); @@ -187,19 +199,25 @@ public class InteractionTeleport extends HabboItem { public boolean canUseTeleport(GameClient client, Room room) { + /// Get habbo Habbo habbo = client.getHabbo(); + /// this should never happen.... if (habbo == null) return false; + /// Get extension class RoomUnit unit = habbo.getRoomUnit(); + /// this should never happen... if (unit == null) return false; + /// Habbo cannot use the teleport if riding if (habbo.getHabboInfo().getRiding() != null) return false; + /// check whether the room unit Id is valid return this.roomUnitID == -1 || this.roomUnitID == unit.getId(); } @@ -208,6 +226,7 @@ public class InteractionTeleport extends HabboItem { } public void startTeleport(Room room, Habbo habbo, int delay) { + /// dont teleport if we are already teleporting if (habbo.getRoomUnit().isTeleporting) return; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 7dd1b524..1f6fdfe5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4318,6 +4318,60 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.NO_RIGHTS; } + public HabboItem OverrideItem(HabboItem p_Item, Habbo p_Owner) + { + if (p_Item instanceof InteractionTeleport) + { + TIntObjectIterator l_Itr = this.roomItems.iterator(); + + for (int l_I = 0; l_I < this.roomItems.size(); l_I++) + { + l_Itr.advance(); + + if (l_Itr.value() instanceof InteractionTeleport) + { + InteractionTeleport l_Item = (InteractionTeleport)l_Itr.value(); + + /// If the item matches our hand item, then we have the correct item + if (p_Item.getId() == l_Item.getTargetId()) + { + return p_Item; + } + + /// If the pair item is not placed in the room, check whether its placed in any other rooms + if (this.getHabboItem(l_Item.getTargetId()) == null) + { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT room_id FROM items WHERE id = ?")) + { + statement.setInt(1, l_Item.getTargetId()); + try (ResultSet set = statement.executeQuery()) + { + set.next(); + + /// Check if pair item is placed in any rooms, if not then return that i + if (set.getInt("room_id") == 0) + { + HabboItem l_HandItem = p_Owner.getInventory().getItemsComponent().getHabboItem(l_Item.getTargetId()); + + if (l_HandItem != null) + { + return l_HandItem; + } + } + } + } + catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + } + } + } + + return p_Item; + } + + public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation) { if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) return FurnitureMovementError.INVALID_MOVE; @@ -4368,6 +4422,14 @@ public class Room implements Comparable, ISerialize, Runnable { return fits; } + if (item instanceof InteractionTeleport) + { + InteractionTeleport l_Test = (InteractionTeleport)item; + int hello = 0; + } + + item = this.OverrideItem(item, owner); + item.setZ(tile.getStackHeight()); item.setX(tile.x); item.setY(tile.y); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 036ce89c..31cf5d0a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -65,8 +65,9 @@ class TeleportActionThree implements Runnable { targetTeleport.setExtradata("2"); targetRoom.updateItem(targetTeleport); - //targetRoom.updateHabbo(this.client.getHabbo()); - //System.out.println(targetTeleport.getX() + " | " + targetTeleport.getY()); + targetRoom.updateHabbo(this.client.getHabbo()); + //System.out.println(targetTeleport.getX() + " | " + tokay so basically + // after goargetTeleport.getY()); this.client.getHabbo().getHabboInfo().setCurrentRoom(targetRoom); //Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500); Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500); From 2d83bca51381479e1b34ef6d5bc051c911c29ee9 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Tue, 17 Dec 2019 13:20:58 +0000 Subject: [PATCH 61/77] Wordfilter fix. Credits to Layne, requires more testing. --- .../com/eu/habbo/habbohotel/modtool/WordFilter.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java index b000c0b4..6b214a77 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -72,8 +72,15 @@ public class WordFilter { } public String normalise(String message) { - return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD).replaceAll("[,.;:'\"]", "").replace("I", "l") - .replaceAll("[^\\p{ASCII}*$]", "").replaceAll("\\p{M}", "").replaceAll("^\\p{M}*$]", "").replaceAll("[1|]", "i").replace("2", "z").replace("3", "e").replace("4", "a").replace("5", "s").replace("8", "b").replace("0", "o").replace(" ", "").replace("$", "s").replace("ß", "b").trim()).replaceAll(""); + return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD) + .replaceAll("[,.;:'\"]", " ").replace("I", "l") + .replaceAll("[^\\p{ASCII}*$]", "").replaceAll("\\p{M}", " ") + .replaceAll("^\\p{M}*$]", "").replaceAll("[1|]", "i") + .replace("2", "z").replace("3", "e") + .replace("4", "a").replace("5", "s") + .replace("8", "b").replace("0", "o") + .replace(" ", " ").replace("$", "s") + .replace("ß", "b").trim()).replaceAll(" "); } public boolean autoReportCheck(RoomChatMessage roomChatMessage) { @@ -139,7 +146,7 @@ public class WordFilter { if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) continue; } - filteredMessage = filteredMessage.replaceAll("(?i)" + word.key, word.replacement); + filteredMessage = filteredMessage.replace("(?i)" + word.key, word.replacement); foundShit = true; if (habbo != null && word.muteTime > 0) { From ca5431671528125623b9f12e964d0dd3a1e19dd6 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Wed, 18 Dec 2019 14:49:02 -0500 Subject: [PATCH 62/77] Revert "Started fixing teleporters - credits to quadral" This reverts commit d77d18b27fadecce859b755a95291962bd7ea79f --- src/main/java/com/eu/habbo/Emulator.java | 4 +- .../habbohotel/gameclients/GameClient.java | 169 +++++++----------- .../interactions/InteractionTeleport.java | 23 +-- .../com/eu/habbo/habbohotel/rooms/Room.java | 62 ------- .../teleport/TeleportActionThree.java | 5 +- 5 files changed, 71 insertions(+), 192 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 8130ceaa..7b2cfa5d 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -37,7 +37,7 @@ public final class Emulator { public final static int BUILD = 0; - public final static String PREVIEW = "RC-3"; + public final static String PREVIEW = "RC-2"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -49,7 +49,7 @@ public final class Emulator { " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + " /____/ \n" + - " 'the only emulator with broken teleporters' \n" ; + " 'RC Stands for Race Car.' \n" ; public static String build = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java index 943e1b14..376f910c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -1,22 +1,3 @@ -/* - * Morning Star - * Copyright (C) 2019 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - package com.eu.habbo.habbohotel.gameclients; import com.eu.habbo.Emulator; @@ -35,134 +16,114 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; -public class GameClient -{ - /// Constructor - /// @p_Channel : Channel - public GameClient(Channel p_Channel) { - this.m_Channel = p_Channel; +public class GameClient { + + public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); + private final Channel channel; + public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); + private Habbo habbo; + private String machineId = ""; + + public GameClient(Channel channel) { + this.channel = channel; } - /// Composer class - Abstract class - /// @p_Composer : Composer - public void sendResponse(MessageComposer p_Composer) { - if (this.m_Channel.isOpen()) - { - try - { - ServerMessage l_ServerMessage = p_Composer.compose(); - this.sendResponse(l_ServerMessage); - - } catch (Exception l_Exception) - { - Emulator.getLogging().logPacketError(l_Exception); + public void sendResponse(MessageComposer composer) { + if (this.channel.isOpen()) { + try { + ServerMessage msg = composer.compose(); + this.sendResponse(msg); + } catch (Exception e) { + Emulator.getLogging().logPacketError(e); } } } - /// Send Raw Response - /// @p_Response : Response - public void sendResponse(ServerMessage p_Response) - { - if (this.m_Channel.isOpen()) - { - if (p_Response == null || p_Response.getHeader() <= 0) - { + + public void sendResponse(ServerMessage response) { + if (this.channel.isOpen()) { + if (response == null || response.getHeader() <= 0) { return; } if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + p_Response.getHeader() + "] -> " + p_Response.getBodyString()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString()); - this.m_Channel.write(p_Response.get(), this.m_Channel.voidPromise()); - this.m_Channel.flush(); + this.channel.write(response.get(), this.channel.voidPromise()); + this.channel.flush(); } } - /// Send packed response - /// @p_Responses : Response Array - public void sendResponses(ArrayList p_Responses) - { - ByteBuf l_Buffer = Unpooled.buffer(); - if (this.m_Channel.isOpen()) { - for (ServerMessage l_Itr : p_Responses) - { - if (l_Itr == null || l_Itr.getHeader() <= 0) { + public void sendResponses(ArrayList responses) { + ByteBuf buffer = Unpooled.buffer(); + + if (this.channel.isOpen()) { + for (ServerMessage response : responses) { + if (response == null || response.getHeader() <= 0) { return; } if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + l_Itr.getHeader() + "] -> " + l_Itr.getBodyString()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString()); - l_Buffer.writeBytes(l_Itr.get()); + buffer.writeBytes(response.get()); } - this.m_Channel.write(l_Buffer.copy(), this.m_Channel.voidPromise()); - this.m_Channel.flush(); + this.channel.write(buffer.copy(), this.channel.voidPromise()); + this.channel.flush(); } - l_Buffer.release(); + buffer.release(); } - /// Dispose Habbo + public void dispose() { + try { + this.channel.close(); - try - { - this.m_Channel.close(); - - if (this.m_Habbo != null) { - if (this.m_Habbo.isOnline()) - { - this.m_Habbo.getHabboInfo().setOnline(false); - this.m_Habbo.disconnect(); + if (this.habbo != null) { + if (this.habbo.isOnline()) { + this.habbo.getHabboInfo().setOnline(false); + this.habbo.disconnect(); } - this.m_Habbo = null; + this.habbo = null; } - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - /////////////////////////////////////////// - // GETTERS/SETTERS - /////////////////////////////////////////// + public Channel getChannel() { + return this.channel; + } - public Channel getChannel() { return this.m_Channel; } - public String getMachineId() { return this.m_MachineId; } - public Habbo getHabbo() { return this.m_Habbo; } + public Habbo getHabbo() { + return this.habbo; + } - public void setHabbo(Habbo p_Habbo) { this.m_Habbo = p_Habbo; } - public void setMachineId(String p_MachineId) - { - if (p_MachineId == null) - { + public void setHabbo(Habbo habbo) { + this.habbo = habbo; + } + + public String getMachineId() { + return this.machineId; + } + + public void setMachineId(String machineId) { + if (machineId == null) { throw new RuntimeException("Cannot set machineID to NULL"); } - this.m_MachineId = p_MachineId; + this.machineId = machineId; - if (this.m_MachineId != null) - { + if (this.habbo != null) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET machine_id = ? WHERE id = ? LIMIT 1")) { - statement.setString(1, this.m_MachineId); - statement.setInt(2, this.m_Habbo.getHabboInfo().getId()); + statement.setString(1, this.machineId); + statement.setInt(2, this.habbo.getHabboInfo().getId()); statement.execute(); - } catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); - public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); - - private final Channel m_Channel; - private Habbo m_Habbo; - private String m_MachineId; } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 041b10cc..0106e1b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -17,8 +17,6 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; - -/// how u find files? where is file search bar on this ide public class InteractionTeleport extends HabboItem { private int targetId; private int targetRoomId; @@ -64,37 +62,27 @@ public class InteractionTeleport extends HabboItem { Habbo habbo = client.getHabbo(); - /// Habbo must exist if (habbo == null) return; - /// Get Unit of habbo (extension class) RoomUnit unit = habbo.getRoomUnit(); - /// Unit must exit - this should be logged as this should never happen if (unit == null) return; - /// Get current tile habbo is standing on RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY()); - /// dont proceed is our current tile is null - this should never happen if (currentLocation == null) return; - /// Get the tile infront RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation()); - /// Check whether we can use the teleport if (!canUseTeleport(client, room)) return; - if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) - { + if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { startTeleport(room, habbo); - - } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) - { + } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { // set state 1 and walk on item this.roomUnitID = unit.getId(); this.setExtradata("1"); @@ -199,25 +187,19 @@ public class InteractionTeleport extends HabboItem { public boolean canUseTeleport(GameClient client, Room room) { - /// Get habbo Habbo habbo = client.getHabbo(); - /// this should never happen.... if (habbo == null) return false; - /// Get extension class RoomUnit unit = habbo.getRoomUnit(); - /// this should never happen... if (unit == null) return false; - /// Habbo cannot use the teleport if riding if (habbo.getHabboInfo().getRiding() != null) return false; - /// check whether the room unit Id is valid return this.roomUnitID == -1 || this.roomUnitID == unit.getId(); } @@ -226,7 +208,6 @@ public class InteractionTeleport extends HabboItem { } public void startTeleport(Room room, Habbo habbo, int delay) { - /// dont teleport if we are already teleporting if (habbo.getRoomUnit().isTeleporting) return; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 1f6fdfe5..7dd1b524 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4318,60 +4318,6 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.NO_RIGHTS; } - public HabboItem OverrideItem(HabboItem p_Item, Habbo p_Owner) - { - if (p_Item instanceof InteractionTeleport) - { - TIntObjectIterator l_Itr = this.roomItems.iterator(); - - for (int l_I = 0; l_I < this.roomItems.size(); l_I++) - { - l_Itr.advance(); - - if (l_Itr.value() instanceof InteractionTeleport) - { - InteractionTeleport l_Item = (InteractionTeleport)l_Itr.value(); - - /// If the item matches our hand item, then we have the correct item - if (p_Item.getId() == l_Item.getTargetId()) - { - return p_Item; - } - - /// If the pair item is not placed in the room, check whether its placed in any other rooms - if (this.getHabboItem(l_Item.getTargetId()) == null) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT room_id FROM items WHERE id = ?")) - { - statement.setInt(1, l_Item.getTargetId()); - try (ResultSet set = statement.executeQuery()) - { - set.next(); - - /// Check if pair item is placed in any rooms, if not then return that i - if (set.getInt("room_id") == 0) - { - HabboItem l_HandItem = p_Owner.getInventory().getItemsComponent().getHabboItem(l_Item.getTargetId()); - - if (l_HandItem != null) - { - return l_HandItem; - } - } - } - } - catch (SQLException e) { - Emulator.getLogging().logSQLException(e); - } - } - } - } - } - - return p_Item; - } - - public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation) { if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) return FurnitureMovementError.INVALID_MOVE; @@ -4422,14 +4368,6 @@ public class Room implements Comparable, ISerialize, Runnable { return fits; } - if (item instanceof InteractionTeleport) - { - InteractionTeleport l_Test = (InteractionTeleport)item; - int hello = 0; - } - - item = this.OverrideItem(item, owner); - item.setZ(tile.getStackHeight()); item.setX(tile.x); item.setY(tile.y); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 31cf5d0a..036ce89c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -65,9 +65,8 @@ class TeleportActionThree implements Runnable { targetTeleport.setExtradata("2"); targetRoom.updateItem(targetTeleport); - targetRoom.updateHabbo(this.client.getHabbo()); - //System.out.println(targetTeleport.getX() + " | " + tokay so basically - // after goargetTeleport.getY()); + //targetRoom.updateHabbo(this.client.getHabbo()); + //System.out.println(targetTeleport.getX() + " | " + targetTeleport.getY()); this.client.getHabbo().getHabboInfo().setCurrentRoom(targetRoom); //Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500); Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500); From 12b1b7c2ba30a7be48723d3aadc96f7bbb5d95a2 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 23 Dec 2019 15:12:13 +0200 Subject: [PATCH 63/77] Limit number of furniture in rooms --- .../habbo/habbohotel/rooms/FurnitureMovementError.java | 3 ++- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 9 +++++++++ src/main/java/com/eu/habbo/plugin/PluginManager.java | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java b/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java index 5d806570..be20b9e9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java @@ -12,7 +12,8 @@ public enum FurnitureMovementError { TILE_HAS_PETS("${room.error.cant_set_item}"), TILE_HAS_BOTS("${room.error.cant_set_item}"), MAX_DIMMERS("${room.error.max_dimmers}"), - MAX_SOUNDFURNI("${room.errors.max_soundfurni}"); + MAX_SOUNDFURNI("${room.errors.max_soundfurni}"), + MAX_ITEMS("${room.error.max_furniture}"); public final String errorCode; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 7dd1b524..174cad24 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -105,6 +105,7 @@ public class Room implements Comparable, ISerialize, Runnable { public static boolean HABBO_CHAT_DELAY = false; public static int MAXIMUM_BOTS = 10; public static int MAXIMUM_PETS = 10; + public static int MAXIMUM_FURNI = 2500; public static int HAND_ITEM_TIME = 10; public static int IDLE_CYCLES = 240; public static int IDLE_CYCLES_KICK = 480; @@ -416,6 +417,10 @@ public class Room implements Comparable, ISerialize, Runnable { } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } + + if (this.itemCount() > Room.MAXIMUM_FURNI) { + Emulator.getLogging().logErrorLine("Room ID: " + this.getId() + " has exceeded the furniture limit (" + this.itemCount() + " > " + Room.MAXIMUM_FURNI + ")."); + } } private synchronized void loadWiredData(Connection connection) { @@ -4298,6 +4303,10 @@ public class Room implements Comparable, ISerialize, Runnable { } public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation) { + if (this.itemCount() >= Room.MAXIMUM_FURNI) { + return FurnitureMovementError.MAX_ITEMS; + } + rotation %= 8; if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE)) { return FurnitureMovementError.NONE; diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 556ae8d4..9881701a 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -82,6 +82,7 @@ public class PluginManager { Messenger.MAXIMUM_FRIENDS_HC = Emulator.getConfig().getInt("hotel.max.friends.hc"); Room.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room"); Room.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room"); + Room.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 2500); Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time"); Room.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240); Room.IDLE_CYCLES_KICK = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles.kick", 480); @@ -206,7 +207,7 @@ public class PluginManager { } } - public Event fireEvent(Event event) { + public T fireEvent(T event) { for (Method method : this.methods) { if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(event.getClass())) { try { From 906a0c880cd690f35c788aba99e713b562b35e45 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 23 Dec 2019 15:55:50 +0200 Subject: [PATCH 64/77] Remove extraneous logging --- sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql | 1 + .../habbohotel/items/interactions/InteractionHabboClubGate.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql diff --git a/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql b/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql new file mode 100644 index 00000000..cbb9ce33 --- /dev/null +++ b/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql @@ -0,0 +1 @@ +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.furni.max', '2500'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java index 95c0c496..f9aa57dc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java @@ -32,7 +32,6 @@ public class InteractionHabboClubGate extends InteractionDefault { public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { Habbo habbo = room.getHabbo(roomUnit); - System.out.println(habbo != null && habbo.getHabboStats().hasActiveClub()); return habbo != null && habbo.getHabboStats().hasActiveClub(); } From 3f8762f7bbe68eaa0d4ec335ad3be28316288e22 Mon Sep 17 00:00:00 2001 From: David Silva Date: Mon, 23 Dec 2019 23:54:54 +0000 Subject: [PATCH 65/77] feat(InviteFriendsEvent): filter message --- .../eu/habbo/messages/incoming/friends/InviteFriendsEvent.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java index 185e2d47..a2624748 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java @@ -17,6 +17,8 @@ public class InviteFriendsEvent extends MessageHandler { String message = this.packet.readString(); + message = Emulator.getGameEnvironment().getWordFilter().filter(message, this.client.getHabbo()); + for (int i : userIds) { if (i == 0) continue; From c10a09357216b7ce8aec682e01dea9b03f27dabe Mon Sep 17 00:00:00 2001 From: David Silva Date: Tue, 24 Dec 2019 00:07:33 +0000 Subject: [PATCH 66/77] fix(RoomUnitEffects): add more effects to enum --- .../java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java index 5ae0885e..3be40d28 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java @@ -198,7 +198,11 @@ public enum RoomUnitEffect { WATERINGCAN(192), TRAMPOLINEJUMP(193), TREADMILL(194), - CROSSTRAINER(195); + CROSSTRAINER(195), + STARWARS(196), + FLYINGCARPET(197), + YELLOWDUCK(198), + FLYNGTURTLE(199); private int id; From 1151a6197de19a457b29e79514a7ef5257ec00ab Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 16:53:10 +0000 Subject: [PATCH 67/77] Teleporter Fix - Beny --- .../items/interactions/InteractionTeleport.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 0106e1b8..0720fba6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -21,7 +21,7 @@ public class InteractionTeleport extends HabboItem { private int targetId; private int targetRoomId; private int roomUnitID = -1; - private boolean walkable = false; + private boolean walkable; public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -82,6 +82,7 @@ public class InteractionTeleport extends HabboItem { if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { startTeleport(room, habbo); + walkable = true; } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { // set state 1 and walk on item this.roomUnitID = unit.getId(); @@ -93,11 +94,11 @@ public class InteractionTeleport extends HabboItem { List onFail = new ArrayList(); onSuccess.add(() -> { - walkable = this.getBaseItem().allowWalk(); room.updateTile(currentLocation); tryTeleport(client, room); unit.removeOverrideTile(currentLocation); unit.setCanLeaveRoomByDoor(true); + walkable = this.getBaseItem().allowWalk(); }); onFail.add(() -> { @@ -208,8 +209,10 @@ public class InteractionTeleport extends HabboItem { } public void startTeleport(Room room, Habbo habbo, int delay) { - if (habbo.getRoomUnit().isTeleporting) + if (habbo.getRoomUnit().isTeleporting) { + walkable = this.getBaseItem().allowWalk(); return; + } this.roomUnitID = -1; habbo.getRoomUnit().isTeleporting = true; From cf5283c66f0b8dc83323337b7bdb010f7ac8369e Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 18:13:06 +0000 Subject: [PATCH 68/77] Vote Counters - By Beny --- .../habbo/habbohotel/items/ItemManager.java | 2 + .../interactions/InteractionVoteCounter.java | 106 ++++++++++++++++++ .../rooms/users/RoomUserSignEvent.java | 12 ++ 3 files changed, 120 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index ce313579..e0c533a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -355,6 +355,8 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("snowstorm_tree", null)); this.interactionsList.add(new ItemInteraction("snowstorm_machine", null)); this.interactionsList.add(new ItemInteraction("snowstorm_pile", null)); + + this.interactionsList.add(new ItemInteraction("vote_counter", InteractionVoteCounter.class)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java new file mode 100644 index 00000000..54ea473b --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java @@ -0,0 +1,106 @@ +package com.eu.habbo.habbohotel.items.interactions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.messages.ServerMessage; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class InteractionVoteCounter extends HabboItem { + + private boolean frozen; + private int votes; + private List votedUsers; + + public InteractionVoteCounter(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + if(!this.getExtradata().contains(",")) { + this.setExtradata("1,0"); // frozen,votes + } + + String[] bits = this.getExtradata().split(","); + frozen = bits[0].equals("1"); + votes = Integer.parseInt(bits[1]); + votedUsers = new ArrayList<>(); + } + + public InteractionVoteCounter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + + if(!extradata.contains(",")) { + extradata = "1,0"; + } + + String[] bits = extradata.split(","); + frozen = bits[0].equals("1"); + votes = Integer.parseInt(bits[1]); + votedUsers = new ArrayList<>(); + } + + @Override + public void serializeExtradata(ServerMessage serverMessage) { + serverMessage.appendInt((this.isLimited() ? 256 : 0) + 3); + serverMessage.appendString(this.frozen ? "0" : "1"); + serverMessage.appendInt(this.votes); + super.serializeExtradata(serverMessage); + } + + @Override + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + return false; + } + + @Override + public boolean isWalkable() { + return false; + } + + private void updateExtradata() { + this.setExtradata((this.frozen ? "1" : "0") + "," + this.votes); + } + + @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))) + return; + + this.frozen = !this.frozen; + + if(!frozen) { + this.votes = 0; + this.votedUsers.clear(); + } + + updateExtradata(); + this.needsUpdate(true); + room.updateItem(this); + } + + @Override + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + + } + + public void vote(Room room, int UserId, int vote) { + if(frozen) + return; + + if(votedUsers.contains(UserId)) + return; + + votedUsers.add(UserId); + + votes += vote; + updateExtradata(); + this.needsUpdate(true); + room.updateItem(this); + } +} diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java index 3e1200e6..3b2aaf93 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java @@ -1,8 +1,10 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionVoteCounter; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserSignEvent; @@ -20,6 +22,16 @@ public class RoomUserSignEvent extends MessageHandler { if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.sign + ""); this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo()); + + if(signId <= 10) { + + int userId = this.client.getHabbo().getHabboInfo().getId(); + for (HabboItem item : room.getFloorItems()) { + if (item instanceof InteractionVoteCounter) { + ((InteractionVoteCounter)item).vote(room, userId, signId); + } + } + } } } } From aed6c495b4d4cf8c1f607411f7fced85590a6e1b Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 20:37:25 +0000 Subject: [PATCH 69/77] Effects now work properly in the clothing selector, as well as durations. Credits to Beny --- .../java/com/eu/habbo/core/CleanerThread.java | 4 +- .../items/interactions/InteractionFXBox.java | 37 +++++++++++++------ .../users/inventory/EffectsComponent.java | 11 ++++++ .../inventory/UserEffectsListComposer.java | 14 +++++-- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/eu/habbo/core/CleanerThread.java b/src/main/java/com/eu/habbo/core/CleanerThread.java index 9c174fca..764770d0 100644 --- a/src/main/java/com/eu/habbo/core/CleanerThread.java +++ b/src/main/java/com/eu/habbo/core/CleanerThread.java @@ -147,8 +147,8 @@ public class CleanerThread implements Runnable { statement.execute("DELETE users_favorite_rooms FROM users_favorite_rooms LEFT JOIN rooms ON room_id = rooms.id WHERE rooms.id IS NULL"); } - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp < ? AND activation_timestamp != 0")) { - statement.setInt(1, Emulator.getIntUnixTimestamp() - 86400); + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp + duration < ? AND activation_timestamp > 0 AND duration > 0")) { + statement.setInt(1, Emulator.getIntUnixTimestamp()); statement.execute(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java index f68a0aa8..3b579a54 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java @@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; +import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; @@ -15,41 +17,54 @@ import java.sql.SQLException; public class InteractionFXBox extends InteractionDefault { public InteractionFXBox(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + // this.setExtradata("0"); } public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + // this.setExtradata("0"); } @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null && room.hasRights(client.getHabbo())) { + if (client != null && this.getUserId() == client.getHabbo().getHabboInfo().getId()) { + if(this.getExtradata().equals("1")) + return; + + int effectId = -1; + if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.M)) { if (this.getBaseItem().getEffectM() > 0) { - room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); + effectId = this.getBaseItem().getEffectM(); } } if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.F)) { if (this.getBaseItem().getEffectF() > 0) { - room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); + effectId = this.getBaseItem().getEffectF(); } } + if(effectId < 0) + return; + + if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) + return; + + EffectsComponent.HabboEffect effect = client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId, 0); + client.sendResponse(new UserEffectsListComposer(client.getHabbo())); + client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId); + this.setExtradata("1"); room.updateItemState(this); room.removeHabboItem(this); HabboItem item = this; - Emulator.getThreading().run(new Runnable() { - @Override - public void run() { - new QueryDeleteHabboItem(item.getId()).run(); - room.sendComposer(new RemoveFloorItemComposer(item).compose()); - } + Emulator.getThreading().run(() -> { + new QueryDeleteHabboItem(item.getId()).run(); + room.sendComposer(new RemoveFloorItemComposer(item).compose()); + room.updateTile(room.getLayout().getTile(this.getX(), this.getY())); }, 500); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java index 6be7b4dd..b0da325b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java @@ -34,6 +34,10 @@ public class EffectsComponent { } public HabboEffect createEffect(int effectId) { + return createEffect(effectId, 86400); + } + + public HabboEffect createEffect(int effectId, int duration) { HabboEffect effect; synchronized (this.effects) { if (this.effects.containsKey(effectId)) { @@ -44,6 +48,7 @@ public class EffectsComponent { } } else { effect = new HabboEffect(effectId, this.habbo.getHabboInfo().getId()); + effect.duration = duration; effect.insert(); } @@ -159,6 +164,9 @@ public class EffectsComponent { } public boolean isRemaining() { + if(this.duration <= 0) + return true; + if (this.total > 0) { if (this.activationTimestamp >= 0) { if (Emulator.getIntUnixTimestamp() - this.activationTimestamp >= this.duration) { @@ -172,6 +180,9 @@ public class EffectsComponent { } public int remainingTime() { + if(this.duration <= 0) //permanant + return Integer.MAX_VALUE; + return Emulator.getIntUnixTimestamp() - this.activationTimestamp + this.duration; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java index 9fa470af..157c53c9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java @@ -27,10 +27,16 @@ public class UserEffectsListComposer extends MessageComposer { this.habbo.getInventory().getEffectsComponent().effects.forEachValue(effect -> { UserEffectsListComposer.this.response.appendInt(effect.effect); UserEffectsListComposer.this.response.appendInt(0); - UserEffectsListComposer.this.response.appendInt(effect.duration); - UserEffectsListComposer.this.response.appendInt(effect.total); - UserEffectsListComposer.this.response.appendInt(effect.activationTimestamp >= 0 ? Emulator.getIntUnixTimestamp() - effect.activationTimestamp : -1); - UserEffectsListComposer.this.response.appendBoolean(effect.isActivated()); + UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? effect.duration : 1); + UserEffectsListComposer.this.response.appendInt(effect.total - (effect.isActivated() ? 1 : 0)); + + if(!effect.isActivated()) { + UserEffectsListComposer.this.response.appendInt(0); + } + else { + UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? (Emulator.getIntUnixTimestamp() - effect.activationTimestamp) + effect.duration : -1); + } + UserEffectsListComposer.this.response.appendBoolean(effect.duration <= 0); //effect.isActivated()); return true; }); } From 4086127fba7687903e94c3416df232944a437336 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 20:40:13 +0000 Subject: [PATCH 70/77] RC-3 Completed. Ready for testing. --- src/main/java/com/eu/habbo/Emulator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 7b2cfa5d..bacb369a 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -37,7 +37,7 @@ public final class Emulator { public final static int BUILD = 0; - public final static String PREVIEW = "RC-2"; + public final static String PREVIEW = "RC-3"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -49,7 +49,7 @@ public final class Emulator { " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + " /____/ \n" + - " 'RC Stands for Race Car.' \n" ; + " 'The boiz are back in town.' \n" ; public static String build = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; @@ -136,7 +136,7 @@ public final class Emulator { Emulator.getThreading().run(() -> { - Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a 2.2.0 RC-1 Build. If you find any bugs please place them on our git repository."); + Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a 2.2.0 RC-3 Build. If you find any bugs please place them on our git repository."); Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: "); Emulator.getLogging().logStart("https://discord.gg/syuqgN"); Emulator.getLogging().logStart("Please report bugs on our git at Krews.org. Not on our discord!!"); From 45e52f165b61f5ed238f2507ef1a26a95f925415 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 20:43:04 +0000 Subject: [PATCH 71/77] Added SQL for vote counters. --- sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql b/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql index cbb9ce33..90e2028c 100644 --- a/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql +++ b/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql @@ -1 +1,2 @@ -INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.furni.max', '2500'); \ No newline at end of file +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.furni.max', '2500'); +UPDATE items_base SET interaction_type = 'vote_counter' WHERE item_name = 'vote_count_add'; \ No newline at end of file From 7bd31aed7b0ec696cf3cca4fabadc700b31fe7cc Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 27 Dec 2019 14:38:45 +0200 Subject: [PATCH 72/77] Modify HabboAddedToRoomEvent --- .../habbo/habbohotel/rooms/RoomManager.java | 21 +++++++++++++------ .../events/users/HabboAddedToRoomEvent.java | 6 +++++- 2 files changed, 20 insertions(+), 7 deletions(-) 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 d1c9a692..9157886e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.core.RoomUserPetComposer; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; import com.eu.habbo.habbohotel.games.football.FootballGame; @@ -40,6 +41,7 @@ import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer; +import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent; import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent; import com.eu.habbo.plugin.events.rooms.UserVoteRoomEvent; @@ -710,9 +712,20 @@ public class RoomManager { List habbos = new ArrayList<>(); if (!room.getCurrentHabbos().isEmpty()) { + Collection habbosToSendEnter = room.getCurrentHabbos().values(); - room.sendComposer(new RoomUsersComposer(habbo).compose()); - room.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); + if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) { + HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter)); + habbosToSendEnter = event.habbosToSendEnter; + } + + for (Habbo habboToSendEnter : habbosToSendEnter) { + GameClient client = habboToSendEnter.getClient(); + if (client != null) { + client.sendResponse(new RoomUsersComposer(habbo).compose()); + habboToSendEnter.getClient().sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); + } + } for (Habbo h : room.getHabbos()) { if (!h.getRoomUnit().isInvisible()) { @@ -890,10 +903,6 @@ public class RoomManager { if (!habbo.getHabboStats().nux && (room.isOwner(habbo) || room.isPublicRoom())) { UserNuxEvent.handle(habbo); } - - if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) { - Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room)); - } } void logEnter(Habbo habbo, Room room) { diff --git a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java index be861f8a..d31f4a6c 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java @@ -3,14 +3,18 @@ package com.eu.habbo.plugin.events.users; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; +import java.util.Collection; + public class HabboAddedToRoomEvent extends UserEvent { public final Room room; + public final Collection habbosToSendEnter; - public HabboAddedToRoomEvent(Habbo habbo, Room room) { + public HabboAddedToRoomEvent(Habbo habbo, Room room, Collection habbosToSendEnter) { super(habbo); this.room = room; + this.habbosToSendEnter = habbosToSendEnter; } } From 9f8850b0bd20b2995e883b8f46733a655eec83de Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 27 Dec 2019 17:41:55 +0200 Subject: [PATCH 73/77] Add annotation to mark messages that don't need auth --- .../com/eu/habbo/messages/NoAuthMessage.java | 7 +++++++ .../com/eu/habbo/messages/PacketManager.java | 17 +++++++++++++---- .../incoming/handshake/MachineIDEvent.java | 2 ++ .../incoming/handshake/ReleaseVersionEvent.java | 2 ++ .../incoming/handshake/SecureLoginEvent.java | 2 ++ 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/eu/habbo/messages/NoAuthMessage.java diff --git a/src/main/java/com/eu/habbo/messages/NoAuthMessage.java b/src/main/java/com/eu/habbo/messages/NoAuthMessage.java new file mode 100644 index 00000000..47487068 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/NoAuthMessage.java @@ -0,0 +1,7 @@ +package com.eu.habbo.messages; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface NoAuthMessage {} diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 989a6e6d..d5e2eb8e 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -156,11 +156,20 @@ public class PacketManager { if (client == null || Emulator.isShuttingDown) return; - if (client.getHabbo() == null && !(packet.getMessageId() == Incoming.SecureLoginEvent || packet.getMessageId() == Incoming.MachineIDEvent)) - return; - try { if (this.isRegistered(packet.getMessageId())) { + Class handlerClass = this.incoming.get(packet.getMessageId()); + + if (handlerClass == null) throw new Exception("Unknown message " + packet.getMessageId()); + + if (client.getHabbo() == null && !handlerClass.isAnnotationPresent(NoAuthMessage.class)) { + if (DEBUG_SHOW_PACKETS) { + Emulator.getLogging().logPacketLine("[\033[36mCLIENT\033[0m][\033[33mNOT LOGGED IN\033[0m][" + packet.getMessageId() + "] => " + packet.getMessageBody()); + } + + return; + } + if (PacketManager.DEBUG_SHOW_PACKETS) Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); @@ -168,7 +177,7 @@ public class PacketManager { System.out.println(("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + client.getHabbo().getHabboInfo().getUsername() + "][" + packet.getMessageId() + "] => " + packet.getMessageBody())); } - final MessageHandler handler = this.incoming.get(packet.getMessageId()).newInstance(); + final MessageHandler handler = handlerClass.newInstance(); handler.client = client; handler.packet = packet; diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java index fd50c886..7be07c04 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java @@ -1,8 +1,10 @@ package com.eu.habbo.messages.incoming.handshake; +import com.eu.habbo.messages.NoAuthMessage; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.handshake.MachineIDComposer; +@NoAuthMessage public class MachineIDEvent extends MessageHandler { @Override diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java index 4dfe71ae..e9ea57e1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java @@ -1,7 +1,9 @@ package com.eu.habbo.messages.incoming.handshake; +import com.eu.habbo.messages.NoAuthMessage; import com.eu.habbo.messages.incoming.MessageHandler; +@NoAuthMessage public class ReleaseVersionEvent extends MessageHandler { @Override diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index a899c5b0..6759a1e6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboManager; +import com.eu.habbo.messages.NoAuthMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.achievements.AchievementListComposer; @@ -31,6 +32,7 @@ import com.eu.habbo.plugin.events.users.UserLoginEvent; import java.util.ArrayList; +@NoAuthMessage public class SecureLoginEvent extends MessageHandler { From ab6d1ccac611708512f78e99307e901e54104cdb Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sat, 28 Dec 2019 01:52:09 +0000 Subject: [PATCH 74/77] Totems --- .../habbo/habbohotel/items/ItemManager.java | 7 ++ .../totems/InteractionTotemHead.java | 85 +++++++++++++++++++ .../totems/InteractionTotemLegs.java | 56 ++++++++++++ .../totems/InteractionTotemPlanet.java | 85 +++++++++++++++++++ .../items/interactions/totems/TotemColor.java | 24 ++++++ .../interactions/totems/TotemPlanetType.java | 22 +++++ .../items/interactions/totems/TotemType.java | 24 ++++++ .../rooms/items/ToggleFloorItemEvent.java | 3 +- 8 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index e0c533a7..a2d7f55c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -38,6 +38,9 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun.Interaction import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagPole; import com.eu.habbo.habbohotel.items.interactions.games.tag.rollerskate.InteractionRollerskateField; +import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemHead; +import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemLegs; +import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemPlanet; import com.eu.habbo.habbohotel.items.interactions.wired.conditions.*; import com.eu.habbo.habbohotel.items.interactions.wired.effects.*; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; @@ -357,6 +360,10 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("snowstorm_pile", null)); this.interactionsList.add(new ItemInteraction("vote_counter", InteractionVoteCounter.class)); + + this.interactionsList.add(new ItemInteraction("totem_leg", InteractionTotemLegs.class)); + this.interactionsList.add(new ItemInteraction("totem_head", InteractionTotemHead.class)); + this.interactionsList.add(new ItemInteraction("totem_planet", InteractionTotemPlanet.class)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java new file mode 100644 index 00000000..65036015 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java @@ -0,0 +1,85 @@ +package com.eu.habbo.habbohotel.items.interactions.totems; + +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredEffectType; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionTotemHead extends InteractionDefault { + + public InteractionTotemHead(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public InteractionTotemHead(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + public TotemType getTotemType() { + int extraData = Integer.parseInt(this.getExtradata()); + if(extraData < 3) { + return TotemType.fromInt(extraData + 1); + } + return TotemType.fromInt((int)Math.ceil((extraData - 2) / 4.0f)); + } + + public TotemColor getTotemColor() { + int extraData = Integer.parseInt(this.getExtradata()); + if(extraData < 3) { + return TotemColor.NONE; + } + return TotemColor.fromInt(extraData - 3 - (4 * (getTotemType().type - 1))); + } + + private void update(Room room, RoomTile tile) { + InteractionTotemLegs legs = null; + + for(HabboItem item : room.getItemsAt(tile)) { + if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) + legs = (InteractionTotemLegs)item; + } + + if(legs == null) + return; + + this.setExtradata(((4 * this.getTotemType().type) + legs.getTotemColor().color) - 1 + ""); + } + + public void updateTotemState(Room room) { + updateTotemState(room, room.getLayout().getTile(this.getX(), this.getY())); + } + + public void updateTotemState(Room room, RoomTile tile) { + this.setExtradata(getTotemType().type - 1 + ""); + update(room, tile); + this.needsUpdate(true); + room.updateItem(this); + } + + @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))) + return; + + TotemType newType = TotemType.fromInt(getTotemType().type + 1); + if(newType == TotemType.NONE) { + newType = TotemType.TROLL; + } + + this.setExtradata(newType.type - 1 + ""); + + updateTotemState(room); + } + + @Override + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + super.onMove(room, oldLocation, newLocation); + updateTotemState(room, newLocation); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java new file mode 100644 index 00000000..4070a876 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java @@ -0,0 +1,56 @@ +package com.eu.habbo.habbohotel.items.interactions.totems; + +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredEffectType; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionTotemLegs extends InteractionDefault { + public InteractionTotemLegs(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public InteractionTotemLegs(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + public TotemType getTotemType() { + int extraData = Integer.parseInt(this.getExtradata()); + return TotemType.fromInt((int)Math.ceil((extraData + 1) / 4.0f)); + } + + public TotemColor getTotemColor() { + int extraData = Integer.parseInt(this.getExtradata()); + return TotemColor.fromInt(extraData - (4 * (getTotemType().type - 1))); + } + + private void updateHead(Room room, RoomTile tile) { + for(HabboItem item : room.getItemsAt(tile)) { + if(item instanceof InteractionTotemHead && item.getZ() > this.getZ()) + ((InteractionTotemHead)item).updateTotemState(room); + } + } + + @Override + 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))) + return; + + updateHead(room, room.getLayout().getTile(this.getX(), this.getY())); + } + + @Override + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + super.onMove(room, oldLocation, newLocation); + + updateHead(room, oldLocation); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java new file mode 100644 index 00000000..bff2b26c --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java @@ -0,0 +1,85 @@ +package com.eu.habbo.habbohotel.items.interactions.totems; + +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; +import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer; +import gnu.trove.set.hash.THashSet; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionTotemPlanet extends InteractionDefault { + public InteractionTotemPlanet(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public InteractionTotemPlanet(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + public TotemPlanetType getPlanetType() { + int extraData = Integer.parseInt(this.getExtradata()); + return TotemPlanetType.fromInt(extraData); + } + + @Override + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + InteractionTotemLegs legs = null; + InteractionTotemHead head = null; + + THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); + + for(HabboItem item : items) { + if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) + legs = (InteractionTotemLegs)item; + } + + if(legs == null) { + super.onClick(client, room, objects); + return; + } + + for(HabboItem item : items) { + if(item instanceof InteractionTotemHead && item.getZ() > legs.getZ()) + head = (InteractionTotemHead)item; + } + + if(head == null) { + super.onClick(client, room, objects); + return; + } + + int effectId = 0; + + if(getPlanetType() == TotemPlanetType.SUN && head.getTotemType() == TotemType.BIRD && legs.getTotemType() == TotemType.BIRD && legs.getTotemColor() == TotemColor.RED) { + effectId = 25; + } + else if(getPlanetType() == TotemPlanetType.EARTH && head.getTotemType() == TotemType.TROLL && legs.getTotemType() == TotemType.TROLL && legs.getTotemColor() == TotemColor.YELLOW) { + effectId = 23; + } + else if(getPlanetType() == TotemPlanetType.EARTH && head.getTotemType() == TotemType.SNAKE && legs.getTotemType() == TotemType.BIRD && legs.getTotemColor() == TotemColor.YELLOW) { + effectId = 26; + } + else if(getPlanetType() == TotemPlanetType.MOON && head.getTotemType() == TotemType.SNAKE && legs.getTotemType() == TotemType.SNAKE && legs.getTotemColor() == TotemColor.BLUE) { + effectId = 24; + } + + if(effectId > 0) { + if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) { + client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId); + return; + } + + client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId); + client.sendResponse(new UserEffectsListComposer(client.getHabbo())); + client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId); + return; + } + + super.onClick(client, room, objects); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java new file mode 100644 index 00000000..340bb47f --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java @@ -0,0 +1,24 @@ +package com.eu.habbo.habbohotel.items.interactions.totems; + +public enum TotemColor { + + NONE(0), + RED(1), + YELLOW(2), + BLUE(3); + + public final int color; + + TotemColor(int color) { + this.color = color; + } + + public static TotemColor fromInt(int color) { + for(TotemColor totemColor : TotemColor.values()) { + if(totemColor.color == color) + return totemColor; + } + + return NONE; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java new file mode 100644 index 00000000..bf8c7378 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java @@ -0,0 +1,22 @@ +package com.eu.habbo.habbohotel.items.interactions.totems; + +public enum TotemPlanetType { + MOON(0), + SUN(1), + EARTH(2); + + public final int type; + + TotemPlanetType(int type) { + this.type = type; + } + + public static TotemPlanetType fromInt(int type) { + for(TotemPlanetType planetType : TotemPlanetType.values()) { + if(planetType.type == type) + return planetType; + } + + return MOON; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java new file mode 100644 index 00000000..b82d909b --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java @@ -0,0 +1,24 @@ +package com.eu.habbo.habbohotel.items.interactions.totems; + +public enum TotemType { + + NONE(0), + TROLL(1), + SNAKE(2), + BIRD(3); + + public final int type; + + TotemType(int type) { + this.type = type; + } + + public static TotemType fromInt(int type) { + for(TotemType totemType : TotemType.values()) { + if(totemType.type == type) + return totemType; + } + + return NONE; + } +} diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java index 66f02e49..c64d111e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java @@ -31,6 +31,7 @@ public class ToggleFloorItemEvent extends MessageHandler { if (item == null || item instanceof InteractionDice) return; + /* if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) { THashSet items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY())); HabboItem totemLeg = null; @@ -75,7 +76,7 @@ public class ToggleFloorItemEvent extends MessageHandler { } } } - } + }*/ //Do not move to onClick(). Wired could trigger it. if (item instanceof InteractionMonsterPlantSeed) { From 427fc9fb2488cd53fa69ad781a7dc4937f2bb17c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 2 Jan 2020 11:03:06 +0200 Subject: [PATCH 75/77] Update PacketManager logging --- src/main/java/com/eu/habbo/messages/PacketManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index d5e2eb8e..7cda01db 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -164,7 +164,7 @@ public class PacketManager { if (client.getHabbo() == null && !handlerClass.isAnnotationPresent(NoAuthMessage.class)) { if (DEBUG_SHOW_PACKETS) { - Emulator.getLogging().logPacketLine("[\033[36mCLIENT\033[0m][\033[33mNOT LOGGED IN\033[0m][" + packet.getMessageId() + "] => " + packet.getMessageBody()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + Logging.ANSI_RED + "NOT LOGGED IN" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); } return; @@ -193,7 +193,7 @@ public class PacketManager { } } else { if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + Logging.ANSI_RED + "UNDEFINED" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + Logging.ANSI_YELLOW + "UNDEFINED" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); } } catch (Exception e) { Emulator.getLogging().logErrorLine(e); From cf4a6856573831b60d79bddad5a11f8432c3194a Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 3 Jan 2020 18:05:19 +0000 Subject: [PATCH 76/77] TODO: Fix Moving Large Furniture, which causes disconnections. Temp Fix by Beny. --- .../outgoing/rooms/UpdateStackHeightComposer.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java index 4f6c3b67..5a99f16c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java @@ -25,8 +25,21 @@ public class UpdateStackHeightComposer extends MessageComposer { @Override public ServerMessage compose() { + //TODO: THIS IS A TEMP FIX. THERE IS AN ISSUE WITH BAD PACKET STRUCTURE HERE CAUSING ISSUES WITH MOVING LARGE FURNITURE this.response.init(Outgoing.UpdateStackHeightComposer); if (this.updateTiles != null) { + if(this.updateTiles.size() > 4) { + RoomTile[] tiles = (RoomTile[])this.updateTiles.toArray(); + this.response.appendByte(4); + for(int i = 0; i < 4; i++) { + RoomTile t = tiles[i]; + this.response.appendByte((int) t.x); + this.response.appendByte((int) t.y); + this.response.appendShort(t.relativeHeight()); + } + return this.response; + } + this.response.appendByte(this.updateTiles.size()); for (RoomTile t : this.updateTiles) { this.response.appendByte((int) t.x); From 8f2f15b367a68d8c385f91de444d4d88bdacc6ac Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Tue, 14 Jan 2020 19:45:11 +0000 Subject: [PATCH 77/77] 2.2.0 Stable. Boom. Credits to Alejandro, Beny, Harmonic, Layne and everyone at Krews.org --- src/main/java/com/eu/habbo/Emulator.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index bacb369a..24b0d0b8 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -37,7 +37,7 @@ public final class Emulator { public final static int BUILD = 0; - public final static String PREVIEW = "RC-3"; + public final static String PREVIEW = "Stable"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -48,8 +48,7 @@ public final class Emulator { " / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" + " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + - " /____/ \n" + - " 'The boiz are back in town.' \n" ; + " /____/ \n" ; public static String build = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; @@ -115,8 +114,7 @@ public final class Emulator { Emulator.rconServer.initializePipeline(); Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); - Emulator.getLogging().logStart("Habbo Hotel Emulator has succesfully loaded."); - Emulator.getLogging().logStart("You're running: " + Emulator.version); + Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version); Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!"); Emulator.getLogging().logStart("Memory: " + (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024) + "/" + (runtime.freeMemory()) / (1024 * 1024) + "MB"); @@ -136,10 +134,9 @@ public final class Emulator { Emulator.getThreading().run(() -> { - Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a 2.2.0 RC-3 Build. If you find any bugs please place them on our git repository."); Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: "); Emulator.getLogging().logStart("https://discord.gg/syuqgN"); - Emulator.getLogging().logStart("Please report bugs on our git at Krews.org. Not on our discord!!"); + Emulator.getLogging().logStart("Please report bugs on our git at Krews.org."); System.out.println("Waiting for commands: "); }, 1500);