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 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] 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 6/6] 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));