You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-19 15:06:19 +00:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 281fede58c | |||
| edf152485b | |||
| 18a1bfbe90 | |||
| 7c32bbfd2d | |||
| 4eae206b64 | |||
| 155b2202c7 | |||
| 10c291eb9f | |||
| 349a8c727e | |||
| 68f2b71d14 | |||
| 69a6c0d060 | |||
| 885bdca0c4 | |||
| db035294a7 | |||
| 3216ba1df6 | |||
| c9a47b1fac | |||
| 8d6b969d75 | |||
| b9723e0298 | |||
| c4aae676b2 | |||
| 7624d3fbc3 | |||
| 585f4dd3aa | |||
| afa114d511 | |||
| e9129576a9 | |||
| 0aadd01493 | |||
| 9d98fbf9ee | |||
| b38274e134 | |||
| 02ab30180c | |||
| da63439d53 |
@@ -322,13 +322,6 @@ CREATE TABLE IF NOT EXISTS `custom_prefix_settings` (
|
|||||||
PRIMARY KEY (`key_name`)
|
PRIMARY KEY (`key_name`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `custom_prefix_blacklist` (
|
|
||||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`word` VARCHAR(100) NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `uk_custom_prefix_blacklist_word` (`word`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
||||||
|
|
||||||
INSERT IGNORE INTO `custom_prefix_settings` (`key_name`, `value`) VALUES
|
INSERT IGNORE INTO `custom_prefix_settings` (`key_name`, `value`) VALUES
|
||||||
('max_length', '15'),
|
('max_length', '15'),
|
||||||
('min_rank_to_buy', '1'),
|
('min_rank_to_buy', '1'),
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS `habbo_mentions` (
|
||||||
|
`id` INT NOT NULL AUTO_INCREMENT,
|
||||||
|
`target_user_id` INT NOT NULL,
|
||||||
|
`sender_user_id` INT NOT NULL,
|
||||||
|
`sender_username` VARCHAR(64) NOT NULL DEFAULT '',
|
||||||
|
`room_id` INT NOT NULL,
|
||||||
|
`room_name` VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
|
`message` VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
|
`mention_type` TINYINT NOT NULL DEFAULT 0,
|
||||||
|
`timestamp` INT NOT NULL DEFAULT 0,
|
||||||
|
`read` TINYINT NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
INDEX `idx_target_read` (`target_user_id`, `read`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `emulator_settings` (`key`, `value`) VALUES
|
||||||
|
('mentions.enabled', '1'),
|
||||||
|
('mentions.room.aliases', 'amici,friends,all,everyone,tutti,room,stanza'),
|
||||||
|
('mentions.max.targets', '50'),
|
||||||
|
('mentions.cooldown.ms', '3000'),
|
||||||
|
('mentions.store.limit', '50');
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE `wordfilter`
|
||||||
|
ADD COLUMN `prefix_only` ENUM('0','1') NOT NULL DEFAULT '0'
|
||||||
|
COMMENT 'When 1, this word only applies to custom prefixes, not to chat/motto/guild.' AFTER `mute`;
|
||||||
@@ -63,15 +63,6 @@ CREATE TABLE IF NOT EXISTS `custom_prefix_settings` (
|
|||||||
PRIMARY KEY (`key_name`)
|
PRIMARY KEY (`key_name`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
-- ------------------------------------------------------------
|
|
||||||
-- 5. Blacklist table
|
|
||||||
-- ------------------------------------------------------------
|
|
||||||
CREATE TABLE IF NOT EXISTS `custom_prefix_blacklist` (
|
|
||||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`word` VARCHAR(100) NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `uk_word` (`word`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- Schema upgrades for existing installations
|
-- Schema upgrades for existing installations
|
||||||
@@ -296,14 +287,6 @@ INSERT IGNORE INTO `custom_prefixes_catalog`
|
|||||||
(2, 'Legend', 'Legend', '#8B5CF6', '', 'discord-neon', '', 15, 0, 1, 2),
|
(2, 'Legend', 'Legend', '#8B5CF6', '', 'discord-neon', '', 15, 0, 1, 2),
|
||||||
(3, 'Staff Pick', 'Staff', '#3B82F6', '*', 'cartoon', '', 20, 0, 1, 3);
|
(3, 'Staff Pick', 'Staff', '#3B82F6', '*', 'cartoon', '', 20, 0, 1, 3);
|
||||||
|
|
||||||
-- ============================================================
|
|
||||||
-- Example blacklist entries
|
|
||||||
-- ============================================================
|
|
||||||
INSERT IGNORE INTO `custom_prefix_blacklist` (`word`) VALUES
|
|
||||||
('admin'),
|
|
||||||
('staff'),
|
|
||||||
('mod'),
|
|
||||||
('owner');
|
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
-- Notes
|
-- Notes
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.eu.habbo</groupId>
|
<groupId>com.eu.habbo</groupId>
|
||||||
<artifactId>Habbo</artifactId>
|
<artifactId>Habbo</artifactId>
|
||||||
<version>4.2.26</version>
|
<version>4.2.31</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.campaign.calendar.CalendarManager;
|
|||||||
import com.eu.habbo.habbohotel.catalog.CatalogManager;
|
import com.eu.habbo.habbohotel.catalog.CatalogManager;
|
||||||
import com.eu.habbo.habbohotel.wheel.WheelManager;
|
import com.eu.habbo.habbohotel.wheel.WheelManager;
|
||||||
import com.eu.habbo.habbohotel.soundboard.SoundboardManager;
|
import com.eu.habbo.habbohotel.soundboard.SoundboardManager;
|
||||||
|
import com.eu.habbo.habbohotel.mentions.MentionManager;
|
||||||
import com.eu.habbo.habbohotel.commands.CommandHandler;
|
import com.eu.habbo.habbohotel.commands.CommandHandler;
|
||||||
import com.eu.habbo.habbohotel.crafting.CraftingManager;
|
import com.eu.habbo.habbohotel.crafting.CraftingManager;
|
||||||
import com.eu.habbo.habbohotel.guides.GuideManager;
|
import com.eu.habbo.habbohotel.guides.GuideManager;
|
||||||
@@ -68,6 +69,7 @@ public class GameEnvironment {
|
|||||||
private InfostandBackgroundManager infostandBackgroundManager;
|
private InfostandBackgroundManager infostandBackgroundManager;
|
||||||
private WheelManager wheelManager;
|
private WheelManager wheelManager;
|
||||||
private SoundboardManager soundboardManager;
|
private SoundboardManager soundboardManager;
|
||||||
|
private MentionManager mentionManager;
|
||||||
|
|
||||||
public void load() throws Exception {
|
public void load() throws Exception {
|
||||||
LOGGER.info("GameEnvironment -> Loading...");
|
LOGGER.info("GameEnvironment -> Loading...");
|
||||||
@@ -99,6 +101,7 @@ public class GameEnvironment {
|
|||||||
this.infostandBackgroundManager = new InfostandBackgroundManager();
|
this.infostandBackgroundManager = new InfostandBackgroundManager();
|
||||||
this.wheelManager = new WheelManager();
|
this.wheelManager = new WheelManager();
|
||||||
this.soundboardManager = new SoundboardManager();
|
this.soundboardManager = new SoundboardManager();
|
||||||
|
this.mentionManager = new MentionManager();
|
||||||
|
|
||||||
this.roomManager.loadPublicRooms();
|
this.roomManager.loadPublicRooms();
|
||||||
this.navigatorManager.loadNavigator();
|
this.navigatorManager.loadNavigator();
|
||||||
@@ -202,6 +205,10 @@ public class GameEnvironment {
|
|||||||
return this.petManager;
|
return this.petManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MentionManager getMentionManager() {
|
||||||
|
return this.mentionManager;
|
||||||
|
}
|
||||||
|
|
||||||
public AchievementManager getAchievementManager() {
|
public AchievementManager getAchievementManager() {
|
||||||
return this.achievementManager;
|
return this.achievementManager;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,7 +301,6 @@ public class CommandHandler {
|
|||||||
addCommand(new GivePrefixCommand());
|
addCommand(new GivePrefixCommand());
|
||||||
addCommand(new ListPrefixesCommand());
|
addCommand(new ListPrefixesCommand());
|
||||||
addCommand(new RemovePrefixCommand());
|
addCommand(new RemovePrefixCommand());
|
||||||
addCommand(new PrefixBlacklistCommand());
|
|
||||||
addCommand(new WiredCommand());
|
addCommand(new WiredCommand());
|
||||||
addCommand(new TestCommand());
|
addCommand(new TestCommand());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.modtool.WordFilter;
|
import com.eu.habbo.habbohotel.modtool.WordFilter;
|
||||||
import com.eu.habbo.habbohotel.modtool.WordFilterWord;
|
import com.eu.habbo.habbohotel.modtool.WordFilterWord;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -21,30 +22,44 @@ public class FilterWordCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||||
if (params.length < 2) {
|
if (params.length < 2) {
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_filterword.missing_word"));
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_filterword.missing_word"), RoomChatMessageBubbles.ALERT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String word = params[1];
|
String word = params[1];
|
||||||
|
|
||||||
|
// Optional trailing "prefix" keyword marks the word as prefix-only (blocks
|
||||||
|
// custom prefixes but not chat/motto/guild). Usage:
|
||||||
|
// :filterword <word> -> everywhere, default replacement
|
||||||
|
// :filterword <word> <replacement> -> everywhere
|
||||||
|
// :filterword <word> prefix -> prefix-only, default replacement
|
||||||
|
// :filterword <word> <replacement> prefix -> prefix-only
|
||||||
|
boolean prefixOnly = false;
|
||||||
String replacement = WordFilter.DEFAULT_REPLACEMENT;
|
String replacement = WordFilter.DEFAULT_REPLACEMENT;
|
||||||
if (params.length == 3) {
|
|
||||||
replacement = params[2];
|
if (params.length >= 3) {
|
||||||
|
if (params[params.length - 1].equalsIgnoreCase("prefix")) {
|
||||||
|
prefixOnly = true;
|
||||||
|
if (params.length >= 4) replacement = params[2];
|
||||||
|
} else {
|
||||||
|
replacement = params[2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WordFilterWord wordFilterWord = new WordFilterWord(word, replacement);
|
WordFilterWord wordFilterWord = new WordFilterWord(word, replacement, prefixOnly);
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO wordfilter (`key`, `replacement`) VALUES (?, ?)")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO wordfilter (`key`, `replacement`, `prefix_only`) VALUES (?, ?, ?)")) {
|
||||||
statement.setString(1, word);
|
statement.setString(1, word);
|
||||||
statement.setString(2, replacement);
|
statement.setString(2, replacement);
|
||||||
|
statement.setString(3, prefixOnly ? "1" : "0");
|
||||||
statement.execute();
|
statement.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("Caught SQL exception", e);
|
LOGGER.error("Caught SQL exception", e);
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_filterword.error"));
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_filterword.error"), RoomChatMessageBubbles.ALERT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_filterword.added").replace("%word%", word).replace("%replacement%", replacement));
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_filterword.added").replace("%word%", word).replace("%replacement%", replacement) + (prefixOnly ? " [prefix-only]" : ""), RoomChatMessageBubbles.ALERT);
|
||||||
Emulator.getGameEnvironment().getWordFilter().addWord(wordFilterWord);
|
Emulator.getGameEnvironment().getWordFilter().addWord(wordFilterWord);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
package com.eu.habbo.habbohotel.commands;
|
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class PrefixBlacklistCommand extends Command {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PrefixBlacklistCommand.class);
|
|
||||||
|
|
||||||
public PrefixBlacklistCommand() {
|
|
||||||
super("cmd_prefix_blacklist", Emulator.getTexts().getValue("commands.keys.cmd_prefix_blacklist").split(";"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
|
||||||
if (params.length < 2) {
|
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_prefix_blacklist.usage"), RoomChatMessageBubbles.ALERT);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String action = params[1].toLowerCase();
|
|
||||||
|
|
||||||
if (action.equals("list")) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(Emulator.getTexts().getValue("commands.succes.cmd_prefix_blacklist.header")).append("\r");
|
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT word FROM custom_prefix_blacklist ORDER BY word")) {
|
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
|
||||||
int count = 0;
|
|
||||||
while (set.next()) {
|
|
||||||
sb.append("- ").append(set.getString("word")).append("\r");
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (count == 0) {
|
|
||||||
sb.append(Emulator.getTexts().getValue("commands.succes.cmd_prefix_blacklist.empty"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
LOGGER.error("Error listing prefix blacklist", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
gameClient.getHabbo().whisper(sb.toString(), RoomChatMessageBubbles.ALERT);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.length < 3) {
|
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_prefix_blacklist.usage"), RoomChatMessageBubbles.ALERT);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String word = params[2].toLowerCase().trim();
|
|
||||||
|
|
||||||
if (word.isEmpty()) {
|
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_prefix_blacklist.empty_word"), RoomChatMessageBubbles.ALERT);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action.equals("add")) {
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO custom_prefix_blacklist (word) VALUES (?)")) {
|
|
||||||
statement.setString(1, word);
|
|
||||||
statement.execute();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
LOGGER.error("Error adding prefix blacklist word", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
gameClient.getHabbo().whisper(
|
|
||||||
Emulator.getTexts().getValue("commands.succes.cmd_prefix_blacklist.added").replace("%word%", word),
|
|
||||||
RoomChatMessageBubbles.ALERT
|
|
||||||
);
|
|
||||||
} else if (action.equals("remove")) {
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
|
||||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM custom_prefix_blacklist WHERE word = ?")) {
|
|
||||||
statement.setString(1, word);
|
|
||||||
statement.execute();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
LOGGER.error("Error removing prefix blacklist word", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
gameClient.getHabbo().whisper(
|
|
||||||
Emulator.getTexts().getValue("commands.succes.cmd_prefix_blacklist.removed").replace("%word%", word),
|
|
||||||
RoomChatMessageBubbles.ALERT
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_prefix_blacklist.usage"), RoomChatMessageBubbles.ALERT);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -252,6 +252,25 @@ public class Guild implements Runnable {
|
|||||||
return this.readForum;
|
return this.readForum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canHabboReadForum(int habboId, GuildMember member, boolean staff) {
|
||||||
|
if (staff || this.getOwnerId() == habboId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (this.readForum) {
|
||||||
|
case EVERYONE:
|
||||||
|
return true;
|
||||||
|
case MEMBERS:
|
||||||
|
return member != null && member.getRank().type <= GuildRank.MEMBER.type;
|
||||||
|
case ADMINS:
|
||||||
|
return member != null && member.getRank().type < GuildRank.MEMBER.type;
|
||||||
|
case OWNER:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setReadForum(SettingsState readForum) {
|
public void setReadForum(SettingsState readForum) {
|
||||||
this.readForum = readForum;
|
this.readForum = readForum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package com.eu.habbo.habbohotel.mentions;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class HabboMention {
|
||||||
|
|
||||||
|
public static final int TYPE_DIRECT = 0;
|
||||||
|
public static final int TYPE_ROOM = 1;
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
private final int targetUserId;
|
||||||
|
private final int senderUserId;
|
||||||
|
private final String senderUsername;
|
||||||
|
private final int roomId;
|
||||||
|
private final String roomName;
|
||||||
|
private final String message;
|
||||||
|
private final int mentionType;
|
||||||
|
private final int timestamp;
|
||||||
|
private final boolean read;
|
||||||
|
|
||||||
|
public HabboMention(ResultSet set) throws SQLException {
|
||||||
|
this.id = set.getInt("id");
|
||||||
|
this.targetUserId = set.getInt("target_user_id");
|
||||||
|
this.senderUserId = set.getInt("sender_user_id");
|
||||||
|
this.senderUsername = set.getString("sender_username");
|
||||||
|
this.roomId = set.getInt("room_id");
|
||||||
|
this.roomName = set.getString("room_name");
|
||||||
|
this.message = set.getString("message");
|
||||||
|
this.mentionType = set.getInt("mention_type");
|
||||||
|
this.timestamp = set.getInt("timestamp");
|
||||||
|
this.read = set.getInt("read") == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HabboMention(int targetUserId, int id, Habbo sender, Room room, String roomName, String message, int mentionType, int timestamp) {
|
||||||
|
this.id = id;
|
||||||
|
this.targetUserId = targetUserId;
|
||||||
|
this.senderUserId = sender.getHabboInfo().getId();
|
||||||
|
this.senderUsername = sender.getHabboInfo().getUsername();
|
||||||
|
this.roomId = room.getId();
|
||||||
|
this.roomName = roomName;
|
||||||
|
this.message = message;
|
||||||
|
this.mentionType = mentionType;
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.read = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTargetUserId() {
|
||||||
|
return this.targetUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSenderUserId() {
|
||||||
|
return this.senderUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSenderUsername() {
|
||||||
|
return this.senderUsername;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRoomId() {
|
||||||
|
return this.roomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoomName() {
|
||||||
|
return this.roomName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return this.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMentionType() {
|
||||||
|
return this.mentionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimestamp() {
|
||||||
|
return this.timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRead() {
|
||||||
|
return this.read;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
package com.eu.habbo.habbohotel.mentions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomChatType;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class MentionManager {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(MentionManager.class);
|
||||||
|
|
||||||
|
private final ConcurrentHashMap<Integer, Long> cooldowns = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return Emulator.getConfig().getInt("mentions.enabled", 1) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<String> roomAliases() {
|
||||||
|
Set<String> aliases = new HashSet<>();
|
||||||
|
String raw = Emulator.getConfig().getValue("mentions.room.aliases", "amici,friends,all,everyone,tutti,room,stanza");
|
||||||
|
for (String alias : raw.split(",")) {
|
||||||
|
String trimmed = alias.trim().toLowerCase();
|
||||||
|
if (!trimmed.isEmpty()) {
|
||||||
|
aliases.add(trimmed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(Habbo sender, Room room, String message, RoomChatType type) {
|
||||||
|
try {
|
||||||
|
if (!this.isEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender == null || room == null || message == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.isEmpty() || message.indexOf('@') < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int senderId = sender.getHabboInfo().getId();
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
long cooldownMs = Emulator.getConfig().getInt("mentions.cooldown.ms", 3000);
|
||||||
|
Long last = this.cooldowns.get(senderId);
|
||||||
|
if (last != null && (now - last) < cooldownMs) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> aliases = this.roomAliases();
|
||||||
|
boolean roomBroadcast = false;
|
||||||
|
LinkedHashSet<String> directTokens = new LinkedHashSet<>();
|
||||||
|
|
||||||
|
for (String token : message.split("\\s+")) {
|
||||||
|
if (token.length() < 2 || token.charAt(0) != '@') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String raw = token.substring(1);
|
||||||
|
String aliasCandidate = trimTrailingPunctuation(raw).toLowerCase();
|
||||||
|
|
||||||
|
if (!aliasCandidate.isEmpty() && aliases.contains(aliasCandidate)) {
|
||||||
|
roomBroadcast = true;
|
||||||
|
} else if (!raw.isEmpty()) {
|
||||||
|
directTokens.add(raw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!roomBroadcast && directTokens.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxTargets = Emulator.getConfig().getInt("mentions.max.targets", 50);
|
||||||
|
|
||||||
|
List<Habbo> targets = new ArrayList<>();
|
||||||
|
Set<Integer> seen = new HashSet<>();
|
||||||
|
|
||||||
|
if (roomBroadcast) {
|
||||||
|
for (Habbo habbo : room.getHabbos()) {
|
||||||
|
if (habbo == null || habbo.getHabboInfo().getId() == senderId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (seen.add(habbo.getHabboInfo().getId())) {
|
||||||
|
targets.add(habbo);
|
||||||
|
}
|
||||||
|
if (targets.size() >= maxTargets) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (String token : directTokens) {
|
||||||
|
Habbo habbo = this.resolveHabbo(room, token);
|
||||||
|
if (habbo == null || habbo.getHabboInfo().getId() == senderId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (seen.add(habbo.getHabboInfo().getId())) {
|
||||||
|
targets.add(habbo);
|
||||||
|
}
|
||||||
|
if (targets.size() >= maxTargets) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targets.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cooldowns.put(senderId, now);
|
||||||
|
|
||||||
|
int mentionType = roomBroadcast ? HabboMention.TYPE_ROOM : HabboMention.TYPE_DIRECT;
|
||||||
|
int timestamp = Emulator.getIntUnixTimestamp();
|
||||||
|
String roomName = room.getName();
|
||||||
|
|
||||||
|
String storedMessage = message;
|
||||||
|
if (storedMessage.length() > 255) {
|
||||||
|
storedMessage = storedMessage.substring(0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Habbo target : targets) {
|
||||||
|
this.store(target, sender, room, storedMessage, mentionType, timestamp, roomName);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error("Failed to process mentions.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void store(Habbo target, Habbo sender, Room room, String message, int mentionType, int timestamp, String roomName) {
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
|
PreparedStatement statement = connection.prepareStatement(
|
||||||
|
"INSERT INTO habbo_mentions (target_user_id, sender_user_id, sender_username, room_id, room_name, message, mention_type, timestamp, `read`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0)",
|
||||||
|
Statement.RETURN_GENERATED_KEYS)) {
|
||||||
|
statement.setInt(1, target.getHabboInfo().getId());
|
||||||
|
statement.setInt(2, sender.getHabboInfo().getId());
|
||||||
|
statement.setString(3, sender.getHabboInfo().getUsername());
|
||||||
|
statement.setInt(4, room.getId());
|
||||||
|
statement.setString(5, roomName);
|
||||||
|
statement.setString(6, message);
|
||||||
|
statement.setInt(7, mentionType);
|
||||||
|
statement.setInt(8, timestamp);
|
||||||
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
int generatedId = 0;
|
||||||
|
try (ResultSet keys = statement.getGeneratedKeys()) {
|
||||||
|
if (keys.next()) {
|
||||||
|
generatedId = keys.getInt(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HabboMention mention = new HabboMention(target.getHabboInfo().getId(), generatedId, sender, room, roomName, message, mentionType, timestamp);
|
||||||
|
|
||||||
|
if (target.getClient() != null) {
|
||||||
|
target.getClient().sendResponse(new com.eu.habbo.messages.outgoing.mentions.MentionReceivedComposer(mention));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error("Failed to store mention.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HabboMention> getMentions(int userId, int limit) {
|
||||||
|
List<HabboMention> mentions = new ArrayList<>();
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
|
PreparedStatement statement = connection.prepareStatement(
|
||||||
|
"SELECT * FROM habbo_mentions WHERE target_user_id = ? ORDER BY id DESC LIMIT ?")) {
|
||||||
|
statement.setInt(1, userId);
|
||||||
|
statement.setInt(2, limit);
|
||||||
|
try (ResultSet set = statement.executeQuery()) {
|
||||||
|
while (set.next()) {
|
||||||
|
mentions.add(new HabboMention(set));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error("Failed to load mentions.", e);
|
||||||
|
}
|
||||||
|
return mentions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void markRead(int userId, int mode, int mentionId) {
|
||||||
|
String query = mode == 1
|
||||||
|
? "UPDATE habbo_mentions SET `read` = 1 WHERE target_user_id = ? AND id = ?"
|
||||||
|
: "UPDATE habbo_mentions SET `read` = 1 WHERE target_user_id = ?";
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
|
PreparedStatement statement = connection.prepareStatement(query)) {
|
||||||
|
statement.setInt(1, userId);
|
||||||
|
if (mode == 1) {
|
||||||
|
statement.setInt(2, mentionId);
|
||||||
|
}
|
||||||
|
statement.executeUpdate();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error("Failed to mark mentions as read.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(int userId, int mentionId) {
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
|
PreparedStatement statement = connection.prepareStatement(
|
||||||
|
"DELETE FROM habbo_mentions WHERE target_user_id = ? AND id = ?")) {
|
||||||
|
statement.setInt(1, userId);
|
||||||
|
statement.setInt(2, mentionId);
|
||||||
|
statement.executeUpdate();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error("Failed to delete mention.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String TRAILING_PUNCTUATION = ".,!?;:)]}\"'";
|
||||||
|
|
||||||
|
private static String trimTrailingPunctuation(String value) {
|
||||||
|
int end = value.length();
|
||||||
|
while (end > 0 && TRAILING_PUNCTUATION.indexOf(value.charAt(end - 1)) >= 0) {
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
return value.substring(0, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a present room occupant from a raw mention token. Tries the token
|
||||||
|
* verbatim first (so usernames containing allowed punctuation such as '-',
|
||||||
|
* '.', '!' still match), then falls back to a trailing-punctuation-trimmed
|
||||||
|
* form so a mention written as "@Bob!" still resolves the user "Bob".
|
||||||
|
*/
|
||||||
|
private Habbo resolveHabbo(Room room, String rawToken) {
|
||||||
|
Habbo habbo = room.getHabbo(rawToken);
|
||||||
|
if (habbo != null) {
|
||||||
|
return habbo;
|
||||||
|
}
|
||||||
|
String trimmed = trimTrailingPunctuation(rawToken);
|
||||||
|
if (!trimmed.isEmpty() && !trimmed.equals(rawToken)) {
|
||||||
|
return room.getHabbo(trimmed);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,6 @@ public class WordFilter {
|
|||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WordFilter.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(WordFilter.class);
|
||||||
|
|
||||||
private static final Pattern DIACRITICS_AND_FRIENDS = Pattern.compile("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+");
|
private static final Pattern DIACRITICS_AND_FRIENDS = Pattern.compile("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+");
|
||||||
//Configuration. Loaded from database & updated accordingly.
|
|
||||||
public static boolean ENABLED_FRIENDCHAT = true;
|
public static boolean ENABLED_FRIENDCHAT = true;
|
||||||
public static String DEFAULT_REPLACEMENT = "bobba";
|
public static String DEFAULT_REPLACEMENT = "bobba";
|
||||||
protected THashSet<WordFilterWord> autoReportWords = new THashSet<>();
|
protected THashSet<WordFilterWord> autoReportWords = new THashSet<>();
|
||||||
@@ -63,10 +62,12 @@ public class WordFilter {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (word.autoReport)
|
if (!word.prefixOnly) {
|
||||||
this.autoReportWords.add(word);
|
if (word.autoReport)
|
||||||
else if (word.hideMessage)
|
this.autoReportWords.add(word);
|
||||||
this.hideMessageWords.add(word);
|
else if (word.hideMessage)
|
||||||
|
this.hideMessageWords.add(word);
|
||||||
|
}
|
||||||
|
|
||||||
this.words.add(word);
|
this.words.add(word);
|
||||||
}
|
}
|
||||||
@@ -146,6 +147,8 @@ public class WordFilter {
|
|||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
WordFilterWord word = (WordFilterWord) iterator.next();
|
WordFilterWord word = (WordFilterWord) iterator.next();
|
||||||
|
|
||||||
|
if (word.prefixOnly) continue;
|
||||||
|
|
||||||
if (StringUtils.containsIgnoreCase(filteredMessage, word.key)) {
|
if (StringUtils.containsIgnoreCase(filteredMessage, word.key)) {
|
||||||
if (habbo != null) {
|
if (habbo != null) {
|
||||||
if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
|
if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
|
||||||
@@ -179,6 +182,8 @@ public class WordFilter {
|
|||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
WordFilterWord word = (WordFilterWord) iterator.next();
|
WordFilterWord word = (WordFilterWord) iterator.next();
|
||||||
|
|
||||||
|
if (word.prefixOnly) continue;
|
||||||
|
|
||||||
if (StringUtils.containsIgnoreCase(message, word.key)) {
|
if (StringUtils.containsIgnoreCase(message, word.key)) {
|
||||||
if (habbo != null) {
|
if (habbo != null) {
|
||||||
if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
|
if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class WordFilterWord {
|
|||||||
public final boolean hideMessage;
|
public final boolean hideMessage;
|
||||||
public final boolean autoReport;
|
public final boolean autoReport;
|
||||||
public final int muteTime;
|
public final int muteTime;
|
||||||
|
public final boolean prefixOnly;
|
||||||
|
|
||||||
public WordFilterWord(ResultSet set) throws SQLException {
|
public WordFilterWord(ResultSet set) throws SQLException {
|
||||||
this.key = set.getString("key");
|
this.key = set.getString("key");
|
||||||
@@ -16,13 +17,27 @@ public class WordFilterWord {
|
|||||||
this.hideMessage = set.getInt("hide") == 1;
|
this.hideMessage = set.getInt("hide") == 1;
|
||||||
this.autoReport = set.getInt("report") == 1;
|
this.autoReport = set.getInt("report") == 1;
|
||||||
this.muteTime = set.getInt("mute");
|
this.muteTime = set.getInt("mute");
|
||||||
|
this.prefixOnly = readBooleanColumn(set, "prefix_only");
|
||||||
}
|
}
|
||||||
|
|
||||||
public WordFilterWord(String key, String replacement) {
|
public WordFilterWord(String key, String replacement) {
|
||||||
|
this(key, replacement, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordFilterWord(String key, String replacement, boolean prefixOnly) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.replacement = replacement;
|
this.replacement = replacement;
|
||||||
this.hideMessage = false;
|
this.hideMessage = false;
|
||||||
this.autoReport = false;
|
this.autoReport = false;
|
||||||
this.muteTime = 0;
|
this.muteTime = 0;
|
||||||
|
this.prefixOnly = prefixOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean readBooleanColumn(ResultSet set, String column) {
|
||||||
|
try {
|
||||||
|
return set.getInt(column) == 1;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,18 @@ public class RoomChatMessageBubbles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static RoomChatMessageBubbles getBubble(int id) {
|
public static RoomChatMessageBubbles getBubble(int id) {
|
||||||
return BUBBLES.getOrDefault(id, NORMAL);
|
RoomChatMessageBubbles bubble = BUBBLES.get(id);
|
||||||
|
if (bubble != null) return bubble;
|
||||||
|
|
||||||
|
// Custom chat bubbles (client-side only, e.g. ids 253+) are not registered
|
||||||
|
// above. Instead of falling back to NORMAL (which made them render as the
|
||||||
|
// default bubble), pass the id through so the server relays it as-is and
|
||||||
|
// the client renders its own .bubble-<id> style. Capped to avoid abuse.
|
||||||
|
if (id > 0 && id <= 1000) {
|
||||||
|
return new RoomChatMessageBubbles(id, "CUSTOM_" + id, "", true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerBubble(RoomChatMessageBubbles bubble) {
|
private static void registerBubble(RoomChatMessageBubbles bubble) {
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.StringJoiner;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
@@ -330,26 +332,88 @@ public class WheelManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void savePrize(int id, String type, String value, int amount, int pointsType, int weight, String label) {
|
/**
|
||||||
|
* Persists a single prize. An {@code id <= 0} inserts a brand-new prize and
|
||||||
|
* returns its generated id; a positive id updates the existing row (and
|
||||||
|
* re-enables it, so a previously soft-deleted prize can be brought back).
|
||||||
|
* {@code sortOrder} reflects the prize's position in the editor so the
|
||||||
|
* wheel layout matches what the admin sees. Returns the effective row id,
|
||||||
|
* or {@code 0} if the write failed.
|
||||||
|
*/
|
||||||
|
public int savePrize(int id, String type, String value, int amount, int pointsType, int weight, String label, int sortOrder) {
|
||||||
String safeType = (type != null && VALID_PRIZE_TYPES.contains(type)) ? type : "nothing";
|
String safeType = (type != null && VALID_PRIZE_TYPES.contains(type)) ? type : "nothing";
|
||||||
String safeValue = truncate(value, MAX_STRING_LEN);
|
String safeValue = truncate(value, MAX_STRING_LEN);
|
||||||
String safeLabel = truncate(label, MAX_STRING_LEN);
|
String safeLabel = truncate(label, MAX_STRING_LEN);
|
||||||
int safeAmount = clamp(amount, 0, MAX_PRIZE_AMOUNT);
|
int safeAmount = clamp(amount, 0, MAX_PRIZE_AMOUNT);
|
||||||
int safeWeight = clamp(weight, 0, MAX_WEIGHT);
|
int safeWeight = clamp(weight, 0, MAX_WEIGHT);
|
||||||
|
int safeSort = clamp(sortOrder, 0, MAX_PRIZES_PER_SAVE);
|
||||||
|
|
||||||
|
if (id > 0) {
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
|
PreparedStatement statement = connection.prepareStatement(
|
||||||
|
"UPDATE wheel_prizes SET type = ?, value = ?, amount = ?, points_type = ?, weight = ?, label = ?, sort_order = ?, enabled = 1 WHERE id = ?")) {
|
||||||
|
statement.setString(1, safeType);
|
||||||
|
statement.setString(2, safeValue);
|
||||||
|
statement.setInt(3, safeAmount);
|
||||||
|
statement.setInt(4, pointsType);
|
||||||
|
statement.setInt(5, safeWeight);
|
||||||
|
statement.setString(6, safeLabel);
|
||||||
|
statement.setInt(7, safeSort);
|
||||||
|
statement.setInt(8, id);
|
||||||
|
statement.executeUpdate();
|
||||||
|
return id;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error("Failed to save wheel prize {}", id, e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
PreparedStatement statement = connection.prepareStatement(
|
PreparedStatement statement = connection.prepareStatement(
|
||||||
"UPDATE wheel_prizes SET type = ?, value = ?, amount = ?, points_type = ?, weight = ?, label = ? WHERE id = ?")) {
|
"INSERT INTO wheel_prizes (type, value, amount, points_type, weight, label, enabled, sort_order) VALUES (?, ?, ?, ?, ?, ?, 1, ?)",
|
||||||
|
Statement.RETURN_GENERATED_KEYS)) {
|
||||||
statement.setString(1, safeType);
|
statement.setString(1, safeType);
|
||||||
statement.setString(2, safeValue);
|
statement.setString(2, safeValue);
|
||||||
statement.setInt(3, safeAmount);
|
statement.setInt(3, safeAmount);
|
||||||
statement.setInt(4, pointsType);
|
statement.setInt(4, pointsType);
|
||||||
statement.setInt(5, safeWeight);
|
statement.setInt(5, safeWeight);
|
||||||
statement.setString(6, safeLabel);
|
statement.setString(6, safeLabel);
|
||||||
statement.setInt(7, id);
|
statement.setInt(7, safeSort);
|
||||||
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
try (ResultSet keys = statement.getGeneratedKeys()) {
|
||||||
|
if (keys.next()) return keys.getInt(1);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error("Failed to insert wheel prize", e);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Soft-deletes every enabled prize whose id is not in {@code keptIds} by
|
||||||
|
* setting {@code enabled = 0}. This is intentionally non-destructive: rows
|
||||||
|
* stay in the table (so historical references and re-enabling remain
|
||||||
|
* possible) but {@link #loadPrizes()} only ever loads {@code enabled = 1}.
|
||||||
|
* An empty set disables all prizes.
|
||||||
|
*/
|
||||||
|
public void disablePrizesNotIn(Set<Integer> keptIds) {
|
||||||
|
if (keptIds == null) return;
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder("UPDATE wheel_prizes SET enabled = 0 WHERE enabled = 1");
|
||||||
|
if (!keptIds.isEmpty()) {
|
||||||
|
StringJoiner ids = new StringJoiner(",", " AND id NOT IN (", ")");
|
||||||
|
for (Integer keptId : keptIds) {
|
||||||
|
ids.add(Integer.toString(keptId));
|
||||||
|
}
|
||||||
|
sql.append(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
|
PreparedStatement statement = connection.prepareStatement(sql.toString())) {
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("Failed to save wheel prize {}", id, e);
|
LOGGER.error("Failed to disable removed wheel prizes", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import com.eu.habbo.messages.incoming.hotelview.*;
|
|||||||
import com.eu.habbo.messages.incoming.inventory.*;
|
import com.eu.habbo.messages.incoming.inventory.*;
|
||||||
import com.eu.habbo.messages.incoming.inventory.nickicons.*;
|
import com.eu.habbo.messages.incoming.inventory.nickicons.*;
|
||||||
import com.eu.habbo.messages.incoming.inventory.prefixes.*;
|
import com.eu.habbo.messages.incoming.inventory.prefixes.*;
|
||||||
|
import com.eu.habbo.messages.incoming.mentions.*;
|
||||||
import com.eu.habbo.messages.incoming.modtool.*;
|
import com.eu.habbo.messages.incoming.modtool.*;
|
||||||
import com.eu.habbo.messages.incoming.navigator.*;
|
import com.eu.habbo.messages.incoming.navigator.*;
|
||||||
import com.eu.habbo.messages.incoming.polls.AnswerPollEvent;
|
import com.eu.habbo.messages.incoming.polls.AnswerPollEvent;
|
||||||
@@ -426,6 +427,9 @@ public class PacketManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void registerRooms() throws Exception {
|
void registerRooms() throws Exception {
|
||||||
|
this.registerHandler(Incoming.RequestMentionsEvent, RequestMentionsEvent.class);
|
||||||
|
this.registerHandler(Incoming.MarkMentionsReadEvent, MarkMentionsReadEvent.class);
|
||||||
|
this.registerHandler(Incoming.DeleteMentionEvent, DeleteMentionEvent.class);
|
||||||
this.registerHandler(Incoming.RequestRoomLoadEvent, RequestRoomLoadEvent.class);
|
this.registerHandler(Incoming.RequestRoomLoadEvent, RequestRoomLoadEvent.class);
|
||||||
this.registerHandler(Incoming.RequestHeightmapEvent, RequestRoomHeightmapEvent.class);
|
this.registerHandler(Incoming.RequestHeightmapEvent, RequestRoomHeightmapEvent.class);
|
||||||
this.registerHandler(Incoming.RequestRoomHeightmapEvent, RequestRoomHeightmapEvent.class);
|
this.registerHandler(Incoming.RequestRoomHeightmapEvent, RequestRoomHeightmapEvent.class);
|
||||||
|
|||||||
@@ -496,4 +496,7 @@ public class Incoming {
|
|||||||
public static final int WheelAdminSavePrizesEvent = 9305;
|
public static final int WheelAdminSavePrizesEvent = 9305;
|
||||||
public static final int SoundboardPlayEvent = 9306;
|
public static final int SoundboardPlayEvent = 9306;
|
||||||
public static final int SoundboardSetEnabledEvent = 9307;
|
public static final int SoundboardSetEnabledEvent = 9307;
|
||||||
|
public static final int RequestMentionsEvent = 4803;
|
||||||
|
public static final int MarkMentionsReadEvent = 4804;
|
||||||
|
public static final int DeleteMentionEvent = 4805;
|
||||||
}
|
}
|
||||||
|
|||||||
+47
-37
@@ -25,45 +25,55 @@ public class GuildAcceptMembershipEvent extends MessageHandler {
|
|||||||
int userId = this.packet.readInt();
|
int userId = this.packet.readInt();
|
||||||
|
|
||||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
||||||
|
|
||||||
|
if (guild == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuildMember actorMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
|
||||||
|
boolean canAccept = guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()
|
||||||
|
|| this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)
|
||||||
|
|| (actorMember != null && (actorMember.getRank().equals(GuildRank.ADMIN) || actorMember.getRank().equals(GuildRank.OWNER)));
|
||||||
|
|
||||||
|
if (!canAccept) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuildMember targetMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId);
|
||||||
|
|
||||||
|
if (targetMember == null) {
|
||||||
|
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.NO_LONGER_MEMBER));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetMember.getRank().type != GuildRank.REQUESTED.type) {
|
||||||
|
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.ALREADY_ACCEPTED));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||||
|
|
||||||
if (guild != null) {
|
GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo);
|
||||||
GuildMember groupMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
|
Emulator.getPluginManager().fireEvent(event);
|
||||||
if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()
|
|
||||||
|| this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)
|
if (event.isCancelled()) {
|
||||||
|| (groupMember != null && (groupMember.getRank().equals(GuildRank.ADMIN) || groupMember.getRank().equals(GuildRank.OWNER)))) {
|
return;
|
||||||
if (habbo != null) {
|
}
|
||||||
if (habbo.getHabboStats().hasGuild(guild.getId())) {
|
|
||||||
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.ALREADY_ACCEPTED));
|
if (habbo != null) {
|
||||||
return;
|
habbo.getHabboStats().addGuild(guild.getId());
|
||||||
} else {
|
}
|
||||||
//Check the user has requested
|
|
||||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo);
|
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true);
|
||||||
if (member == null || member.getRank().type != GuildRank.REQUESTED.type) {
|
guild.decreaseRequestCount();
|
||||||
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.NO_LONGER_MEMBER));
|
guild.increaseMemberCount();
|
||||||
return;
|
this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
|
||||||
} else {
|
|
||||||
GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo);
|
if (habbo != null) {
|
||||||
Emulator.getPluginManager().fireEvent(event);
|
Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||||
if (!event.isCancelled()) {
|
if (room != null && room.getGuildId() == guildId) {
|
||||||
habbo.getHabboStats().addGuild(guild.getId());
|
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId)));
|
||||||
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, habbo.getHabboInfo().getId(), true);
|
room.refreshRightsForHabbo(habbo);
|
||||||
guild.decreaseRequestCount();
|
|
||||||
guild.increaseMemberCount();
|
|
||||||
this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
|
|
||||||
Room room = habbo.getHabboInfo().getCurrentRoom();
|
|
||||||
if (room != null) {
|
|
||||||
if (room.getGuildId() == guildId) {
|
|
||||||
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId)));
|
|
||||||
room.refreshRightsForHabbo(habbo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -29,6 +29,11 @@ public class GuildDeclineMembershipEvent extends MessageHandler {
|
|||||||
if (guild != null) {
|
if (guild != null) {
|
||||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
|
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
|
||||||
if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && (member.getRank().equals(GuildRank.ADMIN) || member.getRank().equals(GuildRank.OWNER))) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) {
|
if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && (member.getRank().equals(GuildRank.ADMIN) || member.getRank().equals(GuildRank.OWNER))) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) {
|
||||||
|
GuildMember target = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId);
|
||||||
|
if (target == null || target.getRank().type != GuildRank.REQUESTED.type) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
guild.decreaseRequestCount();
|
guild.decreaseRequestCount();
|
||||||
Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId);
|
Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId);
|
||||||
this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), this.client.getHabbo(), 0, 0, "", true, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 0, 0, "")));
|
this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), this.client.getHabbo(), 0, 0, "", true, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 0, 0, "")));
|
||||||
|
|||||||
+74
-69
@@ -30,20 +30,69 @@ public class RequestGuildBuyEvent extends MessageHandler {
|
|||||||
final String name = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
final String name = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
||||||
final String description = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
final String description = Emulator.getGameEnvironment().getWordFilter().filter(this.packet.readString(), this.client.getHabbo());
|
||||||
|
|
||||||
if(name.length() > 29){
|
if (name.length() == 0 || name.length() > 29) {
|
||||||
this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.INVALID_GUILD_NAME));
|
this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.INVALID_GUILD_NAME));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(description.length() > 254){
|
if (description.length() > 254) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Emulator.getConfig().getBoolean("catalog.guild.hc_required", true) && !this.client.getHabbo().getHabboStats().hasActiveClub()) {
|
if (Emulator.getConfig().getBoolean("catalog.guild.hc_required", true) && !this.client.getHabbo().getHabboStats().hasActiveClub()) {
|
||||||
this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.HC_REQUIRED));
|
this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.HC_REQUIRED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int roomId = this.packet.readInt();
|
||||||
|
|
||||||
|
Room r = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
|
||||||
|
|
||||||
|
if (r == null) {
|
||||||
|
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r.hasGuild() || r.getGuildId() != 0) {
|
||||||
|
this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.ROOM_ALREADY_IN_USE));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) {
|
||||||
|
String message = Emulator.getTexts().getValue("scripter.warning.guild.buy.owner").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", r.getName().replace("%owner%", r.getOwnerName()));
|
||||||
|
ScripterManager.scripterDetected(this.client, message);
|
||||||
|
LOGGER.info(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int colorOne = this.packet.readInt();
|
||||||
|
int colorTwo = this.packet.readInt();
|
||||||
|
|
||||||
|
int count = this.packet.readInt();
|
||||||
|
|
||||||
|
StringBuilder badge = new StringBuilder();
|
||||||
|
|
||||||
|
byte base = 1;
|
||||||
|
|
||||||
|
while (base < count) {
|
||||||
|
int id = this.packet.readInt();
|
||||||
|
int color = this.packet.readInt();
|
||||||
|
int pos = this.packet.readInt();
|
||||||
|
|
||||||
|
if (base == 1) {
|
||||||
|
badge.append("b");
|
||||||
|
} else {
|
||||||
|
badge.append("s");
|
||||||
|
}
|
||||||
|
|
||||||
|
badge.append(id < 100 ? "0" : "").append(id < 10 ? "0" : "").append(id).append(color < 10 ? "0" : "").append(color).append(pos);
|
||||||
|
|
||||||
|
base += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only charge the player once every step has been validated. Previously the
|
||||||
|
// credits were deducted before the room was checked, so a purchase that
|
||||||
|
// failed afterwards (missing room, room already used by a guild, not the
|
||||||
|
// owner) still took the credits without ever creating the group.
|
||||||
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) {
|
if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) {
|
||||||
int guildPrice = Emulator.getConfig().getInt("catalog.guild.price");
|
int guildPrice = Emulator.getConfig().getInt("catalog.guild.price");
|
||||||
if (this.client.getHabbo().getHabboInfo().getCredits() >= guildPrice) {
|
if (this.client.getHabbo().getHabboInfo().getCredits() >= guildPrice) {
|
||||||
@@ -54,78 +103,34 @@ public class RequestGuildBuyEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int roomId = this.packet.readInt();
|
Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getName(), name, description, badge.toString(), colorOne, colorTwo);
|
||||||
|
|
||||||
Room r = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
|
r.setGuild(guild.getId());
|
||||||
|
r.removeAllRights();
|
||||||
|
r.setNeedsUpdate(true);
|
||||||
|
|
||||||
if (r != null) {
|
Emulator.getGameEnvironment().getGuildManager().addGuild(guild);
|
||||||
if (r.hasGuild()) {
|
|
||||||
this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.ROOM_ALREADY_IN_USE));
|
if (Emulator.getConfig().getBoolean("imager.internal.enabled")) {
|
||||||
return;
|
Emulator.getBadgeImager().generate(guild);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.client.sendResponse(new PurchaseOKComposer());
|
||||||
|
this.client.sendResponse(new GuildBoughtComposer(guild));
|
||||||
|
r.refreshGuild(guild);
|
||||||
|
|
||||||
|
for (Habbo habbo : r.getHabbos()) {
|
||||||
|
if (habbo.getClient() == null) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) {
|
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null));
|
||||||
if (r.getGuildId() == 0) {
|
|
||||||
int colorOne = this.packet.readInt();
|
|
||||||
int colorTwo = this.packet.readInt();
|
|
||||||
|
|
||||||
int count = this.packet.readInt();
|
if (habbo.getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) {
|
||||||
|
habbo.getClient().sendResponse(new RoomDataComposer(r, habbo, true, false));
|
||||||
StringBuilder badge = new StringBuilder();
|
|
||||||
|
|
||||||
byte base = 1;
|
|
||||||
|
|
||||||
while (base < count) {
|
|
||||||
int id = this.packet.readInt();
|
|
||||||
int color = this.packet.readInt();
|
|
||||||
int pos = this.packet.readInt();
|
|
||||||
|
|
||||||
if (base == 1) {
|
|
||||||
badge.append("b");
|
|
||||||
} else {
|
|
||||||
badge.append("s");
|
|
||||||
}
|
|
||||||
|
|
||||||
badge.append(id < 100 ? "0" : "").append(id < 10 ? "0" : "").append(id).append(color < 10 ? "0" : "").append(color).append(pos);
|
|
||||||
|
|
||||||
base += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getName(), name, description, badge.toString(), colorOne, colorTwo);
|
|
||||||
|
|
||||||
r.setGuild(guild.getId());
|
|
||||||
r.removeAllRights();
|
|
||||||
r.setNeedsUpdate(true);
|
|
||||||
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().addGuild(guild);
|
|
||||||
|
|
||||||
if (Emulator.getConfig().getBoolean("imager.internal.enabled")) {
|
|
||||||
Emulator.getBadgeImager().generate(guild);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.client.sendResponse(new PurchaseOKComposer());
|
|
||||||
this.client.sendResponse(new GuildBoughtComposer(guild));
|
|
||||||
r.refreshGuild(guild);
|
|
||||||
|
|
||||||
for (Habbo habbo : r.getHabbos()) {
|
|
||||||
if (habbo.getClient() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null));
|
|
||||||
|
|
||||||
if (habbo.getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) {
|
|
||||||
habbo.getClient().sendResponse(new RoomDataComposer(r, habbo, true, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Emulator.getPluginManager().fireEvent(new GuildPurchasedEvent(guild, this.client.getHabbo()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String message = Emulator.getTexts().getValue("scripter.warning.guild.buy.owner").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", r.getName().replace("%owner%", r.getOwnerName()));
|
|
||||||
ScripterManager.scripterDetected(this.client, message);
|
|
||||||
LOGGER.info(message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Emulator.getPluginManager().fireEvent(new GuildPurchasedEvent(guild, this.client.getHabbo()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-1
@@ -2,7 +2,11 @@ package com.eu.habbo.messages.incoming.guilds.forums;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||||
|
import com.eu.habbo.habbohotel.guilds.GuildMember;
|
||||||
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||||
import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer;
|
import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer;
|
||||||
|
|
||||||
public class GuildForumDataEvent extends MessageHandler {
|
public class GuildForumDataEvent extends MessageHandler {
|
||||||
@@ -20,10 +24,18 @@ public class GuildForumDataEvent extends MessageHandler {
|
|||||||
if (guild == null) return;
|
if (guild == null) return;
|
||||||
if (!guild.hasForum()) return;
|
if (!guild.hasForum()) return;
|
||||||
|
|
||||||
|
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId());
|
||||||
|
boolean staff = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q);
|
||||||
|
|
||||||
|
if (!guild.canHabboReadForum(this.client.getHabbo().getHabboInfo().getId(), member, staff)) {
|
||||||
|
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FORUMS_ACCESS_DENIED.key).compose());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo()));
|
this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo()));
|
||||||
|
|
||||||
if (!Emulator.getGameEnvironment().getGuildManager().hasViewedForum(this.client.getHabbo().getHabboInfo().getId(), guildId)) {
|
if (!Emulator.getGameEnvironment().getGuildManager().hasViewedForum(this.client.getHabbo().getHabboInfo().getId(), guildId)) {
|
||||||
Emulator.getGameEnvironment().getGuildManager().addView(this.client.getHabbo().getHabboInfo().getId(), guildId);
|
Emulator.getGameEnvironment().getGuildManager().addView(this.client.getHabbo().getHabboInfo().getId(), guildId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-1
@@ -2,7 +2,11 @@ package com.eu.habbo.messages.incoming.guilds.forums;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||||
|
import com.eu.habbo.habbohotel.guilds.GuildMember;
|
||||||
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||||
import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer;
|
import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer;
|
||||||
import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadsComposer;
|
import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadsComposer;
|
||||||
import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer;
|
import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer;
|
||||||
@@ -24,8 +28,15 @@ public class GuildForumThreadsEvent extends MessageHandler {
|
|||||||
this.client.sendResponse(new ConnectionErrorComposer(404));
|
this.client.sendResponse(new ConnectionErrorComposer(404));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId());
|
||||||
|
boolean staff = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q);
|
||||||
|
|
||||||
|
if (!guild.canHabboReadForum(this.client.getHabbo().getHabboInfo().getId(), member, staff)) {
|
||||||
|
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FORUMS_ACCESS_DENIED.key).compose());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo()));
|
this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo()));
|
||||||
this.client.sendResponse(new GuildForumThreadsComposer(guild, index));
|
this.client.sendResponse(new GuildForumThreadsComposer(guild, index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -38,7 +38,6 @@ public class GuildForumThreadsMessagesEvent extends MessageHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify thread belongs to the requested guild
|
|
||||||
if (thread.getGuildId() != guildId) {
|
if (thread.getGuildId() != guildId) {
|
||||||
this.client.sendResponse(new ConnectionErrorComposer(403));
|
this.client.sendResponse(new ConnectionErrorComposer(403));
|
||||||
return;
|
return;
|
||||||
@@ -47,6 +46,11 @@ public class GuildForumThreadsMessagesEvent extends MessageHandler {
|
|||||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId());
|
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId());
|
||||||
boolean isGuildAdministrator = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.ADMIN)));
|
boolean isGuildAdministrator = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.ADMIN)));
|
||||||
|
|
||||||
|
if (!guild.canHabboReadForum(this.client.getHabbo().getHabboInfo().getId(), member, hasStaffPermissions)) {
|
||||||
|
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FORUMS_ACCESS_DENIED.key).compose());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (thread.getState() != ForumThreadState.HIDDEN_BY_GUILD_ADMIN || hasStaffPermissions || isGuildAdministrator) {
|
if (thread.getState() != ForumThreadState.HIDDEN_BY_GUILD_ADMIN || hasStaffPermissions || isGuildAdministrator) {
|
||||||
this.client.sendResponse(new GuildForumCommentsComposer(guildId, threadId, index, thread.getComments(limit, index)));
|
this.client.sendResponse(new GuildForumCommentsComposer(guildId, threadId, index, thread.getComments(limit, index)));
|
||||||
this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo()));
|
this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo()));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.eu.habbo.messages.incoming.handshake;
|
package com.eu.habbo.messages.incoming.handshake;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.messages.NoAuthMessage;
|
import com.eu.habbo.messages.NoAuthMessage;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -24,6 +25,15 @@ public class MachineIDEvent extends MessageHandler {
|
|||||||
|
|
||||||
this.client.setMachineId(storedMachineId);
|
this.client.setMachineId(storedMachineId);
|
||||||
|
|
||||||
|
// Persist the machine fingerprint onto the user so machine/super bans can
|
||||||
|
// target it (createOfflineUserBan copies users.machine_id). The Nitro client
|
||||||
|
// sends this UniqueID packet right after the SSO ticket, so the Habbo is
|
||||||
|
// normally already loaded by the time we get here.
|
||||||
|
if (!storedMachineId.isEmpty() && this.client.getHabbo() != null && this.client.getHabbo().getHabboInfo() != null) {
|
||||||
|
this.client.getHabbo().getHabboInfo().setMachineID(storedMachineId);
|
||||||
|
Emulator.getThreading().run(this.client.getHabbo());
|
||||||
|
}
|
||||||
|
|
||||||
LOGGER.debug("Setting client MachineId to {}", storedMachineId);
|
LOGGER.debug("Setting client MachineId to {}", storedMachineId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,6 +161,12 @@ public class SecureLoginEvent extends MessageHandler {
|
|||||||
throw new NullPointerException(habbo.getHabboInfo().getUsername() + " has a NON EXISTING RANK!");
|
throw new NullPointerException(habbo.getHabboInfo().getUsername() + " has a NON EXISTING RANK!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the machine fingerprint already arrived (UniqueID before login),
|
||||||
|
// persist it so machine/super bans can target this user.
|
||||||
|
if (this.client.getMachineId() != null && !this.client.getMachineId().isEmpty()) {
|
||||||
|
this.client.getHabbo().getHabboInfo().setMachineID(this.client.getMachineId());
|
||||||
|
}
|
||||||
|
|
||||||
Emulator.getThreading().run(habbo);
|
Emulator.getThreading().run(habbo);
|
||||||
Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo);
|
Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
+5
@@ -6,6 +6,11 @@ import com.eu.habbo.messages.incoming.MessageHandler;
|
|||||||
import com.eu.habbo.messages.outgoing.inventory.prefixes.UserPrefixesComposer;
|
import com.eu.habbo.messages.outgoing.inventory.prefixes.UserPrefixesComposer;
|
||||||
|
|
||||||
public class DeletePrefixEvent extends MessageHandler {
|
public class DeletePrefixEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public int getRatelimit() {
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
int prefixId = this.packet.readInt();
|
int prefixId = this.packet.readInt();
|
||||||
|
|||||||
+132
-58
@@ -1,15 +1,20 @@
|
|||||||
package com.eu.habbo.messages.incoming.inventory.prefixes;
|
package com.eu.habbo.messages.incoming.inventory.prefixes;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.modtool.WordFilterWord;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.UserPrefix;
|
import com.eu.habbo.habbohotel.users.UserPrefix;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
|
||||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||||
import com.eu.habbo.messages.outgoing.inventory.nickicons.UserNickIconsComposer;
|
import com.eu.habbo.messages.outgoing.inventory.nickicons.UserNickIconsComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.inventory.prefixes.ActivePrefixUpdatedComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.inventory.prefixes.CustomPrefixPurchaseFailedComposer;
|
||||||
import com.eu.habbo.messages.outgoing.inventory.prefixes.PrefixReceivedComposer;
|
import com.eu.habbo.messages.outgoing.inventory.prefixes.PrefixReceivedComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
||||||
import com.eu.habbo.messages.outgoing.users.UserCreditsComposer;
|
import com.eu.habbo.messages.outgoing.users.UserCreditsComposer;
|
||||||
import com.eu.habbo.messages.outgoing.users.UserCurrencyComposer;
|
import com.eu.habbo.messages.outgoing.users.UserCurrencyComposer;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -17,10 +22,18 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class PurchasePrefixEvent extends MessageHandler {
|
public class PurchasePrefixEvent extends MessageHandler {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PurchasePrefixEvent.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(PurchasePrefixEvent.class);
|
||||||
private static final String[] ALLOWED_FONTS = { "", "pixel", "cherry", "vampiro" };
|
private static final String[] ALLOWED_FONTS = { "", "pixel", "cherry", "vampiro" };
|
||||||
|
private static final String[] ALLOWED_EFFECTS = {
|
||||||
|
"", "glow", "shadow", "italic", "outline", "underline", "pulse", "bounce", "wave", "shake",
|
||||||
|
"discord-neon", "cartoon", "toon", "pop", "bold-glow", "rainbow", "frost", "gold", "glitch",
|
||||||
|
"fire", "matrix", "sparkle"
|
||||||
|
};
|
||||||
|
private static final int MAX_ICON_LENGTH = 16;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRatelimit() {
|
public int getRatelimit() {
|
||||||
@@ -39,81 +52,101 @@ public class PurchasePrefixEvent extends MessageHandler {
|
|||||||
|
|
||||||
if (habbo == null) return;
|
if (habbo == null) return;
|
||||||
|
|
||||||
// Load settings
|
Map<String, Integer> settings = loadSettings();
|
||||||
int maxLength = getSettingInt("max_length", 15);
|
int maxLength = setting(settings, "max_length", 15);
|
||||||
int minRank = getSettingInt("min_rank_to_buy", 1);
|
int minRank = setting(settings, "min_rank_to_buy", 1);
|
||||||
int priceCredits = getSettingInt("price_credits", 5);
|
int priceCredits = setting(settings, "price_credits", 5);
|
||||||
int pricePoints = getSettingInt("price_points", 0);
|
int pricePoints = setting(settings, "price_points", 0);
|
||||||
int pointsType = getSettingInt("points_type", 0);
|
int pointsType = setting(settings, "points_type", 0);
|
||||||
int fontPriceCredits = getSettingInt("font_price_credits", 10);
|
int fontPriceCredits = setting(settings, "font_price_credits", 10);
|
||||||
int fontPricePoints = getSettingInt("font_price_points", 0);
|
int fontPricePoints = setting(settings, "font_price_points", 0);
|
||||||
int fontPointsType = getSettingInt("font_points_type", pointsType);
|
int fontPointsType = setting(settings, "font_points_type", pointsType);
|
||||||
|
int maxPrefixes = setting(settings, "max_prefixes", 60);
|
||||||
|
|
||||||
// Validate text
|
if (maxPrefixes > 0 && habbo.getInventory().getPrefixesComponent().getPrefixes().size() >= maxPrefixes) {
|
||||||
text = text.trim();
|
this.fail(habbo, "You already own the maximum number of prefixes (" + maxPrefixes + ").");
|
||||||
|
return;
|
||||||
if (text.isEmpty() || text.length() > maxLength) {
|
}
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "Prefix text is invalid or too long (max " + maxLength + " characters)."));
|
|
||||||
|
text = text.trim();
|
||||||
|
|
||||||
|
if (text.isEmpty() || text.length() > maxLength) {
|
||||||
|
this.fail(habbo, "Prefix text is invalid or too long (max " + maxLength + " characters).");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (containsControlChars(text)) {
|
||||||
|
this.fail(habbo, "Prefix text contains invalid characters.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (containsFilteredWord(text)) {
|
||||||
|
this.fail(habbo, "This prefix contains a blocked word.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate color (single hex or comma-separated multi hex for per-letter colors)
|
|
||||||
String[] colorParts = color.split(",");
|
String[] colorParts = color.split(",");
|
||||||
|
|
||||||
|
if (colorParts.length > text.length()) {
|
||||||
|
this.fail(habbo, "Invalid color format.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (String part : colorParts) {
|
for (String part : colorParts) {
|
||||||
if (!part.matches("^#[0-9A-Fa-f]{6}$")) {
|
if (!part.matches("^#[0-9A-Fa-f]{6}$")) {
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "Invalid color format."));
|
this.fail(habbo, "Invalid color format.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check rank
|
|
||||||
if (habbo.getHabboInfo().getRank().getId() < minRank) {
|
if (habbo.getHabboInfo().getRank().getId() < minRank) {
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "Your rank is too low to purchase prefixes."));
|
this.fail(habbo, "Your rank is too low to purchase prefixes.");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check blacklist
|
|
||||||
if (isBlacklisted(text)) {
|
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "This prefix contains a blocked word."));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon == null) icon = "";
|
if (icon == null) icon = "";
|
||||||
icon = icon.trim();
|
icon = icon.trim();
|
||||||
|
|
||||||
|
if (!isValidIcon(icon)) {
|
||||||
|
this.fail(habbo, "Invalid prefix icon.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (effect == null) effect = "";
|
if (effect == null) effect = "";
|
||||||
effect = effect.trim();
|
effect = effect.trim().toLowerCase();
|
||||||
|
|
||||||
|
if (!isAllowedEffect(effect)) {
|
||||||
|
this.fail(habbo, "Invalid prefix effect.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (font == null) font = "";
|
if (font == null) font = "";
|
||||||
font = font.trim().toLowerCase();
|
font = font.trim().toLowerCase();
|
||||||
|
|
||||||
if (!isAllowedFont(font)) {
|
if (!isAllowedFont(font)) {
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "Invalid font format."));
|
this.fail(habbo, "Invalid font format.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalPriceCredits = priceCredits + (!font.isEmpty() ? fontPriceCredits : 0);
|
int totalPriceCredits = priceCredits + (!font.isEmpty() ? fontPriceCredits : 0);
|
||||||
|
|
||||||
// Check credits
|
|
||||||
if (totalPriceCredits > 0 && habbo.getHabboInfo().getCredits() < totalPriceCredits) {
|
if (totalPriceCredits > 0 && habbo.getHabboInfo().getCredits() < totalPriceCredits) {
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "Not enough credits."));
|
this.fail(habbo, "Not enough credits.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalPricePointsSameType = pricePoints + ((fontPricePoints > 0 && fontPointsType == pointsType && !font.isEmpty()) ? fontPricePoints : 0);
|
int totalPricePointsSameType = pricePoints + ((fontPricePoints > 0 && fontPointsType == pointsType && !font.isEmpty()) ? fontPricePoints : 0);
|
||||||
|
|
||||||
// Check points
|
|
||||||
if (totalPricePointsSameType > 0 && habbo.getHabboInfo().getCurrencyAmount(pointsType) < totalPricePointsSameType) {
|
if (totalPricePointsSameType > 0 && habbo.getHabboInfo().getCurrencyAmount(pointsType) < totalPricePointsSameType) {
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "Not enough points."));
|
this.fail(habbo, "Not enough points.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!font.isEmpty() && fontPricePoints > 0 && fontPointsType != pointsType && habbo.getHabboInfo().getCurrencyAmount(fontPointsType) < fontPricePoints) {
|
if (!font.isEmpty() && fontPricePoints > 0 && fontPointsType != pointsType && habbo.getHabboInfo().getCurrencyAmount(fontPointsType) < fontPricePoints) {
|
||||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, "Not enough points."));
|
this.fail(habbo, "Not enough points.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deduct currency
|
|
||||||
if (totalPriceCredits > 0) {
|
if (totalPriceCredits > 0) {
|
||||||
habbo.getHabboInfo().addCredits(-totalPriceCredits);
|
habbo.getHabboInfo().addCredits(-totalPriceCredits);
|
||||||
this.client.sendResponse(new UserCreditsComposer(habbo));
|
this.client.sendResponse(new UserCreditsComposer(habbo));
|
||||||
@@ -129,47 +162,57 @@ public class PurchasePrefixEvent extends MessageHandler {
|
|||||||
this.client.sendResponse(new UserCurrencyComposer(habbo));
|
this.client.sendResponse(new UserCurrencyComposer(habbo));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create prefix
|
|
||||||
int storedPoints = totalPricePointsSameType;
|
int storedPoints = totalPricePointsSameType;
|
||||||
int storedPointsType = (storedPoints > 0) ? pointsType : ((!font.isEmpty() && fontPricePoints > 0) ? fontPointsType : pointsType);
|
int storedPointsType = (storedPoints > 0) ? pointsType : ((!font.isEmpty() && fontPricePoints > 0) ? fontPointsType : pointsType);
|
||||||
|
|
||||||
UserPrefix prefix = new UserPrefix(habbo.getHabboInfo().getId(), text, color, icon, effect, font, 0, text, storedPoints, storedPointsType, true);
|
UserPrefix prefix = new UserPrefix(habbo.getHabboInfo().getId(), text, color, icon, effect, font, 0, text, storedPoints, storedPointsType, true);
|
||||||
prefix.run(); // Insert into DB synchronously to get the ID
|
prefix.run(); // Insert into DB synchronously to get the ID
|
||||||
habbo.getInventory().getPrefixesComponent().addPrefix(prefix);
|
habbo.getInventory().getPrefixesComponent().addPrefix(prefix);
|
||||||
|
habbo.getInventory().getPrefixesComponent().setActive(prefix.getId());
|
||||||
this.client.sendResponse(new PrefixReceivedComposer(prefix));
|
this.client.sendResponse(new PrefixReceivedComposer(prefix));
|
||||||
|
this.client.sendResponse(new ActivePrefixUpdatedComposer(prefix));
|
||||||
this.client.sendResponse(new UserNickIconsComposer(habbo));
|
this.client.sendResponse(new UserNickIconsComposer(habbo));
|
||||||
}
|
|
||||||
|
|
||||||
private int getSettingInt(String key, int defaultValue) {
|
if (habbo.getHabboInfo().getCurrentRoom() != null) {
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose());
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT `value` FROM custom_prefix_settings WHERE key_name = ?")) {
|
|
||||||
statement.setString(1, key);
|
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
|
||||||
if (set.next()) {
|
|
||||||
return Integer.parseInt(set.getString("value"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException | NumberFormatException e) {
|
|
||||||
LOGGER.error("Error reading prefix setting: " + key, e);
|
|
||||||
}
|
}
|
||||||
return defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBlacklisted(String text) {
|
private void fail(Habbo habbo, String message) {
|
||||||
String lowerText = text.toLowerCase();
|
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, message));
|
||||||
|
this.client.sendResponse(new CustomPrefixPurchaseFailedComposer(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Integer> loadSettings() {
|
||||||
|
Map<String, Integer> settings = new HashMap<>();
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT word FROM custom_prefix_blacklist")) {
|
PreparedStatement statement = connection.prepareStatement("SELECT key_name, `value` FROM custom_prefix_settings");
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
ResultSet set = statement.executeQuery()) {
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
if (lowerText.contains(set.getString("word").toLowerCase())) {
|
try {
|
||||||
return true;
|
settings.put(set.getString("key_name"), Integer.parseInt(set.getString("value")));
|
||||||
}
|
} catch (NumberFormatException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("Error checking prefix blacklist", e);
|
LOGGER.error("Error reading prefix settings", e);
|
||||||
}
|
}
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int setting(Map<String, Integer> settings, String key, int defaultValue) {
|
||||||
|
Integer value = settings.get(key);
|
||||||
|
return value != null ? value : defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean containsFilteredWord(String text) {
|
||||||
|
if (text == null || text.isEmpty()) return false;
|
||||||
|
|
||||||
|
for (WordFilterWord word : Emulator.getGameEnvironment().getWordFilter().getWords()) {
|
||||||
|
if (word.key != null && !word.key.isEmpty() && StringUtils.containsIgnoreCase(text, word.key)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,4 +225,35 @@ public class PurchasePrefixEvent extends MessageHandler {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isAllowedEffect(String effect) {
|
||||||
|
for (String allowedEffect : ALLOWED_EFFECTS) {
|
||||||
|
if (allowedEffect.equals(effect)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidIcon(String icon) {
|
||||||
|
if (icon.isEmpty()) return true;
|
||||||
|
if (icon.length() > MAX_ICON_LENGTH) return false;
|
||||||
|
|
||||||
|
for (int i = 0; i < icon.length(); i++) {
|
||||||
|
char c = icon.charAt(i);
|
||||||
|
if (c < 0x20 || c == 0x7F || c == '<' || c == '>') return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean containsControlChars(String text) {
|
||||||
|
for (int i = 0; i < text.length(); i++) {
|
||||||
|
char c = text.charAt(i);
|
||||||
|
if (c < 0x20 || c == 0x7F) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -4,6 +4,11 @@ import com.eu.habbo.messages.incoming.MessageHandler;
|
|||||||
import com.eu.habbo.messages.outgoing.inventory.prefixes.UserPrefixesComposer;
|
import com.eu.habbo.messages.outgoing.inventory.prefixes.UserPrefixesComposer;
|
||||||
|
|
||||||
public class RequestUserPrefixesEvent extends MessageHandler {
|
public class RequestUserPrefixesEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public int getRatelimit() {
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
this.client.sendResponse(new UserPrefixesComposer(this.client.getHabbo()));
|
this.client.sendResponse(new UserPrefixesComposer(this.client.getHabbo()));
|
||||||
|
|||||||
+6
-1
@@ -2,11 +2,16 @@ package com.eu.habbo.messages.incoming.inventory.prefixes;
|
|||||||
|
|
||||||
import com.eu.habbo.habbohotel.users.UserPrefix;
|
import com.eu.habbo.habbohotel.users.UserPrefix;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.inventory.prefixes.ActivePrefixUpdatedComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.inventory.nickicons.UserNickIconsComposer;
|
import com.eu.habbo.messages.outgoing.inventory.nickicons.UserNickIconsComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.inventory.prefixes.ActivePrefixUpdatedComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
||||||
|
|
||||||
public class SetActivePrefixEvent extends MessageHandler {
|
public class SetActivePrefixEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public int getRatelimit() {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
int prefixId = this.packet.readInt();
|
int prefixId = this.packet.readInt();
|
||||||
|
|||||||
+6
-1
@@ -7,6 +7,11 @@ import com.eu.habbo.messages.outgoing.inventory.nickicons.UserNickIconsComposer;
|
|||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
||||||
|
|
||||||
public class SetDisplayOrderEvent extends MessageHandler {
|
public class SetDisplayOrderEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public int getRatelimit() {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
Habbo habbo = this.client.getHabbo();
|
Habbo habbo = this.client.getHabbo();
|
||||||
@@ -23,4 +28,4 @@ public class SetDisplayOrderEvent extends MessageHandler {
|
|||||||
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose());
|
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package com.eu.habbo.messages.incoming.mentions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
|
||||||
|
public class DeleteMentionEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public void handle() throws Exception {
|
||||||
|
int userId = this.client.getHabbo().getHabboInfo().getId();
|
||||||
|
int mentionId = this.packet.readInt();
|
||||||
|
|
||||||
|
Emulator.getGameEnvironment().getMentionManager().delete(userId, mentionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.eu.habbo.messages.incoming.mentions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
|
||||||
|
public class MarkMentionsReadEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public void handle() throws Exception {
|
||||||
|
int userId = this.client.getHabbo().getHabboInfo().getId();
|
||||||
|
int mode = this.packet.readInt();
|
||||||
|
int mentionId = this.packet.readInt();
|
||||||
|
|
||||||
|
Emulator.getGameEnvironment().getMentionManager().markRead(userId, mode, mentionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.eu.habbo.messages.incoming.mentions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.mentions.HabboMention;
|
||||||
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.messages.outgoing.mentions.MentionsListComposer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RequestMentionsEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public void handle() throws Exception {
|
||||||
|
int userId = this.client.getHabbo().getHabboInfo().getId();
|
||||||
|
int limit = Emulator.getConfig().getInt("mentions.store.limit", 50);
|
||||||
|
|
||||||
|
List<HabboMention> mentions = Emulator.getGameEnvironment().getMentionManager().getMentions(userId, limit);
|
||||||
|
this.client.sendResponse(new MentionsListComposer(mentions));
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
@@ -34,6 +34,9 @@ public class RoomUserShoutEvent extends MessageHandler {
|
|||||||
if (RoomChatMessage.SAVE_ROOM_CHATS) {
|
if (RoomChatMessage.SAVE_ROOM_CHATS) {
|
||||||
Emulator.getThreading().run(message);
|
Emulator.getThreading().run(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Emulator.getGameEnvironment().getMentionManager()
|
||||||
|
.process(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getCurrentRoom(), message.getMessage(), RoomChatType.SHOUT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + "");
|
String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + "");
|
||||||
|
|||||||
+3
@@ -36,6 +36,9 @@ public class RoomUserTalkEvent extends MessageHandler {
|
|||||||
if (RoomChatMessage.SAVE_ROOM_CHATS) {
|
if (RoomChatMessage.SAVE_ROOM_CHATS) {
|
||||||
Emulator.getThreading().run(message);
|
Emulator.getThreading().run(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Emulator.getGameEnvironment().getMentionManager()
|
||||||
|
.process(this.client.getHabbo(), room, message.getMessage(), RoomChatType.TALK);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + "");
|
String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + "");
|
||||||
|
|||||||
+12
-1
@@ -6,6 +6,9 @@ import com.eu.habbo.messages.incoming.MessageHandler;
|
|||||||
import com.eu.habbo.messages.outgoing.wheel.WheelAdminPrizesComposer;
|
import com.eu.habbo.messages.outgoing.wheel.WheelAdminPrizesComposer;
|
||||||
import com.eu.habbo.messages.outgoing.wheel.WheelDataComposer;
|
import com.eu.habbo.messages.outgoing.wheel.WheelDataComposer;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class WheelAdminSavePrizesEvent extends MessageHandler {
|
public class WheelAdminSavePrizesEvent extends MessageHandler {
|
||||||
public static final String PERMISSION_KEY = "acc_wheeladmin";
|
public static final String PERMISSION_KEY = "acc_wheeladmin";
|
||||||
|
|
||||||
@@ -25,6 +28,12 @@ public class WheelAdminSavePrizesEvent extends MessageHandler {
|
|||||||
int count = this.packet.readInt();
|
int count = this.packet.readInt();
|
||||||
if (count <= 0 || count > WheelManager.MAX_PRIZES_PER_SAVE) return;
|
if (count <= 0 || count > WheelManager.MAX_PRIZES_PER_SAVE) return;
|
||||||
|
|
||||||
|
// The client sends the full authoritative list of prizes in display
|
||||||
|
// order. id <= 0 means "insert a new prize"; any existing prize whose
|
||||||
|
// id is absent from this list was removed in the editor and gets
|
||||||
|
// soft-disabled below.
|
||||||
|
Set<Integer> keptIds = new HashSet<>();
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
int id = this.packet.readInt();
|
int id = this.packet.readInt();
|
||||||
String type = this.packet.readString();
|
String type = this.packet.readString();
|
||||||
@@ -33,9 +42,11 @@ public class WheelAdminSavePrizesEvent extends MessageHandler {
|
|||||||
int pointsType = this.packet.readInt();
|
int pointsType = this.packet.readInt();
|
||||||
int weight = this.packet.readInt();
|
int weight = this.packet.readInt();
|
||||||
String label = this.packet.readString();
|
String label = this.packet.readString();
|
||||||
wheel.savePrize(id, type, value, amount, pointsType, weight, label);
|
int savedId = wheel.savePrize(id, type, value, amount, pointsType, weight, label, i);
|
||||||
|
if (savedId > 0) keptIds.add(savedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wheel.disablePrizesNotIn(keptIds);
|
||||||
wheel.reload();
|
wheel.reload();
|
||||||
|
|
||||||
this.client.sendResponse(new WheelAdminPrizesComposer(wheel.getPrizes()));
|
this.client.sendResponse(new WheelAdminPrizesComposer(wheel.getPrizes()));
|
||||||
|
|||||||
@@ -579,6 +579,7 @@ public class Outgoing {
|
|||||||
public static final int PrefixReceivedComposer = 7002;
|
public static final int PrefixReceivedComposer = 7002;
|
||||||
public static final int ActivePrefixUpdatedComposer = 7003;
|
public static final int ActivePrefixUpdatedComposer = 7003;
|
||||||
public static final int UserNickIconsComposer = 7004;
|
public static final int UserNickIconsComposer = 7004;
|
||||||
|
public static final int CustomPrefixPurchaseFailedComposer = 7005;
|
||||||
public static final int AvailableCommandsComposer = 4050;
|
public static final int AvailableCommandsComposer = 4050;
|
||||||
|
|
||||||
// YouTube Room Broadcast
|
// YouTube Room Broadcast
|
||||||
@@ -602,5 +603,7 @@ public class Outgoing {
|
|||||||
public static final int WheelAdminPrizesComposer = 9404;
|
public static final int WheelAdminPrizesComposer = 9404;
|
||||||
public static final int SoundboardSettingsComposer = 9405;
|
public static final int SoundboardSettingsComposer = 9405;
|
||||||
public static final int SoundboardPlayComposer = 9406;
|
public static final int SoundboardPlayComposer = 9406;
|
||||||
|
public static final int MentionReceivedComposer = 4801;
|
||||||
|
public static final int MentionsListComposer = 4802;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package com.eu.habbo.messages.outgoing.inventory.prefixes;
|
||||||
|
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||||
|
|
||||||
|
public class CustomPrefixPurchaseFailedComposer extends MessageComposer {
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
public CustomPrefixPurchaseFailedComposer(String message) {
|
||||||
|
this.message = message != null ? message : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ServerMessage composeInternal() {
|
||||||
|
this.response.init(Outgoing.CustomPrefixPurchaseFailedComposer);
|
||||||
|
this.response.appendString(this.message);
|
||||||
|
return this.response;
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package com.eu.habbo.messages.outgoing.mentions;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.mentions.HabboMention;
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||||
|
|
||||||
|
public class MentionReceivedComposer extends MessageComposer {
|
||||||
|
private final HabboMention mention;
|
||||||
|
|
||||||
|
public MentionReceivedComposer(HabboMention mention) {
|
||||||
|
this.mention = mention;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ServerMessage composeInternal() {
|
||||||
|
this.response.init(Outgoing.MentionReceivedComposer);
|
||||||
|
this.response.appendInt(this.mention.getId());
|
||||||
|
this.response.appendInt(this.mention.getSenderUserId());
|
||||||
|
this.response.appendString(this.mention.getSenderUsername());
|
||||||
|
this.response.appendInt(this.mention.getRoomId());
|
||||||
|
this.response.appendString(this.mention.getRoomName());
|
||||||
|
this.response.appendString(this.mention.getMessage());
|
||||||
|
this.response.appendInt(this.mention.getMentionType());
|
||||||
|
this.response.appendInt(this.mention.getTimestamp());
|
||||||
|
return this.response;
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package com.eu.habbo.messages.outgoing.mentions;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.mentions.HabboMention;
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MentionsListComposer extends MessageComposer {
|
||||||
|
private final List<HabboMention> mentions;
|
||||||
|
|
||||||
|
public MentionsListComposer(List<HabboMention> mentions) {
|
||||||
|
this.mentions = mentions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ServerMessage composeInternal() {
|
||||||
|
this.response.init(Outgoing.MentionsListComposer);
|
||||||
|
this.response.appendInt(this.mentions.size());
|
||||||
|
|
||||||
|
for (HabboMention mention : this.mentions) {
|
||||||
|
this.response.appendInt(mention.getId());
|
||||||
|
this.response.appendInt(mention.getSenderUserId());
|
||||||
|
this.response.appendString(mention.getSenderUsername());
|
||||||
|
this.response.appendInt(mention.getRoomId());
|
||||||
|
this.response.appendString(mention.getRoomName());
|
||||||
|
this.response.appendString(mention.getMessage());
|
||||||
|
this.response.appendInt(mention.getMentionType());
|
||||||
|
this.response.appendInt(mention.getTimestamp());
|
||||||
|
this.response.appendBoolean(mention.isRead());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.response;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user