mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
Merge branch 'dev' into 'master'
Arcturus 3.0.0-stable Closes #779, #741, #784, #780, #787, #788, #705, #721, #726, #727, #791, #802, #816, #804, #786, #772, #304, #841, #842, #390, #845, #844, #852, #853, #449, #789, #475, #474, #805, #496, #481, #478, #752, #858, #886, #885, #883, #881, #882, #915, #923, #934, #931, #876, #936, #957, and #956 See merge request morningstar/Arcturus-Community!425
This commit is contained in:
commit
211531afcd
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -0,0 +1,19 @@
|
||||
FROM maven:latest AS builder
|
||||
|
||||
# Copy the Emulator sources to the container
|
||||
COPY . .
|
||||
# Package it
|
||||
RUN mvn package && mv /target/Habbo*-with-dependencies.jar /target/Habbo.jar
|
||||
|
||||
# Use Java 8 for running
|
||||
FROM java:8 AS runner
|
||||
|
||||
# Copy the generated source
|
||||
COPY --from=builder /target/Habbo.jar /
|
||||
|
||||
# Save the script to wait for the database, among running the Arcturus Emulator
|
||||
RUN echo "#!/bin/bash \n java -Dfile.encoding=UTF-8 -jar /Habbo.jar" > /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
# Run the Emulator with Java
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
40
README.md
40
README.md
@ -11,10 +11,11 @@ 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.4.0-success.svg?style=for-the-badge&logo=appveyor)
|
||||
![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor)
|
||||
[![image](https://img.shields.io/badge/VERSION-3.0.0-success.svg?style=for-the-badge&logo=appveyor)](#)
|
||||
[![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor)](#)
|
||||
[![image](https://img.shields.io/discord/557240155040251905?style=for-the-badge&logo=discord&color=7289DA&label=DISCORD&logoColor=fff)](https://discord.gg/BzfFsTp)
|
||||
|
||||
Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases
|
||||
Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/-/releases
|
||||
|
||||
Client build: **PRODUCTION-201611291003-338511768**
|
||||
|
||||
@ -24,17 +25,36 @@ When making an bug report or a feature request use the template we provide so th
|
||||
|
||||
## Credits ##
|
||||
- TheGeneral
|
||||
- Capheus (Decompilation.)
|
||||
- Harmonic
|
||||
- Beny
|
||||
- Claudio
|
||||
- Alejandro
|
||||
- Harmony
|
||||
- Quadral (Pathfinder)
|
||||
- Capheus
|
||||
- Skeletor
|
||||
- z
|
||||
- ArpyAge
|
||||
- Harmonic
|
||||
- Mike
|
||||
- Remco
|
||||
- zGrav
|
||||
- Quadral
|
||||
- Harmony
|
||||
- Swirny
|
||||
- ArpyAge
|
||||
- Mikkel
|
||||
- Rodolfo
|
||||
- Rasmus
|
||||
- Kitt Mustang
|
||||
- Snaiker
|
||||
- nttzx
|
||||
- necmi
|
||||
- Dome
|
||||
- Jose Flores
|
||||
- Cam
|
||||
- Oliver
|
||||
- Narzo
|
||||
- Tenshie
|
||||
- MartenM
|
||||
- Ridge
|
||||
- SenpaiDipper
|
||||
- Snaiker
|
||||
- Thijmen
|
||||
|
||||
|
||||
## Discord ##
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.eu.habbo</groupId>
|
||||
<artifactId>Habbo</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<version>3.0.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
132
sqlupdates/2_4_0 to 3_0_BETA_1.sql
Normal file
132
sqlupdates/2_4_0 to 3_0_BETA_1.sql
Normal file
@ -0,0 +1,132 @@
|
||||
CREATE TABLE `users_subscriptions` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(10) UNSIGNED NULL,
|
||||
`subscription_type` varchar(255) NULL,
|
||||
`timestamp_start` int(10) UNSIGNED NULL,
|
||||
`duration` int(10) UNSIGNED NULL,
|
||||
`active` tinyint(1) NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `user_id`(`user_id`),
|
||||
INDEX `subscription_type`(`subscription_type`),
|
||||
INDEX `timestamp_start`(`timestamp_start`),
|
||||
INDEX `active`(`active`)
|
||||
);
|
||||
|
||||
CREATE TABLE `logs_shop_purchases` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`timestamp` int(10) UNSIGNED NULL,
|
||||
`user_id` int(10) UNSIGNED NULL,
|
||||
`catalog_item_id` int(10) UNSIGNED NULL,
|
||||
`item_ids` text DEFAULT NULL,
|
||||
`catalog_name` varchar(255) NULL,
|
||||
`cost_credits` int(10) NULL,
|
||||
`cost_points` int(10) NULL,
|
||||
`points_type` int(10) NULL,
|
||||
`amount` int(10) NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `timestamp`(`timestamp`),
|
||||
INDEX `user_id`(`user_id`)
|
||||
);
|
||||
|
||||
CREATE TABLE `logs_hc_payday` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`timestamp` int(10) UNSIGNED NULL,
|
||||
`user_id` int(10) UNSIGNED NULL,
|
||||
`hc_streak` int(10) UNSIGNED NULL,
|
||||
`total_coins_spent` int(10) UNSIGNED NULL,
|
||||
`reward_coins_spent` int(10) UNSIGNED NULL,
|
||||
`reward_streak` int(10) UNSIGNED NULL,
|
||||
`total_payout` int(10) UNSIGNED NULL,
|
||||
`currency` varchar(255) NULL,
|
||||
`claimed` tinyint(1) DEFAULT 0 NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `timestamp`(`timestamp`),
|
||||
INDEX `user_id`(`user_id`)
|
||||
);
|
||||
|
||||
ALTER TABLE `emulator_settings` MODIFY COLUMN `value` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL AFTER `key`;
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.payday.enabled', '1');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.payday.next_date', '2020-10-15 00:00:00');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.payday.interval', '1 month');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.payday.query', 'SELECT SUM(cost_credits) AS `amount_spent` FROM `logs_shop_purchases` WHERE `user_id` = @user_id AND `timestamp` > @timestamp_start AND `timestamp` <= @timestamp_end AND `catalog_name` NOT LIKE \'CF_%\' AND `catalog_name` NOT LIKE \'CFC_%\';');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.payday.streak', '7=5;30=10;60=15;90=20;180=25;365=30');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.payday.currency', 'credits');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.payday.percentage', '10');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.payday.creditsspent_reset_on_expire', '1');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.achievement', 'VipHC');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.discount.enabled', '1');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.hc.discount.days_before_end', '7');
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.scheduler.enabled', '1');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('subscriptions.scheduler.interval', '10');
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.clothingvalidation.onhcexpired', '0');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.clothingvalidation.onlogin', '0');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.clothingvalidation.onchangelooks', '0');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.clothingvalidation.onmimic', '0');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.clothingvalidation.onmannequin', '0');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.clothingvalidation.onfballgate', '0');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('gamedata.figuredata.url', 'https://habbo.com/gamedata/figuredata/0');
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.max.friends', '300');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.max.friends.hc', '1100');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.max.rooms', '50');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.users.max.rooms.hc', '75');
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.pixels.hc_modifier', '1');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.points.hc_modifier', '1');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.credits.hc_modifier', '1');
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.hc_modifier', '1');
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('room.chat.mutearea.allow_whisper', '1');
|
||||
|
||||
DELETE FROM `emulator_settings` WHERE `key` IN ('hotel.max.rooms.per.user', 'hotel.max.rooms.user', 'hotel.max.rooms.vip', 'max.friends', 'hotel.max.friends', 'max.friends.hc', 'hotel.max.friends.hc');
|
||||
|
||||
ALTER TABLE `users_settings` ADD COLUMN `max_friends` int(10) NULL DEFAULT 300 AFTER `has_gotten_default_saved_searches`;
|
||||
ALTER TABLE `users_settings` ADD COLUMN `max_rooms` int(10) NULL DEFAULT 50 AFTER `has_gotten_default_saved_searches`;
|
||||
ALTER TABLE `users_settings` ADD COLUMN `last_hc_payday` int(10) NULL DEFAULT 0 AFTER `has_gotten_default_saved_searches`;
|
||||
ALTER TABLE `users_settings` ADD COLUMN `hc_gifts_claimed` int(10) NULL DEFAULT 0 AFTER `has_gotten_default_saved_searches`;
|
||||
|
||||
ALTER TABLE `permissions` ADD COLUMN `cmd_subscription` enum('0','1') NULL DEFAULT '0' AFTER `cmd_credits`;
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_subscription', 'subscription;sub');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscription.invalid_action', 'Invalid action specified. Must be add, +, remove or -');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscription.type_not_found', '%subscription% is not a valid subscription type');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscription.invalid_params_time', 'Invalid time span, try: x minutes/days/weeks/months');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscription.success_add_time', 'Successfully added %time% seconds to %subscription% on %user%');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscription.user_not_have', '%user% does not have the %subscription% subscription');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscription.success_remove_time', 'Successfully removed %time% seconds from %subscription% on %user%');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscription.success_remove_sub', 'Successfully removed %subscription% sub from %user%');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscription.user_not_found', '%user% was not found');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscription.invalid_params', 'Invalid command format');
|
||||
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('subscriptions.hc.payday.message', 'Woohoo HC Payday has arrived! You have received %amount% credits to your purse. Enjoy!');
|
||||
|
||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.roomuser.idle.not_dancing.ignore.wired_idle', '0');
|
||||
|
||||
-- OPTIONAL HC MIGRATION
|
||||
-- INSERT INTO users_subscriptions SELECT NULL, user_id, 'HABBO_CLUB' as `subscription_type`, UNIX_TIMESTAMP() AS `timestamp_start`, (club_expire_timestamp - UNIX_TIMESTAMP()) AS `duration`, 1 AS `active` FROM users_settings WHERE club_expire_timestamp > UNIX_TIMESTAMP();
|
||||
|
||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.rooms.deco_hosting', '1');
|
||||
|
||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('easter_eggs.enabled', '1');
|
||||
|
||||
ALTER TABLE `bots`
|
||||
ADD COLUMN `bubble_id` int(3) NULL DEFAULT 31 AFTER `effect`;
|
||||
|
||||
-- Permissions to see tent chat
|
||||
ALTER TABLE `permissions` ADD `acc_see_tentchat` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_see_whispers`;
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', 'Tent');
|
||||
|
||||
-- Roombadge command
|
||||
ALTER TABLE `permissions` ADD `cmd_roombadge` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_massbadge`;
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_roombadge.no_badge', 'No badge specified!');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_roombadge', 'roombadge');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_roombadge', ':roombadge <badge>');
|
||||
|
||||
-- Making items.wired_data column bigger since wired data is saved as JSON now
|
||||
ALTER TABLE `items` MODIFY COLUMN `wired_data` varchar(10000);
|
||||
|
||||
-- Mute area sqls
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('room.chat.mutearea.allow_whisper', 'false');
|
||||
|
||||
|
2
sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql
Normal file
2
sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- Recycler value fix
|
||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('recycler.value', '8');
|
9
sqlupdates/3_0_BETA_1 to 3_0_0.sql
Normal file
9
sqlupdates/3_0_BETA_1 to 3_0_0.sql
Normal file
@ -0,0 +1,9 @@
|
||||
-- Wired variables for bots
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('wired.variable.name', '%name%');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('wired.variable.roomname', '%roomname%');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('wired.variable.user_count', '%user_count%');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('wired.variable.owner', '%owner%');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('wired.variable.item_count', '%item_count%');
|
||||
|
||||
-- Enable bubble alerts
|
||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('bubblealerts.enabled', '1');
|
@ -24,10 +24,10 @@ import java.io.*;
|
||||
import java.security.MessageDigest;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class Emulator {
|
||||
|
||||
@ -35,13 +35,12 @@ public final class Emulator {
|
||||
private static final String OS_NAME = System.getProperty("os.name");
|
||||
private static final String CLASS_PATH = System.getProperty("java.class.path");
|
||||
|
||||
public final static int MAJOR = 2;
|
||||
public final static int MINOR = 4;
|
||||
public final static int MAJOR = 3;
|
||||
public final static int MINOR = 0;
|
||||
public final static int BUILD = 0;
|
||||
|
||||
public final static String PREVIEW = "";
|
||||
|
||||
public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD;
|
||||
public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW;
|
||||
private static final String logo =
|
||||
"\n" +
|
||||
"███╗ ███╗ ██████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ ███████╗████████╗ █████╗ ██████╗ \n" +
|
||||
@ -49,8 +48,8 @@ public final class Emulator {
|
||||
"██╔████╔██║██║ ██║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗███████╗ ██║ ███████║██████╔╝\n" +
|
||||
"██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" +
|
||||
"██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" +
|
||||
"╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" +
|
||||
" ";
|
||||
"╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" ;
|
||||
|
||||
|
||||
public static String build = "";
|
||||
public static boolean isReady = false;
|
||||
@ -83,6 +82,13 @@ public final class Emulator {
|
||||
Runtime.getRuntime().addShutdownHook(hook);
|
||||
}
|
||||
|
||||
public static void promptEnterKey(){
|
||||
System.out.println("\n");
|
||||
System.out.println("Press \"ENTER\" if you agree to the terms stated above...");
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
scanner.nextLine();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
// Check if running on Windows and not in IntelliJ.
|
||||
@ -104,6 +110,12 @@ public final class Emulator {
|
||||
|
||||
System.out.println(logo);
|
||||
|
||||
// Checks if this is a BETA build before allowing them to continue.
|
||||
if (PREVIEW.toLowerCase().contains("beta")) {
|
||||
System.out.println("Warning, this is a beta build, this means that there may be unintended consequences so make sure you take regular backups while using this build. If you notice any issues you should make an issue on the Krews Git.");
|
||||
promptEnterKey();
|
||||
}
|
||||
|
||||
LOGGER.info("This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral.");
|
||||
LOGGER.info("Version: {}", version);
|
||||
LOGGER.info("Build: {}", build);
|
||||
@ -141,7 +153,7 @@ public final class Emulator {
|
||||
Emulator.rconServer.connect();
|
||||
Emulator.badgeImager = new BadgeImager();
|
||||
|
||||
LOGGER.info("Arcturus Morningstar has succesfully loaded.");
|
||||
LOGGER.info("Arcturus Morningstar has successfully loaded.");
|
||||
LOGGER.info("System launched in: {}ms. Using {} threads!", (System.nanoTime() - startTime) / 1e6, Runtime.getRuntime().availableProcessors() * 2);
|
||||
LOGGER.info("Memory: {}/{}MB", (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024), (runtime.freeMemory()) / (1024 * 1024));
|
||||
|
||||
@ -368,6 +380,65 @@ public final class Emulator {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static int timeStringToSeconds(String timeString) {
|
||||
int totalSeconds = 0;
|
||||
|
||||
Matcher m = Pattern.compile("(([0-9]*) (second|minute|hour|day|week|month|year))").matcher(timeString);
|
||||
Map<String,Integer> map = new HashMap<String,Integer>() {
|
||||
{
|
||||
put("second", 1);
|
||||
put("minute", 60);
|
||||
put("hour", 3600);
|
||||
put("day", 86400);
|
||||
put("week", 604800);
|
||||
put("month", 2628000);
|
||||
put("year", 31536000);
|
||||
}
|
||||
};
|
||||
|
||||
while (m.find()) {
|
||||
try {
|
||||
int amount = Integer.parseInt(m.group(2));
|
||||
String what = m.group(3);
|
||||
totalSeconds += amount * map.get(what);
|
||||
}
|
||||
catch (Exception ignored) { }
|
||||
}
|
||||
|
||||
return totalSeconds;
|
||||
}
|
||||
|
||||
public static Date modifyDate(Date date, String timeString) {
|
||||
int totalSeconds = 0;
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
|
||||
Matcher m = Pattern.compile("(([0-9]*) (second|minute|hour|day|week|month|year))").matcher(timeString);
|
||||
Map<String, Integer> map = new HashMap<String, Integer>() {
|
||||
{
|
||||
put("second", Calendar.SECOND);
|
||||
put("minute", Calendar.MINUTE);
|
||||
put("hour", Calendar.HOUR);
|
||||
put("day", Calendar.DAY_OF_MONTH);
|
||||
put("week", Calendar.WEEK_OF_MONTH);
|
||||
put("month", Calendar.MONTH);
|
||||
put("year", Calendar.YEAR);
|
||||
}
|
||||
};
|
||||
|
||||
while (m.find()) {
|
||||
try {
|
||||
int amount = Integer.parseInt(m.group(2));
|
||||
String what = m.group(3);
|
||||
c.add(map.get(what), amount);
|
||||
}
|
||||
catch (Exception ignored) { }
|
||||
}
|
||||
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
private static String dateToUnixTimestamp(Date date) {
|
||||
String res = "";
|
||||
Date aux = stringToDate("1970-01-01 00:00:00");
|
||||
@ -378,7 +449,7 @@ public final class Emulator {
|
||||
return res + seconds;
|
||||
}
|
||||
|
||||
private static Date stringToDate(String date) {
|
||||
public static Date stringToDate(String date) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date res = null;
|
||||
try {
|
||||
|
@ -144,8 +144,8 @@ public class CleanerThread implements Runnable {
|
||||
|
||||
if (Emulator.isReady) {
|
||||
for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) {
|
||||
habbo.getHabboStats().petRespectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect");
|
||||
habbo.getHabboStats().respectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect.pets");
|
||||
habbo.getHabboStats().respectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect");
|
||||
habbo.getHabboStats().petRespectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect.pets");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class ConfigurationManager {
|
||||
public boolean loaded = false;
|
||||
public boolean isLoading = false;
|
||||
|
||||
public ConfigurationManager(String configurationPath) throws Exception {
|
||||
public ConfigurationManager(String configurationPath) {
|
||||
this.properties = new Properties();
|
||||
this.configurationPath = configurationPath;
|
||||
this.reload();
|
||||
@ -37,7 +37,12 @@ public class ConfigurationManager {
|
||||
|
||||
String envDbHostname = System.getenv("DB_HOSTNAME");
|
||||
|
||||
boolean useEnvVarsForDbConnection = envDbHostname != null && envDbHostname.length() > 1;
|
||||
boolean useEnvVarsForDbConnection = false;
|
||||
|
||||
if(envDbHostname != null)
|
||||
{
|
||||
useEnvVarsForDbConnection = envDbHostname.length() > 1;
|
||||
}
|
||||
|
||||
if (!useEnvVarsForDbConnection) {
|
||||
try {
|
||||
|
@ -13,6 +13,7 @@ public class CreditsScheduler extends Scheduler {
|
||||
|
||||
public static boolean IGNORE_HOTEL_VIEW;
|
||||
public static boolean IGNORE_IDLED;
|
||||
public static double HC_MODIFIER;
|
||||
|
||||
public CreditsScheduler() {
|
||||
|
||||
@ -24,6 +25,8 @@ public class CreditsScheduler extends Scheduler {
|
||||
if (Emulator.getConfig().getBoolean("hotel.auto.credits.enabled")) {
|
||||
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.hotelview");
|
||||
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.idled");
|
||||
HC_MODIFIER = Emulator.getConfig().getDouble("hotel.auto.credits.hc_modifier", 1.0);
|
||||
|
||||
if (this.disposed) {
|
||||
this.disposed = false;
|
||||
this.run();
|
||||
@ -49,7 +52,7 @@ public class CreditsScheduler extends Scheduler {
|
||||
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
|
||||
continue;
|
||||
|
||||
habbo.giveCredits(habbo.getHabboInfo().getRank().getCreditsTimerAmount());
|
||||
habbo.giveCredits((int)(habbo.getHabboInfo().getRank().getCreditsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.core;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
@ -11,7 +12,7 @@ import com.eu.habbo.plugin.events.users.UserSavedMottoEvent;
|
||||
public class Easter {
|
||||
@EventHandler
|
||||
public static void onUserChangeMotto(UserSavedMottoEvent event) {
|
||||
if (event.newMotto.equalsIgnoreCase("crickey!")) {
|
||||
if (Emulator.getConfig().getBoolean("easter_eggs.enabled") && event.newMotto.equalsIgnoreCase("crickey!")) {
|
||||
event.habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(event.newMotto, event.habbo, event.habbo, RoomChatMessageBubbles.ALERT)));
|
||||
|
||||
Room room = event.habbo.getHabboInfo().getCurrentRoom();
|
||||
|
@ -14,6 +14,7 @@ public class GotwPointsScheduler extends Scheduler {
|
||||
public static boolean IGNORE_HOTEL_VIEW;
|
||||
public static boolean IGNORE_IDLED;
|
||||
public static String GOTW_POINTS_NAME;
|
||||
public static double HC_MODIFIER;
|
||||
|
||||
public GotwPointsScheduler() { //TODO MOVE TO A PLUGIN. IS NOT PART OF OFFICIAL HABBO.
|
||||
|
||||
@ -25,6 +26,7 @@ public class GotwPointsScheduler extends Scheduler {
|
||||
if (Emulator.getConfig().getBoolean("hotel.auto.gotwpoints.enabled")) {
|
||||
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.gotwpoints.ignore.hotelview");
|
||||
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.gotwpoints.ignore.idled");
|
||||
HC_MODIFIER = Emulator.getConfig().getDouble("hotel.auto.gotwpoints.hc_modifier", 1.0);
|
||||
GOTW_POINTS_NAME = Emulator.getConfig().getValue("hotel.auto.gotwpoints.name");
|
||||
|
||||
if (this.disposed) {
|
||||
@ -62,8 +64,7 @@ public class GotwPointsScheduler extends Scheduler {
|
||||
}
|
||||
type = Emulator.getConfig().getInt("seasonal.currency." + GOTW_POINTS_NAME, -1);
|
||||
if (found || type != -1) {
|
||||
|
||||
habbo.givePoints(type, habbo.getHabboInfo().getRank().getGotwTimerAmount());
|
||||
habbo.givePoints(type, (int)(habbo.getHabboInfo().getRank().getGotwTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0)));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -13,6 +13,7 @@ public class PixelScheduler extends Scheduler {
|
||||
|
||||
public static boolean IGNORE_HOTEL_VIEW;
|
||||
public static boolean IGNORE_IDLED;
|
||||
public static double HC_MODIFIER;
|
||||
|
||||
public PixelScheduler() {
|
||||
super(Emulator.getConfig().getInt("hotel.auto.pixels.interval"));
|
||||
@ -23,6 +24,7 @@ public class PixelScheduler extends Scheduler {
|
||||
if (Emulator.getConfig().getBoolean("hotel.auto.pixels.enabled")) {
|
||||
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.hotelview");
|
||||
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.idled");
|
||||
HC_MODIFIER = Emulator.getConfig().getDouble("hotel.auto.pixels.hc_modifier", 1.0);
|
||||
if (this.disposed) {
|
||||
this.disposed = false;
|
||||
this.run();
|
||||
@ -47,7 +49,7 @@ public class PixelScheduler extends Scheduler {
|
||||
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
|
||||
continue;
|
||||
|
||||
habbo.givePixels(habbo.getHabboInfo().getRank().getPixelsTimerAmount());
|
||||
habbo.givePixels((int)(habbo.getHabboInfo().getRank().getPixelsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
|
@ -13,6 +13,7 @@ public class PointsScheduler extends Scheduler {
|
||||
|
||||
public static boolean IGNORE_HOTEL_VIEW;
|
||||
public static boolean IGNORE_IDLED;
|
||||
public static double HC_MODIFIER;
|
||||
|
||||
public PointsScheduler() {
|
||||
|
||||
@ -24,6 +25,7 @@ public class PointsScheduler extends Scheduler {
|
||||
if (Emulator.getConfig().getBoolean("hotel.auto.points.enabled")) {
|
||||
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.hotelview");
|
||||
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.idled");
|
||||
HC_MODIFIER = Emulator.getConfig().getDouble("hotel.auto.points.hc_modifier", 1.0);
|
||||
if (this.disposed) {
|
||||
this.disposed = false;
|
||||
this.run();
|
||||
@ -50,7 +52,7 @@ public class PointsScheduler extends Scheduler {
|
||||
continue;
|
||||
|
||||
//habbo.givePoints(POINTS);
|
||||
habbo.givePoints(habbo.getHabboInfo().getRank().getDiamondsTimerAmount());
|
||||
habbo.givePoints((int)(habbo.getHabboInfo().getRank().getDiamondsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
|
@ -72,7 +72,7 @@ public class TextsManager {
|
||||
public int getInt(String key, Integer defaultValue) {
|
||||
try {
|
||||
return Integer.parseInt(this.getValue(key, defaultValue.toString()));
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
}
|
||||
return defaultValue;
|
||||
|
@ -3,9 +3,18 @@ package com.eu.habbo.database;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.core.ConfigurationManager;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Database {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Database.class);
|
||||
@ -53,4 +62,52 @@ public class Database {
|
||||
public DatabasePool getDatabasePool() {
|
||||
return this.databasePool;
|
||||
}
|
||||
|
||||
public static PreparedStatement preparedStatementWithParams(Connection connection, String query, THashMap<String, Object> queryParams) throws SQLException {
|
||||
THashMap<Integer, Object> params = new THashMap<Integer, Object>();
|
||||
THashSet<String> quotedParams = new THashSet<>();
|
||||
|
||||
for(String key : queryParams.keySet()) {
|
||||
quotedParams.add(Pattern.quote(key));
|
||||
}
|
||||
|
||||
String regex = "(" + String.join("|", quotedParams) + ")";
|
||||
|
||||
Matcher m = Pattern.compile(regex).matcher(query);
|
||||
|
||||
int i = 1;
|
||||
|
||||
while (m.find()) {
|
||||
try {
|
||||
params.put(i, queryParams.get(m.group(1)));
|
||||
i++;
|
||||
}
|
||||
catch (Exception ignored) { }
|
||||
}
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement(query.replaceAll(regex, "?"));
|
||||
|
||||
for(Map.Entry<Integer, Object> set : params.entrySet()) {
|
||||
if(set.getValue().getClass() == String.class) {
|
||||
statement.setString(set.getKey(), (String)set.getValue());
|
||||
}
|
||||
else if(set.getValue().getClass() == Integer.class) {
|
||||
statement.setInt(set.getKey(), (Integer)set.getValue());
|
||||
}
|
||||
else if(set.getValue().getClass() == Double.class) {
|
||||
statement.setDouble(set.getKey(), (Double)set.getValue());
|
||||
}
|
||||
else if(set.getValue().getClass() == Float.class) {
|
||||
statement.setFloat(set.getKey(), (Float)set.getValue());
|
||||
}
|
||||
else if(set.getValue().getClass() == Long.class) {
|
||||
statement.setLong(set.getKey(), (Long)set.getValue());
|
||||
}
|
||||
else {
|
||||
statement.setObject(set.getKey(), set.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return statement;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import com.eu.habbo.habbohotel.pets.PetManager;
|
||||
import com.eu.habbo.habbohotel.polls.PollManager;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomManager;
|
||||
import com.eu.habbo.habbohotel.users.HabboManager;
|
||||
import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionManager;
|
||||
import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionScheduler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -31,6 +33,8 @@ public class GameEnvironment {
|
||||
public PixelScheduler pixelScheduler;
|
||||
public PointsScheduler pointsScheduler;
|
||||
public GotwPointsScheduler gotwPointsScheduler;
|
||||
public SubscriptionScheduler subscriptionScheduler;
|
||||
|
||||
private HabboManager habboManager;
|
||||
private NavigatorManager navigatorManager;
|
||||
private GuildManager guildManager;
|
||||
@ -49,6 +53,7 @@ public class GameEnvironment {
|
||||
private WordFilter wordFilter;
|
||||
private CraftingManager craftingManager;
|
||||
private PollManager pollManager;
|
||||
private SubscriptionManager subscriptionManager;
|
||||
|
||||
public void load() throws Exception {
|
||||
LOGGER.info("GameEnvironment -> Loading...");
|
||||
@ -86,6 +91,11 @@ public class GameEnvironment {
|
||||
this.gotwPointsScheduler = new GotwPointsScheduler();
|
||||
Emulator.getThreading().run(this.gotwPointsScheduler);
|
||||
|
||||
this.subscriptionManager = new SubscriptionManager();
|
||||
this.subscriptionManager.init();
|
||||
|
||||
this.subscriptionScheduler = new SubscriptionScheduler();
|
||||
Emulator.getThreading().run(this.subscriptionScheduler);
|
||||
|
||||
LOGGER.info("GameEnvironment -> Loaded!");
|
||||
}
|
||||
@ -103,6 +113,7 @@ public class GameEnvironment {
|
||||
this.roomManager.dispose();
|
||||
this.itemManager.dispose();
|
||||
this.hotelViewManager.dispose();
|
||||
this.subscriptionManager.dispose();
|
||||
LOGGER.info("GameEnvironment -> Disposed!");
|
||||
}
|
||||
|
||||
@ -191,4 +202,8 @@ public class GameEnvironment {
|
||||
|
||||
public GotwPointsScheduler getGotwPointsScheduler() { return this.gotwPointsScheduler;
|
||||
}
|
||||
|
||||
public SubscriptionManager getSubscriptionManager() {
|
||||
return this.subscriptionManager;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public class Bot implements Runnable {
|
||||
private int chatTimeOut;
|
||||
private int chatTimestamp;
|
||||
private short lastChatIndex;
|
||||
private int bubble;
|
||||
|
||||
|
||||
private String type;
|
||||
@ -73,6 +74,7 @@ public class Bot implements Runnable {
|
||||
this.chatLines = new ArrayList<>();
|
||||
this.type = "generic_bot";
|
||||
this.room = null;
|
||||
this.bubble = RoomChatMessageBubbles.BOT_RENTABLE.getType();
|
||||
}
|
||||
|
||||
public Bot(ResultSet set) throws SQLException {
|
||||
@ -94,6 +96,7 @@ public class Bot implements Runnable {
|
||||
this.roomUnit = null;
|
||||
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
|
||||
this.needsUpdate = false;
|
||||
this.bubble = set.getInt("bubble_id");
|
||||
}
|
||||
|
||||
public Bot(Bot bot) {
|
||||
@ -110,6 +113,7 @@ public class Bot implements Runnable {
|
||||
this.chatLines = new ArrayList<>(Arrays.asList("Default Message :D"));
|
||||
this.type = bot.getType();
|
||||
this.effect = bot.getEffect();
|
||||
this.bubble = bot.getBubbleId();
|
||||
|
||||
this.needsUpdate = false;
|
||||
}
|
||||
@ -133,7 +137,7 @@ public class Bot implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ? WHERE id = ?")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) {
|
||||
statement.setString(1, this.name);
|
||||
statement.setString(2, this.motto);
|
||||
statement.setString(3, this.figure);
|
||||
@ -155,7 +159,8 @@ public class Bot implements Runnable {
|
||||
statement.setString(15, this.chatRandom ? "1" : "0");
|
||||
statement.setInt(16, this.chatDelay);
|
||||
statement.setInt(17, this.effect);
|
||||
statement.setInt(18, this.id);
|
||||
statement.setInt(18, this.bubble);
|
||||
statement.setInt(19, this.id);
|
||||
statement.execute();
|
||||
this.needsUpdate = false;
|
||||
} catch (SQLException e) {
|
||||
@ -173,11 +178,11 @@ public class Bot implements Runnable {
|
||||
int timeOut = Emulator.getRandom().nextInt(20) * 2;
|
||||
this.roomUnit.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp());
|
||||
}
|
||||
} else {
|
||||
}/* else {
|
||||
for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) {
|
||||
WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) {
|
||||
@ -188,12 +193,16 @@ public class Bot implements Runnable {
|
||||
this.lastChatIndex = 0;
|
||||
}
|
||||
|
||||
this.talk(this.chatLines.get(this.lastChatIndex)
|
||||
.replace("%owner%", this.room.getOwnerName())
|
||||
.replace("%item_count%", this.room.itemCount() + "")
|
||||
.replace("%name%", this.name)
|
||||
.replace("%roomname%", this.room.getName())
|
||||
.replace("%user_count%", this.room.getUserCount() + ""));
|
||||
String message = this.chatLines.get(this.lastChatIndex)
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.room.getOwnerName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.itemCount() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.name)
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getUserCount() + "");
|
||||
|
||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{ message })) {
|
||||
this.talk(message);
|
||||
}
|
||||
|
||||
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
|
||||
}
|
||||
@ -208,7 +217,7 @@ public class Bot implements Runnable {
|
||||
return;
|
||||
|
||||
this.chatTimestamp = Emulator.getIntUnixTimestamp();
|
||||
this.room.botChat(new RoomUserTalkComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose());
|
||||
this.room.botChat(new RoomUserTalkComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose());
|
||||
|
||||
if (message.equals("o/") || message.equals("_o/")) {
|
||||
this.room.sendComposer(new RoomUserActionComposer(this.roomUnit, RoomUserAction.WAVE).compose());
|
||||
@ -223,7 +232,7 @@ public class Bot implements Runnable {
|
||||
return;
|
||||
|
||||
this.chatTimestamp = Emulator.getIntUnixTimestamp();
|
||||
this.room.botChat(new RoomUserShoutComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose());
|
||||
this.room.botChat(new RoomUserShoutComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose());
|
||||
|
||||
if (message.equals("o/") || message.equals("_o/")) {
|
||||
this.room.sendComposer(new RoomUserActionComposer(this.roomUnit, RoomUserAction.WAVE).compose());
|
||||
@ -238,7 +247,7 @@ public class Bot implements Runnable {
|
||||
return;
|
||||
|
||||
this.chatTimestamp = Emulator.getIntUnixTimestamp();
|
||||
event.target.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)));
|
||||
event.target.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))));
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +256,12 @@ public class Bot implements Runnable {
|
||||
room.giveEffect(this.roomUnit, this.effect, -1);
|
||||
}
|
||||
|
||||
this.talk(PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)]);
|
||||
if(PLACEMENT_MESSAGES.length > 0) {
|
||||
String message = PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)];
|
||||
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{message})) {
|
||||
this.talk(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPickUp(Habbo habbo, Room room) {
|
||||
@ -270,6 +284,10 @@ public class Bot implements Runnable {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getBubbleId() {
|
||||
return bubble;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
this.needsUpdate = true;
|
||||
|
@ -12,6 +12,7 @@ import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||
import com.eu.habbo.messages.outgoing.inventory.AddBotComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.RemoveBotComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
|
||||
import com.eu.habbo.plugin.events.bots.BotPickUpEvent;
|
||||
import com.eu.habbo.plugin.events.bots.BotPlacedEvent;
|
||||
@ -48,14 +49,9 @@ public class BotManager {
|
||||
}
|
||||
|
||||
public static void addBotDefinition(String type, Class<? extends Bot> botClazz) throws Exception {
|
||||
if (botClazz.getDeclaredConstructor(ResultSet.class) == null) {
|
||||
throw new Exception("Missing Bot(ResultSet) constructor!");
|
||||
} else {
|
||||
botClazz.getDeclaredConstructor(ResultSet.class).setAccessible(true);
|
||||
|
||||
botDefenitions.put(type, botClazz);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean reload() {
|
||||
for (Map.Entry<String, Class<? extends Bot>> set : botDefenitions.entrySet()) {
|
||||
@ -144,6 +140,7 @@ public class BotManager {
|
||||
room.addBot(bot);
|
||||
Emulator.getThreading().run(bot);
|
||||
room.sendComposer(new RoomUsersComposer(bot).compose());
|
||||
room.sendComposer(new RoomUserStatusComposer(bot.getRoomUnit()).compose());
|
||||
habbo.getInventory().getBotsComponent().removeBot(bot);
|
||||
habbo.getClient().sendResponse(new RemoveBotComposer(bot));
|
||||
bot.onPlace(habbo, room);
|
||||
|
@ -3,6 +3,8 @@ package com.eu.habbo.habbohotel.bots;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.plugin.events.bots.BotServerItemEvent;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit;
|
||||
@ -56,49 +58,80 @@ public class ButlerBot extends Bot {
|
||||
|
||||
@Override
|
||||
public void onUserSay(final RoomChatMessage message) {
|
||||
if (this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
|
||||
if (this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || this.getRoom() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
double distanceBetweenBotAndHabbo = this.getRoomUnit().getCurrentLocation().distance(message.getHabbo().getRoomUnit().getCurrentLocation());
|
||||
|
||||
if (distanceBetweenBotAndHabbo <= Emulator.getConfig().getInt("hotel.bot.butler.commanddistance")) {
|
||||
|
||||
if (this.getRoomUnit().getCurrentLocation().distance(message.getHabbo().getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.commanddistance"))
|
||||
if (message.getUnfilteredMessage() != null) {
|
||||
for (Map.Entry<THashSet<String>, Integer> set : serveItems.entrySet()) {
|
||||
for (String s : set.getKey()) {
|
||||
if (message.getUnfilteredMessage().toLowerCase().contains(s)) {
|
||||
for (String keyword : set.getKey()) {
|
||||
|
||||
// Check if the string contains a certain keyword using a regex.
|
||||
// If keyword = tea, teapot wouldn't trigger it.
|
||||
if (message.getUnfilteredMessage().toLowerCase().matches("\\b" + keyword + "\\b")) {
|
||||
|
||||
// Enable plugins to cancel this event
|
||||
BotServerItemEvent serveEvent = new BotServerItemEvent(this, message.getHabbo(), set.getValue());
|
||||
if (Emulator.getPluginManager().fireEvent(serveEvent).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Start give handitem process
|
||||
if (this.getRoomUnit().canWalk()) {
|
||||
final String key = s;
|
||||
final Bot b = this;
|
||||
b.lookAt(serveEvent.habbo);
|
||||
final String key = keyword;
|
||||
final Bot bot = this;
|
||||
|
||||
final List<Runnable> tasks = new ArrayList();
|
||||
// Step 1: Look at Habbo
|
||||
bot.lookAt(serveEvent.habbo);
|
||||
|
||||
// Step 2: Prepare tasks for when the Bot (carrying the handitem) reaches the Habbo
|
||||
final List<Runnable> tasks = new ArrayList<>();
|
||||
tasks.add(new RoomUnitGiveHanditem(serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), 0));
|
||||
|
||||
tasks.add(() -> b.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername())));
|
||||
tasks.add(() -> {
|
||||
if(this.getRoom() != null) {
|
||||
String botMessage = Emulator.getTexts()
|
||||
.getValue("bots.butler.given")
|
||||
.replace("%key%", key)
|
||||
.replace("%username%", serveEvent.habbo.getHabboInfo().getUsername());
|
||||
|
||||
List<Runnable> failedReached = new ArrayList();
|
||||
failedReached.add(() -> {
|
||||
if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance", 8)) {
|
||||
for (Runnable t : tasks) {
|
||||
t.run();
|
||||
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{ botMessage })) {
|
||||
bot.talk(botMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<Runnable> failedReached = new ArrayList<>();
|
||||
failedReached.add(() -> {
|
||||
if (distanceBetweenBotAndHabbo <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance", 8)) {
|
||||
for (Runnable task : tasks) {
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Give bot the handitem that it's going to give the Habbo
|
||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId));
|
||||
|
||||
if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) > Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)) {
|
||||
if (distanceBetweenBotAndHabbo > Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)) {
|
||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.getRoomUnit(), serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), tasks, failedReached, Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)));
|
||||
} else {
|
||||
Emulator.getThreading().run(failedReached.get(0), 1000);
|
||||
}
|
||||
} else {
|
||||
if(this.getRoom() != null) {
|
||||
this.getRoom().giveHandItem(serveEvent.habbo, serveEvent.itemId);
|
||||
this.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", s).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()));
|
||||
|
||||
String msg = Emulator.getTexts().getValue("bots.butler.given").replace("%key%", keyword).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername());
|
||||
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{msg})) {
|
||||
this.talk(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -107,3 +140,4 @@ public class ButlerBot extends Bot {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -615,6 +615,16 @@ public class CatalogManager {
|
||||
.findAny().orElse(null);
|
||||
}
|
||||
|
||||
public CatalogPage getCatalogPageByLayout(String layoutName) {
|
||||
return this.catalogPages.valueCollection().stream()
|
||||
.filter(p -> p != null &&
|
||||
p.isVisible() &&
|
||||
p.isEnabled() &&
|
||||
p.getRank() < 2 &&
|
||||
p.getLayout() != null && p.getLayout().equalsIgnoreCase(layoutName)
|
||||
)
|
||||
.findAny().orElse(null);
|
||||
}
|
||||
|
||||
public CatalogItem getCatalogItem(int id) {
|
||||
final CatalogItem[] item = {null};
|
||||
@ -639,10 +649,19 @@ public class CatalogManager {
|
||||
this.catalogPages.get(parentId).childPages.forEachValue(new TObjectProcedure<CatalogPage>() {
|
||||
@Override
|
||||
public boolean execute(CatalogPage object) {
|
||||
if (object.getRank() <= habbo.getHabboInfo().getRank().getId() && object.visible) {
|
||||
pages.add(object);
|
||||
|
||||
boolean isVisiblePage = object.visible;
|
||||
boolean hasRightRank = object.getRank() <= habbo.getHabboInfo().getRank().getId();
|
||||
|
||||
boolean clubRightsOkay = true;
|
||||
|
||||
if(object.isClubOnly() && !habbo.getHabboInfo().getHabboStats().hasActiveClub()) {
|
||||
clubRightsOkay = false;
|
||||
}
|
||||
|
||||
if (isVisiblePage && hasRightRank && clubRightsOkay) {
|
||||
pages.add(object);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -1060,9 +1079,6 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
|
||||
UserCatalogItemPurchasedEvent purchasedEvent = new UserCatalogItemPurchasedEvent(habbo, item, itemsList, totalCredits, totalPoints, badges);
|
||||
Emulator.getPluginManager().fireEvent(purchasedEvent);
|
||||
|
||||
if (badgeFound) {
|
||||
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.ALREADY_HAVE_BADGE));
|
||||
|
||||
@ -1071,6 +1087,9 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
|
||||
UserCatalogItemPurchasedEvent purchasedEvent = new UserCatalogItemPurchasedEvent(habbo, item, itemsList, totalCredits, totalPoints, badges);
|
||||
Emulator.getPluginManager().fireEvent(purchasedEvent);
|
||||
|
||||
if (!free && !habbo.getClient().getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) {
|
||||
if (purchasedEvent.totalCredits > 0) {
|
||||
habbo.getClient().getHabbo().getHabboInfo().addCredits(-purchasedEvent.totalCredits);
|
||||
@ -1121,6 +1140,26 @@ public class CatalogManager {
|
||||
habbo.getClient().sendResponse(new PurchaseOKComposer(purchasedEvent.catalogItem));
|
||||
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
||||
|
||||
THashSet<String> itemIds = new THashSet<>();
|
||||
|
||||
for(HabboItem ix : purchasedEvent.itemsList) {
|
||||
itemIds.add(ix.getId() + "");
|
||||
}
|
||||
|
||||
if(!free) {
|
||||
Emulator.getThreading().run(new CatalogPurchaseLogEntry(
|
||||
Emulator.getIntUnixTimestamp(),
|
||||
purchasedEvent.habbo.getHabboInfo().getId(),
|
||||
purchasedEvent.catalogItem != null ? purchasedEvent.catalogItem.getId() : 0,
|
||||
String.join(";", itemIds),
|
||||
purchasedEvent.catalogItem != null ? purchasedEvent.catalogItem.getName() : "",
|
||||
purchasedEvent.totalCredits,
|
||||
purchasedEvent.totalPoints,
|
||||
item != null ? item.getPointsType() : 0,
|
||||
amount
|
||||
));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Exception caught", e);
|
||||
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||
|
@ -0,0 +1,61 @@
|
||||
package com.eu.habbo.habbohotel.catalog;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.core.DatabaseLoggable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class CatalogPurchaseLogEntry implements Runnable, DatabaseLoggable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CatalogPurchaseLogEntry.class);
|
||||
private static final String QUERY = "INSERT INTO `logs_shop_purchases` (timestamp, user_id, catalog_item_id, item_ids, catalog_name, cost_credits, cost_points, points_type, amount) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
private final int timestamp;
|
||||
private final int userId;
|
||||
private final int catalogItemId;
|
||||
private final String itemIds;
|
||||
private final String catalogName;
|
||||
private final int costCredits;
|
||||
private final int costPoints;
|
||||
private final int pointsType;
|
||||
private final int amount;
|
||||
|
||||
public CatalogPurchaseLogEntry(int timestamp, int userId, int catalogItemId, String itemIds, String catalogName, int costCredits, int costPoints, int pointsType, int amount) {
|
||||
this.timestamp = timestamp;
|
||||
this.userId = userId;
|
||||
this.catalogItemId = catalogItemId;
|
||||
this.itemIds = itemIds;
|
||||
this.catalogName = catalogName;
|
||||
this.costCredits = costCredits;
|
||||
this.costPoints = costPoints;
|
||||
this.pointsType = pointsType;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery() {
|
||||
return QUERY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(PreparedStatement statement) throws SQLException {
|
||||
statement.setInt(1, this.timestamp);
|
||||
statement.setInt(2, this.userId);
|
||||
statement.setInt(3, this.catalogItemId);
|
||||
statement.setString(4, this.itemIds);
|
||||
statement.setString(5, this.catalogName);
|
||||
statement.setInt(6, this.costCredits);
|
||||
statement.setInt(7, this.costPoints);
|
||||
statement.setInt(8, this.pointsType);
|
||||
statement.setInt(9, this.amount);
|
||||
statement.addBatch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Emulator.getDatabaseLogger().store(this);
|
||||
}
|
||||
}
|
@ -1,9 +1,15 @@
|
||||
package com.eu.habbo.habbohotel.catalog;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.messages.ISerialize;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class ClubOffer {
|
||||
public class ClubOffer implements ISerialize {
|
||||
|
||||
private final int id;
|
||||
|
||||
@ -70,4 +76,47 @@ public class ClubOffer {
|
||||
public boolean isDeal() {
|
||||
return this.deal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ServerMessage message) {
|
||||
serialize(message, Emulator.getIntUnixTimestamp());
|
||||
}
|
||||
|
||||
public void serialize(ServerMessage message, int hcExpireTimestamp) {
|
||||
hcExpireTimestamp = Math.max(Emulator.getIntUnixTimestamp(), hcExpireTimestamp);
|
||||
message.appendInt(this.id);
|
||||
message.appendString(this.name);
|
||||
message.appendBoolean(false); //unused
|
||||
message.appendInt(this.credits);
|
||||
message.appendInt(this.points);
|
||||
message.appendInt(this.pointsType);
|
||||
message.appendBoolean(this.vip);
|
||||
|
||||
long seconds = this.days * 86400;
|
||||
|
||||
long secondsTotal = seconds;
|
||||
|
||||
int totalYears = (int) Math.floor((int) seconds / (86400.0 * 31 * 12));
|
||||
seconds -= totalYears * (86400 * 31 * 12);
|
||||
|
||||
int totalMonths = (int) Math.floor((int) seconds / (86400.0 * 31));
|
||||
seconds -= totalMonths * (86400 * 31);
|
||||
|
||||
int totalDays = (int) Math.floor((int) seconds / 86400.0);
|
||||
seconds -= totalDays * 86400;
|
||||
|
||||
message.appendInt((int) secondsTotal / 86400 / 31);
|
||||
message.appendInt((int) seconds);
|
||||
message.appendBoolean(false); //giftable
|
||||
message.appendInt((int) seconds);
|
||||
|
||||
hcExpireTimestamp += secondsTotal;
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
cal.setTimeInMillis(hcExpireTimestamp * 1000L);
|
||||
message.appendInt(cal.get(Calendar.YEAR));
|
||||
message.appendInt(cal.get(Calendar.MONTH) + 1);
|
||||
message.appendInt(cal.get(Calendar.DAY_OF_MONTH));
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogItem;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomManager;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||
@ -133,7 +134,7 @@ public class RoomBundleLayout extends SingleBundle {
|
||||
|
||||
if (habbo != null) {
|
||||
int count = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(habbo).size();
|
||||
int max = habbo.getHabboStats().hasActiveClub() ? Emulator.getConfig().getInt("hotel.max.rooms.vip") : Emulator.getConfig().getInt("hotel.max.rooms.user");
|
||||
int max = habbo.getHabboStats().hasActiveClub() ? RoomManager.MAXIMUM_ROOMS_HC : RoomManager.MAXIMUM_ROOMS_USER;
|
||||
|
||||
if (count >= max) {
|
||||
habbo.getClient().sendResponse(new CanCreateRoomComposer(count, max));
|
||||
|
@ -3,7 +3,10 @@ package com.eu.habbo.habbohotel.commands;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.catalog.CatalogManager;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.users.HabboManager;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@ -11,9 +14,12 @@ public class AboutCommand extends Command {
|
||||
public AboutCommand() {
|
||||
super(null, new String[]{"about", "info", "online", "server"});
|
||||
}
|
||||
|
||||
public static String credits = "Arcturus Morningstar is an opensource project based on Arcturus By TheGeneral \n" +
|
||||
"The Following people have all contributed to this emulator:\n" +
|
||||
" TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Quadral \n Harmony\n Swirny\n ArpyAge\n Mikkel\n Rodolfo\n Rasmus\n Kitt Mustang\n Snaiker\n nttzx\n necmi\n Dome\n Jose Flores\n Cam\n Oliver\n Narzo\n Tenshie\n MartenM\n Ridge\n SenpaiDipper\n Snaiker\n Thijmen";
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) {
|
||||
|
||||
Emulator.getRuntime().gc();
|
||||
|
||||
int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted();
|
||||
@ -42,9 +48,8 @@ public class AboutCommand extends Command {
|
||||
|
||||
"<b>Thanks for using Arcturus. Report issues on the forums. http://arcturus.wf \r\r" +
|
||||
" - The General";
|
||||
|
||||
gameClient.getHabbo().alert(message);
|
||||
|
||||
gameClient.sendResponse(new MessagesForYouComposer(Collections.singletonList(credits)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.pets.PetCommand;
|
||||
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
||||
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomRightLevels;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTypingComposer;
|
||||
import com.eu.habbo.plugin.events.users.UserCommandEvent;
|
||||
import com.eu.habbo.plugin.events.users.UserExecuteCommandEvent;
|
||||
@ -72,9 +73,14 @@ public class CommandHandler {
|
||||
for (String s : command.keys) {
|
||||
if (s.toLowerCase().equals(parts[0].toLowerCase())) {
|
||||
boolean succes = false;
|
||||
if (command.permission == null || gameClient.getHabbo().hasPermission(command.permission, gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && (gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasPermission(Permission.ACC_PLACEFURNI) || (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().getGuildId() > 0 && gameClient.getHabbo().getHabboInfo().getCurrentRoom().guildRightLevel(gameClient.getHabbo()) >= 2))) {
|
||||
if (command.permission == null || gameClient.getHabbo().hasPermission(command.permission, gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && (gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasPermission(Permission.ACC_PLACEFURNI) || (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().getGuildId() > 0 && gameClient.getHabbo().getHabboInfo().getCurrentRoom().getGuildRightLevel(gameClient.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS)))) {
|
||||
try {
|
||||
Emulator.getPluginManager().fireEvent(new UserExecuteCommandEvent(gameClient.getHabbo(), command, parts));
|
||||
UserExecuteCommandEvent userExecuteCommandEvent = new UserExecuteCommandEvent(gameClient.getHabbo(), command, parts);
|
||||
Emulator.getPluginManager().fireEvent(userExecuteCommandEvent);
|
||||
|
||||
if(userExecuteCommandEvent.isCancelled()) {
|
||||
return userExecuteCommandEvent.isSuccess();
|
||||
}
|
||||
|
||||
if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null)
|
||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserTypingComposer(gameClient.getHabbo().getRoomUnit(), false).compose());
|
||||
@ -211,6 +217,7 @@ public class CommandHandler {
|
||||
addCommand(new LayCommand());
|
||||
addCommand(new MachineBanCommand());
|
||||
addCommand(new MassBadgeCommand());
|
||||
addCommand(new RoomBadgeCommand());
|
||||
addCommand(new MassCreditsCommand());
|
||||
addCommand(new MassGiftCommand());
|
||||
addCommand(new MassPixelsCommand());
|
||||
@ -285,6 +292,7 @@ public class CommandHandler {
|
||||
addCommand(new UpdateYoutubePlaylistsCommand());
|
||||
addCommand(new AddYoutubePlaylistCommand());
|
||||
addCommand(new SoftKickCommand());
|
||||
addCommand(new SubscriptionCommand());
|
||||
|
||||
addCommand(new TestCommand());
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.commands;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomRightLevels;
|
||||
|
||||
public class EjectAllCommand extends Command {
|
||||
public EjectAllCommand() {
|
||||
@ -14,7 +15,7 @@ public class EjectAllCommand extends Command {
|
||||
Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
|
||||
if (room != null) {
|
||||
if (room.isOwner(gameClient.getHabbo()) || (room.hasGuild() && room.guildRightLevel(gameClient.getHabbo()) == 3)) {
|
||||
if (room.isOwner(gameClient.getHabbo()) || (room.hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) {
|
||||
room.ejectAll(gameClient.getHabbo());
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
||||
import com.eu.habbo.messages.outgoing.users.UserDataComposer;
|
||||
import com.eu.habbo.util.figure.FigureUtil;
|
||||
@ -35,7 +36,7 @@ public class MimicCommand extends Command {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.forbidden_clothing"), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
} else {
|
||||
gameClient.getHabbo().getHabboInfo().setLook(habbo.getHabboInfo().getLook());
|
||||
gameClient.getHabbo().getHabboInfo().setLook(ClothingValidationManager.VALIDATE_ON_MIMIC ? ClothingValidationManager.validateLook(gameClient.getHabbo(), habbo.getHabboInfo().getLook(), habbo.getHabboInfo().getGender().name()) : habbo.getHabboInfo().getLook());
|
||||
gameClient.getHabbo().getHabboInfo().setGender(habbo.getHabboInfo().getGender());
|
||||
gameClient.sendResponse(new UserDataComposer(gameClient.getHabbo()));
|
||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(gameClient.getHabbo()).compose());
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.eu.habbo.habbohotel.commands;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||
import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
public class RoomBadgeCommand extends Command {
|
||||
public RoomBadgeCommand() {
|
||||
super("cmd_roombadge", Emulator.getTexts().getValue("commands.keys.cmd_roombadge").split(";"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||
if (gameClient == null)
|
||||
return true;
|
||||
|
||||
if (params.length == 2) {
|
||||
String badge;
|
||||
|
||||
badge = params[1];
|
||||
|
||||
if (!badge.isEmpty()) {
|
||||
THashMap<String, String> keys = new THashMap<>();
|
||||
keys.put("display", "BUBBLE");
|
||||
keys.put("image", "${image.library.url}album1584/" + badge + ".gif");
|
||||
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
|
||||
ServerMessage message = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
|
||||
|
||||
for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getHabbos()) {
|
||||
if (habbo.isOnline()) {
|
||||
if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
|
||||
HabboBadge b = BadgesComponent.createBadge(badge, habbo);
|
||||
|
||||
habbo.getClient().sendResponse(new AddUserBadgeComposer(b));
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roombadge.no_badge"), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.eu.habbo.habbohotel.commands;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboInfo;
|
||||
import com.eu.habbo.habbohotel.users.HabboManager;
|
||||
import com.eu.habbo.habbohotel.users.subscriptions.Subscription;
|
||||
|
||||
/**
|
||||
* @author Beny
|
||||
*/
|
||||
public class SubscriptionCommand extends Command {
|
||||
public SubscriptionCommand() {
|
||||
super("cmd_subscription", Emulator.getTexts().getValue("commands.keys.cmd_subscription").split(";"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to give/extend/remove subscription on a given user.
|
||||
*
|
||||
* Parameters:
|
||||
* [username] = Username of user to execute command on
|
||||
* [type] = Subscription type (e.g. HABBO_CLUB)
|
||||
* [add|remove] = Use add or remove to increase/decrease sub duration
|
||||
* [time] = Time string e.g. "1 week", "18 days", "4 minutes". Can be complex e.g. "1 month 5 days 2 minutes"
|
||||
*
|
||||
* Examples:
|
||||
* :sub Beny habbo_club add 1 month - adds 1 month of HABBO_CLUB subscription duration on the user Beny
|
||||
* :sub Beny builders_club add 1 month - adds 1 month of BUILDERS_CLUB subscription duration on the user Beny
|
||||
* :sub Beny habbo_club remove 3 days - removes 3 days of HABBO_CLUB subscription duration on the user Beny
|
||||
* :sub Beny habbo_club remove - removes all remaining time from the HABBO_CLUB subscription (expires it) on the user Beny
|
||||
*
|
||||
* @param gameClient Client that executed the command
|
||||
* @param params Command parameters
|
||||
* @return Boolean indicating success
|
||||
* @throws Exception Exception
|
||||
*/
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||
if (params.length >= 4) {
|
||||
HabboInfo info = HabboManager.getOfflineHabboInfo(params[1]);
|
||||
|
||||
if (info != null) {
|
||||
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]);
|
||||
|
||||
String subscription = params[2].toUpperCase();
|
||||
String action = params[3];
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
if (params.length > 4) {
|
||||
for (int i = 4; i < params.length; i++) {
|
||||
message.append(params[i]).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
if(!Emulator.getGameEnvironment().getSubscriptionManager().types.containsKey(subscription)) {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.type_not_found", "%subscription% is not a valid subscription type").replace("%subscription%", subscription), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(action.equalsIgnoreCase("add") || action.equalsIgnoreCase("+") || action.equalsIgnoreCase("a")) {
|
||||
int timeToAdd = Emulator.timeStringToSeconds(message.toString());
|
||||
|
||||
if(timeToAdd < 1) {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.invalid_params_time", "Invalid time span, try: x minutes/days/weeks/months"), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
|
||||
habbo.getHabboStats().createSubscription(subscription, timeToAdd);
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.success_add_time", "Successfully added %time% seconds to %subscription% on %user%").replace("%time%", timeToAdd + "").replace("%user%", params[1]).replace("%subscription%", subscription), RoomChatMessageBubbles.ALERT);
|
||||
}
|
||||
else if(action.equalsIgnoreCase("remove") || action.equalsIgnoreCase("-") || action.equalsIgnoreCase("r")) {
|
||||
Subscription s = habbo.getHabboStats().getSubscription(subscription);
|
||||
|
||||
if (s == null) {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.user_not_have", "%user% does not have the %subscription% subscription").replace("%user%", params[1]).replace("%subscription%", subscription), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(message.length() != 0) {
|
||||
int timeToRemove = Emulator.timeStringToSeconds(message.toString());
|
||||
|
||||
if (timeToRemove < 1) {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.invalid_params_time", "Invalid time span, try: x minutes/days/weeks/months"), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
|
||||
s.addDuration(-timeToRemove);
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.success_remove_time", "Successfully removed %time% seconds from %subscription% on %user%").replace("%time%", timeToRemove + "").replace("%user%", params[1]).replace("%subscription%", subscription), RoomChatMessageBubbles.ALERT);
|
||||
}
|
||||
else {
|
||||
s.addDuration(-s.getRemaining());
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.success_remove_sub", "Successfully removed %subscription% sub from %user%").replace("%user%", params[1]).replace("%subscription%", subscription), RoomChatMessageBubbles.ALERT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.invalid_action", "Invalid action specified. Must be add, +, remove or -"), RoomChatMessageBubbles.ALERT);
|
||||
}
|
||||
|
||||
} else {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.user_not_found", "%user% was not found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
||||
}
|
||||
} else {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_subscription.invalid_params", "Invalid command format"), RoomChatMessageBubbles.ALERT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ public class UpdateNavigatorCommand extends Command {
|
||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||
Emulator.getGameEnvironment().getNavigatorManager().loadNavigator();
|
||||
Emulator.getGameEnvironment().getRoomManager().loadRoomModels();
|
||||
Emulator.getGameEnvironment().getRoomManager().loadPublicRooms();
|
||||
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_navigator"), RoomChatMessageBubbles.ALERT);
|
||||
|
||||
return true;
|
||||
|
@ -45,7 +45,7 @@ public class UserInfoCommand extends Command {
|
||||
Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" +
|
||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_MAIL, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") +
|
||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
|
||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getClient().getChannel().remoteAddress().toString() + "\r") +
|
||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getHabboInfo().getIpLogin() + "\r") +
|
||||
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : ""));
|
||||
|
||||
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId());
|
||||
|
@ -2,6 +2,9 @@ package com.eu.habbo.habbohotel.commands;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class WordQuizCommand extends Command {
|
||||
public WordQuizCommand() {
|
||||
@ -11,21 +14,21 @@ public class WordQuizCommand extends Command {
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||
if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasActiveWordQuiz()) {
|
||||
if(params.length == 1) {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.description.cmd_word_quiz"), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
StringBuilder question = new StringBuilder();
|
||||
int duration = 60;
|
||||
|
||||
if (params.length > 2) {
|
||||
for (int i = 1; i < params.length - 1; i++) {
|
||||
question.append(" ").append(params[i]);
|
||||
}
|
||||
|
||||
try {
|
||||
duration = Integer.valueOf(params[params.length - 1]);
|
||||
} catch (Exception e) {
|
||||
question.append(" ").append(params[params.length - 1]);
|
||||
duration = Integer.parseInt(params[params.length-1]);
|
||||
params = Arrays.copyOf(params, params.length-1);
|
||||
}
|
||||
} else {
|
||||
question = new StringBuilder(params[1]);
|
||||
catch (Exception e) {}
|
||||
|
||||
for (int i = 1; i < params.length; i++) {
|
||||
question.append(" ").append(params[i]);
|
||||
}
|
||||
|
||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().startWordQuiz(question.toString(), duration * 1000);
|
||||
|
@ -95,8 +95,10 @@ public abstract class Game implements Runnable {
|
||||
if (team != null && team.isMember(habbo)) {
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
team.removeMember(habbo.getHabboInfo().getGamePlayer());
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
habbo.getHabboInfo().getGamePlayer().reset();
|
||||
}
|
||||
}
|
||||
|
||||
habbo.getHabboInfo().setCurrentGame(null);
|
||||
habbo.getHabboInfo().setGamePlayer(null);
|
||||
@ -238,7 +240,10 @@ public abstract class Game implements Runnable {
|
||||
if (this.room == null)
|
||||
return;
|
||||
|
||||
for (Map.Entry<GameTeamColors, GameTeam> teamEntry : this.teams.entrySet()) {
|
||||
THashMap<GameTeamColors, GameTeam> teamsCopy = new THashMap<>();
|
||||
teamsCopy.putAll(this.teams);
|
||||
|
||||
for (Map.Entry<GameTeamColors, GameTeam> teamEntry : teamsCopy.entrySet()) {
|
||||
Emulator.getThreading().run(new SaveScoreForTeam(teamEntry.getValue(), this));
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ public class GamePlayer {
|
||||
|
||||
|
||||
private int score;
|
||||
private int wiredScore;
|
||||
|
||||
|
||||
public GamePlayer(Habbo habbo, GameTeamColors teamColor) {
|
||||
@ -23,15 +24,23 @@ public class GamePlayer {
|
||||
|
||||
public void reset() {
|
||||
this.score = 0;
|
||||
this.wiredScore = 0;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addScore(int amount) {
|
||||
addScore(amount, false);
|
||||
}
|
||||
|
||||
public synchronized void addScore(int amount, boolean isWired) {
|
||||
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;
|
||||
|
||||
if(isWired && this.score > 0) {
|
||||
this.wiredScore += amount;
|
||||
}
|
||||
|
||||
WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
|
||||
}
|
||||
}
|
||||
@ -49,4 +58,8 @@ public class GamePlayer {
|
||||
public int getScore() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
public int getScoreAchievementValue() {
|
||||
return this.score - this.wiredScore;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public class BattleBanzaiGame extends Game {
|
||||
private final THashMap<Integer, HabboItem> gameTiles;
|
||||
private int tileCount;
|
||||
private int countDown;
|
||||
private int countDown2;
|
||||
|
||||
public BattleBanzaiGame(Room room) {
|
||||
super(BattleBanzaiGameTeam.class, BattleBanzaiGamePlayer.class, room, true);
|
||||
@ -59,7 +60,11 @@ public class BattleBanzaiGame extends Game {
|
||||
if (!this.state.equals(GameState.IDLE))
|
||||
return;
|
||||
|
||||
/* The first countdown is activated for the first two seconds emitting only the blue light (second interaction),
|
||||
the second, after another two seconds, completely activates the sphere (third interaction).
|
||||
*/
|
||||
this.countDown = 3;
|
||||
this.countDown2 = 2;
|
||||
|
||||
this.resetMap();
|
||||
|
||||
@ -105,10 +110,17 @@ public class BattleBanzaiGame extends Game {
|
||||
|
||||
if (this.countDown == 0) {
|
||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
|
||||
item.setExtradata("1");
|
||||
this.room.updateItemState(item);
|
||||
if(this.countDown2 > 0) {
|
||||
this.countDown2--;
|
||||
if(this.countDown2 == 0) {
|
||||
item.setExtradata("2");
|
||||
this.room.updateItemState(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.countDown > 1) {
|
||||
Emulator.getThreading().run(this, 500);
|
||||
@ -166,7 +178,7 @@ public class BattleBanzaiGame extends Game {
|
||||
for (GameTeam team : this.teams.values()) {
|
||||
if (!singleTeamGame) {
|
||||
for (GamePlayer player : team.getMembers()) {
|
||||
if (player.getScore() > 0) {
|
||||
if (player.getScoreAchievementValue() > 0) {
|
||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer"));
|
||||
}
|
||||
}
|
||||
@ -180,7 +192,7 @@ public class BattleBanzaiGame extends Game {
|
||||
if (winningTeam != null) {
|
||||
if (!singleTeamGame) {
|
||||
for (GamePlayer player : winningTeam.getMembers()) {
|
||||
if (player.getScore() > 0) {
|
||||
if (player.getScoreAchievementValue() > 0) {
|
||||
this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
|
||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner"));
|
||||
}
|
||||
|
@ -287,9 +287,9 @@ public class FreezeGame extends Game {
|
||||
players.addAll(team.getMembers());
|
||||
|
||||
for (GamePlayer p : players) {
|
||||
if (p.getScore() > 0) {
|
||||
if (p.getScoreAchievementValue() > 0) {
|
||||
if (team.equals(winningTeam)) {
|
||||
AchievementManager.progressAchievement(p.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FreezeWinner"), p.getScore());
|
||||
AchievementManager.progressAchievement(p.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FreezeWinner"), p.getScoreAchievementValue());
|
||||
this.room.sendComposer(new RoomUserActionComposer(p.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,14 @@ package com.eu.habbo.habbohotel.items;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionMultiHeight;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ISerialize;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class Item {
|
||||
public class Item implements ISerialize {
|
||||
|
||||
private int id;
|
||||
private int spriteId;
|
||||
@ -36,6 +38,7 @@ public class Item {
|
||||
private String clothingOnWalk;
|
||||
|
||||
private ItemInteraction interactionType;
|
||||
private int rotations;
|
||||
|
||||
public Item(ResultSet set) throws SQLException {
|
||||
this.load(set);
|
||||
@ -117,6 +120,13 @@ public class Item {
|
||||
this.multiHeights = new double[0];
|
||||
}
|
||||
}
|
||||
|
||||
this.rotations = 4;
|
||||
|
||||
try {
|
||||
this.rotations = set.getInt("rotations");
|
||||
}
|
||||
catch (SQLException ignored) { }
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@ -220,4 +230,34 @@ public class Item {
|
||||
}
|
||||
|
||||
public String getClothingOnWalk() { return clothingOnWalk; }
|
||||
|
||||
public int getRotations() {
|
||||
return rotations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ServerMessage message) {
|
||||
message.appendString(this.type.code.toLowerCase());
|
||||
|
||||
if (type == FurnitureType.BADGE) {
|
||||
message.appendString(this.customParams);
|
||||
} else {
|
||||
message.appendInt(this.spriteId);
|
||||
|
||||
if (this.getName().contains("wallpaper_single") || this.getName().contains("floor_single") || this.getName().contains("landscape_single")) {
|
||||
message.appendString(this.name.split("_")[2]);
|
||||
} else if (type == FurnitureType.ROBOT) {
|
||||
message.appendString(this.customParams);
|
||||
} else if (name.equalsIgnoreCase("poster")) {
|
||||
message.appendString(this.customParams);
|
||||
} else if (name.startsWith("SONG ")) {
|
||||
message.appendString(this.customParams);
|
||||
} else {
|
||||
message.appendString("");
|
||||
}
|
||||
|
||||
message.appendInt(1); // productCount
|
||||
message.appendBoolean(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,6 +141,7 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("puzzle_box", InteractionPuzzleBox.class));
|
||||
this.interactionsList.add(new ItemInteraction("hopper", InteractionHopper.class));
|
||||
this.interactionsList.add(new ItemInteraction("costume_hopper", InteractionCostumeHopper.class));
|
||||
this.interactionsList.add(new ItemInteraction("effect_gate", InteractionEffectGate.class));
|
||||
this.interactionsList.add(new ItemInteraction("club_hopper", InteractionHabboClubHopper.class));
|
||||
this.interactionsList.add(new ItemInteraction("club_gate", InteractionHabboClubGate.class));
|
||||
this.interactionsList.add(new ItemInteraction("club_teleporttile", InteractionHabboClubTeleportTile.class));
|
||||
@ -685,13 +686,14 @@ public class ItemManager {
|
||||
}
|
||||
|
||||
public HabboItem createGift(String username, Item item, String extraData, int limitedStack, int limitedSells) {
|
||||
HabboItem gift = null;
|
||||
int userId = 0;
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username);
|
||||
|
||||
int userId = 0;
|
||||
|
||||
if (habbo != null) {
|
||||
userId = habbo.getHabboInfo().getId();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT id FROM users WHERE username = ?")) {
|
||||
statement.setString(1, username);
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
@ -704,6 +706,14 @@ public class ItemManager {
|
||||
}
|
||||
}
|
||||
|
||||
if(userId > 0) {
|
||||
return createGift(userId, item, extraData, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public HabboItem createGift(int userId, Item item, String extraData, int limitedStack, int limitedSells) {
|
||||
if (userId == 0)
|
||||
return null;
|
||||
|
||||
@ -712,26 +722,12 @@ public class ItemManager {
|
||||
extraData = extraData.substring(0, 1000);
|
||||
}
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data, limited_data) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
statement.setInt(1, userId);
|
||||
statement.setInt(2, item.getId());
|
||||
statement.setString(3, extraData);
|
||||
statement.setString(4, limitedStack + ":" + limitedSells);
|
||||
statement.execute();
|
||||
|
||||
try (ResultSet set = statement.getGeneratedKeys()) {
|
||||
if (set.next()) {
|
||||
gift = new InteractionGift(set.getInt(1), userId, item, extraData, limitedStack, limitedSells);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("Caught SQL exception", e);
|
||||
}
|
||||
HabboItem gift = this.createItem(userId, item, limitedStack, limitedSells, extraData);
|
||||
|
||||
if (gift != null) {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
if (habbo != null) {
|
||||
habbo.getInventory().getItemsComponent().addItem(gift);
|
||||
|
||||
habbo.getClient().sendResponse(new AddHabboItemComposer(gift));
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class InteractionBackgroundToner extends HabboItem {
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
return false;
|
||||
return this.getBaseItem().allowWalk();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
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.habbohotel.users.subscriptions.SubscriptionHabboClub;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.users.UserClubComposer;
|
||||
import com.eu.habbo.messages.outgoing.users.UserPermissionsComposer;
|
||||
@ -120,16 +121,10 @@ public class InteractionCrackable extends HabboItem {
|
||||
// subscriptions are given immediately upon cracking
|
||||
switch (rewardData.subscriptionType) {
|
||||
case HABBO_CLUB:
|
||||
if (habbo.getHabboStats().getClubExpireTimestamp() <= Emulator.getIntUnixTimestamp())
|
||||
habbo.getHabboStats().setClubExpireTimestamp(Emulator.getIntUnixTimestamp());
|
||||
|
||||
habbo.getHabboStats().setClubExpireTimestamp(habbo.getHabboStats().getClubExpireTimestamp() + (rewardData.subscriptionDuration * 86400));
|
||||
habbo.getClient().sendResponse(new UserPermissionsComposer(habbo));
|
||||
habbo.getClient().sendResponse(new UserClubComposer(habbo));
|
||||
habbo.getHabboStats().run();
|
||||
habbo.getHabboStats().createSubscription(SubscriptionHabboClub.HABBO_CLUB, rewardData.subscriptionDuration * 86400);
|
||||
break;
|
||||
case BUILDERS_CLUB:
|
||||
habbo.alert("Builders club has not been implemented yet. Sorry!");
|
||||
habbo.getHabboStats().createSubscription("BUILDERS_CLUB", rewardData.subscriptionDuration * 86400);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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;
|
||||
@ -78,4 +79,8 @@ public abstract class InteractionCustomValues extends HabboItem {
|
||||
|
||||
super.serializeExtradata(serverMessage);
|
||||
}
|
||||
|
||||
public void onCustomValuesSaved(Room room, GameClient client) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -48,18 +48,20 @@ public class InteractionDefault extends HabboItem {
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
|
||||
if(room.getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) {
|
||||
for (RoomUnit unit : room.getRoomUnits()) {
|
||||
if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem()))
|
||||
continue; // If the unit was previously on the furni...
|
||||
if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // but is not anymore...
|
||||
|
||||
try {
|
||||
this.onWalkOff(unit, room, new Object[]{}); // the unit walked off!
|
||||
this.onWalkOff(unit, room, new Object[]{oldLocation, newLocation}); // the unit walked off!
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
@ -137,14 +139,22 @@ public class InteractionDefault extends HabboItem {
|
||||
|
||||
if (roomUnit != null) {
|
||||
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
|
||||
int nextEffectM = 0;
|
||||
int nextEffectF = 0;
|
||||
|
||||
if (objects != null && objects.length == 2) {
|
||||
if (objects[0] instanceof RoomTile && objects[1] instanceof RoomTile) {
|
||||
RoomTile goalTile = (RoomTile) objects[1];
|
||||
HabboItem topItem = room.getTopItemAt(goalTile.x, goalTile.y);
|
||||
RoomTile goalTile = (RoomTile) objects[0];
|
||||
HabboItem topItem = room.getTopItemAt(goalTile.x, goalTile.y, (objects[0] != objects[1]) ? this : null);
|
||||
|
||||
if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(topItem != null) {
|
||||
nextEffectM = topItem.getBaseItem().getEffectM();
|
||||
nextEffectF = topItem.getBaseItem().getEffectF();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,12 +164,12 @@ public class InteractionDefault extends HabboItem {
|
||||
if (habbo != null) {
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
room.giveEffect(habbo, nextEffectM, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
room.giveEffect(habbo, nextEffectF, -1);
|
||||
}
|
||||
}
|
||||
} else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) {
|
||||
@ -167,12 +177,12 @@ public class InteractionDefault extends HabboItem {
|
||||
|
||||
if (bot != null) {
|
||||
if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
||||
room.giveEffect(roomUnit, 0, -1);
|
||||
room.giveEffect(roomUnit, nextEffectM, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
|
||||
room.giveEffect(roomUnit, 0, -1);
|
||||
room.giveEffect(roomUnit, nextEffectF, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,85 @@
|
||||
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.interactions.interfaces.ConditionalGate;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.threading.runnables.CloseGate;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class InteractionEffectGate extends InteractionDefault implements ConditionalGate {
|
||||
|
||||
// List of Habboween costumes according to http://www.habboxwiki.com/Costumes
|
||||
private static final List<Integer> defaultAllowedEnables = new ArrayList<>(Arrays.asList(
|
||||
114, // Strong Arms
|
||||
115, // Ringmaster Costume
|
||||
116, // Fly Head
|
||||
117, // Executioner Hood
|
||||
118, // Evil Clown Paint
|
||||
135 // Marionette
|
||||
));
|
||||
|
||||
public InteractionEffectGate(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
public InteractionEffectGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
if (roomUnit == null || room == null)
|
||||
return false;
|
||||
|
||||
String customparams = this.getBaseItem().getCustomParams().trim();
|
||||
|
||||
if (!customparams.isEmpty()) {
|
||||
return Arrays.asList(customparams.split(";"))
|
||||
.contains(Integer.valueOf(roomUnit.getEffectId()).toString());
|
||||
}
|
||||
|
||||
return defaultAllowedEnables.contains(roomUnit.getEffectId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
|
||||
if (this.canWalkOn(roomUnit, room, objects)) {
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOff(roomUnit, room, objects);
|
||||
|
||||
Emulator.getThreading().run(new CloseGate(this, room), 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
@ -7,6 +8,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitType;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -32,7 +35,11 @@ public class InteractionEffectTile extends InteractionPressurePlate {
|
||||
|
||||
@Override
|
||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOff(roomUnit, room, objects);
|
||||
Emulator.getThreading().run(() -> updateState(room), 100);
|
||||
|
||||
if(objects != null && objects.length > 0) {
|
||||
WiredHandler.handle(WiredTriggerType.WALKS_OFF_FURNI, roomUnit, room, new Object[]{this});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,14 +5,28 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||
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.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InteractionFireworks extends InteractionDefault {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionFireworks.class);
|
||||
|
||||
private static final String STATE_EMPTY = "0"; // Not used since the removal of pixels
|
||||
private static final String STATE_CHARGED = "1";
|
||||
private static final String STATE_EXPLOSION = "2";
|
||||
|
||||
public class InteractionFireworks extends HabboItem {
|
||||
public InteractionFireworks(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
@ -26,35 +40,103 @@ public class InteractionFireworks extends HabboItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
return this.getBaseItem().allowWalk();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeExtradata(ServerMessage serverMessage) {
|
||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
||||
serverMessage.appendString(this.getExtradata());
|
||||
super.serializeExtradata(serverMessage); //Design flaw ;(
|
||||
}
|
||||
|
||||
/**
|
||||
* Checked in Habbo on 2021-01-03
|
||||
* - Fireworks should be charged to be able to detonate them
|
||||
* - Habbos with Rights can detonate fireworks from anywhere in a room
|
||||
* - Habbos without rights have to walk to an adjecent tile to be able to detonate (see Interaction Switch)
|
||||
* - Wired can always detonate fireworks
|
||||
*/
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if (room == null)
|
||||
return;
|
||||
|
||||
// Wireds can always detonate fireworks if charged
|
||||
if (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE) {
|
||||
if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (client != null && this.getExtradata().equalsIgnoreCase("2")) //2 explodes I think (0 = empty, 1 = charged, 2 = effect)
|
||||
if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) {
|
||||
this.reCharge(room);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (client == null)
|
||||
return;
|
||||
|
||||
// Habbos without rights have to walk to an adjecent tile to be able to detonate the fireworks
|
||||
if (!this.canToggle(client.getHabbo(), room)) {
|
||||
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 = tile;
|
||||
}
|
||||
}
|
||||
|
||||
if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
||||
List<Runnable> 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<>()));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION))
|
||||
{
|
||||
this.reCharge(room);
|
||||
AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowWiredResetState() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(Room room) {
|
||||
super.onPlace(room);
|
||||
this.setExtradata(STATE_CHARGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canToggle(Habbo habbo, Room room) {
|
||||
return room.hasRights(habbo) || RoomLayout.tilesAdjecent(
|
||||
room.getLayout().getTile(this.getX(), this.getY()),
|
||||
habbo.getRoomUnit().getCurrentLocation()
|
||||
);
|
||||
}
|
||||
|
||||
private void reCharge(Room room) {
|
||||
// Default = 5000, Nuclear Firework should have 10000 in its custom params according to Habbo
|
||||
int explodeDuration = 5000;
|
||||
if (!this.getBaseItem().getCustomParams().isEmpty()) {
|
||||
try {
|
||||
explodeDuration = Integer.parseInt(this.getBaseItem().getCustomParams());
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.error("Incorrect customparams (" + this.getBaseItem().getCustomParams() + ") for base item ID (" + this.getBaseItem().getId() + ") of type (" + this.getBaseItem().getName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
this.setExtradata(STATE_CHARGED);
|
||||
this.needsUpdate(true);
|
||||
room.updateItemState(this);
|
||||
}, explodeDuration);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ 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.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
@ -38,17 +39,21 @@ public class InteractionGate extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
boolean isWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
|
||||
if (client != null && !room.hasRights(client.getHabbo()) && !isWired)
|
||||
boolean executedByWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
|
||||
|
||||
if (client != null && !room.hasRights(client.getHabbo()) && !executedByWired)
|
||||
return;
|
||||
|
||||
if (!isWired && !room.getHabbosAt(this.getX(), this.getY()).isEmpty())
|
||||
// If a Habbo is standing on a tile occupied by the gate, the gate shouldn't open/close
|
||||
for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()))
|
||||
if (room.hasHabbosAt(tile.x, tile.y))
|
||||
return;
|
||||
|
||||
// Gate closed = 0, open = 1
|
||||
if (this.getExtradata().length() == 0)
|
||||
this.setExtradata("0");
|
||||
|
||||
this.setExtradata((Integer.valueOf(this.getExtradata()) + 1) % 2 + "");
|
||||
this.setExtradata((Integer.parseInt(this.getExtradata()) + 1) % 2 + "");
|
||||
room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
|
||||
this.needsUpdate(true);
|
||||
room.updateItemState(this);
|
||||
|
@ -6,12 +6,18 @@ 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.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionGuildFurni extends InteractionDefault {
|
||||
private int guildId;
|
||||
private static final THashSet<String> ROTATION_8_ITEMS = new THashSet<String>() {
|
||||
{
|
||||
this.add("gld_wall_tall");
|
||||
}
|
||||
};
|
||||
|
||||
public InteractionGuildFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@ -23,6 +29,14 @@ public class InteractionGuildFurni extends InteractionDefault {
|
||||
this.guildId = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumRotations() {
|
||||
if(ROTATION_8_ITEMS.stream().anyMatch(x -> x.equalsIgnoreCase(this.getBaseItem().getName()))) {
|
||||
return 8;
|
||||
}
|
||||
return this.getBaseItem().getRotations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeExtradata(ServerMessage serverMessage) {
|
||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId);
|
||||
|
@ -3,6 +3,7 @@ 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.interactions.interfaces.ConditionalGate;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
@ -13,7 +14,7 @@ import com.eu.habbo.threading.runnables.CloseGate;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionGuildGate extends InteractionGuildFurni {
|
||||
public class InteractionGuildGate extends InteractionGuildFurni implements ConditionalGate {
|
||||
public InteractionGuildGate(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
@ -61,4 +62,9 @@ public class InteractionGuildGate extends InteractionGuildFurni {
|
||||
this.setExtradata("0");
|
||||
room.updateItemState(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ 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.interactions.interfaces.ConditionalGate;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
@ -12,7 +13,7 @@ import com.eu.habbo.threading.runnables.CloseGate;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionHabboClubGate extends InteractionDefault {
|
||||
public class InteractionHabboClubGate extends InteractionDefault implements ConditionalGate {
|
||||
public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
@ -42,14 +43,6 @@ public class InteractionHabboClubGate extends InteractionDefault {
|
||||
if (this.canWalkOn(roomUnit, room, objects)) {
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
} else {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getClient().sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC));
|
||||
}
|
||||
|
||||
roomUnit.setGoalLocation(roomUnit.getCurrentLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,4 +63,14 @@ public class InteractionHabboClubGate extends InteractionDefault {
|
||||
|
||||
Emulator.getThreading().run(new CloseGate(this, room), 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
if (roomUnit == null || room == null)
|
||||
return;
|
||||
|
||||
room.getHabbo(roomUnit).getClient().sendResponse(
|
||||
new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
||||
import com.eu.habbo.messages.outgoing.users.UserDataComposer;
|
||||
@ -22,6 +23,11 @@ public class InteractionMannequin extends HabboItem {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumRotations() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeExtradata(ServerMessage serverMessage) {
|
||||
serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0));
|
||||
@ -60,26 +66,39 @@ public class InteractionMannequin extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
String[] lookCode = this.getExtradata().split(":")[1].split("\\.");
|
||||
String[] data = this.getExtradata().split(":");
|
||||
|
||||
StringBuilder look = new StringBuilder();
|
||||
for (String part : client.getHabbo().getHabboInfo().getLook().split("\\.")) {
|
||||
String type = part.split("-")[0];
|
||||
if(data.length < 2)
|
||||
return;
|
||||
|
||||
boolean found = false;
|
||||
for (String s : lookCode) {
|
||||
if (s.contains(type)) {
|
||||
found = true;
|
||||
look.append(s).append(".");
|
||||
}
|
||||
String gender = data[0];
|
||||
String figure = data[1];
|
||||
|
||||
if (gender.isEmpty() || figure.isEmpty() || (!gender.equalsIgnoreCase("m") && !gender.equalsIgnoreCase("f")) || !client.getHabbo().getHabboInfo().getGender().name().equalsIgnoreCase(gender))
|
||||
return;
|
||||
|
||||
String newFigure = "";
|
||||
|
||||
for (String playerFigurePart : client.getHabbo().getHabboInfo().getLook().split("\\.")) {
|
||||
if (!playerFigurePart.startsWith("ch") && !playerFigurePart.startsWith("lg"))
|
||||
newFigure += playerFigurePart + ".";
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
look.append(part).append(".");
|
||||
}
|
||||
String newFigureParts = figure;
|
||||
|
||||
for (String newFigurePart : newFigureParts.split("\\.")) {
|
||||
if (newFigurePart.startsWith("hd"))
|
||||
newFigureParts = newFigureParts.replace(newFigurePart, "");
|
||||
}
|
||||
|
||||
client.getHabbo().getHabboInfo().setLook(look.substring(0, look.length() - 1));
|
||||
if (newFigureParts.equals("")) return;
|
||||
|
||||
String newLook = newFigure + newFigureParts;
|
||||
|
||||
if (newLook.length() > 512)
|
||||
return;
|
||||
|
||||
client.getHabbo().getHabboInfo().setLook(ClothingValidationManager.VALIDATE_ON_MANNEQUIN ? ClothingValidationManager.validateLook(client.getHabbo(), newLook, client.getHabbo().getHabboInfo().getGender().name()) : newLook);
|
||||
room.sendComposer(new RoomUserDataComposer(client.getHabbo()).compose());
|
||||
client.sendResponse(new UserDataComposer(client.getHabbo()));
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import gnu.trove.set.hash.THashSet;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@ -68,39 +69,39 @@ public class InteractionMultiHeight extends HabboItem {
|
||||
this.setExtradata("0");
|
||||
|
||||
if (this.getBaseItem().getMultiHeights().length > 0) {
|
||||
this.setExtradata("" + (Integer.valueOf(this.getExtradata()) + 1) % (this.getBaseItem().getMultiHeights().length));
|
||||
this.setExtradata("" + (Integer.parseInt(this.getExtradata()) + 1) % (this.getBaseItem().getMultiHeights().length));
|
||||
this.needsUpdate(true);
|
||||
room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
|
||||
room.updateItemState(this);
|
||||
//room.sendComposer(new UpdateStackHeightComposer(this.getX(), this.getY(), this.getBaseItem().getMultiHeights()[Integer.valueOf(this.getExtradata())] * 256.0D).compose());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isWalkable()) {
|
||||
List<RoomUnit> 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()));
|
||||
public void updateUnitsOnItem(Room room) {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
|
||||
|
||||
for(RoomTile tile : occupiedTiles) {
|
||||
Collection<RoomUnit> unitsOnItem = room.getRoomUnitsAt(room.getLayout().getTile(tile.x, tile.y));
|
||||
|
||||
THashSet<RoomUnit> updatedUnits = new THashSet<>();
|
||||
for (RoomUnit unit : unitsOnItem) {
|
||||
if (unit.hasStatus(RoomUnitStatus.MOVE))
|
||||
if (unit.hasStatus(RoomUnitStatus.MOVE) && unit.getGoal() != tile)
|
||||
continue;
|
||||
|
||||
if (this.getBaseItem().getMultiHeights().length >= 0) {
|
||||
if (this.getBaseItem().allowSit()) {
|
||||
unit.setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + "");
|
||||
if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) {
|
||||
unit.sitUpdate = true;
|
||||
unit.statusUpdate(true);
|
||||
} else {
|
||||
unit.setZ(unit.getCurrentLocation().getStackHeight());
|
||||
unit.setPreviousLocationZ(unit.getZ());
|
||||
unit.statusUpdate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updatedUnits.add(unit);
|
||||
}
|
||||
|
||||
room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose());
|
||||
}
|
||||
}
|
||||
}
|
||||
//room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,8 +1,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.RoomTileState;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemExtraDataComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.RoomFloorItemsComposer;
|
||||
import gnu.trove.TCollections;
|
||||
import gnu.trove.map.TIntObjectMap;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.awt.*;
|
||||
import java.sql.ResultSet;
|
||||
@ -25,25 +38,122 @@ public class InteractionMuteArea extends InteractionCustomValues {
|
||||
{
|
||||
this.put("tilesBack", "0");
|
||||
}
|
||||
|
||||
{
|
||||
this.put("state", "0");
|
||||
}
|
||||
};
|
||||
|
||||
private THashSet<RoomTile> tiles;
|
||||
|
||||
public InteractionMuteArea(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem, defaultValues);
|
||||
tiles = new THashSet<>();
|
||||
}
|
||||
|
||||
public InteractionMuteArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues);
|
||||
tiles = new THashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if((objects.length >= 2 && objects[1] instanceof WiredEffectType) || (client != null && room.hasRights(client.getHabbo()))) {
|
||||
this.values.put("state", this.values.get("state").equals("0") ? "1" : "0");
|
||||
room.sendComposer(new ItemExtraDataComposer(this).compose());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(Room room) {
|
||||
super.onPlace(room);
|
||||
this.regenAffectedTiles(room);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
super.onPickUp(room);
|
||||
this.tiles.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
this.regenAffectedTiles(room);
|
||||
}
|
||||
|
||||
public boolean inSquare(RoomTile location) {
|
||||
try {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
if(!this.values.get("state").equals("1"))
|
||||
return false;
|
||||
|
||||
if(room != null && this.tiles.size() == 0) {
|
||||
regenAffectedTiles(room);
|
||||
}
|
||||
|
||||
return this.tiles.contains(location);
|
||||
|
||||
/*try {
|
||||
return new Rectangle(
|
||||
this.getX() - Integer.valueOf(this.values.get("tilesBack")),
|
||||
this.getX() - Integer.parseInt(this.values.get("tilesBack")),
|
||||
this.getY() + Integer.valueOf(this.values.get("tilesLeft")) - (Integer.valueOf(this.values.get("tilesLeft")) + Integer.valueOf(this.values.get("tilesRight"))),
|
||||
Integer.valueOf(this.values.get("tilesLeft")) + Integer.valueOf(this.values.get("tilesRight")) + 1,
|
||||
Integer.valueOf(this.values.get("tilesFront")) + Integer.valueOf(this.values.get("tilesBack")) + 1).contains(location.x, location.y);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
|
||||
private void regenAffectedTiles(Room room) {
|
||||
int minX = Math.max(0, this.getX() - Integer.parseInt(this.values.get("tilesBack")));
|
||||
int minY = Math.max(0, this.getY() - Integer.parseInt(this.values.get("tilesRight")));
|
||||
int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(this.values.get("tilesFront")));
|
||||
int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(this.values.get("tilesLeft")));
|
||||
|
||||
this.tiles.clear();
|
||||
|
||||
for(int x = minX; x <= maxX; x++) {
|
||||
for(int y = minY; y <= maxY; y++) {
|
||||
RoomTile tile = room.getLayout().getTile((short)x, (short)y);
|
||||
if(tile != null && tile.state != RoomTileState.INVALID)
|
||||
this.tiles.add(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCustomValuesSaved(Room room, GameClient client) {
|
||||
super.onCustomValuesSaved(room, client);
|
||||
|
||||
this.regenAffectedTiles(room);
|
||||
|
||||
// show the effect
|
||||
Item effectItem = Emulator.getGameEnvironment().getItemManager().getItem("mutearea_sign2");
|
||||
|
||||
if(effectItem != null) {
|
||||
TIntObjectMap<String> ownerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
|
||||
ownerNames.put(-1, "System");
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
int id = 0;
|
||||
for(RoomTile tile : this.tiles) {
|
||||
id--;
|
||||
HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0);
|
||||
item.setX(tile.x);
|
||||
item.setY(tile.y);
|
||||
item.setZ(tile.relativeHeight());
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
client.sendResponse(new RoomFloorItemsComposer(ownerNames, items));
|
||||
Emulator.getThreading().run(() -> {
|
||||
for(HabboItem item : items) {
|
||||
client.sendResponse(new RemoveFloorItemComposer(item, true));
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,34 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.ICycleable;
|
||||
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.pets.PetTasks;
|
||||
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.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.ServerMessage;
|
||||
import com.eu.habbo.threading.runnables.HabboItemNewState;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class InteractionObstacle extends HabboItem implements ICycleable {
|
||||
|
||||
private THashSet<RoomTile> middleTiles;
|
||||
|
||||
public class InteractionObstacle extends HabboItem {
|
||||
public InteractionObstacle(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
this.middleTiles = new THashSet<>();
|
||||
}
|
||||
|
||||
public InteractionObstacle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
this.setExtradata("0");
|
||||
this.middleTiles = new THashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -40,20 +41,12 @@ public class InteractionObstacle extends HabboItem {
|
||||
|
||||
@Override
|
||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
|
||||
if (pet instanceof HorsePet) {
|
||||
HorsePet horsePet = (HorsePet) pet;
|
||||
|
||||
return horsePet.getRider() != null;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,10 +56,7 @@ public class InteractionObstacle extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
/*Pet pet = room.getPet(roomUnit);
|
||||
|
||||
if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) {
|
||||
if (pet.getTask() != null && pet.getTask().equals(PetTasks.RIDE)) {
|
||||
@ -91,8 +81,7 @@ public class InteractionObstacle extends HabboItem {
|
||||
|
||||
room.updateItemState(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,4 +127,70 @@ public class InteractionObstacle extends HabboItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(Room room) {
|
||||
super.onPlace(room);
|
||||
this.calculateMiddleTiles(room);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
super.onPickUp(room);
|
||||
middleTiles.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
this.calculateMiddleTiles(room);
|
||||
}
|
||||
|
||||
private void calculateMiddleTiles(Room room) {
|
||||
middleTiles.clear();
|
||||
|
||||
if(this.getRotation() == 2) {
|
||||
middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), this.getY()));
|
||||
middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), (short)(this.getY() + 1)));
|
||||
}
|
||||
else if(this.getRotation() == 4) {
|
||||
middleTiles.add(room.getLayout().getTile(this.getX(), (short)(this.getY() + 1)));
|
||||
middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), (short)(this.getY() + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoomTileState getOverrideTileState(RoomTile tile, Room room) {
|
||||
if(this.middleTiles.contains(tile))
|
||||
return RoomTileState.BLOCKED;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cycle(Room room) {
|
||||
if(this.middleTiles.size() == 0) {
|
||||
this.calculateMiddleTiles(room);
|
||||
}
|
||||
|
||||
for(RoomTile tile : this.middleTiles) {
|
||||
for(RoomUnit unit : tile.getUnits()) {
|
||||
if(unit.getPath().size() == 0 && !unit.hasStatus(RoomUnitStatus.MOVE)) {
|
||||
if(unit.getBodyRotation().getValue() != this.getRotation() && Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue() != this.getRotation())
|
||||
continue;
|
||||
|
||||
RoomTile tileInfront = room.getLayout().getTileInFront(unit.getCurrentLocation(), unit.getBodyRotation().getValue());
|
||||
if(tileInfront.state != RoomTileState.INVALID && tileInfront.state != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileInfront).size() == 0) {
|
||||
unit.setGoalLocation(tileInfront);
|
||||
}
|
||||
else {
|
||||
RoomTile tileBehind = room.getLayout().getTileInFront(unit.getCurrentLocation(), Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue());
|
||||
if(tileBehind.state != RoomTileState.INVALID && tileBehind.state != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileBehind).size() == 0) {
|
||||
unit.setGoalLocation(tileBehind);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,14 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.rooms.users.RoomUserWalkEvent;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemIntStateComposer;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -17,6 +22,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InteractionOneWayGate extends HabboItem {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionOneWayGate.class);
|
||||
|
||||
private boolean walkable = false;
|
||||
|
||||
public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException {
|
||||
@ -74,7 +81,6 @@ public class InteractionOneWayGate extends HabboItem {
|
||||
if (unit == null)
|
||||
return;
|
||||
|
||||
|
||||
if (tileInfront.x == unit.getX() && tileInfront.y == unit.getY()) {
|
||||
if (!currentLocation.hasUnits()) {
|
||||
List<Runnable> onSuccess = new ArrayList<Runnable>();
|
||||
@ -86,6 +92,8 @@ public class InteractionOneWayGate extends HabboItem {
|
||||
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4);
|
||||
unit.setGoalLocation(tile);
|
||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail));
|
||||
|
||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500);
|
||||
});
|
||||
|
||||
onFail.add(() -> {
|
||||
|
@ -8,12 +8,13 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionPressurePlate extends HabboItem {
|
||||
public class InteractionPressurePlate extends InteractionDefault {
|
||||
public InteractionPressurePlate(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
@ -39,14 +40,6 @@ public class InteractionPressurePlate extends HabboItem {
|
||||
super.onClick(client, room, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeExtradata(ServerMessage serverMessage) {
|
||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
||||
serverMessage.appendString(this.getExtradata());
|
||||
|
||||
super.serializeExtradata(serverMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
|
||||
@ -99,7 +92,7 @@ public class InteractionPressurePlate extends HabboItem {
|
||||
}
|
||||
|
||||
this.setExtradata(occupied ? "1" : "0");
|
||||
room.updateItem(this);
|
||||
room.updateItemState(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +50,7 @@ public abstract class InteractionPushable extends InteractionDefault {
|
||||
if (this.currentThread != null)
|
||||
this.currentThread.dead = true;
|
||||
|
||||
this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity);
|
||||
this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity, false);
|
||||
Emulator.getThreading().run(this.currentThread, 0);
|
||||
}
|
||||
}
|
||||
@ -69,7 +69,7 @@ public abstract class InteractionPushable extends InteractionDefault {
|
||||
if (this.currentThread != null)
|
||||
this.currentThread.dead = true;
|
||||
|
||||
this.currentThread = new KickBallAction(this, room, client.getHabbo().getRoomUnit(), direction, velocity);
|
||||
this.currentThread = new KickBallAction(this, room, client.getHabbo().getRoomUnit(), direction, velocity, false);
|
||||
Emulator.getThreading().run(this.currentThread, 0);
|
||||
}
|
||||
}
|
||||
@ -80,6 +80,7 @@ public abstract class InteractionPushable extends InteractionDefault {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
|
||||
int velocity;
|
||||
boolean isDrag = false;
|
||||
RoomUserRotation direction;
|
||||
|
||||
if (this.getX() == roomUnit.getGoal().x && this.getY() == roomUnit.getGoal().y) //User clicked on the tile the ball is on, they want to kick it
|
||||
@ -92,13 +93,14 @@ public abstract class InteractionPushable extends InteractionDefault {
|
||||
velocity = this.getDragVelocity(roomUnit, room);
|
||||
direction = this.getDragDirection(roomUnit, room);
|
||||
this.onDrag(room, roomUnit, velocity, direction);
|
||||
isDrag = true;
|
||||
}
|
||||
|
||||
if (velocity > 0) {
|
||||
if (this.currentThread != null)
|
||||
this.currentThread.dead = true;
|
||||
|
||||
this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity);
|
||||
this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity, isDrag);
|
||||
Emulator.getThreading().run(this.currentThread, 0);
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class InteractionTeleport extends HabboItem {
|
||||
// set state 1 and walk on item
|
||||
this.roomUnitID = unit.getId();
|
||||
this.setExtradata("1");
|
||||
room.updateItem(this);
|
||||
room.updateItemState(this);
|
||||
unit.setGoalLocation(infrontTile);
|
||||
|
||||
List<Runnable> onSuccess = new ArrayList<Runnable>();
|
||||
@ -111,7 +111,7 @@ public class InteractionTeleport extends HabboItem {
|
||||
walkable = this.getBaseItem().allowWalk();
|
||||
room.updateTile(currentLocation);
|
||||
this.setExtradata("0");
|
||||
room.updateItem(this);
|
||||
room.updateItemState(this);
|
||||
this.roomUnitID = -1;
|
||||
unit.removeOverrideTile(currentLocation);
|
||||
unit.setCanLeaveRoomByDoor(true);
|
||||
|
@ -13,4 +13,9 @@ public class InteractionTrophy extends InteractionDefault {
|
||||
public InteractionTrophy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowWiredResetState() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ 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.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
@ -34,8 +36,12 @@ public class InteractionVendingMachine extends HabboItem {
|
||||
}
|
||||
|
||||
public THashSet<RoomTile> getActivatorTiles(Room room) {
|
||||
THashSet<RoomTile> tiles = new THashSet<RoomTile>();
|
||||
tiles.add(getSquareInFront(room.getLayout(), this));
|
||||
THashSet<RoomTile> tiles = new THashSet<>();
|
||||
RoomTile tileInFront = getSquareInFront(room.getLayout(), this);
|
||||
|
||||
if (tileInFront != null)
|
||||
tiles.add(tileInFront);
|
||||
|
||||
tiles.add(room.getLayout().getTile(this.getX(), this.getY()));
|
||||
return tiles;
|
||||
}
|
||||
@ -71,7 +77,13 @@ public class InteractionVendingMachine extends HabboItem {
|
||||
this.setExtradata("1");
|
||||
room.updateItem(this);
|
||||
|
||||
if(!unit.isWalking()) {
|
||||
try {
|
||||
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(!unit.isWalking() && !unit.hasStatus(RoomUnitStatus.SIT) && !unit.hasStatus(RoomUnitStatus.LAY)) {
|
||||
this.rotateToMachine(room, unit);
|
||||
}
|
||||
|
||||
@ -94,8 +106,6 @@ public class InteractionVendingMachine extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (client == null) {
|
||||
return;
|
||||
}
|
||||
@ -118,7 +128,7 @@ public class InteractionVendingMachine extends HabboItem {
|
||||
if(!inActivatorSpace) {
|
||||
RoomTile tileToWalkTo = null;
|
||||
for(RoomTile tile : activatorTiles) {
|
||||
if(room.getLayout().tileWalkable(tile.x, tile.y) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentLocation()) > tile.distance(unit.getCurrentLocation()))) {
|
||||
if((tile.state == RoomTileState.OPEN || tile.state == RoomTileState.SIT) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentLocation()) > tile.distance(unit.getCurrentLocation()))) {
|
||||
tileToWalkTo = tile;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
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;
|
||||
@ -13,7 +14,7 @@ import java.awt.*;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionWaterItem extends InteractionDefault {
|
||||
public class InteractionWaterItem extends InteractionMultiHeight {
|
||||
public InteractionWaterItem(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
@ -30,15 +31,22 @@ public class InteractionWaterItem extends InteractionDefault {
|
||||
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
super.onPickUp(room);
|
||||
this.setExtradata("0");
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
this.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, new Object[] { });
|
||||
}
|
||||
|
||||
public void update() {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
@ -75,7 +83,7 @@ public class InteractionWaterItem extends InteractionDefault {
|
||||
if (!this.getExtradata().equals(updatedData)) {
|
||||
this.setExtradata(updatedData);
|
||||
this.needsUpdate(true);
|
||||
room.updateItem(this);
|
||||
room.updateItemState(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,9 +91,4 @@ public class InteractionWaterItem extends InteractionDefault {
|
||||
public boolean allowWiredResetState() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canToggle(Habbo habbo, Room room) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public abstract class InteractionWired extends HabboItem {
|
||||
public abstract class InteractionWired extends InteractionDefault {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class);
|
||||
private long cooldown;
|
||||
|
||||
@ -37,25 +37,6 @@ public abstract class InteractionWired extends HabboItem {
|
||||
|
||||
public abstract void loadWiredData(ResultSet set, Room room) throws SQLException;
|
||||
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOff(roomUnit, room, objects);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void serializeExtradata(ServerMessage serverMessage) {
|
||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
||||
serverMessage.appendString(this.getExtradata());
|
||||
|
||||
super.serializeExtradata(serverMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate()) {
|
||||
|
@ -41,21 +41,6 @@ public abstract class InteractionWiredCondition extends InteractionWired {
|
||||
}
|
||||
}
|
||||
|
||||
@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 {
|
||||
|
||||
}
|
||||
|
||||
public abstract WiredConditionType getType();
|
||||
|
||||
public abstract boolean saveData(ClientMessage packet);
|
||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -42,22 +43,7 @@ public abstract class InteractionWiredEffect extends InteractionWired {
|
||||
}
|
||||
}
|
||||
|
||||
@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 {
|
||||
|
||||
}
|
||||
|
||||
public abstract boolean saveData(ClientMessage packet, GameClient gameClient);
|
||||
public abstract boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException;
|
||||
|
||||
public int getDelay() {
|
||||
return this.delay;
|
||||
|
@ -6,6 +6,9 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreClearType;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreRow;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreScoreType;
|
||||
@ -78,6 +81,9 @@ public class InteractionWiredHighscore extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
|
||||
return;
|
||||
|
||||
if (this.getExtradata() == null || this.getExtradata().isEmpty() || this.getExtradata().length() == 0) {
|
||||
this.setExtradata("0");
|
||||
}
|
||||
@ -89,6 +95,10 @@ public class InteractionWiredHighscore extends HabboItem {
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
}
|
||||
|
||||
if(client != null && !(objects.length >= 2 && objects[1] instanceof WiredEffectType)) {
|
||||
WiredHandler.handle(WiredTriggerType.STATE_CHANGED, client.getHabbo().getRoomUnit(), room, new Object[]{this});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,21 +42,6 @@ public abstract class InteractionWiredTrigger extends InteractionWired {
|
||||
}
|
||||
}
|
||||
|
||||
@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 {
|
||||
|
||||
}
|
||||
|
||||
public abstract WiredTriggerType getType();
|
||||
|
||||
public abstract boolean saveData(ClientMessage packet);
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.games.Game;
|
||||
import com.eu.habbo.habbohotel.games.GameState;
|
||||
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
@ -13,6 +14,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.threading.runnables.games.GameTimer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -62,7 +64,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
String[] data = set.getString("extra_data").split("\t");
|
||||
|
||||
if (data.length >= 2) {
|
||||
this.baseTime = Integer.valueOf(data[1]);
|
||||
this.baseTime = Integer.parseInt(data[1]);
|
||||
this.timeNow = this.baseTime;
|
||||
}
|
||||
|
||||
@ -98,11 +100,15 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
}
|
||||
|
||||
public void endGame(Room room) {
|
||||
endGame(room, false);
|
||||
}
|
||||
|
||||
public void endGame(Room room, boolean isStart) {
|
||||
this.isRunning = false;
|
||||
this.isPaused = false;
|
||||
|
||||
for (Game game : room.getGames()) {
|
||||
if (!game.getState().equals(GameState.IDLE)) {
|
||||
if (!game.getState().equals(GameState.IDLE) && !(isStart && game instanceof WiredGame)) {
|
||||
game.onEnd();
|
||||
game.stop();
|
||||
}
|
||||
@ -144,33 +150,6 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
if (this.needsUpdate() || this.needsDelete()) {
|
||||
super.run();
|
||||
}
|
||||
|
||||
if (this.getRoomId() == 0) {
|
||||
this.threadActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
if (room == null || !this.isRunning || this.isPaused) {
|
||||
this.threadActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.timeNow--;
|
||||
if (this.timeNow < 0) this.timeNow = 0;
|
||||
|
||||
if (this.timeNow > 0) {
|
||||
this.threadActive = true;
|
||||
Emulator.getThreading().run(this, 1000);
|
||||
} else {
|
||||
this.threadActive = false;
|
||||
this.timeNow = 0;
|
||||
this.endGame(room);
|
||||
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
|
||||
}
|
||||
|
||||
room.updateItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -226,7 +205,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
return;
|
||||
|
||||
boolean wasPaused = this.isPaused;
|
||||
this.endGame(room);
|
||||
this.endGame(room, true);
|
||||
|
||||
if(wasPaused) {
|
||||
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
|
||||
@ -243,7 +222,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
|
||||
if (!this.threadActive) {
|
||||
this.threadActive = true;
|
||||
Emulator.getThreading().run(this, 1000);
|
||||
Emulator.getThreading().run(new GameTimer(this), 1000);
|
||||
}
|
||||
} else if (client != null) {
|
||||
if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)))
|
||||
@ -266,7 +245,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
|
||||
if (!this.threadActive) {
|
||||
this.threadActive = true;
|
||||
Emulator.getThreading().run(this);
|
||||
Emulator.getThreading().run(new GameTimer(this));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -280,7 +259,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
|
||||
if (!this.threadActive) {
|
||||
this.threadActive = true;
|
||||
Emulator.getThreading().run(this, 1000);
|
||||
Emulator.getThreading().run(new GameTimer(this), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,10 +324,30 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return isRunning;
|
||||
return this.isRunning;
|
||||
}
|
||||
|
||||
public void setRunning(boolean running) {
|
||||
isRunning = running;
|
||||
this.isRunning = running;
|
||||
}
|
||||
|
||||
public void setThreadActive(boolean threadActive) {
|
||||
this.threadActive = threadActive;
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return this.isPaused;
|
||||
}
|
||||
|
||||
public void reduceTime() {
|
||||
this.timeNow--;
|
||||
}
|
||||
|
||||
public int getTimeNow() {
|
||||
return this.timeNow;
|
||||
}
|
||||
|
||||
public void setTimeNow(int timeNow) {
|
||||
this.timeNow = timeNow;
|
||||
}
|
||||
}
|
||||
|
@ -55,18 +55,18 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem {
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(this.getBaseItem(), this);
|
||||
|
||||
if(objects.length < 3) {
|
||||
HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(null, this);
|
||||
if (target == null) return;
|
||||
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
||||
target.setExtradata("1");
|
||||
room.updateItem(this);
|
||||
room.updateItem(target);
|
||||
roomUnit.setGoalLocation(room.getLayout().getTile(roomUnit.getX(), roomUnit.getY()));
|
||||
roomUnit.setGoalLocation(roomUnit.getCurrentLocation());
|
||||
roomUnit.setCanWalk(false);
|
||||
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 1000);
|
||||
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,15 +1,13 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.games.football;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||
import com.eu.habbo.habbohotel.games.football.FootballGame;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionPushable;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTeamItem;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.football.goals.InteractionFootballGoal;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer;
|
||||
import com.eu.habbo.util.pathfinding.Rotation;
|
||||
@ -31,15 +29,21 @@ public class InteractionFootball extends InteractionPushable {
|
||||
|
||||
@Override
|
||||
public int getWalkOnVelocity(RoomUnit roomUnit, Room room) {
|
||||
if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2)
|
||||
if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2 && this.getExtradata().equals("1"))
|
||||
return 0;
|
||||
|
||||
if (roomUnit.getPath().size() == 0 && roomUnit.tilesWalked() == 1)
|
||||
return 6;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWalkOffVelocity(RoomUnit roomUnit, Room room) {
|
||||
if (roomUnit.getPath().size() == 0 && roomUnit.tilesWalked() == 0)
|
||||
return 6;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,8 +83,17 @@ public class InteractionFootball extends InteractionPushable {
|
||||
|
||||
@Override
|
||||
public int getNextRollDelay(int currentStep, int totalSteps) {
|
||||
int t = 2500;
|
||||
return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100);
|
||||
|
||||
if(totalSteps > 4) {
|
||||
if(currentStep <= 4) {
|
||||
return 125;
|
||||
}
|
||||
}
|
||||
|
||||
return 500;
|
||||
|
||||
/*int t = 2500;
|
||||
return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100);*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -136,9 +149,9 @@ public class InteractionFootball extends InteractionPushable {
|
||||
|
||||
@Override
|
||||
public boolean validMove(Room room, RoomTile from, RoomTile to) {
|
||||
if (to == null) return false;
|
||||
if (to == null || to.state == RoomTileState.INVALID) return false;
|
||||
HabboItem topItem = room.getTopItemAt(to.x, to.y, this);
|
||||
return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
|
||||
return (topItem == null || topItem.getBaseItem().allowStack());
|
||||
}
|
||||
|
||||
//Events
|
||||
@ -176,8 +189,11 @@ public class InteractionFootball extends InteractionPushable {
|
||||
game.onScore(kicker, color);
|
||||
}
|
||||
|
||||
this.setExtradata(nextRoll <= 200 ? "8" : (nextRoll <= 250 ? "7" : (nextRoll <= 300 ? "6" : (nextRoll <= 350 ? "5" : (nextRoll <= 400 ? "4" : (nextRoll <= 450 ? "3" : (nextRoll <= 500 ? "2" : "1")))))));
|
||||
this.setExtradata(Math.abs(currentStep - (totalSteps + 1)) + "");
|
||||
room.sendComposer(new ItemStateComposer(this).compose());
|
||||
|
||||
/*this.setExtradata(nextRoll <= 200 ? "8" : (nextRoll <= 250 ? "7" : (nextRoll <= 300 ? "6" : (nextRoll <= 350 ? "5" : (nextRoll <= 400 ? "4" : (nextRoll <= 450 ? "3" : (nextRoll <= 500 ? "2" : "1")))))));
|
||||
room.sendComposer(new ItemStateComposer(this).compose());*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -194,7 +210,7 @@ public class InteractionFootball extends InteractionPushable {
|
||||
@Override
|
||||
public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
|
||||
HabboItem topItem = room.getTopItemAt(from.x, from.y, this);
|
||||
return !(room.hasHabbosAt(to.x, to.y) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1));
|
||||
return !((Emulator.getRandom().nextInt(10) >= 3 && room.hasHabbosAt(to.x, to.y)) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
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.habbohotel.users.clothingvalidation.ClothingValidationManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
||||
import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer;
|
||||
@ -120,7 +121,7 @@ public class InteractionFootballGate extends HabboItem {
|
||||
UserSavedLookEvent lookEvent = new UserSavedLookEvent(habbo, habbo.getHabboInfo().getGender(), oldlook);
|
||||
Emulator.getPluginManager().fireEvent(lookEvent);
|
||||
if (!lookEvent.isCancelled()) {
|
||||
habbo.getHabboInfo().setLook(lookEvent.newLook);
|
||||
habbo.getHabboInfo().setLook(ClothingValidationManager.VALIDATE_ON_FBALLGATE ? ClothingValidationManager.validateLook(habbo, lookEvent.newLook, lookEvent.gender.name()) : lookEvent.newLook);
|
||||
Emulator.getThreading().run(habbo.getHabboInfo());
|
||||
habbo.getClient().sendResponse(new UpdateUserLookComposer(habbo));
|
||||
room.sendComposer(new RoomUserDataComposer(habbo).compose());
|
||||
@ -134,7 +135,7 @@ public class InteractionFootballGate extends HabboItem {
|
||||
Emulator.getPluginManager().fireEvent(lookEvent);
|
||||
if (!lookEvent.isCancelled()) {
|
||||
habbo.getHabboStats().cache.put(CACHE_KEY, habbo.getHabboInfo().getLook());
|
||||
habbo.getHabboInfo().setLook(lookEvent.newLook);
|
||||
habbo.getHabboInfo().setLook(ClothingValidationManager.VALIDATE_ON_FBALLGATE ? ClothingValidationManager.validateLook(habbo, lookEvent.newLook, lookEvent.gender.name()) : lookEvent.newLook);
|
||||
Emulator.getThreading().run(habbo.getHabboInfo());
|
||||
habbo.getClient().sendResponse(new UpdateUserLookComposer(habbo));
|
||||
room.sendComposer(new RoomUserDataComposer(habbo).compose());
|
||||
|
@ -26,7 +26,7 @@ public class InteractionFootballGoal extends InteractionGameTeamItem {
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
return true;
|
||||
return this.getBaseItem().allowWalk();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.interfaces;
|
||||
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
|
||||
public interface ConditionalGate {
|
||||
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects);
|
||||
}
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -64,25 +65,46 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.startDate + "\t" + this.endDate;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.startDate,
|
||||
this.endDate
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split("\t");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.startDate = data.startDate;
|
||||
this.endDate = data.endDate;
|
||||
} else {
|
||||
String[] data = wiredData.split("\t");
|
||||
|
||||
if (data.length == 2) {
|
||||
try {
|
||||
this.startDate = Integer.valueOf(data[0]);
|
||||
this.endDate = Integer.valueOf(data[1]);
|
||||
this.startDate = Integer.parseInt(data[0]);
|
||||
this.endDate = Integer.parseInt(data[1]);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
this.startDate = 0;
|
||||
this.endDate = 0;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int startDate;
|
||||
int endDate;
|
||||
|
||||
public JsonData(int startDate, int endDate) {
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
@ -14,6 +15,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI;
|
||||
@ -35,56 +38,52 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
this.refresh();
|
||||
|
||||
boolean foundSomething = false;
|
||||
for (HabboItem item : this.items) {
|
||||
boolean found = false;
|
||||
|
||||
THashSet<HabboItem> stackedItems = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
|
||||
if (stackedItems == null)
|
||||
continue;
|
||||
|
||||
if (stackedItems.isEmpty() && this.all)
|
||||
return false;
|
||||
|
||||
for (HabboItem i : stackedItems) {
|
||||
if (i == item)
|
||||
continue;
|
||||
|
||||
if (i.getZ() >= item.getZ()) {
|
||||
found = true;
|
||||
foundSomething = true;
|
||||
}
|
||||
}
|
||||
if(this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
if(this.all) {
|
||||
if (!found)
|
||||
return false;
|
||||
} else {
|
||||
if (found)
|
||||
return true;
|
||||
return this.items.stream().allMatch(item -> {
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
else {
|
||||
return this.items.stream().anyMatch(item -> {
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
|
||||
return this.items.isEmpty() || foundSomething;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
@ -93,7 +92,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
@ -101,6 +100,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
@ -137,8 +137,6 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.items.clear();
|
||||
|
||||
int count;
|
||||
packet.readInt();
|
||||
|
||||
@ -147,6 +145,9 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
packet.readString();
|
||||
|
||||
count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
@ -180,4 +181,14 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean all;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(boolean all, List<Integer> itemIds) {
|
||||
this.all = all;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
|
||||
@ -51,63 +51,45 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
THashMap<HabboItem, THashSet<RoomTile>> tiles = new THashMap<>();
|
||||
for (HabboItem item : this.items) {
|
||||
tiles.put(item, room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
|
||||
}
|
||||
|
||||
Collection<Habbo> habbos = room.getHabbos();
|
||||
Collection<Bot> bots = room.getCurrentBots().valueCollection();
|
||||
Collection<Pet> pets = room.getCurrentPets().valueCollection();
|
||||
|
||||
for (Map.Entry<HabboItem, THashSet<RoomTile>> set : tiles.entrySet()) {
|
||||
boolean found = false;
|
||||
for (Habbo habbo : habbos) {
|
||||
if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
for (Bot bot : bots) {
|
||||
if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
for (Pet pet : pets) {
|
||||
if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.items.stream().allMatch(item -> {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
data.append(item.getId()).append(";");
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
@ -116,7 +98,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
@ -124,6 +106,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WiredConditionType getType() {
|
||||
@ -154,14 +137,15 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.items.clear();
|
||||
|
||||
int count;
|
||||
packet.readInt();
|
||||
|
||||
packet.readString();
|
||||
|
||||
count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
@ -196,4 +180,14 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean all;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(boolean all, List<Integer> itemIds) {
|
||||
this.all = all;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.STUFF_IS;
|
||||
@ -37,43 +39,55 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
this.refresh();
|
||||
|
||||
if(items.isEmpty())
|
||||
return false;
|
||||
|
||||
if (stuff != null) {
|
||||
if (stuff.length >= 1) {
|
||||
if (stuff[0] instanceof HabboItem) {
|
||||
HabboItem item = (HabboItem) stuff[0];
|
||||
|
||||
for (HabboItem i : this.items) {
|
||||
if (i.getBaseItem().getId() == item.getBaseItem().getId())
|
||||
return true;
|
||||
HabboItem triggeringItem = (HabboItem)stuff[0];
|
||||
return this.items.stream().anyMatch(item -> item == triggeringItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
|
||||
for (String s : data)
|
||||
this.items.add(room.getHabboItem(Integer.valueOf(s)));
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(";");
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,12 +118,13 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.items.clear();
|
||||
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
@ -139,4 +154,12 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -34,15 +35,26 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.lowerLimit + ":" + this.upperLimit;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.lowerLimit,
|
||||
this.upperLimit
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
this.lowerLimit = Integer.valueOf(data[0]);
|
||||
this.upperLimit = Integer.valueOf(data[1]);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.lowerLimit = data.lowerLimit;
|
||||
this.upperLimit = data.upperLimit;
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
this.lowerLimit = Integer.parseInt(data[0]);
|
||||
this.upperLimit = Integer.parseInt(data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,4 +94,14 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int lowerLimit;
|
||||
int upperLimit;
|
||||
|
||||
public JsonData(int lowerLimit, int upperLimit) {
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -32,12 +33,21 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.effectId + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.effectId
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.effectId = Integer.valueOf(set.getString("wired_data"));
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.effectId = data.effectId;
|
||||
} else {
|
||||
this.effectId = Integer.parseInt(wiredData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,4 +83,12 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int effectId;
|
||||
|
||||
public JsonData(int effectId) {
|
||||
this.effectId = effectId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import org.slf4j.Logger;
|
||||
@ -66,13 +67,22 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.handItem + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.handItem
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
try {
|
||||
this.handItem = Integer.valueOf(set.getString("wired_data"));
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.handItem = data.handItemId;
|
||||
} else {
|
||||
this.handItem = Integer.parseInt(wiredData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
}
|
||||
@ -82,4 +92,12 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
|
||||
public void onPickUp() {
|
||||
this.handItem = 0;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int handItemId;
|
||||
|
||||
public JsonData(int handItemId) {
|
||||
this.handItemId = handItemId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -44,12 +45,21 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.badge;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.badge
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.badge = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.badge = data.badge;
|
||||
} else {
|
||||
this.badge = wiredData;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,4 +95,12 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String badge;
|
||||
|
||||
public JsonData(String badge) {
|
||||
this.badge = badge;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -32,16 +33,23 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.cycles + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.cycles
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String data = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
try {
|
||||
if (!data.equals(""))
|
||||
this.cycles = Integer.valueOf(data);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.cycles = data.cycles;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
this.cycles = Integer.parseInt(wiredData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
@ -80,4 +88,12 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int cycles;
|
||||
|
||||
public JsonData(int cycles) {
|
||||
this.cycles = cycles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
@ -15,8 +16,10 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WiredConditionMatchStatePosition extends InteractionWiredCondition {
|
||||
public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings {
|
||||
public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT;
|
||||
|
||||
private THashSet<WiredMatchFurniSetting> settings;
|
||||
@ -49,7 +52,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
message.appendInt(this.settings.size());
|
||||
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
message.appendInt(item.itemId);
|
||||
message.appendInt(item.item_id);
|
||||
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
@ -67,8 +70,6 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.settings.clear();
|
||||
|
||||
int count;
|
||||
packet.readInt();
|
||||
|
||||
@ -84,6 +85,9 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
return true;
|
||||
|
||||
count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.settings.clear();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int itemId = packet.readInt();
|
||||
@ -104,7 +108,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
THashSet<WiredMatchFurniSetting> s = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
|
||||
if (item != null) {
|
||||
if (this.state) {
|
||||
@ -137,25 +141,28 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder data = new StringBuilder(this.settings.size() + ":");
|
||||
|
||||
if (this.settings.isEmpty()) {
|
||||
data.append("\t;");
|
||||
} else {
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
data.append(item.toString()).append(";");
|
||||
}
|
||||
|
||||
data.append(":").append(this.state ? 1 : 0).append(":").append(this.direction ? 1 : 0).append(":").append(this.position ? 1 : 0);
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.state,
|
||||
this.position,
|
||||
this.direction,
|
||||
new ArrayList<>(this.settings)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
int itemCount = Integer.valueOf(data[0]);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.state = data.state;
|
||||
this.position = data.position;
|
||||
this.direction = data.direction;
|
||||
this.settings.addAll(data.settings);
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
int itemCount = Integer.parseInt(data[0]);
|
||||
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
@ -163,13 +170,14 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
String[] stuff = items[i].split("-");
|
||||
|
||||
if (stuff.length >= 5)
|
||||
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
|
||||
this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4])));
|
||||
}
|
||||
|
||||
this.state = data[2].equals("1");
|
||||
this.direction = data[3].equals("1");
|
||||
this.position = data[4].equals("1");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
@ -186,7 +194,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
THashSet<WiredMatchFurniSetting> remove = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
if (item == null) {
|
||||
remove.add(setting);
|
||||
}
|
||||
@ -197,4 +205,38 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public THashSet<WiredMatchFurniSetting> getMatchFurniSettings() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldMatchState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldMatchRotation() {
|
||||
return this.direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldMatchPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean state;
|
||||
boolean position;
|
||||
boolean direction;
|
||||
List<WiredMatchFurniSetting> settings;
|
||||
|
||||
public JsonData(boolean state, boolean position, boolean direction, List<WiredMatchFurniSetting> settings) {
|
||||
this.state = state;
|
||||
this.position = position;
|
||||
this.direction = direction;
|
||||
this.settings = settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -32,16 +33,23 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.cycles + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.cycles
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String data = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
try {
|
||||
if (!data.equals(""))
|
||||
this.cycles = Integer.valueOf(data);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.cycles = data.cycles;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
this.cycles = Integer.parseInt(wiredData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
@ -80,4 +88,12 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int cycles;
|
||||
|
||||
public JsonData(int cycles) {
|
||||
this.cycles = cycles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
|
||||
@ -15,6 +16,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI;
|
||||
@ -39,38 +42,49 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
THashSet<HabboItem> things = room.getItemsAt(item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item));
|
||||
things.removeAll(this.items);
|
||||
if (!things.isEmpty()) {
|
||||
if (this.all)
|
||||
return false;
|
||||
else
|
||||
continue;
|
||||
if(this.all) {
|
||||
return this.items.stream().allMatch(item -> {
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
return true;
|
||||
else {
|
||||
return this.items.stream().anyMatch(item -> {
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
for (int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
@ -79,7 +93,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
@ -87,6 +101,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
@ -123,16 +138,16 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.items.clear();
|
||||
|
||||
int count;
|
||||
packet.readInt();
|
||||
|
||||
this.all = packet.readInt() == 1;
|
||||
|
||||
packet.readString();
|
||||
|
||||
count = packet.readInt();
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
@ -169,6 +184,18 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public WiredConditionOperator operator() {
|
||||
return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR;
|
||||
// NICE TRY BUT THAT'S NOT HOW IT WORKS. NOTHING IN HABBO IS AN "OR" CONDITION - EVERY CONDITION MUST BE SUCCESS FOR THE STACK TO EXECUTE, BUT LET'S LEAVE IT IMPLEMENTED FOR PLUGINS TO USE.
|
||||
//return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR;
|
||||
return WiredConditionOperator.AND;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean all;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(boolean all, List<Integer> itemIds) {
|
||||
this.all = all;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO;
|
||||
@ -51,63 +51,45 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
THashMap<HabboItem, THashSet<RoomTile>> tiles = new THashMap<>();
|
||||
for (HabboItem item : this.items) {
|
||||
tiles.put(item, room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
|
||||
}
|
||||
|
||||
Collection<Habbo> habbos = room.getHabbos();
|
||||
Collection<Bot> bots = room.getCurrentBots().valueCollection();
|
||||
Collection<Pet> pets = room.getCurrentPets().valueCollection();
|
||||
|
||||
for (Map.Entry<HabboItem, THashSet<RoomTile>> set : tiles.entrySet()) {
|
||||
if (!habbos.isEmpty()) {
|
||||
for (Habbo habbo : habbos) {
|
||||
if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bots.isEmpty()) {
|
||||
for (Bot bot : bots) {
|
||||
if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pets.isEmpty()) {
|
||||
for (Pet pet : pets) {
|
||||
if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
return this.items.stream().noneMatch(item -> {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
data.append(item.getId()).append(";");
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
@ -116,7 +98,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
@ -124,6 +106,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WiredConditionType getType() {
|
||||
@ -154,14 +137,14 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.items.clear();
|
||||
|
||||
int count;
|
||||
packet.readInt();
|
||||
|
||||
packet.readString();
|
||||
|
||||
count = packet.readInt();
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
@ -196,4 +179,14 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean all;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(boolean all, List<Integer> itemIds) {
|
||||
this.all = all;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS;
|
||||
@ -32,15 +34,14 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
this.refresh();
|
||||
|
||||
if(items.isEmpty())
|
||||
return true;
|
||||
|
||||
if (stuff != null) {
|
||||
if (stuff.length >= 1) {
|
||||
if (stuff[0] instanceof HabboItem) {
|
||||
HabboItem item = (HabboItem) stuff[0];
|
||||
|
||||
for (HabboItem i : this.items) {
|
||||
if (i.getBaseItem().getId() == item.getBaseItem().getId())
|
||||
return false;
|
||||
}
|
||||
HabboItem triggeringItem = (HabboItem)stuff[0];
|
||||
return this.items.stream().noneMatch(item -> item == triggeringItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,23 +52,37 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
|
||||
for (String s : data)
|
||||
this.items.add(room.getHabboItem(Integer.valueOf(s)));
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -103,12 +118,13 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.items.clear();
|
||||
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
@ -138,4 +154,12 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -34,14 +35,25 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.lowerLimit + ":" + this.upperLimit;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.lowerLimit,
|
||||
this.upperLimit
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
this.lowerLimit = Integer.valueOf(data[0]);
|
||||
this.upperLimit = Integer.valueOf(data[1]);
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionHabboCount.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionHabboCount.JsonData.class);
|
||||
this.lowerLimit = data.lowerLimit;
|
||||
this.upperLimit = data.upperLimit;
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
this.lowerLimit = Integer.parseInt(data[0]);
|
||||
this.upperLimit = Integer.parseInt(data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,4 +93,14 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int lowerLimit;
|
||||
int upperLimit;
|
||||
|
||||
public JsonData(int lowerLimit, int upperLimit) {
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -32,12 +33,21 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.effectId + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.effectId
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.effectId = Integer.valueOf(set.getString("wired_data"));
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.effectId = data.effectId;
|
||||
} else {
|
||||
this.effectId = Integer.parseInt(wiredData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,4 +83,12 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int effectId;
|
||||
|
||||
public JsonData(int effectId) {
|
||||
this.effectId = effectId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -45,12 +46,21 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.badge;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.badge
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.badge = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.badge = data.badge;
|
||||
} else {
|
||||
this.badge = wiredData;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,4 +96,12 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String badge;
|
||||
|
||||
public JsonData(String badge) {
|
||||
this.badge = badge;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ 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.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -31,27 +32,31 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
return !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor);
|
||||
}
|
||||
return true; // user is not part of any team
|
||||
return habbo.getHabboInfo().getGamePlayer() == null || !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor); // user is not part of any team
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.teamColor.type + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.teamColor
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String data = set.getString("wired_data");
|
||||
|
||||
try {
|
||||
if (!data.equals(""))
|
||||
this.teamColor = GameTeamColors.values()[Integer.valueOf(data)];
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.teamColor = data.teamColor;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)];
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.teamColor = GameTeamColors.RED;
|
||||
}
|
||||
@ -91,4 +96,12 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
GameTeamColors teamColor;
|
||||
|
||||
public JsonData(GameTeamColors teamColor) {
|
||||
this.teamColor = teamColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,192 +1,32 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition {
|
||||
public class WiredConditionNotMatchStatePosition extends WiredConditionMatchStatePosition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT;
|
||||
|
||||
private THashSet<WiredMatchFurniSetting> settings;
|
||||
|
||||
private boolean state;
|
||||
private boolean position;
|
||||
private boolean rotation;
|
||||
|
||||
public WiredConditionNotMatchStatePosition(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.settings = new THashSet<>();
|
||||
}
|
||||
|
||||
public WiredConditionNotMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
this.settings = new THashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
if (this.settings.isEmpty())
|
||||
return true;
|
||||
|
||||
THashSet<WiredMatchFurniSetting> s = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
|
||||
if (item != null) {
|
||||
boolean stateMatches = !this.state || item.getExtradata().equals(setting.state);
|
||||
boolean positionMatches = !this.position || (setting.x == item.getX() && setting.y == item.getY());
|
||||
boolean directionMatches = !this.rotation || setting.rotation == item.getRotation();
|
||||
|
||||
if (stateMatches && positionMatches && directionMatches)
|
||||
return false;
|
||||
} else {
|
||||
s.add(setting);
|
||||
}
|
||||
}
|
||||
|
||||
if (!s.isEmpty()) {
|
||||
for (WiredMatchFurniSetting setting : s) {
|
||||
this.settings.remove(setting);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder data = new StringBuilder(this.settings.size() + ":");
|
||||
|
||||
if (this.settings.isEmpty()) {
|
||||
data.append("\t;");
|
||||
} else {
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
data.append(item.toString()).append(";");
|
||||
}
|
||||
|
||||
data.append(":").append(this.state ? 1 : 0).append(":").append(this.rotation ? 1 : 0).append(":").append(this.position ? 1 : 0);
|
||||
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
|
||||
int itemCount = Integer.valueOf(data[0]);
|
||||
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
String[] stuff = items[i].split("-");
|
||||
|
||||
if (stuff.length >= 5)
|
||||
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
|
||||
}
|
||||
|
||||
this.state = data[2].equals("1");
|
||||
this.rotation = data[3].equals("1");
|
||||
this.position = data[4].equals("1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
this.settings.clear();
|
||||
this.state = false;
|
||||
this.rotation = false;
|
||||
this.position = false;
|
||||
return !super.execute(roomUnit, room, stuff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WiredConditionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeWiredData(ServerMessage message, Room room) {
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.settings.size());
|
||||
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
message.appendInt(item.itemId);
|
||||
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString("");
|
||||
message.appendInt(4);
|
||||
message.appendInt(this.state ? 1 : 0);
|
||||
message.appendInt(this.rotation ? 1 : 0);
|
||||
message.appendInt(this.position ? 1 : 0);
|
||||
message.appendInt(10);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.settings.clear();
|
||||
|
||||
int count;
|
||||
packet.readInt();
|
||||
|
||||
this.state = packet.readInt() == 1;
|
||||
this.rotation = packet.readInt() == 1;
|
||||
this.position = packet.readInt() == 1;
|
||||
|
||||
packet.readString();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
if (room == null)
|
||||
return true;
|
||||
|
||||
count = packet.readInt();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem item = room.getHabboItem(itemId);
|
||||
|
||||
if (item != null)
|
||||
this.settings.add(new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
if (room != null) {
|
||||
THashSet<WiredMatchFurniSetting> remove = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
if (item == null) {
|
||||
remove.add(setting);
|
||||
}
|
||||
}
|
||||
|
||||
for (WiredMatchFurniSetting setting : remove) {
|
||||
this.settings.remove(setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,16 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
||||
public class WiredConditionNotTriggerOnFurni extends WiredConditionTriggerOnFurni {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_ON_FURNI;
|
||||
|
||||
private THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
public WiredConditionNotTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
@ -31,115 +21,19 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
if (roomUnit == null) return false;
|
||||
if (roomUnit == null)
|
||||
return false;
|
||||
|
||||
this.refresh();
|
||||
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
this.items.clear();
|
||||
return !triggerOnFurni(roomUnit, room);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WiredConditionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeWiredData(ServerMessage message, Room room) {
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
message.appendInt(item.getId());
|
||||
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString("");
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.items.clear();
|
||||
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
|
||||
int count = packet.readInt();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
if (room != null) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
HabboItem item = room.getHabboItem(packet.readInt());
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
if (room == null) {
|
||||
items.addAll(this.items);
|
||||
} else {
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() != room.getId())
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
this.items.removeAll(items);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ 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.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -41,16 +42,23 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.teamColor.type + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.teamColor
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String data = set.getString("wired_data");
|
||||
|
||||
try {
|
||||
if (!data.equals(""))
|
||||
this.teamColor = GameTeamColors.values()[Integer.valueOf(data)];
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.teamColor = data.teamColor;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)];
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.teamColor = GameTeamColors.RED;
|
||||
}
|
||||
@ -90,4 +98,12 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
GameTeamColors teamColor;
|
||||
|
||||
public JsonData(GameTeamColors teamColor) {
|
||||
this.teamColor = teamColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
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.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
|
||||
@ -16,11 +16,13 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.TRIGGER_ON_FURNI;
|
||||
|
||||
private THashSet<HabboItem> items = new THashSet<>();
|
||||
protected THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
public WiredConditionTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@ -32,47 +34,76 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
if (roomUnit == null) return false;
|
||||
if (roomUnit == null)
|
||||
return false;
|
||||
|
||||
this.refresh();
|
||||
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY()))
|
||||
return true;
|
||||
return triggerOnFurni(roomUnit, room);
|
||||
}
|
||||
|
||||
protected boolean triggerOnFurni(RoomUnit roomUnit, Room room) {
|
||||
/*
|
||||
* 1. If a Habbo IS NOT walking we only have to check if the Habbo is on one of the selected tiles.
|
||||
* 2. If a Habbo IS walking we have to check if the next tile in the walking path is one of the selected items
|
||||
* */
|
||||
if (!roomUnit.isWalking()) {
|
||||
THashSet<HabboItem> itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation());
|
||||
return this.items.stream().anyMatch(itemsAtUser::contains);
|
||||
} else {
|
||||
RoomTile firstTileInPath = room.getLayout()
|
||||
.findPath(roomUnit.getCurrentLocation(), roomUnit.getGoal(), roomUnit.getGoal(), roomUnit)
|
||||
.peek();
|
||||
|
||||
if (firstTileInPath == null)
|
||||
return false;
|
||||
|
||||
return this.items
|
||||
.stream()
|
||||
.anyMatch(conditionItem -> conditionItem
|
||||
.getOccupyingTiles(room.getLayout())
|
||||
.contains(firstTileInPath)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
data.append(item.getId()).append(";");
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(";");
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,12 +139,13 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet) {
|
||||
this.items.clear();
|
||||
|
||||
packet.readInt();
|
||||
packet.readString();
|
||||
|
||||
int count = packet.readInt();
|
||||
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
|
||||
|
||||
this.items.clear();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
@ -130,7 +162,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
protected void refresh() {
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
@ -148,6 +180,14 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public WiredConditionOperator operator() {
|
||||
return WiredConditionOperator.OR;
|
||||
return WiredConditionOperator.AND;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
@ -7,12 +8,16 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.BOT_CLOTHES;
|
||||
@ -44,18 +49,27 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
String dataString = packet.readString();
|
||||
packet.readInt();
|
||||
int delay = packet.readInt();
|
||||
|
||||
String[] data = packet.readString().split(((char) 9) + "");
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
String splitBy = "\t";
|
||||
if(!dataString.contains(splitBy))
|
||||
throw new WiredSaveException("Malformed data string");
|
||||
|
||||
String[] data = dataString.split(Pattern.quote(splitBy));
|
||||
|
||||
if (data.length != 2)
|
||||
throw new WiredSaveException("Malformed data string. Invalid data length");
|
||||
|
||||
this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.botLook = data[1];
|
||||
}
|
||||
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -69,32 +83,40 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (bots.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bots.size() == 1) {
|
||||
Bot bot = bots.get(0);
|
||||
bot.setFigure(this.botLook);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" +
|
||||
this.botName + ((char) 9) +
|
||||
this.botLook;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.botLook, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.botName = data.bot_name;
|
||||
this.botLook = data.look;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length >= 3) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
this.botName = data[1];
|
||||
this.botLook = data[2];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,4 +141,16 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
public void setBotLook(String botLook) {
|
||||
this.botLook = botLook;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
String look;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, String look, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.look = look;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
@ -9,8 +10,10 @@ 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 com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -67,13 +70,25 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
int mode = packet.readInt();
|
||||
|
||||
this.mode = packet.readInt();
|
||||
this.botName = packet.readString().replace("\t", "");
|
||||
if(mode != 0 && mode != 1)
|
||||
throw new WiredSaveException("Mode is invalid");
|
||||
|
||||
String botName = packet.readString().replace("\t", "");
|
||||
botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.botName = botName;
|
||||
this.mode = mode;
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -105,18 +120,30 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + this.botName;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.mode = data.mode;
|
||||
this.botName = data.bot_name;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length == 3) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
this.mode = (data[1].equalsIgnoreCase("1") ? 1 : 0);
|
||||
this.botName = data[2];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,4 +157,16 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
int mode;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, int mode, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.mode = mode;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,17 @@ 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.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -70,13 +74,25 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.itemId = packet.readInt();
|
||||
this.botName = packet.readString();
|
||||
int itemId = packet.readInt();
|
||||
|
||||
if(itemId < 0)
|
||||
itemId = 0;
|
||||
|
||||
String botName = packet.readString();
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.itemId = itemId;
|
||||
this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -94,15 +110,22 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
Bot bot = bots.get(0);
|
||||
|
||||
List<Runnable> tasks = new ArrayList<>();
|
||||
tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(roomUnit, room, this.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
|
||||
tasks.add(() -> {
|
||||
if(roomUnit.getRoom() != null && roomUnit.getRoom().getId() == room.getId() && roomUnit.getCurrentLocation().distance(bot.getRoomUnit().getCurrentLocation()) < 2) {
|
||||
WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, bot.getRoomUnit(), room, new Object[]{});
|
||||
}
|
||||
});
|
||||
|
||||
RoomTile tile = bot.getRoomUnit().getClosestAdjacentTile(roomUnit.getX(), roomUnit.getY(), true);
|
||||
|
||||
if(tile != null) {
|
||||
bot.getRoomUnit().setGoalLocation(tile);
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
|
||||
|
||||
List<Runnable> failedReach = new ArrayList<>();
|
||||
failedReach.add(() -> tasks.forEach(Runnable::run));
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, failedReach));
|
||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(bot.getRoomUnit(), tile, room, tasks, tasks));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -112,18 +135,30 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" + this.itemId + "" + ((char) 9) + "" + this.botName;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.itemId, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.itemId = data.item_id;
|
||||
this.botName = data.bot_name;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length == 3) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
this.itemId = Integer.valueOf(data[1]);
|
||||
this.botName = data[2];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,4 +172,16 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
int item_id;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, int item_id, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.item_id = item_id;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,16 @@ 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 com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.BOT_TALK;
|
||||
@ -48,20 +52,35 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.mode = packet.readInt();
|
||||
int mode = packet.readInt();
|
||||
|
||||
String[] data = packet.readString().split(((char) 9) + "");
|
||||
if(mode != 0 && mode != 1)
|
||||
throw new WiredSaveException("Mode is invalid");
|
||||
|
||||
if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
this.message = data[1];
|
||||
}
|
||||
String dataString = packet.readString();
|
||||
|
||||
String splitBy = "\t";
|
||||
if(!dataString.contains(splitBy))
|
||||
throw new WiredSaveException("Malformed data string");
|
||||
|
||||
String[] data = dataString.split(Pattern.quote(splitBy));
|
||||
|
||||
if (data.length != 2)
|
||||
throw new WiredSaveException("Malformed data string. Invalid data length");
|
||||
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.setDelay(delay);
|
||||
this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.mode = mode;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -78,38 +97,52 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
message = message.replace(Emulator.getTexts().getValue("wired.variable.username"), habbo.getHabboInfo().getUsername())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.credits"), habbo.getHabboInfo().getCredits() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.pixels"), habbo.getHabboInfo().getPixels() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.points"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "");
|
||||
message = message.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.credits", "%credits%"), habbo.getHabboInfo().getCredits() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getOwnerName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.botName)
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getUserCount() + "");
|
||||
}
|
||||
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (bots.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bots.size() == 1) {
|
||||
Bot bot = bots.get(0);
|
||||
|
||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ message })) {
|
||||
if (this.mode == 1) {
|
||||
bot.shout(message);
|
||||
} else {
|
||||
bot.talk(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + "" + this.botName + "" + ((char) 9) + "" + this.message;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String d = set.getString("wired_data");
|
||||
String[] data = d.split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.mode = data.mode;
|
||||
this.botName = data.bot_name;
|
||||
this.message = data.message;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length == 4) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
@ -117,6 +150,9 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
this.botName = data[2];
|
||||
this.message = data[3];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -155,4 +191,18 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
protected long requiredCooldown() {
|
||||
return 500;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
int mode;
|
||||
String message;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, int mode, String message, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.mode = mode;
|
||||
this.message = message;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,18 @@ 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 com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.BOT_TALK_TO_AVATAR;
|
||||
@ -69,19 +73,34 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
|
||||
this.mode = packet.readInt();
|
||||
String[] data = packet.readString().split("" + ((char) 9));
|
||||
int mode = packet.readInt();
|
||||
|
||||
if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
this.message = data[1];
|
||||
}
|
||||
if(mode != 0 && mode != 1)
|
||||
throw new WiredSaveException("Mode is invalid");
|
||||
|
||||
String dataString = packet.readString();
|
||||
String splitBy = "\t";
|
||||
if(!dataString.contains(splitBy))
|
||||
throw new WiredSaveException("Malformed data string");
|
||||
|
||||
String[] data = dataString.split(Pattern.quote(splitBy));
|
||||
|
||||
if (data.length != 2)
|
||||
throw new WiredSaveException("Malformed data string. Invalid data length");
|
||||
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.mode = mode;
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -97,10 +116,15 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
|
||||
if (habbo != null) {
|
||||
String m = this.message;
|
||||
m = m.replace(Emulator.getTexts().getValue("wired.variable.username"), habbo.getHabboInfo().getUsername())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.credits"), habbo.getHabboInfo().getCredits() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.pixels"), habbo.getHabboInfo().getPixels() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.points"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "");
|
||||
m = m.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.credits", "%credits%"), habbo.getHabboInfo().getCredits() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getOwnerName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.botName)
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getUserCount() + "");
|
||||
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
@ -110,11 +134,13 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
|
||||
Bot bot = bots.get(0);
|
||||
|
||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ m })) {
|
||||
if (this.mode == 1) {
|
||||
bot.whisper(m, habbo);
|
||||
} else {
|
||||
bot.talk(habbo.getHabboInfo().getUsername() + ": " + m);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -124,12 +150,22 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + "" + this.botName + "" + ((char) 9) + "" + this.message;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.mode = data.mode;
|
||||
this.botName = data.bot_name;
|
||||
this.message = data.message;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length == 4) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
@ -137,6 +173,9 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
this.botName = data[2];
|
||||
this.message = data[3];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,4 +190,18 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
int mode;
|
||||
String message;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, int mode, String message, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.mode = mode;
|
||||
this.message = message;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitTeleport;
|
||||
import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer;
|
||||
@ -21,8 +22,10 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.BOT_TELEPORT;
|
||||
@ -77,6 +80,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> { roomUnit.isWiredTeleporting = true; }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
|
||||
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
|
||||
}
|
||||
|
||||
@ -110,19 +114,36 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
|
||||
packet.readInt();
|
||||
this.botName = packet.readString();
|
||||
String botName = packet.readString();
|
||||
int itemsCount = packet.readInt();
|
||||
|
||||
this.items.clear();
|
||||
|
||||
int count = packet.readInt();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
|
||||
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
|
||||
throw new WiredSaveException("Too many furni selected");
|
||||
}
|
||||
|
||||
this.setDelay(packet.readInt());
|
||||
List<HabboItem> newItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = packet.readInt();
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
|
||||
newItems.add(it);
|
||||
}
|
||||
|
||||
int delay = packet.readInt();
|
||||
|
||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
||||
throw new WiredSaveException("Delay too long");
|
||||
|
||||
this.items.clear();
|
||||
this.items.addAll(newItems);
|
||||
this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
||||
this.setDelay(delay);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -164,27 +185,43 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t" + this.botName + ";");
|
||||
ArrayList<Integer> itemIds = new ArrayList<>();
|
||||
|
||||
if (this.items != null && !this.items.isEmpty()) {
|
||||
if (this.items != null) {
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() != 0) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
itemIds.add(item.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items = new THashSet<>();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
|
||||
if (wiredData.length >= 2) {
|
||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
||||
String[] data = wiredData[1].split(";");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.botName = data.bot_name;
|
||||
|
||||
for(int itemId : data.items) {
|
||||
HabboItem item = room.getHabboItem(itemId);
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String[] wiredDataSplit = set.getString("wired_data").split("\t");
|
||||
|
||||
if (wiredDataSplit.length >= 2) {
|
||||
this.setDelay(Integer.valueOf(wiredDataSplit[0]));
|
||||
String[] data = wiredDataSplit[1].split(";");
|
||||
|
||||
if (data.length > 1) {
|
||||
this.botName = data[0];
|
||||
@ -197,6 +234,9 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -205,4 +245,16 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
this.items.clear();
|
||||
this.setDelay(0);
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
List<Integer> items;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, List<Integer> items, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.items = items;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user