diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 00000000..a0cacc72
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,15 @@
+image: maven:latest
+
+cache:
+ paths:
+ - target/
+
+build:
+ script:
+ - mvn package
+ only:
+ - dev
+ - master
+ artifacts:
+ paths:
+ - target/Habbo-*.jar
\ No newline at end of file
diff --git a/README.md b/README.md
index d9a0cf39..e56d1cca 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha
Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt).
## Versions ##
-![image](https://img.shields.io/badge/VERSION-2.2.2-success.svg?style=for-the-badge&logo=appveyor)
-![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor)
+![image](https://img.shields.io/badge/VERSION-2.3.0-success.svg?style=for-the-badge&logo=appveyor)
+![image](https://img.shields.io/badge/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor)
Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases
@@ -32,8 +32,7 @@ When making an bug report or a feature request use the template we provide so th
- Harmony
- Quadral (Pathfinder)
- Skeletor
-- Arpyage
-- ItsGiuseppe
+- z
## Discord ##
Join us on Discord at https://discord.gg/BzfFsTp
diff --git a/pom.xml b/pom.xml
index 557fc959..5fa89a3e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.eu.habbo
Habbo
- 2.2.2
+ 2.3.0
UTF-8
@@ -79,7 +79,11 @@
central
- http://repo1.maven.org/maven2/
+ https://repo1.maven.org/maven2/
+
+
+ mvnrepo
+ https://mvnrepository.com/
@@ -91,6 +95,14 @@
4.1.36.Final
+
+
+ org.fusesource.jansi
+ jansi
+ 1.18
+
+
+
io.netty
netty-codec-http
@@ -182,4 +194,12 @@
+
+
+
+ internal.repo
+ Internal repo
+ file:///home/thara/testesb/in
+
+
\ No newline at end of file
diff --git a/sqlupdates/2_2_2_TO_2_3_0-RC-1.sql b/sqlupdates/2_2_2_TO_2_3_0-RC-1.sql
new file mode 100644
index 00000000..8df3c1b5
--- /dev/null
+++ b/sqlupdates/2_2_2_TO_2_3_0-RC-1.sql
@@ -0,0 +1,32 @@
+CREATE TABLE `sanctions` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `habbo_id` int(11) NOT NULL DEFAULT '0',
+ `sanction_level` int(11) NOT NULL DEFAULT '0',
+ `probation_timestamp` int(32) NOT NULL DEFAULT '0',
+ `reason` varchar(255) NOT NULL DEFAULT '',
+ `trade_locked_until` int(32) NOT NULL DEFAULT '0',
+ `is_muted` tinyint(1) NOT NULL DEFAULT '0',
+ `mute_duration` int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+CREATE TABLE `sanction_levels` (
+ `level` int(1) NOT NULL,
+ `type` enum('ALERT', 'BAN', 'MUTE') NOT NULL,
+ `hour_length` int(12) NOT NULL,
+ `probation_days` int(12) NOT NULL,
+ PRIMARY KEY (`level`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+ALTER TABLE `sanction_levels`
+ADD CONSTRAINT `level` CHECK (`level`<=7);
+
+INSERT INTO `sanction_levels` VALUES (1, 'ALERT', 0, 30);
+INSERT INTO `sanction_levels` VALUES (2, 'MUTE', 1, 30);
+INSERT INTO `sanction_levels` VALUES (3, 'BAN', 18, 30);
+INSERT INTO `sanction_levels` VALUES (4, 'BAN', 168, 30);
+INSERT INTO `sanction_levels` VALUES (5, 'BAN', 720, 60);
+INSERT INTO `sanction_levels` VALUES (6, 'BAN', 720, 60);
+INSERT INTO `sanction_levels` VALUES (7, 'BAN', 876581, 876581);
+
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.sanctions.enabled', '1');
diff --git a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql
new file mode 100644
index 00000000..c1280901
--- /dev/null
+++ b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql
@@ -0,0 +1,23 @@
+INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish', '5');
+INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish.type', '0');
+INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.type', '0');
+
+ALTER TABLE `room_promotions`
+ADD COLUMN `start_timestamp` int(11) NOT NULL DEFAULT -1 AFTER `end_timestamp`;
+ALTER TABLE `room_promotions`
+ADD COLUMN `category` int(11) NOT NULL DEFAULT 0 AFTER `start_timestamp`;
+
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('navigator.eventcategories', '1,Hottest Events,false;2,Parties & Music,true;3,Role Play,true;4,Help Desk,true;5,Trading,true;6,Games,true;7,Debates & Discussions,true;8,Grand Openings,true;9,Friending,true;10,Jobs,true;11,Group Events,true');
+
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('room.promotion.badge', 'RADZZ');
+
+CREATE TABLE `guild_forum_views` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` int(11) NOT NULL,
+ `guild_id` int(11) NOT NULL,
+ `timestamp` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+);
+
+ALTER TABLE `support_tickets`
+ADD COLUMN `photo_item_id` int(11) NOT NULL DEFAULT -1 AFTER `comment_id`;
diff --git a/sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql b/sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql
new file mode 100644
index 00000000..d1a5d906
--- /dev/null
+++ b/sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql
@@ -0,0 +1,7 @@
+ALTER TABLE `users_pets`
+ADD COLUMN `saddle_item_id` int(11) NULL;
+
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!');
+
+UPDATE `items_base` SET `customparams` = '1,true' WHERE `item_name` = 'wf_blob';
+UPDATE `items_base` SET `customparams` = '5,false' WHERE `item_name` = 'wf_blob2';
diff --git a/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql b/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql
new file mode 100644
index 00000000..d1a5d906
--- /dev/null
+++ b/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql
@@ -0,0 +1,7 @@
+ALTER TABLE `users_pets`
+ADD COLUMN `saddle_item_id` int(11) NULL;
+
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!');
+
+UPDATE `items_base` SET `customparams` = '1,true' WHERE `item_name` = 'wf_blob';
+UPDATE `items_base` SET `customparams` = '5,false' WHERE `item_name` = 'wf_blob2';
diff --git a/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql b/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql
new file mode 100644
index 00000000..f403dc29
--- /dev/null
+++ b/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql
@@ -0,0 +1,2 @@
+INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.generic.cmd_commands.text', 'Your Commands');
+INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_stand', 'stand');
diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java
index 6392e58c..209ab029 100644
--- a/src/main/java/com/eu/habbo/Emulator.java
+++ b/src/main/java/com/eu/habbo/Emulator.java
@@ -17,6 +17,7 @@ import com.eu.habbo.plugin.events.emulator.EmulatorStartShutdownEvent;
import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent;
import com.eu.habbo.threading.ThreadPooling;
import com.eu.habbo.util.imager.badges.BadgeImager;
+import org.fusesource.jansi.AnsiConsole;
import java.io.*;
import java.security.MessageDigest;
@@ -28,32 +29,37 @@ import java.util.Random;
public final class Emulator {
+
public final static int MAJOR = 2;
+ public final static int MINOR = 3;
+ public final static int BUILD = 0;
+ public static final String ANSI_RED = "\u001B[31m";
+ public static final String ANSI_BLUE = "\u001B[34m";
+ public static final String ANSI_PURPLE = "\u001B[35m";
+ public static final String ANSI_WHITE = "\u001B[37m";
+ public static final String ANSI_YELLOW = "\u001B[33m";
- public final static int MINOR = 2;
-
-
- public final static int BUILD = 2;
-
-
- public final static String PREVIEW = "Stable";
+ public final static String PREVIEW = "RC-3";
public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW;
private static final String logo =
+ "\n" +
+ "███╗ ███╗ ██████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ ███████╗████████╗ █████╗ ██████╗ \n" +
+ "████╗ ████║██╔═══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗\n" +
+ "██╔████╔██║██║ ██║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗███████╗ ██║ ███████║██████╔╝\n" +
+ "██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" +
+ "██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" +
+ "╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" +
+ " ";
- " \n" +
- " __ ___ _ A R C T U R U S __ \n" +
- " / |/ /___ _________ (_)___ ____ ______/ /_____ ______ \n" +
- " / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" +
- " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" +
- "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" +
- " /____/ \n" ;
public static String build = "";
public static boolean isReady = false;
public static boolean isShuttingDown = false;
public static boolean stopped = false;
public static boolean debugging = false;
+ private static String classPath = System.getProperty("java.class.path");
+ private static String osName = System.getProperty("os.name");
private static int timeStarted = 0;
private static Runtime runtime;
private static ConfigurationManager config;
@@ -81,14 +87,20 @@ public final class Emulator {
public static void main(String[] args) throws Exception {
try {
+ if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) {
+ AnsiConsole.systemInstall();
+ }
Locale.setDefault(new Locale("en"));
-
setBuild();
Emulator.stopped = false;
ConsoleCommand.load();
Emulator.logging = new Logging();
- Emulator.getLogging().logStart("\r" + Emulator.logo +
- " Build: " + build + "\n");
+ System.out.println(ANSI_PURPLE + logo );
+ System.out.println(ANSI_WHITE + "This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral.");
+ System.out.println(ANSI_BLUE + "[VERSION] " + ANSI_WHITE + version);
+ System.out.println(ANSI_RED + "[BUILD] " + ANSI_WHITE + build + "\n");
+ System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Remember to sign up your hotel to join our toplist beta at https://bit.ly/2NN0rxq" );
+ System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Join our discord at https://discord.gg/syuqgN" + "\n");
random = new Random();
long startTime = System.nanoTime();
@@ -119,7 +131,6 @@ public final class Emulator {
Emulator.getLogging().logStart("Memory: " + (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024) + "/" + (runtime.freeMemory()) / (1024 * 1024) + "MB");
Emulator.debugging = Emulator.getConfig().getBoolean("debug.mode");
-
if (debugging) {
Emulator.getLogging().logDebugLine("Debugging Enabled!");
}
@@ -134,10 +145,6 @@ public final class Emulator {
Emulator.getThreading().run(() -> {
- Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: ");
- Emulator.getLogging().logStart("https://discord.gg/syuqgN");
- Emulator.getLogging().logStart("Please report bugs on our git at Krews.org.");
- System.out.println("Waiting for commands: ");
}, 1500);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
@@ -189,11 +196,11 @@ public final class Emulator {
}
private static void dispose() {
+
Emulator.getThreading().setCanAdd(false);
Emulator.isShuttingDown = true;
Emulator.isReady = false;
Emulator.getLogging().logShutdownLine("Stopping Arcturus Emulator " + version + "...");
-
try {
if (Emulator.getPluginManager() != null)
Emulator.getPluginManager().fireEvent(new EmulatorStartShutdownEvent());
@@ -245,7 +252,6 @@ public final class Emulator {
Emulator.gameServer.stop();
} catch (Exception e) {
}
-
Emulator.getLogging().logShutdownLine("Stopped Arcturus Emulator " + version + "...");
if (Emulator.database != null) {
@@ -253,8 +259,12 @@ public final class Emulator {
}
Emulator.stopped = true;
+ if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) {
+ AnsiConsole.systemUninstall();
+ }
try {
if (Emulator.threading != null)
+
Emulator.threading.shutDown();
} catch (Exception e) {
}
diff --git a/src/main/java/com/eu/habbo/core/Logging.java b/src/main/java/com/eu/habbo/core/Logging.java
index 1f3b1b51..c364f2ec 100644
--- a/src/main/java/com/eu/habbo/core/Logging.java
+++ b/src/main/java/com/eu/habbo/core/Logging.java
@@ -134,7 +134,7 @@ public class Logging {
if (Emulator.getConfig().getBoolean("logging.debug")) {
this.write(debugFileWriter, line.toString());
}
- System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_GREEN + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString());
+ System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_RED + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString());
}
public void logUserLine(Object line) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java
index 02704bd3..93312b2c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java
+++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java
@@ -15,6 +15,7 @@ import com.eu.habbo.habbohotel.guilds.GuildManager;
import com.eu.habbo.habbohotel.hotelview.HotelViewManager;
import com.eu.habbo.habbohotel.items.ItemManager;
import com.eu.habbo.habbohotel.modtool.ModToolManager;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
import com.eu.habbo.habbohotel.modtool.WordFilter;
import com.eu.habbo.habbohotel.navigation.NavigatorManager;
import com.eu.habbo.habbohotel.permissions.PermissionsManager;
@@ -39,6 +40,7 @@ public class GameEnvironment {
private PermissionsManager permissionsManager;
private BotManager botManager;
private ModToolManager modToolManager;
+ private ModToolSanctions modToolSanctions;
private PetManager petManager;
private AchievementManager achievementManager;
private GuideManager guideManager;
@@ -62,6 +64,7 @@ public class GameEnvironment {
this.navigatorManager = new NavigatorManager();
this.commandHandler = new CommandHandler();
this.modToolManager = new ModToolManager();
+ this.modToolSanctions = new ModToolSanctions();
this.achievementManager = new AchievementManager();
this.achievementManager.reload();
this.guideManager = new GuideManager();
@@ -145,6 +148,10 @@ public class GameEnvironment {
return this.modToolManager;
}
+ public ModToolSanctions getModToolSanctions() {
+ return this.modToolSanctions;
+ }
+
public PetManager getPetManager() {
return this.petManager;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
index e6a5d900..d10ed613 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
@@ -22,6 +22,8 @@ import java.util.Arrays;
public class Bot implements Runnable {
public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}";
+ public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";");
+
private final ArrayList chatLines;
private transient int id;
private String name;
@@ -240,6 +242,8 @@ public class Bot implements Runnable {
if (this.roomUnit != null) {
room.giveEffect(this.roomUnit, this.effect, -1);
}
+
+ this.talk(PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)]);
}
public void onPickUp(Habbo habbo, Room room) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java
index 97484248..3afd12e0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java
@@ -113,15 +113,19 @@ public class BotManager {
return;
}
- if (!room.hasHabbosAt(location.x, location.y) && !location.isWalkable() && location.state != RoomTileState.SIT)
+ if (room.hasHabbosAt(location.x, location.y) || (!location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY))
return;
RoomUnit roomUnit = new RoomUnit();
roomUnit.setRotation(RoomUserRotation.SOUTH);
roomUnit.setLocation(location);
HabboItem topItem = room.getTopItemAt(location.x, location.y);
- roomUnit.setZ(roomUnit.getCurrentLocation().getStackHeight());
- roomUnit.setPreviousLocationZ(roomUnit.getCurrentLocation().getStackHeight());
+
+ double topItemHeight = 0;
+ if (topItem != null) topItemHeight = Item.getCurrentHeight(topItem);
+ roomUnit.setPreviousLocationZ(roomUnit.getCurrentLocation().getStackHeight() - topItemHeight);
+
+
roomUnit.setPathFinderRoom(room);
roomUnit.setRoomUnitType(RoomUnitType.BOT);
roomUnit.setCanWalk(room.isAllowBotsWalk());
@@ -136,7 +140,6 @@ public class BotManager {
bot.onPlace(habbo, room);
if (topItem != null) {
- roomUnit.setZ(topItem.getBaseItem().allowSit() ? topItem.getZ() : topItem.getZ() + Item.getCurrentHeight(topItem));
try {
topItem.onWalkOn(bot.getRoomUnit(), room, null);
} catch (Exception e) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
index 68db8eea..009b0828 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
@@ -40,6 +40,7 @@ import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.hash.THashSet;
+import java.lang.reflect.InvocationTargetException;
import java.sql.*;
import java.util.*;
import java.util.stream.Collectors;
@@ -729,6 +730,8 @@ public class CatalogManager {
if (pageClazz != null) {
try {
catalogPage = pageClazz.getConstructor(ResultSet.class).newInstance(page);
+ } catch (InvocationTargetException e) {
+ Emulator.getLogging().logErrorLine(e.getCause());
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java
index 1a7109dc..2e978403 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java
@@ -171,7 +171,7 @@ public class MarketPlace {
public static void serializeItemInfo(int itemId, ServerMessage message) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(timestamp))")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(marketplace_items.price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(marketplace_items.timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND marketplace_items.state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(marketplace_items.timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(marketplace_items.timestamp))")) {
statement.setInt(1, itemId);
message.appendInt(avarageLastXDays(itemId, 7));
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java
index d51eb126..dbf2fa6a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java
@@ -245,6 +245,7 @@ public class CommandHandler {
addCommand(new ShoutCommand());
addCommand(new ShutdownCommand());
addCommand(new SitCommand());
+ addCommand(new StandCommand());
addCommand(new SitDownCommand());
addCommand(new StaffAlertCommand());
addCommand(new StaffOnlineCommand());
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java
index 026a1d53..358f4266 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java
@@ -12,7 +12,7 @@ public class CommandsCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) throws Exception {
- StringBuilder message = new StringBuilder("Your Commands");
+ StringBuilder message = new StringBuilder(Emulator.getTexts().getValue("commands.generic.cmd_commands.text"));
List commands = Emulator.getGameEnvironment().getCommandHandler().getCommandsForRank(gameClient.getHabbo().getHabboInfo().getRank().getId());
message.append("(").append(commands.size()).append("):\r\n");
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java
index 919c43a7..24425e2c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java
@@ -43,7 +43,7 @@ public class MuteCommand extends Command {
}
}
- habbo.mute(duration);
+ habbo.mute(duration, false);
if (habbo.getHabboInfo().getCurrentRoom() != null) {
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.MUTED).compose()); //: RoomUserIgnoredComposer.UNIGNORED
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java
index 75c978a2..c468e0d1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java
@@ -9,7 +9,7 @@ import java.util.Collections;
public class PluginsCommand extends Command {
public PluginsCommand() {
- super("cmd_plugins", Emulator.getTexts().getValue("commands.keys.cmd_plugins").split(";"));
+ super(null, Emulator.getTexts().getValue("commands.keys.cmd_plugins").split(";"));
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/StandCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/StandCommand.java
new file mode 100644
index 00000000..82bf092c
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/StandCommand.java
@@ -0,0 +1,18 @@
+package com.eu.habbo.habbohotel.commands;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+
+public class StandCommand extends Command {
+ public StandCommand() {
+ super(null, Emulator.getTexts().getValue("commands.keys.cmd_stand").split(";"));
+ }
+
+
+ @Override
+ public boolean handle(GameClient gameClient, String[] params) throws Exception {
+ if (gameClient.getHabbo().getHabboInfo().getRiding() == null)
+ gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeStand(gameClient.getHabbo());
+ return true;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java
index 376f910c..6b7ff3f5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java
+++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java
@@ -5,6 +5,7 @@ import com.eu.habbo.core.Logging;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.PacketManager;
import com.eu.habbo.messages.ServerMessage;
+import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.MessageComposer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@@ -17,12 +18,12 @@ import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
public class GameClient {
-
public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25);
private final Channel channel;
public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp();
private Habbo habbo;
private String machineId = "";
+ public final ConcurrentHashMap, Long> messageTimestamps = new ConcurrentHashMap<>();
public GameClient(Channel channel) {
this.channel = channel;
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java
index 359792d8..b64d8292 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java
@@ -12,6 +12,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredHandler;
+import com.eu.habbo.messages.outgoing.guides.GuideSessionPartnerIsPlayingComposer;
import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.games.GameHabboJoinEvent;
import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent;
@@ -68,7 +69,7 @@ public abstract class Game implements Runnable {
habbo.getHabboInfo().setCurrentGame(this.getClass());
habbo.getHabboInfo().setGamePlayer(player);
}
-
+ habbo.getClient().sendResponse(new GuideSessionPartnerIsPlayingComposer(true));
return true;
}
} catch (Exception e) {
@@ -90,33 +91,19 @@ public abstract class Game implements Runnable {
GameTeam team = this.getTeamForHabbo(habbo);
if (team != null && team.isMember(habbo)) {
- team.removeMember(habbo.getHabboInfo().getGamePlayer());
- habbo.getHabboInfo().getGamePlayer().reset();
+ if (habbo.getHabboInfo().getGamePlayer() != null) {
+ team.removeMember(habbo.getHabboInfo().getGamePlayer());
+ habbo.getHabboInfo().getGamePlayer().reset();
+ }
+
habbo.getHabboInfo().setCurrentGame(null);
habbo.getHabboInfo().setGamePlayer(null);
-
+ habbo.getClient().sendResponse(new GuideSessionPartnerIsPlayingComposer(false));
if (this.countsAchievements && this.endTime > this.startTime) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GamePlayed"));
}
}
}
-
- /*
- boolean deleteGame = true;
- for (GameTeam team : this.teams.values())
- {
- if (team.getMembers().size() > 0 )
- {
- deleteGame = false;
- break;
- }
- }
-
- if (deleteGame)
- {
- this.room.deleteGame(this);
- }
- */
}
@@ -131,8 +118,7 @@ public abstract class Game implements Runnable {
}
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
- item.setExtradata("0");
- this.room.updateItem(item);
+ ((WiredBlob) item).onGameStart(this.room);
}
}
@@ -190,6 +176,10 @@ public abstract class Game implements Runnable {
((InteractionWiredHighscore) item).reloadData();
this.room.updateItem(item);
}
+
+ for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
+ ((WiredBlob) item).onGameEnd(this.room);
+ }
}
public abstract void run();
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java
index edc62fb4..1950c917 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java
@@ -29,6 +29,9 @@ public class GamePlayer {
public synchronized void addScore(int amount) {
if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) {
this.score += amount;
+
+ if (this.score < 0) this.score = 0;
+
WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java
index 5a5ba98b..aad945b1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java
@@ -72,7 +72,7 @@ public class GameTeam {
for (GamePlayer player : this.members) {
if (player == null || player.getHabbo() == null) continue;
- player.getHabbo().getHabboInfo().getGamePlayer().reset();
+ if (player.getHabbo().getHabboInfo().getGamePlayer() != null) player.getHabbo().getHabboInfo().getGamePlayer().reset();
player.getHabbo().getHabboInfo().setCurrentGame(null);
player.getHabbo().getHabboInfo().setGamePlayer(null);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java
index 3b390138..074d494a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java
@@ -157,11 +157,14 @@ public class BattleBanzaiGame extends Game {
public void onEnd() {
GameTeam winningTeam = null;
+ boolean singleTeamGame = this.teams.values().stream().filter(t -> t.getMembers().size() > 0).count() == 1;
+
for (GameTeam team : this.teams.values()) {
- for (GamePlayer player : team.getMembers()) {
- if (player.getScore() > 0) {
- AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer"));
- AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallQuestCompleted"));
+ if (!singleTeamGame) {
+ for (GamePlayer player : team.getMembers()) {
+ if (player.getScore() > 0) {
+ AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer"));
+ }
}
}
@@ -171,10 +174,12 @@ public class BattleBanzaiGame extends Game {
}
if (winningTeam != null) {
- for (GamePlayer player : winningTeam.getMembers()) {
- if (player.getScore() > 0) {
- this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
- AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner"));
+ if (!singleTeamGame) {
+ for (GamePlayer player : winningTeam.getMembers()) {
+ if (player.getScore() > 0) {
+ this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
+ AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner"));
+ }
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java
index df8a64a8..71a017aa 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.guilds;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.guilds.forums.ForumView;
import com.eu.habbo.habbohotel.items.interactions.InteractionGuildFurni;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
@@ -14,10 +15,8 @@ import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.set.hash.THashSet;
import java.sql.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.NoSuchElementException;
+import java.util.*;
+import java.util.stream.Collectors;
public class GuildManager {
@@ -25,12 +24,16 @@ public class GuildManager {
private final TIntObjectMap guilds;
+ private final THashSet views = new THashSet<>();
+
public GuildManager() {
long millis = System.currentTimeMillis();
this.guildParts = new THashMap>();
this.guilds = TCollections.synchronizedMap(new TIntObjectHashMap());
this.loadGuildParts();
+ this.loadGuildViews();
+
Emulator.getLogging().logStart("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
@@ -53,6 +56,19 @@ public class GuildManager {
}
}
+ public void loadGuildViews() {
+ this.views.clear();
+
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet set = statement.executeQuery("SELECT * FROM guild_forum_views")) {
+ while (set.next()) {
+ this.views.add(new ForumView(set));
+ }
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
public Guild createGuild(Habbo habbo, int roomId, String roomName, String name, String description, String badge, int colorOne, int colorTwo) {
Guild guild = new Guild(habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), roomId, roomName, name, description, colorOne, colorTwo, badge);
@@ -203,7 +219,7 @@ public class GuildManager {
}
if (userId == 0 && !error) {
- if (guild.getState() == GuildState.LOCKED) {
+ if (guild.getState() == GuildState.EXCLUSIVE) {
try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(id) as total FROM guilds_members WHERE guild_id = ? AND level_id = 3")) {
statement.setInt(1, guild.getId());
try (ResultSet set = statement.executeQuery()) {
@@ -236,7 +252,7 @@ public class GuildManager {
statement.setInt(1, guild.getId());
statement.setInt(2, client.getHabbo().getHabboInfo().getId());
statement.setInt(3, Emulator.getIntUnixTimestamp());
- statement.setInt(4, guild.getState() == GuildState.LOCKED ? GuildRank.REQUESTED.type : GuildRank.MEMBER.type);
+ statement.setInt(4, guild.getState() == GuildState.EXCLUSIVE ? GuildRank.REQUESTED.type : GuildRank.MEMBER.type);
statement.execute();
}
}
@@ -251,7 +267,7 @@ public class GuildManager {
}
if (userId == 0 && !error) {
- if (guild.getState() == GuildState.LOCKED)
+ if (guild.getState() == GuildState.EXCLUSIVE)
guild.increaseRequestCount();
else {
guild.increaseMemberCount();
@@ -594,4 +610,38 @@ public class GuildManager {
}
Emulator.getLogging().logShutdownLine("Guild Manager -> Disposed!");
}
+
+ public boolean hasViewedForum(int userId, int guildId) {
+ return this.views.stream()
+ .anyMatch(v -> v.getUserId() == userId && v.getGuildId() == guildId && v.getTimestamp() > (Emulator.getIntUnixTimestamp() - 7 * 24 * 60 * 60));
+ }
+
+ public void addView(int userId, int guildId) {
+ ForumView view = new ForumView(userId, guildId, Emulator.getIntUnixTimestamp());
+
+ this.views.add(view);
+
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `guild_forum_views`(`user_id`, `guild_id`, `timestamp`) VALUES (?, ?, ?)")) {
+ statement.setInt(1, view.getUserId());
+ statement.setInt(2, view.getGuildId());
+ statement.setInt(3, view.getTimestamp());
+
+ statement.execute();
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ public Set getMostViewed() {
+ return this.views.stream()
+ .filter(v -> v.getTimestamp() > (Emulator.getIntUnixTimestamp() - 7 * 24 * 60 * 60))
+ .collect(Collectors.groupingBy(ForumView::getGuildId))
+ .entrySet()
+ .stream()
+ .sorted(Comparator.comparingInt((Map.Entry> a) -> a.getValue().size()))
+ .map(k -> this.getGuild(k.getKey()))
+ .filter(g -> g != null && g.canReadForum() == SettingsState.EVERYONE)
+ .limit(100)
+ .collect(Collectors.toSet());
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java
index 87f4cdc7..173bed2f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java
@@ -62,4 +62,12 @@ public class GuildMember implements Comparable {
public int compareTo(Object o) {
return 0;
}
+
+ public GuildMembershipStatus getMembershipStatus() {
+ if (this.rank == GuildRank.DELETED) return GuildMembershipStatus.NOT_MEMBER;
+ if (this.rank == GuildRank.OWNER || this.rank == GuildRank.ADMIN || this.rank == GuildRank.MEMBER) return GuildMembershipStatus.MEMBER;
+ if (this.rank == GuildRank.REQUESTED) return GuildMembershipStatus.PENDING;
+
+ return GuildMembershipStatus.NOT_MEMBER;
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java
new file mode 100644
index 00000000..e6cb38f7
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java
@@ -0,0 +1,17 @@
+package com.eu.habbo.habbohotel.guilds;
+
+public enum GuildMembershipStatus {
+ NOT_MEMBER(0),
+ MEMBER(1),
+ PENDING(2);
+
+ private int status;
+
+ GuildMembershipStatus(int status) {
+ this.status = status;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java
index e0c5c833..a7afa1b1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java
@@ -1,8 +1,8 @@
package com.eu.habbo.habbohotel.guilds;
public enum GuildRank {
- ADMIN(0),
- MOD(1),
+ OWNER(0),
+ ADMIN(1),
MEMBER(2),
REQUESTED(3),
DELETED(4);
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java
index e2a8eb60..7fcd74eb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java
@@ -2,8 +2,10 @@ package com.eu.habbo.habbohotel.guilds;
public enum GuildState {
OPEN(0),
- LOCKED(1),
- CLOSED(2);
+ EXCLUSIVE(1),
+ CLOSED(2),
+ LARGE(3),
+ LARGE_CLOSED(4);
public final int state;
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java
index f1f05529..01f6792c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java
@@ -192,7 +192,7 @@ public class ForumThreadComment implements Runnable, ISerialize {
if (!this.needsUpdate)
return;
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments` SET `state` = ?, `admin_id` = ? WHERE `id` = ?;")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments SET `state` = ?, `admin_id` = ? WHERE `id` = ?")) {
statement.setInt(1, this.state.getStateId());
statement.setInt(2, this.adminId);
statement.setInt(3, this.commentId);
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java
new file mode 100644
index 00000000..c1b2569e
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java
@@ -0,0 +1,34 @@
+package com.eu.habbo.habbohotel.guilds.forums;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class ForumView {
+ private final int userId;
+ private final int guildId;
+ private final int timestamp;
+
+ public ForumView(int userId, int guildId, int timestamp) {
+ this.userId = userId;
+ this.guildId = guildId;
+ this.timestamp = timestamp;
+ }
+
+ public ForumView(ResultSet set) throws SQLException {
+ this.userId = set.getInt("user_id");
+ this.guildId = set.getInt("guild_id");
+ this.timestamp = set.getInt("timestamp");
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public int getGuildId() {
+ return guildId;
+ }
+
+ public int getTimestamp() {
+ return timestamp;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
index a2d7f55c..dbfea5f1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
@@ -38,6 +38,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun.Interaction
import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagPole;
import com.eu.habbo.habbohotel.items.interactions.games.tag.rollerskate.InteractionRollerskateField;
+import com.eu.habbo.habbohotel.items.interactions.pets.*;
import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemHead;
import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemLegs;
import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemPlanet;
@@ -177,6 +178,8 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class));
this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class));
this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class));
+ this.interactionsList.add(new ItemInteraction("random_state", InteractionRandomState.class));
+ this.interactionsList.add(new ItemInteraction("vendingmachine_no_sides", InteractionNoSidesVendingMachine.class));
this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class));
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java b/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java
new file mode 100644
index 00000000..931be676
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java
@@ -0,0 +1,41 @@
+package com.eu.habbo.habbohotel.items;
+
+import com.eu.habbo.Emulator;
+
+import java.util.Arrays;
+
+public class RandomStateParams {
+ private int states = -1;
+ private int delay = -1;
+
+ public RandomStateParams(String customparams) throws Exception {
+ Arrays.stream(customparams.split(",")).forEach(pair -> {
+ String[] keyValue = pair.split("=");
+
+ if (keyValue.length != 2) return;
+
+ switch (keyValue[0]) {
+ case "states":
+ this.states = Integer.parseInt(keyValue[1]);
+ break;
+ case "delay":
+ this.delay = Integer.parseInt(keyValue[1]);
+ break;
+ default:
+ Emulator.getLogging().logDebugLine("RandomStateParams: unknown key: " + keyValue[0]);
+ break;
+ }
+ });
+
+ if (this.states < 0) throw new Exception("RandomStateParams: states not defined");
+ if (this.delay < 0) throw new Exception("RandomStateParams: states not defined");
+ }
+
+ public int getStates() {
+ return states;
+ }
+
+ public int getDelay() {
+ return delay;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java
index 631f15d5..4e9ce06d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java
@@ -77,42 +77,44 @@ public class YoutubeManager {
long millis = System.currentTimeMillis();
- ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10);
+ Emulator.getThreading().run(() -> {
+ ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10);
- Emulator.getLogging().logStart("YouTube Manager -> Loading...");
+ Emulator.getLogging().logStart("YouTube Manager -> Loading...");
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM youtube_playlists")) {
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- final int itemId = set.getInt("item_id");
- final String playlistId = set.getString("playlist_id");
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM youtube_playlists")) {
+ try (ResultSet set = statement.executeQuery()) {
+ while (set.next()) {
+ final int itemId = set.getInt("item_id");
+ final String playlistId = set.getString("playlist_id");
- youtubeDataLoaderPool.submit(() -> {
- ArrayList playlists = this.playlists.getOrDefault(itemId, new ArrayList<>());
+ youtubeDataLoaderPool.submit(() -> {
+ ArrayList playlists = this.playlists.getOrDefault(itemId, new ArrayList<>());
- YoutubePlaylist playlist = this.getPlaylistDataById(playlistId);
- if (playlist != null) {
- playlists.add(playlist);
- } else {
- Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId);
- }
+ YoutubePlaylist playlist = this.getPlaylistDataById(playlistId);
+ if (playlist != null) {
+ playlists.add(playlist);
+ } else {
+ Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId);
+ }
- this.playlists.put(itemId, playlists);
- });
+ this.playlists.put(itemId, playlists);
+ });
+ }
}
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
}
- } catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
- }
- youtubeDataLoaderPool.shutdown();
- try {
- youtubeDataLoaderPool.awaitTermination(60, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ youtubeDataLoaderPool.shutdown();
+ try {
+ youtubeDataLoaderPool.awaitTermination(60, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
- Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ });
}
public YoutubePlaylist getPlaylistDataById(String playlistId) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java
index 5ea9050e..eccba568 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java
@@ -3,20 +3,21 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
-import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
+import com.eu.habbo.habbohotel.rooms.*;
+import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.threading.runnables.RoomUnitVendingMachineAction;
+import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import com.eu.habbo.util.pathfinding.Rotation;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
-public class InteractionEffectVendingMachine extends InteractionDefault {
+public class InteractionEffectVendingMachine extends InteractionVendingMachine {
public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
this.setExtradata("0");
@@ -28,46 +29,7 @@ public class InteractionEffectVendingMachine extends InteractionDefault {
}
@Override
- public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- super.onClick(client, room, objects);
-
- if (client != null) {
- RoomTile tile = getSquareInFront(room.getLayout(), this);
-
- if (tile != null) {
- if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
- if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) {
- room.updateHabbo(client.getHabbo());
- if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) {
- client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]);
- client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
- room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
- }
- this.setExtradata("1");
- room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
- Emulator.getThreading().run(this, 1000);
- HabboItem instance = this;
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- room.giveEffect(client.getHabbo().getRoomUnit(), instance.getBaseItem().getRandomVendingItem(), 30);
- }
- });
- }
- } else {
- if (!tile.isWalkable()) {
- for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
- if (t != null && t.isWalkable()) {
- tile = t;
- break;
- }
- }
- }
- client.getHabbo().getRoomUnit().setGoalLocation(tile);
- Emulator.getThreading().run(new RoomUnitVendingMachineAction(client.getHabbo(), this, room), client.getHabbo().getRoomUnit().getPath().size() + 2 * 510);
- }
- }
- }
+ public void giveVendingMachineItem(Habbo habbo, Room room) {
+ room.giveEffect(habbo.getRoomUnit(), this.getBaseItem().getRandomVendingItem(), 30);
}
-
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java
index 14e38794..5c0b3422 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java
@@ -38,8 +38,6 @@ public class InteractionGate extends HabboItem {
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- super.onClick(client, room, objects);
-
boolean isWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
if (client != null && !room.hasRights(client.getHabbo()) && !isWired)
return;
@@ -54,6 +52,8 @@ public class InteractionGate extends HabboItem {
room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
this.needsUpdate(true);
room.updateItemState(this);
+
+ super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
}
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java
index f73af35e..efce0c5a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java
@@ -1,11 +1,9 @@
package com.eu.habbo.habbohotel.items.interactions;
+import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
-import com.eu.habbo.habbohotel.rooms.RoomUnitType;
+import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
@@ -13,9 +11,14 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import gnu.trove.set.hash.THashSet;
+import org.apache.commons.math3.util.Pair;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
public class InteractionMultiHeight extends HabboItem {
public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
@@ -55,6 +58,11 @@ public class InteractionMultiHeight extends HabboItem {
if (objects.length > 0) {
if (objects[0] instanceof Integer && room != null) {
+ HabboItem topItem = room.getTopItemAt(this.getX(), this.getY());
+ if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top
+ return;
+ }
+
this.needsUpdate(true);
if (this.getExtradata().length() == 0)
@@ -69,26 +77,27 @@ public class InteractionMultiHeight extends HabboItem {
}
if (this.isWalkable()) {
- THashSet habbos = room.getHabbosOnItem(this);
- THashSet updatedUnits = new THashSet<>();
- for (Habbo habbo : habbos) {
- if (habbo.getRoomUnit() == null)
- continue;
+ List unitsOnItem = new ArrayList<>();
+ unitsOnItem.addAll(room.getHabbosOnItem(this).stream().map(Habbo::getRoomUnit).filter(Objects::nonNull).collect(Collectors.toList()));
+ unitsOnItem.addAll(room.getBotsOnItem(this).stream().map(Bot::getRoomUnit).filter(Objects::nonNull).collect(Collectors.toList()));
- if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
+ THashSet updatedUnits = new THashSet<>();
+ for (RoomUnit unit : unitsOnItem) {
+ if (unit.hasStatus(RoomUnitStatus.MOVE))
continue;
if (this.getBaseItem().getMultiHeights().length >= 0) {
if (this.getBaseItem().allowSit()) {
- habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + "");
+ unit.setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + "");
} else {
- habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
- habbo.getRoomUnit().setPreviousLocationZ(habbo.getRoomUnit().getZ());
+ unit.setZ(unit.getCurrentLocation().getStackHeight());
+ unit.setPreviousLocationZ(unit.getZ());
}
}
- updatedUnits.add(habbo.getRoomUnit());
+ updatedUnits.add(unit);
}
+
room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose());
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java
index a0e245b7..9a163257 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java
@@ -13,7 +13,6 @@ import java.sql.SQLException;
public class InteractionMusicDisc extends HabboItem {
private int songId;
- private boolean inQueue;
public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
@@ -74,21 +73,13 @@ public class InteractionMusicDisc extends HabboItem {
public void onPlace(Room room) {
super.onPlace(room);
- room.sendComposer(new JukeBoxMySongsComposer(room.getTraxManager().myList()).compose());
+ room.getTraxManager().sendUpdatedSongList();
}
@Override
public void onPickUp(Room room) {
super.onPickUp(room);
- room.getTraxManager().removeSong(this.getId());
- }
-
- public boolean inQueue() {
- return this.inQueue;
- }
-
- public void inQueue(boolean inQueue) {
- this.inQueue = inQueue;
+ room.getTraxManager().sendUpdatedSongList();
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java
new file mode 100644
index 00000000..367d500e
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java
@@ -0,0 +1,24 @@
+package com.eu.habbo.habbohotel.items.interactions;
+
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.users.Habbo;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class InteractionNoSidesVendingMachine extends InteractionVendingMachine {
+ public InteractionNoSidesVendingMachine(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public InteractionNoSidesVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, userId, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public RoomTile getRequiredTile(Habbo habbo, Room room) {
+ return habbo.getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), true);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java
index 21d42d2a..daff0b5d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java
@@ -6,10 +6,12 @@ import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
-import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Optional;
public class InteractionPuzzleBox extends HabboItem {
public InteractionPuzzleBox(ResultSet set, Item baseItem) throws SQLException {
@@ -22,43 +24,56 @@ public class InteractionPuzzleBox extends HabboItem {
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- if (client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
- return;
-
- if (!RoomLayout.tilesAdjecent(room.getLayout().getTile(super.getX(), super.getY()), client.getHabbo().getRoomUnit().getCurrentLocation()))
- return;
-
-
RoomTile boxLocation = room.getLayout().getTile(this.getX(), this.getY());
- client.getHabbo().getRoomUnit().lookAtPoint(boxLocation);
- room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
+ RoomUserRotation rotation = null;
- switch (client.getHabbo().getRoomUnit().getBodyRotation()) {
- case NORTH_EAST:
- case NORTH_WEST:
- case SOUTH_EAST:
- case SOUTH_WEST:
- return;
+ if (this.getX() == client.getHabbo().getRoomUnit().getX()) {
+ if (this.getY() == client.getHabbo().getRoomUnit().getY() + 1) {
+ rotation = RoomUserRotation.SOUTH;
+ } else if (this.getY() == client.getHabbo().getRoomUnit().getY() - 1) {
+ rotation = RoomUserRotation.NORTH;
+ }
+ } else if (this.getY() == client.getHabbo().getRoomUnit().getY()) {
+ if (this.getX() == client.getHabbo().getRoomUnit().getX() + 1) {
+ rotation = RoomUserRotation.EAST;
+ } else if (this.getX() == client.getHabbo().getRoomUnit().getX() - 1) {
+ rotation = RoomUserRotation.WEST;
+ }
}
- RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getBodyRotation().getValue());
+ if (rotation == null) {
+ RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), false);
- if (tile == null || !room.tileWalkable(tile) || room.hasHabbosAt(tile.x, tile.y)) {
+ if (nearestTile != null) client.getHabbo().getRoomUnit().setGoalLocation(nearestTile);
return;
}
- double offset = room.getStackHeight(tile.x, tile.y, false) - this.getZ();
+ super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
- if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), client.getHabbo().getRoomUnit().getBodyRotation().getValue())))
+ RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), rotation.getValue());
+
+ if (tile == null || tile.getState() == RoomTileState.INVALID || room.hasHabbosAt(tile.x, tile.y)) {
+ return;
+ }
+
+ if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), rotation.getValue())))
return;
HabboItem item = room.getTopItemAt(tile.x, tile.y);
- if (item == null || (item.getZ() <= this.getZ() && item.getBaseItem().allowWalk())) {
- room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, offset, room).compose());
+ if (item != null && !room.getTopItemAt(tile.x, tile.y).getBaseItem().allowStack()) return;
+
+ this.setZ(room.getStackHeight(tile.x, tile.y, false));
+ this.needsUpdate(true);
+ room.updateItem(this);
+
+ room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose());
+ room.scheduledTasks.add(() -> {
client.getHabbo().getRoomUnit().setGoalLocation(boxLocation);
- this.needsUpdate(true);
- }
+
+ room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation));
+ });
+ this.needsUpdate(true);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java
new file mode 100644
index 00000000..c28ee163
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java
@@ -0,0 +1,42 @@
+package com.eu.habbo.habbohotel.items.interactions;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.RandomStateParams;
+import com.eu.habbo.habbohotel.rooms.Room;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class InteractionRandomState extends InteractionDefault {
+ public InteractionRandomState(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public InteractionRandomState(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, userId, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public void onPlace(Room room) {
+ super.onPlace(room);
+
+ this.setExtradata("");
+ room.updateItemState(this);
+ }
+
+ public void onRandomStateClick(GameClient client, Room room) throws Exception {
+ RandomStateParams params = new RandomStateParams(this.getBaseItem().getCustomParams());
+
+ this.setExtradata("");
+ room.updateItemState(this);
+
+ int randomState = Emulator.getRandom().nextInt(params.getStates()) + 1;
+
+ Emulator.getThreading().run(() -> {
+ this.setExtradata(randomState + "");
+ room.updateItemState(this);
+ }, params.getDelay());
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java
index 09a9a846..10489695 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java
@@ -16,6 +16,7 @@ import java.util.List;
public class InteractionRoller extends HabboItem {
public static boolean NO_RULES = false;
+ public static int DELAY = 400;
public InteractionRoller(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java
index 87543a07..e1761878 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java
@@ -1,14 +1,18 @@
package com.eu.habbo.habbohotel.items.interactions;
+import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
public class InteractionSwitch extends InteractionDefault {
public InteractionSwitch(ResultSet set, Item baseItem) throws SQLException {
@@ -43,12 +47,22 @@ public class InteractionSwitch extends InteractionDefault {
RoomTile closestTile = null;
for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) {
- closestTile = client.getHabbo().getRoomUnit().getCurrentLocation();
+ closestTile = tile;
}
}
- if (closestTile != null) {
+ if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
+ List onSuccess = new ArrayList<>();
+ onSuccess.add(() -> {
+ try {
+ this.onClick(client, room, objects);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ });
+
client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
+ Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
index 0720fba6..69d7fe3a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
@@ -83,6 +83,12 @@ public class InteractionTeleport extends HabboItem {
if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) {
startTeleport(room, habbo);
walkable = true;
+
+ try {
+ super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
} else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) {
// set state 1 and walk on item
this.roomUnitID = unit.getId();
@@ -133,9 +139,7 @@ public class InteractionTeleport extends HabboItem {
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- super.onClick(client, room, objects);
-
- if (room != null && client != null && objects.length <= 1) {
+ if (room != null && client != null && objects != null && objects.length <= 1) {
tryTeleport(client, room);
}
}
@@ -201,7 +205,7 @@ public class InteractionTeleport extends HabboItem {
if (habbo.getHabboInfo().getRiding() != null)
return false;
- return this.roomUnitID == -1 || this.roomUnitID == unit.getId();
+ return true;
}
public void startTeleport(Room room, Habbo habbo) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java
index bf2d2021..7ded66c2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java
@@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.items.interactions;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.Room;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,4 +15,9 @@ public class InteractionTent extends InteractionDefault {
public InteractionTent(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
}
+
+ @Override
+ public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
+ // do nothing
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java
index 36d978e8..791109a4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java
@@ -1,16 +1,11 @@
package com.eu.habbo.habbohotel.items.interactions;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
-import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionTrophy extends HabboItem {
+public class InteractionTrophy extends InteractionDefault {
public InteractionTrophy(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
@@ -18,41 +13,4 @@ public class InteractionTrophy extends HabboItem {
public InteractionTrophy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
}
-
- @Override
- public void serializeExtradata(ServerMessage serverMessage) {
- serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
- super.serializeExtradata(serverMessage);
- }
-
- @Override
- public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- return true;
- }
-
- @Override
- public boolean isWalkable() {
- return false;
- }
-
- @Override
- public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- super.onClick(client, room, objects);
- }
-
- @Override
- public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
-
- }
-
- @Override
- public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
-
- }
-
- @Override
- public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
-
- }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java
index 19a5c52b..55b96e98 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java
@@ -4,17 +4,21 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.*;
+import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
-import com.eu.habbo.threading.runnables.RoomUnitVendingMachineAction;
+import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import com.eu.habbo.util.pathfinding.Rotation;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
public class InteractionVendingMachine extends HabboItem {
public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException {
@@ -42,26 +46,32 @@ public class InteractionVendingMachine extends HabboItem {
super.onClick(client, room, objects);
if (client != null) {
- RoomTile tile = getSquareInFront(room.getLayout(), this);
+ RoomTile tile = this.getRequiredTile(client.getHabbo(), room);
if (tile != null) {
if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) {
- room.updateHabbo(client.getHabbo());
- if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) {
- client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]);
+ if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) && (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || tile.equals(client.getHabbo().getRoomUnit().getGoal()))) {
+ room.updateHabbo(client.getHabbo());
+ this.rotateToMachine(client.getHabbo().getRoomUnit());
client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
}
+
+ super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
+
this.setExtradata("1");
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
- Emulator.getThreading().run(this, 1000);
- Emulator.getThreading().run(new RoomUnitGiveHanditem(client.getHabbo().getRoomUnit(), room, this.getBaseItem().getRandomVendingItem()));
- if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
- if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
+ Emulator.getThreading().run(() -> {
+ Emulator.getThreading().run(this, 1000);
+ this.giveVendingMachineItem(client.getHabbo(), room);
+
+ if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
+ room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
+ if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
+ room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
+ }, 500);
}
} else {
if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) {
@@ -72,8 +82,43 @@ public class InteractionVendingMachine extends HabboItem {
}
}
}
+
+ RoomTile finalTile = tile;
client.getHabbo().getRoomUnit().setGoalLocation(tile);
- Emulator.getThreading().run(new RoomUnitVendingMachineAction(client.getHabbo(), this, room), client.getHabbo().getRoomUnit().getPath().size() + 2 * 510);
+
+ Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, () -> {
+ this.setExtradata("1");
+ room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
+
+ try {
+ super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ Emulator.getThreading().run(() -> {
+ client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(() -> {
+ if (client.getHabbo().getRoomUnit().getCurrentLocation().equals(finalTile)) {
+ this.rotateToMachine(client.getHabbo().getRoomUnit());
+ room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
+ }
+
+ try {
+ Emulator.getThreading().run(() -> {
+ Emulator.getThreading().run(this, 1000);
+ this.giveVendingMachineItem(client.getHabbo(), room);
+
+ if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
+ room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
+ if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
+ room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
+ }, 500).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ }, 300));
+ }, 250);
+ }, null));
}
}
}
@@ -119,4 +164,45 @@ public class InteractionVendingMachine extends HabboItem {
public boolean isUsable() {
return true;
}
+
+ private void rotateToMachine(RoomUnit unit) {
+ RoomUserRotation rotation = RoomUserRotation.values()[Rotation.Calculate(unit.getX(), unit.getY(), this.getX(), this.getY())];
+ boolean onlyHead = false;
+
+ switch (unit.getBodyRotation()) {
+ case NORTH_EAST:
+ if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.EAST))
+ onlyHead = true;
+ break;
+
+ case NORTH_WEST:
+ if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.WEST))
+ onlyHead = true;
+ break;
+
+ case SOUTH_EAST:
+ if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.EAST))
+ onlyHead = true;
+ break;
+
+ case SOUTH_WEST:
+ if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.WEST))
+ onlyHead = true;
+ break;
+ }
+
+ if (onlyHead) {
+ unit.setHeadRotation(rotation);
+ } else {
+ unit.setRotation(rotation);
+ }
+ }
+
+ public void giveVendingMachineItem(Habbo habbo, Room room) {
+ Emulator.getThreading().run(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.getBaseItem().getRandomVendingItem()));
+ }
+
+ public RoomTile getRequiredTile(Habbo habbo, Room room) {
+ return getSquareInFront(room.getLayout(), this);
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
index 94e01be1..6c0ff65e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
@@ -153,16 +153,20 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
return;
}
+ this.timeNow--;
+ if (this.timeNow < 0) this.timeNow = 0;
+
if (this.timeNow > 0) {
this.threadActive = true;
Emulator.getThreading().run(this, 1000);
- this.timeNow--;
- room.updateItem(this);
} else {
this.threadActive = false;
+ this.timeNow = 0;
this.endGame(room);
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
}
+
+ room.updateItem(this);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java
index 1ff4c3c7..5c28cda7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java
@@ -124,10 +124,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
@Override
public boolean validMove(Room room, RoomTile from, RoomTile to) {
- if (room == null || from == null || to == null) return false;
-
- HabboItem topItem = room.getTopItemAt(to.x, to.y, this);
- return topItem != null;
+ return room != null && from != null && to != null;
//return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java
index 24e98ed6..8e364615 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java
@@ -99,4 +99,23 @@ public class InteractionBattleBanzaiTile extends HabboItem {
return super.canStackAt(room, itemsAtLocation);
}
+
+ @Override
+ public void onPickUp(Room room) {
+ super.onPickUp(room);
+
+ this.setExtradata("0");
+ room.updateItem(this);
+ }
+
+ @Override
+ public void onPlace(Room room) {
+ super.onPlace(room);
+
+ BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class);
+
+ if (game != null && game.getState() != GameState.IDLE) {
+ this.setExtradata("1");
+ }
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java
index 5948ec9e..04def885 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.GameState;
import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors;
@@ -28,17 +29,19 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate {
}
@Override
- public boolean isWalkable() {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- if (room == null)
- return false;
+ public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
- return (this.getExtradata() == null || this.getExtradata().isEmpty() || Integer.valueOf(this.getExtradata()) < 5) && ((room.getGame(BattleBanzaiGame.class))) == null || ((BattleBanzaiGame) (room.getGame(BattleBanzaiGame.class))).state.equals(GameState.IDLE);
}
@Override
- public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
+ public boolean isWalkable() {
+ Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ if (room == null) return false;
+
+ Game game = room.getGame(BattleBanzaiGame.class);
+
+ return game == null || game.getState() == GameState.IDLE;
}
//TODO: Move to upper class
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java
index f8971b4f..5b98b827 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java
@@ -76,7 +76,7 @@ public class InteractionFreezeTile extends HabboItem {
@Override
public boolean canStackAt(Room room, List>> itemsAtLocation) {
for (Pair> set : itemsAtLocation) {
- if (!set.getValue().isEmpty()) return false;
+ if (set.getValue() != null && !set.getValue().isEmpty()) return false;
}
return super.canStackAt(room, itemsAtLocation);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java
index 96daf1d2..ec583fde 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java
@@ -1,5 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates;
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.GameState;
import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors;
@@ -27,18 +29,18 @@ public class InteractionFreezeGate extends InteractionGameGate {
}
@Override
- public boolean isWalkable() {
- if (this.getRoomId() == 0)
- return false;
-
- return (this.getExtradata().isEmpty() ||
- Integer.valueOf(this.getExtradata()) < 5);
- //((Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))) == null ||
- //!((FreezeGame)(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))).isRunning;
+ public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
}
@Override
- public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
+ public boolean isWalkable() {
+ Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+
+ if (room == null) return false;
+
+ Game game = room.getGame(FreezeGame.class);
+
+ return game == null || game.getState() == GameState.IDLE;
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java
similarity index 95%
rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java
rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java
index f9ac09da..8bbe249c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java
@@ -1,4 +1,4 @@
-package com.eu.habbo.habbohotel.items.interactions;
+package com.eu.habbo.habbohotel.items.interactions.pets;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
@@ -33,7 +33,7 @@ public class InteractionMonsterPlantSeed extends HabboItem {
public static int randomRarityLevel() {
int number = Emulator.getRandom().nextInt(66);
int count = 0;
- for (int i = 1; i <= 11; i++) {
+ for (int i = 1; i < 11; i++) {
count += 11 - i;
if (number <= count) {
return i;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java
similarity index 97%
rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java
rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java
index 36fb719a..d7293389 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java
@@ -1,4 +1,4 @@
-package com.eu.habbo.habbohotel.items.interactions;
+package com.eu.habbo.habbohotel.items.interactions.pets;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java
similarity index 99%
rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java
rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java
index 48049fee..16d219a9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java
@@ -1,4 +1,4 @@
-package com.eu.habbo.habbohotel.items.interactions;
+package com.eu.habbo.habbohotel.items.interactions.pets;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java
similarity index 94%
rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java
rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java
index b0a3131f..a18ada6b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java
@@ -1,8 +1,9 @@
-package com.eu.habbo.habbohotel.items.interactions;
+package com.eu.habbo.habbohotel.items.interactions.pets;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.rooms.Room;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java
similarity index 94%
rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java
rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java
index 07e3fd90..8f2dd02c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java
@@ -1,7 +1,8 @@
-package com.eu.habbo.habbohotel.items.interactions;
+package com.eu.habbo.habbohotel.items.interactions.pets;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.rooms.Room;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java
similarity index 95%
rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java
rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java
index f70540b8..680bae5a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java
@@ -1,7 +1,8 @@
-package com.eu.habbo.habbohotel.items.interactions;
+package com.eu.habbo.habbohotel.items.interactions.pets;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.rooms.Room;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java
index b0e63eb8..aa9dcb62 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java
@@ -35,7 +35,12 @@ public class InteractionTotemHead extends InteractionDefault {
}
public TotemColor getTotemColor() {
- int extraData = Integer.parseInt(this.getExtradata());
+ int extraData;
+ try {
+ extraData = Integer.parseInt(this.getExtradata());
+ }catch(NumberFormatException ex) {
+ extraData = 0;
+ }
if(extraData < 3) {
return TotemColor.NONE;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java
index 4555a2f9..d8d83da4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java
@@ -31,7 +31,12 @@ public class InteractionTotemLegs extends InteractionDefault {
}
public TotemColor getTotemColor() {
- int extraData = Integer.parseInt(this.getExtradata());
+ int extraData;
+ try {
+ extraData = Integer.parseInt(this.getExtradata());
+ } catch(NumberFormatException ex) {
+ extraData = 0;
+ }
return TotemColor.fromInt(extraData - (4 * (getTotemType().type - 1)));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java
index 75b48203..2c49e91c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java
@@ -33,6 +33,11 @@ public class InteractionTotemPlanet extends InteractionDefault {
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
+ if(client.getHabbo().getHabboInfo().getId() != this.getUserId()) {
+ super.onClick(client, room, objects);
+ return;
+ }
+
InteractionTotemLegs legs = null;
InteractionTotemHead head = null;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java
index 8258e6fa..fba63af0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java
@@ -34,6 +34,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
if (habbo.getHabboInfo().getGamePlayer() != null) {
return !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor);
}
+ return true; // user is not part of any team
}
return false;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java
index d32e932a..918f12fb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java
@@ -96,8 +96,13 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
List tasks = new ArrayList<>();
tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
+
Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
- Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, null));
+
+ List failedReach = new ArrayList<>();
+ failedReach.add(() -> tasks.forEach(Runnable::run));
+
+ Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, failedReach));
}
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
index a5662610..487b88f6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
@@ -107,7 +107,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
int currentEffect = bot.getRoomUnit().getEffectId();
room.giveEffect(bot.getRoomUnit(), 4, -1);
- Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, bot.getRoomUnit()), WiredHandler.TELEPORT_DELAY + 1000);
+ Emulator.getThreading().run(() -> room.giveEffect(bot.getRoomUnit(), 0, -1), WiredHandler.TELEPORT_DELAY + 1000);
Emulator.getThreading().run(new RoomUnitTeleport(bot.getRoomUnit(), room, item.getX(), item.getY(), item.getZ() + item.getBaseItem().getHeight() + (item.getBaseItem().allowSit() ? -0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY);
break;
} else {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
index dbd0907d..3a9b1f3c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
@@ -62,7 +62,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue());
int count = 1;
- while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID) && count < 8) {
+ while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID || targetTile.state == RoomTileState.BLOCKED) && count < 8) {
entry.setValue(this.nextRotation(entry.getValue()));
targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue());
count++;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java
index e461c25b..b318a033 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java
@@ -16,7 +16,6 @@ import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
-import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
@@ -45,6 +44,9 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
THashSet tilesToUpdate = new THashSet<>(this.settings.size());
//this.refresh();
+ if(this.settings.isEmpty())
+ return false;
+
for (WiredMatchFurniSetting setting : this.settings) {
HabboItem item = room.getHabboItem(setting.itemId);
if (item != null) {
@@ -57,66 +59,80 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
int oldRotation = item.getRotation();
boolean slideAnimation = true;
- if (this.direction) {
+ double offsetZ = 0;
+
+ if (this.direction && item.getRotation() != setting.rotation) {
item.setRotation(setting.rotation);
slideAnimation = false;
+
+ room.scheduledTasks.add(() -> {
+ room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation).forEach(t -> {
+ room.updateBotsAt(t.x, t.y);
+ room.updateHabbosAt(t.x, t.y);
+ });
+ room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation).forEach(t -> {
+ room.updateBotsAt(t.x, t.y);
+ room.updateHabbosAt(t.x, t.y);
+ });
+ });
}
- //room.sendComposer(new ItemStateComposer(item).compose());
- room.sendComposer(new FloorItemUpdateComposer(item).compose());
+ RoomTile t = null;
if (this.position) {
- RoomTile t = room.getLayout().getTile((short) setting.x, (short) setting.y);
+ t = room.getLayout().getTile((short) setting.x, (short) setting.y);
- if (t != null) {
- if (t.state != RoomTileState.INVALID) {
- boolean canMove = true;
+ if (t != null && t.state != RoomTileState.INVALID) {
+ boolean canMove = true;
- if (t.x == item.getX() && t.y == item.getY()) {
- canMove = !(room.getTopItemAt(t.x, t.y) == item);
- slideAnimation = false;
- }
+ if (t.x == item.getX() && t.y == item.getY()) {
+ canMove = !(room.getTopItemAt(t.x, t.y) == item);
+ slideAnimation = false;
+ }
- if (canMove && !room.hasHabbosAt(t.x, t.y)) {
- THashSet tiles = room.getLayout().getTilesAt(t, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation);
- double highestZ = -1d;
- for (RoomTile tile : tiles) {
- if (tile.state == RoomTileState.INVALID) {
- highestZ = -1d;
- break;
- }
-
- if (item instanceof InteractionRoller && room.hasItemsAt(tile.x, tile.y)) {
- highestZ = -1d;
- break;
- }
-
- double stackHeight = room.getStackHeight(tile.x, tile.y, false, item);
- if (stackHeight > highestZ) {
- highestZ = stackHeight;
- }
+ if (canMove && !room.hasHabbosAt(t.x, t.y)) {
+ THashSet tiles = room.getLayout().getTilesAt(t, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation);
+ double highestZ = -1d;
+ for (RoomTile tile : tiles) {
+ if (tile.state == RoomTileState.INVALID) {
+ highestZ = -1d;
+ break;
}
- if (highestZ != -1d) {
- tilesToUpdate.addAll(tiles);
+ if (item instanceof InteractionRoller && room.hasItemsAt(tile.x, tile.y)) {
+ highestZ = -1d;
+ break;
+ }
- double offsetZ = highestZ - item.getZ();
- double totalHeight = item.getZ() + offsetZ;
- if(totalHeight > 40) break;
- tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation));
+ double stackHeight = room.getStackHeight(tile.x, tile.y, false, item);
+ if (stackHeight > highestZ) {
+ highestZ = stackHeight;
+ }
+ }
- if (!slideAnimation) {
- item.setX(t.x);
- item.setY(t.y);
- }
+ if (highestZ != -1d) {
+ tilesToUpdate.addAll(tiles);
- room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose());
+ offsetZ = highestZ - item.getZ();
+ double totalHeight = item.getZ() + offsetZ;
+ if (totalHeight > 40) break;
+ tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation));
+
+ if (!slideAnimation) {
+ item.setX(t.x);
+ item.setY(t.y);
}
}
}
}
}
+ if (slideAnimation && t != null) {
+ room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose());
+ } else {
+ room.updateItem(item);
+ }
+
item.needsUpdate(true);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java
index caabe0e0..ae37a0f3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java
@@ -39,166 +39,117 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- THashSet items = new THashSet<>(this.items.size());
+ // remove items that are no longer in the room
+ this.items.removeIf( item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
+
THashSet tilesToUpdate = new THashSet<>(Math.min(this.items.size(), 10));
- for (HabboItem item : this.items) {
- if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
- items.add(item);
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
-
for (HabboItem item : this.items) {
//Handle rotation
- int rotationToAdd = 0;
if (this.rotation > 0) {
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
- if (this.rotation == 1) {
- rotationToAdd = 2;
- } else if (this.rotation == 2) {
- rotationToAdd = 6;
- }
- //Random rotation
- else if (this.rotation == 3) {
- if (Emulator.getRandom().nextInt(2) == 1) {
- rotationToAdd = 2;
- } else {
- rotationToAdd = 6;
- }
- }
+ int newRotation = this.getNewRotation(item);
- }
-
- int newRotation = ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8);
-
- //Verify if rotation result in a valid position
- if (rotationToAdd > 0 && room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation).equals(FurnitureMovementError.NONE))//room.canPlaceFurnitureAt(item, null, room.getLayout().getTile(item.getX(), item.getY()), item.getRotation() + rotationToAdd))
- {
- item.setRotation(newRotation);
-
- if (this.direction == 0) {
- tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
- room.sendComposer(new FloorItemUpdateComposer(item).compose());
- }
- }
-
- if (this.direction > 0) {
- int nextDirectionOffset = 0;
- RoomUserRotation startMoveDirection = RoomUserRotation.NORTH;
- RoomUserRotation moveDirection = null;
- if (this.direction == 1) {
- startMoveDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2];
- nextDirectionOffset = 2;
- } else if (this.direction == 2) {
- if (Emulator.getRandom().nextInt(2) == 1) {
- startMoveDirection = RoomUserRotation.EAST;
- nextDirectionOffset = 4;
- } else {
- startMoveDirection = RoomUserRotation.WEST;
- nextDirectionOffset = 4;
- }
- } else if (this.direction == 3) {
- if (Emulator.getRandom().nextInt(2) == 1) {
- startMoveDirection = RoomUserRotation.NORTH;
- nextDirectionOffset = 4;
- } else {
- startMoveDirection = RoomUserRotation.SOUTH;
- nextDirectionOffset = 4;
- }
- } else if (this.direction == 4) {
- startMoveDirection = RoomUserRotation.SOUTH;
- nextDirectionOffset = 8;
- } else if (this.direction == 5) {
- startMoveDirection = RoomUserRotation.EAST;
- nextDirectionOffset = 8;
- } else if (this.direction == 6) {
- startMoveDirection = RoomUserRotation.NORTH;
- nextDirectionOffset = 8;
- } else if (this.direction == 7) {
- startMoveDirection = RoomUserRotation.WEST;
- nextDirectionOffset = 8;
- }
-
- boolean validMove = false;
-
- int count = 0;
- int maxCount = 8 / nextDirectionOffset;
- while (moveDirection != startMoveDirection && !validMove && count < maxCount) {
- count++;
- if (moveDirection == null) {
- moveDirection = startMoveDirection;
- }
- RoomLayout layout = room.getLayout();
- if (layout == null) return false;
-
- RoomTile newTile = layout.getTile(
- (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))),
- (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0)))
- );
-
- if (newTile != null) {
- boolean hasHabbos = false;
- for (Habbo habbo : room.getHabbosAt(newTile)) {
- hasHabbos = true;
- WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item});
+ //Verify if rotation result in a valid position
+ FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation);
+ if (item.getRotation() != newRotation && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) ||
+ rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE)))
+ {
+ item.setRotation(newRotation);
+ if(this.direction == 0) {
+ tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
+ room.sendComposer(new FloorItemUpdateComposer(item).compose());
+ for (RoomTile t : tilesToUpdate) {
+ room.updateHabbosAt(t.x, t.y);
+ room.updateBotsAt(t.x, t.y);
}
+ }
+ }
+ }
- if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) {
- java.awt.Rectangle rectangle = new Rectangle(newTile.x,
- newTile.y,
- item.getBaseItem().getWidth(),
- item.getBaseItem().getLength());
+ //handle movement
+ if (this.direction > 0) {
+ RoomUserRotation moveDirection = this.getMovementDirection();
+ boolean validMove = false;
+ RoomLayout layout = room.getLayout();
+ if (layout == null) return false;
- double offset = -Short.MAX_VALUE;
- validMove = true;
- for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) {
- if (!validMove) {
+ RoomTile newTile = layout.getTile(
+ (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))),
+ (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0)))
+ );
+
+ if (newTile != null) {
+ boolean hasHabbos = false;
+ for (Habbo habbo : room.getHabbosAt(newTile)) {
+ hasHabbos = true;
+ WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item});
+ }
+
+ if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) {
+ java.awt.Rectangle rectangle = new Rectangle(newTile.x,
+ newTile.y,
+ item.getBaseItem().getWidth(),
+ item.getBaseItem().getLength());
+
+ double offset = -Short.MAX_VALUE;
+ validMove = true;
+ for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) {
+ if (!validMove) {
+ break;
+ }
+
+ for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) {
+ RoomTile tile = layout.getTile(x, y);
+ if (tile == null || tile.state == RoomTileState.INVALID || !tile.getAllowStack()) {
+ validMove = false;
break;
}
- for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) {
- RoomTile tile = layout.getTile(x, y);
+ THashSet itemsAtNewTile = room.getItemsAt(tile);
+ if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) {
+ validMove = false;
+ break;
+ }
- if (tile == null || tile.state == RoomTileState.INVALID || !tile.getAllowStack()) {
- validMove = false;
- break;
- }
+ ArrayList>> tileItems = new ArrayList<>(rectangle.width * rectangle.height);
+ tileItems.add(Pair.create(tile, itemsAtNewTile));
+ if (!item.canStackAt(room, tileItems)) {
+ validMove = false;
+ break;
+ }
- THashSet itemsAtNewTile = room.getItemsAt(tile);
- if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) {
- validMove = false;
- break;
- }
+ HabboItem i = room.getTopItemAt(x, y, item);
+ if (i != null && !i.getBaseItem().allowStack()) {
+ validMove = false;
+ break;
+ }
- java.util.List tileItems = new ArrayList>>(rectangle.width * rectangle.height);
- tileItems.add(Pair.create(tile, itemsAtNewTile));
- if (!item.canStackAt(room, tileItems)) {
- validMove = false;
- break;
- }
+ offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset);
- HabboItem i = room.getTopItemAt(x, y, item);
- if (i == null || i == item || i.getBaseItem().allowStack()) {
- offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset);
- }
- tilesToUpdate.add(tile);
+ tilesToUpdate.add(tile);
+ }
+ }
+ if (item.getZ() + offset > 40) {
+ offset = 40 - item.getZ();
+ }
+
+ if (validMove) {
+ if(this.rotation > 0) {
+ item.setX(newTile.x);
+ item.setY(newTile.y);
+ item.setZ(item.getZ() + offset);
+ room.sendComposer(new FloorItemUpdateComposer(item).compose());
+ for (RoomTile t : tilesToUpdate) {
+ room.updateHabbosAt(t.x, t.y);
+ room.updateBotsAt(t.x, t.y);
}
}
- if (item.getZ() + offset > 40) {
- offset = 40 - item.getZ();
- }
-
- if (validMove) {
+ else {
room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose());
}
}
}
- if (!validMove) {
- moveDirection = RoomUserRotation.fromValue(moveDirection.getValue() + nextDirectionOffset);
- }
}
}
}
@@ -244,14 +195,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
if (data.length == 4) {
try {
- this.direction = Integer.valueOf(data[0]);
- this.rotation = Integer.valueOf(data[1]);
- this.setDelay(Integer.valueOf(data[2]));
+ this.direction = Integer.parseInt(data[0]);
+ this.rotation = Integer.parseInt(data[1]);
+ this.setDelay(Integer.parseInt(data[2]));
} catch (Exception e) {
}
for (String s : data[3].split("\r")) {
- HabboItem item = room.getHabboItem(Integer.valueOf(s));
+ HabboItem item = room.getHabboItem(Integer.parseInt(s));
if (item != null)
this.items.add(item);
@@ -328,8 +279,60 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
return true;
}
- @Override
- protected long requiredCooldown() {
- return 100;
+
+ /**
+ * Returns a new rotation for an item based on the wired options
+ * @param item
+ * @return new rotation
+ */
+ private int getNewRotation(HabboItem item) {
+ int rotationToAdd = 0;
+ if (this.rotation == 1) {
+ rotationToAdd = 2;
+ } else if (this.rotation == 2) {
+ rotationToAdd = 6;
+ }
+ //Random rotation
+ else if (this.rotation == 3) {
+ if (Emulator.getRandom().nextInt(2) == 1) {
+ rotationToAdd = 2;
+ } else {
+ rotationToAdd = 6;
+ }
+ }
+
+ return ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8);
}
-}
+
+ /**
+ * Returns the direction of movement based on the wired settings
+ * @return direction
+ */
+ private RoomUserRotation getMovementDirection() {
+ RoomUserRotation movemementDirection = RoomUserRotation.NORTH;
+ if (this.direction == 1) {
+ movemementDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2];
+ } else if (this.direction == 2) {
+ if (Emulator.getRandom().nextInt(2) == 1) {
+ movemementDirection = RoomUserRotation.EAST;
+ } else {
+ movemementDirection = RoomUserRotation.WEST;
+ }
+ } else if (this.direction == 3) {
+ if (Emulator.getRandom().nextInt(2) == 1) {
+ movemementDirection = RoomUserRotation.NORTH;
+ } else {
+ movemementDirection = RoomUserRotation.SOUTH;
+ }
+ } else if (this.direction == 4) {
+ movemementDirection = RoomUserRotation.SOUTH;
+ } else if (this.direction == 5) {
+ movemementDirection = RoomUserRotation.EAST;
+ } else if (this.direction == 6) {
+ movemementDirection = RoomUserRotation.NORTH;
+ } else if (this.direction == 7) {
+ movemementDirection = RoomUserRotation.WEST;
+ }
+ return movemementDirection;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java
index 729c50e4..965ed802 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java
@@ -42,7 +42,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
}
public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
- if (roomUnit == null || tile == null)
+ if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting)
return;
Room room = roomUnit.getRoom();
@@ -63,6 +63,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
for (RoomTile optionalTile : optionalTiles) {
if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED) {
alternativeTile = optionalTile;
+ break;
}
}
@@ -139,30 +140,13 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- THashSet items = new THashSet<>();
-
- for (HabboItem item : this.items) {
- if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
- items.add(item);
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
+ this.items.removeIf(item -> item == null || item.getRoomId() != this.getRoomId()
+ || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
if (!this.items.isEmpty()) {
- int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
- int j = 1;
-
- int tryCount = 0;
- while (tryCount < this.items.size()) {
- tryCount++;
- HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size());
-
- teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY()));
- break;
-
- }
+ int i = Emulator.getRandom().nextInt(this.items.size());
+ HabboItem item = this.items.get(i);
+ teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY()));
return true;
}
@@ -220,6 +204,6 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
@Override
protected long requiredCooldown() {
- return 0;
+ return 50L;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java
index 55e8ca96..b46c81c9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java
@@ -1,66 +1,120 @@
package com.eu.habbo.habbohotel.items.interactions.wired.extra;
import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.games.Game;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.games.GamePlayer;
-import com.eu.habbo.habbohotel.games.GameTeam;
+import com.eu.habbo.habbohotel.games.GameState;
+import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
+import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.wired.WiredEffectType;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredBlob extends InteractionDefault {
+ enum WiredBlobState {
+ ACTIVE("0"),
+ USED("1");
+
+ private String state;
+ WiredBlobState(String state) {
+ this.state = state;
+ }
+
+ public String getState() {
+ return state;
+ }
+ }
+
+ private int POINTS_REWARD = 0;
+ private boolean RESETS_WITH_GAME = true;
+
public WiredBlob(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
+
+ this.parseCustomParams();
}
public WiredBlob(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
+
+ this.parseCustomParams();
+ }
+
+ @Override
+ public void onPlace(Room room) {
+ super.onPlace(room);
+
+ this.setExtradata(WiredBlobState.USED.getState());
+ room.updateItem(this);
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- if (this.getExtradata().equals("0")) {
- Habbo habbo = room.getHabbo(roomUnit);
+ if (!this.getExtradata().equals(WiredBlobState.ACTIVE.getState())) return;
- if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) {
- int points = Emulator.getConfig().getInt("hotel.item.wiredblob." + this.getBaseItem().getName());
+ Habbo habbo = room.getHabbo(roomUnit);
- if (points == 0) {
- Emulator.getConfig().register("hotel.item.wiredblob." + this.getBaseItem().getName(), "3000");
- points = 1;
+ if (habbo != null) {
+ GamePlayer player = habbo.getHabboInfo().getGamePlayer();
+
+ if (player != null) {
+ player.addScore(this.POINTS_REWARD);
+
+ BattleBanzaiGame battleBanzaiGame = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class);
+
+ if (battleBanzaiGame != null && battleBanzaiGame.getState() != GameState.IDLE) {
+ battleBanzaiGame.refreshCounters(habbo.getHabboInfo().getGamePlayer().getTeamColor());
}
- boolean triggered = false;
- Game game = room.getGame(habbo.getHabboInfo().getCurrentGame());
-
- if (game != null) {
- GameTeam team = game.getTeamForHabbo(habbo);
-
- if (team != null) {
- team.addTeamScore(points);
- triggered = true;
- } else {
- GamePlayer player = habbo.getHabboInfo().getGamePlayer();
-
- if (player != null) {
- player.addScore(points);
- triggered = true;
- }
- }
- }
-
- if (triggered) {
- this.setExtradata("1");
- room.updateItem(this);
- }
+ this.setExtradata(WiredBlobState.USED.getState());
+ room.updateItem(this);
}
}
}
+
+ @Override
+ public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
+ if (!this.RESETS_WITH_GAME && objects != null && objects.length == 2 && objects[1].equals(WiredEffectType.TOGGLE_STATE) && room.getGames().stream().anyMatch(game -> game.getState().equals(GameState.RUNNING) || game.getState().equals(GameState.PAUSED))) {
+ this.setExtradata(this.getExtradata().equals(WiredBlobState.ACTIVE.getState()) ? WiredBlobState.USED.getState() : WiredBlobState.ACTIVE.getState());
+ room.updateItem(this);
+ }
+ }
+
+ public void onGameStart(Room room) {
+ if (this.RESETS_WITH_GAME) {
+ this.setExtradata(WiredBlobState.ACTIVE.getState());
+ room.updateItem(this);
+ }
+ }
+
+ public void onGameEnd(Room room) {
+ this.setExtradata(WiredBlobState.USED.getState());
+ room.updateItem(this);
+ }
+
+ private void parseCustomParams() {
+ String[] params = this.getBaseItem().getCustomParams().split(",");
+
+ if (params.length != 2) {
+ Emulator.getLogging().logErrorLine("Wired blobs should have customparams with two parameters (points,resetsWithGame)");
+ return;
+ }
+
+ try {
+ this.POINTS_REWARD = Integer.parseInt(params[0]);
+ } catch (NumberFormatException e) {
+ Emulator.getLogging().logErrorLine("Wired blobs should have customparams with the first parameter being the amount of points (number)");
+ return;
+ }
+
+ this.RESETS_WITH_GAME = params[1].equalsIgnoreCase("true");
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java
index 2ed298fb..e058b1e3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java
@@ -14,7 +14,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredTriggerHabboUnidle extends InteractionWiredTrigger {
- private static final WiredTriggerType type = WiredTriggerType.IDLES;
+ private static final WiredTriggerType type = WiredTriggerType.UNIDLES;
public WiredTriggerHabboUnidle(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java
index 4476c515..a0f693c9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java
@@ -1,9 +1,11 @@
package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
+import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
+import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredHandler;
@@ -17,9 +19,9 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable {
+public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset {
public static final WiredTriggerType type = WiredTriggerType.PERIODICALLY;
- public static final int DEFAULT_DELAY = 20 * 500;
+ public static final int DEFAULT_DELAY = 10 * 500;
protected int repeatTime = DEFAULT_DELAY;
protected int counter = 0;
@@ -123,4 +125,15 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
}
}
}
+
+ @Override
+ public void resetTimer() {
+ this.counter = 0;
+ if (this.getRoomId() != 0) {
+ Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ if (room != null && room.isLoaded()) {
+ WiredHandler.handle(this, null, room, new Object[]{this});
+ }
+ }
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java
index 5a0df5a1..ff3f9688 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java
@@ -1,9 +1,11 @@
package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
+import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
+import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredHandler;
@@ -17,8 +19,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable {
- public static final int DEFAULT_DELAY = 20 * 5000;
+public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset {
+ public static final int DEFAULT_DELAY = 10 * 5000;
private static final WiredTriggerType type = WiredTriggerType.PERIODICALLY_LONG;
private int repeatTime = DEFAULT_DELAY;
private int counter = 0;
@@ -117,4 +119,15 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
}
}
}
+
+ @Override
+ public void resetTimer() {
+ this.counter = 0;
+ if (this.getRoomId() != 0) {
+ Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ if (room != null && room.isLoaded()) {
+ WiredHandler.handle(this, null, room, new Object[]{this});
+ }
+ }
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java
index 172e29e2..14a0b737 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java
@@ -45,6 +45,15 @@ public class ModToolIssue implements ISerialize {
this.modName = set.getString("mod_username");
this.type = ModToolTicketType.values()[set.getInt("type") - 1];
this.category = set.getInt("category");
+ this.groupId = set.getInt("group_id");
+ this.threadId = set.getInt("thread_id");
+ this.commentId = set.getInt("comment_id");
+
+ int photoItemId = set.getInt("photo_item_id");
+
+ if (photoItemId != -1) {
+ this.photoItem = Emulator.getGameEnvironment().getItemManager().loadHabboItem(photoItemId);;
+ }
if (this.modId <= 0) {
this.modName = "";
@@ -79,8 +88,8 @@ public class ModToolIssue implements ISerialize {
message.appendString(this.senderUsername); //Reporter user name.
message.appendInt(this.reportedId); //Reported user ID.
message.appendString(this.reportedUsername); //Reported user name.
- message.appendInt(this.modId); //MOD User ID?
- message.appendString(this.modName); //MOD User name?
+ message.appendInt(this.modId); //ADMIN User ID?
+ message.appendString(this.modName); //ADMIN User name?
message.appendString(this.message);
message.appendInt(0);
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java
index 18f546b1..8a10edbb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java
@@ -278,12 +278,12 @@ public class ModToolManager {
return chatlogs;
}
- public THashSet requestUserRoomVisits(Habbo habbo) {
+ public THashSet getUserRoomVisits(int userId) {
THashSet roomVisits = new THashSet<>();
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, room_enter_log.* FROM room_enter_log INNER JOIN rooms ON rooms.id = room_enter_log.room_id WHERE user_id = ? AND timestamp >= ? ORDER BY timestamp DESC LIMIT 50")) {
- statement.setInt(1, habbo.getHabboInfo().getId());
- statement.setInt(2, Emulator.getIntUnixTimestamp() - 84600);
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, room_enter_log.* FROM room_enter_log INNER JOIN rooms ON rooms.id = room_enter_log.room_id WHERE user_id = ? ORDER BY timestamp DESC LIMIT 50")) {
+ statement.setInt(1, userId);
+
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
roomVisits.add(new ModToolRoomVisit(set));
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java
new file mode 100644
index 00000000..70d2b375
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java
@@ -0,0 +1,25 @@
+package com.eu.habbo.habbohotel.modtool;
+
+public class ModToolSanctionItem {
+ public int id;
+ public int habboId;
+ public int sanctionLevel;
+ public int probationTimestamp;
+ public boolean isMuted;
+ public int muteDuration;
+ public int tradeLockedUntil;
+ public String reason;
+
+ public ModToolSanctionItem(int id, int habboId, int sanctionLevel, int probationTimestamp, boolean isMuted, int muteDuration, int tradeLockedUntil, String reason) {
+ this.id = id;
+ this.habboId = habboId;
+ this.sanctionLevel = sanctionLevel;
+ this.probationTimestamp = probationTimestamp;
+ this.isMuted = isMuted;
+ this.muteDuration = muteDuration;
+ this.tradeLockedUntil = tradeLockedUntil;
+ this.reason = reason;
+ }
+
+
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java
new file mode 100644
index 00000000..d893b4e2
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java
@@ -0,0 +1,15 @@
+package com.eu.habbo.habbohotel.modtool;
+
+public class ModToolSanctionLevelItem {
+ public int sanctionLevel;
+ public String sanctionType;
+ public int sanctionHourLength;
+ public int sanctionProbationDays;
+
+ public ModToolSanctionLevelItem(int sanctionLevel, String sanctionType, int sanctionHourLength, int sanctionProbationDays) {
+ this.sanctionLevel = sanctionLevel;
+ this.sanctionType = sanctionType;
+ this.sanctionHourLength = sanctionHourLength;
+ this.sanctionProbationDays = sanctionProbationDays;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java
new file mode 100644
index 00000000..ea72d8bb
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java
@@ -0,0 +1,173 @@
+package com.eu.habbo.habbohotel.modtool;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.plugin.events.sanctions.SanctionEvent;
+import gnu.trove.map.hash.THashMap;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Date;
+
+public class ModToolSanctions {
+
+ private final THashMap> sanctionHashmap;
+ private final THashMap sanctionLevelsHashmap;
+
+ public ModToolSanctions() {
+ long millis = System.currentTimeMillis();
+ this.sanctionHashmap = new THashMap<>();
+ this.sanctionLevelsHashmap = new THashMap<>();
+ this.loadModSanctions();
+ Emulator.getLogging().logStart("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+
+ }
+
+ public synchronized void loadModSanctions() {
+ this.sanctionHashmap.clear();
+ this.sanctionLevelsHashmap.clear();
+
+ this.loadSanctionLevels();
+ }
+
+ private void loadSanctionLevels() {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanction_levels")) {
+ try (ResultSet set = statement.executeQuery()) {
+ while (set.next()) {
+ this.sanctionLevelsHashmap.put(set.getInt("level"), new ModToolSanctionLevelItem(set.getInt("level"), set.getString("type"), set.getInt("hour_length"), set.getInt("probation_days")));
+ }
+ }
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ public ModToolSanctionLevelItem getSanctionLevelItem(int sanctionLevel) {
+ return this.sanctionLevelsHashmap.get(sanctionLevel);
+ }
+
+ public THashMap> getSanctions(int habboId) {
+ synchronized (this.sanctionHashmap) {
+ this.sanctionHashmap.clear();
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanctions WHERE habbo_id = ? ORDER BY id ASC")) {
+ statement.setInt(1, habboId);
+ try (ResultSet set = statement.executeQuery()) {
+ while (set.next()) {
+ if (this.sanctionHashmap.get(set.getInt("habbo_id")) == null) {
+ this.sanctionHashmap.put(set.getInt("habbo_id"), new ArrayList<>());
+ }
+
+ ModToolSanctionItem item = new ModToolSanctionItem(set.getInt("id"), set.getInt("habbo_id"), set.getInt("sanction_level"), set.getInt("probation_timestamp"), set.getBoolean("is_muted"), set.getInt("mute_duration"), set.getInt("trade_locked_until"), set.getString("reason"));
+
+ if (!this.sanctionHashmap.get(set.getInt("habbo_id")).contains(item)) {
+ this.sanctionHashmap.get(set.getInt("habbo_id")).add(item);
+ }
+ }
+ }
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+
+ return this.sanctionHashmap;
+ }
+ }
+
+ private void insertSanction(int habboId, int sanctionLevel, int probationTimestamp, String reason, int tradeLockedUntil, boolean isMuted, int muteDuration) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO sanctions (habbo_id, sanction_level, probation_timestamp, reason, trade_locked_until, is_muted, mute_duration) VALUES (?, ?, ?, ?, ?, ?, ?)")) {
+ statement.setInt(1, habboId);
+ statement.setInt(2, sanctionLevel);
+ statement.setInt(3, probationTimestamp);
+ statement.setString(4, reason);
+ statement.setInt(5, tradeLockedUntil);
+ statement.setBoolean(6, isMuted);
+ statement.setInt(7, muteDuration);
+
+ statement.execute();
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ public void updateSanction(int rowId, int probationTimestamp) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET probation_timestamp = ? WHERE id = ?")) {
+ statement.setInt(1, probationTimestamp);
+ statement.setInt(2, rowId);
+
+ statement.execute();
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ public void updateTradeLockedUntil(int rowId, int tradeLockedUntil) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET trade_locked_until = ? WHERE id = ?")) {
+ statement.setInt(1, tradeLockedUntil);
+ statement.setInt(2, rowId);
+
+ statement.execute();
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ public void updateMuteDuration(int rowId, int muteDuration) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET mute_duration = ? WHERE id = ?")) {
+ statement.setInt(1, muteDuration);
+ statement.setInt(2, rowId);
+
+ statement.execute();
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ public void run(int habboId, Habbo self, int sanctionLevel, int cfhTopic, String reason, int tradeLockedUntil, boolean isMuted, int muteDuration) {
+ sanctionLevel++;
+
+ ModToolSanctionLevelItem sanctionLevelItem = getSanctionLevelItem(sanctionLevel);
+
+ insertSanction(habboId, sanctionLevel, buildProbationTimestamp(sanctionLevelItem), reason, tradeLockedUntil, isMuted, muteDuration);
+
+ runSanctionBasedOnLevel(sanctionLevelItem, habboId, reason, cfhTopic, self, muteDuration);
+
+ Emulator.getPluginManager().fireEvent(new SanctionEvent(self, Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId), sanctionLevel));
+ }
+
+ private int buildProbationTimestamp(ModToolSanctionLevelItem sanctionLevelItem) {
+ return Emulator.getIntUnixTimestamp() + (sanctionLevelItem.sanctionProbationDays * 24 * 60 * 60);
+ }
+
+ public int getProbationDays(ModToolSanctionLevelItem sanctionLevelItem) {
+ return sanctionLevelItem.sanctionProbationDays;
+ }
+
+ private void runSanctionBasedOnLevel(ModToolSanctionLevelItem sanctionLevelItem, int habboId, String reason, int cfhTopic, Habbo self, int muteDuration) {
+ Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId);
+
+ int muteDurationSeconds = 0;
+
+ if (muteDuration > 0) {
+ Date muteDurationDate = new Date((long) muteDuration * 1000);
+ long diff = muteDurationDate.getTime() - Emulator.getDate().getTime();
+ muteDurationSeconds = Math.toIntExact(diff / 1000);
+ }
+
+ switch (sanctionLevelItem.sanctionType) {
+ case "ALERT": habbo.alert(reason); break;
+ case "BAN": Emulator.getGameEnvironment().getModToolManager().ban(habboId, self, reason, sanctionLevelItem.sanctionHourLength, ModToolBanType.ACCOUNT, cfhTopic); break;
+ case "MUTE": habbo.mute(muteDurationSeconds == 0 ? 3600 : muteDurationSeconds, false); break;
+ default: break;
+ }
+ }
+
+ public String getSanctionType(ModToolSanctionLevelItem sanctionLevelItem) {
+ return sanctionLevelItem.sanctionType;
+ }
+
+ public int getTimeOfSanction(ModToolSanctionLevelItem sanctionLevelItem) {
+ return sanctionLevelItem.sanctionHourLength;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java
index 6b214a77..123a47c4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java
@@ -150,7 +150,7 @@ public class WordFilter {
foundShit = true;
if (habbo != null && word.muteTime > 0) {
- habbo.mute(word.muteTime);
+ habbo.mute(word.muteTime, false);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java b/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java
new file mode 100644
index 00000000..264c8943
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java
@@ -0,0 +1,43 @@
+package com.eu.habbo.habbohotel.navigation;
+
+import com.eu.habbo.messages.ServerMessage;
+
+public class EventCategory {
+ private int id;
+ private String caption;
+ private boolean visible;
+
+ public EventCategory(int id, String caption, boolean visible) {
+ this.id = id;
+ this.caption = caption;
+ this.visible = visible;
+ }
+
+ public EventCategory(String serialized) throws Exception {
+ String[] parts = serialized.split(",");
+
+ if (parts.length != 3) throw new Exception("A serialized event category should contain 3 fields");
+
+ this.id = Integer.valueOf(parts[0]);
+ this.caption = parts[1];
+ this.visible = parts[2].equalsIgnoreCase("true");
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public boolean isVisible() {
+ return visible;
+ }
+
+ public void serialize(ServerMessage message) {
+ message.appendInt(this.id);
+ message.appendString(this.caption);
+ message.appendBoolean(this.visible);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java
index 87be3a16..46704168 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java
@@ -17,6 +17,7 @@ public class HorsePet extends RideablePet {
this.hairStyle = set.getInt("hair_style");
this.hasSaddle(set.getString("saddle").equalsIgnoreCase("1"));
this.setAnyoneCanRide(set.getString("ride").equalsIgnoreCase("1"));
+ this.setSaddleItemId(set.getInt("saddle_item_id"));
}
public HorsePet(int type, int race, String color, String name, int userId) {
@@ -30,12 +31,13 @@ public class HorsePet extends RideablePet {
@Override
public void run() {
if (this.needsUpdate) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ? WHERE id = ?")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ?, saddle_item_id = ? WHERE id = ?")) {
statement.setInt(1, this.hairStyle);
statement.setInt(2, this.hairColor);
statement.setString(3, this.hasSaddle() ? "1" : "0");
statement.setString(4, this.anyoneCanRide() ? "1" : "0");
- statement.setInt(5, super.getId());
+ statement.setInt(5, this.getSaddleItemId());
+ statement.setInt(6, super.getId());
statement.execute();
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java
index 8771b7b3..1eae8a4b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java
@@ -2,10 +2,10 @@ package com.eu.habbo.habbohotel.pets;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionNest;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetDrink;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetFood;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetToy;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy;
import com.eu.habbo.habbohotel.users.HabboItem;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java
index d4079923..7335963d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java
@@ -3,10 +3,10 @@ package com.eu.habbo.habbohotel.pets;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionNest;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetDrink;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetFood;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetToy;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy;
import com.eu.habbo.habbohotel.pets.actions.*;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java
index 92ec07a7..afdb4b39 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java
@@ -10,6 +10,7 @@ public class RideablePet extends Pet {
private Habbo rider;
private boolean hasSaddle;
private boolean anyoneCanRide;
+ private int saddleItemId;
public RideablePet(ResultSet set) throws SQLException {
super(set);
@@ -44,4 +45,12 @@ public class RideablePet extends Pet {
public void setRider(Habbo rider) {
this.rider = rider;
}
+
+ public int getSaddleItemId() {
+ return saddleItemId;
+ }
+
+ public void setSaddleItemId(int saddleItemId) {
+ this.saddleItemId = saddleItemId;
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java
index 180474e7..83ec6207 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java
@@ -1,6 +1,6 @@
package com.eu.habbo.habbohotel.pets.actions;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetBreedingNest;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetAction;
import com.eu.habbo.habbohotel.pets.PetTasks;
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
index 174cad24..c36b15b9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
@@ -19,6 +19,10 @@ import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.Interaction
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
import com.eu.habbo.habbohotel.permissions.Permission;
@@ -26,7 +30,8 @@ import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetManager;
import com.eu.habbo.habbohotel.pets.RideablePet;
import com.eu.habbo.habbohotel.users.*;
-import com.eu.habbo.habbohotel.wired.*;
+import com.eu.habbo.habbohotel.wired.WiredHandler;
+import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
@@ -78,6 +83,7 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
public class Room implements Comparable, ISerialize, Runnable {
public static final Comparator SORT_SCORE = new Comparator() {
@@ -466,6 +472,7 @@ public class Room implements Comparable, ISerialize, Runnable {
b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection()));
} else {
b.getRoomUnit().setZ(set.getDouble("z"));
+ b.getRoomUnit().setPreviousLocationZ(set.getDouble("z"));
b.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]);
}
b.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
@@ -547,7 +554,7 @@ public class Room implements Comparable, ISerialize, Runnable {
tile.setState(this.calculateTileState(tile));
}
- this.sendComposer(new UpdateStackHeightComposer(tiles).compose());
+ this.sendComposer(new UpdateStackHeightComposer(this, tiles).compose());
}
private RoomTileState calculateTileState(RoomTile tile) {
@@ -563,6 +570,9 @@ public class Room implements Comparable, ISerialize, Runnable {
HabboItem lowestChair = this.getLowestChair(tile);
THashSet items = this.getItemsAt(tile);
if (items == null) return RoomTileState.INVALID;
+
+ if (items.stream().anyMatch(i -> i.getBaseItem().allowLay())) return RoomTileState.LAY;
+
for (HabboItem item : items) {
if (exclude != null && item == exclude) continue;
@@ -573,10 +583,10 @@ public class Room implements Comparable, ISerialize, Runnable {
if (lowestItem == null || lowestItem.getZ() < item.getZ()) {
lowestItem = item;
- result = this.checkStateForItem(lowestItem);
+ result = this.checkStateForItem(lowestItem, tile);
} else if (lowestItem.getZ() == item.getZ()) {
if (result == RoomTileState.OPEN) {
- result = this.checkStateForItem(item);
+ result = this.checkStateForItem(item, tile);
}
}
}
@@ -586,7 +596,7 @@ public class Room implements Comparable, ISerialize, Runnable {
return result;
}
- private RoomTileState checkStateForItem(HabboItem item) {
+ private RoomTileState checkStateForItem(HabboItem item, RoomTile tile) {
RoomTileState result = RoomTileState.BLOCKED;
if (item.isWalkable()) {
@@ -601,6 +611,11 @@ public class Room implements Comparable, ISerialize, Runnable {
result = RoomTileState.LAY;
}
+ RoomTileState overriddenState = item.getOverrideTileState(tile, this);
+ if (overriddenState != null) {
+ result = overriddenState;
+ }
+
return result;
}
@@ -655,7 +670,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
}
- this.sendComposer(new UpdateStackHeightComposer(updatedTiles).compose());
+ this.sendComposer(new UpdateStackHeightComposer(this, updatedTiles).compose());
this.updateTiles(updatedTiles);
for (RoomTile tile : updatedTiles) {
this.updateHabbosAt(tile.x, tile.y);
@@ -719,8 +734,10 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public void updateHabbosAt(short x, short y) {
- THashSet habbos = this.getHabbosAt(x, y);
+ this.updateHabbosAt(x, y, this.getHabbosAt(x, y));
+ }
+ public void updateHabbosAt(short x, short y, THashSet habbos) {
HabboItem item = this.getTopItemAt(x, y);
THashSet roomUnits = new THashSet<>();
@@ -751,7 +768,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
- private void updateBotsAt(short x, short y) {
+ public void updateBotsAt(short x, short y) {
HabboItem topItem = this.getTopItemAt(x, y);
THashSet roomUnits = new THashSet<>();
@@ -763,7 +780,7 @@ public class Room implements Comparable, ISerialize, Runnable {
bot.getRoomUnit().setPreviousLocationZ(topItem.getZ());
bot.getRoomUnit().setRotation(RoomUserRotation.fromValue(topItem.getRotation()));
} else {
- bot.getRoomUnit().setZ(topItem.getZ() + topItem.getBaseItem().getHeight());
+ bot.getRoomUnit().setZ(topItem.getZ() + Item.getCurrentHeight(topItem));
if (topItem.getBaseItem().allowLay()) {
bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + "");
@@ -771,6 +788,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
} else {
bot.getRoomUnit().setZ(bot.getRoomUnit().getCurrentLocation().getStackHeight());
+ bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentLocation().getStackHeight());
}
roomUnits.add(bot.getRoomUnit());
@@ -838,10 +856,11 @@ public class Room implements Comparable, ISerialize, Runnable {
return;
if (this.loaded) {
- if (!this.traxManager.disposed()) {
- this.traxManager.dispose();
- }
try {
+ if (!this.traxManager.disposed()) {
+ this.traxManager.dispose();
+ }
+
this.roomCycleTask.cancel(false);
this.scheduledTasks.clear();
this.scheduledComposers.clear();
@@ -921,12 +940,16 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
- this.wordQuiz = "";
- this.yesVotes = 0;
- this.noVotes = 0;
- this.updateDatabaseUserCount();
- this.preLoaded = true;
- this.layout = null;
+ try {
+ this.wordQuiz = "";
+ this.yesVotes = 0;
+ this.noVotes = 0;
+ this.updateDatabaseUserCount();
+ this.preLoaded = true;
+ this.layout = null;
+ } catch (Exception e) {
+ Emulator.getLogging().logErrorLine(e);
+ }
}
Emulator.getPluginManager().fireEvent(new RoomUnloadedEvent(this));
@@ -1457,7 +1480,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
}
- }, 500);
+ }, this.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY);
}
}
@@ -1603,7 +1626,6 @@ public class Room implements Comparable, ISerialize, Runnable {
this.dance(unit, DanceType.NONE);
//int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z;
unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + "");
- unit.setPreviousLocationZ(topItem.getZ());
unit.setZ(topItem.getZ());
unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]);
unit.sitUpdate = false;
@@ -2095,25 +2117,29 @@ public class Room implements Comparable, ISerialize, Runnable {
return "";
}
- public void createPromotion(String title, String description) {
+ public void createPromotion(String title, String description, int category) {
this.promoted = true;
if (this.promotion == null) {
- this.promotion = new RoomPromotion(this, title, description, Emulator.getIntUnixTimestamp() + (120 * 60));
+ this.promotion = new RoomPromotion(this, title, description, Emulator.getIntUnixTimestamp() + (120 * 60), Emulator.getIntUnixTimestamp(), category);
} else {
this.promotion.setTitle(title);
this.promotion.setDescription(description);
this.promotion.setEndTimestamp(Emulator.getIntUnixTimestamp() + (120 * 60));
+ this.promotion.setCategory(category);
}
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp, start_timestamp, category) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?, category = ?")) {
statement.setInt(1, this.id);
statement.setString(2, title);
statement.setString(3, description);
statement.setInt(4, this.promotion.getEndTimestamp());
- statement.setString(5, this.promotion.getTitle());
- statement.setString(6, this.promotion.getDescription());
- statement.setInt(7, this.promotion.getEndTimestamp());
+ statement.setInt(5, this.promotion.getStartTimestamp());
+ statement.setInt(6, category);
+ statement.setString(7, this.promotion.getTitle());
+ statement.setString(8, this.promotion.getDescription());
+ statement.setInt(9, this.promotion.getEndTimestamp());
+ statement.setInt(10, this.promotion.getCategory());
statement.execute();
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
@@ -2359,6 +2385,9 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public HabboItem getHabboItem(int id) {
+ if (this.roomItems == null || this.roomSpecialTypes == null)
+ return null; // room not loaded completely
+
HabboItem item;
synchronized (this.roomItems) {
item = this.roomItems.get(id);
@@ -2577,13 +2606,15 @@ public class Room implements Comparable, ISerialize, Runnable {
this.sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose());
}
- HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY());
+ if (habbo.getRoomUnit().getCurrentLocation() != null) {
+ HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY());
- if (item != null) {
- try {
- item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{});
- } catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ if (item != null) {
+ try {
+ item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{});
+ } catch (Exception e) {
+ Emulator.getLogging().logErrorLine(e);
+ }
}
}
@@ -2971,7 +3002,7 @@ public class Room implements Comparable, ISerialize, Runnable {
habbo.getHabboStats().mutedCount++;
timeOut += (timeOut * (int) Math.ceil(Math.pow(habbo.getHabboStats().mutedCount, 2)));
habbo.getHabboStats().chatCounter = 0;
- habbo.mute(timeOut);
+ habbo.mute(timeOut, true);
}
public void talk(Habbo habbo, RoomChatMessage roomChatMessage, RoomChatType chatType) {
@@ -3962,6 +3993,18 @@ public class Room implements Comparable, ISerialize, Runnable {
this.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
}
+ public void makeStand(Habbo habbo) {
+ if (habbo.getRoomUnit() == null) return;
+
+ HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY());
+ if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) {
+ habbo.getRoomUnit().cmdStand = true;
+ habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]);
+ habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT);
+ this.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
+ }
+ }
+
public void giveEffect(Habbo habbo, int effectId, int duration) {
if (this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) {
this.giveEffect(habbo.getRoomUnit(), effectId, duration);
@@ -4089,11 +4132,10 @@ public class Room implements Comparable, ISerialize, Runnable {
if (habbo != null && iterator.value().getUserId() == habbo.getHabboInfo().getId())
continue;
- if (userItemsMap.get(iterator.value().getUserId()) == null) {
- userItemsMap.put(iterator.value().getUserId(), new THashSet<>());
- }
+ if (iterator.value() instanceof InteractionPostIt)
+ continue;
- userItemsMap.get(iterator.value().getUserId()).add(iterator.value());
+ userItemsMap.computeIfAbsent(iterator.value().getUserId(), k -> new THashSet<>()).add(iterator.value());
}
}
@@ -4161,6 +4203,11 @@ public class Room implements Comparable, ISerialize, Runnable {
public void idle(Habbo habbo) {
habbo.getRoomUnit().setIdle();
+
+ if (habbo.getRoomUnit().getDanceType() != DanceType.NONE) {
+ this.dance(habbo, DanceType.NONE);
+ }
+
this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose());
WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
}
@@ -4331,6 +4378,8 @@ public class Room implements Comparable, ISerialize, Runnable {
if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))
return FurnitureMovementError.INVALID_MOVE;
+ if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE;
+
THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
for (RoomTile t : occupiedTiles) {
@@ -4339,24 +4388,20 @@ public class Room implements Comparable, ISerialize, Runnable {
if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
}
- boolean magicTile = item instanceof InteractionStackHelper;
+ List>> tileFurniList = new ArrayList<>();
+ for (RoomTile t : occupiedTiles) {
+ tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
- if (!magicTile) {
- List>> tileFurniList = new ArrayList<>();
- for (RoomTile t : occupiedTiles) {
- tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
-
- HabboItem topItem = this.getTopItemAt(t.x, t.y, item);
- if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) {
- return FurnitureMovementError.CANT_STACK;
- }
- }
-
- if (!item.canStackAt(this, tileFurniList)) {
+ HabboItem topItem = this.getTopItemAt(t.x, t.y, item);
+ if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) {
return FurnitureMovementError.CANT_STACK;
}
}
+ if (!item.canStackAt(this, tileFurniList)) {
+ return FurnitureMovementError.CANT_STACK;
+ }
+
return FurnitureMovementError.NONE;
}
@@ -4438,26 +4483,31 @@ public class Room implements Comparable, ISerialize, Runnable {
boolean magicTile = item instanceof InteractionStackHelper;
+ Optional stackHelper = this.getItemsAt(tile).stream().filter(i -> i instanceof InteractionStackHelper).findAny();
+
//Check if can be placed at new position
THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
- if (topItem != item) {
- for (RoomTile t : occupiedTiles) {
- HabboItem tileTopItem = this.getTopItemAt(t.x, t.y);
- if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID))))
- return FurnitureMovementError.CANT_STACK;
- if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
- if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
- if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
+
+ if (!stackHelper.isPresent()) {
+ if (topItem != item) {
+ for (RoomTile t : occupiedTiles) {
+ HabboItem tileTopItem = this.getTopItemAt(t.x, t.y);
+ if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID))))
+ return FurnitureMovementError.CANT_STACK;
+ if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
+ if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
+ if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
+ }
}
- }
- List>> tileFurniList = new ArrayList<>();
- for (RoomTile t : occupiedTiles) {
- tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
- }
+ List>> tileFurniList = new ArrayList<>();
+ for (RoomTile t : occupiedTiles) {
+ tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
+ }
- if (!magicTile && !item.canStackAt(this, tileFurniList)) {
- return FurnitureMovementError.CANT_STACK;
+ if (!magicTile && !item.canStackAt(this, tileFurniList)) {
+ return FurnitureMovementError.CANT_STACK;
+ }
}
THashSet oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
@@ -4477,8 +4527,19 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
//Place at new position
- double height = this.getStackHeight(tile.x, tile.y, false, item);
+
+ double height;
+
+ if (stackHelper.isPresent()) {
+ height = stackHelper.get().getExtradata().isEmpty() ? Double.valueOf("0.0") : (Double.valueOf(stackHelper.get().getExtradata()) / 100);
+ } else if (item.equals(topItem) && tile.x == item.getX() && tile.y == item.getY()) {
+ height = item.getZ();
+ } else {
+ height = this.getStackHeight(tile.x, tile.y, false, item);
+ }
+
if(height > 40d) return FurnitureMovementError.CANT_STACK;
+
item.setX(tile.x);
item.setY(tile.y);
item.setZ(height);
@@ -4504,7 +4565,14 @@ public class Room implements Comparable, ISerialize, Runnable {
//Update Habbos at old position
for (RoomTile t : occupiedTiles) {
- this.updateHabbosAt(t.x, t.y);
+ this.updateHabbosAt(
+ t.x,
+ t.y,
+ this.getHabbosAt(t.x, t.y)
+ .stream()
+ .filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
+ .collect(Collectors.toCollection(THashSet::new))
+ );
this.updateBotsAt(t.x, t.y);
}
return FurnitureMovementError.NONE;
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java
index c6ed428e..8322d624 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java
@@ -210,7 +210,7 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable {
return;
}
} else {
- this.habbo.mute(Emulator.getConfig().getInt("hotel.wordfilter.automute"));
+ this.habbo.mute(Emulator.getConfig().getInt("hotel.wordfilter.automute"), false);
}
this.message = "";
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java
index 258d023b..03a4a382 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java
@@ -257,45 +257,56 @@ public class RoomLayout {
return this.heightmap.replace("\r\n", "\r");
}//re
- /// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3
public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) {
+ return this.findPath(oldTile, newTile, goalLocation, roomUnit, false);
+ }
+
+ /// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3
+ public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit, boolean isWalktroughRetry) {
if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID)
return new LinkedList<>();
+
LinkedList openList = new LinkedList<>();
List closedList = new LinkedList<>();
- RoomTile current;
openList.add(oldTile.copy());
- while (!openList.isEmpty()) {
- current = this.lowestFInOpen(openList);
- if ((current.x == newTile.x) && (current.y == newTile.y)) {
- return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current);
+ while (!openList.isEmpty()) {
+ RoomTile current = this.lowestFInOpen(openList);
+ if (current.x == newTile.x && current.y == newTile.y) {
+ return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current);
}
+
closedList.add(current);
openList.remove(current);
- List adjacentNodes = this.getAdjacent(openList, current, newTile);
+
+ List adjacentNodes = this.getAdjacent(openList, current, newTile, roomUnit);
for (RoomTile currentAdj : adjacentNodes) {
if (closedList.contains(currentAdj)) continue;
- if (roomUnit.canOverrideTile(currentAdj) || (currentAdj.state != RoomTileState.BLOCKED && currentAdj.x == doorX && currentAdj.y == doorY)) {
- currentAdj.setPrevious(current);
- currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y));
- currentAdj.setgCosts(current);
- openList.add(currentAdj);
- continue;
- }
- if ((currentAdj.state == RoomTileState.BLOCKED) || ((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) {
+
+ if (roomUnit.canOverrideTile(currentAdj) || (currentAdj.state != RoomTileState.BLOCKED && currentAdj.x == doorX && currentAdj.y == doorY)) {
+ currentAdj.setPrevious(current);
+ currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y));
+ currentAdj.setgCosts(current);
+ openList.add(currentAdj);
+ continue;
+ }
+
+ if (currentAdj.state == RoomTileState.BLOCKED || ((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) {
closedList.add(currentAdj);
openList.remove(currentAdj);
continue;
}
+
double height = currentAdj.getStackHeight() - current.getStackHeight();
if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue;
if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue;
- if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) {
+
+ if (currentAdj.hasUnits() && ((!isWalktroughRetry && !this.room.isAllowWalkthrough()) || currentAdj.equals(goalLocation))) {
closedList.add(currentAdj);
openList.remove(currentAdj);
continue;
}
+
if (!openList.contains(currentAdj)) {
currentAdj.setPrevious(current);
currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y));
@@ -307,8 +318,12 @@ public class RoomLayout {
}
}
}
- // System.out.println("Invalid Path.");
- return new LinkedList<>();
+
+ if (!this.room.isAllowWalkthrough() && !isWalktroughRetry) {
+ return this.findPath(oldTile, newTile, goalLocation, roomUnit, true);
+ }
+
+ return null;
}
private RoomTile findTile(List tiles, short x, short y) {
@@ -326,7 +341,7 @@ public class RoomLayout {
return null;
}
- private Deque calcPath(RoomTile start, RoomTile goal) {
+ public Deque calcPath(RoomTile start, RoomTile goal) {
LinkedList path = new LinkedList<>();
if (start == null)
return path;
@@ -355,13 +370,13 @@ public class RoomLayout {
return cheapest;
}
- private List getAdjacent(List openList, RoomTile node, RoomTile nextTile) {
+ private List getAdjacent(List openList, RoomTile node, RoomTile nextTile, RoomUnit unit) {
short x = node.x;
short y = node.y;
List adj = new LinkedList<>();
if (x > 0) {
RoomTile temp = this.findTile(openList, (short) (x - 1), y);
- if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
+ if (this.canWalkOn(temp, unit)) {
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
temp.isDiagonally(false);
if (!adj.contains(temp))
@@ -371,7 +386,7 @@ public class RoomLayout {
}
if (x < this.mapSizeX) {
RoomTile temp = this.findTile(openList, (short) (x + 1), y);
- if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
+ if (this.canWalkOn(temp, unit)) {
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
temp.isDiagonally(false);
if (!adj.contains(temp))
@@ -381,7 +396,7 @@ public class RoomLayout {
}
if (y > 0) {
RoomTile temp = this.findTile(openList, x, (short) (y - 1));
- if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
+ if (this.canWalkOn(temp, unit)) {
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
temp.isDiagonally(false);
if (!adj.contains(temp))
@@ -391,7 +406,7 @@ public class RoomLayout {
}
if (y < this.mapSizeY) {
RoomTile temp = this.findTile(openList, x, (short) (y + 1));
- if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
+ if (this.canWalkOn(temp, unit)) {
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
temp.isDiagonally(false);
if (!adj.contains(temp))
@@ -405,7 +420,7 @@ public class RoomLayout {
RoomTile offY = this.findTile(openList, x, (short) (y + 1));
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y + 1));
- if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
+ if (this.canWalkOn(temp, unit)) {
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
temp.isDiagonally(true);
if (!adj.contains(temp))
@@ -419,7 +434,7 @@ public class RoomLayout {
RoomTile offY = this.findTile(openList, x, (short) (y - 1));
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y - 1));
- if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
+ if (this.canWalkOn(temp, unit)) {
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
temp.isDiagonally(true);
if (!adj.contains(temp))
@@ -433,7 +448,7 @@ public class RoomLayout {
RoomTile offY = this.findTile(openList, x, (short) (y + 1));
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y + 1));
- if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
+ if (this.canWalkOn(temp, unit)) {
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
temp.isDiagonally(true);
if (!adj.contains(temp))
@@ -447,7 +462,7 @@ public class RoomLayout {
RoomTile offY = this.findTile(openList, x, (short) (y - 1));
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y - 1));
- if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
+ if (this.canWalkOn(temp, unit)) {
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
temp.isDiagonally(true);
if (!adj.contains(temp))
@@ -460,6 +475,10 @@ public class RoomLayout {
return adj;
}
+ private boolean canWalkOn(RoomTile tile, RoomUnit unit) {
+ return tile != null && (unit.canOverrideTile(tile) || (tile.state != RoomTileState.BLOCKED && tile.state != RoomTileState.INVALID));
+ }
+
public void moveDiagonally(boolean value) {
this.CANMOVEDIAGONALY = value;
}
@@ -536,10 +555,14 @@ public class RoomLayout {
}
public List getTilesAround(RoomTile tile, int directionOffset) {
- List tiles = new ArrayList<>(8);
+ return getTilesAround(tile, directionOffset, true);
+ }
+
+ public List getTilesAround(RoomTile tile, int directionOffset, boolean diagonal) {
+ List tiles = new ArrayList<>(diagonal ? 8 : 4);
if (tile != null) {
- for (int i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; i += (diagonal ? 1 : 2)) {
RoomTile t = this.getTileInFront(tile, (i + directionOffset) % 8);
if (t != null) {
tiles.add(t);
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
index 9157886e..2faa824c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
@@ -596,7 +596,7 @@ public class RoomManager {
habbo.getRoomUnit().clearStatus();
if (habbo.getRoomUnit().getCurrentLocation() == null) {
habbo.getRoomUnit().setLocation(doorLocation != null ? doorLocation : room.getLayout().getDoorTile());
- habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
+ if (habbo.getRoomUnit().getCurrentLocation() != null) habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
if (doorLocation == null) {
habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
@@ -713,21 +713,23 @@ public class RoomManager {
if (!room.getCurrentHabbos().isEmpty()) {
Collection habbosToSendEnter = room.getCurrentHabbos().values();
+ Collection visibleHabbos = room.getHabbos();
if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) {
- HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter));
+ HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter, visibleHabbos));
habbosToSendEnter = event.habbosToSendEnter;
+ visibleHabbos = event.visibleHabbos;
}
for (Habbo habboToSendEnter : habbosToSendEnter) {
GameClient client = habboToSendEnter.getClient();
if (client != null) {
client.sendResponse(new RoomUsersComposer(habbo).compose());
- habboToSendEnter.getClient().sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
+ client.sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
}
}
- for (Habbo h : room.getHabbos()) {
+ for (Habbo h : visibleHabbos) {
if (!h.getRoomUnit().isInvisible()) {
habbos.add(h);
}
@@ -747,11 +749,6 @@ public class RoomManager {
}
int effect = habbo.getInventory().getEffectsComponent().activatedEffect;
-
- if (effect == 0) {
- effect = habbo.getHabboInfo().getRank().getRoomEffect();
- }
-
room.giveEffect(habbo.getRoomUnit(), effect, -1);
}
@@ -770,7 +767,7 @@ public class RoomManager {
habbo.getClient().sendResponse(new RoomUserDanceComposer(bot.getRoomUnit()));
}
- habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit()));
+ habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit(), bot.getRoomUnit().getZ()));
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java
index 6aeae74f..fa43278b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java
@@ -13,12 +13,16 @@ public class RoomPromotion {
private String title;
private String description;
private int endTimestamp;
+ private int startTimestamp;
+ private int category;
- public RoomPromotion(Room room, String title, String description, int endTimestamp) {
+ public RoomPromotion(Room room, String title, String description, int endTimestamp, int startTimestamp, int category) {
this.room = room;
this.title = title;
this.description = description;
this.endTimestamp = endTimestamp;
+ this.startTimestamp = startTimestamp;
+ this.category = category;
}
public RoomPromotion(Room room, ResultSet set) throws SQLException {
@@ -26,14 +30,17 @@ public class RoomPromotion {
this.title = set.getString("title");
this.description = set.getString("description");
this.endTimestamp = set.getInt("end_timestamp");
+ this.startTimestamp = set.getInt("start_timestamp");
+ this.category = set.getInt("category");
}
public void save() {
if (this.needsUpdate) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_promotions SET title = ?, description = ? WHERE room_id = ?")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_promotions SET title = ?, description = ?, category = ? WHERE room_id = ?")) {
statement.setString(1, this.title);
statement.setString(2, this.description);
- statement.setInt(3, this.room.getId());
+ statement.setInt(3, this.category);
+ statement.setInt(4, this.room.getId());
statement.executeUpdate();
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
@@ -74,4 +81,20 @@ public class RoomPromotion {
public void addEndTimestamp(int time) {
this.endTimestamp += time;
}
+
+ public int getStartTimestamp() {
+ return startTimestamp;
+ }
+
+ public void setStartTimestamp(int startTimestamp) {
+ this.startTimestamp = startTimestamp;
+ }
+
+ public int getCategory() {
+ return category;
+ }
+
+ public void setCategory(int category) {
+ this.category = category;
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java
index 8f340378..0b912776 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java
@@ -15,6 +15,10 @@ import com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards.Int
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java
index 79ba7fab..6f72b1ff 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java
@@ -1,8 +1,12 @@
package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.*;
+import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate;
+import com.eu.habbo.habbohotel.items.interactions.InteractionHabboClubGate;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWater;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.RideablePet;
import com.eu.habbo.habbohotel.users.DanceType;
@@ -21,18 +25,20 @@ import gnu.trove.map.TMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
-import java.util.Deque;
-import java.util.LinkedList;
-import java.util.Map;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledFuture;
+import java.util.stream.Collectors;
public class RoomUnit {
+ public boolean isWiredTeleporting = false;
private final ConcurrentHashMap status;
private final THashMap cacheable;
public boolean canRotate = true;
public boolean animateWalk = false;
public boolean cmdTeleport = false;
public boolean cmdSit = false;
+ public boolean cmdStand = false;
public boolean cmdLay = false;
public boolean sitUpdate = false;
public boolean isTeleporting = false;
@@ -63,6 +69,7 @@ public class RoomUnit {
private int walkTimeOut;
private int effectId;
private int effectEndTimestamp;
+ private ScheduledFuture moveBlockingTask;
private int idleTimer;
private Room room;
@@ -173,6 +180,9 @@ public class RoomUnit {
}
Deque peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this);
+
+ if (peekPath == null) peekPath = new LinkedList<>();
+
if (peekPath.size() >= 3) {
if (path.isEmpty()) return true;
@@ -282,7 +292,7 @@ public class RoomUnit {
if (item != null) {
if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) {
if (item.canWalkOn(this, room, null)) {
- item.onWalkOn(this, room, null);
+ item.onWalkOn(this, room, new Object[]{this.getCurrentLocation(), next});
} else if (item instanceof InteractionGuildGate || item instanceof InteractionHabboClubGate) {
this.setRotation(oldRotation);
this.tilesWalked--;
@@ -297,7 +307,7 @@ public class RoomUnit {
return false;
}
} else {
- item.onWalk(this, room, null);
+ item.onWalk(this, room, new Object[]{this.getCurrentLocation(), next});
}
zHeight += item.getZ();
@@ -391,6 +401,13 @@ public class RoomUnit {
public void setZ(double z) {
this.z = z;
+
+ if (this.room != null) {
+ Bot bot = this.room.getBot(this);
+ if (bot != null) {
+ bot.needsUpdate(true);
+ }
+ }
}
public boolean isInRoom() {
@@ -532,10 +549,9 @@ public class RoomUnit {
public void findPath()
{
- if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation)))
- {
-
- this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
+ if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) {
+ Deque path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
+ if (path != null) this.path = path;
}
}
@@ -700,6 +716,9 @@ public class RoomUnit {
public boolean canOverrideTile(RoomTile tile) {
if (tile == null || room == null || room.getLayout() == null) return false;
+ if (room.getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, room, tile)))
+ return true;
+
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
return this.overridableTiles.contains(tileIndex);
}
@@ -712,6 +731,8 @@ public class RoomUnit {
}
public void removeOverrideTile(RoomTile tile) {
+ if (room == null || room.getLayout() == null) return;
+
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
this.overridableTiles.remove(tileIndex);
}
@@ -735,4 +756,44 @@ public class RoomUnit {
return topItem == null || (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem));
}
+
+ public RoomTile getClosestTile(List tiles) {
+ return tiles.stream().min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null);
+ }
+
+ public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) {
+ if(room == null) return null;
+
+ RoomTile baseTile = room.getLayout().getTile(x, y);
+
+ if (baseTile == null) return null;
+
+ List rotations = new ArrayList<>();
+ rotations.add(RoomUserRotation.SOUTH.getValue());
+ rotations.add(RoomUserRotation.NORTH.getValue());
+ rotations.add(RoomUserRotation.EAST.getValue());
+ rotations.add(RoomUserRotation.WEST.getValue());
+
+ if (diagonal) {
+ rotations.add(RoomUserRotation.NORTH_EAST.getValue());
+ rotations.add(RoomUserRotation.NORTH_WEST.getValue());
+ rotations.add(RoomUserRotation.SOUTH_EAST.getValue());
+ rotations.add(RoomUserRotation.SOUTH_WEST.getValue());
+ }
+
+ return this.getClosestTile(
+ rotations.stream()
+ .map(rotation -> room.getLayout().getTileInFront(baseTile, rotation))
+ .filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) || !room.hasHabbosAt(t.x, t.y)))
+ .collect(Collectors.toList())
+ );
+ }
+
+ public ScheduledFuture getMoveBlockingTask() {
+ return moveBlockingTask;
+ }
+
+ public void setMoveBlockingTask(ScheduledFuture moveBlockingTask) {
+ this.moveBlockingTask = moveBlockingTask;
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java
index 075ce283..334ddc17 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java
@@ -3,11 +3,15 @@ package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.core.Disposable;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.SoundTrack;
import com.eu.habbo.habbohotel.items.interactions.InteractionJukeBox;
import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
+import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
+import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer;
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer;
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxNowPlayingMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxPlayListComposer;
@@ -18,6 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
public class TraxManager implements Disposable {
private final Room room;
@@ -38,8 +43,18 @@ public class TraxManager implements Disposable {
statement.setInt(1, this.room.getId());
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
- HabboItem musicDisc = this.room.getHabboItem(set.getInt("item_id"));
- if (musicDisc instanceof InteractionMusicDisc) {
+ HabboItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id"));
+
+ if (!(musicDisc instanceof InteractionMusicDisc) || musicDisc.getRoomId() != -1) {
+ try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ? AND item_id = ? LIMIT 1")) {
+ stmt.setInt(1, this.room.getId());
+ stmt.setInt(2, musicDisc.getId());
+ stmt.execute();
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ return;
+ }
+ } else {
SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId());
if (track != null) {
@@ -128,29 +143,32 @@ public class TraxManager implements Disposable {
return null;
}
- public void addSong(int itemId) {
- HabboItem musicDisc = this.room.getHabboItem(itemId);
+ public void addSong(InteractionMusicDisc musicDisc, Habbo habbo) {
+ SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(musicDisc.getSongId());
- if (musicDisc instanceof InteractionMusicDisc) {
- SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId());
+ if (track != null) {
+ this.totalLength += track.getLength();
+ this.songs.add(musicDisc);
- if (track != null) {
- this.totalLength += track.getLength();
- this.songs.add((InteractionMusicDisc) musicDisc);
-
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_trax_playlist (room_id, item_id) VALUES (?, ?)")) {
- statement.setInt(1, this.room.getId());
- statement.setInt(2, itemId);
- statement.execute();
- } catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
- return;
- }
-
- this.room.sendComposer(new JukeBoxPlayListComposer(this.songs, this.totalLength).compose());
- this.room.sendComposer(new JukeBoxMySongsComposer(this.myList()).compose());
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_trax_playlist (room_id, item_id) VALUES (?, ?)")) {
+ statement.setInt(1, this.room.getId());
+ statement.setInt(2, musicDisc.getId());
+ statement.execute();
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ return;
}
+
+ this.room.sendComposer(new JukeBoxPlayListComposer(this.songs, this.totalLength).compose());
+
+ musicDisc.setRoomId(-1);
+ musicDisc.needsUpdate(true);
+
+ habbo.getInventory().getItemsComponent().removeHabboItem(musicDisc);
+ habbo.getClient().sendResponse(new RemoveHabboItemComposer(musicDisc.getGiftAdjustedId()));
}
+
+ this.sendUpdatedSongList();
}
public void removeSong(int itemId) {
@@ -174,8 +192,34 @@ public class TraxManager implements Disposable {
}
this.room.sendComposer(new JukeBoxPlayListComposer(this.songs, this.totalLength).compose());
+
+ musicDisc.setRoomId(0);
+ musicDisc.needsUpdate(true);
+
+ Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getUserId());
+
+ if (owner != null) {
+ owner.getInventory().getItemsComponent().addItem(musicDisc);
+
+ GameClient client = owner.getClient();
+ if (client != null) {
+ client.sendResponse(new AddHabboItemComposer(musicDisc));
+ client.sendResponse(new InventoryRefreshComposer());
+ }
+ }
}
- this.room.sendComposer(new JukeBoxMySongsComposer(this.myList()).compose());
+
+ this.sendUpdatedSongList();
+ }
+
+ public void sendUpdatedSongList() {
+ this.room.getHabbos().forEach(h -> {
+ GameClient client = h.getClient();
+
+ if (client != null) {
+ client.sendResponse(new JukeBoxMySongsComposer(this.myList(h)));
+ }
+ });
}
public int timePlaying() {
@@ -208,21 +252,16 @@ public class TraxManager implements Disposable {
return trax;
}
- public List myList() {
- List trax = new ArrayList<>();
-
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionMusicDisc.class)) {
- if (!this.songs.contains(item)) {
- trax.add((InteractionMusicDisc) item);
- }
- }
-
- return trax;
+ public List myList(Habbo habbo) {
+ return habbo.getInventory().getItemsComponent().getItems().valueCollection().stream()
+ .filter(i -> i instanceof InteractionMusicDisc && i.getRoomId() == 0)
+ .map(i -> (InteractionMusicDisc) i)
+ .collect(Collectors.toList());
}
public InteractionMusicDisc fromItemId(int itemId) {
for (InteractionMusicDisc musicDisc : this.songs) {
- if (musicDisc.getId() == itemId) {
+ if (musicDisc != null && musicDisc.getId() == itemId) {
return musicDisc;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java
index 0838c76f..b3fb1399 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java
@@ -378,14 +378,14 @@ public class Habbo implements Runnable {
}
}
- public void mute(int seconds) {
+ public void mute(int seconds, boolean isFlood) {
if (!this.hasPermission("acc_no_mute")) {
int remaining = this.habboStats.addMuteTime(seconds);
this.client.sendResponse(new FloodCounterComposer(remaining));
this.client.sendResponse(new MutedWhisperComposer(remaining));
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
- if (room != null) {
+ if (room != null && !isFlood) {
room.sendComposer(new RoomUserIgnoredComposer(this, RoomUserIgnoredComposer.MUTED).compose());
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java
index 5ac1bc7c..f689c504 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java
@@ -9,10 +9,8 @@ import com.eu.habbo.habbohotel.items.FurnitureType;
import com.eu.habbo.habbohotel.items.IEventTriggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.*;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomLayout;
-import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
+import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@@ -20,20 +18,28 @@ import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer;
-import com.eu.habbo.util.figure.FigureUtil;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.math3.util.Pair;
+import java.awt.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Deque;
import java.util.List;
public abstract class HabboItem implements Runnable, IEventTriggers {
+ private static Class[] TOGGLING_INTERACTIONS = new Class[]{
+ InteractionGameTimer.class,
+ InteractionWired.class,
+ InteractionWiredHighscore.class,
+ InteractionMultiHeight.class
+ };
+
private int id;
private int userId;
private int roomId;
@@ -60,7 +66,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
this.y = set.getShort("y");
this.z = set.getDouble("z");
this.rotation = set.getInt("rot");
- this.extradata = set.getString("extra_data");
+ this.extradata = set.getString("extra_data").isEmpty() ? "0" : set.getString("extra_data");
String ltdData = set.getString("limited_data");
if (!ltdData.isEmpty()) {
@@ -79,7 +85,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
this.y = 0;
this.z = 0;
this.rotation = 0;
- this.extradata = extradata;
+ this.extradata = extradata.isEmpty() ? "0" : extradata;
this.limitedSells = limitedSells;
this.limitedStack = limitedStack;
}
@@ -283,8 +289,9 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
}
}
-
- WiredHandler.handle(WiredTriggerType.STATE_CHANGED, client.getHabbo().getRoomUnit(), room, new Object[]{this});
+ if ((this.getBaseItem().getStateCount() > 1 && !(this instanceof InteractionDice)) || Arrays.asList(HabboItem.TOGGLING_INTERACTIONS).contains(this.getClass()) || (objects != null && objects.length == 1 && objects[0].equals("TOGGLE_OVERRIDE"))) {
+ WiredHandler.handle(WiredTriggerType.STATE_CHANGED, client.getHabbo().getRoomUnit(), room, new Object[]{this});
+ }
}
}
@@ -479,4 +486,30 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
}
public boolean invalidatesToRoomKick() { return false; }
+
+ public List getOccupyingTiles(RoomLayout layout) {
+ List tiles = new ArrayList<>();
+
+ Rectangle rect = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
+
+ for (int i = rect.x; i < rect.x + rect.getWidth(); i++) {
+ for (int j = rect.y; j < rect.y + rect.getHeight(); j++) {
+ tiles.add(layout.getTile((short) i, (short) j));
+ }
+ }
+
+ return tiles;
+ }
+
+ public RoomTile getOverrideGoalTile(RoomUnit unit, Room room, RoomTile tile) {
+ return tile;
+ }
+
+ public RoomTileState getOverrideTileState(RoomTile tile, Room room) {
+ return null;
+ }
+
+ public boolean canOverrideTile(RoomUnit unit, Room room, RoomTile tile) {
+ return false;
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java
index 0a1a6b00..27adcc59 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java
@@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.modtool.ModToolBan;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.permissions.Rank;
+import com.eu.habbo.habbohotel.users.inventory.EffectsComponent;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.catalog.*;
import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer;
@@ -246,7 +247,9 @@ public class HabboManager {
Rank oldRank = habbo.getHabboInfo().getRank();
if (!oldRank.getBadge().isEmpty()) {
habbo.deleteBadge(habbo.getInventory().getBadgesComponent().getBadge(oldRank.getBadge()));
- //BadgesComponent.deleteBadge(userId, oldRank.getBadge()); // unnecessary as Habbo.deleteBadge does this
+ }
+ if(oldRank.getRoomEffect() > 0) {
+ habbo.getInventory().getEffectsComponent().effects.remove(oldRank.getRoomEffect());
}
habbo.getHabboInfo().setRank(newRank);
@@ -255,6 +258,10 @@ public class HabboManager {
habbo.addBadge(newRank.getBadge());
}
+ if(newRank.getRoomEffect() > 0) {
+ habbo.getInventory().getEffectsComponent().createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect());
+ }
+
habbo.getClient().sendResponse(new UserPermissionsComposer(habbo));
habbo.getClient().sendResponse(new UserPerksComposer(habbo));
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java
index b0da325b..591ab435 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java
@@ -14,12 +14,11 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class EffectsComponent {
- public final THashMap effects;
+ public final THashMap effects = new THashMap<>();
public final Habbo habbo;
public int activatedEffect = 0;
public EffectsComponent(Habbo habbo) {
- this.effects = new THashMap<>();
this.habbo = habbo;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_effects WHERE user_id = ?")) {
statement.setInt(1, habbo.getHabboInfo().getId());
@@ -31,6 +30,8 @@ public class EffectsComponent {
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
}
+ if(habbo.getHabboInfo().getRank().getRoomEffect() > 0)
+ this.createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect());
}
public HabboEffect createEffect(int effectId) {
@@ -58,6 +59,17 @@ public class EffectsComponent {
return effect;
}
+ public HabboEffect createRankEffect(int effectId) {
+ HabboEffect rankEffect = new HabboEffect(effectId, habbo.getHabboInfo().getId());
+ rankEffect.duration = 0;
+ rankEffect.isRankEnable = true;
+ rankEffect.activationTimestamp = Emulator.getIntUnixTimestamp();
+ rankEffect.enabled = true;
+ this.effects.put(effectId, rankEffect);
+ this.activatedEffect = effectId; // enabled by default
+ return rankEffect;
+ }
+
public void addEffect(HabboEffect effect) {
this.effects.put(effect.effect, effect);
@@ -67,9 +79,8 @@ public class EffectsComponent {
public void dispose() {
synchronized (this.effects) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET duration = ?, activation_timestamp = ?, total = ? WHERE user_id = ? AND effect = ?")) {
- this.effects.forEachValue(new TObjectProcedure() {
- @Override
- public boolean execute(HabboEffect effect) {
+ this.effects.forEachValue(effect -> {
+ if(!effect.isRankEnable) {
try {
statement.setInt(1, effect.duration);
statement.setInt(2, effect.activationTimestamp);
@@ -80,9 +91,8 @@ public class EffectsComponent {
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
}
-
- return true;
}
+ return true;
});
statement.executeBatch();
@@ -145,6 +155,7 @@ public class EffectsComponent {
public int activationTimestamp = -1;
public int total = 1;
public boolean enabled = false;
+ public boolean isRankEnable = false;
public HabboEffect(ResultSet set) throws SQLException {
this.effect = set.getInt("effect");
diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java
index ac1b2cc7..ce4b7361 100644
--- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java
+++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java
@@ -139,12 +139,11 @@ public class WiredHandler {
}
for (InteractionWiredCondition condition : conditions) {
- if ((condition.operator() == WiredConditionOperator.OR && matchedConditions.contains(condition.getType())) ||
- (condition.operator() == WiredConditionOperator.AND && condition.execute(roomUnit, room, stuff))) {
- condition.activateBox(room);
- } else {
- if (!Emulator.getPluginManager().fireEvent(new WiredConditionFailedEvent(room, roomUnit, trigger, condition)).isCancelled())
- return false;
+ if (!((condition.operator() == WiredConditionOperator.OR && matchedConditions.contains(condition.getType())) ||
+ (condition.operator() == WiredConditionOperator.AND && condition.execute(roomUnit, room, stuff))) &&
+ !Emulator.getPluginManager().fireEvent(new WiredConditionFailedEvent(room, roomUnit, trigger, condition)).isCancelled()) {
+
+ return false;
}
}
}
@@ -194,19 +193,16 @@ public class WiredHandler {
if (effect != null && effect.canExecute(millis)) {
executed = true;
if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) {
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- if (room.isLoaded()) {
- try {
- if (!effect.execute(roomUnit, room, stuff)) return;
- effect.setCooldown(millis);
- } catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
- }
-
- effect.activateBox(room);
+ Emulator.getThreading().run(() -> {
+ if (room.isLoaded()) {
+ try {
+ if (!effect.execute(roomUnit, room, stuff)) return;
+ effect.setCooldown(millis);
+ } catch (Exception e) {
+ Emulator.getLogging().logErrorLine(e);
}
+
+ effect.activateBox(room);
}
}, effect.getDelay() * 500);
}
@@ -415,16 +411,16 @@ public class WiredHandler {
}
public static void resetTimers(Room room) {
- if (!room.isLoaded())
+ if (!room.isLoaded() || room.getRoomSpecialTypes() == null)
return;
- THashSet triggers = room.getRoomSpecialTypes().getTriggers(WiredTriggerType.AT_GIVEN_TIME);
-
- if (triggers != null) {
- for (InteractionWiredTrigger trigger : triggers) {
- ((WiredTriggerReset) trigger).resetTimer();
+ room.getRoomSpecialTypes().getTriggers().forEach(t -> {
+ if (t == null) return;
+
+ if (t.getType() == WiredTriggerType.AT_GIVEN_TIME || t.getType() == WiredTriggerType.PERIODICALLY || t.getType() == WiredTriggerType.PERIODICALLY_LONG) {
+ ((WiredTriggerReset) t).resetTimer();
}
- }
+ });
room.setLastTimerReset(Emulator.getIntUnixTimestamp());
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java
index 1873b2de..5e797bec 100644
--- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java
@@ -92,7 +92,7 @@ public class WiredHighscoreManager {
public List getHighscoreRowsForItem(int itemId, WiredHighscoreClearType clearType, WiredHighscoreScoreType scoreType) {
if (!this.data.containsKey(itemId)) return null;
- Stream highscores = this.data.get(itemId).stream()
+ Stream highscores = new ArrayList<>(this.data.get(itemId)).stream()
.filter(entry -> this.timeMatchesEntry(entry, clearType) && (scoreType != WiredHighscoreScoreType.MOSTWIN || entry.isWin()))
.map(entry -> new WiredHighscoreRow(
entry.getUserIds().stream()
diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java
index 7cda01db..8acc8689 100644
--- a/src/main/java/com/eu/habbo/messages/PacketManager.java
+++ b/src/main/java/com/eu/habbo/messages/PacketManager.java
@@ -31,6 +31,7 @@ import com.eu.habbo.messages.incoming.guides.*;
import com.eu.habbo.messages.incoming.guilds.*;
import com.eu.habbo.messages.incoming.guilds.forums.*;
import com.eu.habbo.messages.incoming.handshake.*;
+import com.eu.habbo.messages.incoming.helper.MySanctionStatusEvent;
import com.eu.habbo.messages.incoming.helper.RequestTalentTrackEvent;
import com.eu.habbo.messages.incoming.hotelview.*;
import com.eu.habbo.messages.incoming.inventory.RequestInventoryBadgesEvent;
@@ -170,6 +171,20 @@ public class PacketManager {
return;
}
+ final MessageHandler handler = handlerClass.newInstance();
+
+ if (handler.getRatelimit() > 0) {
+ if (client.messageTimestamps.containsKey(handlerClass) && System.currentTimeMillis() - client.messageTimestamps.get(handlerClass) < handler.getRatelimit()) {
+ if (PacketManager.DEBUG_SHOW_PACKETS) {
+ Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "][" + Logging.ANSI_RED + "RATELIMITED" + Logging.ANSI_RESET + "] => " + packet.getMessageBody());
+ }
+
+ return;
+ } else {
+ client.messageTimestamps.put(handlerClass, System.currentTimeMillis());
+ }
+ }
+
if (PacketManager.DEBUG_SHOW_PACKETS)
Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody());
@@ -177,8 +192,6 @@ public class PacketManager {
System.out.println(("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + client.getHabbo().getHabboInfo().getUsername() + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()));
}
- final MessageHandler handler = handlerClass.newInstance();
-
handler.client = client;
handler.packet = packet;
@@ -338,13 +351,14 @@ public class PacketManager {
this.registerHandler(Incoming.HotelViewRequestBadgeRewardEvent, HotelViewRequestBadgeRewardEvent.class);
this.registerHandler(Incoming.HotelViewClaimBadgeRewardEvent, HotelViewClaimBadgeRewardEvent.class);
this.registerHandler(Incoming.HotelViewRequestLTDAvailabilityEvent, HotelViewRequestLTDAvailabilityEvent.class);
+ this.registerHandler(Incoming.HotelViewRequestSecondsUntilEvent, HotelViewRequestSecondsUntilEvent.class);
}
private void registerInventory() throws Exception {
- //this.registerHandler(Incoming.TestInventoryEvent, TestInventoryEvent.class);
this.registerHandler(Incoming.RequestInventoryBadgesEvent, RequestInventoryBadgesEvent.class);
this.registerHandler(Incoming.RequestInventoryBotsEvent, RequestInventoryBotsEvent.class);
this.registerHandler(Incoming.RequestInventoryItemsEvent, RequestInventoryItemsEvent.class);
+ this.registerHandler(Incoming.HotelViewInventoryEvent, RequestInventoryItemsEvent.class);
this.registerHandler(Incoming.RequestInventoryPetsEvent, RequestInventoryPetsEvent.class);
}
@@ -439,6 +453,7 @@ public class PacketManager {
this.registerHandler(Incoming.RoomFavoriteEvent, RoomFavoriteEvent.class);
this.registerHandler(Incoming.LoveLockStartConfirmEvent, LoveLockStartConfirmEvent.class);
this.registerHandler(Incoming.RoomUnFavoriteEvent, RoomUnFavoriteEvent.class);
+ this.registerHandler(Incoming.UseRandomStateItemEvent, UseRandomStateItemEvent.class);
}
void registerPolls() throws Exception {
@@ -539,9 +554,10 @@ public class PacketManager {
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
- this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class);
+ this.registerHandler(Incoming.PetUseItemEvent, PetUseItemEvent.class);
this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class);
this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class);
+ this.registerHandler(Incoming.HorseRemoveSaddleEvent, HorseRemoveSaddleEvent.class);
this.registerHandler(Incoming.ToggleMonsterplantBreedableEvent, ToggleMonsterplantBreedableEvent.class);
this.registerHandler(Incoming.CompostMonsterplantEvent, CompostMonsterplantEvent.class);
this.registerHandler(Incoming.BreedMonsterplantsEvent, BreedMonsterplantsEvent.class);
@@ -561,6 +577,7 @@ public class PacketManager {
this.registerHandler(Incoming.RequestResolutionEvent, RequestResolutionEvent.class);
this.registerHandler(Incoming.RequestTalenTrackEvent, RequestTalentTrackEvent.class);
this.registerHandler(Incoming.UnknownEvent1, UnknownEvent1.class);
+ this.registerHandler(Incoming.MySanctionStatusEvent, MySanctionStatusEvent.class);
}
void registerFloorPlanEditor() throws Exception {
diff --git a/src/main/java/com/eu/habbo/messages/PacketManager_1006.java b/src/main/java/com/eu/habbo/messages/PacketManager_1006.java
index a7241c2d..93edd722 100644
--- a/src/main/java/com/eu/habbo/messages/PacketManager_1006.java
+++ b/src/main/java/com/eu/habbo/messages/PacketManager_1006.java
@@ -228,6 +228,7 @@ public class PacketManager_1006 {
this.registerHandler(Incoming.RequestInventoryBadgesEvent, RequestInventoryBadgesEvent.class);
this.registerHandler(Incoming.RequestInventoryBotsEvent, RequestInventoryBotsEvent.class);
this.registerHandler(Incoming.RequestInventoryItemsEvent, RequestInventoryItemsEvent.class);
+ this.registerHandler(Incoming.HotelViewInventoryEvent, RequestInventoryItemsEvent.class);
this.registerHandler(Incoming.RequestInventoryPetsEvent, RequestInventoryPetsEvent.class);
}
@@ -371,7 +372,7 @@ public class PacketManager_1006 {
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
- this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class);
+ this.registerHandler(Incoming.PetUseItemEvent, PetUseItemEvent.class);
this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class);
this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class);
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java
index 0b70e95b..dea1137b 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java
@@ -64,7 +64,8 @@ public class Incoming {
public static final int SearchRoomsFriendsNowEvent = 1786;
public static final int SetStackHelperHeightEvent = 3839;
public static final int RedeemVoucherEvent = 339;
- public static final int HorseUseItemEvent = 1328;
+ public static final int PetUseItemEvent = 1328;
+ public static final int HorseRemoveSaddleEvent = 186;
public static final int BuyItemEvent = 1603;
public static final int AdvertisingSaveEvent = 3608;
public static final int RequestPetTrainingPanelEvent = 2161;
@@ -136,7 +137,7 @@ public class Incoming {
public static final int RequestAchievementsEvent = 219;
public static final int GuildChangeColorsEvent = 1764;
public static final int RequestInventoryBadgesEvent = 2769;
- public static final int TestInventoryEvent = 3500;
+ public static final int HotelViewInventoryEvent = 3500;
public static final int RequestPetBreedsEvent = 1756;
public static final int GuildChangeBadgeEvent = 1991;
public static final int ModToolBanEvent = -1;
@@ -216,6 +217,10 @@ public class Incoming {
public static final int PostItRequestDataEvent = 3964;
public static final int PostItSaveDataEvent = 3666;
public static final int PostItDeleteEvent = 3336;
+ public static final int UseRandomStateItemEvent = 3617;
+
+ public static final int MySanctionStatusEvent = 2746;
+
public static final int MoodLightSaveSettingsEvent = 1648;
public static final int ModToolRequestIssueChatlogEvent = 211;
public static final int ModToolRequestRoomUserChatlogEvent = -1;
@@ -255,6 +260,7 @@ public class Incoming {
public static final int RequestDeleteRoomEvent = 532;
public static final int RequestPromotionRoomsEvent = 1075;
public static final int BuyRoomPromotionEvent = 777;
+ public static final int EditRoomPromotionMessageEvent = 3991;
public static final int RequestGuideToolEvent = 1922;
public static final int RequestGuideAssistanceEvent = 3338;
public static final int GuideUserTypingEvent = 519;
@@ -310,7 +316,6 @@ public class Incoming {
public static final int YoutubeRequestStateChange = 3005;
public static final int YoutubeRequestPlaylistChange = 2069;
- public static final int EditRoomPromotionMessageEvent = 3707;
public static final int HotelViewRequestBadgeRewardEvent = 2318;
public static final int HotelViewClaimBadgeRewardEvent = -1;
@@ -347,6 +352,8 @@ public class Incoming {
public static final int LoveLockStartConfirmEvent = 3775;
public static final int HotelViewRequestLTDAvailabilityEvent = 410;
+ public static final int HotelViewRequestSecondsUntilEvent = 271;
+
public static final int PurchaseTargetOfferEvent = 1826;
public static final int TargetOfferStateEvent = 2041;
public static final int StopBreedingEvent = 2713;
diff --git a/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java b/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java
index 98baf3b6..38920afe 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java
@@ -9,4 +9,8 @@ public abstract class MessageHandler {
public boolean isCancelled = false;
public abstract void handle() throws Exception;
+
+ public int getRatelimit() {
+ return 0;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java
index 537765e4..5b16fead 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java
@@ -1,8 +1,10 @@
package com.eu.habbo.messages.incoming.camera;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.camera.CameraPublishWaitMessageComposer;
+import com.eu.habbo.messages.outgoing.catalog.NotEnoughPointsTypeComposer;
import com.eu.habbo.plugin.events.users.UserPublishPictureEvent;
import java.sql.Connection;
@@ -10,40 +12,49 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
public class CameraPublishToWebEvent extends MessageHandler {
+ public static int CAMERA_PUBLISH_POINTS = 5;
+ public static int CAMERA_PUBLISH_POINTS_TYPE = 0;
+
@Override
public void handle() throws Exception {
- if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) {
- if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) {
- if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) {
- int timestamp = Emulator.getIntUnixTimestamp();
+ Habbo habbo = this.client.getHabbo();
- boolean published = false;
- int timeDiff = timestamp - this.client.getHabbo().getHabboInfo().getWebPublishTimestamp();
- int wait = 0;
- if (timeDiff < Emulator.getConfig().getInt("camera.publish.delay")) {
- wait = timeDiff - Emulator.getConfig().getInt("camera.publish.delay");
- } else {
- UserPublishPictureEvent publishPictureEvent = new UserPublishPictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), timestamp, this.client.getHabbo().getHabboInfo().getPhotoRoomId());
- if (!Emulator.getPluginManager().fireEvent(publishPictureEvent).isCancelled()) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO camera_web (user_id, room_id, timestamp, url) VALUES (?, ?, ?, ?)")) {
- statement.setInt(1, this.client.getHabbo().getHabboInfo().getId());
- statement.setInt(2, publishPictureEvent.roomId);
- statement.setInt(3, publishPictureEvent.timestamp);
- statement.setString(4, publishPictureEvent.URL);
- statement.execute();
- this.client.getHabbo().getHabboInfo().setWebPublishTimestamp(timestamp);
- published = true;
- } catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
- }
- } else {
- return;
- }
- }
+ if (habbo == null) return;
+ if (habbo.getHabboInfo().getPhotoTimestamp() == 0) return;
+ if (habbo.getHabboInfo().getPhotoJSON().isEmpty()) return;
+ if (!habbo.getHabboInfo().getPhotoJSON().contains(habbo.getHabboInfo().getPhotoTimestamp() + "")) return;
- this.client.sendResponse(new CameraPublishWaitMessageComposer(published, wait, published ? this.client.getHabbo().getHabboInfo().getPhotoURL() : ""));
+ if (habbo.getHabboInfo().getCurrencyAmount(CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS_TYPE) < CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS) {
+ this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS));
+ return;
+ }
+
+ int timestamp = Emulator.getIntUnixTimestamp();
+
+ boolean isOk = false;
+ int cooldownLeft = Math.max(0, Emulator.getConfig().getInt("camera.publish.delay") - (timestamp - this.client.getHabbo().getHabboInfo().getWebPublishTimestamp()));
+
+ if (cooldownLeft == 0) {
+ UserPublishPictureEvent publishPictureEvent = new UserPublishPictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), timestamp, this.client.getHabbo().getHabboInfo().getPhotoRoomId());
+
+ if (!Emulator.getPluginManager().fireEvent(publishPictureEvent).isCancelled()) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO camera_web (user_id, room_id, timestamp, url) VALUES (?, ?, ?, ?)")) {
+ statement.setInt(1, this.client.getHabbo().getHabboInfo().getId());
+ statement.setInt(2, publishPictureEvent.roomId);
+ statement.setInt(3, publishPictureEvent.timestamp);
+ statement.setString(4, publishPictureEvent.URL);
+ statement.execute();
+
+ this.client.getHabbo().getHabboInfo().setWebPublishTimestamp(timestamp);
+ this.client.getHabbo().givePoints(CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS_TYPE, -CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS);
+
+ isOk = true;
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
}
}
}
+
+ this.client.sendResponse(new CameraPublishWaitMessageComposer(isOk, cooldownLeft, isOk ? this.client.getHabbo().getHabboInfo().getPhotoURL() : ""));
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java
index 351f4be5..173f3ca3 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java
@@ -11,34 +11,47 @@ import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import com.eu.habbo.plugin.events.users.UserPurchasePictureEvent;
public class CameraPurchaseEvent extends MessageHandler {
+ public static int CAMERA_PURCHASE_CREDITS = 5;
+ public static int CAMERA_PURCHASE_POINTS = 5;
+ public static int CAMERA_PURCHASE_POINTS_TYPE = 0;
+
@Override
public void handle() throws Exception {
- if (this.client.getHabbo().getHabboInfo().getCredits() < Emulator.getConfig().getInt("camera.price.credits") || this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points")) {
- this.client.sendResponse(new NotEnoughPointsTypeComposer(this.client.getHabbo().getHabboInfo().getCredits() < Emulator.getConfig().getInt("camera.price.credits"), this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points"), 0));
+ if (this.client.getHabbo().getHabboInfo().getCredits() < CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS) {
+ this.client.sendResponse(new NotEnoughPointsTypeComposer(true, false, 0));
return;
}
- if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) {
- if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) {
- if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) {
- if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) {
- return;
- }
- HabboItem photoItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("camera.item_id")), 0, 0, this.client.getHabbo().getHabboInfo().getPhotoJSON());
+ if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE) < CameraPurchaseEvent.CAMERA_PURCHASE_POINTS) {
+ this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE));
+ return;
+ }
- if (photoItem != null) {
- photoItem.setExtradata(photoItem.getExtradata().replace("%id%", photoItem.getId() + ""));
- photoItem.needsUpdate(true);
- this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem);
- this.client.sendResponse(new CameraPurchaseSuccesfullComposer());
- this.client.sendResponse(new AddHabboItemComposer(photoItem));
- this.client.sendResponse(new InventoryRefreshComposer());
- this.client.getHabbo().giveCredits(-Emulator.getConfig().getInt("camera.price.credits"));
- this.client.getHabbo().givePixels(-Emulator.getConfig().getInt("camera.price.points"));
- AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("CameraPhotoCount"));
- }
- }
- }
+ if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() == 0) return;
+ if (this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) return;
+ if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + ""))
+ return;
+
+ if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) {
+ return;
+ }
+
+ HabboItem photoItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("camera.item_id")), 0, 0, this.client.getHabbo().getHabboInfo().getPhotoJSON());
+
+ if (photoItem != null) {
+ photoItem.setExtradata(photoItem.getExtradata().replace("%id%", photoItem.getId() + ""));
+ photoItem.needsUpdate(true);
+
+ this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem);
+
+ this.client.sendResponse(new CameraPurchaseSuccesfullComposer());
+ this.client.sendResponse(new AddHabboItemComposer(photoItem));
+ this.client.sendResponse(new InventoryRefreshComposer());
+
+ this.client.getHabbo().giveCredits(-CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS);
+ this.client.getHabbo().givePoints(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE, -CameraPurchaseEvent.CAMERA_PURCHASE_POINTS);
+
+ AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("CameraPhotoCount"));
}
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java
index ac8902e4..113dd0e3 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java
@@ -58,6 +58,11 @@ public class FloorPlanEditorSaveEvent extends MessageHandler {
if (mapRows.length > 64) errors.add("${notification.floorplan_editor.error.message.too_large_height}");
else if (Arrays.stream(mapRows).anyMatch(l -> l.length() > 64 || l.length() == 0)) errors.add("${notification.floorplan_editor.error.message.too_large_width}");
+
+ if (errors.length() > 0) {
+ this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errors.toString()));
+ return;
+ }
}
int doorX = this.packet.readInt();
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java
index 5d12d01d..9e04a545 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java
@@ -18,7 +18,7 @@ public class GuildConfirmRemoveMemberEvent extends MessageHandler {
if (guild != null) {
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)) || this.client.getHabbo().hasPermission("acc_guild_admin")) {
+ if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.OWNER)) || this.client.getHabbo().hasPermission("acc_guild_admin")) {
Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId());
int count = 0;
if (room != null) {
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java
index e2aede92..e67945d6 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java
@@ -22,7 +22,7 @@ public class GuildDeclineMembershipEvent extends MessageHandler {
if (guild != null) {
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.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) {
+ if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission("acc_guild_admin")) {
guild.decreaseRequestCount();
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, "")));
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java
index cfcada6c..beb69560 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java
@@ -22,7 +22,7 @@ public class GuildRemoveMemberEvent extends MessageHandler {
if (guild != null) {
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.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) {
+ if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission("acc_guild_admin")) {
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo);
Emulator.getPluginManager().fireEvent(removedMemberEvent);
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java
index bb5a5de4..811dca2c 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java
@@ -21,7 +21,7 @@ public class RequestGuildJoinEvent extends MessageHandler {
if (guild == null)
return;
- if (guild.getState() == GuildState.CLOSED) {
+ if (guild.getState() == GuildState.CLOSED || guild.getState() == GuildState.LARGE_CLOSED) {
this.client.sendResponse(new GuildJoinErrorComposer(GuildJoinErrorComposer.GROUP_CLOSED));
return;
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java
index b1c1e873..f8ec7693 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java
@@ -21,7 +21,7 @@ public class RequestGuildMembersEvent extends MessageHandler {
boolean isAdmin = this.client.getHabbo().hasPermission("acc_guild_admin");
if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) {
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(g, this.client.getHabbo());
- isAdmin = member != null && (member.getRank().equals(GuildRank.ADMIN) || member.getRank().equals(GuildRank.MOD));
+ isAdmin = member != null && (member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN));
}
this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), this.client.getHabbo(), pageId, levelId, query, isAdmin, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(g, pageId, levelId, query)));
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java
index 88fec7ab..ab78d2c0 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java
@@ -16,5 +16,9 @@ public class GuildForumDataEvent extends MessageHandler {
return;
this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo()));
+
+ if (!Emulator.getGameEnvironment().getGuildManager().hasViewedForum(this.client.getHabbo().getHabboInfo().getId(), guildId)) {
+ Emulator.getGameEnvironment().getGuildManager().addView(this.client.getHabbo().getHabboInfo().getId(), guildId);
+ }
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java
index a47a52bc..9dc377e3 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java
@@ -11,6 +11,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Set;
public class GuildForumListEvent extends MessageHandler {
@Override
@@ -19,14 +20,14 @@ public class GuildForumListEvent extends MessageHandler {
int offset = this.packet.readInt();
int amount = this.packet.readInt();
- THashSet guilds = null;
+ Set guilds = null;
switch (mode) {
case 0: // most active
- guilds = getPopularForums();
+ guilds = getActiveForums();
break;
case 1: // most viewed
- guilds = getPopularForums();
+ guilds = Emulator.getGameEnvironment().getGuildManager().getMostViewed();
break;
case 2: // my groups
@@ -39,14 +40,16 @@ public class GuildForumListEvent extends MessageHandler {
}
}
- private THashSet getPopularForums() {
+ private THashSet getActiveForums() {
THashSet guilds = new THashSet();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT `guilds`.`id`, SUM(`guilds_forums_threads`.`posts_count`) AS `post_count` " +
"FROM `guilds_forums_threads` " +
"LEFT JOIN `guilds` ON `guilds`.`id` = `guilds_forums_threads`.`guild_id` " +
+ "WHERE `guilds`.`read_forum` = 'EVERYONE' AND `guilds_forums_threads`.`created_at` > ? " +
"GROUP BY `guilds`.`id` " +
"ORDER BY `post_count` DESC LIMIT 100")) {
+ statement.setInt(1, Emulator.getIntUnixTimestamp() - 7 * 24 * 60 * 60);
ResultSet set = statement.executeQuery();
while (set.next()) {
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java
index c156a9af..9f8ab11f 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java
@@ -60,6 +60,8 @@ public class GuildForumModerateMessageEvent extends MessageHandler {
comment.setAdminId(this.client.getHabbo().getHabboInfo().getId());
this.client.sendResponse(new PostUpdateMessageComposer(guild.getId(), thread.getThreadId(), comment));
+ Emulator.getThreading().run(comment);
+
switch (state) {
case 10:
case 20:
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java
index 1aaea3d6..6fdea270 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java
@@ -10,6 +10,7 @@ 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.GuildForumThreadMessagesComposer;
+import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadsComposer;
import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer;
@@ -51,6 +52,8 @@ public class GuildForumModerateThreadEvent extends MessageHandler {
thread.setState(ForumThreadState.fromValue(state));
thread.setAdminId(this.client.getHabbo().getHabboInfo().getId());
+ thread.run();
+
switch (state) {
case 10:
case 20:
@@ -62,5 +65,6 @@ public class GuildForumModerateThreadEvent extends MessageHandler {
}
this.client.sendResponse(new GuildForumThreadMessagesComposer(thread));
+ this.client.sendResponse(new GuildForumThreadsComposer(guild, 0));
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java
index e2004257..a73b9b27 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java
@@ -7,6 +7,8 @@ import com.eu.habbo.habbohotel.guilds.GuildRank;
import com.eu.habbo.habbohotel.guilds.SettingsState;
import com.eu.habbo.habbohotel.guilds.forums.ForumThread;
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.GuildForumThreadsComposer;
import com.eu.habbo.messages.outgoing.guilds.forums.ThreadUpdatedMessageComposer;
import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer;
@@ -42,9 +44,24 @@ public class GuildForumThreadUpdateEvent extends MessageHandler {
return;
}
+ boolean pinChanged = isPinned != thread.isPinned();
+ if (pinChanged) {
+ this.client.sendResponse(new BubbleAlertComposer(isPinned ? BubbleAlertKeys.FORUMS_THREAD_PINNED.key : BubbleAlertKeys.FORUMS_THREAD_UNPINNED.key).compose());
+ }
+
+ if (isLocked != thread.isLocked()) {
+ this.client.sendResponse(new BubbleAlertComposer(isLocked ? BubbleAlertKeys.FORUMS_THREAD_LOCKED.key : BubbleAlertKeys.FORUMS_THREAD_UNLOCKED.key).compose());
+ }
+
+ thread.setPinned(isPinned);
+ thread.setLocked(isLocked);
+
+ thread.run();
+
+
this.client.sendResponse(new ThreadUpdatedMessageComposer(guild, thread, this.client.getHabbo(), isPinned, isLocked));
- if (isPinned) {
+ if (pinChanged) {
this.client.sendResponse(new GuildForumThreadsComposer(guild, 0));
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java
index 28d985e7..0a8f2685 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java
@@ -2,6 +2,8 @@ package com.eu.habbo.messages.incoming.handshake;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.messenger.Messenger;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo;
@@ -25,13 +27,17 @@ import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer;
import com.eu.habbo.messages.outgoing.modtool.CfhTopicsMessageComposer;
import com.eu.habbo.messages.outgoing.modtool.ModToolComposer;
+import com.eu.habbo.messages.outgoing.modtool.ModToolSanctionInfoComposer;
import com.eu.habbo.messages.outgoing.navigator.*;
import com.eu.habbo.messages.outgoing.unknown.BuildersClubExpiredComposer;
import com.eu.habbo.messages.outgoing.users.*;
import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent;
import com.eu.habbo.plugin.events.users.UserLoginEvent;
+import gnu.trove.map.hash.THashMap;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
@NoAuthMessage
public class SecureLoginEvent extends MessageHandler {
@@ -96,7 +102,7 @@ public class SecureLoginEvent extends MessageHandler {
messages.add(new SecureLoginOKComposer().compose());
messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0).compose());
- messages.add(new UserEffectsListComposer(habbo, client.getHabbo().getInventory().getEffectsComponent().effects.values().toArray(new EffectsComponent.HabboEffect[0])).compose());
+ messages.add(new UserEffectsListComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().effects.values()).compose());
messages.add(new UserClothesComposer(this.client.getHabbo()).compose());
messages.add(new NewUserIdentityComposer(habbo).compose());
messages.add(new UserPermissionsComposer(this.client.getHabbo()).compose());
@@ -135,6 +141,39 @@ public class SecureLoginEvent extends MessageHandler {
this.client.sendResponse(new InventoryAchievementsComposer());
this.client.sendResponse(new AchievementListComposer(this.client.getHabbo()));
+ ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
+
+ if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
+ THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
+ ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
+
+ if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
+ ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
+
+ if (item.sanctionLevel > 0 && item.probationTimestamp != 0 && item.probationTimestamp > Emulator.getIntUnixTimestamp()) {
+ this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo()));
+ } else if (item.sanctionLevel > 0 && item.probationTimestamp != 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) {
+ modToolSanctions.updateSanction(item.id, 0);
+ }
+
+ if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) {
+ modToolSanctions.updateTradeLockedUntil(item.id, 0);
+ habbo.getHabboStats().setAllowTrade(true);
+ } else if (item.tradeLockedUntil > 0 && item.tradeLockedUntil > Emulator.getIntUnixTimestamp()) {
+ habbo.getHabboStats().setAllowTrade(false);
+ }
+
+ if (item.isMuted && item.muteDuration <= Emulator.getIntUnixTimestamp()) {
+ modToolSanctions.updateMuteDuration(item.id, 0);
+ habbo.unMute();
+ } else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) {
+ Date muteDuration = new Date((long) item.muteDuration * 1000);
+ long diff = muteDuration.getTime() - Emulator.getDate().getTime();
+ habbo.mute(Math.toIntExact(diff), false);
+ }
+ }
+ }
+
Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress()));
if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) {
diff --git a/src/main/java/com/eu/habbo/messages/incoming/helper/MySanctionStatusEvent.java b/src/main/java/com/eu/habbo/messages/incoming/helper/MySanctionStatusEvent.java
new file mode 100644
index 00000000..8608708f
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/helper/MySanctionStatusEvent.java
@@ -0,0 +1,12 @@
+package com.eu.habbo.messages.incoming.helper;
+
+import com.eu.habbo.messages.incoming.MessageHandler;
+import com.eu.habbo.messages.outgoing.modtool.ModToolSanctionInfoComposer;
+
+public class MySanctionStatusEvent extends MessageHandler {
+
+ @Override
+ public void handle() throws Exception {
+ this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo()));
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java
new file mode 100644
index 00000000..c7a6be24
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java
@@ -0,0 +1,20 @@
+package com.eu.habbo.messages.incoming.hotelview;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.messages.incoming.MessageHandler;
+import com.eu.habbo.messages.outgoing.hotelview.HotelViewSecondsUntilComposer;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+public class HotelViewRequestSecondsUntilEvent extends MessageHandler {
+ private static DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm");
+
+ @Override
+ public void handle() throws Exception {
+ String date = this.packet.readString();
+ int secondsUntil = Math.max(0, (int) (dateFormat.parse(date).getTime() / 1000) - Emulator.getIntUnixTimestamp());
+
+ this.client.sendResponse(new HotelViewSecondsUntilComposer(date, secondsUntil));
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java
index bea0a0ff..3a0f770c 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java
@@ -30,7 +30,7 @@ public class ModToolIssueDefaultSanctionEvent extends MessageHandler {
} else if (defaultSanction.muteLength > 0) {
if (target != null) {
- target.mute(defaultSanction.muteLength * 86400);
+ target.mute(defaultSanction.muteLength * 86400, false);
}
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java
index 2725aa50..348cb10a 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java
@@ -3,6 +3,7 @@ package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.modtool.ModToolUserRoomVisitsComposer;
@@ -12,10 +13,11 @@ public class ModToolRequestRoomVisitsEvent extends MessageHandler {
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
int userId = this.packet.readInt();
- Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
+ HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(userId);
- if (habbo != null)
- this.client.sendResponse(new ModToolUserRoomVisitsComposer(habbo, Emulator.getGameEnvironment().getModToolManager().requestUserRoomVisits(habbo)));
+ if (habboInfo != null) {
+ this.client.sendResponse(new ModToolUserRoomVisitsComposer(habboInfo, Emulator.getGameEnvironment().getModToolManager().getUserRoomVisits(userId)));
+ }
}
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java
index 26cfbda9..c0f8bae8 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java
@@ -1,10 +1,18 @@
package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.modtool.ModToolBanType;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer;
+import gnu.trove.map.hash.THashMap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
public class ModToolSanctionAlertEvent extends MessageHandler {
@Override
@@ -17,7 +25,26 @@ public class ModToolSanctionAlertEvent extends MessageHandler {
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (habbo != null) {
- habbo.alert(message);
+ ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
+
+ if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
+ THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
+ ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
+
+ if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) {
+ ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
+
+ if (item != null && item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
+ modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
+ } else {
+ modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
+ }
+ } else {
+ modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0);
+ }
+ } else {
+ habbo.alert(message);
+ }
} else {
this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name"))));
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java
index f317c8d6..c3035034 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java
@@ -2,9 +2,16 @@ package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.modtool.ModToolBanType;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
import com.eu.habbo.habbohotel.modtool.ScripterManager;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.messages.incoming.MessageHandler;
+import gnu.trove.map.hash.THashMap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
public class ModToolSanctionBanEvent extends MessageHandler {
public static final int BAN_18_HOURS = 3;
@@ -42,7 +49,27 @@ public class ModToolSanctionBanEvent extends MessageHandler {
duration = Emulator.getIntUnixTimestamp();
}
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
- Emulator.getGameEnvironment().getModToolManager().ban(userId, this.client.getHabbo(), message, duration, ModToolBanType.ACCOUNT, cfhTopic);
+ ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
+
+ if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
+ THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId);
+ ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(userId);
+
+ if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) {
+ ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
+
+ if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
+ modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
+ } else {
+ modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
+ }
+ } else {
+ modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0);
+ }
+ } else {
+ Emulator.getGameEnvironment().getModToolManager().ban(userId, this.client.getHabbo(), message, duration, ModToolBanType.ACCOUNT, cfhTopic);
+ }
+
} else {
ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.ban").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()));
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java
index f5664f93..c99eee68 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java
@@ -1,10 +1,20 @@
package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.modtool.ModToolBanType;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionLevelItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer;
+import gnu.trove.map.hash.THashMap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
public class ModToolSanctionMuteEvent extends MessageHandler {
@Override
@@ -17,9 +27,36 @@ public class ModToolSanctionMuteEvent extends MessageHandler {
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (habbo != null) {
- habbo.mute(60 * 60);
- habbo.alert(message);
- this.client.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", habbo.getHabboInfo().getUsername()));
+ ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
+
+ if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
+ THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
+ ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
+
+ if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) {
+ ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
+
+ if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
+ ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
+
+ int muteDurationTimestamp = Math.toIntExact(new Date( System.currentTimeMillis() + (modToolSanctionLevelItem.sanctionHourLength * 60 * 60)).getTime() / 1000);
+
+ modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, true, muteDurationTimestamp);
+ } else {
+ ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
+
+ int muteDurationTimestamp = Math.toIntExact(new Date( System.currentTimeMillis() + (modToolSanctionLevelItem.sanctionHourLength * 60 * 60)).getTime() / 1000);
+
+ modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, true, muteDurationTimestamp);
+ }
+ } else {
+ modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0);
+ }
+ } else {
+ habbo.mute(60 * 60, false);
+ habbo.alert(message);
+ this.client.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", habbo.getHabboInfo().getUsername()));
+ }
} else {
this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name"))));
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java
index ed8ad7af..48e14a38 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java
@@ -1,10 +1,17 @@
package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer;
+import gnu.trove.map.hash.THashMap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
public class ModToolSanctionTradeLockEvent extends MessageHandler {
@Override
@@ -18,8 +25,27 @@ public class ModToolSanctionTradeLockEvent extends MessageHandler {
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (habbo != null) {
- habbo.getHabboStats().setAllowTrade(false);
- habbo.alert(message);
+ ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
+
+ if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
+ THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId);
+ ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(userId);
+
+ if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) {
+ ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
+
+ if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
+ modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0);
+ } else {
+ modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0);
+ }
+ } else {
+ modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, duration, false, 0);
+ }
+ } else {
+ habbo.getHabboStats().setAllowTrade(false);
+ habbo.alert(message);
+ }
} else {
this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name"))));
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java
index 04b75b4f..c929941a 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java
@@ -41,18 +41,12 @@ public class ReportPhotoEvent extends MessageHandler {
if (item == null || !(item instanceof InteractionExternalImage)) return;
- InteractionExternalImage photoItem = (InteractionExternalImage) item;
+ HabboInfo photoOwner = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(item.getUserId());
- String photoCreatorId = new JsonParser().parse(photoItem.getExtradata()).getAsJsonObject().get("u").getAsString();
+ if (photoOwner == null) return;
- if (photoCreatorId == null) return;
-
- HabboInfo photoCreator = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(Integer.valueOf(photoCreatorId));
-
- if (photoCreator == null) return;
-
- ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), photoCreator.getId(), photoCreator.getUsername(), roomId, "", ModToolTicketType.PHOTO);
- issue.photoItem = photoItem;
+ ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), photoOwner.getId(), photoOwner.getUsername(), roomId, "", ModToolTicketType.PHOTO);
+ issue.photoItem = item;
new InsertModToolIssue(issue).run();
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java
index 3c2e8d4e..04934da6 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java
@@ -2,31 +2,49 @@ package com.eu.habbo.messages.incoming.rooms.items;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.interactions.InteractionMoodLight;
+import com.eu.habbo.habbohotel.modtool.ScripterManager;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomMoodlightData;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.items.MoodLightDataComposer;
+import java.util.Arrays;
+import java.util.List;
+
public class MoodLightSaveSettingsEvent extends MessageHandler {
+ public static List MOODLIGHT_AVAILABLE_COLORS = Arrays.asList("#74F5F5,#0053F7,#E759DE,#EA4532,#F2F851,#82F349,#000000".split(","));
+ public static int MIN_BRIGHTNESS = (int) Math.floor(0.3 * 0xFF);
+
@Override
public void handle() throws Exception {
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
- if ((room.getGuildId() > 0 && room.guildRightLevel(this.client.getHabbo()) < 2) && !room.hasRights(this.client.getHabbo()))
+ if ((room.getGuildId() <= 0 && room.guildRightLevel(this.client.getHabbo()) < 2) && !room.hasRights(this.client.getHabbo()))
return;
int id = this.packet.readInt();
int backgroundOnly = this.packet.readInt();
String color = this.packet.readString();
- int intensity = this.packet.readInt();
+ int brightness = this.packet.readInt();
+ boolean apply = this.packet.readBoolean();
+
+ if (!MOODLIGHT_AVAILABLE_COLORS.contains(color)) {
+ ScripterManager.scripterDetected(this.client, "User tried to set a moodlight to a non-whitelisted color: " + color);
+ return;
+ }
+
+ if (brightness > 0xFF || brightness < MIN_BRIGHTNESS) {
+ ScripterManager.scripterDetected(this.client, "User tried to set a moodlight's brightness to out-of-bounds ([76, 255]): " + brightness);
+ return;
+ }
for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) {
if (data.getId() == id) {
data.setBackgroundOnly(backgroundOnly == 2);
data.setColor(color);
- data.setIntensity(intensity);
- data.enable();
+ data.setIntensity(brightness);
+ if (apply) data.enable();
for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) {
item.setExtradata(data.toString());
@@ -34,7 +52,7 @@ public class MoodLightSaveSettingsEvent extends MessageHandler {
room.updateItem(item);
Emulator.getThreading().run(item);
}
- } else {
+ } else if (apply) {
data.disable();
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java
index 4986e685..a46bb7d2 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java
@@ -51,7 +51,7 @@ public class SetStackHelperHeightEvent extends MessageHandler {
item.needsUpdate(true);
this.client.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item);
this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(tiles);
- this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(tiles).compose());
+ this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(room, tiles).compose());
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightTileHeightComposer(item, (int) ((height) * 100)).compose());
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java
index c64d111e..e9e04c73 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java
@@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.interactions.InteractionDice;
-import com.eu.habbo.habbohotel.items.interactions.InteractionMonsterPlantSeed;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionMonsterPlantSeed;
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
import com.eu.habbo.habbohotel.pets.MonsterplantPet;
import com.eu.habbo.habbohotel.rooms.Room;
@@ -12,7 +12,6 @@ import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import com.eu.habbo.messages.outgoing.rooms.pets.PetPackageComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
-import gnu.trove.set.hash.THashSet;
public class ToggleFloorItemEvent extends MessageHandler {
@Override
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java
new file mode 100644
index 00000000..0b2e6ba9
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java
@@ -0,0 +1,29 @@
+package com.eu.habbo.messages.incoming.rooms.items;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.items.interactions.InteractionRandomState;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.messages.incoming.MessageHandler;
+
+public class UseRandomStateItemEvent extends MessageHandler {
+ @Override
+ public void handle() throws Exception {
+ try {
+ int itemId = this.packet.readInt();
+ int state = this.packet.readInt();
+
+ Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
+
+ HabboItem item = room.getHabboItem(itemId);
+
+ if (item == null || !(item instanceof InteractionRandomState))
+ return;
+
+ InteractionRandomState randomStateItem = (InteractionRandomState)item;
+ randomStateItem.onRandomStateClick(this.client, room);
+ } catch (Exception e) {
+ Emulator.getLogging().logErrorLine(e);
+ }
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java
index 273e62e4..8585c567 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java
@@ -2,26 +2,25 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox;
import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc;
import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
public class JukeBoxAddSoundTrackEvent extends MessageHandler {
@Override
public void handle() throws Exception {
+ if (!this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) return;
+
int itemId = this.packet.readInt();
int unknown = this.packet.readInt();
- Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
+ Habbo habbo = this.client.getHabbo();
- if (room != null) {
- HabboItem item = room.getHabboItem(itemId);
+ if (habbo != null) {
+ HabboItem item = habbo.getInventory().getItemsComponent().getHabboItem(itemId);
- if (item instanceof InteractionMusicDisc) {
-
-
- if (this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) {
- this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().addSong(itemId);
- }
+ if (item != null && item instanceof InteractionMusicDisc && item.getRoomId() == 0) {
+ this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().addSong((InteractionMusicDisc) item, habbo);
}
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java
index 3e4dd7d6..ad2929f7 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java
@@ -10,7 +10,7 @@ public class JukeBoxEventOne extends MessageHandler {
public void handle() throws Exception {
TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager();
this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength()));
- this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList()));
+ this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList(this.client.getHabbo())));
this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo());
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java
index 41a86a7d..15c53b0e 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java
@@ -10,7 +10,7 @@ public class JukeBoxEventTwo extends MessageHandler {
public void handle() throws Exception {
TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager();
this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength()));
- this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList()));
+ this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList(this.client.getHabbo())));
this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo());
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java
index 88bcd1c4..a5468d59 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java
@@ -10,7 +10,7 @@ public class JukeBoxRequestPlayListEvent extends MessageHandler {
public void handle() throws Exception {
TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager();
this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength()));
- this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList()));
+ this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList(this.client.getHabbo())));
this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo());
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java
index 469861d0..6c4b804b 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java
@@ -1,11 +1,15 @@
package com.eu.habbo.messages.incoming.rooms.items.youtube;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.items.YoutubeManager;
import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
+import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer;
import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayListComposer;
+import java.util.ArrayList;
+
public class YoutubeRequestPlaylists extends MessageHandler {
@Override
public void handle() throws Exception {
@@ -17,7 +21,15 @@ public class YoutubeRequestPlaylists extends MessageHandler {
if (item instanceof InteractionYoutubeTV) {
InteractionYoutubeTV tv = (InteractionYoutubeTV) item;
- this.client.sendResponse(new YoutubeDisplayListComposer(itemId, Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistsForItemId(item.getBaseItem().getId()), tv.currentPlaylist));
+ ArrayList playlists = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistsForItemId(item.getBaseItem().getId());
+
+ if (playlists == null) {
+ Emulator.getLogging().logErrorLine("No YouTube playlists set for base item #" + item.getBaseItem().getId());
+ this.client.sendResponse(new ConnectionErrorComposer(1000));
+ return;
+ }
+
+ this.client.sendResponse(new YoutubeDisplayListComposer(itemId, playlists, tv.currentPlaylist));
}
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java
index 668ee248..13a1e200 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java
@@ -1,6 +1,6 @@
package com.eu.habbo.messages.incoming.rooms.pets;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetBreedingNest;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java
new file mode 100644
index 00000000..5f89d1fd
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java
@@ -0,0 +1,64 @@
+package com.eu.habbo.messages.incoming.rooms.pets;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.pets.HorsePet;
+import com.eu.habbo.habbohotel.pets.Pet;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.messages.incoming.MessageHandler;
+import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
+import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
+import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetHorseFigureComposer;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class HorseRemoveSaddleEvent extends MessageHandler {
+ @Override
+ public void handle() throws Exception {
+ Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
+ Pet pet = room.getPet(this.packet.readInt());
+
+ if (pet == null || !(pet instanceof HorsePet) || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId()) return;
+
+ HorsePet horse = (HorsePet) pet;
+
+ if (!horse.hasSaddle()) return;
+
+ int saddleItemId = horse.getSaddleItemId();
+
+ if (saddleItemId == 0) { // backwards compatibility: horses could be missing the saddle item ID
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT id FROM items_base WHERE item_name LIKE 'horse_saddle%' LIMIT 1")) {
+ try (ResultSet set = statement.executeQuery()) {
+ if (set.next()) {
+ saddleItemId = set.getInt("id");
+ } else {
+ Emulator.getLogging().logErrorLine("There is no viable fallback saddle item for old horses with no saddle item ID. Horse pet ID: " + horse.getId());
+ return;
+ }
+ }
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ Item saddleItem = Emulator.getGameEnvironment().getItemManager().getItem(saddleItemId);
+
+ if (saddleItem == null) return;
+
+ horse.hasSaddle(false);
+ horse.needsUpdate = true;
+ Emulator.getThreading().run(pet);
+ this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomPetHorseFigureComposer(horse).compose());
+
+ HabboItem saddle = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), saddleItem, 0, 0, "");
+
+ this.client.getHabbo().getInventory().getItemsComponent().addItem(saddle);
+
+ this.client.sendResponse(new AddHabboItemComposer(saddle));
+ this.client.sendResponse(new InventoryRefreshComposer());
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java
index 2b597245..7ec34b79 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java
@@ -75,6 +75,7 @@ public class PetUseItemEvent extends MessageHandler {
((HorsePet) pet).needsUpdate = true;
} else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) {
((HorsePet) pet).hasSaddle(true);
+ ((HorsePet) pet).setSaddleItemId(item.getBaseItem().getId());
((HorsePet) pet).needsUpdate = true;
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java
index 4370231e..5d19000d 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java
@@ -1,6 +1,6 @@
package com.eu.habbo.messages.incoming.rooms.pets;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetBreedingNest;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java
index 948d0b08..2fa40246 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java
@@ -7,9 +7,12 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseFailedComposer;
import com.eu.habbo.messages.outgoing.catalog.PurchaseOKComposer;
+import com.eu.habbo.messages.outgoing.navigator.NewNavigatorEventCategoriesComposer;
import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer;
public class BuyRoomPromotionEvent extends MessageHandler {
+ public static String ROOM_PROMOTION_BADGE = "RADZZ";
+
@Override
public void handle() throws Exception {
int pageId = this.packet.readInt();
@@ -20,6 +23,9 @@ public class BuyRoomPromotionEvent extends MessageHandler {
String description = this.packet.readString();
int categoryId = this.packet.readInt();
+ if (NewNavigatorEventCategoriesComposer.CATEGORIES.stream().noneMatch(c -> c.getId() == categoryId))
+ return;
+
CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(pageId);
if (page != null) {
@@ -35,16 +41,24 @@ public class BuyRoomPromotionEvent extends MessageHandler {
if (room.isPromoted()) {
room.getPromotion().addEndTimestamp(120 * 60);
} else {
- room.createPromotion(title, description);
+ room.createPromotion(title, description, categoryId);
}
if (room.isPromoted()) {
- if (!this.client.getHabbo().hasPermission("acc_infinite_credits"))
+ if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) {
this.client.getHabbo().giveCredits(-item.getCredits());
- if (!this.client.getHabbo().hasPermission("acc_infinite_points"))
+ }
+
+ if (!this.client.getHabbo().hasPermission("acc_infinite_points")) {
this.client.getHabbo().givePoints(item.getPointsType(), -item.getPoints());
+ }
+
this.client.sendResponse(new PurchaseOKComposer());
room.sendComposer(new RoomPromotionMessageComposer(room, room.getPromotion()).compose());
+
+ if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(BuyRoomPromotionEvent.ROOM_PROMOTION_BADGE)) {
+ this.client.getHabbo().addBadge(BuyRoomPromotionEvent.ROOM_PROMOTION_BADGE);
+ }
} else {
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java
index 815fe3e0..22c0d5cc 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java
@@ -11,8 +11,14 @@ import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
import com.eu.habbo.plugin.events.users.UserIdleEvent;
+import gnu.trove.set.hash.THashSet;
public class RoomUserWalkEvent extends MessageHandler {
+ @Override
+ public int getRatelimit() {
+ return 500;
+ }
+
@Override
public void handle() throws Exception {
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) {
@@ -115,8 +121,27 @@ public class RoomUserWalkEvent extends MessageHandler {
}
}
+ THashSet items = room.getItemsAt(tile);
+
+ if (items.size() > 0) {
+ for (HabboItem item : items) {
+ RoomTile overriddenTile = item.getOverrideGoalTile(roomUnit, room, tile);
+
+ if (overriddenTile == null) {
+ return; // null cancels the entire event
+ }
+
+ if (!overriddenTile.equals(tile) && overriddenTile.isWalkable()) {
+ tile = overriddenTile;
+ break;
+ }
+ }
+ }
+
// This is where we set the end location and begin finding a path
if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) {
+ if (roomUnit.getMoveBlockingTask() != null) roomUnit.getMoveBlockingTask().get();
+
roomUnit.setGoalLocation(tile);
}
} else {
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java
index cc7efef7..b1d7dd27 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java
@@ -388,13 +388,12 @@ public class Outgoing {
public final static int AlertPurchaseUnavailableComposer = 3770; // PRODUCTION-201611291003-338511768
public final static int PetBreedingStartFailedComposer = 2621; // PRODUCTION-201611291003-338511768
public final static int DailyQuestComposer = 1878; // PRODUCTION-201611291003-338511768
- public final static int NewNavigatorRoomEventComposer = 1840; // PRODUCTION-201611291003-338511768
public final static int HotelViewHideCommunityVoteButtonComposer = 1435; // PRODUCTION-201611291003-338511768
public final static int CatalogSearchResultComposer = 3388; // PRODUCTION-201611291003-338511768
public final static int FriendFindingRoomComposer = 1210; // PRODUCTION-201611291003-338511768
public final static int QuestComposer = 230; // PRODUCTION-201611291003-338511768
public final static int ModToolSanctionDataComposer = 2782; // PRODUCTION-201611291003-338511768
- public final static int RoomEventMessageComposer = 2274;
+ public final static int RoomEventMessageComposer = 1840;
public final static int JukeBoxMySongsComposer = 2602; // PRODUCTION-201611291003-338511768
@@ -525,6 +524,7 @@ public class Outgoing {
public final static int UnknownRoomViewerComposer = 3523;
public final static int ErrorLoginComposer = 4000;
public final static int HotelViewNextLTDAvailableComposer = 44;
+ public final static int HotelViewSecondsUntilComposer = 3926;
public final static int UnknownRoomDesktopComposer = 69;
public final static int UnknownGuildComposer3 = 876;
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java
index f30d815c..defe9a68 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java
@@ -5,25 +5,27 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
public class CameraPublishWaitMessageComposer extends MessageComposer {
- public final boolean published;
- public final int seconds;
- public final String unknownString;
+ public final boolean isOk;
+ public final int cooldownSeconds;
+ public final String extraDataId;
- public CameraPublishWaitMessageComposer(boolean published, int seconds, String unknownString) {
- this.published = published;
- this.seconds = seconds;
- this.unknownString = unknownString;
+ public CameraPublishWaitMessageComposer(boolean isOk, int cooldownSeconds, String extraDataId) {
+ this.isOk = isOk;
+ this.cooldownSeconds = cooldownSeconds;
+ this.extraDataId = extraDataId;
}
@Override
public ServerMessage compose() {
this.response.init(Outgoing.CameraPublishWaitMessageComposer);
- this.response.appendBoolean(this.published);
- this.response.appendInt(this.seconds);
- if (this.published) {
- this.response.appendString(this.unknownString);
+ this.response.appendBoolean(this.isOk);
+ this.response.appendInt(this.cooldownSeconds);
+
+ if (!this.extraDataId.isEmpty()) {
+ this.response.appendString(this.extraDataId);
}
+
return this.response;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java
index 5cf963a9..edfdaa08 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java
@@ -3,6 +3,7 @@ package com.eu.habbo.messages.outgoing.guilds;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.guilds.Guild;
import com.eu.habbo.habbohotel.guilds.GuildMember;
+import com.eu.habbo.habbohotel.guilds.GuildMembershipStatus;
import com.eu.habbo.habbohotel.guilds.GuildRank;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
@@ -36,20 +37,18 @@ public class GuildInfoComposer extends MessageComposer {
this.response.appendString(this.guild.getBadge());
this.response.appendInt(this.guild.getRoomId());
this.response.appendString(this.guild.getRoomName());
- //this.response.appendInt(this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() ? 3 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) || this.member.getRank().equals(GuildRank.MOD) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : 0))));
- this.response.appendInt(adminPermissions ? 4 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : (this.member.getRank().equals(GuildRank.MOD) ? 3 : (this.member.getRank().equals(GuildRank.ADMIN) ? 4 : 0))))));
- this.response.appendInt(this.guild.getMemberCount()); //Member count.
- this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); //favorite group
+ this.response.appendInt((this.member == null ? GuildMembershipStatus.NOT_MEMBER : this.member.getMembershipStatus()).getStatus());
+ this.response.appendInt(this.guild.getMemberCount());
+ this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); // favorite group
this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.guild.getDateCreated() * 1000L)));
this.response.appendBoolean(adminPermissions || (this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()));
- this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); //Is admin. //this.member.getRank().equals(GuildRank.MOD) ||
- //Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.guild.getOwnerId());
+ this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN))));
this.response.appendString(this.guild.getOwnerName());
this.response.appendBoolean(this.newWindow);
- this.response.appendBoolean(this.guild.getRights()); //User can place furni.
+ this.response.appendBoolean(this.guild.getRights());
this.response.appendInt((adminPermissions || this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) ? this.guild.getRequestCount() : 0); //Guild invites count.
- this.response.appendBoolean(this.guild.hasForum()); //Unknown
+ this.response.appendBoolean(this.guild.hasForum());
return this.response;
}
}
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java
index f52c7dff..73e98a26 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java
@@ -49,7 +49,7 @@ public class GuildMembersComposer extends MessageComposer {
this.response.appendInt(member.getUserId());
this.response.appendString(member.getUsername());
this.response.appendString(member.getLook());
- this.response.appendString(member.getRank().type < 3 && member.getRank().type > 0 ? cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR) : "");
+ this.response.appendString(member.getRank().type < 3 ? cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR) : "");
}
this.response.appendBoolean(this.isAdmin);
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java
index f3050354..4700bc13 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java
@@ -8,14 +8,15 @@ import com.eu.habbo.messages.outgoing.Outgoing;
import gnu.trove.set.hash.THashSet;
import java.util.Iterator;
+import java.util.Set;
public class GuildForumListComposer extends MessageComposer {
- private final THashSet guilds;
+ private final Set guilds;
private final Habbo habbo;
private final int mode;
private final int index;
- public GuildForumListComposer(THashSet guilds, Habbo habbo, int mode, int index) {
+ public GuildForumListComposer(Set guilds, Habbo habbo, int mode, int index) {
this.guilds = guilds;
this.habbo = habbo;
this.mode = mode;
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java
index c7138ef8..4476859a 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java
@@ -1,15 +1,11 @@
package com.eu.habbo.messages.outgoing.guilds.forums;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.guilds.Guild;
-import com.eu.habbo.habbohotel.guilds.GuildRank;
import com.eu.habbo.habbohotel.guilds.forums.ForumThread;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
-import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
-import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
public class ThreadUpdatedMessageComposer extends MessageComposer {
@@ -33,30 +29,10 @@ public class ThreadUpdatedMessageComposer extends MessageComposer {
@Override
public ServerMessage compose() {
- if (isPinned != thread.isPinned()) {
- this.habbo.getClient().sendResponse(new BubbleAlertComposer(isPinned ? BubbleAlertKeys.FORUMS_THREAD_PINNED.key : BubbleAlertKeys.FORUMS_THREAD_UNPINNED.key).compose());
- }
+ this.response.init(Outgoing.ThreadUpdateMessageComposer);
+ this.response.appendInt(this.thread.getGuildId());
+ this.thread.serialize(this.response);
- if (isLocked != thread.isLocked()) {
- this.habbo.getClient().sendResponse(new BubbleAlertComposer(isLocked ? BubbleAlertKeys.FORUMS_THREAD_LOCKED.key : BubbleAlertKeys.FORUMS_THREAD_UNLOCKED.key).compose());
- }
-
- if (this.habbo.getHabboInfo().getId() != guild.getOwnerId() ||
- guild.canModForum().state == 2 && (Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.ADMIN
- || Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.MOD)
- || this.habbo.hasPermission("acc_modtool_ticket_q")) {
- this.thread.setPinned(isPinned);
- this.thread.setLocked(isLocked);
-
- Emulator.getThreading().run(this.thread);
-
- this.response.init(Outgoing.ThreadUpdateMessageComposer);
- this.response.appendInt(this.thread.getGuildId());
- this.thread.serialize(this.response);
-
- return this.response;
- }
-
- return null;
+ return this.response;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewSecondsUntilComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewSecondsUntilComposer.java
new file mode 100644
index 00000000..d258dc2a
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewSecondsUntilComposer.java
@@ -0,0 +1,24 @@
+package com.eu.habbo.messages.outgoing.hotelview;
+
+import com.eu.habbo.messages.ServerMessage;
+import com.eu.habbo.messages.outgoing.MessageComposer;
+import com.eu.habbo.messages.outgoing.Outgoing;
+
+public class HotelViewSecondsUntilComposer extends MessageComposer {
+ private final String dateString;
+ private final int seconds;
+
+ public HotelViewSecondsUntilComposer(String dateString, int seconds) {
+ this.dateString = dateString;
+ this.seconds = seconds;
+ }
+
+ @Override
+ public ServerMessage compose() {
+ this.response.init(Outgoing.HotelViewSecondsUntilComposer);
+ this.response.appendString(this.dateString);
+ this.response.appendInt(this.seconds);
+
+ return this.response;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java
index b1cd6cd6..2c09b324 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java
@@ -6,13 +6,15 @@ import com.eu.habbo.habbohotel.users.inventory.EffectsComponent;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
-import gnu.trove.procedure.TObjectProcedure;
+
+import java.util.Collection;
+
public class UserEffectsListComposer extends MessageComposer {
public final Habbo habbo;
- public final EffectsComponent.HabboEffect[] effects;
+ public final Collection effects;
- public UserEffectsListComposer(Habbo habbo, EffectsComponent.HabboEffect[] effects) {
+ public UserEffectsListComposer(Habbo habbo, Collection effects) {
this.habbo = habbo;
this.effects = effects;
}
@@ -26,10 +28,9 @@ public class UserEffectsListComposer extends MessageComposer {
this.response.appendInt(0);
} else {
synchronized (this.habbo.getInventory().getEffectsComponent().effects) {
- this.response.appendInt(this.effects.length);
-
- for(EffectsComponent.HabboEffect effect : effects) {
+ this.response.appendInt(this.effects.size());
+ for (EffectsComponent.HabboEffect effect : effects) {
UserEffectsListComposer.this.response.appendInt(effect.effect);
UserEffectsListComposer.this.response.appendInt(0);
UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? effect.duration : Integer.MAX_VALUE);
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java
index dd73279a..ee8b3830 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java
@@ -61,7 +61,7 @@ public class ModToolIssueChatlogComposer extends MessageComposer {
this.response.appendInt(this.issue.threadId);
if (this.type == ModToolIssueChatlogType.FORUM_COMMENT) {
- ModToolChatRecordDataContext.GROUP_ID.append(this.response);
+ ModToolChatRecordDataContext.MESSAGE_ID.append(this.response);
this.response.appendInt(this.issue.commentId);
}
} else if (this.issue.type == ModToolTicketType.PHOTO) {
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java
index 3e24b6a8..ca323066 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java
@@ -1,26 +1,105 @@
package com.eu.habbo.messages.outgoing.modtool;
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionLevelItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
+import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
+import gnu.trove.map.hash.THashMap;
+import org.joda.time.DateTime;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
public class ModToolSanctionInfoComposer extends MessageComposer {
+
+ private final Habbo habbo;
+
+ public ModToolSanctionInfoComposer(Habbo habbo) {
+ this.habbo = habbo;
+ }
+
@Override
public ServerMessage compose() {
+ ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
+
+ Date probationEndTime;
+ Date probationStartTime;
+
+ if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
+ THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
+ ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
+
+ if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
+ ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
+
+ ModToolSanctionItem prevItem = null;
+ if (modToolSanctionItems.size() > 1 && modToolSanctionItems.get(modToolSanctionItems.size() - 2) != null) {
+ prevItem = modToolSanctionItems.get(modToolSanctionItems.size() - 2);
+ }
+
+ ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
+ ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1);
+
+ if (item.probationTimestamp > 0) {
+ probationEndTime = new Date((long) item.probationTimestamp * 1000);
+
+ probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate();
+
+ Date tradeLockedUntil = null;
+
+ if (item.tradeLockedUntil > 0) {
+ tradeLockedUntil = new Date((long) item.tradeLockedUntil * 1000);
+ }
+
+ this.response.init(Outgoing.ModToolSanctionInfoComposer);
+
+ this.response.appendBoolean(prevItem != null && prevItem.probationTimestamp > 0); // has prev sanction
+ this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation
+ this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type
+ this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction
+ this.response.appendInt(30); // TODO: unused?
+ this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason
+ this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time
+ this.response.appendInt(0); // TODO: unused?
+ this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type
+ this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours)
+ this.response.appendInt(30); // TODO: unused?
+ this.response.appendBoolean(item.isMuted); // muted
+ this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until
+ } else {
+ return cleanResponse();
+ }
+
+ } else {
+ return cleanResponse();
+ }
+ }
+
+ return this.response;
+ }
+
+ private ServerMessage cleanResponse() {
this.response.init(Outgoing.ModToolSanctionInfoComposer);
- this.response.appendBoolean(false); //Has Last Sanction.
- this.response.appendBoolean(false); //Is probabtion.
- this.response.appendString("<< Last Sanction >>");
- this.response.appendInt(0); //Value | Probation days left.
- this.response.appendInt(-1); //Unused
- this.response.appendString("<< Reason >>"); //Reason
- this.response.appendString("1/1/1970 00:00"); //Start Time
- this.response.appendInt(0); //Probation Days Left
- this.response.appendString("<< Next Sanction >>"); //Next Sanction
- this.response.appendInt(0); //Value
- this.response.appendInt(-1); //Unused
- this.response.appendBoolean(false); //Trade Locked
- this.response.appendString("1/1/1970 00:00"); //Trade Locked Untill
+
+ this.response.appendBoolean(false); // has prev sanction
+ this.response.appendBoolean(false); // is on probation
+ this.response.appendString("ALERT"); // last sanction type
+ this.response.appendInt(0); // time of current sanction
+ this.response.appendInt(30); // TODO: unused?
+ this.response.appendString("cfh.reason.EMPTY"); // reason
+ this.response.appendString(Emulator.getDate().toString()); // probation start time
+ this.response.appendInt(0); // TODO: unused?
+ this.response.appendString("ALERT"); // next sanction type
+ this.response.appendInt(0); // time to be applied in next sanction (in hours)
+ this.response.appendInt(30); // TODO: unused?
+ this.response.appendBoolean(false); // muted
+ this.response.appendString(""); // trade locked until
+
return this.response;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java
index 804ec6e1..59723fdb 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java
@@ -1,12 +1,17 @@
package com.eu.habbo.messages.outgoing.modtool;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctionLevelItem;
+import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
+import gnu.trove.map.hash.THashMap;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
public class ModToolUserInfoComposer extends MessageComposer {
private final ResultSet set;
@@ -37,11 +42,23 @@ public class ModToolUserInfoComposer extends MessageComposer {
this.response.appendString(this.set.getString("mail"));
this.response.appendString("Rank (" + this.set.getInt("rank_id") + "): " + this.set.getString("rank_name")); //user_class_txt
- if (false) //has sanction
- {
- this.response.appendString("SOME SANCTION");
- this.response.appendInt(31);
+ ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
+
+ if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
+ THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(this.set.getInt("user_id"));
+ ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(this.set.getInt("user_id"));
+
+ if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) //has sanction
+ {
+ ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
+ ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
+
+ this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem));
+ this.response.appendInt(31);
+ }
+
}
+
return this.response;
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java
index 25ffcc8a..1ccc19a3 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java
@@ -1,7 +1,7 @@
package com.eu.habbo.messages.outgoing.modtool;
import com.eu.habbo.habbohotel.modtool.ModToolRoomVisit;
-import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
@@ -11,19 +11,19 @@ import java.util.Calendar;
import java.util.TimeZone;
public class ModToolUserRoomVisitsComposer extends MessageComposer {
- private final Habbo habbo;
+ private final HabboInfo habboInfo;
private final THashSet roomVisits;
- public ModToolUserRoomVisitsComposer(Habbo habbo, THashSet roomVisits) {
- this.habbo = habbo;
+ public ModToolUserRoomVisitsComposer(HabboInfo habboInfo, THashSet roomVisits) {
+ this.habboInfo = habboInfo;
this.roomVisits = roomVisits;
}
@Override
public ServerMessage compose() {
this.response.init(Outgoing.ModToolUserRoomVisitsComposer);
- this.response.appendInt(this.habbo.getHabboInfo().getId());
- this.response.appendString(this.habbo.getHabboInfo().getUsername());
+ this.response.appendInt(this.habboInfo.getId());
+ this.response.appendString(this.habboInfo.getUsername());
this.response.appendInt(this.roomVisits.size());
Calendar cal = Calendar.getInstance(TimeZone.getDefault());
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java
index aacf54cb..baff726f 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java
@@ -1,47 +1,26 @@
package com.eu.habbo.messages.outgoing.navigator;
+import com.eu.habbo.habbohotel.navigation.EventCategory;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
+import java.util.ArrayList;
+import java.util.List;
+
public class NewNavigatorEventCategoriesComposer extends MessageComposer {
+ public static List CATEGORIES = new ArrayList<>();
+
@Override
public ServerMessage compose() {
this.response.init(Outgoing.NewNavigatorEventCategoriesComposer);
- this.response.appendInt(11);
- this.response.appendInt(1);
- this.response.appendString("Hottest Events");
- this.response.appendBoolean(false);
- this.response.appendInt(2);
- this.response.appendString("Parties & Music");
- this.response.appendBoolean(true);
- this.response.appendInt(3);
- this.response.appendString("Role Play");
- this.response.appendBoolean(true);
- this.response.appendInt(4);
- this.response.appendString("Help Desk");
- this.response.appendBoolean(true);
- this.response.appendInt(5);
- this.response.appendString("Trading");
- this.response.appendBoolean(true);
- this.response.appendInt(6);
- this.response.appendString("Games");
- this.response.appendBoolean(true);
- this.response.appendInt(7);
- this.response.appendString("Debates & Discussions");
- this.response.appendBoolean(true);
- this.response.appendInt(8);
- this.response.appendString("Grand Openings");
- this.response.appendBoolean(true);
- this.response.appendInt(9);
- this.response.appendString("Friending");
- this.response.appendBoolean(true);
- this.response.appendInt(10);
- this.response.appendString("Jobs");
- this.response.appendBoolean(true);
- this.response.appendInt(11);
- this.response.appendString("Group Events");
- this.response.appendBoolean(true);
+
+ this.response.appendInt(NewNavigatorEventCategoriesComposer.CATEGORIES.size());
+
+ for (EventCategory category : NewNavigatorEventCategoriesComposer.CATEGORIES) {
+ category.serialize(this.response);
+ }
+
return this.response;
}
}
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java
index 5a99f16c..b01a6369 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java
@@ -1,5 +1,6 @@
package com.eu.habbo.messages.outgoing.rooms;
+import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
@@ -12,6 +13,7 @@ public class UpdateStackHeightComposer extends MessageComposer {
private double height;
private THashSet updateTiles;
+ private Room room;
public UpdateStackHeightComposer(int x, int y, double height) {
this.x = x;
@@ -19,24 +21,29 @@ public class UpdateStackHeightComposer extends MessageComposer {
this.height = height;
}
- public UpdateStackHeightComposer(THashSet updateTiles) {
+ public UpdateStackHeightComposer(Room room, THashSet updateTiles) {
this.updateTiles = updateTiles;
+ this.room = room;
}
@Override
public ServerMessage compose() {
- //TODO: THIS IS A TEMP FIX. THERE IS AN ISSUE WITH BAD PACKET STRUCTURE HERE CAUSING ISSUES WITH MOVING LARGE FURNITURE
+ //TODO: maybe do this another way? doesn't seem to be very clean but gets the job done
this.response.init(Outgoing.UpdateStackHeightComposer);
if (this.updateTiles != null) {
- if(this.updateTiles.size() > 4) {
- RoomTile[] tiles = (RoomTile[])this.updateTiles.toArray();
- this.response.appendByte(4);
- for(int i = 0; i < 4; i++) {
+ // prevent overflow. Byte max value is 127
+ if(this.updateTiles.size() > 127) {
+ RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]);
+ this.response.appendByte(127);
+ for(int i = 0; i < 127; i++) {
RoomTile t = tiles[i];
+ updateTiles.remove(t); // remove it from the set
this.response.appendByte((int) t.x);
this.response.appendByte((int) t.y);
this.response.appendShort(t.relativeHeight());
}
+ //send the remaining tiles in a new message
+ this.room.sendComposer(new UpdateStackHeightComposer(this.room, updateTiles).compose());
return this.response;
}
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java
index aa5244e8..0dddc403 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java
@@ -6,11 +6,12 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
import java.util.List;
+import java.util.Set;
public class ItemsDataUpdateComposer extends MessageComposer {
- private final List items;
+ private final Set items;
- public ItemsDataUpdateComposer(List items) {
+ public ItemsDataUpdateComposer(Set items) {
this.items = items;
}
@@ -18,9 +19,12 @@ public class ItemsDataUpdateComposer extends MessageComposer {
public ServerMessage compose() {
this.response.init(Outgoing.ItemsDataUpdateComposer);
this.response.appendInt(this.items.size());
+
for (HabboItem item : this.items) {
+ this.response.appendInt(item.getId());
item.serializeExtradata(this.response);
}
+
return this.response;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java
index e82a8055..12403e90 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java
@@ -1,5 +1,6 @@
package com.eu.habbo.messages.outgoing.rooms.promotions;
+import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomPromotion;
import com.eu.habbo.messages.ServerMessage;
@@ -21,37 +22,29 @@ public class RoomPromotionMessageComposer extends MessageComposer {
this.response.init(Outgoing.RoomEventMessageComposer);
if (this.room == null || this.roomPromotion == null) {
-
this.response.appendInt(-1);
-
this.response.appendInt(-1);
-
this.response.appendString("");
-
this.response.appendInt(0);
this.response.appendInt(0);
-
this.response.appendString("");
-
this.response.appendString("");
-
this.response.appendInt(0);
-
this.response.appendInt(0);
this.response.appendInt(0);
} else {
- this.response.appendInt(this.room.getId());
+ this.response.appendInt(this.room.getId()); // promotion id
this.response.appendInt(this.room.getOwnerId());
this.response.appendString(this.room.getOwnerName());
- this.response.appendInt(1);
- this.response.appendInt(1);
+ this.response.appendInt(this.room.getId()); // room id
+ this.response.appendInt(1); // "type"
this.response.appendString(this.roomPromotion.getTitle());
this.response.appendString(this.roomPromotion.getDescription());
- this.response.appendInt(0);
- this.response.appendInt(0);
- this.response.appendInt(0);
+ this.response.appendInt((Emulator.getIntUnixTimestamp() - this.roomPromotion.getStartTimestamp()) / 60); // minutes since starting
+ this.response.appendInt((this.roomPromotion.getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); // minutes until end
+ this.response.appendInt(this.roomPromotion.getCategory()); // category
}
return this.response;
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java
index 9f30152a..f77d520c 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java
@@ -1,6 +1,7 @@
package com.eu.habbo.messages.outgoing.rooms.users;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.items.interactions.InteractionRoller;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@@ -65,7 +66,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
RoomUnitOnRollerComposer.this.roomUnit.setZ(RoomUnitOnRollerComposer.this.newLocation.getStackHeight());
RoomUnitOnRollerComposer.this.roomUnit.sitUpdate = true;
}
- }, this.room.getRollerSpeed() == 0 ? 250 : 500);
+ }, this.room.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY);
} else {
this.roomUnit.setLocation(this.newLocation);
this.roomUnit.setZ(this.newZ);
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java
index 652511e8..28f89597 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java
@@ -14,12 +14,18 @@ import java.util.Map;
public class RoomUserStatusComposer extends MessageComposer {
private Collection habbos;
private THashSet roomUnits;
+ private double overrideZ = -1;
public RoomUserStatusComposer(RoomUnit roomUnit) {
this.roomUnits = new THashSet<>();
this.roomUnits.add(roomUnit);
}
+ public RoomUserStatusComposer(RoomUnit roomUnit, double overrideZ) {
+ this(roomUnit);
+ this.overrideZ = overrideZ;
+ }
+
public RoomUserStatusComposer(THashSet roomUnits, boolean value) {
this.roomUnits = roomUnits;
}
@@ -37,7 +43,7 @@ public class RoomUserStatusComposer extends MessageComposer {
this.response.appendInt(roomUnit.getId());
this.response.appendInt(roomUnit.getPreviousLocation().x);
this.response.appendInt(roomUnit.getPreviousLocation().y);
- this.response.appendString(roomUnit.getPreviousLocationZ() + "");
+ this.response.appendString((this.overrideZ != -1 ? this.overrideZ : roomUnit.getPreviousLocationZ()) + "");
this.response.appendInt(roomUnit.getHeadRotation().getValue());
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java
index 6a9cdf33..eecb7858 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java
@@ -46,7 +46,7 @@ public class UserProfileComposer extends MessageComposer {
this.response.appendString(this.habboInfo.getUsername());
this.response.appendString(this.habboInfo.getLook());
this.response.appendString(this.habboInfo.getMotto());
- this.response.appendString(new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date(this.habboInfo.getAccountCreated() * 1000L)));
+ this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.habboInfo.getAccountCreated() * 1000L)));
int achievementScore = 0;
if (this.habbo != null) {
diff --git a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java
index a83da553..b86893d1 100644
--- a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java
+++ b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java
@@ -21,7 +21,7 @@ public class MuteUser extends RCONMessage {
if (json.duration == 0) {
habbo.unMute();
} else {
- habbo.mute(json.duration);
+ habbo.mute(json.duration, false);
}
} else {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET mute_end_timestamp = ? WHERE user_id = ? LIMIT 1")) {
diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java
index 9881701a..7edf9579 100644
--- a/src/main/java/com/eu/habbo/plugin/PluginManager.java
+++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java
@@ -3,6 +3,7 @@ package com.eu.habbo.plugin;
import com.eu.habbo.Emulator;
import com.eu.habbo.core.Easter;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
+import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.bots.BotManager;
import com.eu.habbo.habbohotel.catalog.CatalogManager;
import com.eu.habbo.habbohotel.catalog.TargetOffer;
@@ -15,6 +16,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionRoller;
import com.eu.habbo.habbohotel.items.interactions.games.football.InteractionFootballGate;
import com.eu.habbo.habbohotel.messenger.Messenger;
import com.eu.habbo.habbohotel.modtool.WordFilter;
+import com.eu.habbo.habbohotel.navigation.EventCategory;
import com.eu.habbo.habbohotel.navigation.NavigatorManager;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.HabboInventory;
@@ -22,10 +24,14 @@ import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager;
import com.eu.habbo.messages.PacketManager;
+import com.eu.habbo.messages.incoming.camera.CameraPublishToWebEvent;
+import com.eu.habbo.messages.incoming.camera.CameraPurchaseEvent;
import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent;
import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent;
+import com.eu.habbo.messages.incoming.rooms.promotions.BuyRoomPromotionEvent;
import com.eu.habbo.messages.incoming.users.ChangeNameCheckUsernameEvent;
import com.eu.habbo.messages.outgoing.catalog.DiscountComposer;
+import com.eu.habbo.messages.outgoing.navigator.NewNavigatorEventCategoriesComposer;
import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent;
import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent;
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent;
@@ -77,6 +83,8 @@ public class PluginManager {
BotManager.MAXIMUM_CHAT_LENGTH = Emulator.getConfig().getInt("hotel.bot.max.chatlength");
BotManager.MAXIMUM_NAME_LENGTH = Emulator.getConfig().getInt("hotel.bot.max.namelength");
BotManager.MAXIMUM_CHAT_SPEED = Emulator.getConfig().getInt("hotel.bot.max.chatdelay");
+ Bot.PLACEMENT_MESSAGES = Emulator.getConfig().getValue("hotel.bot.placement.messages", "Yo!;Hello I'm a real party animal!;Hello!").split(";");
+
HabboInventory.MAXIMUM_ITEMS = Emulator.getConfig().getInt("hotel.inventory.max.items");
Messenger.MAXIMUM_FRIENDS = Emulator.getConfig().getInt("hotel.max.friends");
Messenger.MAXIMUM_FRIENDS_HC = Emulator.getConfig().getInt("hotel.max.friends.hc");
@@ -124,13 +132,28 @@ public class PluginManager {
RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB = Emulator.getConfig().getBoolean("hotel.navigator.populartab.publics");
ChangeNameCheckUsernameEvent.VALID_CHARACTERS = Emulator.getConfig().getValue("allowed.username.characters", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,.");
+ CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS = Emulator.getConfig().getInt("camera.price.points.publish", 5);
+ CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.publish.type", 0);
+ CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS = Emulator.getConfig().getInt("camera.price.credits", 5);
+ CameraPurchaseEvent.CAMERA_PURCHASE_POINTS = Emulator.getConfig().getInt("camera.price.points", 5);
+ CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.type", 0);
+
+ BuyRoomPromotionEvent.ROOM_PROMOTION_BADGE = Emulator.getConfig().getValue("room.promotion.badge", "RADZZ");
+
+ NewNavigatorEventCategoriesComposer.CATEGORIES.clear();
+ for (String category : Emulator.getConfig().getValue("navigator.eventcategories", "").split(";")) {
+ try {
+ NewNavigatorEventCategoriesComposer.CATEGORIES.add(new EventCategory(category));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
if (Emulator.isReady) {
Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig();
Emulator.getGameEnvironment().getPointsScheduler().reloadConfig();
Emulator.getGameEnvironment().getPixelScheduler().reloadConfig();
Emulator.getGameEnvironment().getGotwPointsScheduler().reloadConfig();
-
}
}
diff --git a/src/main/java/com/eu/habbo/plugin/events/sanctions/SanctionEvent.java b/src/main/java/com/eu/habbo/plugin/events/sanctions/SanctionEvent.java
new file mode 100644
index 00000000..1a73c4f0
--- /dev/null
+++ b/src/main/java/com/eu/habbo/plugin/events/sanctions/SanctionEvent.java
@@ -0,0 +1,17 @@
+package com.eu.habbo.plugin.events.sanctions;
+
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.plugin.events.support.SupportEvent;
+
+public class SanctionEvent extends SupportEvent {
+ public Habbo target;
+
+ public int sanctionLevel;
+
+ public SanctionEvent(Habbo moderator, Habbo target, int sanctionLevel) {
+ super(moderator);
+
+ this.target = target;
+ this.sanctionLevel = sanctionLevel;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java
index d31f4a6c..8753b8bf 100644
--- a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java
+++ b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java
@@ -8,13 +8,14 @@ import java.util.Collection;
public class HabboAddedToRoomEvent extends UserEvent {
public final Room room;
- public final Collection habbosToSendEnter;
+ public Collection habbosToSendEnter;
+ public Collection visibleHabbos;
-
- public HabboAddedToRoomEvent(Habbo habbo, Room room, Collection habbosToSendEnter) {
+ public HabboAddedToRoomEvent(Habbo habbo, Room room, Collection habbosToSendEnter, Collection visibleHabbos) {
super(habbo);
this.room = room;
this.habbosToSendEnter = habbosToSendEnter;
+ this.visibleHabbos = visibleHabbos;
}
}
diff --git a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java
index 345c45be..77eb02ef 100644
--- a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java
+++ b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java
@@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.messages.outgoing.rooms.items.ItemsDataUpdateComposer;
import gnu.trove.set.hash.THashSet;
public class BattleBanzaiTilesFlicker implements Runnable {
@@ -36,9 +37,10 @@ public class BattleBanzaiTilesFlicker implements Runnable {
for (HabboItem item : this.items) {
item.setExtradata(state + "");
- this.room.updateItem(item);
}
+ this.room.sendComposer(new ItemsDataUpdateComposer(this.items).compose());
+
if (this.count == 5) {
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
item.setExtradata("0");
diff --git a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java
index af335844..b1af7db2 100644
--- a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java
+++ b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java
@@ -14,7 +14,7 @@ public class InsertModToolIssue implements Runnable {
@Override
public void run() {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO support_tickets (state, timestamp, score, sender_id, reported_id, room_id, mod_id, issue, category, group_id, thread_id, comment_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO support_tickets (state, timestamp, score, sender_id, reported_id, room_id, mod_id, issue, category, group_id, thread_id, comment_id, photo_item_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, this.issue.state.getState());
statement.setInt(2, this.issue.timestamp);
statement.setInt(3, this.issue.priority);
@@ -27,6 +27,7 @@ public class InsertModToolIssue implements Runnable {
statement.setInt(10, this.issue.groupId);
statement.setInt(11, this.issue.threadId);
statement.setInt(12, this.issue.commentId);
+ statement.setInt(13, this.issue.photoItem != null ? this.issue.photoItem.getId() : -1);
statement.execute();
try (ResultSet key = statement.getGeneratedKeys()) {
diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java
index 28c0cf96..331e5949 100644
--- a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java
+++ b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java
@@ -2,7 +2,7 @@ package com.eu.habbo.threading.runnables;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
-import com.eu.habbo.habbohotel.items.interactions.InteractionPetFood;
+import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
import com.eu.habbo.habbohotel.pets.GnomePet;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetTasks;
diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java
index 9e342d34..18489aec 100644
--- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java
+++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java
@@ -27,13 +27,14 @@ public class RoomUnitTeleport implements Runnable {
this.y = y;
this.z = z;
this.newEffect = newEffect;
+ roomUnit.isWiredTeleporting = true;
}
@Override
public void run() {
- if (roomUnit == null || roomUnit.getRoom() == null)
+ if (roomUnit == null || roomUnit.getRoom() == null || room.getLayout() == null)
return;
-
+
RoomTile t = this.room.getLayout().getTile((short) this.x, (short) this.y);
HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y);
@@ -53,8 +54,10 @@ public class RoomUnitTeleport implements Runnable {
ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, t, this.room).compose();
this.roomUnit.setLocation(t);
this.room.sendComposer(teleportMessage);
+ roomUnit.isWiredTeleporting = false;
this.room.updateHabbosAt(t.x, t.y);
+ this.room.updateBotsAt(t.x, t.y);
topItem = room.getTopItemAt(x, y);
if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short) x, (short) y))) {
diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java
index cb3e2935..7a648ff0 100644
--- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java
+++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java
@@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import java.util.ArrayList;
import java.util.List;
public class RoomUnitWalkToLocation implements Runnable {
@@ -14,6 +15,18 @@ public class RoomUnitWalkToLocation implements Runnable {
private List targetReached;
private List failedReached;
+ public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, Runnable targetReached, Runnable failedReached) {
+ this.walker = walker;
+ this.goalTile = goalTile;
+ this.room = room;
+
+ this.targetReached = new ArrayList<>();
+ if (targetReached != null) this.targetReached.add(targetReached);
+
+ this.failedReached = new ArrayList<>();
+ if (failedReached != null) this.targetReached.add(failedReached);
+ }
+
public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, List targetReached, List failedReached) {
this.walker = walker;
this.goalTile = goalTile;
@@ -29,17 +42,17 @@ public class RoomUnitWalkToLocation implements Runnable {
return;
}
- if (!this.walker.getGoal().equals(this.goalTile)) {
- onFail();
- return;
- }
-
if (this.walker.getCurrentLocation().equals(this.goalTile)) {
onSuccess();
return;
}
- Emulator.getThreading().run(this, 500);
+ if (!this.walker.getGoal().equals(this.goalTile)) {
+ onFail();
+ return;
+ }
+
+ Emulator.getThreading().run(this, 250);
}
private void onSuccess() {
diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java
index 1eeac72d..296490e7 100644
--- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java
+++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java
@@ -47,9 +47,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable {
if (this.goalTile == null)
return;
- if (this.walker.getGoal().equals(this.goalTile)) //Check if the goal is still the same. Chances are something is running the same task. If so we dump this task.
- {
- //Check if arrived.
+ if (this.walker.getGoal().equals(this.goalTile)) { // check that the action hasn't been cancelled by changing the goal
if (this.walker.getCurrentLocation().distance(this.goalTile) <= this.minDistance) {
for (Runnable r : this.targetReached) {
Emulator.getThreading().run(r);
@@ -57,38 +55,22 @@ public class RoomUnitWalkToRoomUnit implements Runnable {
WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, this.target, this.room, new Object[]{this.walker});
}
} else {
- List tiles = this.room.getLayout().getTilesAround(this.target.getCurrentLocation());
-
- for (RoomTile t : tiles) {
- if (t.equals(this.goalTile)) {
- Emulator.getThreading().run(this, 500);
- return;
- }
- }
-
- this.findNewLocation();
-
Emulator.getThreading().run(this, 500);
}
}
}
private void findNewLocation() {
- this.goalTile = this.room.getLayout().getTileInFront(this.target.getCurrentLocation(), this.target.getBodyRotation().getValue());
+ this.goalTile = this.walker.getClosestAdjacentTile(this.target.getCurrentLocation().x, this.target.getCurrentLocation().y, true);
- if (this.goalTile == null)
- return;
-
- if (!this.room.tileWalkable(this.goalTile)) {
- List tiles = this.room.getLayout().getTilesAround(this.target.getCurrentLocation());
-
- for (RoomTile t : tiles) {
- if (this.room.tileWalkable(t)) {
- this.goalTile = t;
-
- break;
+ if (this.goalTile == null) {
+ if (this.failedReached != null) {
+ for (Runnable r : this.failedReached) {
+ Emulator.getThreading().run(r);
}
}
+
+ return;
}
this.walker.setGoalLocation(this.goalTile);