mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Merge branch 'dev' into 'master'
2.0.0 Stable - Merged Into Master. Closes #96, #55, #18, #9, #90, #92, #40, #87, #84, #28, #41, #79, #16, and #1 See merge request morningstar/Arcturus-Community!39
This commit is contained in:
commit
7e5cf51fba
@ -31,6 +31,8 @@ When making an bug report or a feature request use the template we provide so th
|
|||||||
- Harmonic
|
- Harmonic
|
||||||
- Beny
|
- Beny
|
||||||
- Claudio
|
- Claudio
|
||||||
|
- Alejandro
|
||||||
|
- Harmony
|
||||||
|
|
||||||
## Discord ##
|
## Discord ##
|
||||||
Join us on Discord at https://discord.gg/BzfFsTp
|
Join us on Discord at https://discord.gg/BzfFsTp
|
||||||
|
31
sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql
Normal file
31
sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#DATABASE UPDATE: 2.0.0 RC-2 -> 2.0.0 RC-3
|
||||||
|
|
||||||
|
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('commands.plugins.oldstyle', '0');
|
||||||
|
|
||||||
|
ALTER TABLE `emulator_errors`
|
||||||
|
ADD COLUMN `version` varchar(64) NOT NULL AFTER `timestamp`,
|
||||||
|
ADD COLUMN `build_hash` varchar(64) NOT NULL AFTER `version`;
|
||||||
|
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('scripter.modtool.tickets', '1');
|
||||||
|
|
||||||
|
ALTER TABLE `items_crackable`
|
||||||
|
ADD COLUMN `subscription_duration` int(3) NULL AFTER `required_effect`,
|
||||||
|
ADD COLUMN `subscription_type` varchar(255) NULL COMMENT 'hc for Habbo Club, bc for Builders Club' AFTER `subscription_duration`;
|
||||||
|
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('invisible.prevent.chat', '0');
|
||||||
|
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('invisible.prevent.chat.error', 'While being invisible you cannot talk.');
|
||||||
|
|
||||||
|
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_invisible.updated.back', 'You are now visible again.');
|
||||||
|
|
||||||
|
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_mimic.forbidden_clothing', 'The other user has clothing that you do not own yet.');
|
||||||
|
ALTER TABLE `permissions`
|
||||||
|
ADD COLUMN `acc_mimic_unredeemed` enum('0','1') NOT NULL DEFAULT '0';
|
||||||
|
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.max.allowed.items', '100');
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.batch.size', '6');
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.batch.free.items', '1');
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.bonus.min.discounts', '1');
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.additional.thresholds', '40;99');
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('clothing.strip_unowned', '0');
|
||||||
|
|
||||||
|
#END DATABASE UPDATE: 2.0.0 RC-2 -> 2.0.0 RC-3
|
74
sqlupdates/2_0_0_TO_DEV.sql
Normal file
74
sqlupdates/2_0_0_TO_DEV.sql
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#DATABASE UPDATE: 2.0.0 -> DEV
|
||||||
|
|
||||||
|
ALTER TABLE `guilds_forums` RENAME TO `old_guilds_forums`;
|
||||||
|
ALTER TABLE `guilds_forums_comments` RENAME TO `old_guilds_forums_comments`;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `guilds_forums_comments`;
|
||||||
|
CREATE TABLE `guilds_forums_comments` (
|
||||||
|
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`thread_id` int(11) NOT NULL DEFAULT 0,
|
||||||
|
`user_id` int(11) NOT NULL DEFAULT 0,
|
||||||
|
`message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||||
|
`created_at` int(11) NOT NULL DEFAULT 0,
|
||||||
|
`state` int(11) NOT NULL DEFAULT 0,
|
||||||
|
`admin_id` int(11) NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
|
||||||
|
|
||||||
|
CREATE TABLE `guilds_forums_threads` (
|
||||||
|
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`guild_id` int(11) NULL DEFAULT 0,
|
||||||
|
`opener_id` int(11) NULL DEFAULT 0,
|
||||||
|
`subject` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '',
|
||||||
|
`posts_count` int(11) NULL DEFAULT 0,
|
||||||
|
`created_at` int(11) NULL DEFAULT 0,
|
||||||
|
`updated_at` int(11) NULL DEFAULT 0,
|
||||||
|
`state` int(11) NULL DEFAULT 0,
|
||||||
|
`pinned` tinyint(4) NULL DEFAULT 0,
|
||||||
|
`locked` tinyint(4) NULL DEFAULT 0,
|
||||||
|
`admin_id` int(11) NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
|
||||||
|
|
||||||
|
|
||||||
|
DROP PROCEDURE IF EXISTS MIGRATION_FORUMS;
|
||||||
|
DELIMITER ;;
|
||||||
|
|
||||||
|
CREATE PROCEDURE MIGRATION_FORUMS()
|
||||||
|
BEGIN
|
||||||
|
DECLARE n INT DEFAULT 0;
|
||||||
|
DECLARE i INT DEFAULT 0;
|
||||||
|
SELECT COUNT(*) FROM `old_guilds_forums` INTO n;
|
||||||
|
SET i=0;
|
||||||
|
WHILE i<n DO
|
||||||
|
SET @old_id = (SELECT id FROM `old_guilds_forums` LIMIT i,1);
|
||||||
|
INSERT INTO `guilds_forums_threads` (`guild_id`, `opener_id`, `subject`, `posts_count`, `created_at`, `updated_at`, `state`, `pinned`, `locked`, `admin_id`)
|
||||||
|
SELECT `guild_id`, `user_id`, `subject`, 0 AS `posts_count`, `timestamp`, `timestamp`, IF(STRCMP(`state`,'OPEN')=0, 0, IF(STRCMP(`state`,'HIDDEN_BY_ADMIN')=0, 10, IF(STRCMP(`state`,'HIDDEN_BY_STAFF')=0, 20, 1))) AS `state`, IF(STRCMP(`pinned`,'1')=0, 1, 0), IF(STRCMP(`locked`,'1')=0, 1, 0), `admin_id` FROM `old_guilds_forums`
|
||||||
|
LIMIT i,1;
|
||||||
|
|
||||||
|
SET @new_id = LAST_INSERT_ID();
|
||||||
|
INSERT INTO `guilds_forums_comments` (`thread_id`, `user_id`, `message`, `created_at`, `state`, `admin_id`)
|
||||||
|
SELECT @new_id AS `thread_id`, `user_id`, `message`, `timestamp`, IF(STRCMP(`state`,'OPEN')=0, 0, IF(STRCMP(`state`,'HIDDEN_BY_ADMIN')=0, 10, IF(STRCMP(`state`,'HIDDEN_BY_STAFF')=0, 20, 1))) AS `state`, `admin_id` FROM `old_guilds_forums_comments`
|
||||||
|
WHERE thread_id = @old_id;
|
||||||
|
|
||||||
|
SET i = i + 1;
|
||||||
|
END WHILE;
|
||||||
|
END;
|
||||||
|
;;
|
||||||
|
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
CALL MIGRATION_FORUMS();
|
||||||
|
DROP PROCEDURE IF EXISTS MIGRATION_FORUMS;
|
||||||
|
|
||||||
|
UPDATE `users_pets` LEFT JOIN `rooms` ON `users_pets`.`room_id` = `rooms`.`id` SET `users_pets`.`room_id` = 0 WHERE `users_pets`.`room_id` != 0 AND `rooms`.`id` IS NULL;
|
||||||
|
|
||||||
|
ALTER TABLE `users_settings` ADD COLUMN `forums_post_count` int(11) NULL DEFAULT 0 AFTER `perk_trade`;
|
||||||
|
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('catalog.guild.hc_required', '1');
|
||||||
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('catalog.ltd.random', '1');
|
||||||
|
UPDATE `emulator_settings` SET `value` = '0' WHERE `key` = 'hotel.banzai.points.tile.steal';
|
||||||
|
UPDATE `emulator_settings` SET `value` = '0' WHERE `key` = 'hotel.banzai.points.tile.fill';
|
||||||
|
UPDATE `emulator_settings` SET `value` = '1' WHERE `key` = 'hotel.banzai.points.tile.lock';
|
||||||
|
|
||||||
|
#END DATABASE UPDATE: 2.0.0 -> DEV
|
@ -21,11 +21,16 @@ import com.eu.habbo.threading.runnables.CameraClientAutoReconnect;
|
|||||||
import com.eu.habbo.util.imager.badges.BadgeImager;
|
import com.eu.habbo.util.imager.badges.BadgeImager;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.security.MessageDigest;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.zip.Checksum;
|
||||||
|
|
||||||
public final class Emulator
|
public final class Emulator
|
||||||
{
|
{
|
||||||
@ -39,21 +44,18 @@ public final class Emulator
|
|||||||
public final static int BUILD = 0;
|
public final static int BUILD = 0;
|
||||||
|
|
||||||
|
|
||||||
public static final String version = "Version: " + MAJOR + "." + MINOR + "." + BUILD;
|
public final static String PREVIEW = "RC-3";
|
||||||
|
|
||||||
|
public static final String version = "Arcturus Morningstar"+ " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW;
|
||||||
|
|
||||||
public static MessengerBuddy publicChatBuddy;
|
public static String build = "";
|
||||||
|
|
||||||
|
|
||||||
public static boolean isReady = false;
|
public static boolean isReady = false;
|
||||||
|
|
||||||
|
|
||||||
public static boolean isShuttingDown = false;
|
public static boolean isShuttingDown = false;
|
||||||
|
|
||||||
|
|
||||||
public static boolean stopped = false;
|
public static boolean stopped = false;
|
||||||
|
|
||||||
|
|
||||||
public static boolean debugging = false;
|
public static boolean debugging = false;
|
||||||
|
|
||||||
private static int timeStarted = 0;
|
private static int timeStarted = 0;
|
||||||
@ -89,12 +91,15 @@ public final class Emulator
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Locale.setDefault(new Locale("en"));
|
||||||
|
|
||||||
|
setBuild();
|
||||||
Emulator.stopped = false;
|
Emulator.stopped = false;
|
||||||
ConsoleCommand.load();
|
ConsoleCommand.load();
|
||||||
Emulator.logging = new Logging();
|
Emulator.logging = new Logging();
|
||||||
Emulator.getLogging().logStart("\r" + Emulator.logo);
|
Emulator.getLogging().logStart("\r" + Emulator.logo +
|
||||||
|
" Build: " + build + "\n");
|
||||||
random = new Random();
|
random = new Random();
|
||||||
publicChatBuddy = new MessengerBuddy(-1, "Staff Chat", "", (short) 0, 0);
|
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
|
|
||||||
Emulator.runtime = Runtime.getRuntime();
|
Emulator.runtime = Runtime.getRuntime();
|
||||||
@ -159,9 +164,9 @@ public final class Emulator
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Emulator.getLogging().logStart("Arcturus Morningstar does not include a camera by default, if you wish to have that feature please download the PNGCamera plugin!");
|
Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a Release Candidate for 2.0.0, if you find any bugs please place them on our git repository.");
|
||||||
Emulator.getLogging().logStart("This is not an official arcturus build. This is a community forked version released under the GPL License. You are breaking no laws by using this software... Except for copyright infringement from sulake i suppose... oopsie.");
|
Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: ");
|
||||||
Emulator.getLogging().logStart("- Krews.org Team");
|
Emulator.getLogging().logStart("https://discord.gg/syuqgN");
|
||||||
System.out.println("Waiting for commands: ");
|
System.out.println("Waiting for commands: ");
|
||||||
}
|
}
|
||||||
}, 3500);
|
}, 3500);
|
||||||
@ -193,6 +198,38 @@ public final class Emulator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setBuild() {
|
||||||
|
if(Emulator.class.getProtectionDomain().getCodeSource() == null) {
|
||||||
|
build = "UNKNOWN";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String filepath = new File(Emulator.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");// MD5
|
||||||
|
FileInputStream fis = new FileInputStream(filepath);
|
||||||
|
byte[] dataBytes = new byte[1024];
|
||||||
|
int nread = 0;
|
||||||
|
|
||||||
|
while((nread = fis.read(dataBytes)) != -1)
|
||||||
|
md.update(dataBytes, 0, nread);
|
||||||
|
|
||||||
|
byte[] mdbytes = md.digest();
|
||||||
|
|
||||||
|
for(int i=0; i<mdbytes.length; i++)
|
||||||
|
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100 , 16).substring(1));
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
build = "UNKNOWN";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
build = sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void dispose()
|
private static void dispose()
|
||||||
{
|
{
|
||||||
@ -457,12 +494,11 @@ public final class Emulator
|
|||||||
|
|
||||||
private static final String logo =
|
private static final String logo =
|
||||||
|
|
||||||
" \n" +
|
" \n" +
|
||||||
" __ ___ _ ARCTURUS __ \n" +
|
" __ ___ _ A R C T U R U S __ \n" +
|
||||||
" / |/ /___ _________ (_)___ ____ ______/ /_____ ______ \n" +
|
" / |/ /___ _________ (_)___ ____ ______/ /_____ ______ \n" +
|
||||||
" / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" +
|
" / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" +
|
||||||
" / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" +
|
" / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" +
|
||||||
"/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" +
|
"/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" +
|
||||||
" /____/ Love You Wesley x \n" +
|
" /____/ \n";
|
||||||
" \n" ;
|
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.eu.habbo.core;
|
package com.eu.habbo.core;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.guilds.forums.ForumThread;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.incoming.friends.SearchUserEvent;
|
import com.eu.habbo.messages.incoming.friends.SearchUserEvent;
|
||||||
import com.eu.habbo.messages.incoming.navigator.SearchRoomsEvent;
|
import com.eu.habbo.messages.incoming.navigator.SearchRoomsEvent;
|
||||||
@ -107,7 +108,7 @@ public class CleanerThread implements Runnable {
|
|||||||
if (time - LAST_INACTIVE_GUILDS_CLEARED > REMOVE_INACTIVE_GUILDS)
|
if (time - LAST_INACTIVE_GUILDS_CLEARED > REMOVE_INACTIVE_GUILDS)
|
||||||
{
|
{
|
||||||
Emulator.getGameEnvironment().getGuildManager().clearInactiveGuilds();
|
Emulator.getGameEnvironment().getGuildManager().clearInactiveGuilds();
|
||||||
Emulator.getGameEnvironment().getGuildForumManager().clearInactiveForums();
|
ForumThread.clearCache();
|
||||||
LAST_INACTIVE_GUILDS_CLEARED = time;
|
LAST_INACTIVE_GUILDS_CLEARED = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,13 +11,20 @@ import java.sql.SQLException;
|
|||||||
|
|
||||||
public class ErrorLog implements Loggable
|
public class ErrorLog implements Loggable
|
||||||
{
|
{
|
||||||
public final static String insertQuery = "INSERT INTO emulator_errors (timestamp, type, stacktrace) VALUES (?, ?, ?)";
|
public final static String insertQuery = "INSERT INTO emulator_errors (timestamp, version, build_hash, type, stacktrace) VALUES (?, ?, ?, ?, ?)";
|
||||||
|
public final String version;
|
||||||
|
public final String buildHash;
|
||||||
|
|
||||||
public final int timeStamp;
|
public final int timeStamp;
|
||||||
public final String type;
|
public final String type;
|
||||||
public final String stackTrace;
|
public final String stackTrace;
|
||||||
|
|
||||||
public ErrorLog(String type, Throwable e)
|
public ErrorLog(String type, Throwable e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
this.version = Emulator.version;
|
||||||
|
this.buildHash = Emulator.version;
|
||||||
|
|
||||||
this.timeStamp = Emulator.getIntUnixTimestamp();
|
this.timeStamp = Emulator.getIntUnixTimestamp();
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
@ -38,6 +45,9 @@ public class ErrorLog implements Loggable
|
|||||||
|
|
||||||
public ErrorLog(String type, String message)
|
public ErrorLog(String type, String message)
|
||||||
{
|
{
|
||||||
|
this.version = Emulator.version;
|
||||||
|
this.buildHash = Emulator.build;
|
||||||
|
|
||||||
this.timeStamp = Emulator.getIntUnixTimestamp();
|
this.timeStamp = Emulator.getIntUnixTimestamp();
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.stackTrace = message;
|
this.stackTrace = message;
|
||||||
@ -47,8 +57,10 @@ public class ErrorLog implements Loggable
|
|||||||
public void log(PreparedStatement statement) throws SQLException
|
public void log(PreparedStatement statement) throws SQLException
|
||||||
{
|
{
|
||||||
statement.setInt(1, this.timeStamp);
|
statement.setInt(1, this.timeStamp);
|
||||||
statement.setString(2, this.type);
|
statement.setString(2, this.version);
|
||||||
statement.setString(3, this.stackTrace);
|
statement.setString(3, this.buildHash);
|
||||||
|
statement.setString(4, this.type);
|
||||||
|
statement.setString(5, this.stackTrace);
|
||||||
statement.addBatch();
|
statement.addBatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,10 @@ public class ConsoleInfoCommand extends ConsoleCommand
|
|||||||
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60);
|
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60);
|
||||||
|
|
||||||
System.out.println("Emulator version: " + Emulator.version);
|
System.out.println("Emulator version: " + Emulator.version);
|
||||||
|
System.out.println("Emulator build: " + Emulator.build);
|
||||||
|
|
||||||
|
System.out.println("");
|
||||||
|
|
||||||
System.out.println("Hotel Statistics");
|
System.out.println("Hotel Statistics");
|
||||||
System.out.println("- Users: " + Emulator.getGameEnvironment().getHabboManager().getOnlineCount());
|
System.out.println("- Users: " + Emulator.getGameEnvironment().getHabboManager().getOnlineCount());
|
||||||
System.out.println("- Rooms: " + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size());
|
System.out.println("- Rooms: " + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size());
|
||||||
|
@ -11,7 +11,6 @@ import com.eu.habbo.habbohotel.commands.CommandHandler;
|
|||||||
import com.eu.habbo.habbohotel.crafting.CraftingManager;
|
import com.eu.habbo.habbohotel.crafting.CraftingManager;
|
||||||
import com.eu.habbo.habbohotel.guides.GuideManager;
|
import com.eu.habbo.habbohotel.guides.GuideManager;
|
||||||
import com.eu.habbo.habbohotel.guilds.GuildManager;
|
import com.eu.habbo.habbohotel.guilds.GuildManager;
|
||||||
import com.eu.habbo.habbohotel.guilds.forums.GuildForumManager;
|
|
||||||
import com.eu.habbo.habbohotel.hotelview.HotelViewManager;
|
import com.eu.habbo.habbohotel.hotelview.HotelViewManager;
|
||||||
import com.eu.habbo.habbohotel.items.ItemManager;
|
import com.eu.habbo.habbohotel.items.ItemManager;
|
||||||
import com.eu.habbo.habbohotel.modtool.ModToolManager;
|
import com.eu.habbo.habbohotel.modtool.ModToolManager;
|
||||||
@ -28,7 +27,6 @@ public class GameEnvironment
|
|||||||
private HabboManager habboManager;
|
private HabboManager habboManager;
|
||||||
private NavigatorManager navigatorManager;
|
private NavigatorManager navigatorManager;
|
||||||
private GuildManager guildManager;
|
private GuildManager guildManager;
|
||||||
private GuildForumManager guildForumManager;
|
|
||||||
private ItemManager itemManager;
|
private ItemManager itemManager;
|
||||||
private CatalogManager catalogManager;
|
private CatalogManager catalogManager;
|
||||||
private HotelViewManager hotelViewManager;
|
private HotelViewManager hotelViewManager;
|
||||||
@ -60,7 +58,6 @@ public class GameEnvironment
|
|||||||
this.botManager = new BotManager();
|
this.botManager = new BotManager();
|
||||||
this.petManager = new PetManager();
|
this.petManager = new PetManager();
|
||||||
this.guildManager = new GuildManager();
|
this.guildManager = new GuildManager();
|
||||||
this.guildForumManager = new GuildForumManager();
|
|
||||||
this.catalogManager = new CatalogManager();
|
this.catalogManager = new CatalogManager();
|
||||||
this.roomManager = new RoomManager();
|
this.roomManager = new RoomManager();
|
||||||
this.navigatorManager = new NavigatorManager();
|
this.navigatorManager = new NavigatorManager();
|
||||||
@ -74,6 +71,7 @@ public class GameEnvironment
|
|||||||
this.pollManager = new PollManager();
|
this.pollManager = new PollManager();
|
||||||
|
|
||||||
this.roomManager.loadPublicRooms();
|
this.roomManager.loadPublicRooms();
|
||||||
|
this.navigatorManager.loadNavigator();
|
||||||
|
|
||||||
this.creditsScheduler = new CreditsScheduler();
|
this.creditsScheduler = new CreditsScheduler();
|
||||||
Emulator.getThreading().run(this.creditsScheduler);
|
Emulator.getThreading().run(this.creditsScheduler);
|
||||||
@ -116,11 +114,6 @@ public class GameEnvironment
|
|||||||
return this.guildManager;
|
return this.guildManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuildForumManager getGuildForumManager()
|
|
||||||
{
|
|
||||||
return this.guildForumManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemManager getItemManager()
|
public ItemManager getItemManager()
|
||||||
{
|
{
|
||||||
return this.itemManager;
|
return this.itemManager;
|
||||||
|
@ -295,6 +295,8 @@ public class AchievementManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
habbo.getClient().sendResponse(new AddHabboItemComposer(badge.getId(), AddHabboItemComposer.AddHabboItemCategory.BADGE));
|
||||||
|
|
||||||
habbo.getHabboStats().addAchievementScore(newLevel.points);
|
habbo.getHabboStats().addAchievementScore(newLevel.points);
|
||||||
|
|
||||||
if (newLevel.rewardAmount > 0)
|
if (newLevel.rewardAmount > 0)
|
||||||
|
@ -144,11 +144,8 @@ public class BotManager
|
|||||||
roomUnit.setRotation(RoomUserRotation.SOUTH);
|
roomUnit.setRotation(RoomUserRotation.SOUTH);
|
||||||
roomUnit.setLocation(location);
|
roomUnit.setLocation(location);
|
||||||
HabboItem topItem = room.getTopItemAt(location.x, location.y);
|
HabboItem topItem = room.getTopItemAt(location.x, location.y);
|
||||||
|
roomUnit.setZ(roomUnit.getCurrentLocation().getStackHeight());
|
||||||
if (topItem != null )
|
roomUnit.setPreviousLocationZ(roomUnit.getCurrentLocation().getStackHeight());
|
||||||
roomUnit.setZ(topItem.getBaseItem().allowSit() ? topItem.getZ() : topItem.getZ() + Item.getCurrentHeight(topItem));
|
|
||||||
|
|
||||||
roomUnit.setPreviousLocationZ(roomUnit.getZ());
|
|
||||||
roomUnit.setPathFinderRoom(room);
|
roomUnit.setPathFinderRoom(room);
|
||||||
roomUnit.setRoomUnitType(RoomUnitType.BOT);
|
roomUnit.setRoomUnitType(RoomUnitType.BOT);
|
||||||
roomUnit.setCanWalk(room.isAllowBotsWalk());
|
roomUnit.setCanWalk(room.isAllowBotsWalk());
|
||||||
@ -164,6 +161,7 @@ public class BotManager
|
|||||||
|
|
||||||
if (topItem != null)
|
if (topItem != null)
|
||||||
{
|
{
|
||||||
|
roomUnit.setZ(topItem.getBaseItem().allowSit() ? topItem.getZ() : topItem.getZ() + Item.getCurrentHeight(topItem));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
topItem.onWalkOn(bot.getRoomUnit(), room, null);
|
topItem.onWalkOn(bot.getRoomUnit(), room, null);
|
||||||
|
@ -99,20 +99,28 @@ public class ButlerBot extends Bot
|
|||||||
b.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()));
|
b.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
List<Runnable> failedReached = new ArrayList();
|
List<Runnable> failedReached = new ArrayList();
|
||||||
failedReached.add(new Runnable()
|
failedReached.add(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance")) {
|
if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance", 8)) {
|
||||||
for (Runnable t : tasks) {
|
for (Runnable t : tasks) {
|
||||||
t.run();
|
t.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId));
|
Emulator.getThreading().run(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId));
|
||||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.getRoomUnit(), serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), tasks, failedReached));
|
|
||||||
|
if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) > 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
|
else
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,13 @@ public class CatalogLimitedConfiguration implements Runnable
|
|||||||
this.itemId = itemId;
|
this.itemId = itemId;
|
||||||
this.totalSet = totalSet;
|
this.totalSet = totalSet;
|
||||||
this.limitedNumbers = availableNumbers;
|
this.limitedNumbers = availableNumbers;
|
||||||
Collections.shuffle(this.limitedNumbers);
|
|
||||||
|
if(Emulator.getConfig().getBoolean("catalog.ltd.random", true)) {
|
||||||
|
Collections.shuffle(this.limitedNumbers);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Collections.reverse(this.limitedNumbers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumber()
|
public int getNumber()
|
||||||
@ -80,7 +86,13 @@ public class CatalogLimitedConfiguration implements Runnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.totalSet += amount;
|
this.totalSet += amount;
|
||||||
Collections.shuffle(this.limitedNumbers);
|
|
||||||
|
if(Emulator.getConfig().getBoolean("catalog.ltd.random", true)) {
|
||||||
|
Collections.shuffle(this.limitedNumbers);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Collections.reverse(this.limitedNumbers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,10 +5,12 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
|||||||
import com.eu.habbo.habbohotel.bots.Bot;
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
import com.eu.habbo.habbohotel.catalog.layouts.*;
|
import com.eu.habbo.habbohotel.catalog.layouts.*;
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||||
import com.eu.habbo.habbohotel.items.FurnitureType;
|
import com.eu.habbo.habbohotel.items.FurnitureType;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.SoundTrack;
|
import com.eu.habbo.habbohotel.items.SoundTrack;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||||
|
import com.eu.habbo.habbohotel.modtool.ScripterManager;
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||||
@ -39,6 +41,7 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CatalogManager
|
public class CatalogManager
|
||||||
{
|
{
|
||||||
@ -1043,16 +1046,13 @@ public class CatalogManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalCredits = 0;
|
|
||||||
int totalPoints = 0;
|
|
||||||
|
|
||||||
THashSet<HabboItem> itemsList = new THashSet<>();
|
THashSet<HabboItem> itemsList = new THashSet<>();
|
||||||
|
|
||||||
|
|
||||||
if (amount > 1 && !CatalogItem.haveOffer(item))
|
if (amount > 1 && !CatalogItem.haveOffer(item))
|
||||||
{
|
{
|
||||||
String message = Emulator.getTexts().getValue("scripter.warning.catalog.amount").replace("%username%", habbo.getHabboInfo().getUsername()).replace("%itemname%", item.getName()).replace("%pagename%", page.getCaption());
|
String message = Emulator.getTexts().getValue("scripter.warning.catalog.amount").replace("%username%", habbo.getHabboInfo().getUsername()).replace("%itemname%", item.getName()).replace("%pagename%", page.getCaption());
|
||||||
Emulator.getGameEnvironment().getModToolManager().quickTicket(habbo.getClient().getHabbo(), "Scripter", message);
|
ScripterManager.scripterDetected(habbo.getClient(), message);
|
||||||
Emulator.getLogging().logUserLine(message);
|
Emulator.getLogging().logUserLine(message);
|
||||||
habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL));
|
habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL));
|
||||||
return;
|
return;
|
||||||
@ -1071,205 +1071,171 @@ public class CatalogManager
|
|||||||
limitedStack = limitedConfiguration.getTotalSet();
|
limitedStack = limitedConfiguration.getTotalSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int totalCredits = free ? 0 : this.calculateDiscountedPrice(item.getCredits(), amount, item);
|
||||||
|
int totalPoints = free ? 0 : this.calculateDiscountedPrice(item.getPoints(), amount, item);
|
||||||
|
|
||||||
|
if (totalCredits > 0 && habbo.getHabboInfo().getCredits() - totalCredits < 0) return;
|
||||||
|
if (totalPoints > 0 && habbo.getHabboInfo().getCurrencyAmount(item.getPointsType()) - totalPoints < 0) return;
|
||||||
|
|
||||||
List<String> badges = new ArrayList<>();
|
List<String> badges = new ArrayList<>();
|
||||||
|
Map<AddHabboItemComposer.AddHabboItemCategory, List<Integer>> unseenItems = new HashMap<>();
|
||||||
boolean badgeFound = false;
|
boolean badgeFound = false;
|
||||||
for (int i = 0; i < amount; i++)
|
|
||||||
{
|
|
||||||
if (free || (item.getCredits() <= habbo.getClient().getHabbo().getHabboInfo().getCredits() - totalCredits))
|
|
||||||
{
|
|
||||||
if (free ||
|
|
||||||
item.getPoints() <= habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()) - totalPoints)
|
|
||||||
{
|
|
||||||
if (((i + 1) % 6 != 0 && CatalogItem.haveOffer(item)) || !CatalogItem.haveOffer(item))
|
|
||||||
{
|
|
||||||
totalCredits += item.getCredits();
|
|
||||||
totalPoints += item.getPoints();
|
|
||||||
}
|
|
||||||
|
|
||||||
habbo.getHabboStats().addLtdLog(item.getId(), Emulator.getIntUnixTimestamp());
|
for (int i = 0; i < amount; i++) {
|
||||||
|
habbo.getHabboStats().addLtdLog(item.getId(), Emulator.getIntUnixTimestamp());
|
||||||
|
|
||||||
//for (int j = 0; j < item.getAmount(); j++)
|
for (Item baseItem : item.getBaseItems()) {
|
||||||
//{
|
for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) {
|
||||||
for (Item baseItem : item.getBaseItems())
|
if (baseItem.getName().startsWith("rentable_bot_") || baseItem.getName().startsWith("bot_")) {
|
||||||
{
|
String type = item.getName().replace("rentable_bot_", "");
|
||||||
for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++)
|
type = type.replace("bot_", "");
|
||||||
{
|
type = type.replace("visitor_logger", "visitor_log");
|
||||||
if (baseItem.getName().startsWith("rentable_bot_") || baseItem.getName().startsWith("bot_"))
|
|
||||||
{
|
|
||||||
String type = item.getName().replace("rentable_bot_", "");
|
|
||||||
type = type.replace("bot_", "");
|
|
||||||
type = type.replace("visitor_logger", "visitor_log");
|
|
||||||
|
|
||||||
THashMap<String, String> data = new THashMap<>();
|
THashMap<String, String> data = new THashMap<>();
|
||||||
|
|
||||||
for (String s : item.getExtradata().split(";"))
|
for (String s : item.getExtradata().split(";")) {
|
||||||
{
|
if (s.contains(":")) {
|
||||||
if (s.contains(":"))
|
data.put(s.split(":")[0], s.split(":")[1]);
|
||||||
{
|
|
||||||
data.put(s.split(":")[0], s.split(":")[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Bot bot = Emulator.getGameEnvironment().getBotManager().createBot(data, type);
|
|
||||||
|
|
||||||
if (bot != null)
|
|
||||||
{
|
|
||||||
bot.setOwnerId(habbo.getClient().getHabbo().getHabboInfo().getId());
|
|
||||||
bot.setOwnerName(habbo.getClient().getHabbo().getHabboInfo().getUsername());
|
|
||||||
bot.needsUpdate(true);
|
|
||||||
Emulator.getThreading().run(bot);
|
|
||||||
habbo.getClient().getHabbo().getInventory().getBotsComponent().addBot(bot);
|
|
||||||
habbo.getClient().sendResponse(new AddBotComposer(bot));
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
throw new Exception("Failed to create bot of type: " + type);
|
|
||||||
}
|
|
||||||
} else if (baseItem.getType() == FurnitureType.EFFECT)
|
|
||||||
{
|
|
||||||
int effectId = baseItem.getEffectM();
|
|
||||||
|
|
||||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F))
|
|
||||||
{
|
|
||||||
effectId = baseItem.getEffectF();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (effectId > 0)
|
|
||||||
{
|
|
||||||
habbo.getInventory().getEffectsComponent().createEffect(effectId);
|
|
||||||
}
|
|
||||||
} else if (Item.isPet(baseItem))
|
|
||||||
{
|
|
||||||
String[] data = extradata.split("\n");
|
|
||||||
|
|
||||||
if (data.length < 3)
|
|
||||||
{
|
|
||||||
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pet pet = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pet = Emulator.getGameEnvironment().getPetManager().createPet(baseItem, data[0], data[1], data[2], habbo.getClient());
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
Emulator.getLogging().logErrorLine(e);
|
|
||||||
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pet == null)
|
|
||||||
{
|
|
||||||
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
habbo.getClient().getHabbo().getInventory().getPetsComponent().addPet(pet);
|
|
||||||
habbo.getClient().sendResponse(new AddPetComposer(pet));
|
|
||||||
habbo.getClient().sendResponse(new PetBoughtNotificationComposer(pet, false));
|
|
||||||
|
|
||||||
AchievementManager.progressAchievement(habbo.getClient().getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLover"));
|
|
||||||
} else if (baseItem.getType() == FurnitureType.BADGE)
|
|
||||||
{
|
|
||||||
if (!habbo.getInventory().getBadgesComponent().hasBadge(baseItem.getName()))
|
|
||||||
{
|
|
||||||
if (!badges.contains(baseItem.getName()))
|
|
||||||
{
|
|
||||||
badges.add(baseItem.getName());
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
badgeFound = true;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class)
|
|
||||||
{
|
|
||||||
if (baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class && !habbo.getClient().getHabbo().getInventory().getBadgesComponent().hasBadge(extradata))
|
|
||||||
{
|
|
||||||
Emulator.getGameEnvironment().getModToolManager().quickTicket(habbo.getClient().getHabbo(), "Scripter", Emulator.getTexts().getValue("scripter.warning.catalog.badge_display").replace("%username%", habbo.getClient().getHabbo().getHabboInfo().getUsername()).replace("%badge%", extradata));
|
|
||||||
extradata = "UMAD";
|
|
||||||
}
|
|
||||||
|
|
||||||
extradata = habbo.getClient().getHabbo().getHabboInfo().getUsername() + (char) 9 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR) + (char) 9 + Emulator.getGameEnvironment().getWordFilter().filter(extradata.replace(((char)9) + "", ""), habbo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InteractionTeleport.class.isAssignableFrom(baseItem.getInteractionType().getType()))
|
|
||||||
{
|
|
||||||
HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
|
||||||
HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
|
||||||
Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId());
|
|
||||||
itemsList.add(teleportOne);
|
|
||||||
itemsList.add(teleportTwo);
|
|
||||||
} else if (baseItem.getInteractionType().getType() == InteractionHopper.class)
|
|
||||||
{
|
|
||||||
HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
|
||||||
|
|
||||||
Emulator.getGameEnvironment().getItemManager().insertHopper(hopper);
|
|
||||||
|
|
||||||
itemsList.add(hopper);
|
|
||||||
} else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class)
|
|
||||||
{
|
|
||||||
int guildId;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
guildId = Integer.parseInt(extradata);
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
Emulator.getLogging().logErrorLine(e);
|
|
||||||
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
|
||||||
habboItem.setExtradata("");
|
|
||||||
habboItem.needsUpdate(true);
|
|
||||||
|
|
||||||
Emulator.getThreading().run(habboItem);
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId);
|
|
||||||
itemsList.add(habboItem);
|
|
||||||
|
|
||||||
if(baseItem.getName().equals("guild_forum")) {
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().getGuild(guildId).setForum(true);
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().getGuild(guildId).needsUpdate = true;
|
|
||||||
Emulator.getGameEnvironment().getGuildForumManager().addGuildForum(guildId);
|
|
||||||
{
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds SET forum = '1' WHERE id = ?"))
|
|
||||||
|
|
||||||
{
|
|
||||||
statement.setInt(1, guildId);
|
|
||||||
statement.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (baseItem.getInteractionType().getType() == InteractionMusicDisc.class)
|
|
||||||
{
|
|
||||||
SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(item.getExtradata());
|
|
||||||
|
|
||||||
if (track == null)
|
|
||||||
{
|
|
||||||
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
InteractionMusicDisc habboItem = (InteractionMusicDisc) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, habbo.getClient().getHabbo().getHabboInfo().getUsername() + "\n" + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "\n" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "\n" + Calendar.getInstance().get(Calendar.YEAR) + "\n" + track.getLength() + "\n" + track.getName() + "\n" + track.getId());
|
|
||||||
habboItem.needsUpdate(true);
|
|
||||||
|
|
||||||
Emulator.getThreading().run(habboItem);
|
|
||||||
itemsList.add(habboItem);
|
|
||||||
|
|
||||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MusicCollector"));
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
|
||||||
itemsList.add(habboItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bot bot = Emulator.getGameEnvironment().getBotManager().createBot(data, type);
|
||||||
|
|
||||||
|
if (bot != null) {
|
||||||
|
bot.setOwnerId(habbo.getClient().getHabbo().getHabboInfo().getId());
|
||||||
|
bot.setOwnerName(habbo.getClient().getHabbo().getHabboInfo().getUsername());
|
||||||
|
bot.needsUpdate(true);
|
||||||
|
Emulator.getThreading().run(bot);
|
||||||
|
habbo.getClient().getHabbo().getInventory().getBotsComponent().addBot(bot);
|
||||||
|
habbo.getClient().sendResponse(new AddBotComposer(bot));
|
||||||
|
|
||||||
|
if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.BOT)) {
|
||||||
|
unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.BOT, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.BOT).add(bot.getId());
|
||||||
|
} else {
|
||||||
|
throw new Exception("Failed to create bot of type: " + type);
|
||||||
|
}
|
||||||
|
} else if (baseItem.getType() == FurnitureType.EFFECT) {
|
||||||
|
int effectId = baseItem.getEffectM();
|
||||||
|
|
||||||
|
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
|
||||||
|
effectId = baseItem.getEffectF();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (effectId > 0) {
|
||||||
|
habbo.getInventory().getEffectsComponent().createEffect(effectId);
|
||||||
|
}
|
||||||
|
} else if (Item.isPet(baseItem)) {
|
||||||
|
String[] data = extradata.split("\n");
|
||||||
|
|
||||||
|
if (data.length < 3) {
|
||||||
|
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pet pet = null;
|
||||||
|
try {
|
||||||
|
pet = Emulator.getGameEnvironment().getPetManager().createPet(baseItem, data[0], data[1], data[2], habbo.getClient());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Emulator.getLogging().logErrorLine(e);
|
||||||
|
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pet == null) {
|
||||||
|
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
habbo.getClient().getHabbo().getInventory().getPetsComponent().addPet(pet);
|
||||||
|
habbo.getClient().sendResponse(new AddPetComposer(pet));
|
||||||
|
habbo.getClient().sendResponse(new PetBoughtNotificationComposer(pet, false));
|
||||||
|
|
||||||
|
AchievementManager.progressAchievement(habbo.getClient().getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLover"));
|
||||||
|
|
||||||
|
if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.PET)) {
|
||||||
|
unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.PET, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.PET).add(pet.getId());
|
||||||
|
} else if (baseItem.getType() == FurnitureType.BADGE) {
|
||||||
|
if (!habbo.getInventory().getBadgesComponent().hasBadge(baseItem.getName())) {
|
||||||
|
if (!badges.contains(baseItem.getName())) {
|
||||||
|
badges.add(baseItem.getName());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
badgeFound = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class) {
|
||||||
|
if (baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class && !habbo.getClient().getHabbo().getInventory().getBadgesComponent().hasBadge(extradata)) {
|
||||||
|
ScripterManager.scripterDetected(habbo.getClient(), Emulator.getTexts().getValue("scripter.warning.catalog.badge_display").replace("%username%", habbo.getClient().getHabbo().getHabboInfo().getUsername()).replace("%badge%", extradata));
|
||||||
|
extradata = "UMAD";
|
||||||
|
}
|
||||||
|
|
||||||
|
extradata = habbo.getClient().getHabbo().getHabboInfo().getUsername() + (char) 9 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR) + (char) 9 + Emulator.getGameEnvironment().getWordFilter().filter(extradata.replace(((char) 9) + "", ""), habbo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (InteractionTeleport.class.isAssignableFrom(baseItem.getInteractionType().getType())) {
|
||||||
|
HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
||||||
|
HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
||||||
|
Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId());
|
||||||
|
itemsList.add(teleportOne);
|
||||||
|
itemsList.add(teleportTwo);
|
||||||
|
} else if (baseItem.getInteractionType().getType() == InteractionHopper.class) {
|
||||||
|
HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
||||||
|
|
||||||
|
Emulator.getGameEnvironment().getItemManager().insertHopper(hopper);
|
||||||
|
|
||||||
|
itemsList.add(hopper);
|
||||||
|
} else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) {
|
||||||
|
int guildId;
|
||||||
|
try {
|
||||||
|
guildId = Integer.parseInt(extradata);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Emulator.getLogging().logErrorLine(e);
|
||||||
|
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
||||||
|
habboItem.setExtradata("");
|
||||||
|
habboItem.needsUpdate(true);
|
||||||
|
|
||||||
|
Emulator.getThreading().run(habboItem);
|
||||||
|
Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId);
|
||||||
|
itemsList.add(habboItem);
|
||||||
|
|
||||||
|
if (baseItem.getName().equals("guild_forum")) {
|
||||||
|
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
||||||
|
if (guild != null) {
|
||||||
|
guild.setForum(true);
|
||||||
|
guild.needsUpdate = true;
|
||||||
|
guild.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (baseItem.getInteractionType().getType() == InteractionMusicDisc.class) {
|
||||||
|
SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(item.getExtradata());
|
||||||
|
|
||||||
|
if (track == null) {
|
||||||
|
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InteractionMusicDisc habboItem = (InteractionMusicDisc) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, habbo.getClient().getHabbo().getHabboInfo().getUsername() + "\n" + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "\n" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "\n" + Calendar.getInstance().get(Calendar.YEAR) + "\n" + track.getLength() + "\n" + track.getName() + "\n" + track.getId());
|
||||||
|
habboItem.needsUpdate(true);
|
||||||
|
|
||||||
|
Emulator.getThreading().run(habboItem);
|
||||||
|
itemsList.add(habboItem);
|
||||||
|
|
||||||
|
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MusicCollector"));
|
||||||
|
} else {
|
||||||
|
HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
||||||
|
itemsList.add(habboItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1305,12 +1271,10 @@ public class CatalogManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (purchasedEvent.itemsList != null)
|
if (purchasedEvent.itemsList != null && !purchasedEvent.itemsList.isEmpty())
|
||||||
{
|
{
|
||||||
habbo.getClient().sendResponse(new AddHabboItemComposer(purchasedEvent.itemsList));
|
|
||||||
habbo.getClient().getHabbo().getInventory().getItemsComponent().addItems(purchasedEvent.itemsList);
|
habbo.getClient().getHabbo().getInventory().getItemsComponent().addItems(purchasedEvent.itemsList);
|
||||||
habbo.getClient().sendResponse(new PurchaseOKComposer(purchasedEvent.catalogItem));
|
unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI, purchasedEvent.itemsList.stream().map(HabboItem::getId).collect(Collectors.toList()));
|
||||||
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
|
||||||
|
|
||||||
Emulator.getPluginManager().fireEvent(new UserCatalogFurnitureBoughtEvent(habbo, item, purchasedEvent.itemsList));
|
Emulator.getPluginManager().fireEvent(new UserCatalogFurnitureBoughtEvent(habbo, item, purchasedEvent.itemsList));
|
||||||
|
|
||||||
@ -1323,6 +1287,10 @@ public class CatalogManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!purchasedEvent.badges.isEmpty() && !unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.BADGE)) {
|
||||||
|
unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.BADGE, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
for (String b : purchasedEvent.badges)
|
for (String b : purchasedEvent.badges)
|
||||||
{
|
{
|
||||||
HabboBadge badge = new HabboBadge(0, b, 0, habbo);
|
HabboBadge badge = new HabboBadge(0, b, 0, habbo);
|
||||||
@ -1334,9 +1302,15 @@ public class CatalogManager
|
|||||||
keys.put("image", "${image.library.url}album1584/" + badge.getCode() + ".gif");
|
keys.put("image", "${image.library.url}album1584/" + badge.getCode() + ".gif");
|
||||||
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
|
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
|
||||||
habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys));
|
habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys));
|
||||||
|
unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.BADGE).add(badge.getId());
|
||||||
}
|
}
|
||||||
habbo.getClient().getHabbo().getHabboStats().addPurchase(purchasedEvent.catalogItem);
|
habbo.getClient().getHabbo().getHabboStats().addPurchase(purchasedEvent.catalogItem);
|
||||||
|
|
||||||
|
habbo.getClient().sendResponse(new AddHabboItemComposer(unseenItems));
|
||||||
|
|
||||||
|
habbo.getClient().sendResponse(new PurchaseOKComposer(purchasedEvent.catalogItem));
|
||||||
|
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
||||||
|
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
Emulator.getLogging().logPacketError(e);
|
Emulator.getLogging().logPacketError(e);
|
||||||
@ -1398,4 +1372,28 @@ public class CatalogManager
|
|||||||
{
|
{
|
||||||
return this.targetOffers.get(offerId);
|
return this.targetOffers.get(offerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int calculateDiscountedPrice(int originalPrice, int amount, CatalogItem item) {
|
||||||
|
if (!CatalogItem.haveOffer(item)) return originalPrice * amount;
|
||||||
|
|
||||||
|
int basicDiscount = amount / DiscountComposer.DISCOUNT_BATCH_SIZE;
|
||||||
|
|
||||||
|
int bonusDiscount = 0;
|
||||||
|
if (basicDiscount >= DiscountComposer.MINIMUM_DISCOUNTS_FOR_BONUS) {
|
||||||
|
if (amount % DiscountComposer.DISCOUNT_BATCH_SIZE == DiscountComposer.DISCOUNT_BATCH_SIZE - 1) {
|
||||||
|
bonusDiscount = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bonusDiscount += basicDiscount - DiscountComposer.MINIMUM_DISCOUNTS_FOR_BONUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int additionalDiscounts = 0;
|
||||||
|
for (int threshold : DiscountComposer.ADDITIONAL_DISCOUNT_THRESHOLDS) {
|
||||||
|
if (amount >= threshold) additionalDiscounts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalDiscountedItems = (basicDiscount * DiscountComposer.DISCOUNT_AMOUNT_PER_BATCH) + bonusDiscount + additionalDiscounts;
|
||||||
|
|
||||||
|
return Math.max(0, originalPrice * (amount - totalDiscountedItems));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,8 +132,8 @@ public class MarketPlace
|
|||||||
|
|
||||||
|
|
||||||
public static List<MarketPlaceOffer> getOffers(int minPrice, int maxPrice, String search, int sort) {
|
public static List<MarketPlaceOffer> getOffers(int minPrice, int maxPrice, String search, int sort) {
|
||||||
List<MarketPlaceOffer> offers = new ArrayList(10);
|
List<MarketPlaceOffer> offers = new ArrayList<>(10);
|
||||||
String query = "SELECT B.* FROM marketplace_items a INNER JOIN (SELECT b.item_id AS base_item_id, b.limited_data AS ltd_data, marketplace_items.*, AVG(price) as avg, MIN(marketplace_items.price) as minPrice, MAX(marketplace_items.price) as maxPrice, COUNT(*) as number, (SELECT COUNT(*) FROM marketplace_items c INNER JOIN items as items_b ON c.item_id = items_b.id WHERE state = 2 AND items_b.item_id = base_item_id AND DATE(from_unixtime(sold_timestamp)) = CURDATE()) as sold_count_today FROM marketplace_items INNER JOIN items b ON marketplace_items.item_id = b.id WHERE price = (SELECT MIN(e.price) FROM marketplace_items e, items d WHERE e.item_id = d.id AND d.item_id = b.item_id AND e.state = 1 AND e.timestamp > ? GROUP BY d.item_id) AND state = 1 AND timestamp > ?";
|
String query = "SELECT B.* FROM marketplace_items a INNER JOIN (SELECT b.item_id AS base_item_id, b.limited_data AS ltd_data, marketplace_items.*, AVG(price) as avg, MIN(marketplace_items.price) as minPrice, MAX(marketplace_items.price) as maxPrice, COUNT(*) as number, (SELECT COUNT(*) FROM marketplace_items c INNER JOIN items as items_b ON c.item_id = items_b.id WHERE state = 2 AND items_b.item_id = base_item_id AND DATE(from_unixtime(sold_timestamp)) = CURDATE()) as sold_count_today FROM marketplace_items INNER JOIN items b ON marketplace_items.item_id = b.id INNER JOIN items_base bi ON b.item_id = bi.id WHERE price = (SELECT MIN(e.price) FROM marketplace_items e, items d WHERE e.item_id = d.id AND d.item_id = b.item_id AND e.state = 1 AND e.timestamp > ? GROUP BY d.item_id) AND state = 1 AND timestamp > ?";
|
||||||
if (minPrice > 0)
|
if (minPrice > 0)
|
||||||
{
|
{
|
||||||
query += " AND CEIL(price + (price / 100)) >= " + minPrice;
|
query += " AND CEIL(price + (price / 100)) >= " + minPrice;
|
||||||
@ -144,7 +144,7 @@ public class MarketPlace
|
|||||||
}
|
}
|
||||||
if(search.length() > 0)
|
if(search.length() > 0)
|
||||||
{
|
{
|
||||||
query += " AND items_base.public_name LIKE ?";
|
query += " AND bi.public_name LIKE ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
query += " GROUP BY base_item_id, ltd_data";
|
query += " GROUP BY base_item_id, ltd_data";
|
||||||
@ -414,11 +414,14 @@ public class MarketPlace
|
|||||||
RequestOffersEvent.cachedResults.clear();
|
RequestOffersEvent.cachedResults.clear();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
client.sendResponse(new RemoveHabboItemComposer(event.item.getGiftAdjustedId()));
|
||||||
|
client.sendResponse(new InventoryRefreshComposer());
|
||||||
|
|
||||||
|
event.item.setFromGift(false);
|
||||||
|
|
||||||
MarketPlaceOffer offer = new MarketPlaceOffer(event.item, event.price, client.getHabbo());
|
MarketPlaceOffer offer = new MarketPlaceOffer(event.item, event.price, client.getHabbo());
|
||||||
client.getHabbo().getInventory().addMarketplaceOffer(offer);
|
client.getHabbo().getInventory().addMarketplaceOffer(offer);
|
||||||
client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.item);
|
client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.item);
|
||||||
client.sendResponse(new RemoveHabboItemComposer(event.item.getId()));
|
|
||||||
client.sendResponse(new InventoryRefreshComposer());
|
|
||||||
item.setUserId(-1);
|
item.setUserId(-1);
|
||||||
item.needsUpdate(true);
|
item.needsUpdate(true);
|
||||||
Emulator.getThreading().run(item);
|
Emulator.getThreading().run(item);
|
||||||
|
@ -54,7 +54,7 @@ public class BadgeCommand extends Command
|
|||||||
{
|
{
|
||||||
boolean found;
|
boolean found;
|
||||||
|
|
||||||
try (PreparedStatement statement = connection.prepareStatement("SELECT badge_code FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.username = ? AND badge_code = ? LIMIT 1"))
|
try (PreparedStatement statement = connection.prepareStatement("SELECT `badge_code` FROM `users_badges` INNER JOIN `users` ON `users`.`id` = `user_id` WHERE `users`.`username` = ? AND `badge_code` = ? LIMIT 1"))
|
||||||
{
|
{
|
||||||
statement.setString(1, params[1]);
|
statement.setString(1, params[1]);
|
||||||
statement.setString(2, params[2]);
|
statement.setString(2, params[2]);
|
||||||
@ -71,7 +71,7 @@ public class BadgeCommand extends Command
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges VALUES (null, (SELECT id FROM users WHERE username = ? LIMIT 1), 0, ?)"))
|
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (`id`, `user_id`, `slot_id`, `badge_code`) VALUES (null, (SELECT `id` FROM `users` WHERE `username` = ? LIMIT 1), 0, ?)"))
|
||||||
{
|
{
|
||||||
statement.setString(1, params[1]);
|
statement.setString(1, params[1]);
|
||||||
statement.setString(2, params[2]);
|
statement.setString(2, params[2]);
|
||||||
|
@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.permissions.PermissionSetting;
|
|||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
import com.eu.habbo.habbohotel.pets.PetCommand;
|
import com.eu.habbo.habbohotel.pets.PetCommand;
|
||||||
import com.eu.habbo.habbohotel.pets.PetVocalsType;
|
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.Room;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTypingComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTypingComposer;
|
||||||
import com.eu.habbo.plugin.events.users.UserCommandEvent;
|
import com.eu.habbo.plugin.events.users.UserCommandEvent;
|
||||||
@ -267,6 +268,13 @@ public class CommandHandler
|
|||||||
{
|
{
|
||||||
if (command.key.equalsIgnoreCase(s.toString()))
|
if (command.key.equalsIgnoreCase(s.toString()))
|
||||||
{
|
{
|
||||||
|
if(pet instanceof RideablePet && ((RideablePet)pet).getRider() != null) {
|
||||||
|
if(((RideablePet) pet).getRider().getHabboInfo().getId() == gameClient.getHabbo().getHabboInfo().getId()) {
|
||||||
|
((RideablePet) pet).getRider().getHabboInfo().dismountPet();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (command.level <= pet.getLevel())
|
if (command.level <= pet.getLevel())
|
||||||
pet.handleCommand(command, gameClient.getHabbo(), args);
|
pet.handleCommand(command, gameClient.getHabbo(), args);
|
||||||
else
|
else
|
||||||
|
@ -41,7 +41,7 @@ public class GiveRankCommand extends Command
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(params[2]);
|
rank = Emulator.getGameEnvironment().getPermissionsManager().getRankByName(params[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rank != null)
|
if (rank != null)
|
||||||
|
@ -2,8 +2,17 @@ package com.eu.habbo.habbohotel.commands;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
|
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.rooms.RoomUnit;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
||||||
|
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.outgoing.rooms.users.RoomUserRemoveComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
|
||||||
|
import com.eu.habbo.threading.runnables.RoomUnitTeleport;
|
||||||
|
|
||||||
public class InvisibleCommand extends Command
|
public class InvisibleCommand extends Command
|
||||||
{
|
{
|
||||||
@ -17,10 +26,27 @@ public class InvisibleCommand extends Command
|
|||||||
{
|
{
|
||||||
RoomUnit roomUnit = gameClient.getHabbo().getRoomUnit();
|
RoomUnit roomUnit = gameClient.getHabbo().getRoomUnit();
|
||||||
|
|
||||||
|
if (roomUnit.isInvisible()) {
|
||||||
|
RoomLayout roomLayout = roomUnit.getRoom().getLayout();
|
||||||
|
|
||||||
|
new RoomUnitTeleport(roomUnit, roomUnit.getRoom(), roomLayout.getDoorTile().x, roomLayout.getDoorTile().y, roomLayout.getDoorTile().z, 0).run();
|
||||||
|
|
||||||
|
roomUnit.setInvisible(false);
|
||||||
|
roomUnit.setInRoom(true);
|
||||||
|
|
||||||
|
roomUnit.getRoom().sendComposer(new RoomUsersComposer(gameClient.getHabbo()).compose());
|
||||||
|
roomUnit.getRoom().sendComposer(new RoomUserStatusComposer(roomUnit).compose());
|
||||||
|
|
||||||
|
WiredHandler.handle(WiredTriggerType.ENTER_ROOM, roomUnit, roomUnit.getRoom(), null);
|
||||||
|
roomUnit.getRoom().habboEntered(gameClient.getHabbo());
|
||||||
|
|
||||||
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_invisible.updated.back"));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
roomUnit.setInvisible(true);
|
roomUnit.setInvisible(true);
|
||||||
|
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_invisible.updated"));
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_invisible.updated"));
|
||||||
|
|
||||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserRemoveComposer(roomUnit).compose());
|
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserRemoveComposer(roomUnit).compose());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
|||||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
||||||
import com.eu.habbo.messages.outgoing.users.UserDataComposer;
|
import com.eu.habbo.messages.outgoing.users.UserDataComposer;
|
||||||
|
import com.eu.habbo.util.figure.FigureUtil;
|
||||||
|
|
||||||
public class MimicCommand extends Command
|
public class MimicCommand extends Command
|
||||||
{
|
{
|
||||||
@ -18,28 +19,24 @@ public class MimicCommand extends Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(GameClient gameClient, String[] params) throws Exception
|
public boolean handle(GameClient gameClient, String[] params) throws Exception
|
||||||
{
|
{
|
||||||
if(params.length == 2)
|
if (params.length == 2) {
|
||||||
{
|
|
||||||
Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]);
|
Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]);
|
||||||
|
|
||||||
if (habbo == null)
|
if (habbo == null) {
|
||||||
{
|
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.not_found").replace("%user%", ""), RoomChatMessageBubbles.ALERT);
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.not_found").replace("%user%", ""), RoomChatMessageBubbles.ALERT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(habbo == gameClient.getHabbo())
|
if (habbo == gameClient.getHabbo()) {
|
||||||
{
|
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.not_self"), RoomChatMessageBubbles.ALERT);
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.not_self"), RoomChatMessageBubbles.ALERT);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (habbo.hasPermission("acc_not_mimiced") && !gameClient.getHabbo().hasPermission("acc_not_mimiced")) {
|
||||||
else if(habbo.hasPermission("acc_not_mimiced") && !gameClient.getHabbo().hasPermission("acc_not_mimiced"))
|
|
||||||
{
|
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.blocked").replace("%user%", params[1]).replace("%gender_name%", (habbo.getHabboInfo().getGender().equals(HabboGender.M) ? Emulator.getTexts().getValue("gender.him") : Emulator.getTexts().getValue("gender.her"))), RoomChatMessageBubbles.ALERT);
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.blocked").replace("%user%", params[1]).replace("%gender_name%", (habbo.getHabboInfo().getGender().equals(HabboGender.M) ? Emulator.getTexts().getValue("gender.him") : Emulator.getTexts().getValue("gender.her"))), RoomChatMessageBubbles.ALERT);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (!habbo.hasPermission("acc_mimic_unredeemed") && FigureUtil.hasBlacklistedClothing(habbo.getHabboInfo().getLook(), gameClient.getHabbo().getForbiddenClothing())) {
|
||||||
else
|
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(habbo.getHabboInfo().getLook());
|
||||||
gameClient.getHabbo().getHabboInfo().setGender(habbo.getHabboInfo().getGender());
|
gameClient.getHabbo().getHabboInfo().setGender(habbo.getHabboInfo().getGender());
|
||||||
gameClient.sendResponse(new UserDataComposer(gameClient.getHabbo()));
|
gameClient.sendResponse(new UserDataComposer(gameClient.getHabbo()));
|
||||||
|
@ -2,9 +2,11 @@ package com.eu.habbo.habbohotel.commands;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
|
import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer;
|
||||||
import com.eu.habbo.plugin.HabboPlugin;
|
import com.eu.habbo.plugin.HabboPlugin;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class PluginsCommand extends Command
|
public class PluginsCommand extends Command
|
||||||
{
|
{
|
||||||
public PluginsCommand()
|
public PluginsCommand()
|
||||||
@ -22,7 +24,14 @@ public class PluginsCommand extends Command
|
|||||||
message.append("\r").append(plugin.configuration.name).append(" By ").append(plugin.configuration.author);
|
message.append("\r").append(plugin.configuration.name).append(" By ").append(plugin.configuration.author);
|
||||||
}
|
}
|
||||||
|
|
||||||
gameClient.getHabbo().alert(message.toString());
|
|
||||||
|
if (Emulator.getConfig().getBoolean("commands.plugins.oldstyle"))
|
||||||
|
{
|
||||||
|
gameClient.sendResponse(new MessagesForYouComposer(Collections.singletonList(message.toString())));
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
gameClient.getHabbo().alert(message.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ public class TestCommand extends Command
|
|||||||
((MonsterplantPet) pet).setPubliclyBreedable(false);
|
((MonsterplantPet) pet).setPubliclyBreedable(false);
|
||||||
((MonsterplantPet) pet).setCanBreed(true);
|
((MonsterplantPet) pet).setCanBreed(true);
|
||||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetStatusUpdateComposer(pet).compose());
|
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetStatusUpdateComposer(pet).compose());
|
||||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetInformationComposer(pet, gameClient.getHabbo().getHabboInfo().getCurrentRoom()).compose());
|
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetInformationComposer(pet, gameClient.getHabbo().getHabboInfo().getCurrentRoom(), gameClient.getHabbo()).compose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.games;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
|
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses;
|
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins;
|
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins;
|
||||||
@ -24,28 +25,19 @@ import java.util.Map;
|
|||||||
public abstract class Game implements Runnable
|
public abstract class Game implements Runnable
|
||||||
{
|
{
|
||||||
|
|
||||||
public final Class<? extends GameTeam> gameTeamClazz;
|
private final Class<? extends GameTeam> gameTeamClazz;
|
||||||
|
|
||||||
|
|
||||||
public final Class<? extends GamePlayer> gamePlayerClazz;
|
|
||||||
|
|
||||||
|
private final Class<? extends GamePlayer> gamePlayerClazz;
|
||||||
|
|
||||||
protected final THashMap<GameTeamColors, GameTeam> teams = new THashMap<>();
|
protected final THashMap<GameTeamColors, GameTeam> teams = new THashMap<>();
|
||||||
|
|
||||||
|
|
||||||
protected final Room room;
|
protected final Room room;
|
||||||
|
|
||||||
|
private final boolean countsAchievements;
|
||||||
|
|
||||||
protected final boolean countsAchievements;
|
private int startTime;
|
||||||
|
|
||||||
|
private int endTime;
|
||||||
protected int startTime;
|
|
||||||
|
|
||||||
|
|
||||||
protected int pauseTime;
|
|
||||||
|
|
||||||
|
|
||||||
protected int endTime;
|
|
||||||
|
|
||||||
public boolean isRunning;
|
public boolean isRunning;
|
||||||
|
|
||||||
@ -132,6 +124,7 @@ public abstract class Game implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
boolean deleteGame = true;
|
boolean deleteGame = true;
|
||||||
for (GameTeam team : this.teams.values())
|
for (GameTeam team : this.teams.values())
|
||||||
{
|
{
|
||||||
@ -146,6 +139,7 @@ public abstract class Game implements Runnable
|
|||||||
{
|
{
|
||||||
this.room.deleteGame(this);
|
this.room.deleteGame(this);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -170,30 +164,7 @@ public abstract class Game implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onEnd() {
|
||||||
public abstract void run();
|
|
||||||
|
|
||||||
public void pause()
|
|
||||||
{
|
|
||||||
if (this.state.equals(GameState.RUNNING))
|
|
||||||
{
|
|
||||||
this.state = GameState.PAUSED;
|
|
||||||
this.pauseTime = Emulator.getIntUnixTimestamp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unpause()
|
|
||||||
{
|
|
||||||
if (this.state.equals(GameState.PAUSED))
|
|
||||||
{
|
|
||||||
this.state = GameState.RUNNING;
|
|
||||||
this.endTime = Emulator.getIntUnixTimestamp() + (this.endTime - this.pauseTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop()
|
|
||||||
{
|
|
||||||
this.state = GameState.IDLE;
|
|
||||||
this.endTime = Emulator.getIntUnixTimestamp();
|
this.endTime = Emulator.getIntUnixTimestamp();
|
||||||
|
|
||||||
this.saveScores();
|
this.saveScores();
|
||||||
@ -225,18 +196,52 @@ public abstract class Game implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class))
|
||||||
|
{
|
||||||
|
this.room.updateItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void run();
|
||||||
|
|
||||||
|
public void pause()
|
||||||
|
{
|
||||||
|
if (this.state.equals(GameState.RUNNING))
|
||||||
|
{
|
||||||
|
this.state = GameState.PAUSED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unpause()
|
||||||
|
{
|
||||||
|
if (this.state.equals(GameState.PAUSED))
|
||||||
|
{
|
||||||
|
this.state = GameState.RUNNING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop()
|
||||||
|
{
|
||||||
|
this.state = GameState.IDLE;
|
||||||
|
|
||||||
|
boolean gamesActive = false;
|
||||||
|
for(HabboItem timer : room.getFloorItems())
|
||||||
|
{
|
||||||
|
if(timer instanceof InteractionGameTimer) {
|
||||||
|
if(((InteractionGameTimer) timer).isRunning())
|
||||||
|
gamesActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gamesActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(Emulator.getPluginManager().isRegistered(GameStoppedEvent.class, true))
|
if(Emulator.getPluginManager().isRegistered(GameStoppedEvent.class, true))
|
||||||
{
|
{
|
||||||
Event gameStoppedEvent = new GameStoppedEvent(this);
|
Event gameStoppedEvent = new GameStoppedEvent(this);
|
||||||
Emulator.getPluginManager().fireEvent(gameStoppedEvent);
|
Emulator.getPluginManager().fireEvent(gameStoppedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, this.room, new Object[]{this});
|
|
||||||
|
|
||||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class))
|
|
||||||
{
|
|
||||||
this.room.updateItem(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -289,27 +294,33 @@ public abstract class Game implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Room getRoom()
|
public Room getRoom()
|
||||||
{
|
{
|
||||||
return this.room;
|
return this.room;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getStartTime()
|
public int getStartTime()
|
||||||
{
|
{
|
||||||
return this.startTime;
|
return this.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class<? extends GameTeam> getGameTeamClass() {
|
||||||
public int getEndTime()
|
return gameTeamClazz;
|
||||||
{
|
|
||||||
return this.endTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class<? extends GamePlayer> getGamePlayerClass() {
|
||||||
|
return gamePlayerClazz;
|
||||||
|
}
|
||||||
|
|
||||||
public void addTime(int time)
|
public THashMap<GameTeamColors, GameTeam> getTeams() {
|
||||||
{
|
return teams;
|
||||||
this.endTime += time;
|
}
|
||||||
|
|
||||||
|
public boolean isCountsAchievements() {
|
||||||
|
return countsAchievements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameState getState() {
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.games.battlebanzai;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||||
import com.eu.habbo.habbohotel.games.*;
|
import com.eu.habbo.habbohotel.games.*;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere;
|
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile;
|
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTimer;
|
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTimer;
|
||||||
@ -13,13 +14,17 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUserAction;
|
import com.eu.habbo.habbohotel.rooms.RoomUserAction;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
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.outgoing.rooms.users.RoomUserActionComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer;
|
||||||
import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker;
|
import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker;
|
||||||
|
import gnu.trove.impl.hash.THash;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.Map;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
public class BattleBanzaiGame extends Game
|
public class BattleBanzaiGame extends Game
|
||||||
{
|
{
|
||||||
@ -27,15 +32,15 @@ public class BattleBanzaiGame extends Game
|
|||||||
public static final int effectId = 33;
|
public static final int effectId = 33;
|
||||||
|
|
||||||
|
|
||||||
public static final int POINTS_HIJACK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.steal");
|
public static final int POINTS_HIJACK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.steal", 0);
|
||||||
|
|
||||||
|
|
||||||
public static final int POINTS_FILL_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.fill");
|
public static final int POINTS_FILL_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.fill", 0);
|
||||||
|
|
||||||
|
|
||||||
public static final int POINTS_LOCK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.lock");
|
public static final int POINTS_LOCK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.lock", 1);
|
||||||
|
|
||||||
private int timeLeft;
|
private static final ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Emulator.getConfig().getInt("hotel.banzai.fill.threads", 2));
|
||||||
|
|
||||||
private int tileCount;
|
private int tileCount;
|
||||||
|
|
||||||
@ -62,22 +67,10 @@ public class BattleBanzaiGame extends Game
|
|||||||
if(!this.state.equals(GameState.IDLE))
|
if(!this.state.equals(GameState.IDLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int highestTime = 0;
|
|
||||||
this.countDown = 3;
|
this.countDown = 3;
|
||||||
|
|
||||||
this.resetMap();
|
this.resetMap();
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionBattleBanzaiTimer> set : this.room.getRoomSpecialTypes().getBattleBanzaiTimers().entrySet())
|
|
||||||
{
|
|
||||||
if(set.getValue().getExtradata().isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(highestTime < Integer.valueOf(set.getValue().getExtradata()))
|
|
||||||
{
|
|
||||||
highestTime = Integer.valueOf(set.getValue().getExtradata());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (this.teams)
|
synchronized (this.teams)
|
||||||
{
|
{
|
||||||
for (GameTeam t : this.teams.values())
|
for (GameTeam t : this.teams.values())
|
||||||
@ -92,13 +85,6 @@ public class BattleBanzaiGame extends Game
|
|||||||
this.room.updateItemState(item);
|
this.room.updateItemState(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.timeLeft = highestTime;
|
|
||||||
|
|
||||||
if (this.timeLeft == 0)
|
|
||||||
{
|
|
||||||
this.timeLeft = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,99 +136,50 @@ public class BattleBanzaiGame extends Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.timeLeft > 0)
|
Emulator.getThreading().run(this, 1000);
|
||||||
|
|
||||||
|
if (this.state.equals(GameState.PAUSED)) return;
|
||||||
|
|
||||||
|
int total = 0;
|
||||||
|
synchronized (this.lockedTiles)
|
||||||
{
|
{
|
||||||
Emulator.getThreading().run(this, 1000);
|
for (Map.Entry<GameTeamColors, THashSet<HabboItem>> set : this.lockedTiles.entrySet())
|
||||||
|
|
||||||
if (this.state.equals(GameState.PAUSED)) return;
|
|
||||||
|
|
||||||
this.timeLeft--;
|
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionBattleBanzaiTimer> set : this.room.getRoomSpecialTypes().getBattleBanzaiTimers().entrySet())
|
|
||||||
{
|
{
|
||||||
set.getValue().setExtradata(this.timeLeft + "");
|
total += set.getValue().size();
|
||||||
this.room.updateItemState(set.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
int total = 0;
|
|
||||||
synchronized (this.lockedTiles)
|
|
||||||
{
|
|
||||||
for (Map.Entry<GameTeamColors, THashSet<HabboItem>> set : this.lockedTiles.entrySet())
|
|
||||||
{
|
|
||||||
total += set.getValue().size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GameTeam highestScore = null;
|
|
||||||
|
|
||||||
synchronized (this.teams)
|
|
||||||
{
|
|
||||||
for (Map.Entry<GameTeamColors, GameTeam> set : this.teams.entrySet())
|
|
||||||
{
|
|
||||||
if (highestScore == null || highestScore.getTotalScore() < set.getValue().getTotalScore())
|
|
||||||
{
|
|
||||||
highestScore = set.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(highestScore != null)
|
|
||||||
{
|
|
||||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class))
|
|
||||||
{
|
|
||||||
item.setExtradata((highestScore.teamColor.type + 3) + "");
|
|
||||||
this.room.updateItemState(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(total >= this.tileCount && this.tileCount != 0)
|
|
||||||
{
|
|
||||||
this.timeLeft = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
GameTeam highestScore = null;
|
||||||
|
|
||||||
|
synchronized (this.teams)
|
||||||
{
|
{
|
||||||
|
for (Map.Entry<GameTeamColors, GameTeam> set : this.teams.entrySet())
|
||||||
GameTeam winningTeam = null;
|
|
||||||
|
|
||||||
for (GameTeam team : this.teams.values())
|
|
||||||
{
|
{
|
||||||
for(GamePlayer player : team.getMembers())
|
if (highestScore == null || highestScore.getTotalScore() < set.getValue().getTotalScore())
|
||||||
{
|
{
|
||||||
if (player.getScore() > 0)
|
highestScore = set.getValue();
|
||||||
{
|
|
||||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer"));
|
|
||||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallQuestCompleted"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore())
|
|
||||||
{
|
|
||||||
winningTeam = team;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (winningTeam != null)
|
if(highestScore != null)
|
||||||
|
{
|
||||||
|
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class))
|
||||||
{
|
{
|
||||||
for (GamePlayer player : winningTeam.getMembers())
|
item.setExtradata((highestScore.teamColor.type + 3) + "");
|
||||||
{
|
this.room.updateItemState(item);
|
||||||
if (player.getScore() > 0)
|
|
||||||
{
|
|
||||||
this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
|
|
||||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class))
|
|
||||||
{
|
|
||||||
item.setExtradata((7 + winningTeam.teamColor.type) + "");
|
|
||||||
this.room.updateItemState(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.stop();
|
|
||||||
|
if(total >= this.tileCount && this.tileCount != 0)
|
||||||
|
{
|
||||||
|
for(InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values())
|
||||||
|
{
|
||||||
|
if(timer.isRunning())
|
||||||
|
timer.setRunning(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
InteractionGameTimer.endGames(room, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -251,13 +188,55 @@ public class BattleBanzaiGame extends Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnd() {
|
||||||
|
GameTeam winningTeam = null;
|
||||||
|
|
||||||
|
for (GameTeam team : this.teams.values())
|
||||||
|
{
|
||||||
|
for(GamePlayer player : team.getMembers())
|
||||||
|
{
|
||||||
|
if (player.getScore() > 0)
|
||||||
|
{
|
||||||
|
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer"));
|
||||||
|
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallQuestCompleted"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore())
|
||||||
|
{
|
||||||
|
winningTeam = team;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (winningTeam != null)
|
||||||
|
{
|
||||||
|
for (GamePlayer player : winningTeam.getMembers())
|
||||||
|
{
|
||||||
|
if (player.getScore() > 0)
|
||||||
|
{
|
||||||
|
this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
|
||||||
|
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class))
|
||||||
|
{
|
||||||
|
item.setExtradata((7 + winningTeam.teamColor.type) + "");
|
||||||
|
this.room.updateItemState(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room));
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onEnd();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop()
|
public void stop()
|
||||||
{
|
{
|
||||||
super.stop();
|
super.stop();
|
||||||
|
|
||||||
this.timeLeft = 0;
|
|
||||||
|
|
||||||
this.refreshGates();
|
this.refreshGates();
|
||||||
|
|
||||||
for (HabboItem tile : this.gameTiles.values())
|
for (HabboItem tile : this.gameTiles.values())
|
||||||
@ -265,7 +244,7 @@ public class BattleBanzaiGame extends Game
|
|||||||
if (tile.getExtradata().equals("1"))
|
if (tile.getExtradata().equals("1"))
|
||||||
{
|
{
|
||||||
tile.setExtradata("0");
|
tile.setExtradata("0");
|
||||||
this.room.updateItemState(tile);
|
this.room.updateItem(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.lockedTiles.clear();
|
this.lockedTiles.clear();
|
||||||
@ -292,24 +271,13 @@ public class BattleBanzaiGame extends Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPositionToGate(GameTeamColors teamColor)
|
|
||||||
{
|
|
||||||
for (InteractionBattleBanzaiGate gate : this.room.getRoomSpecialTypes().getBattleBanzaiGates().values())
|
|
||||||
{
|
|
||||||
if (gate.teamColor != teamColor)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (gate.getExtradata().isEmpty() || gate.getExtradata().equals("0"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
gate.setExtradata(Integer.valueOf(gate.getExtradata()) - 1 + "");
|
|
||||||
this.room.updateItemState(gate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo)
|
public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo)
|
||||||
|
{
|
||||||
|
this.tileLocked(teamColor, item, habbo, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo, boolean doNotCheckFill)
|
||||||
{
|
{
|
||||||
if(item instanceof InteractionBattleBanzaiTile)
|
if(item instanceof InteractionBattleBanzaiTile)
|
||||||
{
|
{
|
||||||
@ -325,8 +293,102 @@ public class BattleBanzaiGame extends Game
|
|||||||
{
|
{
|
||||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallTilesLocked"));
|
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallTilesLocked"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doNotCheckFill) return;
|
||||||
|
|
||||||
|
final int x = item.getX();
|
||||||
|
final int y = item.getY();
|
||||||
|
|
||||||
|
final List<List<RoomTile>> filledAreas = new ArrayList<>();
|
||||||
|
final THashSet<HabboItem> lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor));
|
||||||
|
|
||||||
|
executor.execute(() -> {
|
||||||
|
filledAreas.add(this.floodFill(x, y - 1, lockedTiles, new ArrayList<>(), teamColor));
|
||||||
|
filledAreas.add(this.floodFill(x, y + 1, lockedTiles, new ArrayList<>(), teamColor));
|
||||||
|
filledAreas.add(this.floodFill(x - 1, y, lockedTiles, new ArrayList<>(), teamColor));
|
||||||
|
filledAreas.add(this.floodFill(x + 1, y, lockedTiles, new ArrayList<>(), teamColor));
|
||||||
|
|
||||||
|
Optional<List<RoomTile>> largestAreaOfAll = filledAreas.stream().filter(Objects::nonNull).max(Comparator.comparing(List::size));
|
||||||
|
|
||||||
|
if (largestAreaOfAll.isPresent())
|
||||||
|
{
|
||||||
|
for (RoomTile tile: largestAreaOfAll.get())
|
||||||
|
{
|
||||||
|
Optional<HabboItem> tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.x && i.getY() == tile.y && i instanceof InteractionBattleBanzaiTile).findAny();
|
||||||
|
|
||||||
|
tileItem.ifPresent(habboItem -> {
|
||||||
|
this.tileLocked(teamColor, habboItem, habbo, true);
|
||||||
|
|
||||||
|
habboItem.setExtradata((2 + (teamColor.type * 3) + 3) + "");
|
||||||
|
this.room.updateItem(habboItem);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.refreshCounters(teamColor);
|
||||||
|
if (habbo != null)
|
||||||
|
{
|
||||||
|
habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_LOCK_TILE * largestAreaOfAll.get().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<RoomTile> floodFill(int x, int y, THashSet<HabboItem> lockedTiles, List<RoomTile> stack, GameTeamColors color)
|
||||||
|
{
|
||||||
|
if (this.isOutOfBounds(x, y) || this.isForeignLockedTile(x, y, color)) return null;
|
||||||
|
|
||||||
|
RoomTile tile = this.room.getLayout().getTile((short)x, (short)y);
|
||||||
|
|
||||||
|
if (this.hasLockedTileAtCoordinates(x, y, lockedTiles) || stack.contains(tile)) return stack;
|
||||||
|
|
||||||
|
stack.add(tile);
|
||||||
|
|
||||||
|
List<List<RoomTile>> result = new ArrayList<>();
|
||||||
|
result.add(this.floodFill(x, y - 1, lockedTiles, stack, color));
|
||||||
|
result.add(this.floodFill(x, y + 1, lockedTiles, stack, color));
|
||||||
|
result.add(this.floodFill(x - 1, y, lockedTiles, stack, color));
|
||||||
|
result.add(this.floodFill(x + 1, y, lockedTiles, stack, color));
|
||||||
|
|
||||||
|
if (result.contains(null)) return null;
|
||||||
|
|
||||||
|
Optional<List<RoomTile>> biggestArea = result.stream().max(Comparator.comparing(List::size));
|
||||||
|
|
||||||
|
return biggestArea.orElse(null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasLockedTileAtCoordinates(int x, int y, THashSet<HabboItem> lockedTiles)
|
||||||
|
{
|
||||||
|
for (HabboItem item : lockedTiles)
|
||||||
|
{
|
||||||
|
if (item.getX() == x && item.getY() == y) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isOutOfBounds(int x, int y)
|
||||||
|
{
|
||||||
|
for (HabboItem item : this.gameTiles.values())
|
||||||
|
{
|
||||||
|
if (item.getX() == x && item.getY() == y) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isForeignLockedTile(int x, int y, GameTeamColors color)
|
||||||
|
{
|
||||||
|
for (HashMap.Entry<GameTeamColors, THashSet<HabboItem>> lockedTilesForColor : this.lockedTiles.entrySet()) {
|
||||||
|
if (lockedTilesForColor.getKey() == color) continue;
|
||||||
|
|
||||||
|
for (HabboItem item : lockedTilesForColor.getValue()) {
|
||||||
|
if (item.getX() == x && item.getY() == y) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void refreshCounters()
|
public void refreshCounters()
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,8 @@ import com.eu.habbo.habbohotel.games.Game;
|
|||||||
import com.eu.habbo.habbohotel.games.GamePlayer;
|
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
|
||||||
public class BattleBanzaiGameTeam extends GameTeam
|
public class BattleBanzaiGameTeam extends GameTeam
|
||||||
{
|
{
|
||||||
@ -24,14 +26,17 @@ public class BattleBanzaiGameTeam extends GameTeam
|
|||||||
public void removeMember(GamePlayer gamePlayer)
|
public void removeMember(GamePlayer gamePlayer)
|
||||||
{
|
{
|
||||||
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame());
|
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame());
|
||||||
if(game instanceof BattleBanzaiGame)
|
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
|
||||||
{
|
|
||||||
((BattleBanzaiGame) game).addPositionToGate(gamePlayer.getTeamColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
||||||
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
||||||
|
|
||||||
super.removeMember(gamePlayer);
|
super.removeMember(gamePlayer);
|
||||||
|
|
||||||
|
if(room != null && room.getRoomSpecialTypes() != null) {
|
||||||
|
for (InteractionGameGate gate : room.getRoomSpecialTypes().getBattleBanzaiGates().values()) {
|
||||||
|
gate.updateState(game, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze
|
|||||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer;
|
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate;
|
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard;
|
import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectTeleport;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
@ -45,8 +46,6 @@ public class FreezeGame extends Game
|
|||||||
public static int FREEZE_LOOSE_POINTS;
|
public static int FREEZE_LOOSE_POINTS;
|
||||||
public static boolean POWERUP_STACK;
|
public static boolean POWERUP_STACK;
|
||||||
|
|
||||||
private int timeLeft;
|
|
||||||
|
|
||||||
public FreezeGame(Room room)
|
public FreezeGame(Room room)
|
||||||
{
|
{
|
||||||
super(FreezeGameTeam.class, FreezeGamePlayer.class, room, true);
|
super(FreezeGameTeam.class, FreezeGamePlayer.class, room, true);
|
||||||
@ -59,49 +58,13 @@ public class FreezeGame extends Game
|
|||||||
if(this.state == GameState.RUNNING)
|
if(this.state == GameState.RUNNING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int highestTime = 0;
|
|
||||||
|
|
||||||
this.resetMap();
|
this.resetMap();
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionFreezeTimer> set : this.room.getRoomSpecialTypes().getFreezeTimers().entrySet())
|
|
||||||
{
|
|
||||||
if(set.getValue().getExtradata().isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(highestTime < Integer.valueOf(set.getValue().getExtradata()))
|
|
||||||
{
|
|
||||||
highestTime = Integer.valueOf(set.getValue().getExtradata());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (GameTeam t : this.teams.values())
|
for (GameTeam t : this.teams.values())
|
||||||
{
|
{
|
||||||
t.initialise();
|
t.initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.room.getRoomSpecialTypes().hasFreezeExitTile())
|
|
||||||
{
|
|
||||||
for (Habbo habbo : this.room.getHabbos())
|
|
||||||
{
|
|
||||||
if (this.getTeamForHabbo(habbo) == null)
|
|
||||||
{
|
|
||||||
for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation()))
|
|
||||||
{
|
|
||||||
if (item instanceof InteractionFreezeTile)
|
|
||||||
{
|
|
||||||
this.room.teleportHabboToItem(habbo, this.room.getRoomSpecialTypes().getRandomFreezeExitTile());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.timeLeft = highestTime;
|
|
||||||
|
|
||||||
if (this.timeLeft == 0)
|
|
||||||
{
|
|
||||||
this.timeLeft = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,22 +80,6 @@ public class FreezeGame extends Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void placebackHelmet(GameTeamColors teamColor)
|
|
||||||
{
|
|
||||||
for (InteractionFreezeGate gate : this.room.getRoomSpecialTypes().getFreezeGates().values())
|
|
||||||
{
|
|
||||||
if (gate.teamColor != teamColor)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (gate.getExtradata().isEmpty() || gate.getExtradata().equals("0"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
gate.setExtradata(Integer.valueOf(gate.getExtradata()) - 1 + "");
|
|
||||||
this.room.updateItemState(gate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void throwBall(Habbo habbo, InteractionFreezeTile item)
|
public void throwBall(Habbo habbo, InteractionFreezeTile item)
|
||||||
{
|
{
|
||||||
if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass())
|
if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass())
|
||||||
@ -280,9 +227,26 @@ public class FreezeGame extends Game
|
|||||||
|
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
|
if (this.room.getRoomSpecialTypes().hasFreezeExitTile())
|
||||||
|
{
|
||||||
|
for (Habbo habbo : this.room.getHabbos())
|
||||||
|
{
|
||||||
|
if (this.getTeamForHabbo(habbo) == null)
|
||||||
|
{
|
||||||
|
for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation()))
|
||||||
|
{
|
||||||
|
if (item instanceof InteractionFreezeTile)
|
||||||
|
{
|
||||||
|
HabboItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile();
|
||||||
|
WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.refreshGates();
|
this.refreshGates();
|
||||||
|
|
||||||
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, this.room, null);
|
|
||||||
this.setFreezeTileState("1");
|
this.setFreezeTileState("1");
|
||||||
this.run();
|
this.run();
|
||||||
}
|
}
|
||||||
@ -295,50 +259,36 @@ public class FreezeGame extends Game
|
|||||||
if (this.state.equals(GameState.IDLE))
|
if (this.state.equals(GameState.IDLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.timeLeft > 0)
|
Emulator.getThreading().run(this, 1000);
|
||||||
|
|
||||||
|
if (this.state.equals(GameState.PAUSED)) return;
|
||||||
|
|
||||||
|
for (GameTeam team : this.teams.values())
|
||||||
{
|
{
|
||||||
Emulator.getThreading().run(this, 1000);
|
for (GamePlayer player : team.getMembers())
|
||||||
|
|
||||||
if (this.state.equals(GameState.PAUSED)) return;
|
|
||||||
|
|
||||||
this.timeLeft--;
|
|
||||||
|
|
||||||
for (GameTeam team : this.teams.values())
|
|
||||||
{
|
{
|
||||||
for (GamePlayer player : team.getMembers())
|
((FreezeGamePlayer)player).cycle();
|
||||||
{
|
|
||||||
((FreezeGamePlayer)player).cycle();
|
|
||||||
}
|
|
||||||
|
|
||||||
int totalScore = team.getTotalScore();
|
|
||||||
|
|
||||||
THashMap<Integer, InteractionFreezeScoreboard> scoreBoards = this.room.getRoomSpecialTypes().getFreezeScoreboards(team.teamColor);
|
|
||||||
|
|
||||||
for (InteractionFreezeScoreboard scoreboard : scoreBoards.values())
|
|
||||||
{
|
|
||||||
if(scoreboard.getExtradata().isEmpty())
|
|
||||||
{
|
|
||||||
scoreboard.setExtradata("0");
|
|
||||||
}
|
|
||||||
|
|
||||||
int oldScore = Integer.valueOf(scoreboard.getExtradata());
|
|
||||||
|
|
||||||
if(oldScore == totalScore)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
scoreboard.setExtradata(totalScore + "");
|
|
||||||
this.room.updateItemState(scoreboard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionFreezeTimer> set : this.room.getRoomSpecialTypes().getFreezeTimers().entrySet())
|
int totalScore = team.getTotalScore();
|
||||||
|
|
||||||
|
THashMap<Integer, InteractionFreezeScoreboard> scoreBoards = this.room.getRoomSpecialTypes().getFreezeScoreboards(team.teamColor);
|
||||||
|
|
||||||
|
for (InteractionFreezeScoreboard scoreboard : scoreBoards.values())
|
||||||
{
|
{
|
||||||
set.getValue().setExtradata(this.timeLeft + "");
|
if(scoreboard.getExtradata().isEmpty())
|
||||||
this.room.updateItemState(set.getValue());
|
{
|
||||||
|
scoreboard.setExtradata("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
int oldScore = Integer.valueOf(scoreboard.getExtradata());
|
||||||
|
|
||||||
|
if(oldScore == totalScore)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
scoreboard.setExtradata(totalScore + "");
|
||||||
|
this.room.updateItemState(scoreboard);
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
{
|
|
||||||
this.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -352,8 +302,6 @@ public class FreezeGame extends Game
|
|||||||
{
|
{
|
||||||
super.stop();
|
super.stop();
|
||||||
|
|
||||||
this.timeLeft = 0;
|
|
||||||
|
|
||||||
GameTeam winningTeam = null;
|
GameTeam winningTeam = null;
|
||||||
|
|
||||||
for(GameTeam team : this.teams.values())
|
for(GameTeam team : this.teams.values())
|
||||||
|
@ -4,6 +4,8 @@ import com.eu.habbo.habbohotel.games.Game;
|
|||||||
import com.eu.habbo.habbohotel.games.GamePlayer;
|
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
|
||||||
public class FreezeGameTeam extends GameTeam
|
public class FreezeGameTeam extends GameTeam
|
||||||
{
|
{
|
||||||
@ -16,15 +18,18 @@ public class FreezeGameTeam extends GameTeam
|
|||||||
public void removeMember(GamePlayer gamePlayer)
|
public void removeMember(GamePlayer gamePlayer)
|
||||||
{
|
{
|
||||||
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
|
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
|
||||||
if(game instanceof FreezeGame)
|
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
|
||||||
{
|
|
||||||
((FreezeGame) game).placebackHelmet(gamePlayer.getTeamColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
|
||||||
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
|
||||||
|
|
||||||
super.removeMember(gamePlayer);
|
super.removeMember(gamePlayer);
|
||||||
|
|
||||||
|
if(room != null && room.getRoomSpecialTypes() != null) {
|
||||||
|
for (InteractionGameGate gate : room.getRoomSpecialTypes().getFreezeGates().values()) {
|
||||||
|
gate.updateState(game, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,51 +14,19 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class WiredGame extends Game
|
public class WiredGame extends Game
|
||||||
{
|
{
|
||||||
private int timeLeft = 30;
|
|
||||||
public WiredGame(Room room)
|
public WiredGame(Room room)
|
||||||
{
|
{
|
||||||
super(GameTeam.class, GamePlayer.class, room , false);
|
super(GameTeam.class, GamePlayer.class, room , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialise()
|
public void initialise() {
|
||||||
{
|
|
||||||
for (Map.Entry<Integer, InteractionGameTimer> set : this.room.getRoomSpecialTypes().getGameTimers().entrySet())
|
|
||||||
{
|
|
||||||
if(set.getValue().getExtradata().isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(this.timeLeft < Integer.valueOf(set.getValue().getExtradata()))
|
|
||||||
{
|
|
||||||
this.timeLeft = Integer.valueOf(set.getValue().getExtradata());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.timeLeft <= 30)
|
|
||||||
{
|
|
||||||
this.timeLeft = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
if (this.timeLeft > 0)
|
|
||||||
{
|
|
||||||
Emulator.getThreading().run(this, 1000);
|
|
||||||
this.timeLeft--;
|
|
||||||
for (Map.Entry<Integer, InteractionGameTimer> set : this.room.getRoomSpecialTypes().getGameTimers().entrySet())
|
|
||||||
{
|
|
||||||
set.getValue().setExtradata(this.timeLeft + "");
|
|
||||||
this.room.updateItemState(set.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,7 @@ public class Guild implements Runnable
|
|||||||
private int roomId;
|
private int roomId;
|
||||||
private String roomName;
|
private String roomName;
|
||||||
private GuildState state;
|
private GuildState state;
|
||||||
private int rights;
|
private boolean rights;
|
||||||
private int colorOne;
|
private int colorOne;
|
||||||
private int colorTwo;
|
private int colorTwo;
|
||||||
private String badge;
|
private String badge;
|
||||||
@ -43,7 +43,7 @@ public class Guild implements Runnable
|
|||||||
this.state = GuildState.values()[set.getInt("state")];
|
this.state = GuildState.values()[set.getInt("state")];
|
||||||
this.roomId = set.getInt("room_id");
|
this.roomId = set.getInt("room_id");
|
||||||
this.roomName = set.getString("room_name");
|
this.roomName = set.getString("room_name");
|
||||||
this.rights = set.getString("rights").equalsIgnoreCase("1") ? 1 : 0;
|
this.rights = set.getString("rights").equalsIgnoreCase("1");
|
||||||
this.colorOne = set.getInt("color_one");
|
this.colorOne = set.getInt("color_one");
|
||||||
this.colorTwo = set.getInt("color_two");
|
this.colorTwo = set.getInt("color_two");
|
||||||
this.badge = set.getString("badge");
|
this.badge = set.getString("badge");
|
||||||
@ -67,7 +67,7 @@ public class Guild implements Runnable
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.state = GuildState.OPEN;
|
this.state = GuildState.OPEN;
|
||||||
this.rights = 0;
|
this.rights = false;
|
||||||
this.colorOne = colorOne;
|
this.colorOne = colorOne;
|
||||||
this.colorTwo = colorTwo;
|
this.colorTwo = colorTwo;
|
||||||
this.badge = badge;
|
this.badge = badge;
|
||||||
@ -114,12 +114,12 @@ public class Guild implements Runnable
|
|||||||
{
|
{
|
||||||
if(this.needsUpdate)
|
if(this.needsUpdate)
|
||||||
{
|
{
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds SET name = ?, description = ?, state = ?, rights = ?, color_one = ?, color_two = ?, badge = ?, read_forum = ?, post_messages = ?, post_threads = ?, mod_forum = ? WHERE id = ?"))
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds SET name = ?, description = ?, state = ?, rights = ?, color_one = ?, color_two = ?, badge = ?, read_forum = ?, post_messages = ?, post_threads = ?, mod_forum = ?, forum = ? WHERE id = ?"))
|
||||||
{
|
{
|
||||||
statement.setString(1, this.name);
|
statement.setString(1, this.name);
|
||||||
statement.setString(2, this.description);
|
statement.setString(2, this.description);
|
||||||
statement.setInt(3, this.state.state);
|
statement.setInt(3, this.state.state);
|
||||||
statement.setString(4, this.rights == 1 ? "1" : "0");
|
statement.setString(4, this.rights ? "1" : "0");
|
||||||
statement.setInt(5, this.colorOne);
|
statement.setInt(5, this.colorOne);
|
||||||
statement.setInt(6, this.colorTwo);
|
statement.setInt(6, this.colorTwo);
|
||||||
statement.setString(7, this.badge);
|
statement.setString(7, this.badge);
|
||||||
@ -127,7 +127,8 @@ public class Guild implements Runnable
|
|||||||
statement.setString(9, this.postMessages.name());
|
statement.setString(9, this.postMessages.name());
|
||||||
statement.setString(10, this.postThreads.name());
|
statement.setString(10, this.postThreads.name());
|
||||||
statement.setString(11, this.modForum.name());
|
statement.setString(11, this.modForum.name());
|
||||||
statement.setInt(12, this.id);
|
statement.setString(12, this.forum ? "1" : "0");
|
||||||
|
statement.setInt(13, this.id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
|
||||||
this.needsUpdate = false;
|
this.needsUpdate = false;
|
||||||
@ -199,12 +200,12 @@ public class Guild implements Runnable
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRights()
|
public boolean getRights()
|
||||||
{
|
{
|
||||||
return this.rights;
|
return this.rights;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRights(int rights)
|
public void setRights(boolean rights)
|
||||||
{
|
{
|
||||||
this.rights = rights;
|
this.rights = rights;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ public class GuildManager {
|
|||||||
|
|
||||||
private final THashMap<GuildPartType, THashMap<Integer, GuildPart>> guildParts;
|
private final THashMap<GuildPartType, THashMap<Integer, GuildPart>> guildParts;
|
||||||
|
|
||||||
|
|
||||||
private final TIntObjectMap<Guild> guilds;
|
private final TIntObjectMap<Guild> guilds;
|
||||||
|
|
||||||
public GuildManager() {
|
public GuildManager() {
|
||||||
@ -40,7 +39,7 @@ public class GuildManager {
|
|||||||
this.guildParts.clear();
|
this.guildParts.clear();
|
||||||
|
|
||||||
for (GuildPartType t : GuildPartType.values()) {
|
for (GuildPartType t : GuildPartType.values()) {
|
||||||
this.guildParts.put(t, new THashMap<Integer, GuildPart>());
|
this.guildParts.put(t, new THashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
|
@ -0,0 +1,478 @@
|
|||||||
|
package com.eu.habbo.habbohotel.guilds.forums;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.messages.ISerialize;
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadBeforeCreated;
|
||||||
|
import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadCreated;
|
||||||
|
import gnu.trove.map.hash.THashMap;
|
||||||
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ForumThread implements Runnable, ISerialize {
|
||||||
|
|
||||||
|
private final int threadId;
|
||||||
|
private final int guildId;
|
||||||
|
private final int openerId;
|
||||||
|
private final String subject;
|
||||||
|
private int postsCount;
|
||||||
|
private final int createdAt;
|
||||||
|
private int updatedAt;
|
||||||
|
private ForumThreadState state;
|
||||||
|
private boolean pinned;
|
||||||
|
private boolean locked;
|
||||||
|
private int adminId;
|
||||||
|
private boolean needsUpdate;
|
||||||
|
private boolean hasCommentsLoaded;
|
||||||
|
private final THashMap<Integer, ForumThreadComment> comments;
|
||||||
|
private int commentIndex;
|
||||||
|
private ForumThreadComment lastComment;
|
||||||
|
|
||||||
|
private final static THashMap<Integer, THashSet<ForumThread>> guildThreadsCache = new THashMap<>();
|
||||||
|
private final static THashMap<Integer, ForumThread> forumThreadsCache = new THashMap<>();
|
||||||
|
|
||||||
|
public ForumThread(int threadId, int guildId, int openerId, String subject, int postsCount, int createdAt, int updatedAt, ForumThreadState state, boolean pinned, boolean locked, int adminId, ForumThreadComment lastComment) {
|
||||||
|
this.threadId = threadId;
|
||||||
|
this.guildId = guildId;
|
||||||
|
this.openerId = openerId;
|
||||||
|
this.subject = subject;
|
||||||
|
this.postsCount = postsCount;
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
this.state = state;
|
||||||
|
this.pinned = pinned;
|
||||||
|
this.locked = locked;
|
||||||
|
this.adminId = adminId;
|
||||||
|
this.lastComment = lastComment;
|
||||||
|
this.comments = new THashMap<>();
|
||||||
|
this.needsUpdate = false;
|
||||||
|
this.hasCommentsLoaded = false;
|
||||||
|
this.commentIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForumThread(ResultSet set) throws SQLException {
|
||||||
|
this.threadId = set.getInt("id");
|
||||||
|
this.guildId = set.getInt("guild_id");
|
||||||
|
this.openerId = set.getInt("opener_id");
|
||||||
|
this.subject = set.getString("subject");
|
||||||
|
this.postsCount = set.getInt("posts_count");
|
||||||
|
this.createdAt = set.getInt("created_at");
|
||||||
|
this.updatedAt = set.getInt("updated_at");
|
||||||
|
this.state = ForumThreadState.fromValue(set.getInt("state"));
|
||||||
|
this.pinned = set.getInt("pinned") > 0;
|
||||||
|
this.locked = set.getInt("locked") > 0;
|
||||||
|
this.adminId = set.getInt("admin_id");
|
||||||
|
this.lastComment = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.lastComment = ForumThreadComment.getById(set.getInt("last_comment_id"));
|
||||||
|
}
|
||||||
|
catch (Exception e) { }
|
||||||
|
|
||||||
|
this.comments = new THashMap<>();
|
||||||
|
this.needsUpdate = false;
|
||||||
|
this.hasCommentsLoaded = false;
|
||||||
|
this.commentIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGuildId() {
|
||||||
|
return guildId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOpenerId() {
|
||||||
|
return openerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubject() {
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPostsCount() {
|
||||||
|
return postsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPostsCount(int postsCount) {
|
||||||
|
this.postsCount = postsCount;
|
||||||
|
this.needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(int updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
this.needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForumThreadState getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(ForumThreadState state) {
|
||||||
|
this.state = state;
|
||||||
|
this.needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPinned() {
|
||||||
|
return pinned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPinned(boolean pinned) {
|
||||||
|
this.pinned = pinned;
|
||||||
|
this.needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLocked() {
|
||||||
|
return locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocked(boolean locked) {
|
||||||
|
this.locked = locked;
|
||||||
|
this.needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAdminId() {
|
||||||
|
return adminId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForumThreadComment getLastComment() {
|
||||||
|
return lastComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastComment(ForumThreadComment lastComment) {
|
||||||
|
this.lastComment = lastComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdminId(int adminId) {
|
||||||
|
this.adminId = adminId;
|
||||||
|
this.needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadComments() {
|
||||||
|
if(this.hasCommentsLoaded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
synchronized (this.comments) {
|
||||||
|
this.hasCommentsLoaded = true;
|
||||||
|
|
||||||
|
commentIndex = 0;
|
||||||
|
this.comments.clear();
|
||||||
|
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM `guilds_forums_comments` WHERE `thread_id` = ? ORDER BY `id`")) {
|
||||||
|
statement.setInt(1, this.threadId);
|
||||||
|
ResultSet set = statement.executeQuery();
|
||||||
|
|
||||||
|
while (set.next()) {
|
||||||
|
ForumThreadComment comment = new ForumThreadComment(set);
|
||||||
|
addComment(comment);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addComment(ForumThreadComment comment) {
|
||||||
|
this.comments.put(comment.getCommentId(), comment);
|
||||||
|
comment.setIndex(this.commentIndex);
|
||||||
|
this.commentIndex++;
|
||||||
|
this.lastComment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<ForumThreadComment> getComments() {
|
||||||
|
if(!this.hasCommentsLoaded) {
|
||||||
|
loadComments();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.comments.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<ForumThreadComment> getComments(int limit, int offset) {
|
||||||
|
if(!this.hasCommentsLoaded) {
|
||||||
|
loadComments();
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (this.comments) {
|
||||||
|
ArrayList<ForumThreadComment> limitedComments = new ArrayList<>();
|
||||||
|
|
||||||
|
List<ForumThreadComment> comments = new ArrayList<>(this.comments.values());
|
||||||
|
comments.sort(Comparator.comparingInt(ForumThreadComment::getIndex));
|
||||||
|
|
||||||
|
Iterator<ForumThreadComment> iterator = comments.iterator();
|
||||||
|
|
||||||
|
for (; offset > 0; --offset) {
|
||||||
|
if (!iterator.hasNext())
|
||||||
|
break;
|
||||||
|
|
||||||
|
iterator.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; limit > 0; --limit) {
|
||||||
|
if (!iterator.hasNext())
|
||||||
|
break;
|
||||||
|
|
||||||
|
limitedComments.add(iterator.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
return limitedComments;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForumThreadComment getCommentById(int commentId) {
|
||||||
|
if(!this.hasCommentsLoaded) {
|
||||||
|
loadComments();
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (this.comments) {
|
||||||
|
return this.comments.get(commentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(ServerMessage message) {
|
||||||
|
Habbo opener = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.openerId);
|
||||||
|
Habbo admin = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.adminId);
|
||||||
|
|
||||||
|
Collection<ForumThreadComment> comments = this.getComments();
|
||||||
|
int lastSeenAt = 0;
|
||||||
|
int totalComments = comments.size();
|
||||||
|
int newComments = 0;
|
||||||
|
ForumThreadComment lastComment = this.lastComment;
|
||||||
|
|
||||||
|
if(lastComment == null) {
|
||||||
|
for (ForumThreadComment comment : comments) {
|
||||||
|
if (comment.getCreatedAt() > lastSeenAt) {
|
||||||
|
newComments++;
|
||||||
|
}
|
||||||
|
if (lastComment == null || lastComment.getCreatedAt() < comment.getCreatedAt()) {
|
||||||
|
lastComment = comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.lastComment = lastComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
Habbo lastAuthor = lastComment != null ? lastComment.getHabbo() : null;
|
||||||
|
|
||||||
|
int nowTimestamp = Emulator.getIntUnixTimestamp();
|
||||||
|
message.appendInt(this.threadId);
|
||||||
|
message.appendInt(this.openerId);
|
||||||
|
message.appendString(opener != null ? opener.getHabboInfo().getUsername() : "");
|
||||||
|
message.appendString(this.subject);
|
||||||
|
message.appendBoolean(this.pinned);
|
||||||
|
message.appendBoolean(this.locked);
|
||||||
|
message.appendInt(nowTimestamp - this.createdAt);
|
||||||
|
message.appendInt(totalComments); // total comments
|
||||||
|
message.appendInt(newComments); // unread comments
|
||||||
|
message.appendInt(1);
|
||||||
|
|
||||||
|
message.appendInt(lastAuthor != null ? lastAuthor.getHabboInfo().getId() : -1);
|
||||||
|
message.appendString(lastAuthor != null ? lastAuthor.getHabboInfo().getUsername() : "");
|
||||||
|
message.appendInt(nowTimestamp - (lastComment != null ? lastComment.getCreatedAt() : this.updatedAt));
|
||||||
|
message.appendByte(this.state.getStateId());
|
||||||
|
message.appendInt(this.adminId);
|
||||||
|
message.appendString(admin != null ? admin.getHabboInfo().getUsername() : "");
|
||||||
|
message.appendInt(this.threadId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(!this.needsUpdate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE `guilds_forums_threads` SET `posts_count` = ?, `updated_at` = ?, `state` = ?, `pinned` = ?, `locked` = ?, `admin_id` = ? WHERE `id` = ?"))
|
||||||
|
{
|
||||||
|
statement.setInt(1, this.postsCount);
|
||||||
|
statement.setInt(2, this.updatedAt);
|
||||||
|
statement.setInt(3, this.state.getStateId());
|
||||||
|
statement.setInt(4, this.pinned ? 1 : 0);
|
||||||
|
statement.setInt(5, this.locked ? 1 : 0);
|
||||||
|
statement.setInt(6, this.adminId);
|
||||||
|
statement.setInt(7, this.threadId);
|
||||||
|
statement.execute();
|
||||||
|
|
||||||
|
this.needsUpdate = false;
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ForumThread create(Guild guild, Habbo opener, String subject, String message) throws Exception {
|
||||||
|
ForumThread createdThread = null;
|
||||||
|
|
||||||
|
if(Emulator.getPluginManager().fireEvent(new GuildForumThreadBeforeCreated(guild, opener, subject, message)).isCancelled())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `guilds_forums_threads`(`guild_id`, `opener_id`, `subject`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS))
|
||||||
|
{
|
||||||
|
int timestamp = Emulator.getIntUnixTimestamp();
|
||||||
|
|
||||||
|
statement.setInt(1, guild.getId());
|
||||||
|
statement.setInt(2, opener.getHabboInfo().getId());
|
||||||
|
statement.setString(3, subject);
|
||||||
|
statement.setInt(4, timestamp);
|
||||||
|
statement.setInt(5, timestamp);
|
||||||
|
|
||||||
|
if(statement.executeUpdate() < 1)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ResultSet set = statement.getGeneratedKeys();
|
||||||
|
if(set.next()) {
|
||||||
|
int threadId = set.getInt(1);
|
||||||
|
createdThread = new ForumThread(threadId, guild.getId(), opener.getHabboInfo().getId(), subject, 0, timestamp, timestamp, ForumThreadState.OPEN, false, false, 0, null);
|
||||||
|
cacheThread(createdThread);
|
||||||
|
|
||||||
|
ForumThreadComment comment = ForumThreadComment.create(createdThread, opener, message);
|
||||||
|
createdThread.addComment(comment);
|
||||||
|
|
||||||
|
Emulator.getPluginManager().fireEvent(new GuildForumThreadCreated(createdThread));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return createdThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static THashSet<ForumThread> getByGuildId(int guildId) throws SQLException {
|
||||||
|
THashSet<ForumThread> threads = null;
|
||||||
|
|
||||||
|
if(guildThreadsCache.containsKey(guildId)) {
|
||||||
|
guildThreadsCache.get(guildId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(threads != null)
|
||||||
|
return threads;
|
||||||
|
|
||||||
|
threads = new THashSet<ForumThread>();
|
||||||
|
|
||||||
|
guildThreadsCache.put(guildId, threads);
|
||||||
|
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT A.*, B.`id` AS `last_comment_id` " +
|
||||||
|
"FROM guilds_forums_threads A " +
|
||||||
|
"JOIN (" +
|
||||||
|
"SELECT * " +
|
||||||
|
"FROM `guilds_forums_comments` " +
|
||||||
|
"WHERE `id` IN (" +
|
||||||
|
"SELECT MAX(id) " +
|
||||||
|
"FROM `guilds_forums_comments` B " +
|
||||||
|
"GROUP BY `thread_id` " +
|
||||||
|
"ORDER BY B.`id` ASC " +
|
||||||
|
") " +
|
||||||
|
"ORDER BY `id` DESC " +
|
||||||
|
") B ON A.`id` = B.`thread_id` " +
|
||||||
|
"WHERE A.`guild_id` = ? " +
|
||||||
|
"ORDER BY A.`pinned` DESC, B.`created_at` DESC "
|
||||||
|
))
|
||||||
|
{
|
||||||
|
statement.setInt(1, guildId);
|
||||||
|
ResultSet set = statement.executeQuery();
|
||||||
|
|
||||||
|
while(set.next()) {
|
||||||
|
ForumThread thread = new ForumThread(set);
|
||||||
|
synchronized (threads) {
|
||||||
|
threads.add(thread);
|
||||||
|
}
|
||||||
|
cacheThread(thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return threads;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ForumThread getById(int threadId) throws SQLException {
|
||||||
|
ForumThread foundThread = forumThreadsCache.get(threadId);
|
||||||
|
|
||||||
|
if(foundThread != null)
|
||||||
|
return foundThread;
|
||||||
|
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(
|
||||||
|
"SELECT A.*, B.`id` AS `last_comment_id` " +
|
||||||
|
"FROM guilds_forums_threads A " +
|
||||||
|
"JOIN (" +
|
||||||
|
"SELECT * " +
|
||||||
|
"FROM `guilds_forums_comments` " +
|
||||||
|
"WHERE `id` IN (" +
|
||||||
|
"SELECT MAX(id) " +
|
||||||
|
"FROM `guilds_forums_comments` B " +
|
||||||
|
"GROUP BY `thread_id` " +
|
||||||
|
"ORDER BY B.`id` ASC " +
|
||||||
|
") " +
|
||||||
|
"ORDER BY `id` DESC " +
|
||||||
|
") B ON A.`id` = B.`thread_id` " +
|
||||||
|
"WHERE A.`id` = ? " +
|
||||||
|
"ORDER BY A.`pinned` DESC, B.`created_at` DESC " +
|
||||||
|
"LIMIT 1"
|
||||||
|
))
|
||||||
|
{
|
||||||
|
statement.setInt(1, threadId);
|
||||||
|
ResultSet set = statement.executeQuery();
|
||||||
|
|
||||||
|
while(set.next()) {
|
||||||
|
foundThread = new ForumThread(set);
|
||||||
|
cacheThread(foundThread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return foundThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void cacheThread(ForumThread thread) {
|
||||||
|
synchronized (forumThreadsCache) {
|
||||||
|
forumThreadsCache.put(thread.threadId, thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
THashSet<ForumThread> guildThreads = guildThreadsCache.get(thread.guildId);
|
||||||
|
|
||||||
|
if(guildThreads == null) {
|
||||||
|
guildThreads = new THashSet<>();
|
||||||
|
synchronized (forumThreadsCache) {
|
||||||
|
guildThreadsCache.put(thread.guildId, guildThreads);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (guildThreads) {
|
||||||
|
guildThreads.add(thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearCache() {
|
||||||
|
for(THashSet<ForumThread> threads : guildThreadsCache.values()) {
|
||||||
|
for(ForumThread thread : threads) {
|
||||||
|
thread.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (forumThreadsCache) {
|
||||||
|
forumThreadsCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (guildThreadsCache) {
|
||||||
|
guildThreadsCache.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,214 @@
|
|||||||
|
package com.eu.habbo.habbohotel.guilds.forums;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboInfo;
|
||||||
|
import com.eu.habbo.messages.ISerialize;
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadCommentBeforeCreated;
|
||||||
|
import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadCommentCreated;
|
||||||
|
import gnu.trove.map.hash.THashMap;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
|
||||||
|
public class ForumThreadComment implements Runnable, ISerialize {
|
||||||
|
|
||||||
|
private final int commentId;
|
||||||
|
private final int threadId;
|
||||||
|
private final int userId;
|
||||||
|
private final String message;
|
||||||
|
private final int createdAt;
|
||||||
|
private ForumThreadState state;
|
||||||
|
private int adminId;
|
||||||
|
private int index;
|
||||||
|
private boolean needsUpdate;
|
||||||
|
private static THashMap<Integer, ForumThreadComment> forumCommentsCache = new THashMap<>();
|
||||||
|
|
||||||
|
public ForumThreadComment(int commentId, int threadId, int userId, String message, int createdAt, ForumThreadState state, int adminId) {
|
||||||
|
this.commentId = commentId;
|
||||||
|
this.threadId = threadId;
|
||||||
|
this.userId = userId;
|
||||||
|
this.message = message;
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
this.state = state;
|
||||||
|
this.adminId = adminId;
|
||||||
|
this.index = -1;
|
||||||
|
this.needsUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForumThreadComment(ResultSet set) throws SQLException {
|
||||||
|
this.commentId = set.getInt("id");
|
||||||
|
this.threadId = set.getInt("thread_id");
|
||||||
|
this.userId = set.getInt("user_id");
|
||||||
|
this.message = set.getString("message");
|
||||||
|
this.createdAt = set.getInt("created_at");
|
||||||
|
this.state = ForumThreadState.fromValue(set.getInt("state"));
|
||||||
|
this.adminId = set.getInt("admin_id");
|
||||||
|
this.index = -1;
|
||||||
|
this.needsUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ForumThreadComment getById(int id) {
|
||||||
|
ForumThreadComment foundComment = forumCommentsCache.get(id);
|
||||||
|
|
||||||
|
if(foundComment != null)
|
||||||
|
return foundComment;
|
||||||
|
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM `guilds_forums_comments` WHERE `id` = ? LIMIT 1"))
|
||||||
|
{
|
||||||
|
statement.setInt(1, id);
|
||||||
|
ResultSet set = statement.executeQuery();
|
||||||
|
|
||||||
|
while(set.next()) {
|
||||||
|
foundComment = new ForumThreadComment(set);
|
||||||
|
cacheComment(foundComment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return foundComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void cacheComment(ForumThreadComment foundComment) {
|
||||||
|
forumCommentsCache.put(foundComment.commentId, foundComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearCache() {
|
||||||
|
forumCommentsCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCommentId() {
|
||||||
|
return commentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForumThreadState getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(ForumThreadState state) {
|
||||||
|
this.state = state;
|
||||||
|
this.needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAdminId() {
|
||||||
|
return adminId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdminId(int adminId) {
|
||||||
|
this.adminId = adminId;
|
||||||
|
this.needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndex(int index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Habbo getHabbo() {
|
||||||
|
return Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForumThread getThread() {
|
||||||
|
try {
|
||||||
|
return ForumThread.getById(this.threadId);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(ServerMessage message) {
|
||||||
|
|
||||||
|
HabboInfo habbo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(this.userId);
|
||||||
|
HabboInfo admin = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(this.adminId);
|
||||||
|
|
||||||
|
message.appendInt(this.commentId);
|
||||||
|
message.appendInt(this.index);
|
||||||
|
message.appendInt(this.userId);
|
||||||
|
message.appendString(habbo != null ? habbo.getUsername() : "");
|
||||||
|
message.appendString(habbo != null ? habbo.getLook() : "");
|
||||||
|
message.appendInt(Emulator.getIntUnixTimestamp() - this.createdAt);
|
||||||
|
message.appendString(this.message);
|
||||||
|
message.appendByte(this.state.getStateId());
|
||||||
|
message.appendInt(this.adminId);
|
||||||
|
message.appendString(admin != null ? admin.getUsername() : "");
|
||||||
|
message.appendInt(0); // admin action time ago?
|
||||||
|
message.appendInt(habbo != null ? habbo.getHabboStats().forumPostsCount : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(!this.needsUpdate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments` SET `state` = ?, `admin_id` = ? WHERE `id` = ?;"))
|
||||||
|
{
|
||||||
|
statement.setInt(1, this.state.getStateId());
|
||||||
|
statement.setInt(2, this.adminId);
|
||||||
|
statement.setInt(3, this.commentId);
|
||||||
|
statement.execute();
|
||||||
|
|
||||||
|
this.needsUpdate = false;
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ForumThreadComment create(ForumThread thread, Habbo poster, String message) throws Exception {
|
||||||
|
ForumThreadComment createdComment = null;
|
||||||
|
|
||||||
|
if(Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentBeforeCreated(thread, poster, message)).isCancelled())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `guilds_forums_comments`(`thread_id`, `user_id`, `message`, `created_at`) VALUES (?, ?, ?, ?);", Statement.RETURN_GENERATED_KEYS))
|
||||||
|
{
|
||||||
|
int timestamp = Emulator.getIntUnixTimestamp();
|
||||||
|
|
||||||
|
statement.setInt(1, thread.getThreadId());
|
||||||
|
statement.setInt(2, poster.getHabboInfo().getId());
|
||||||
|
statement.setString(3, message);
|
||||||
|
statement.setInt(4, timestamp);
|
||||||
|
|
||||||
|
if(statement.executeUpdate() < 1)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ResultSet set = statement.getGeneratedKeys();
|
||||||
|
if(set.next()) {
|
||||||
|
int commentId = set.getInt(1);
|
||||||
|
createdComment = new ForumThreadComment(commentId, thread.getThreadId(), poster.getHabboInfo().getId(), message, timestamp, ForumThreadState.OPEN, 0);
|
||||||
|
|
||||||
|
Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentCreated(createdComment));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return createdComment;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.eu.habbo.habbohotel.guilds.forums;
|
||||||
|
|
||||||
|
public enum ForumThreadState {
|
||||||
|
OPEN(0),
|
||||||
|
CLOSED(1),
|
||||||
|
HIDDEN_BY_ADMIN(10),
|
||||||
|
HIDDEN_BY_STAFF(20);
|
||||||
|
|
||||||
|
private int stateId;
|
||||||
|
|
||||||
|
public int getStateId()
|
||||||
|
{
|
||||||
|
return this.stateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
ForumThreadState(int stateId)
|
||||||
|
{
|
||||||
|
this.stateId = stateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ForumThreadState fromValue(int value)
|
||||||
|
{
|
||||||
|
for (ForumThreadState state : ForumThreadState.values())
|
||||||
|
{
|
||||||
|
if (state.stateId == value)
|
||||||
|
{
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CLOSED;
|
||||||
|
}
|
||||||
|
}
|
@ -1,200 +0,0 @@
|
|||||||
package com.eu.habbo.habbohotel.guilds.forums;
|
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
|
||||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
|
||||||
import com.eu.habbo.messages.ISerialize;
|
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
|
||||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
|
||||||
import gnu.trove.procedure.TObjectProcedure;
|
|
||||||
|
|
||||||
import java.sql.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class GuildForum implements ISerialize {
|
|
||||||
private final int guild;
|
|
||||||
|
|
||||||
private int totalThreads;
|
|
||||||
private final TIntObjectHashMap<GuildForumThread> threads;
|
|
||||||
private int lastRequested = Emulator.getIntUnixTimestamp();
|
|
||||||
|
|
||||||
public GuildForum(int guild) {
|
|
||||||
this.guild = guild;
|
|
||||||
|
|
||||||
this.threads = new TIntObjectHashMap<GuildForumThread>();
|
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT author.username as author_name, author.look as look, COALESCE(admin.username, '') as admin_name, guilds_forums.id as thread_id, 0 as row_number, guilds_forums.* FROM guilds_forums " +
|
|
||||||
"INNER JOIN users AS author ON author.id = user_id " +
|
|
||||||
"LEFT JOIN users AS admin ON guilds_forums.admin_id = admin.id " +
|
|
||||||
"WHERE guild_id = ?")) {
|
|
||||||
statement.setInt(1, this.guild);
|
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
|
||||||
while (set.next()) {
|
|
||||||
this.threads.put(set.getInt("id"), new GuildForumThread(set));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Emulator.getLogging().logSQLException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForumComment getLastComment() {
|
|
||||||
if (!this.threads.valueCollection().isEmpty()) {
|
|
||||||
GuildForumThread thread = Collections.max(this.threads.valueCollection(), Comparator.comparing(GuildForumThread::getLastCommentTimestamp));
|
|
||||||
|
|
||||||
if (thread != null && thread.comments.size() > 0) {
|
|
||||||
return thread.comments.get(thread.comments.size() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GuildForumThread> getThreads() {
|
|
||||||
return new ArrayList<>(this.threads.valueCollection());
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GuildForumThread> getThreadsByAuthor(int userId) {
|
|
||||||
return this.threads.valueCollection().stream().filter(p -> p.getAuthorId() == userId).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForumThread getThread(int threadId) {
|
|
||||||
return threads.get(threadId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForumThread createThread(Habbo habbo, String subject, String message) {
|
|
||||||
int timestamp = Emulator.getIntUnixTimestamp();
|
|
||||||
GuildForumThread thread = null;
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO guilds_forums (guild_id, user_id, subject, message, timestamp) VALUES (?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
|
||||||
statement.setInt(1, this.guild);
|
|
||||||
statement.setInt(2, habbo.getClient().getHabbo().getHabboInfo().getId());
|
|
||||||
statement.setString(3, subject);
|
|
||||||
statement.setString(4, message);
|
|
||||||
statement.setInt(5, timestamp);
|
|
||||||
statement.execute();
|
|
||||||
|
|
||||||
try (ResultSet set = statement.getGeneratedKeys()) {
|
|
||||||
if (set.next()) {
|
|
||||||
thread = new GuildForumThread(habbo, set.getInt(1), this.guild, subject, message, timestamp);
|
|
||||||
this.threads.put(set.getInt(1), //Thread id
|
|
||||||
thread);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Emulator.getLogging().logSQLException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return thread;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO:
|
|
||||||
|
|
||||||
|
|
||||||
public void hideThread(int threadId) {
|
|
||||||
this.threads.get(threadId).setState(ThreadState.HIDDEN_BY_ADMIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGuild() {
|
|
||||||
return this.guild;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getLastRequestedTime() {
|
|
||||||
return this.lastRequested;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(ServerMessage message) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void serializeThreads(final ServerMessage message) {
|
|
||||||
synchronized (this.threads) {
|
|
||||||
message.appendInt(this.threads.size());
|
|
||||||
|
|
||||||
this.threads.forEachValue(new TObjectProcedure<GuildForumThread>() {
|
|
||||||
@Override
|
|
||||||
public boolean execute(GuildForumThread thread) {
|
|
||||||
thread.serialize(message);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int threadSize() {
|
|
||||||
synchronized (this.threads) {
|
|
||||||
return this.threads.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateLastRequested() {
|
|
||||||
this.lastRequested = Emulator.getIntUnixTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ThreadState {
|
|
||||||
CLOSED(0),
|
|
||||||
OPEN(1),
|
|
||||||
HIDDEN_BY_ADMIN(10), //DELETED
|
|
||||||
HIDDEN_BY_STAFF(20);
|
|
||||||
|
|
||||||
public final int state;
|
|
||||||
|
|
||||||
ThreadState(int state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ThreadState fromValue(int state) {
|
|
||||||
switch (state) {
|
|
||||||
case 0:
|
|
||||||
return CLOSED;
|
|
||||||
case 1:
|
|
||||||
return OPEN;
|
|
||||||
case 10:
|
|
||||||
return HIDDEN_BY_ADMIN;
|
|
||||||
case 20:
|
|
||||||
return HIDDEN_BY_STAFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
return OPEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void serializeUserForum(ServerMessage response, Habbo habbo) {
|
|
||||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild);
|
|
||||||
GuildForum forum = Emulator.getGameEnvironment().getGuildForumManager().getGuildForum(this.guild);
|
|
||||||
|
|
||||||
Integer amountOfComments = forum.getThreads().stream().map(GuildForumThread::getAmountOfComments).mapToInt(Integer::intValue).sum();
|
|
||||||
|
|
||||||
response.appendInt(guild.getId());
|
|
||||||
|
|
||||||
response.appendString(guild.getName());
|
|
||||||
response.appendString(guild.getDescription());
|
|
||||||
response.appendString(guild.getBadge());
|
|
||||||
|
|
||||||
response.appendInt(0);
|
|
||||||
response.appendInt(0); //Rating
|
|
||||||
response.appendInt(amountOfComments);
|
|
||||||
|
|
||||||
response.appendInt(0); //New Messages
|
|
||||||
|
|
||||||
GuildForumComment comment = this.getLastComment();
|
|
||||||
|
|
||||||
if (comment != null) {
|
|
||||||
response.appendInt(comment.getThreadId());
|
|
||||||
response.appendInt(comment.getUserId());
|
|
||||||
response.appendString(comment.getUserName());
|
|
||||||
response.appendInt(Emulator.getIntUnixTimestamp() - comment.getTimestamp());
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
response.appendInt(-1);
|
|
||||||
response.appendInt(-1);
|
|
||||||
response.appendString("");
|
|
||||||
response.appendInt(0);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,157 +0,0 @@
|
|||||||
package com.eu.habbo.habbohotel.guilds.forums;
|
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
|
||||||
import com.eu.habbo.messages.ISerialize;
|
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class GuildForumComment implements ISerialize, Runnable {
|
|
||||||
private int id;
|
|
||||||
private final int guildId;
|
|
||||||
private final int threadId;
|
|
||||||
private int index = -1;
|
|
||||||
private final int userId;
|
|
||||||
private final String userName;
|
|
||||||
private final String look;
|
|
||||||
private final int timestamp;
|
|
||||||
private final String message;
|
|
||||||
private GuildForum.ThreadState state = GuildForum.ThreadState.OPEN;
|
|
||||||
private int adminId;
|
|
||||||
private String adminName;
|
|
||||||
|
|
||||||
public GuildForumComment(int guildId, int threadId, int userId, String userName, String look, String message) {
|
|
||||||
this.guildId = guildId;
|
|
||||||
this.threadId = threadId;
|
|
||||||
this.userId = userId;
|
|
||||||
this.userName = userName;
|
|
||||||
this.look = look;
|
|
||||||
this.timestamp = Emulator.getIntUnixTimestamp();
|
|
||||||
this.message = message;
|
|
||||||
this.adminName = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForumComment(final ResultSet set, int index, int guildId) throws SQLException {
|
|
||||||
this.id = set.getInt("id");
|
|
||||||
this.guildId = guildId;
|
|
||||||
this.threadId = set.getInt("thread_id");
|
|
||||||
this.index = index;
|
|
||||||
this.userId = set.getInt("user_id");
|
|
||||||
this.userName = set.getString("author_name");
|
|
||||||
this.look = set.getString("look");
|
|
||||||
this.timestamp = set.getInt("timestamp");
|
|
||||||
this.message = set.getString("message");
|
|
||||||
this.state = GuildForum.ThreadState.valueOf(set.getString("state"));
|
|
||||||
this.adminId = set.getInt("admin_id");
|
|
||||||
this.adminName = set.getString("admin_name");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAuthorPostCount() {
|
|
||||||
GuildForum guildForum = Emulator.getGameEnvironment().getGuildForumManager().getGuildForum(this.guildId);
|
|
||||||
|
|
||||||
List<GuildForumComment> matchingObjects = guildForum.getThreads().stream().flatMap(e -> e.getAllComments().stream()).collect(Collectors.toList()).stream().filter(c -> c.getUserId() == this.userId).collect(Collectors.toList());
|
|
||||||
|
|
||||||
return matchingObjects.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(ServerMessage message) {
|
|
||||||
message.appendInt(this.id);
|
|
||||||
message.appendInt(this.index - 1);
|
|
||||||
message.appendInt(this.userId);
|
|
||||||
message.appendString(this.userName);
|
|
||||||
message.appendString(this.look);
|
|
||||||
message.appendInt(Emulator.getIntUnixTimestamp() - this.timestamp);
|
|
||||||
message.appendString(this.message);
|
|
||||||
message.appendByte(this.state.state);
|
|
||||||
message.appendInt(this.adminId);
|
|
||||||
message.appendString(this.adminName);
|
|
||||||
message.appendInt(0);
|
|
||||||
message.appendInt(this.getAuthorPostCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getThreadId() {
|
|
||||||
return this.threadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIndex() {
|
|
||||||
return this.index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIndex(int index) {
|
|
||||||
this.index = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUserId() {
|
|
||||||
return this.userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserName() {
|
|
||||||
return this.userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLook() {
|
|
||||||
return this.look;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTimestamp() {
|
|
||||||
return this.timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return this.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForum.ThreadState getState() {
|
|
||||||
return this.state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(GuildForum.ThreadState state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAdminId() {
|
|
||||||
return this.adminId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdminId(int adminId) {
|
|
||||||
this.adminId = adminId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAdminName() {
|
|
||||||
return this.adminName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdminName(String adminName) {
|
|
||||||
this.adminName = adminName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments SET state = ?, admin_id = ? WHERE id = ?")) {
|
|
||||||
statement.setString(1, this.state.name());
|
|
||||||
statement.setInt(2, this.adminId);
|
|
||||||
statement.setInt(3, this.getId());
|
|
||||||
statement.execute();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Emulator.getLogging().logSQLException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGuildId() {
|
|
||||||
return this.guildId;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,151 +0,0 @@
|
|||||||
package com.eu.habbo.habbohotel.guilds.forums;
|
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
|
||||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
|
||||||
import gnu.trove.TCollections;
|
|
||||||
import gnu.trove.iterator.TIntObjectIterator;
|
|
||||||
import gnu.trove.map.TIntObjectMap;
|
|
||||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class GuildForumManager {
|
|
||||||
private final TIntObjectMap<GuildForum> guildForums;
|
|
||||||
|
|
||||||
public void addGuildForum(int guildId) {
|
|
||||||
GuildForum forum = new GuildForum(guildId);
|
|
||||||
|
|
||||||
this.guildForums.put(guildId, forum);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForumManager() {
|
|
||||||
this.guildForums = TCollections.synchronizedMap(new TIntObjectHashMap<GuildForum>());
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForum getGuildForum(int guildId) {
|
|
||||||
synchronized (this.guildForums) {
|
|
||||||
GuildForum forum = this.guildForums.get(guildId);
|
|
||||||
|
|
||||||
if (forum == null) {
|
|
||||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
|
|
||||||
|
|
||||||
if (guild != null && guild.hasForum()) {
|
|
||||||
|
|
||||||
forum = new GuildForum(guildId);
|
|
||||||
|
|
||||||
this.guildForums.put(guildId, forum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (forum != null) {
|
|
||||||
|
|
||||||
forum.updateLastRequested();
|
|
||||||
|
|
||||||
return forum;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearInactiveForums() {
|
|
||||||
List<Integer> toRemove = new ArrayList<Integer>();
|
|
||||||
TIntObjectIterator<GuildForum> guildForums = this.guildForums.iterator();
|
|
||||||
for (int i = this.guildForums.size(); i-- > 0; ) {
|
|
||||||
try {
|
|
||||||
guildForums.advance();
|
|
||||||
} catch (NoSuchElementException | ConcurrentModificationException e) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (guildForums.value().getLastRequestedTime() < Emulator.getIntUnixTimestamp() - 300) {
|
|
||||||
toRemove.add(guildForums.key());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Integer j : toRemove) {
|
|
||||||
this.guildForums.remove(j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GuildForum> getGuildForums(Habbo habbo) {
|
|
||||||
List<GuildForum> forums = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Integer i : habbo.getHabboStats().guilds) {
|
|
||||||
forums.add(this.getGuildForum(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return forums;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GuildForum> getAllForums() {
|
|
||||||
List<GuildForum> forums = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Guild guild : Emulator.getGameEnvironment().getGuildManager().getAllGuilds()) {
|
|
||||||
if (guild != null && guild.hasForum()) {
|
|
||||||
forums.add(this.getGuildForum(guild.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return forums;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GuildForum> getAllForumsWithPosts() {
|
|
||||||
List<GuildForum> forums = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Guild guild : Emulator.getGameEnvironment().getGuildManager().getAllGuilds()) {
|
|
||||||
if (guild != null && guild.hasForum()) {
|
|
||||||
GuildForum forum = this.getGuildForum(guild.getId());
|
|
||||||
|
|
||||||
if (forum.getLastComment() == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
forums.add(forum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return forums;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Comparator<GuildForum> SORT_ACTIVE = new Comparator<GuildForum>() {
|
|
||||||
@Override
|
|
||||||
public int compare(GuildForum o1, GuildForum o2) {
|
|
||||||
|
|
||||||
if (o2.getLastComment() == null || o2.getLastComment().getTimestamp() <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (o1.getLastComment() == null || o1.getLastComment().getTimestamp() <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return o2.getLastComment().getTimestamp() - o1.getLastComment().getTimestamp();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final Comparator<GuildForum> SORT_VISITED = new Comparator<GuildForum>() {
|
|
||||||
@Override
|
|
||||||
public int compare(GuildForum o1, GuildForum o2) {
|
|
||||||
|
|
||||||
if (o2.getLastRequestedTime() <= 0 || o1.getLastRequestedTime() <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return o2.getLastRequestedTime() - o1.getLastRequestedTime();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public List<GuildForum> getAllForumsByActive() {
|
|
||||||
List<GuildForum> forums = this.getAllForumsWithPosts();
|
|
||||||
|
|
||||||
forums.sort(SORT_ACTIVE);
|
|
||||||
|
|
||||||
return forums;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GuildForum> getAllForumsByVisited() {
|
|
||||||
List<GuildForum> forums = this.getAllForumsWithPosts();
|
|
||||||
|
|
||||||
forums.sort(SORT_VISITED);
|
|
||||||
|
|
||||||
return forums;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package com.eu.habbo.habbohotel.guilds.forums;
|
|
||||||
|
|
||||||
public enum GuildForumState
|
|
||||||
{
|
|
||||||
OPEN(0),
|
|
||||||
CLOSED(1),
|
|
||||||
HIDDEN_BY_ADMIN(10),
|
|
||||||
HIDDEN_BY_STAFF(20);
|
|
||||||
|
|
||||||
private int state;
|
|
||||||
public int getState()
|
|
||||||
{
|
|
||||||
return this.state;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuildForumState(int state)
|
|
||||||
{
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GuildForumState fromValue(int value)
|
|
||||||
{
|
|
||||||
for (GuildForumState state : GuildForumState.values())
|
|
||||||
{
|
|
||||||
if (state.state == value)
|
|
||||||
{
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CLOSED;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,312 +0,0 @@
|
|||||||
package com.eu.habbo.habbohotel.guilds.forums;
|
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
|
||||||
import com.eu.habbo.messages.ISerialize;
|
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
|
||||||
import gnu.trove.map.hash.THashMap;
|
|
||||||
|
|
||||||
import java.sql.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuildForumThread implements ISerialize, Runnable {
|
|
||||||
private final int threadId;
|
|
||||||
private final int guildId;
|
|
||||||
private final int authorId;
|
|
||||||
private final String authorName;
|
|
||||||
private final String subject;
|
|
||||||
private final String message;
|
|
||||||
private GuildForum.ThreadState state;
|
|
||||||
private final int timestamp;
|
|
||||||
private boolean pinned = false;
|
|
||||||
private boolean locked = false;
|
|
||||||
|
|
||||||
private int lastAuthorId = 0;
|
|
||||||
private String lastAuthorName;
|
|
||||||
|
|
||||||
public int getLastCommentTimestamp() {
|
|
||||||
return this.lastCommentTimestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int lastCommentTimestamp = 0;
|
|
||||||
private int adminId;
|
|
||||||
private String adminName = "";
|
|
||||||
|
|
||||||
private int commentsIndex = 1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public final THashMap<Integer, GuildForumComment> comments;
|
|
||||||
|
|
||||||
public GuildForumThread(Habbo habbo, int threadId, int guildId, String subject, String message, int timestamp) {
|
|
||||||
this.threadId = threadId;
|
|
||||||
this.guildId = guildId;
|
|
||||||
this.authorId = habbo.getHabboInfo().getId();
|
|
||||||
this.authorName = habbo.getHabboInfo().getUsername();
|
|
||||||
this.subject = subject;
|
|
||||||
this.message = message;
|
|
||||||
this.state = GuildForum.ThreadState.OPEN;
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
this.lastAuthorId = this.authorId;
|
|
||||||
this.lastAuthorName = this.authorName;
|
|
||||||
this.lastCommentTimestamp = this.timestamp;
|
|
||||||
|
|
||||||
|
|
||||||
this.comments = new THashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public GuildForumThread(ResultSet set) throws SQLException {
|
|
||||||
this.threadId = set.getInt("id");
|
|
||||||
this.guildId = set.getInt("guild_id");
|
|
||||||
this.authorId = set.getInt("user_id");
|
|
||||||
this.authorName = set.getString("author_name");
|
|
||||||
this.subject = set.getString("subject");
|
|
||||||
this.message = set.getString("message");
|
|
||||||
this.state = GuildForum.ThreadState.valueOf(set.getString("state"));
|
|
||||||
this.timestamp = set.getInt("timestamp");
|
|
||||||
this.pinned = set.getString("pinned").equals("1");
|
|
||||||
this.locked = set.getString("locked").equals("1");
|
|
||||||
this.adminId = set.getInt("admin_id");
|
|
||||||
this.adminName = set.getString("admin_name");
|
|
||||||
|
|
||||||
|
|
||||||
this.lastAuthorId = this.authorId;
|
|
||||||
this.lastAuthorName = this.authorName;
|
|
||||||
this.lastCommentTimestamp = this.timestamp;
|
|
||||||
|
|
||||||
this.comments = new THashMap<>();
|
|
||||||
this.comments.put(commentsIndex, new GuildForumComment(set, commentsIndex, guildId));
|
|
||||||
commentsIndex++;
|
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT " +
|
|
||||||
"author.username AS author_name, " +
|
|
||||||
"COALESCE(admin.username, '') as admin_name, " +
|
|
||||||
"author.look, " +
|
|
||||||
"guilds_forums_comments.* " +
|
|
||||||
"FROM guilds_forums_comments " +
|
|
||||||
"INNER JOIN users AS author ON guilds_forums_comments.user_id = author.id " +
|
|
||||||
"LEFT JOIN users AS admin ON guilds_forums_comments.admin_id = admin.id " +
|
|
||||||
"WHERE thread_id = ? " +
|
|
||||||
"ORDER BY id ASC")) {
|
|
||||||
statement.setInt(1, this.threadId);
|
|
||||||
try (ResultSet commentSet = statement.executeQuery()) {
|
|
||||||
while (commentSet.next()) {
|
|
||||||
this.comments.put(commentsIndex, new GuildForumComment(commentSet, commentsIndex, this.guildId));
|
|
||||||
commentsIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Emulator.getLogging().logSQLException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPinned(boolean pinned) {
|
|
||||||
this.pinned = pinned;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocked(boolean locked) {
|
|
||||||
this.locked = locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addComment(GuildForumComment comment) {
|
|
||||||
synchronized (this.comments) {
|
|
||||||
comment.setIndex(commentsIndex);
|
|
||||||
this.comments.put(commentsIndex, comment);
|
|
||||||
commentsIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.lastAuthorId = comment.getUserId();
|
|
||||||
this.lastAuthorName = comment.getUserName();
|
|
||||||
this.lastCommentTimestamp = comment.getTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForumComment addComment(Habbo habbo, String message) {
|
|
||||||
int commentId = -1;
|
|
||||||
|
|
||||||
GuildForumComment comment = new GuildForumComment(this.guildId, this.threadId, habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), habbo.getHabboInfo().getLook(), message);
|
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO guilds_forums_comments (thread_id, user_id, timestamp, message) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
|
||||||
statement.setInt(1, this.threadId);
|
|
||||||
statement.setInt(2, habbo.getHabboInfo().getId());
|
|
||||||
int nowTimestamp = Emulator.getIntUnixTimestamp();
|
|
||||||
statement.setInt(3, nowTimestamp);
|
|
||||||
statement.setString(4, message);
|
|
||||||
statement.execute();
|
|
||||||
try (ResultSet set = statement.getGeneratedKeys()) {
|
|
||||||
if (set.next()) {
|
|
||||||
commentId = set.getInt(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Emulator.getLogging().logSQLException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (commentId >= 0) {
|
|
||||||
comment.setId(commentId);
|
|
||||||
addComment(comment);
|
|
||||||
|
|
||||||
return comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForumComment getCommentById(int id) {
|
|
||||||
synchronized (this.comments) {
|
|
||||||
for(GuildForumComment comment : this.comments.values()) {
|
|
||||||
if(comment.getId() == id) {
|
|
||||||
return comment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForumComment getCommentByIndex(int id) {
|
|
||||||
synchronized (this.comments) {
|
|
||||||
return this.comments.get(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Original Group Forum Code By Claudio and TheGeneral.
|
|
||||||
Rewritten because it was terrible.
|
|
||||||
Credits To Beny.
|
|
||||||
*/
|
|
||||||
public List<GuildForumComment> getComments(int page, int limit) {
|
|
||||||
|
|
||||||
List<GuildForumComment> allComments = new ArrayList(this.comments.values());
|
|
||||||
|
|
||||||
Collections.reverse(allComments);
|
|
||||||
|
|
||||||
List<GuildForumComment> comments = new ArrayList<>();
|
|
||||||
|
|
||||||
int start = page;
|
|
||||||
int end = start + limit;
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
synchronized (this.comments) {
|
|
||||||
for(GuildForumComment comment : allComments) {
|
|
||||||
if(i >= start && i < end) {
|
|
||||||
comments.add(comment);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return comments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<GuildForumComment> getAllComments() {
|
|
||||||
synchronized (this.comments) {
|
|
||||||
return this.comments.values();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAmountOfComments() {
|
|
||||||
synchronized (this.comments) {
|
|
||||||
return this.comments.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return this.threadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGuildId() {
|
|
||||||
return this.guildId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCommentsSize() {
|
|
||||||
return this.comments.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSubject() {
|
|
||||||
return this.subject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getThreadId() {
|
|
||||||
return this.threadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAuthorId() {
|
|
||||||
return this.authorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuthorName() {
|
|
||||||
return this.authorName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return this.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuildForum.ThreadState getState() {
|
|
||||||
return this.state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(GuildForum.ThreadState state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdminId(int adminId) {
|
|
||||||
this.adminId = adminId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdminName(String adminName) {
|
|
||||||
this.adminName = adminName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isPinned() {
|
|
||||||
return pinned;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLocked() {
|
|
||||||
return locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(ServerMessage message) {
|
|
||||||
int nowTimestamp = Emulator.getIntUnixTimestamp();
|
|
||||||
message.appendInt(this.threadId);
|
|
||||||
message.appendInt(this.authorId);
|
|
||||||
message.appendString(this.authorName);
|
|
||||||
message.appendString(this.subject);
|
|
||||||
message.appendBoolean(this.pinned);
|
|
||||||
message.appendBoolean(this.locked);
|
|
||||||
message.appendInt(nowTimestamp - this.timestamp);
|
|
||||||
message.appendInt(this.getCommentsSize());
|
|
||||||
message.appendInt(0);
|
|
||||||
message.appendInt(1);
|
|
||||||
message.appendInt(this.lastAuthorId);
|
|
||||||
message.appendString(this.lastAuthorName);
|
|
||||||
message.appendInt(nowTimestamp - this.lastCommentTimestamp);
|
|
||||||
message.appendByte(this.state.state);
|
|
||||||
message.appendInt(this.adminId);
|
|
||||||
message.appendString(this.adminName);
|
|
||||||
message.appendInt(this.threadId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums SET message = ?, state = ?, pinned = ?, locked = ?, admin_id = ? WHERE id = ?")) {
|
|
||||||
statement.setString(1, this.message);
|
|
||||||
statement.setString(2, this.state.name());
|
|
||||||
statement.setString(3, this.pinned ? "1" : "0");
|
|
||||||
statement.setString(4, this.locked ? "1" : "0");
|
|
||||||
statement.setInt(5, this.adminId);
|
|
||||||
statement.setInt(6, this.getId());
|
|
||||||
statement.execute();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Emulator.getLogging().logSQLException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,6 +17,8 @@ public class CrackableReward
|
|||||||
public final String achievementTick;
|
public final String achievementTick;
|
||||||
public final String achievementCracked;
|
public final String achievementCracked;
|
||||||
public final int requiredEffect;
|
public final int requiredEffect;
|
||||||
|
public final int subscriptionDuration;
|
||||||
|
public final RedeemableSubscriptionType subscriptionType;
|
||||||
|
|
||||||
public CrackableReward(ResultSet set) throws SQLException
|
public CrackableReward(ResultSet set) throws SQLException
|
||||||
{
|
{
|
||||||
@ -25,10 +27,15 @@ public class CrackableReward
|
|||||||
this.achievementTick = set.getString("achievement_tick");
|
this.achievementTick = set.getString("achievement_tick");
|
||||||
this.achievementCracked = set.getString("achievement_cracked");
|
this.achievementCracked = set.getString("achievement_cracked");
|
||||||
this.requiredEffect = set.getInt("required_effect");
|
this.requiredEffect = set.getInt("required_effect");
|
||||||
|
this.subscriptionDuration = set.getInt("subscription_duration");
|
||||||
|
this.subscriptionType = RedeemableSubscriptionType.fromString(set.getString("subscription_type"));
|
||||||
|
|
||||||
|
|
||||||
String[] prizes = set.getString("prizes").split(";");
|
String[] prizes = set.getString("prizes").split(";");
|
||||||
this.prizes = new HashMap<>();
|
this.prizes = new HashMap<>();
|
||||||
|
|
||||||
|
if (set.getString("prizes").isEmpty()) return;
|
||||||
|
|
||||||
this.totalChance = 0;
|
this.totalChance = 0;
|
||||||
for (String prize : prizes)
|
for (String prize : prizes)
|
||||||
{
|
{
|
||||||
@ -59,6 +66,8 @@ public class CrackableReward
|
|||||||
|
|
||||||
public int getRandomReward()
|
public int getRandomReward()
|
||||||
{
|
{
|
||||||
|
if (this.prizes.size() == 0) return 0;
|
||||||
|
|
||||||
int random = Emulator.getRandom().nextInt(this.totalChance);
|
int random = Emulator.getRandom().nextInt(this.totalChance);
|
||||||
|
|
||||||
int notFound = 0;
|
int notFound = 0;
|
||||||
|
@ -175,6 +175,7 @@ public class ItemManager
|
|||||||
this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class));
|
this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class));
|
||||||
this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class));
|
this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class));
|
||||||
this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class));
|
this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class));
|
||||||
|
this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -660,7 +661,7 @@ public class ItemManager
|
|||||||
|
|
||||||
public HabboItem handleOpenRecycleBox(Habbo habbo, HabboItem box)
|
public HabboItem handleOpenRecycleBox(Habbo habbo, HabboItem box)
|
||||||
{
|
{
|
||||||
Emulator.getThreading().run(new QueryDeleteHabboItem(box));
|
Emulator.getThreading().run(new QueryDeleteHabboItem(box.getId()));
|
||||||
HabboItem item = null;
|
HabboItem item = null;
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_presents WHERE item_id = ? LIMIT 1"))
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_presents WHERE item_id = ? LIMIT 1"))
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items;
|
||||||
|
|
||||||
|
public enum RedeemableSubscriptionType {
|
||||||
|
HABBO_CLUB("hc"),
|
||||||
|
BUILDERS_CLUB("bc");
|
||||||
|
|
||||||
|
public final String subscriptionType;
|
||||||
|
|
||||||
|
RedeemableSubscriptionType(String subscriptionType)
|
||||||
|
{
|
||||||
|
this.subscriptionType = subscriptionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RedeemableSubscriptionType fromString(String subscriptionType) {
|
||||||
|
if (subscriptionType == null) return null;
|
||||||
|
|
||||||
|
switch (subscriptionType) {
|
||||||
|
case "hc":
|
||||||
|
return HABBO_CLUB;
|
||||||
|
case "bc":
|
||||||
|
return BUILDERS_CLUB;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
|||||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.messages.outgoing.users.UserClubComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.users.UserPermissionsComposer;
|
||||||
import com.eu.habbo.threading.runnables.CrackableExplode;
|
import com.eu.habbo.threading.runnables.CrackableExplode;
|
||||||
import com.eu.habbo.util.pathfinding.Rotation;
|
import com.eu.habbo.util.pathfinding.Rotation;
|
||||||
|
|
||||||
@ -77,7 +79,7 @@ public class InteractionCrackable extends HabboItem
|
|||||||
if (this.cracked)
|
if (this.cracked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5)
|
if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5)
|
||||||
{
|
{
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())));
|
client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())));
|
||||||
return;
|
return;
|
||||||
@ -129,6 +131,24 @@ public class InteractionCrackable extends HabboItem
|
|||||||
{
|
{
|
||||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementCracked));
|
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementCracked));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rewardData.subscriptionType != null && rewardData.subscriptionDuration > 0) {
|
||||||
|
// 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();
|
||||||
|
break;
|
||||||
|
case BUILDERS_CLUB:
|
||||||
|
habbo.alert("Builders club has not been implemented yet. Sorry!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,6 +187,10 @@ public class InteractionCrackable extends HabboItem
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean userRequiredToBeAdjacent() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void reset(Room room)
|
public void reset(Room room)
|
||||||
{
|
{
|
||||||
this.cracked = false;
|
this.cracked = false;
|
||||||
|
@ -50,6 +50,23 @@ public class InteractionDefault extends HabboItem
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
|
||||||
|
{
|
||||||
|
super.onMove(room, oldLocation, newLocation);
|
||||||
|
|
||||||
|
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!
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ public class InteractionFXBox extends InteractionDefault
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
new QueryDeleteHabboItem(item).run();
|
new QueryDeleteHabboItem(item.getId()).run();
|
||||||
room.sendComposer(new RemoveFloorItemComposer(item).compose());
|
room.sendComposer(new RemoveFloorItemComposer(item).compose());
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
|
@ -35,8 +35,8 @@ public class InteractionHabboClubTeleportTile extends InteractionTeleportTile
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canUseTeleport(GameClient client, Room room)
|
public boolean canUseTeleport(GameClient client, Room room)
|
||||||
{
|
{
|
||||||
return client.getHabbo().getHabboStats().hasActiveClub();
|
return super.canUseTeleport(client, room) && client.getHabbo().getHabboStats().hasActiveClub();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions;
|
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.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -12,7 +14,8 @@ public class InteractionInformationTerminal extends InteractionCustomValues
|
|||||||
public static final THashMap<String, String> defaultValues = new THashMap<String, String>()
|
public static final THashMap<String, String> defaultValues = new THashMap<String, String>()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
this.put("internalLink", "http://arcturus.pw");}
|
this.put("internalLink", "habbopages/chat/commands");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public InteractionInformationTerminal(ResultSet set, Item baseItem) throws SQLException
|
public InteractionInformationTerminal(ResultSet set, Item baseItem) throws SQLException
|
||||||
@ -26,8 +29,11 @@ public class InteractionInformationTerminal extends InteractionCustomValues
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp(Room room)
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||||
{
|
super.onClick(client, room, objects);
|
||||||
this.values.clear();
|
|
||||||
|
if(this.values.containsKey("internalLink")) {
|
||||||
|
client.sendResponse(new NuxAlertComposer(this.values.get("internalLink")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.users.HabboItem;
|
|||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
||||||
import com.eu.habbo.messages.outgoing.users.UserDataComposer;
|
import com.eu.habbo.messages.outgoing.users.UserDataComposer;
|
||||||
|
import com.eu.habbo.util.figure.FigureUtil;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
|||||||
import com.eu.habbo.habbohotel.pets.HorsePet;
|
import com.eu.habbo.habbohotel.pets.HorsePet;
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
|
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||||
@ -67,27 +68,24 @@ public class InteractionNest extends HabboItem
|
|||||||
|
|
||||||
Pet pet = room.getPet(roomUnit);
|
Pet pet = room.getPet(roomUnit);
|
||||||
|
|
||||||
if(pet != null)
|
if(pet == null)
|
||||||
{
|
return;
|
||||||
if(pet instanceof HorsePet)
|
|
||||||
{
|
|
||||||
if(((HorsePet) pet).getRider() != null)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pet.getPetData().haveNest(this))
|
if(pet instanceof RideablePet && ((RideablePet) pet).getRider() != null)
|
||||||
{
|
return;
|
||||||
if (pet.getEnergy() <= 85)
|
|
||||||
{
|
if(!pet.getPetData().haveNest(this))
|
||||||
pet.setTask(PetTasks.NEST);
|
return;
|
||||||
pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY()));
|
|
||||||
pet.getRoomUnit().clearStatus();
|
if(pet.getEnergy() > 85)
|
||||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
return;
|
||||||
pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getX(), this.getY(), false) + "");
|
|
||||||
room.sendComposer(new RoomUserStatusComposer(roomUnit).compose());
|
pet.setTask(PetTasks.NEST);
|
||||||
}
|
pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY()));
|
||||||
}
|
pet.getRoomUnit().clearStatus();
|
||||||
}
|
pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||||
|
pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getX(), this.getY(), false) + "");
|
||||||
|
room.sendComposer(new RoomUserStatusComposer(roomUnit).compose());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions;
|
package com.eu.habbo.habbohotel.items.interactions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
@ -8,13 +9,17 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
|||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemIntStateComposer;
|
import com.eu.habbo.messages.outgoing.rooms.items.ItemIntStateComposer;
|
||||||
|
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class InteractionOneWayGate extends HabboItem
|
public class InteractionOneWayGate extends HabboItem
|
||||||
{
|
{
|
||||||
private int roomUnitID = -1;
|
private boolean walkable = false;
|
||||||
|
|
||||||
public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException
|
public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException
|
||||||
{
|
{
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
@ -28,13 +33,13 @@ public class InteractionOneWayGate extends HabboItem
|
|||||||
@Override
|
@Override
|
||||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects)
|
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects)
|
||||||
{
|
{
|
||||||
return roomUnit.getId() == this.roomUnitID;
|
return this.getBaseItem().allowWalk();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWalkable()
|
public boolean isWalkable()
|
||||||
{
|
{
|
||||||
return this.roomUnitID != -1;
|
return walkable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -65,14 +70,50 @@ public class InteractionOneWayGate extends HabboItem
|
|||||||
|
|
||||||
if (client != null)
|
if (client != null)
|
||||||
{
|
{
|
||||||
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation());
|
RoomTile tileInfront = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation());
|
||||||
RoomTile gatePosition = room.getLayout().getTile(this.getX(), this.getY());
|
if(tileInfront == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (tile != null && tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation()))
|
RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY());
|
||||||
|
if(currentLocation == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RoomUnit unit = client.getHabbo().getRoomUnit();
|
||||||
|
if(unit == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
if (tileInfront.x == unit.getX() && tileInfront.y == unit.getY())
|
||||||
{
|
{
|
||||||
InteractionOneWayGate gate = this;
|
if(!currentLocation.hasUnits())
|
||||||
if (!room.hasHabbosAt(this.getX(), this.getY()) && gate.roomUnitID == -1)
|
|
||||||
{
|
{
|
||||||
|
List<Runnable> onSuccess = new ArrayList<Runnable>();
|
||||||
|
List<Runnable> onFail = new ArrayList<Runnable>();
|
||||||
|
|
||||||
|
onSuccess.add(() -> {
|
||||||
|
unit.setCanLeaveRoomByDoor(false);
|
||||||
|
walkable = this.getBaseItem().allowWalk();
|
||||||
|
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));
|
||||||
|
});
|
||||||
|
|
||||||
|
onFail.add(() -> {
|
||||||
|
unit.setCanLeaveRoomByDoor(true);
|
||||||
|
walkable = this.getBaseItem().allowWalk();
|
||||||
|
room.updateTile(currentLocation);
|
||||||
|
room.sendComposer(new ItemIntStateComposer(this.getId(), 0).compose());
|
||||||
|
unit.removeOverrideTile(currentLocation);
|
||||||
|
});
|
||||||
|
|
||||||
|
walkable = true;
|
||||||
|
room.updateTile(currentLocation);
|
||||||
|
unit.addOverrideTile(currentLocation);
|
||||||
|
unit.setGoalLocation(currentLocation);
|
||||||
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail));
|
||||||
|
room.sendComposer(new ItemIntStateComposer(this.getId(), 1).compose());
|
||||||
|
|
||||||
|
/*
|
||||||
room.scheduledTasks.add(new Runnable()
|
room.scheduledTasks.add(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -80,10 +121,10 @@ public class InteractionOneWayGate extends HabboItem
|
|||||||
{
|
{
|
||||||
gate.roomUnitID = client.getHabbo().getRoomUnit().getId();
|
gate.roomUnitID = client.getHabbo().getRoomUnit().getId();
|
||||||
room.updateTile(gatePosition);
|
room.updateTile(gatePosition);
|
||||||
room.sendComposer(new ItemIntStateComposer(InteractionOneWayGate.this.getId(), 1).compose());
|
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(InteractionOneWayGate.this.getX(), InteractionOneWayGate.this.getY()), InteractionOneWayGate.this.getRotation() + 4));
|
client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(InteractionOneWayGate.this.getX(), InteractionOneWayGate.this.getY()), InteractionOneWayGate.this.getRotation() + 4));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,10 +133,10 @@ public class InteractionOneWayGate extends HabboItem
|
|||||||
private void refresh(Room room)
|
private void refresh(Room room)
|
||||||
{
|
{
|
||||||
this.setExtradata("0");
|
this.setExtradata("0");
|
||||||
this.roomUnitID = -1;
|
|
||||||
room.sendComposer(new ItemIntStateComposer(this.getId(), 0).compose());
|
room.sendComposer(new ItemIntStateComposer(this.getId(), 0).compose());
|
||||||
room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
|
room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp(Room room)
|
public void onPickUp(Room room)
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ public class InteractionPetBreedingNest extends HabboItem
|
|||||||
|
|
||||||
public void breed(Habbo habbo, String name, int petOneId, int petTwoId)
|
public void breed(Habbo habbo, String name, int petOneId, int petTwoId)
|
||||||
{
|
{
|
||||||
Emulator.getThreading().run(new QueryDeleteHabboItem(this));
|
Emulator.getThreading().run(new QueryDeleteHabboItem(this.getId()));
|
||||||
|
|
||||||
this.setExtradata("2");
|
this.setExtradata("2");
|
||||||
habbo.getHabboInfo().getCurrentRoom().updateItem(this);
|
habbo.getHabboInfo().getCurrentRoom().updateItem(this);
|
||||||
|
@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -99,7 +100,17 @@ public class InteractionPressurePlate extends HabboItem
|
|||||||
{
|
{
|
||||||
boolean occupied = false;
|
boolean occupied = false;
|
||||||
|
|
||||||
for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()))
|
if (room == null || room.getLayout() == null || this.getBaseItem() == null) return;
|
||||||
|
|
||||||
|
RoomTile tileAtItem = room.getLayout().getTile(this.getX(), this.getY());
|
||||||
|
|
||||||
|
if (tileAtItem == null) return;
|
||||||
|
|
||||||
|
THashSet<RoomTile> tiles = room.getLayout().getTilesAt(tileAtItem, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
|
||||||
|
|
||||||
|
if (tiles == null) return;
|
||||||
|
|
||||||
|
for (RoomTile tile : tiles)
|
||||||
{
|
{
|
||||||
boolean hasHabbos = room.hasHabbosAt(tile.x, tile.y);
|
boolean hasHabbos = room.hasHabbosAt(tile.x, tile.y);
|
||||||
if (!hasHabbos && this.requiresAllTilesOccupied())
|
if (!hasHabbos && this.requiresAllTilesOccupied())
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
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.RedeemableSubscriptionType;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.messages.outgoing.users.UserClubComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.users.UserPermissionsComposer;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class InteractionRedeemableSubscriptionBox extends InteractionCrackable {
|
||||||
|
public InteractionRedeemableSubscriptionBox(ResultSet set, Item baseItem) throws SQLException {
|
||||||
|
super(set, baseItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InteractionRedeemableSubscriptionBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean userRequiredToBeAdjacent() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ public class InteractionSwitch extends InteractionDefault
|
|||||||
@Override
|
@Override
|
||||||
public boolean canToggle(Habbo habbo, Room room)
|
public boolean canToggle(Habbo habbo, Room room)
|
||||||
{
|
{
|
||||||
return super.canToggle(habbo, room) || RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation());
|
return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,6 +43,9 @@ public class InteractionSwitch extends InteractionDefault
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
||||||
{
|
{
|
||||||
|
if(client == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!this.canToggle(client.getHabbo(), room))
|
if (!this.canToggle(client.getHabbo(), room))
|
||||||
{
|
{
|
||||||
RoomTile closestTile = null;
|
RoomTile closestTile = null;
|
||||||
|
@ -11,25 +11,31 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
|||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemIntStateComposer;
|
import com.eu.habbo.messages.outgoing.rooms.items.ItemIntStateComposer;
|
||||||
|
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||||
import com.eu.habbo.threading.runnables.teleport.TeleportActionOne;
|
import com.eu.habbo.threading.runnables.teleport.TeleportActionOne;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class InteractionTeleport extends HabboItem
|
public class InteractionTeleport extends HabboItem
|
||||||
{
|
{
|
||||||
private int targetId;
|
private int targetId;
|
||||||
private int targetRoomId;
|
private int targetRoomId;
|
||||||
private int roomUnitID = 0;
|
private int roomUnitID = -1;
|
||||||
|
private boolean walkable = false;
|
||||||
|
|
||||||
public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException
|
public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException
|
||||||
{
|
{
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
|
walkable = baseItem.allowWalk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InteractionTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
|
public InteractionTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
|
||||||
{
|
{
|
||||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
|
walkable = item.allowWalk();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,9 +54,87 @@ public class InteractionTeleport extends HabboItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWalkable()
|
public boolean isWalkable() {
|
||||||
{
|
return walkable;
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
private void tryTeleport(GameClient client, Room room) {
|
||||||
|
/*
|
||||||
|
if user is on item, startTeleport
|
||||||
|
else if user is on infront, set state 1 and walk on item
|
||||||
|
else move to infront and interact
|
||||||
|
*/
|
||||||
|
|
||||||
|
Habbo habbo = client.getHabbo();
|
||||||
|
|
||||||
|
if(habbo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RoomUnit unit = habbo.getRoomUnit();
|
||||||
|
|
||||||
|
if(unit == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY());
|
||||||
|
|
||||||
|
if(currentLocation == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation());
|
||||||
|
|
||||||
|
if(!canUseTeleport(client, room))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) {
|
||||||
|
startTeleport(room, habbo);
|
||||||
|
}
|
||||||
|
else if(unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) {
|
||||||
|
// set state 1 and walk on item
|
||||||
|
this.roomUnitID = unit.getId();
|
||||||
|
this.setExtradata("1");
|
||||||
|
room.updateItem(this);
|
||||||
|
unit.setGoalLocation(infrontTile);
|
||||||
|
|
||||||
|
List<Runnable> onSuccess = new ArrayList<Runnable>();
|
||||||
|
List<Runnable> onFail = new ArrayList<Runnable>();
|
||||||
|
|
||||||
|
onSuccess.add(() -> {
|
||||||
|
walkable = this.getBaseItem().allowWalk();
|
||||||
|
room.updateTile(currentLocation);
|
||||||
|
tryTeleport(client, room);
|
||||||
|
unit.removeOverrideTile(currentLocation);
|
||||||
|
unit.setCanLeaveRoomByDoor(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
onFail.add(() -> {
|
||||||
|
walkable = this.getBaseItem().allowWalk();
|
||||||
|
room.updateTile(currentLocation);
|
||||||
|
this.setExtradata("0");
|
||||||
|
room.updateItem(this);
|
||||||
|
this.roomUnitID = -1;
|
||||||
|
unit.removeOverrideTile(currentLocation);
|
||||||
|
unit.setCanLeaveRoomByDoor(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
walkable = true;
|
||||||
|
room.updateTile(currentLocation);
|
||||||
|
unit.addOverrideTile(currentLocation);
|
||||||
|
unit.setGoalLocation(currentLocation);
|
||||||
|
unit.setCanLeaveRoomByDoor(false);
|
||||||
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// walk to teleport and interact
|
||||||
|
List<Runnable> onSuccess = new ArrayList<Runnable>();
|
||||||
|
List<Runnable> onFail = new ArrayList<Runnable>();
|
||||||
|
|
||||||
|
onSuccess.add(() -> {
|
||||||
|
tryTeleport(client, room);
|
||||||
|
});
|
||||||
|
|
||||||
|
unit.setGoalLocation(infrontTile);
|
||||||
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, infrontTile, room, onSuccess, onFail));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -60,54 +144,12 @@ public class InteractionTeleport extends HabboItem
|
|||||||
|
|
||||||
if(room != null && client != null && objects.length <= 1)
|
if(room != null && client != null && objects.length <= 1)
|
||||||
{
|
{
|
||||||
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation());
|
tryTeleport(client, room);
|
||||||
RoomTile teleportPosition = room.getLayout().getTile(this.getX(), this.getY());
|
|
||||||
|
|
||||||
if (tile != null && tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation()))
|
|
||||||
{
|
|
||||||
if (!room.hasHabbosAt(this.getX(), this.getY()) && this.roomUnitID == 0)
|
|
||||||
{
|
|
||||||
room.sendComposer(new ItemIntStateComposer(this.getId(), 1).compose());
|
|
||||||
room.scheduledTasks.add(() -> {
|
|
||||||
if (client.getHabbo().getRoomUnit().isTeleporting) return;
|
|
||||||
this.roomUnitID = client.getHabbo().getRoomUnit().getId();
|
|
||||||
room.updateTile(teleportPosition);
|
|
||||||
client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (teleportPosition.equals(client.getHabbo().getRoomUnit().getCurrentLocation()) && tile != null && tile.state != RoomTileState.BLOCKED && tile.state != RoomTileState.INVALID)
|
|
||||||
{
|
|
||||||
this.startTeleport(room, client.getHabbo());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
|
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
|
|
||||||
{
|
|
||||||
super.onWalkOn(roomUnit, room, objects);
|
|
||||||
|
|
||||||
Habbo habbo = room.getHabbo(roomUnit);
|
|
||||||
|
|
||||||
if (habbo != null && habbo.getRoomUnit().getId() == this.roomUnitID)
|
|
||||||
{
|
|
||||||
if (habbo.getRoomUnit().getGoal().equals(room.getLayout().getTile(this.getX(), this.getY())))
|
|
||||||
{
|
|
||||||
this.startTeleport(room, habbo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
|
|
||||||
{
|
|
||||||
super.onWalkOff(roomUnit, room, objects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -131,23 +173,10 @@ public class InteractionTeleport extends HabboItem
|
|||||||
{
|
{
|
||||||
this.targetId = 0;
|
this.targetId = 0;
|
||||||
this.targetRoomId = 0;
|
this.targetRoomId = 0;
|
||||||
|
this.roomUnitID = -1;
|
||||||
this.setExtradata("0");
|
this.setExtradata("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canUseTeleport(GameClient client, Room room)
|
|
||||||
{
|
|
||||||
if(!this.getExtradata().equals("0"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(client.getHabbo().getRoomUnit().isTeleporting)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (client.getHabbo().getRoomUnit().getCurrentLocation().is(this.getX(), this.getY()))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTargetId()
|
public int getTargetId()
|
||||||
{
|
{
|
||||||
return this.targetId;
|
return this.targetId;
|
||||||
@ -174,17 +203,32 @@ public class InteractionTeleport extends HabboItem
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canUseTeleport(GameClient client, Room room) {
|
||||||
|
|
||||||
|
Habbo habbo = client.getHabbo();
|
||||||
|
|
||||||
|
if(habbo == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
RoomUnit unit = habbo.getRoomUnit();
|
||||||
|
|
||||||
|
if(unit == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(habbo.getHabboInfo().getRiding() != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return this.roomUnitID == -1 || this.roomUnitID == unit.getId();
|
||||||
|
}
|
||||||
|
|
||||||
public void startTeleport(Room room, Habbo habbo)
|
public void startTeleport(Room room, Habbo habbo)
|
||||||
{
|
{
|
||||||
if (this.canUseTeleport(habbo.getClient(), room))
|
if(habbo.getRoomUnit().isTeleporting)
|
||||||
{
|
return;
|
||||||
this.roomUnitID = 0;
|
|
||||||
habbo.getRoomUnit().isTeleporting = true;
|
this.roomUnitID = -1;
|
||||||
//new TeleportInteraction(room, client, this).run();
|
habbo.getRoomUnit().isTeleporting = true;
|
||||||
this.setExtradata("1");
|
room.scheduledTasks.add(new TeleportActionOne(this, room, habbo.getClient()));
|
||||||
room.updateItem(this);
|
|
||||||
room.scheduledTasks.add(new TeleportActionOne(this, room, habbo.getClient()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions;
|
|||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
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.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
|
||||||
@ -27,17 +28,27 @@ public class InteractionTeleportTile extends InteractionTeleport
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWalkable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
|
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
|
||||||
{
|
{
|
||||||
if (roomUnit != null)
|
if (roomUnit != null)
|
||||||
{
|
{
|
||||||
if (roomUnit.getGoal().is(this.getX(), this.getY()) && this.canWalkOn(roomUnit, room, objects))
|
RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY());
|
||||||
|
|
||||||
|
if (roomUnit.getGoal().equals(currentLocation) && this.canWalkOn(roomUnit, room, objects))
|
||||||
{
|
{
|
||||||
Habbo habbo = room.getHabbo(roomUnit);
|
Habbo habbo = room.getHabbo(roomUnit);
|
||||||
|
|
||||||
if (habbo != null)
|
if (habbo != null)
|
||||||
{
|
{
|
||||||
|
if(!canUseTeleport(habbo.getClient(), room))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!habbo.getRoomUnit().isTeleporting)
|
if (!habbo.getRoomUnit().isTeleporting)
|
||||||
{
|
{
|
||||||
this.startTeleport(room, habbo);
|
this.startTeleport(room, habbo);
|
||||||
@ -46,16 +57,4 @@ public class InteractionTeleportTile extends InteractionTeleport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canUseTeleport(GameClient client, Room room)
|
|
||||||
{
|
|
||||||
if(client.getHabbo().getRoomUnit().isTeleporting)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (client.getHabbo().getRoomUnit().getCurrentLocation().is(this.getX(), this.getY()))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ public class InteractionWater extends InteractionDefault
|
|||||||
@Override
|
@Override
|
||||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
|
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
|
||||||
{
|
{
|
||||||
|
super.onMove(room, oldLocation, newLocation);
|
||||||
|
|
||||||
this.recalculate(room);
|
this.recalculate(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public abstract class InteractionWired extends HabboItem
|
|||||||
|
|
||||||
protected long requiredCooldown()
|
protected long requiredCooldown()
|
||||||
{
|
{
|
||||||
return 10L;
|
return 50L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions.games;
|
package com.eu.habbo.habbohotel.items.interactions.games;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.games.Game;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
@ -14,11 +15,13 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem
|
|||||||
public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException
|
public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException
|
||||||
{
|
{
|
||||||
super(set, baseItem, teamColor);
|
super(set, baseItem, teamColor);
|
||||||
|
this.setExtradata("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor)
|
public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor)
|
||||||
{
|
{
|
||||||
super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
|
super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
|
||||||
|
this.setExtradata("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,4 +44,18 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem
|
|||||||
|
|
||||||
super.serializeExtradata(serverMessage);
|
super.serializeExtradata(serverMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateState(Game game, int maxPlayers) {
|
||||||
|
int memberCount = 0;
|
||||||
|
|
||||||
|
if(game.getTeam(this.teamColor) != null) {
|
||||||
|
memberCount = game.getTeam(this.teamColor).getMembers().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(memberCount > maxPlayers) {
|
||||||
|
memberCount = maxPlayers;
|
||||||
|
}
|
||||||
|
this.setExtradata(memberCount + "");
|
||||||
|
game.getRoom().updateItem(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.games.Game;
|
import com.eu.habbo.habbohotel.games.Game;
|
||||||
import com.eu.habbo.habbohotel.games.GameState;
|
import com.eu.habbo.habbohotel.games.GameState;
|
||||||
|
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
|
||||||
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
@ -11,15 +13,22 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
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.messages.ServerMessage;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class InteractionGameTimer extends HabboItem
|
public abstract class InteractionGameTimer extends HabboItem implements Runnable
|
||||||
{
|
{
|
||||||
private int baseTime = 0;
|
private int baseTime = 0;
|
||||||
private int lastToggle = 0;
|
private int timeNow = 0;
|
||||||
|
private boolean isRunning = false;
|
||||||
|
private boolean isPaused = false;
|
||||||
|
|
||||||
public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException
|
public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException
|
||||||
{
|
{
|
||||||
@ -30,6 +39,7 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
if (data.length >= 2)
|
if (data.length >= 2)
|
||||||
{
|
{
|
||||||
this.baseTime = Integer.valueOf(data[1]);
|
this.baseTime = Integer.valueOf(data[1]);
|
||||||
|
this.timeNow = this.baseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.length >= 1)
|
if (data.length >= 1)
|
||||||
@ -43,6 +53,67 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(this.needsUpdate() || this.needsDelete()) {
|
||||||
|
super.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.getRoomId() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||||
|
|
||||||
|
if(room == null || !this.isRunning || this.isPaused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(this.timeNow > 0) {
|
||||||
|
Emulator.getThreading().run(this, 1000);
|
||||||
|
this.timeNow--;
|
||||||
|
room.updateItem(this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.isRunning = false;
|
||||||
|
this.isPaused = false;
|
||||||
|
endGamesIfLastTimer(room);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void endGamesIfLastTimer(Room room) {
|
||||||
|
boolean gamesActive = false;
|
||||||
|
for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
|
||||||
|
if (timer.isRunning())
|
||||||
|
gamesActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gamesActive) {
|
||||||
|
endGames(room);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void endGames(Room room) {
|
||||||
|
endGames(room, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void endGames(Room room, boolean overrideTriggerWired) {
|
||||||
|
|
||||||
|
boolean triggerWired = false;
|
||||||
|
|
||||||
|
//end existing games
|
||||||
|
for (Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
|
||||||
|
Game game = InteractionGameTimer.getOrCreateGame(room, gameClass);
|
||||||
|
if (!game.state.equals(GameState.IDLE)) {
|
||||||
|
triggerWired = true;
|
||||||
|
game.onEnd();
|
||||||
|
game.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(triggerWired) {
|
||||||
|
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp(Room room)
|
public void onPickUp(Room room)
|
||||||
{
|
{
|
||||||
@ -52,8 +123,12 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
@Override
|
@Override
|
||||||
public void onPlace(Room room)
|
public void onPlace(Room room)
|
||||||
{
|
{
|
||||||
this.baseTime = 30;
|
if(this.baseTime == 0) {
|
||||||
this.setExtradata("30");
|
this.baseTime = 30;
|
||||||
|
this.timeNow = this.baseTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setExtradata(this.timeNow + "\t" + this.baseTime);
|
||||||
room.updateItem(this);
|
room.updateItem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +136,7 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
public void serializeExtradata(ServerMessage serverMessage)
|
public void serializeExtradata(ServerMessage serverMessage)
|
||||||
{
|
{
|
||||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
||||||
serverMessage.appendString(this.getExtradata());
|
serverMessage.appendString("" + timeNow);
|
||||||
|
|
||||||
super.serializeExtradata(serverMessage);
|
super.serializeExtradata(serverMessage);
|
||||||
}
|
}
|
||||||
@ -81,65 +156,123 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
|
||||||
{
|
{
|
||||||
if (client != null)
|
|
||||||
{
|
|
||||||
if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (client == null)
|
|
||||||
{
|
|
||||||
int now = Emulator.getIntUnixTimestamp();
|
|
||||||
if (now - this.lastToggle < 3) return;
|
|
||||||
this.lastToggle = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.getExtradata().isEmpty())
|
if(this.getExtradata().isEmpty())
|
||||||
{
|
{
|
||||||
this.setExtradata("0");
|
this.setExtradata("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
Game game = this.getOrCreateGame(room);
|
// if wired triggered it
|
||||||
|
if (objects.length >= 2 && objects[1] instanceof WiredEffectType && !this.isRunning)
|
||||||
if ((objects.length >= 2 && objects[1] instanceof WiredEffectType))
|
|
||||||
{
|
{
|
||||||
if (game == null || !game.isRunning)
|
endGamesIfLastTimer(room);
|
||||||
startGame(room);
|
|
||||||
else if (game.isRunning)
|
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
|
||||||
stopGame(room);
|
Game game = getOrCreateGame(room, gameClass);
|
||||||
|
if(!game.isRunning) {
|
||||||
|
game.initialise();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
this.isRunning = true;
|
||||||
|
room.updateItem(this);
|
||||||
|
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[] { });
|
||||||
|
|
||||||
|
Emulator.getThreading().run(this);
|
||||||
}
|
}
|
||||||
|
else if(client != null)
|
||||||
if(objects.length >= 1 && objects[0] instanceof Integer && client != null)
|
|
||||||
{
|
{
|
||||||
int state = (Integer)objects[0];
|
if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
int state = 1;
|
||||||
|
|
||||||
|
if(objects.length >= 1 && objects[0] instanceof Integer) {
|
||||||
|
state = (Integer) objects[0];
|
||||||
|
}
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
if(this.isRunning) {
|
||||||
this.startGame(room);
|
this.isPaused = !this.isPaused;
|
||||||
|
|
||||||
|
boolean allPaused = this.isPaused;
|
||||||
|
for(InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
|
||||||
|
if(!timer.isPaused)
|
||||||
|
allPaused = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
|
||||||
|
Game game = getOrCreateGame(room, gameClass);
|
||||||
|
if(allPaused) {
|
||||||
|
game.pause();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
game.unpause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.isPaused) {
|
||||||
|
this.isRunning = true;
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
room.updateItem(this);
|
||||||
|
Emulator.getThreading().run(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.isRunning) {
|
||||||
|
endGamesIfLastTimer(room);
|
||||||
|
|
||||||
|
for(Class<? extends Game> gameClass : Emulator.getGameEnvironment().getRoomManager().getGameTypes()) {
|
||||||
|
Game game = getOrCreateGame(room, gameClass);
|
||||||
|
game.initialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[] { });
|
||||||
|
this.isRunning = true;
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
room.updateItem(this);
|
||||||
|
Emulator.getThreading().run(this);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
{
|
if(!this.isRunning) {
|
||||||
this.increaseTimer(room);
|
this.increaseTimer(room);
|
||||||
}
|
return;
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
if(this.isPaused) {
|
||||||
|
this.isPaused = false;
|
||||||
|
this.isRunning = false;
|
||||||
|
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
room.updateItem(this);
|
||||||
|
|
||||||
|
endGamesIfLastTimer(room);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
|
||||||
this.stopGame(room);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
if (game != null && game.state.equals(GameState.IDLE))
|
this.isPaused = false;
|
||||||
{
|
this.isRunning = false;
|
||||||
this.startGame(room);
|
|
||||||
|
timeNow = this.baseTime;
|
||||||
|
room.updateItem(this);
|
||||||
|
|
||||||
|
boolean gamesActive = false;
|
||||||
|
for (InteractionGameTimer timer : room.getRoomSpecialTypes().getGameTimers().values()) {
|
||||||
|
if (timer.isRunning())
|
||||||
|
gamesActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gamesActive) {
|
||||||
|
endGames(room);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,87 +285,29 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Game getOrCreateGame(Room room)
|
public static Game getOrCreateGame(Room room, Class<? extends Game> gameClass)
|
||||||
{
|
{
|
||||||
Game game = (this.getGameType().cast(room.getGame(this.getGameType())));
|
Game game = (gameClass.cast(room.getGame(gameClass)));
|
||||||
|
|
||||||
if (game == null)
|
if (game == null) {
|
||||||
{
|
try {
|
||||||
try
|
game = gameClass.getDeclaredConstructor(Room.class).newInstance(room);
|
||||||
{
|
|
||||||
game = this.getGameType().getDeclaredConstructor(Room.class).newInstance(room);
|
|
||||||
room.addGame(game);
|
room.addGame(game);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
Emulator.getLogging().logErrorLine(e);
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startGame(Room room)
|
|
||||||
{
|
|
||||||
this.needsUpdate(true);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
room.updateItem(this);
|
|
||||||
|
|
||||||
Game game = this.getOrCreateGame(room);
|
|
||||||
|
|
||||||
if (game.state.equals(GameState.IDLE))
|
|
||||||
{
|
|
||||||
this.setExtradata(this.baseTime + "");
|
|
||||||
game.initialise();
|
|
||||||
}
|
|
||||||
else if (game.state.equals(GameState.PAUSED))
|
|
||||||
{
|
|
||||||
game.unpause();
|
|
||||||
}
|
|
||||||
else if (game.state.equals(GameState.RUNNING))
|
|
||||||
{
|
|
||||||
game.pause();
|
|
||||||
}
|
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Emulator.getLogging().logErrorLine(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopGame(Room room)
|
|
||||||
{
|
|
||||||
this.setExtradata(this.baseTime + "");
|
|
||||||
this.needsUpdate(true);
|
|
||||||
Game game = this.getOrCreateGame(room);
|
|
||||||
|
|
||||||
if(game != null && game.state != GameState.IDLE)
|
|
||||||
{
|
|
||||||
this.setExtradata(this.baseTime + "");
|
|
||||||
game.stop();
|
|
||||||
stopGame(room);
|
|
||||||
}
|
|
||||||
|
|
||||||
room.updateItem(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void increaseTimer(Room room)
|
private void increaseTimer(Room room)
|
||||||
{
|
{
|
||||||
Game game = this.getOrCreateGame(room);
|
if(this.isRunning)
|
||||||
|
|
||||||
if (game == null) return;
|
|
||||||
if (game.state.equals(GameState.PAUSED))
|
|
||||||
{
|
|
||||||
stopGame(room);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (game.state.equals(GameState.RUNNING)) return;
|
|
||||||
|
|
||||||
this.needsUpdate(true);
|
this.needsUpdate(true);
|
||||||
|
|
||||||
switch(this.baseTime)
|
switch(this.baseTime)
|
||||||
{
|
{
|
||||||
case 0: this.baseTime = 30; break;
|
case 0: this.baseTime = 30; break;
|
||||||
@ -247,9 +322,9 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
this.baseTime = 30;
|
this.baseTime = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setExtradata(this.baseTime + "");
|
this.timeNow = this.baseTime;
|
||||||
|
|
||||||
room.updateItem(this);
|
room.updateItem(this);
|
||||||
|
this.needsUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -265,4 +340,20 @@ public abstract class InteractionGameTimer extends HabboItem
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRunning() {
|
||||||
|
return isRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRunning(boolean running) {
|
||||||
|
isRunning = running;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimeNow() {
|
||||||
|
return timeNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeNow(int timeNow) {
|
||||||
|
this.timeNow = timeNow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,10 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable
|
|||||||
@Override
|
@Override
|
||||||
public boolean validMove(Room room, RoomTile from, RoomTile to)
|
public boolean validMove(Room room, RoomTile from, RoomTile to)
|
||||||
{
|
{
|
||||||
|
if (room == null || from == null || to == null) return false;
|
||||||
|
|
||||||
HabboItem topItem = room.getTopItemAt(to.x, to.y, this);
|
HabboItem topItem = room.getTopItemAt(to.x, to.y, this);
|
||||||
return topItem instanceof InteractionBattleBanzaiTile;
|
return topItem != null && topItem instanceof InteractionBattleBanzaiTile;
|
||||||
//return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
|
//return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
|
package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||||
import com.eu.habbo.habbohotel.games.GameState;
|
import com.eu.habbo.habbohotel.games.GameState;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||||
@ -9,6 +10,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
|||||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -67,18 +69,11 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(this.getExtradata().isEmpty())
|
|
||||||
{
|
|
||||||
this.setExtradata("0");
|
|
||||||
}
|
|
||||||
|
|
||||||
int value = Integer.valueOf(this.getExtradata()) + 1;
|
|
||||||
|
|
||||||
this.setExtradata(value + "");
|
|
||||||
room.updateItem(this);
|
|
||||||
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
|
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateState(game, 5);
|
||||||
|
|
||||||
super.onWalkOn(roomUnit, room, objects);
|
super.onWalkOn(roomUnit, room, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import com.eu.habbo.plugin.EventHandler;
|
|||||||
import com.eu.habbo.plugin.events.users.UserDisconnectEvent;
|
import com.eu.habbo.plugin.events.users.UserDisconnectEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserExitRoomEvent;
|
import com.eu.habbo.plugin.events.users.UserExitRoomEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserSavedLookEvent;
|
import com.eu.habbo.plugin.events.users.UserSavedLookEvent;
|
||||||
import com.eu.habbo.util.FigureUtil;
|
import com.eu.habbo.util.figure.FigureUtil;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -113,7 +113,13 @@ public class InteractionFreezeBlock extends HabboItem
|
|||||||
if(player == null)
|
if(player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int powerUp = Integer.valueOf(this.getExtradata()) / 1000;
|
int powerUp;
|
||||||
|
try {
|
||||||
|
powerUp = Integer.valueOf(this.getExtradata()) / 1000;
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e){
|
||||||
|
powerUp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(powerUp >= 2 && powerUp <= 7)
|
if(powerUp >= 2 && powerUp <= 7)
|
||||||
{
|
{
|
||||||
|
@ -66,18 +66,11 @@ public class InteractionFreezeGate extends InteractionGameGate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(this.getExtradata().isEmpty())
|
|
||||||
{
|
|
||||||
this.setExtradata("0");
|
|
||||||
}
|
|
||||||
|
|
||||||
int value = Integer.valueOf(this.getExtradata()) + 1;
|
|
||||||
|
|
||||||
this.setExtradata(value + "");
|
|
||||||
room.updateItem(this);
|
|
||||||
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
|
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateState(game, 5);
|
||||||
|
|
||||||
super.onWalkOn(roomUnit, room, objects);
|
super.onWalkOn(roomUnit, room, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
|
|
||||||
private boolean state;
|
private boolean state;
|
||||||
private boolean position;
|
private boolean position;
|
||||||
private boolean direction;
|
private boolean rotation;
|
||||||
|
|
||||||
public WiredConditionNotMatchStatePosition(ResultSet set, Item baseItem) throws SQLException
|
public WiredConditionNotMatchStatePosition(ResultSet set, Item baseItem) throws SQLException
|
||||||
{
|
{
|
||||||
@ -52,23 +52,12 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
|
|
||||||
if(item != null)
|
if(item != null)
|
||||||
{
|
{
|
||||||
if(this.state)
|
boolean stateMatches = !this.state || item.getExtradata().equals(setting.state);
|
||||||
{
|
boolean positionMatches = !this.position || (setting.x == item.getX() && setting.y == item.getY());
|
||||||
if(item.getExtradata().equals(setting.state))
|
boolean directionMatches = !this.rotation || setting.rotation == item.getRotation();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.position)
|
if(stateMatches && positionMatches && directionMatches)
|
||||||
{
|
return false;
|
||||||
if((setting.x == item.getX() && setting.y == item.getY()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.direction)
|
|
||||||
{
|
|
||||||
if((setting.rotation == item.getRotation()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -102,7 +91,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
data.append(item.toString()).append(";");
|
data.append(item.toString()).append(";");
|
||||||
}
|
}
|
||||||
|
|
||||||
data.append(":").append(this.state ? 1 : 0).append(":").append(this.direction ? 1 : 0).append(":").append(this.position ? 1 : 0);
|
data.append(":").append(this.state ? 1 : 0).append(":").append(this.rotation ? 1 : 0).append(":").append(this.position ? 1 : 0);
|
||||||
|
|
||||||
return data.toString();
|
return data.toString();
|
||||||
}
|
}
|
||||||
@ -125,7 +114,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.state = data[2].equals("1");
|
this.state = data[2].equals("1");
|
||||||
this.direction = data[3].equals("1");
|
this.rotation = data[3].equals("1");
|
||||||
this.position = data[4].equals("1");
|
this.position = data[4].equals("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +123,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
{
|
{
|
||||||
this.settings.clear();
|
this.settings.clear();
|
||||||
this.state = false;
|
this.state = false;
|
||||||
this.direction = false;
|
this.rotation = false;
|
||||||
this.position = false;
|
this.position = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +150,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
message.appendString("");
|
message.appendString("");
|
||||||
message.appendInt(4);
|
message.appendInt(4);
|
||||||
message.appendInt(this.state ? 1 : 0);
|
message.appendInt(this.state ? 1 : 0);
|
||||||
message.appendInt(this.direction ? 1 : 0);
|
message.appendInt(this.rotation ? 1 : 0);
|
||||||
message.appendInt(this.position ? 1 : 0);
|
message.appendInt(this.position ? 1 : 0);
|
||||||
message.appendInt(10);
|
message.appendInt(10);
|
||||||
message.appendInt(0);
|
message.appendInt(0);
|
||||||
@ -179,7 +168,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
packet.readInt();
|
packet.readInt();
|
||||||
|
|
||||||
this.state = packet.readInt() == 1;
|
this.state = packet.readInt() == 1;
|
||||||
this.direction = packet.readInt() == 1;
|
this.rotation = packet.readInt() == 1;
|
||||||
this.position = packet.readInt() == 1;
|
this.position = packet.readInt() == 1;
|
||||||
|
|
||||||
packet.readString();
|
packet.readString();
|
||||||
|
@ -94,11 +94,8 @@ public class WiredEffectBotTalk extends InteractionWiredEffect
|
|||||||
}
|
}
|
||||||
List<Bot> bots = room.getBots(this.botName);
|
List<Bot> bots = room.getBots(this.botName);
|
||||||
|
|
||||||
int now = Emulator.getIntUnixTimestamp();
|
|
||||||
for(Bot bot : bots)
|
for(Bot bot : bots)
|
||||||
{
|
{
|
||||||
if (now - bot.getChatTimestamp() < bot.getChatDelay()) continue;
|
|
||||||
|
|
||||||
if(this.mode == 1)
|
if(this.mode == 1)
|
||||||
bot.shout(message);
|
bot.shout(message);
|
||||||
else
|
else
|
||||||
|
@ -119,21 +119,18 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect
|
|||||||
this.items.remove(item);
|
this.items.remove(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Bot bot : bots)
|
if(this.items.size() > 0) {
|
||||||
{
|
for (Bot bot : bots) {
|
||||||
int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
|
int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
|
||||||
int j = 1;
|
int j = 1;
|
||||||
for (HabboItem item : this.items)
|
for (HabboItem item : this.items) {
|
||||||
{
|
if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
|
||||||
if(item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId())
|
if (i == j) {
|
||||||
{
|
bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY()));
|
||||||
if (i == j)
|
break;
|
||||||
{
|
} else {
|
||||||
bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY()));
|
j++;
|
||||||
break;
|
}
|
||||||
} else
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect
|
|||||||
{
|
{
|
||||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
this.items = new THashSet<>();
|
this.items = new THashSet<>();
|
||||||
|
this.lastDirections = new THashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RoomUserRotation> getAvailableDirections(HabboItem item, Room room) {
|
public List<RoomUserRotation> getAvailableDirections(HabboItem item, Room room) {
|
||||||
@ -98,6 +99,9 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect
|
|||||||
|
|
||||||
for(HabboItem item : this.items) {
|
for(HabboItem item : this.items) {
|
||||||
|
|
||||||
|
if(item == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
// direction the furni will move in
|
// direction the furni will move in
|
||||||
RoomUserRotation moveDirection = null;
|
RoomUserRotation moveDirection = null;
|
||||||
RoomUserRotation lastDirection = lastDirections.get(item.getId());
|
RoomUserRotation lastDirection = lastDirections.get(item.getId());
|
||||||
|
@ -119,6 +119,56 @@ public class WiredEffectTeleport extends InteractionWiredEffect
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
|
||||||
|
if(roomUnit == null || tile == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Room room = roomUnit.getRoom();
|
||||||
|
|
||||||
|
if(room == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// makes a temporary effect
|
||||||
|
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
|
||||||
|
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY);
|
||||||
|
|
||||||
|
if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED)
|
||||||
|
{
|
||||||
|
RoomTile alternativeTile = null;
|
||||||
|
List<RoomTile> optionalTiles = room.getLayout().getTilesAround(tile);
|
||||||
|
|
||||||
|
Collections.reverse(optionalTiles);
|
||||||
|
for (RoomTile optionalTile : optionalTiles)
|
||||||
|
{
|
||||||
|
if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED)
|
||||||
|
{
|
||||||
|
alternativeTile = optionalTile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(alternativeTile != null) {
|
||||||
|
tile = alternativeTile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
HabboItem topItem = room.getTopItemAt(tile.x, tile.y);
|
||||||
|
|
||||||
|
if(topItem != null) {
|
||||||
|
Emulator.getThreading().run(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
topItem.onWalkOn(roomUnit, room, new Object[] { });
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, WiredHandler.TELEPORT_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
|
||||||
{
|
{
|
||||||
@ -146,52 +196,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect
|
|||||||
tryCount++;
|
tryCount++;
|
||||||
HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size());
|
HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size());
|
||||||
|
|
||||||
int currentEffect = roomUnit.getEffectId();
|
teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY()));
|
||||||
|
|
||||||
// makes a temporary effect
|
|
||||||
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
|
|
||||||
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), 2000);
|
|
||||||
|
|
||||||
final WiredEffectTeleport teleportWired = this;
|
|
||||||
RoomTile targetTile = room.getLayout().getTile(item.getX(), item.getY());
|
|
||||||
boolean foundTile = false;
|
|
||||||
if (targetTile.state == RoomTileState.INVALID || targetTile.state == RoomTileState.BLOCKED)
|
|
||||||
{
|
|
||||||
List<RoomTile> optionalTiles = room.getLayout().getTilesAround(targetTile, item.getRotation() + 3);
|
|
||||||
|
|
||||||
Collections.reverse(optionalTiles);
|
|
||||||
for (RoomTile tile : optionalTiles)
|
|
||||||
{
|
|
||||||
if (tile.state != RoomTileState.INVALID && tile.state != RoomTileState.BLOCKED)
|
|
||||||
{
|
|
||||||
targetTile = tile;
|
|
||||||
foundTile = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foundTile = true;
|
|
||||||
}
|
|
||||||
if (!foundTile)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, targetTile.x, targetTile.y, targetTile.getStackHeight() + (targetTile.state == RoomTileState.SIT ? -0.5 : 0) , currentEffect), WiredHandler.TELEPORT_DELAY);
|
|
||||||
Emulator.getThreading().run(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
item.onWalkOn(roomUnit, room, new Object[]{teleportWired});
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
}, WiredHandler.TELEPORT_DELAY);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -133,13 +133,6 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect
|
|||||||
|
|
||||||
HabboItem triggerItem = null;
|
HabboItem triggerItem = null;
|
||||||
|
|
||||||
if (stuff != null && stuff.length > 0)
|
|
||||||
{
|
|
||||||
if (stuff[0] instanceof HabboItem)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
THashSet<HabboItem> itemsToRemove = new THashSet<>();
|
THashSet<HabboItem> itemsToRemove = new THashSet<>();
|
||||||
for (HabboItem item : this.items)
|
for (HabboItem item : this.items)
|
||||||
{
|
{
|
||||||
@ -153,7 +146,15 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect
|
|||||||
{
|
{
|
||||||
if (item.getBaseItem().getStateCount() > 1 || item instanceof InteractionGameTimer)
|
if (item.getBaseItem().getStateCount() > 1 || item instanceof InteractionGameTimer)
|
||||||
{
|
{
|
||||||
item.onClick(habbo != null ? habbo.getClient() : null, room, new Object[]{item.getExtradata().length() == 0 ? 0 : Integer.valueOf(item.getExtradata()), this.getType()});
|
int state = 0;
|
||||||
|
if (!item.getExtradata().isEmpty()) {
|
||||||
|
try {
|
||||||
|
state = Integer.valueOf(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc.
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.onClick(habbo != null && !(item instanceof InteractionGameTimer) ? habbo.getClient() : null, room, new Object[]{state, this.getType()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -119,7 +119,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
|
||||||
{
|
{
|
||||||
if (stuff.length >= 1 && stuff[stuff.length - 1] instanceof WiredEffectTriggerStacks)
|
if (stuff != null && stuff.length >= 1 && stuff[stuff.length - 1] instanceof WiredEffectTriggerStacks)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,11 @@ public class Messenger
|
|||||||
this.friends.remove(habbo.getHabboInfo().getId());
|
this.friends.remove(habbo.getHabboInfo().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuddy(MessengerBuddy buddy)
|
||||||
|
{
|
||||||
|
this.friends.put(buddy.getId(), buddy);
|
||||||
|
}
|
||||||
|
|
||||||
public static void unfriend(int userOne, int userTwo)
|
public static void unfriend(int userOne, int userTwo)
|
||||||
{
|
{
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_friendships WHERE (user_one_id = ? AND user_two_id = ?) OR (user_one_id = ? AND user_two_id = ?)"))
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_friendships WHERE (user_one_id = ? AND user_two_id = ?) OR (user_one_id = ? AND user_two_id = ?)"))
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
package com.eu.habbo.habbohotel.messenger;
|
package com.eu.habbo.habbohotel.messenger;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.modtool.WordFilter;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||||
|
import com.eu.habbo.messages.ISerialize;
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.messages.outgoing.friends.FriendChatMessageComposer;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class MessengerBuddy implements Runnable {
|
public class MessengerBuddy implements Runnable, ISerialize {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String username;
|
private String username;
|
||||||
@ -176,4 +180,39 @@ public class MessengerBuddy implements Runnable {
|
|||||||
Emulator.getLogging().logSQLException(e);
|
Emulator.getLogging().logSQLException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onMessageReceived(Habbo from, String message) {
|
||||||
|
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(this.id);
|
||||||
|
|
||||||
|
if(habbo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Message chatMessage = new Message(from.getHabboInfo().getId(), this.id, message);
|
||||||
|
Emulator.getThreading().run(chatMessage);
|
||||||
|
|
||||||
|
if (WordFilter.ENABLED_FRIENDCHAT)
|
||||||
|
{
|
||||||
|
chatMessage.setMessage(Emulator.getGameEnvironment().getWordFilter().filter(chatMessage.getMessage(), from));
|
||||||
|
}
|
||||||
|
|
||||||
|
habbo.getClient().sendResponse(new FriendChatMessageComposer(chatMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(ServerMessage message) {
|
||||||
|
message.appendInt(this.id);
|
||||||
|
message.appendString(this.username);
|
||||||
|
message.appendInt(this.gender.equals(HabboGender.M) ? 0 : 1);
|
||||||
|
message.appendBoolean(this.online == 1);
|
||||||
|
message.appendBoolean(this.inRoom); //IN ROOM
|
||||||
|
message.appendString(this.look);
|
||||||
|
message.appendInt(0);
|
||||||
|
message.appendString(this.motto);
|
||||||
|
message.appendString("");
|
||||||
|
message.appendString("");
|
||||||
|
message.appendBoolean(false); //Offline messaging.
|
||||||
|
message.appendBoolean(false);
|
||||||
|
message.appendBoolean(false);
|
||||||
|
message.appendShort(this.relation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,7 +473,7 @@ public class ModToolManager
|
|||||||
public void alert(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason)
|
public void alert(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason)
|
||||||
{
|
{
|
||||||
if(!moderator.hasPermission(Permission.ACC_SUPPORTTOOL)) {
|
if(!moderator.hasPermission(Permission.ACC_SUPPORTTOOL)) {
|
||||||
Emulator.getGameEnvironment().getModToolManager().quickTicket(moderator, "Scripter", Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", moderator.getHabboInfo().getUsername()).replace("%message%", message));
|
ScripterManager.scripterDetected(moderator.getClient(), Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", moderator.getHabboInfo().getUsername()).replace("%message%", message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.eu.habbo.habbohotel.modtool;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.plugin.events.support.SupportEvent;
|
||||||
|
|
||||||
|
public class ScripterEvent extends SupportEvent {
|
||||||
|
public final Habbo habbo;
|
||||||
|
public final String reason;
|
||||||
|
|
||||||
|
public ScripterEvent(Habbo habbo, String reason) {
|
||||||
|
super(null);
|
||||||
|
|
||||||
|
this.habbo = habbo;
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.eu.habbo.habbohotel.modtool;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
|
|
||||||
|
public class ScripterManager {
|
||||||
|
public static void scripterDetected(GameClient client, String reason) {
|
||||||
|
ScripterEvent scripterEvent = new ScripterEvent(client.getHabbo(), reason);
|
||||||
|
Emulator.getPluginManager().fireEvent(scripterEvent);
|
||||||
|
|
||||||
|
if (scripterEvent.isCancelled()) return;
|
||||||
|
|
||||||
|
if (Emulator.getConfig().getBoolean("scripter.modtool.tickets", true)) {
|
||||||
|
Emulator.getGameEnvironment().getModToolManager().quickTicket(client.getHabbo(), "Scripter", reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@ -27,7 +28,6 @@ public class NavigatorManager
|
|||||||
public NavigatorManager()
|
public NavigatorManager()
|
||||||
{
|
{
|
||||||
long millis = System.currentTimeMillis();
|
long millis = System.currentTimeMillis();
|
||||||
this.loadNavigator();
|
|
||||||
|
|
||||||
this.filters.put(NavigatorPublicFilter.name, new NavigatorPublicFilter());
|
this.filters.put(NavigatorPublicFilter.name, new NavigatorPublicFilter());
|
||||||
this.filters.put(NavigatorHotelFilter.name, new NavigatorHotelFilter());
|
this.filters.put(NavigatorHotelFilter.name, new NavigatorHotelFilter());
|
||||||
@ -139,6 +139,12 @@ public class NavigatorManager
|
|||||||
{
|
{
|
||||||
Emulator.getLogging().logSQLException(e);
|
Emulator.getLogging().logSQLException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Room> staffPromotedRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsStaffPromoted();
|
||||||
|
|
||||||
|
for (Room room : staffPromotedRooms) {
|
||||||
|
this.publicCategories.get(Emulator.getConfig().getInt("hotel.navigator.staffpicks.categoryid")).addRoom(room);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavigatorFilterComparator comperatorForField(Method field)
|
public NavigatorFilterComparator comperatorForField(Method field)
|
||||||
|
@ -108,7 +108,7 @@ public class PermissionsManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Rank getRank(String rankName)
|
public Rank getRankByName(String rankName)
|
||||||
{
|
{
|
||||||
for (Rank rank : this.ranks.valueCollection())
|
for (Rank rank : this.ranks.valueCollection())
|
||||||
{
|
{
|
||||||
@ -161,8 +161,12 @@ public class PermissionsManager
|
|||||||
return this.badges.keySet();
|
return this.badges.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Rank> getRanks(String code)
|
public List<Rank> getRanksByBadgeCode(String code)
|
||||||
{
|
{
|
||||||
return this.badges.get(code);
|
return this.badges.get(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Rank> getAllRanks() {
|
||||||
|
return new ArrayList<>(this.ranks.valueCollection());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,24 @@
|
|||||||
package com.eu.habbo.habbohotel.pets;
|
package com.eu.habbo.habbohotel.pets;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class HorsePet extends Pet
|
public class HorsePet extends RideablePet
|
||||||
{
|
{
|
||||||
private int hairColor;
|
private int hairColor;
|
||||||
private int hairStyle;
|
private int hairStyle;
|
||||||
|
|
||||||
private boolean hasSaddle;
|
|
||||||
private boolean anyoneCanRide;
|
|
||||||
|
|
||||||
private Habbo rider;
|
|
||||||
|
|
||||||
public HorsePet(ResultSet set) throws SQLException
|
public HorsePet(ResultSet set) throws SQLException
|
||||||
{
|
{
|
||||||
super(set);
|
super(set);
|
||||||
this.hairColor = set.getInt("hair_color");
|
this.hairColor = set.getInt("hair_color");
|
||||||
this.hairStyle = set.getInt("hair_style");
|
this.hairStyle = set.getInt("hair_style");
|
||||||
this.hasSaddle = set.getString("saddle").equalsIgnoreCase("1");
|
this.hasSaddle(set.getString("saddle").equalsIgnoreCase("1"));
|
||||||
this.anyoneCanRide = set.getString("ride").equalsIgnoreCase("1");
|
this.setAnyoneCanRide(set.getString("ride").equalsIgnoreCase("1"));
|
||||||
this.rider = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HorsePet(int type, int race, String color, String name, int userId)
|
public HorsePet(int type, int race, String color, String name, int userId)
|
||||||
@ -33,9 +26,8 @@ public class HorsePet extends Pet
|
|||||||
super(type, race, color, name, userId);
|
super(type, race, color, name, userId);
|
||||||
this.hairColor = 0;
|
this.hairColor = 0;
|
||||||
this.hairStyle = -1;
|
this.hairStyle = -1;
|
||||||
this.hasSaddle = false;
|
this.hasSaddle(false);
|
||||||
this.anyoneCanRide = false;
|
this.setAnyoneCanRide(false);
|
||||||
this.rider = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,8 +39,8 @@ public class HorsePet extends Pet
|
|||||||
{
|
{
|
||||||
statement.setInt(1, this.hairStyle);
|
statement.setInt(1, this.hairStyle);
|
||||||
statement.setInt(2, this.hairColor);
|
statement.setInt(2, this.hairColor);
|
||||||
statement.setString(3, this.hasSaddle ? "1" : "0");
|
statement.setString(3, this.hasSaddle() ? "1" : "0");
|
||||||
statement.setString(4, this.anyoneCanRide ? "1" : "0");
|
statement.setString(4, this.anyoneCanRide() ? "1" : "0");
|
||||||
statement.setInt(5, super.getId());
|
statement.setInt(5, super.getId());
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
@ -80,34 +72,4 @@ public class HorsePet extends Pet
|
|||||||
{
|
{
|
||||||
this.hairStyle = hairStyle;
|
this.hairStyle = hairStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSaddle()
|
|
||||||
{
|
|
||||||
return this.hasSaddle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hasSaddle(boolean hasSaddle)
|
|
||||||
{
|
|
||||||
this.hasSaddle = hasSaddle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean anyoneCanRide()
|
|
||||||
{
|
|
||||||
return this.anyoneCanRide;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAnyoneCanRide(boolean anyoneCanRide)
|
|
||||||
{
|
|
||||||
this.anyoneCanRide = anyoneCanRide;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Habbo getRider()
|
|
||||||
{
|
|
||||||
return this.rider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRider(Habbo rider)
|
|
||||||
{
|
|
||||||
this.rider = rider;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.eu.habbo.messages.ServerMessage;
|
|||||||
import com.eu.habbo.messages.outgoing.rooms.pets.PetLevelUpdatedComposer;
|
import com.eu.habbo.messages.outgoing.rooms.pets.PetLevelUpdatedComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetExperienceComposer;
|
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetExperienceComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetRespectComposer;
|
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetRespectComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer;
|
||||||
import com.eu.habbo.plugin.events.pets.PetTalkEvent;
|
import com.eu.habbo.plugin.events.pets.PetTalkEvent;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
@ -876,4 +877,24 @@ public class Pet implements ISerialize, Runnable
|
|||||||
{
|
{
|
||||||
this.levelHunger = levelHunger;
|
this.levelHunger = levelHunger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeFromRoom() {
|
||||||
|
removeFromRoom(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFromRoom(boolean dontSendPackets) {
|
||||||
|
|
||||||
|
if(this.roomUnit != null && this.roomUnit.getCurrentLocation() != null) {
|
||||||
|
this.roomUnit.getCurrentLocation().removeUnit(this.roomUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!dontSendPackets) {
|
||||||
|
room.sendComposer(new RoomUserRemoveComposer(this.roomUnit).compose());
|
||||||
|
room.removePet(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.roomUnit = null;
|
||||||
|
this.room = null;
|
||||||
|
this.needsUpdate = true;
|
||||||
|
}
|
||||||
}
|
}
|
@ -79,6 +79,19 @@ public class PetManager
|
|||||||
this.breedingPetType = new TIntIntHashMap();
|
this.breedingPetType = new TIntIntHashMap();
|
||||||
this.breedingReward = new THashMap<>();
|
this.breedingReward = new THashMap<>();
|
||||||
|
|
||||||
|
reloadPetData();
|
||||||
|
|
||||||
|
Emulator.getLogging().logStart("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void reloadPetData()
|
||||||
|
{
|
||||||
|
this.petRaces.clear();
|
||||||
|
this.petData.clear();
|
||||||
|
this.breedingPetType.clear();
|
||||||
|
this.breedingReward.clear();
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
|
||||||
{
|
{
|
||||||
this.loadRaces(connection);
|
this.loadRaces(connection);
|
||||||
@ -90,55 +103,6 @@ public class PetManager
|
|||||||
{
|
{
|
||||||
Emulator.getLogging().logSQLException(e);
|
Emulator.getLogging().logSQLException(e);
|
||||||
Emulator.getLogging().logErrorLine("Pet Manager -> Failed to load!");
|
Emulator.getLogging().logErrorLine("Pet Manager -> Failed to load!");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Emulator.getLogging().logStart("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void reloadPetData()
|
|
||||||
{
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
|
|
||||||
{
|
|
||||||
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM pet_actions ORDER BY pet_type ASC"))
|
|
||||||
{
|
|
||||||
try (ResultSet set = statement.executeQuery())
|
|
||||||
{
|
|
||||||
while (set.next())
|
|
||||||
{
|
|
||||||
PetData petData = this.petData.get(set.getInt("pet_type"));
|
|
||||||
|
|
||||||
if (petData != null)
|
|
||||||
{
|
|
||||||
petData.load(set);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.petData.put(set.getInt("pet_type"), new PetData(set));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PetData.generalNestItems.clear();
|
|
||||||
PetData.generalFoodItems.clear();
|
|
||||||
PetData.generalDrinkItems.clear();
|
|
||||||
|
|
||||||
for(PetData data : this.petData.values())
|
|
||||||
{
|
|
||||||
data.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loadPetItems(connection);
|
|
||||||
|
|
||||||
this.loadPetVocals(connection);
|
|
||||||
|
|
||||||
this.loadRaces(connection);
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
Emulator.getLogging().logSQLException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
53
src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java
Normal file
53
src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package com.eu.habbo.habbohotel.pets;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class RideablePet extends Pet {
|
||||||
|
|
||||||
|
private Habbo rider;
|
||||||
|
private boolean hasSaddle;
|
||||||
|
private boolean anyoneCanRide;
|
||||||
|
|
||||||
|
public RideablePet(ResultSet set) throws SQLException {
|
||||||
|
super(set);
|
||||||
|
this.rider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RideablePet(int type, int race, String color, String name, int userId) {
|
||||||
|
super(type, race, color, name, userId);
|
||||||
|
this.rider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSaddle()
|
||||||
|
{
|
||||||
|
return this.hasSaddle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hasSaddle(boolean hasSaddle)
|
||||||
|
{
|
||||||
|
this.hasSaddle = hasSaddle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean anyoneCanRide()
|
||||||
|
{
|
||||||
|
return this.anyoneCanRide;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnyoneCanRide(boolean anyoneCanRide)
|
||||||
|
{
|
||||||
|
this.anyoneCanRide = anyoneCanRide;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Habbo getRider()
|
||||||
|
{
|
||||||
|
return this.rider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRider(Habbo rider)
|
||||||
|
{
|
||||||
|
this.rider = rider;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,9 @@
|
|||||||
package com.eu.habbo.habbohotel.rooms;
|
package com.eu.habbo.habbohotel.rooms;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -259,7 +262,7 @@ public class RoomLayout
|
|||||||
return this.heightmap.replace("\r\n", "\r");
|
return this.heightmap.replace("\r\n", "\r");
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Deque<RoomTile> findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation)
|
public final Deque<RoomTile> findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit)
|
||||||
{
|
{
|
||||||
LinkedList<RoomTile> openList = new LinkedList<>();
|
LinkedList<RoomTile> openList = new LinkedList<>();
|
||||||
try
|
try
|
||||||
@ -274,7 +277,7 @@ public class RoomLayout
|
|||||||
long startMillis = System.currentTimeMillis();
|
long startMillis = System.currentTimeMillis();
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (System.currentTimeMillis() - startMillis > 25)
|
if (System.currentTimeMillis() - startMillis > 50)
|
||||||
{
|
{
|
||||||
return new LinkedList<>();
|
return new LinkedList<>();
|
||||||
}
|
}
|
||||||
@ -293,10 +296,16 @@ public class RoomLayout
|
|||||||
{
|
{
|
||||||
if (closedList.contains(currentAdj)) continue;
|
if (closedList.contains(currentAdj)) continue;
|
||||||
|
|
||||||
|
if(roomUnit.canOverrideTile(currentAdj) || (currentAdj.state != RoomTileState.BLOCKED && currentAdj.x == doorX && currentAdj.y == doorY)) {
|
||||||
|
currentAdj.setPrevious(current);
|
||||||
|
currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y));
|
||||||
|
currentAdj.setgCosts(current);
|
||||||
|
openList.add(currentAdj);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//If the tile is sitable or layable and its not our goal tile, we cannot walk over it.
|
//If the tile is sitable or layable and its not our goal tile, we cannot walk over it.
|
||||||
if (
|
if (!currentAdj.equals(goalLocation) && (currentAdj.state == RoomTileState.BLOCKED || currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY))
|
||||||
(currentAdj.state == RoomTileState.BLOCKED) ||
|
|
||||||
((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation)))
|
|
||||||
{
|
{
|
||||||
closedList.add(currentAdj);
|
closedList.add(currentAdj);
|
||||||
openList.remove(currentAdj);
|
openList.remove(currentAdj);
|
||||||
@ -311,10 +320,10 @@ public class RoomLayout
|
|||||||
if (!ALLOW_FALLING && height < - MAXIMUM_STEP_HEIGHT) continue;
|
if (!ALLOW_FALLING && height < - MAXIMUM_STEP_HEIGHT) continue;
|
||||||
|
|
||||||
//If the step difference is bigger than the maximum step height, continue.
|
//If the step difference is bigger than the maximum step height, continue.
|
||||||
if (height > MAXIMUM_STEP_HEIGHT && currentAdj.state == RoomTileState.OPEN) continue;
|
if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue;
|
||||||
|
|
||||||
//Check if the tile has habbos.
|
//Check if the tile has habbos.
|
||||||
if (!this.room.isAllowWalkthrough() && this.room.hasHabbosAt(currentAdj.x, currentAdj.y))
|
if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation)))
|
||||||
{
|
{
|
||||||
closedList.add(currentAdj);
|
closedList.add(currentAdj);
|
||||||
openList.remove(currentAdj);
|
openList.remove(currentAdj);
|
||||||
@ -654,6 +663,28 @@ public class RoomLayout
|
|||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RoomTile> getWalkableTilesAround(RoomTile tile) {
|
||||||
|
return getWalkableTilesAround(tile, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RoomTile> getWalkableTilesAround(RoomTile tile, int directionOffset) {
|
||||||
|
List<RoomTile> availableTiles = new ArrayList<>(this.getTilesAround(tile, directionOffset));
|
||||||
|
|
||||||
|
List<RoomTile> toRemove = new ArrayList<>();
|
||||||
|
|
||||||
|
for(RoomTile t : availableTiles) {
|
||||||
|
if(t == null || t.state != RoomTileState.OPEN || !t.isWalkable()) {
|
||||||
|
toRemove.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(RoomTile t : toRemove) {
|
||||||
|
availableTiles.remove(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return availableTiles;
|
||||||
|
}
|
||||||
|
|
||||||
public static Rectangle getRectangle(int x, int y, int width, int length, int rotation)
|
public static Rectangle getRectangle(int x, int y, int width, int length, int rotation)
|
||||||
{
|
{
|
||||||
rotation = (rotation % 8);
|
rotation = (rotation % 8);
|
||||||
|
@ -4,6 +4,14 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.core.RoomUserPetComposer;
|
import com.eu.habbo.core.RoomUserPetComposer;
|
||||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||||
import com.eu.habbo.habbohotel.bots.Bot;
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
|
import com.eu.habbo.habbohotel.games.Game;
|
||||||
|
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.football.FootballGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.tag.BunnyrunGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.tag.IceTagGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.tag.RollerskateGame;
|
||||||
|
import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
||||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
||||||
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
|
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
|
||||||
@ -34,6 +42,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.*;
|
|||||||
import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer;
|
import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer;
|
||||||
import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent;
|
import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent;
|
||||||
import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent;
|
import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent;
|
||||||
|
import com.eu.habbo.plugin.events.users.HabboAddedToRoomEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserEnterRoomEvent;
|
import com.eu.habbo.plugin.events.users.UserEnterRoomEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserExitRoomEvent;
|
import com.eu.habbo.plugin.events.users.UserExitRoomEvent;
|
||||||
import gnu.trove.iterator.TIntObjectIterator;
|
import gnu.trove.iterator.TIntObjectIterator;
|
||||||
@ -57,6 +66,7 @@ public class RoomManager
|
|||||||
private final THashMap<Integer, RoomCategory> roomCategories;
|
private final THashMap<Integer, RoomCategory> roomCategories;
|
||||||
private final List<String> mapNames;
|
private final List<String> mapNames;
|
||||||
private final ConcurrentHashMap<Integer, Room> activeRooms;
|
private final ConcurrentHashMap<Integer, Room> activeRooms;
|
||||||
|
private final ArrayList<Class<? extends Game>> gameTypes;
|
||||||
|
|
||||||
public RoomManager()
|
public RoomManager()
|
||||||
{
|
{
|
||||||
@ -67,6 +77,16 @@ public class RoomManager
|
|||||||
this.loadRoomCategories();
|
this.loadRoomCategories();
|
||||||
this.loadRoomModels();
|
this.loadRoomModels();
|
||||||
|
|
||||||
|
this.gameTypes = new ArrayList<>();
|
||||||
|
|
||||||
|
registerGameType(BattleBanzaiGame.class);
|
||||||
|
registerGameType(FreezeGame.class);
|
||||||
|
registerGameType(WiredGame.class);
|
||||||
|
registerGameType(FootballGame.class);
|
||||||
|
registerGameType(BunnyrunGame.class);
|
||||||
|
registerGameType(IceTagGame.class);
|
||||||
|
registerGameType(RollerskateGame.class);
|
||||||
|
|
||||||
Emulator.getLogging().logStart("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
Emulator.getLogging().logStart("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,8 +712,23 @@ public class RoomManager
|
|||||||
habbo.getRoomUnit().clearStatus();
|
habbo.getRoomUnit().clearStatus();
|
||||||
if (habbo.getRoomUnit().getCurrentLocation() == null)
|
if (habbo.getRoomUnit().getCurrentLocation() == null)
|
||||||
{
|
{
|
||||||
habbo.getRoomUnit().setLocation(room.getLayout().getDoorTile());
|
habbo.getRoomUnit().setLocation(doorLocation != null ? doorLocation : room.getLayout().getDoorTile());
|
||||||
|
habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||||
|
|
||||||
|
if(doorLocation == null) {
|
||||||
|
habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
|
||||||
|
habbo.getRoomUnit().setHeadRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
habbo.getRoomUnit().setCanLeaveRoomByDoor(false);
|
||||||
|
habbo.getRoomUnit().isTeleporting = true;
|
||||||
|
HabboItem topItem = room.getTopItemAt(doorLocation.x, doorLocation.y);
|
||||||
|
if(topItem != null) {
|
||||||
|
habbo.getRoomUnit().setRotation(RoomUserRotation.values()[topItem.getRotation()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
habbo.getRoomUnit().setRoomUnitType(RoomUnitType.USER);
|
habbo.getRoomUnit().setRoomUnitType(RoomUnitType.USER);
|
||||||
if(room.isBanned(habbo))
|
if(room.isBanned(habbo))
|
||||||
{
|
{
|
||||||
@ -716,7 +751,8 @@ public class RoomManager
|
|||||||
if (habbo.getHabboInfo().getCurrentRoom() != room && habbo.getHabboInfo().getCurrentRoom() != null)
|
if (habbo.getHabboInfo().getCurrentRoom() != room && habbo.getHabboInfo().getCurrentRoom() != null)
|
||||||
{
|
{
|
||||||
habbo.getHabboInfo().getCurrentRoom().removeHabbo(habbo);
|
habbo.getHabboInfo().getCurrentRoom().removeHabbo(habbo);
|
||||||
} else if (!habbo.getHabboStats().blockFollowing && habbo.getHabboInfo().getCurrentRoom() == null)
|
}
|
||||||
|
else if (!habbo.getHabboStats().blockFollowing && habbo.getHabboInfo().getCurrentRoom() == null)
|
||||||
{
|
{
|
||||||
habbo.getMessenger().connectionChanged(habbo, true, true);
|
habbo.getMessenger().connectionChanged(habbo, true, true);
|
||||||
}
|
}
|
||||||
@ -732,11 +768,6 @@ public class RoomManager
|
|||||||
|
|
||||||
habbo.getHabboInfo().setLoadingRoom(room.getId());
|
habbo.getHabboInfo().setLoadingRoom(room.getId());
|
||||||
|
|
||||||
if (habbo.getRoomUnit().isTeleporting)
|
|
||||||
{
|
|
||||||
habbo.getRoomUnit().setLocation(doorLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
habbo.getClient().sendResponse(new RoomModelComposer(room));
|
habbo.getClient().sendResponse(new RoomModelComposer(room));
|
||||||
|
|
||||||
if (!room.getWallPaint().equals("0.0"))
|
if (!room.getWallPaint().equals("0.0"))
|
||||||
@ -793,9 +824,8 @@ public class RoomManager
|
|||||||
}
|
}
|
||||||
habbo.getRoomUnit().isKicked = false;
|
habbo.getRoomUnit().isKicked = false;
|
||||||
|
|
||||||
if (!habbo.getRoomUnit().isTeleporting)
|
if (habbo.getRoomUnit().getCurrentLocation() == null && !habbo.getRoomUnit().isTeleporting)
|
||||||
{
|
{
|
||||||
|
|
||||||
RoomTile doorTile = room.getLayout().getTile(room.getLayout().getDoorX(), room.getLayout().getDoorY());
|
RoomTile doorTile = room.getLayout().getTile(room.getLayout().getDoorX(), room.getLayout().getDoorY());
|
||||||
|
|
||||||
if (doorTile != null)
|
if (doorTile != null)
|
||||||
@ -807,6 +837,7 @@ public class RoomManager
|
|||||||
habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
|
habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
|
||||||
habbo.getRoomUnit().setHeadRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
|
habbo.getRoomUnit().setHeadRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
habbo.getRoomUnit().setPathFinderRoom(room);
|
habbo.getRoomUnit().setPathFinderRoom(room);
|
||||||
habbo.getRoomUnit().resetIdleTimer();
|
habbo.getRoomUnit().resetIdleTimer();
|
||||||
|
|
||||||
@ -1041,6 +1072,10 @@ public class RoomManager
|
|||||||
{
|
{
|
||||||
UserNuxEvent.handle(habbo);
|
UserNuxEvent.handle(habbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) {
|
||||||
|
Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void logEnter(Habbo habbo, Room room)
|
void logEnter(Habbo habbo, Room room)
|
||||||
@ -1070,14 +1105,9 @@ public class RoomManager
|
|||||||
{
|
{
|
||||||
habbo.getRoomUnit().setPathFinderRoom(null);
|
habbo.getRoomUnit().setPathFinderRoom(null);
|
||||||
|
|
||||||
if (!room.isOwner(habbo))
|
|
||||||
{
|
|
||||||
room.pickupPetsForHabbo(habbo);
|
|
||||||
}
|
|
||||||
this.logExit(habbo);
|
this.logExit(habbo);
|
||||||
room.removeHabbo(habbo);
|
room.removeHabbo(habbo, true);
|
||||||
|
|
||||||
room.sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose());
|
|
||||||
if (redirectToHotelView)
|
if (redirectToHotelView)
|
||||||
{
|
{
|
||||||
habbo.getClient().sendResponse(new HotelViewComposer());
|
habbo.getClient().sendResponse(new HotelViewComposer());
|
||||||
@ -1572,6 +1602,20 @@ public class RoomManager
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<Room> getRoomsStaffPromoted() {
|
||||||
|
ArrayList<Room> r = new ArrayList<>();
|
||||||
|
|
||||||
|
for(Room room : this.getActiveRooms())
|
||||||
|
{
|
||||||
|
if(room.isStaffPromotedRoom())
|
||||||
|
{
|
||||||
|
r.add(room);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Room> filterRoomsByOwner(List<Room> rooms, String filter)
|
public List<Room> filterRoomsByOwner(List<Room> rooms, String filter)
|
||||||
{
|
{
|
||||||
ArrayList<Room> r = new ArrayList<>();
|
ArrayList<Room> r = new ArrayList<>();
|
||||||
@ -1751,4 +1795,16 @@ public class RoomManager
|
|||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerGameType(Class<? extends Game> gameClass) {
|
||||||
|
gameTypes.add(gameClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregisterGameType(Class<? extends Game> gameClass) {
|
||||||
|
gameTypes.remove(gameClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Class<? extends Game>> getGameTypes() {
|
||||||
|
return gameTypes;
|
||||||
|
}
|
||||||
}
|
}
|
@ -774,43 +774,6 @@ public class RoomSpecialTypes
|
|||||||
return this.gameTimers;
|
return this.gameTimers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public THashMap<Integer, InteractionFreezeTimer> getFreezeTimers()
|
|
||||||
{
|
|
||||||
synchronized (this.gameTimers)
|
|
||||||
{
|
|
||||||
THashMap<Integer, InteractionFreezeTimer> timers = new THashMap<>();
|
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionGameTimer> set : this.gameTimers.entrySet())
|
|
||||||
{
|
|
||||||
if (set.getValue() instanceof InteractionFreezeTimer)
|
|
||||||
{
|
|
||||||
timers.put(set.getValue().getId(), (InteractionFreezeTimer) set.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return timers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public THashMap<Integer, InteractionBattleBanzaiTimer> getBattleBanzaiTimers()
|
|
||||||
{
|
|
||||||
synchronized (this.gameTimers)
|
|
||||||
{
|
|
||||||
THashMap<Integer, InteractionBattleBanzaiTimer> timers = new THashMap<>();
|
|
||||||
|
|
||||||
for (Map.Entry<Integer, InteractionGameTimer> set : this.gameTimers.entrySet())
|
|
||||||
{
|
|
||||||
if (set.getValue() instanceof InteractionBattleBanzaiTimer)
|
|
||||||
{
|
|
||||||
timers.put(set.getValue().getId(), (InteractionBattleBanzaiTimer) set.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return timers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public InteractionFreezeExitTile getFreezeExitTile()
|
public InteractionFreezeExitTile getFreezeExitTile()
|
||||||
{
|
{
|
||||||
for(InteractionFreezeExitTile t : this.freezeExitTile.values())
|
for(InteractionFreezeExitTile t : this.freezeExitTile.values())
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package com.eu.habbo.habbohotel.rooms;
|
package com.eu.habbo.habbohotel.rooms;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RoomTile
|
public class RoomTile
|
||||||
{
|
{
|
||||||
public final short x;
|
public final short x;
|
||||||
@ -10,12 +17,13 @@ public class RoomTile
|
|||||||
private double stackHeight;
|
private double stackHeight;
|
||||||
private boolean allowStack = true;
|
private boolean allowStack = true;
|
||||||
|
|
||||||
|
|
||||||
private RoomTile previous = null;
|
private RoomTile previous = null;
|
||||||
private boolean diagonally;
|
private boolean diagonally;
|
||||||
private short gCosts;
|
private short gCosts;
|
||||||
private short hCosts;
|
private short hCosts;
|
||||||
|
|
||||||
|
private final THashSet<RoomUnit> units;
|
||||||
|
|
||||||
|
|
||||||
public RoomTile(short x, short y, short z, RoomTileState state, boolean allowStack)
|
public RoomTile(short x, short y, short z, RoomTileState state, boolean allowStack)
|
||||||
{
|
{
|
||||||
@ -25,6 +33,7 @@ public class RoomTile
|
|||||||
this.stackHeight = z;
|
this.stackHeight = z;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.setAllowStack(allowStack);
|
this.setAllowStack(allowStack);
|
||||||
|
this.units = new THashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoomTile(RoomTile tile)
|
public RoomTile(RoomTile tile)
|
||||||
@ -43,6 +52,7 @@ public class RoomTile
|
|||||||
{
|
{
|
||||||
this.allowStack = false;
|
this.allowStack = false;
|
||||||
}
|
}
|
||||||
|
this.units = tile.units;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getStackHeight()
|
public double getStackHeight()
|
||||||
@ -199,4 +209,34 @@ public class RoomTile
|
|||||||
{
|
{
|
||||||
return this.x == x && this.y == y;
|
return this.x == x && this.y == y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RoomUnit> getUnits() {
|
||||||
|
synchronized (this.units) {
|
||||||
|
return new ArrayList<RoomUnit>(this.units);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addUnit(RoomUnit unit) {
|
||||||
|
synchronized (this.units) {
|
||||||
|
if (!this.units.contains(unit)) {
|
||||||
|
this.units.add(unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeUnit(RoomUnit unit) {
|
||||||
|
synchronized (this.units) {
|
||||||
|
this.units.remove(unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUnits() {
|
||||||
|
synchronized (this.units) {
|
||||||
|
return this.units.size() > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean unitIsOnFurniOnTile(RoomUnit unit, Item item) {
|
||||||
|
return (unit.getX() >= this.x && unit.getX() < this.x + item.getLength()) && (unit.getY() >= this.y && unit.getY() < this.y + item.getWidth());
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate;
|
|||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionMultiHeight;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionMultiHeight;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock;
|
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock;
|
||||||
import com.eu.habbo.habbohotel.pets.HorsePet;
|
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||||
import com.eu.habbo.habbohotel.users.DanceType;
|
import com.eu.habbo.habbohotel.users.DanceType;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
@ -21,7 +21,9 @@ import com.eu.habbo.threading.runnables.RoomUnitKick;
|
|||||||
import com.eu.habbo.util.pathfinding.Rotation;
|
import com.eu.habbo.util.pathfinding.Rotation;
|
||||||
import gnu.trove.map.TMap;
|
import gnu.trove.map.TMap;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
|
import java.awt.geom.RectangularShape;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -54,6 +56,8 @@ public class RoomUnit
|
|||||||
public int kickCount = 0;
|
public int kickCount = 0;
|
||||||
private boolean statusUpdate = false;
|
private boolean statusUpdate = false;
|
||||||
private boolean invisible = false;
|
private boolean invisible = false;
|
||||||
|
private boolean lastCycleStatus = false;
|
||||||
|
private boolean canLeaveRoomByDoor = true;
|
||||||
|
|
||||||
private final ConcurrentHashMap<RoomUnitStatus, String> status;
|
private final ConcurrentHashMap<RoomUnitStatus, String> status;
|
||||||
private final THashMap<String, Object> cacheable;
|
private final THashMap<String, Object> cacheable;
|
||||||
@ -71,6 +75,7 @@ public class RoomUnit
|
|||||||
private int idleTimer;
|
private int idleTimer;
|
||||||
private Room room;
|
private Room room;
|
||||||
private RoomRightLevels rightsLevel = RoomRightLevels.NONE;
|
private RoomRightLevels rightsLevel = RoomRightLevels.NONE;
|
||||||
|
private THashSet<Integer> overridableTiles;
|
||||||
|
|
||||||
public RoomUnit()
|
public RoomUnit()
|
||||||
{
|
{
|
||||||
@ -86,6 +91,7 @@ public class RoomUnit
|
|||||||
this.walkTimeOut = Emulator.getIntUnixTimestamp();
|
this.walkTimeOut = Emulator.getIntUnixTimestamp();
|
||||||
this.effectId = 0;
|
this.effectId = 0;
|
||||||
this.isKicked = false;
|
this.isKicked = false;
|
||||||
|
this.overridableTiles = new THashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearWalking()
|
public void clearWalking()
|
||||||
@ -112,27 +118,32 @@ public class RoomUnit
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (this.isTeleporting)
|
Habbo rider = null;
|
||||||
{
|
if(this.getRoomUnitType() == RoomUnitType.PET) {
|
||||||
return false;
|
Pet pet = room.getPet(this);
|
||||||
}
|
if(pet instanceof RideablePet) {
|
||||||
|
rider = ((RideablePet) pet).getRider();
|
||||||
Boolean isHorse = false;
|
|
||||||
Pet pet = room.getPet(this);
|
|
||||||
if(pet != null) {
|
|
||||||
if(pet instanceof HorsePet) {
|
|
||||||
isHorse = true;
|
|
||||||
if (((HorsePet) pet).getRider() != null) {
|
|
||||||
if(!((HorsePet) pet).getRider().getRoomUnit().isWalking()) {
|
|
||||||
this.status.remove(RoomUnitStatus.MOVE);
|
|
||||||
this.setCurrentLocation(((HorsePet) pet).getRider().getRoomUnit().getPreviousLocation());
|
|
||||||
if (this.status.remove(RoomUnitStatus.MOVE) != null) this.statusUpdate = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(rider != null) {
|
||||||
|
// copy things from rider
|
||||||
|
if(this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatusMap().containsKey(RoomUnitStatus.MOVE)) {
|
||||||
|
this.status.remove(RoomUnitStatus.MOVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rider.getRoomUnit().getCurrentLocation().x != this.getX() || rider.getRoomUnit().getCurrentLocation().y != this.getY()) {
|
||||||
|
this.status.put(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentLocation().x + "," + rider.getRoomUnit().getCurrentLocation().y + "," + (rider.getRoomUnit().getCurrentLocation().getStackHeight()));
|
||||||
|
this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation());
|
||||||
|
this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight());
|
||||||
|
this.setCurrentLocation(rider.getRoomUnit().getCurrentLocation());
|
||||||
|
this.setZ(rider.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.statusUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!this.isWalking() && !this.isKicked)
|
if (!this.isWalking() && !this.isKicked)
|
||||||
{
|
{
|
||||||
if (this.status.remove(RoomUnitStatus.MOVE) == null)
|
if (this.status.remove(RoomUnitStatus.MOVE) == null)
|
||||||
@ -168,27 +179,20 @@ public class RoomUnit
|
|||||||
canfastwalk = false;
|
canfastwalk = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canfastwalk && this.fastWalk && this.path.size() >= 3)
|
|
||||||
{
|
|
||||||
this.path.poll();
|
|
||||||
this.path.poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
RoomTile next = this.path.poll();
|
RoomTile next = this.path.poll();
|
||||||
|
boolean overrideChecks = next != null && this.canOverrideTile(next);
|
||||||
|
|
||||||
if (this.path.isEmpty())
|
if (this.path.isEmpty())
|
||||||
{
|
{
|
||||||
this.sitUpdate = true;
|
this.sitUpdate = true;
|
||||||
|
|
||||||
if (next != null && room.hasHabbosAt(next.x, next.y))
|
if (next != null && next.hasUnits() && !overrideChecks)
|
||||||
{
|
{
|
||||||
if(!isHorse) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Deque<RoomTile> peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation);
|
Deque<RoomTile> peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this);
|
||||||
if (peekPath.size() >= 3)
|
if (peekPath.size() >= 3)
|
||||||
{
|
{
|
||||||
path.pop();
|
path.pop();
|
||||||
@ -205,6 +209,13 @@ public class RoomUnit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canfastwalk && this.fastWalk)
|
||||||
|
{
|
||||||
|
if(this.path.size() > 1) {
|
||||||
|
next = this.path.poll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (next == null)
|
if (next == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -241,10 +252,9 @@ public class RoomUnit
|
|||||||
|
|
||||||
HabboItem item = room.getTopItemAt(next.x, next.y);
|
HabboItem item = room.getTopItemAt(next.x, next.y);
|
||||||
|
|
||||||
|
|
||||||
//if(!(this.path.size() == 0 && canSitNextTile))
|
//if(!(this.path.size() == 0 && canSitNextTile))
|
||||||
{
|
{
|
||||||
if (!room.tileWalkable(next.x, next.y) && !(item instanceof InteractionTeleport))
|
if (!room.tileWalkable(next.x, next.y) && !overrideChecks)
|
||||||
{
|
{
|
||||||
this.room = room;
|
this.room = room;
|
||||||
this.findPath();
|
this.findPath();
|
||||||
@ -273,7 +283,7 @@ public class RoomUnit
|
|||||||
item = lowestChair;
|
item = lowestChair;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next.equals(this.goalLocation) && next.state == RoomTileState.SIT)
|
if (next.equals(this.goalLocation) && next.state == RoomTileState.SIT && !overrideChecks)
|
||||||
{
|
{
|
||||||
if (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)
|
if (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)
|
||||||
{
|
{
|
||||||
@ -284,10 +294,10 @@ public class RoomUnit
|
|||||||
|
|
||||||
double zHeight = 0.0D;
|
double zHeight = 0.0D;
|
||||||
|
|
||||||
if (((habbo != null && habbo.getHabboInfo().getRiding() != null) || isHorse) && next.equals(this.goalLocation) && (next.state == RoomTileState.SIT || next.state == RoomTileState.LAY)) {
|
/*if (((habbo != null && habbo.getHabboInfo().getRiding() != null) || isRiding) && next.equals(this.goalLocation) && (next.state == RoomTileState.SIT || next.state == RoomTileState.LAY)) {
|
||||||
this.status.remove(RoomUnitStatus.MOVE);
|
this.status.remove(RoomUnitStatus.MOVE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (habbo != null)
|
if (habbo != null)
|
||||||
{
|
{
|
||||||
@ -335,20 +345,7 @@ public class RoomUnit
|
|||||||
|
|
||||||
if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay())
|
if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay())
|
||||||
{
|
{
|
||||||
zHeight += item.getBaseItem().getHeight();
|
zHeight += Item.getCurrentHeight(item);
|
||||||
|
|
||||||
if (item instanceof InteractionMultiHeight)
|
|
||||||
{
|
|
||||||
if (item.getExtradata().length() == 0)
|
|
||||||
{
|
|
||||||
item.setExtradata("0");
|
|
||||||
}
|
|
||||||
zHeight += Item.getCurrentHeight(item);
|
|
||||||
}
|
|
||||||
else if (item instanceof InteractionFreezeBlock)
|
|
||||||
{
|
|
||||||
zHeight -= item.getBaseItem().getHeight();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -368,14 +365,14 @@ public class RoomUnit
|
|||||||
|
|
||||||
if (ridingUnit != null)
|
if (ridingUnit != null)
|
||||||
{
|
{
|
||||||
|
ridingUnit.setPreviousLocationZ(this.getZ());
|
||||||
this.setZ(zHeight - 1.0);
|
this.setZ(zHeight - 1.0);
|
||||||
ridingUnit.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.x, next.y)]);
|
ridingUnit.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.x, next.y)]);
|
||||||
ridingUnit.setPreviousLocation(this.getCurrentLocation());
|
ridingUnit.setPreviousLocation(this.getCurrentLocation());
|
||||||
ridingUnit.setGoalLocation(this.getGoal());
|
ridingUnit.setGoalLocation(this.getGoal());
|
||||||
ridingUnit.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + (zHeight - 1.0));
|
ridingUnit.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + (zHeight - 1.0));
|
||||||
ridingUnit.setZ(zHeight - 1.0);
|
|
||||||
room.sendComposer(new RoomUserStatusComposer(ridingUnit).compose());
|
room.sendComposer(new RoomUserStatusComposer(ridingUnit).compose());
|
||||||
|
//ridingUnit.setZ(zHeight - 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,7 +384,7 @@ public class RoomUnit
|
|||||||
|
|
||||||
if (habbo != null)
|
if (habbo != null)
|
||||||
{
|
{
|
||||||
if (next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY() && (!room.isPublicRoom()) || (room.isPublicRoom() && Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick")))
|
if (this.canLeaveRoomByDoor && next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY() && (!room.isPublicRoom()) || (room.isPublicRoom() && Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick")))
|
||||||
{
|
{
|
||||||
Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500);
|
Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500);
|
||||||
}
|
}
|
||||||
@ -566,8 +563,8 @@ public class RoomUnit
|
|||||||
if (location != null)
|
if (location != null)
|
||||||
{
|
{
|
||||||
this.startLocation = location;
|
this.startLocation = location;
|
||||||
this.previousLocation = location;
|
setPreviousLocation(location);
|
||||||
this.currentLocation = location;
|
setCurrentLocation(location);
|
||||||
this.goalLocation = location;
|
this.goalLocation = location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -576,7 +573,11 @@ public class RoomUnit
|
|||||||
{
|
{
|
||||||
if (location != null)
|
if (location != null)
|
||||||
{
|
{
|
||||||
this.currentLocation = location;
|
if(this.currentLocation != null) {
|
||||||
|
this.currentLocation.removeUnit(this);
|
||||||
|
}
|
||||||
|
this.currentLocation = location;
|
||||||
|
location.addUnit(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,9 +609,9 @@ public class RoomUnit
|
|||||||
|
|
||||||
public void findPath()
|
public void findPath()
|
||||||
{
|
{
|
||||||
if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y)))
|
if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation)))
|
||||||
{
|
{
|
||||||
this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation);
|
this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -799,4 +800,37 @@ public class RoomUnit
|
|||||||
{
|
{
|
||||||
return this.invisible;
|
return this.invisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Room getRoom() {
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canOverrideTile(RoomTile tile) {
|
||||||
|
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
|
||||||
|
return this.overridableTiles.contains(tileIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addOverrideTile(RoomTile tile) {
|
||||||
|
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
|
||||||
|
if(!this.overridableTiles.contains(tileIndex)) {
|
||||||
|
this.overridableTiles.add(tileIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeOverrideTile(RoomTile tile) {
|
||||||
|
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
|
||||||
|
this.overridableTiles.remove(tileIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearOverrideTiles() {
|
||||||
|
this.overridableTiles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canLeaveRoomByDoor() {
|
||||||
|
return canLeaveRoomByDoor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCanLeaveRoomByDoor(boolean canLeaveRoomByDoor) {
|
||||||
|
this.canLeaveRoomByDoor = canLeaveRoomByDoor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,15 @@ import com.eu.habbo.messages.outgoing.users.*;
|
|||||||
import com.eu.habbo.plugin.events.users.UserCreditsEvent;
|
import com.eu.habbo.plugin.events.users.UserCreditsEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserDisconnectEvent;
|
import com.eu.habbo.plugin.events.users.UserDisconnectEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserPointsEvent;
|
import com.eu.habbo.plugin.events.users.UserPointsEvent;
|
||||||
|
import gnu.trove.TIntCollection;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Map;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class Habbo implements Runnable
|
public class Habbo implements Runnable
|
||||||
{
|
{
|
||||||
@ -40,13 +41,11 @@ public class Habbo implements Runnable
|
|||||||
private volatile boolean disconnected = false;
|
private volatile boolean disconnected = false;
|
||||||
private volatile boolean disconnecting = false;
|
private volatile boolean disconnecting = false;
|
||||||
|
|
||||||
public boolean firstVisit = false;
|
|
||||||
|
|
||||||
public Habbo(ResultSet set)
|
public Habbo(ResultSet set)
|
||||||
{
|
{
|
||||||
this.client = null;
|
this.client = null;
|
||||||
this.habboInfo = new HabboInfo(set);
|
this.habboInfo = new HabboInfo(set);
|
||||||
this.habboStats = HabboStats.load(this);
|
this.habboStats = HabboStats.load(this.habboInfo);
|
||||||
this.habboInventory = new HabboInventory(this);
|
this.habboInventory = new HabboInventory(this);
|
||||||
|
|
||||||
this.messenger = new Messenger();
|
this.messenger = new Messenger();
|
||||||
@ -415,6 +414,7 @@ public class Habbo implements Runnable
|
|||||||
HabboBadge badge = BadgesComponent.createBadge(code, this);
|
HabboBadge badge = BadgesComponent.createBadge(code, this);
|
||||||
this.habboInventory.getBadgesComponent().addBadge(badge);
|
this.habboInventory.getBadgesComponent().addBadge(badge);
|
||||||
this.client.sendResponse(new AddUserBadgeComposer(badge));
|
this.client.sendResponse(new AddUserBadgeComposer(badge));
|
||||||
|
this.client.sendResponse(new AddHabboItemComposer(badge.getId(), AddHabboItemComposer.AddHabboItemCategory.BADGE));
|
||||||
|
|
||||||
THashMap<String, String> keys = new THashMap<>();
|
THashMap<String, String> keys = new THashMap<>();
|
||||||
keys.put("display", "BUBBLE");
|
keys.put("display", "BUBBLE");
|
||||||
@ -514,4 +514,14 @@ public class Habbo implements Runnable
|
|||||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo());
|
this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getForbiddenClothing() {
|
||||||
|
TIntCollection clothingIDs = this.getInventory().getWardrobeComponent().getClothing();
|
||||||
|
|
||||||
|
return Emulator.getGameEnvironment().getCatalogManager().clothing.values().stream()
|
||||||
|
.filter(c -> !clothingIDs.contains(c.id))
|
||||||
|
.map(c -> c.setId)
|
||||||
|
.flatMap(c -> Arrays.stream(c).boxed())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,14 @@ import com.eu.habbo.habbohotel.games.Game;
|
|||||||
import com.eu.habbo.habbohotel.games.GamePlayer;
|
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||||
import com.eu.habbo.habbohotel.permissions.Rank;
|
import com.eu.habbo.habbohotel.permissions.Rank;
|
||||||
import com.eu.habbo.habbohotel.pets.HorsePet;
|
import com.eu.habbo.habbohotel.pets.HorsePet;
|
||||||
|
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||||
|
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
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.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||||
|
import com.eu.habbo.threading.runnables.RoomUnitRidePet;
|
||||||
|
import com.eu.habbo.util.figure.FigureUtil;
|
||||||
import gnu.trove.map.hash.TIntIntHashMap;
|
import gnu.trove.map.hash.TIntIntHashMap;
|
||||||
import gnu.trove.procedure.TIntIntProcedure;
|
import gnu.trove.procedure.TIntIntProcedure;
|
||||||
|
|
||||||
@ -14,6 +21,8 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class HabboInfo implements Runnable
|
public class HabboInfo implements Runnable
|
||||||
{
|
{
|
||||||
@ -40,7 +49,7 @@ public class HabboInfo implements Runnable
|
|||||||
private Room currentRoom;
|
private Room currentRoom;
|
||||||
private int roomQueueId;
|
private int roomQueueId;
|
||||||
|
|
||||||
private HorsePet riding;
|
private RideablePet riding;
|
||||||
|
|
||||||
private Class<? extends Game> currentGame;
|
private Class<? extends Game> currentGame;
|
||||||
private TIntIntHashMap currencies;
|
private TIntIntHashMap currencies;
|
||||||
@ -52,6 +61,7 @@ public class HabboInfo implements Runnable
|
|||||||
private String photoJSON;
|
private String photoJSON;
|
||||||
private int webPublishTimestamp;
|
private int webPublishTimestamp;
|
||||||
private String machineID;
|
private String machineID;
|
||||||
|
public boolean firstVisit = false;
|
||||||
|
|
||||||
public HabboInfo(ResultSet set)
|
public HabboInfo(ResultSet set)
|
||||||
{
|
{
|
||||||
@ -71,6 +81,8 @@ public class HabboInfo implements Runnable
|
|||||||
if (this.rank == null)
|
if (this.rank == null)
|
||||||
{
|
{
|
||||||
Emulator.getLogging().logErrorLine("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists.");
|
Emulator.getLogging().logErrorLine("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists.");
|
||||||
|
Emulator.getLogging().logUserLine(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists.");
|
||||||
|
this.rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.accountCreated = set.getInt("account_created");
|
this.accountCreated = set.getInt("account_created");
|
||||||
@ -204,7 +216,9 @@ public class HabboInfo implements Runnable
|
|||||||
return this.look;
|
return this.look;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLook(String look) { this.look = look; }
|
public void setLook(String look) {
|
||||||
|
this.look = look;
|
||||||
|
}
|
||||||
|
|
||||||
public HabboGender getGender()
|
public HabboGender getGender()
|
||||||
{
|
{
|
||||||
@ -357,12 +371,49 @@ public class HabboInfo implements Runnable
|
|||||||
this.roomQueueId = roomQueueId;
|
this.roomQueueId = roomQueueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HorsePet getRiding()
|
public RideablePet getRiding()
|
||||||
{
|
{
|
||||||
return this.riding;
|
return this.riding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRiding(HorsePet riding)
|
public void dismountPet() {
|
||||||
|
this.dismountPet(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dismountPet(boolean isRemoving) {
|
||||||
|
if(this.getRiding() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Habbo habbo = this.getCurrentRoom().getHabbo(this.getId());
|
||||||
|
if(habbo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RideablePet riding = this.getRiding();
|
||||||
|
|
||||||
|
riding.setRider(null);
|
||||||
|
riding.setTask(PetTasks.FREE);
|
||||||
|
this.setRiding(null);
|
||||||
|
|
||||||
|
Room room = this.getCurrentRoom();
|
||||||
|
if(room != null)
|
||||||
|
room.giveEffect(habbo, 0, -1);
|
||||||
|
|
||||||
|
RoomUnit roomUnit = habbo.getRoomUnit();
|
||||||
|
if(roomUnit == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
roomUnit.setZ(riding.getRoomUnit().getZ());
|
||||||
|
roomUnit.setPreviousLocationZ(riding.getRoomUnit().getZ());
|
||||||
|
roomUnit.stopWalking();
|
||||||
|
room.sendComposer(new RoomUserStatusComposer(roomUnit).compose());
|
||||||
|
List<RoomTile> availableTiles = isRemoving ? new ArrayList<>() : this.getCurrentRoom().getLayout().getWalkableTilesAround(roomUnit.getCurrentLocation());
|
||||||
|
|
||||||
|
RoomTile tile = availableTiles.isEmpty() ? roomUnit.getCurrentLocation() : availableTiles.get(0);
|
||||||
|
roomUnit.setGoalLocation(tile);
|
||||||
|
roomUnit.statusUpdate(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRiding(RideablePet riding)
|
||||||
{
|
{
|
||||||
this.riding = riding;
|
this.riding = riding;
|
||||||
}
|
}
|
||||||
@ -468,7 +519,7 @@ public class HabboInfo implements Runnable
|
|||||||
statement.setInt(6, Emulator.getIntUnixTimestamp());
|
statement.setInt(6, Emulator.getIntUnixTimestamp());
|
||||||
statement.setInt(8, this.homeRoom);
|
statement.setInt(8, this.homeRoom);
|
||||||
statement.setString(9, this.ipLogin);
|
statement.setString(9, this.ipLogin);
|
||||||
statement.setInt(10, this.rank.getId());
|
statement.setInt(10, this.rank != null ? this.rank.getId() : 1);
|
||||||
statement.setString(11, this.machineID);
|
statement.setString(11, this.machineID);
|
||||||
statement.setString(12, this.username);
|
statement.setString(12, this.username);
|
||||||
statement.setInt(13, this.id);
|
statement.setInt(13, this.id);
|
||||||
@ -484,4 +535,13 @@ public class HabboInfo implements Runnable
|
|||||||
{
|
{
|
||||||
return this.getCurrencyAmount(Emulator.getConfig().getInt("hotelview.promotional.points.type"));
|
return this.getCurrencyAmount(Emulator.getConfig().getInt("hotelview.promotional.points.type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HabboStats getHabboStats() {
|
||||||
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getId());
|
||||||
|
if(habbo != null) {
|
||||||
|
return habbo.getHabboStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
return HabboStats.load(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers
|
|||||||
private int limitedSells;
|
private int limitedSells;
|
||||||
private boolean needsUpdate = false;
|
private boolean needsUpdate = false;
|
||||||
private boolean needsDelete = false;
|
private boolean needsDelete = false;
|
||||||
|
private boolean isFromGift = false;
|
||||||
|
|
||||||
public HabboItem(ResultSet set, Item baseItem) throws SQLException
|
public HabboItem(ResultSet set, Item baseItem) throws SQLException
|
||||||
{
|
{
|
||||||
@ -131,6 +132,12 @@ public abstract class HabboItem implements Runnable, IEventTriggers
|
|||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGiftAdjustedId() {
|
||||||
|
if (this.isFromGift) return -this.id;
|
||||||
|
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
public int getUserId()
|
public int getUserId()
|
||||||
{
|
{
|
||||||
return this.userId;
|
return this.userId;
|
||||||
@ -221,6 +228,10 @@ public abstract class HabboItem implements Runnable, IEventTriggers
|
|||||||
return this.needsUpdate;
|
return this.needsUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean needsDelete() {
|
||||||
|
return needsDelete;
|
||||||
|
}
|
||||||
|
|
||||||
public void needsUpdate(boolean value)
|
public void needsUpdate(boolean value)
|
||||||
{
|
{
|
||||||
this.needsUpdate = value;
|
this.needsUpdate = value;
|
||||||
@ -504,4 +515,12 @@ public abstract class HabboItem implements Runnable, IEventTriggers
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFromGift() {
|
||||||
|
return isFromGift;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFromGift(boolean fromGift) {
|
||||||
|
isFromGift = fromGift;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class HabboManager
|
|||||||
|
|
||||||
|
|
||||||
try(Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
try(Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE auth_ticket LIKE ? LIMIT 1"))
|
PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE auth_ticket = ? LIMIT 1"))
|
||||||
{
|
{
|
||||||
statement.setString(1, sso);
|
statement.setString(1, sso);
|
||||||
try (ResultSet set = statement.executeQuery())
|
try (ResultSet set = statement.executeQuery())
|
||||||
@ -119,18 +119,17 @@ public class HabboManager
|
|||||||
{
|
{
|
||||||
habbo = new Habbo(set);
|
habbo = new Habbo(set);
|
||||||
|
|
||||||
if (habbo.firstVisit)
|
if (habbo.getHabboInfo().firstVisit)
|
||||||
{
|
{
|
||||||
Emulator.getPluginManager().fireEvent(new UserRegisteredEvent(habbo));
|
Emulator.getPluginManager().fireEvent(new UserRegisteredEvent(habbo));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Emulator.debugging)
|
if (!Emulator.debugging)
|
||||||
{
|
{
|
||||||
try (PreparedStatement stmt = connection.prepareStatement("UPDATE users SET auth_ticket = ? WHERE auth_ticket LIKE ? AND id = ? LIMIT 1"))
|
try (PreparedStatement stmt = connection.prepareStatement("UPDATE users SET auth_ticket = ? WHERE id = ? LIMIT 1"))
|
||||||
{
|
{
|
||||||
stmt.setString(1, "");
|
stmt.setString(1, "");
|
||||||
stmt.setString(2, sso);
|
stmt.setInt(2, habbo.getHabboInfo().getId());
|
||||||
stmt.setInt(3, habbo.getHabboInfo().getId());
|
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
} catch (SQLException e)
|
} catch (SQLException e)
|
||||||
{
|
{
|
||||||
@ -152,6 +151,13 @@ public class HabboManager
|
|||||||
return habbo;
|
return habbo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HabboInfo getHabboInfo(int id) {
|
||||||
|
if(this.getHabbo(id) == null) {
|
||||||
|
return getOfflineHabboInfo(id);
|
||||||
|
}
|
||||||
|
return this.getHabbo(id).getHabboInfo();
|
||||||
|
}
|
||||||
|
|
||||||
public static HabboInfo getOfflineHabboInfo(int id)
|
public static HabboInfo getOfflineHabboInfo(int id)
|
||||||
{
|
{
|
||||||
HabboInfo info = null;
|
HabboInfo info = null;
|
||||||
@ -326,7 +332,7 @@ public class HabboManager
|
|||||||
if (!oldRank.getBadge().isEmpty())
|
if (!oldRank.getBadge().isEmpty())
|
||||||
{
|
{
|
||||||
habbo.deleteBadge(habbo.getInventory().getBadgesComponent().getBadge(oldRank.getBadge()));
|
habbo.deleteBadge(habbo.getInventory().getBadgesComponent().getBadge(oldRank.getBadge()));
|
||||||
BadgesComponent.deleteBadge(userId, oldRank.getBadge());
|
//BadgesComponent.deleteBadge(userId, oldRank.getBadge()); // unnecessary as Habbo.deleteBadge does this
|
||||||
}
|
}
|
||||||
|
|
||||||
habbo.getHabboInfo().setRank(newRank);
|
habbo.getHabboInfo().setRank(newRank);
|
||||||
|
@ -27,7 +27,7 @@ public class HabboStats implements Runnable
|
|||||||
{
|
{
|
||||||
private final int timeLoggedIn = Emulator.getIntUnixTimestamp();
|
private final int timeLoggedIn = Emulator.getIntUnixTimestamp();
|
||||||
|
|
||||||
private Habbo habbo;
|
private HabboInfo habboInfo;
|
||||||
|
|
||||||
public int achievementScore;
|
public int achievementScore;
|
||||||
public int respectPointsReceived;
|
public int respectPointsReceived;
|
||||||
@ -96,13 +96,15 @@ public class HabboStats implements Runnable
|
|||||||
public boolean allowNameChange;
|
public boolean allowNameChange;
|
||||||
public boolean isPurchasingFurniture = false;
|
public boolean isPurchasingFurniture = false;
|
||||||
|
|
||||||
|
public int forumPostsCount;
|
||||||
|
|
||||||
public THashMap<Integer, List<Integer>> ltdPurchaseLog = new THashMap<>(0);
|
public THashMap<Integer, List<Integer>> ltdPurchaseLog = new THashMap<>(0);
|
||||||
public long lastTradeTimestamp = Emulator.getIntUnixTimestamp();
|
public long lastTradeTimestamp = Emulator.getIntUnixTimestamp();
|
||||||
public long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp();
|
public long lastPurchaseTimestamp = Emulator.getIntUnixTimestamp();
|
||||||
public long lastGiftTimestamp = Emulator.getIntUnixTimestamp();
|
public long lastGiftTimestamp = Emulator.getIntUnixTimestamp();
|
||||||
public final TIntObjectMap<HabboOfferPurchase> offerCache = new TIntObjectHashMap<>();
|
public final TIntObjectMap<HabboOfferPurchase> offerCache = new TIntObjectHashMap<>();
|
||||||
|
|
||||||
private HabboStats(ResultSet set, Habbo habbo) throws SQLException
|
private HabboStats(ResultSet set, HabboInfo habboInfo) throws SQLException
|
||||||
{
|
{
|
||||||
this.cache = new THashMap<>(0);
|
this.cache = new THashMap<>(0);
|
||||||
this.achievementProgress = new THashMap<>(0);
|
this.achievementProgress = new THashMap<>(0);
|
||||||
@ -113,7 +115,7 @@ public class HabboStats implements Runnable
|
|||||||
this.secretRecipes = new TIntArrayList(0);
|
this.secretRecipes = new TIntArrayList(0);
|
||||||
this.calendarRewardsClaimed = new TIntArrayList(0);
|
this.calendarRewardsClaimed = new TIntArrayList(0);
|
||||||
|
|
||||||
this.habbo = habbo;
|
this.habboInfo = habboInfo;
|
||||||
|
|
||||||
this.achievementScore = set.getInt("achievement_score");
|
this.achievementScore = set.getInt("achievement_score");
|
||||||
this.respectPointsReceived = set.getInt("respects_received");
|
this.respectPointsReceived = set.getInt("respects_received");
|
||||||
@ -148,11 +150,12 @@ public class HabboStats implements Runnable
|
|||||||
this.muteEndTime = set.getInt("mute_end_timestamp");
|
this.muteEndTime = set.getInt("mute_end_timestamp");
|
||||||
this.allowNameChange = set.getString("allow_name_change").equalsIgnoreCase("1");
|
this.allowNameChange = set.getString("allow_name_change").equalsIgnoreCase("1");
|
||||||
this.perkTrade = set.getString("perk_trade").equalsIgnoreCase("1");
|
this.perkTrade = set.getString("perk_trade").equalsIgnoreCase("1");
|
||||||
|
this.forumPostsCount = set.getInt("forums_post_count");
|
||||||
this.nuxReward = this.nux;
|
this.nuxReward = this.nux;
|
||||||
|
|
||||||
try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM user_window_settings WHERE user_id = ? LIMIT 1"))
|
try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM user_window_settings WHERE user_id = ? LIMIT 1"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, this.habbo.getHabboInfo().getId());
|
statement.setInt(1, this.habboInfo.getId());
|
||||||
try (ResultSet nSet = statement.executeQuery())
|
try (ResultSet nSet = statement.executeQuery())
|
||||||
{
|
{
|
||||||
if (nSet.next())
|
if (nSet.next())
|
||||||
@ -163,18 +166,18 @@ public class HabboStats implements Runnable
|
|||||||
{
|
{
|
||||||
try (PreparedStatement stmt = statement.getConnection().prepareStatement("INSERT INTO user_window_settings (user_id) VALUES (?)"))
|
try (PreparedStatement stmt = statement.getConnection().prepareStatement("INSERT INTO user_window_settings (user_id) VALUES (?)"))
|
||||||
{
|
{
|
||||||
stmt.setInt(1, this.habbo.getHabboInfo().getId());
|
stmt.setInt(1, this.habboInfo.getId());
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.navigatorWindowSettings = new HabboNavigatorWindowSettings(habbo.getHabboInfo().getId());
|
this.navigatorWindowSettings = new HabboNavigatorWindowSettings(habboInfo.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_navigator_settings WHERE user_id = ?"))
|
try (PreparedStatement statement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_navigator_settings WHERE user_id = ?"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, this.habbo.getHabboInfo().getId());
|
statement.setInt(1, this.habboInfo.getId());
|
||||||
try (ResultSet nSet = statement.executeQuery())
|
try (ResultSet nSet = statement.executeQuery())
|
||||||
{
|
{
|
||||||
while (nSet.next())
|
while (nSet.next())
|
||||||
@ -186,7 +189,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (PreparedStatement favoriteRoomsStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_favorite_rooms WHERE user_id = ?"))
|
try (PreparedStatement favoriteRoomsStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_favorite_rooms WHERE user_id = ?"))
|
||||||
{
|
{
|
||||||
favoriteRoomsStatement.setInt(1, this.habbo.getHabboInfo().getId());
|
favoriteRoomsStatement.setInt(1, this.habboInfo.getId());
|
||||||
try (ResultSet favoriteSet = favoriteRoomsStatement.executeQuery())
|
try (ResultSet favoriteSet = favoriteRoomsStatement.executeQuery())
|
||||||
{
|
{
|
||||||
while (favoriteSet.next())
|
while (favoriteSet.next())
|
||||||
@ -199,7 +202,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (PreparedStatement recipesStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_recipes WHERE user_id = ?"))
|
try (PreparedStatement recipesStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_recipes WHERE user_id = ?"))
|
||||||
{
|
{
|
||||||
recipesStatement.setInt(1, this.habbo.getHabboInfo().getId());
|
recipesStatement.setInt(1, this.habboInfo.getId());
|
||||||
try (ResultSet recipeSet = recipesStatement.executeQuery())
|
try (ResultSet recipeSet = recipesStatement.executeQuery())
|
||||||
{
|
{
|
||||||
while (recipeSet.next())
|
while (recipeSet.next())
|
||||||
@ -211,7 +214,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (PreparedStatement calendarRewardsStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM calendar_rewards_claimed WHERE user_id = ?"))
|
try (PreparedStatement calendarRewardsStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM calendar_rewards_claimed WHERE user_id = ?"))
|
||||||
{
|
{
|
||||||
calendarRewardsStatement.setInt(1, this.habbo.getHabboInfo().getId());
|
calendarRewardsStatement.setInt(1, this.habboInfo.getId());
|
||||||
try (ResultSet rewardSet = calendarRewardsStatement.executeQuery())
|
try (ResultSet rewardSet = calendarRewardsStatement.executeQuery())
|
||||||
{
|
{
|
||||||
while (rewardSet.next())
|
while (rewardSet.next())
|
||||||
@ -223,7 +226,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (PreparedStatement ltdPurchaseLogStatement = set.getStatement().getConnection().prepareStatement("SELECT catalog_item_id, timestamp FROM catalog_items_limited WHERE user_id = ? AND timestamp > ?"))
|
try (PreparedStatement ltdPurchaseLogStatement = set.getStatement().getConnection().prepareStatement("SELECT catalog_item_id, timestamp FROM catalog_items_limited WHERE user_id = ? AND timestamp > ?"))
|
||||||
{
|
{
|
||||||
ltdPurchaseLogStatement.setInt(1, this.habbo.getHabboInfo().getId());
|
ltdPurchaseLogStatement.setInt(1, this.habboInfo.getId());
|
||||||
ltdPurchaseLogStatement.setInt(2, Emulator.getIntUnixTimestamp() - 86400);
|
ltdPurchaseLogStatement.setInt(2, Emulator.getIntUnixTimestamp() - 86400);
|
||||||
try (ResultSet ltdSet = ltdPurchaseLogStatement.executeQuery())
|
try (ResultSet ltdSet = ltdPurchaseLogStatement.executeQuery())
|
||||||
{
|
{
|
||||||
@ -236,7 +239,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (PreparedStatement ignoredPlayersStatement = set.getStatement().getConnection().prepareStatement("SELECT target_id FROM users_ignored WHERE user_id = ?"))
|
try (PreparedStatement ignoredPlayersStatement = set.getStatement().getConnection().prepareStatement("SELECT target_id FROM users_ignored WHERE user_id = ?"))
|
||||||
{
|
{
|
||||||
ignoredPlayersStatement.setInt(1, this.habbo.getHabboInfo().getId());
|
ignoredPlayersStatement.setInt(1, this.habboInfo.getId());
|
||||||
try (ResultSet ignoredSet = ignoredPlayersStatement.executeQuery())
|
try (ResultSet ignoredSet = ignoredPlayersStatement.executeQuery())
|
||||||
{
|
{
|
||||||
while (ignoredSet.next())
|
while (ignoredSet.next())
|
||||||
@ -248,7 +251,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (PreparedStatement loadOfferPurchaseStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_target_offer_purchases WHERE user_id = ?"))
|
try (PreparedStatement loadOfferPurchaseStatement = set.getStatement().getConnection().prepareStatement("SELECT * FROM users_target_offer_purchases WHERE user_id = ?"))
|
||||||
{
|
{
|
||||||
loadOfferPurchaseStatement.setInt(1, this.habbo.getHabboInfo().getId());
|
loadOfferPurchaseStatement.setInt(1, this.habboInfo.getId());
|
||||||
try (ResultSet offerSet = loadOfferPurchaseStatement.executeQuery())
|
try (ResultSet offerSet = loadOfferPurchaseStatement.executeQuery())
|
||||||
{
|
{
|
||||||
while (offerSet.next())
|
while (offerSet.next())
|
||||||
@ -264,7 +267,7 @@ public class HabboStats implements Runnable
|
|||||||
{
|
{
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
|
||||||
{
|
{
|
||||||
try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ? WHERE user_id = ? LIMIT 1"))
|
try (PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET achievement_score = ?, respects_received = ?, respects_given = ?, daily_respect_points = ?, block_following = ?, block_friendrequests = ?, online_time = online_time + ?, guild_id = ?, daily_pet_respect_points = ?, club_expire_timestamp = ?, login_streak = ?, rent_space_id = ?, rent_space_endtime = ?, volume_system = ?, volume_furni = ?, volume_trax = ?, block_roominvites = ?, old_chat = ?, block_camera_follow = ?, chat_color = ?, hof_points = ?, block_alerts = ?, talent_track_citizenship_level = ?, talent_track_helpers_level = ?, ignore_bots = ?, ignore_pets = ?, nux = ?, mute_end_timestamp = ?, allow_name_change = ?, perk_trade = ?, can_trade = ?, `forums_post_count` = ? WHERE user_id = ? LIMIT 1"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, this.achievementScore);
|
statement.setInt(1, this.achievementScore);
|
||||||
statement.setInt(2, this.respectPointsReceived);
|
statement.setInt(2, this.respectPointsReceived);
|
||||||
@ -297,7 +300,8 @@ public class HabboStats implements Runnable
|
|||||||
statement.setString(29, this.allowNameChange ? "1" : "0");
|
statement.setString(29, this.allowNameChange ? "1" : "0");
|
||||||
statement.setString(30, this.perkTrade ? "1" : "0");
|
statement.setString(30, this.perkTrade ? "1" : "0");
|
||||||
statement.setString(31, this.allowTrade ? "1" : "0");
|
statement.setString(31, this.allowTrade ? "1" : "0");
|
||||||
statement.setInt(32, this.habbo.getHabboInfo().getId());
|
statement.setInt(32, this.forumPostsCount);
|
||||||
|
statement.setInt(33, this.habboInfo.getId());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +312,7 @@ public class HabboStats implements Runnable
|
|||||||
statement.setInt(3, this.navigatorWindowSettings.width);
|
statement.setInt(3, this.navigatorWindowSettings.width);
|
||||||
statement.setInt(4, this.navigatorWindowSettings.height);
|
statement.setInt(4, this.navigatorWindowSettings.height);
|
||||||
statement.setString(5, this.navigatorWindowSettings.openSearches ? "1" : "0");
|
statement.setString(5, this.navigatorWindowSettings.openSearches ? "1" : "0");
|
||||||
statement.setInt(6, this.habbo.getHabboInfo().getId());
|
statement.setInt(6, this.habboInfo.getId());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +327,7 @@ public class HabboStats implements Runnable
|
|||||||
statement.setInt(1, purchase.getState());
|
statement.setInt(1, purchase.getState());
|
||||||
statement.setInt(2, purchase.getAmount());
|
statement.setInt(2, purchase.getAmount());
|
||||||
statement.setInt(3, purchase.getLastPurchaseTimestamp());
|
statement.setInt(3, purchase.getLastPurchaseTimestamp());
|
||||||
statement.setInt(4, this.habbo.getHabboInfo().getId());
|
statement.setInt(4, this.habboInfo.getId());
|
||||||
statement.setInt(5, purchase.getOfferId());
|
statement.setInt(5, purchase.getOfferId());
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
@ -341,17 +345,17 @@ public class HabboStats implements Runnable
|
|||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
this.run();
|
this.run();
|
||||||
this.habbo = null;
|
this.habboInfo = null;
|
||||||
this.recentPurchases.clear();
|
this.recentPurchases.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HabboStats createNewStats(Habbo habbo)
|
private static HabboStats createNewStats(HabboInfo habboInfo)
|
||||||
{
|
{
|
||||||
habbo.firstVisit = true;
|
habboInfo.firstVisit = true;
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_settings (user_id) VALUES (?)"))
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_settings (user_id) VALUES (?)"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, habbo.getHabboInfo().getId());
|
statement.setInt(1, habboInfo.getId());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@ -359,27 +363,27 @@ public class HabboStats implements Runnable
|
|||||||
Emulator.getLogging().logSQLException(e);
|
Emulator.getLogging().logSQLException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return load(habbo);
|
return load(habboInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HabboStats load(Habbo habbo)
|
public static HabboStats load(HabboInfo habboInfo)
|
||||||
{
|
{
|
||||||
HabboStats stats = null;
|
HabboStats stats = null;
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
|
||||||
{
|
{
|
||||||
try(PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_settings WHERE user_id = ? LIMIT 1"))
|
try(PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_settings WHERE user_id = ? LIMIT 1"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, habbo.getHabboInfo().getId());
|
statement.setInt(1, habboInfo.getId());
|
||||||
try (ResultSet set = statement.executeQuery())
|
try (ResultSet set = statement.executeQuery())
|
||||||
{
|
{
|
||||||
set.first();
|
set.first();
|
||||||
if (set.getRow() != 0)
|
if (set.getRow() != 0)
|
||||||
{
|
{
|
||||||
stats = new HabboStats(set, habbo);
|
stats = new HabboStats(set, habboInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stats = createNewStats(habbo);
|
stats = createNewStats(habboInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -388,7 +392,7 @@ public class HabboStats implements Runnable
|
|||||||
{
|
{
|
||||||
try (PreparedStatement statement = connection.prepareStatement("SELECT guild_id FROM guilds_members WHERE user_id = ? AND level_id < 3 LIMIT 100"))
|
try (PreparedStatement statement = connection.prepareStatement("SELECT guild_id FROM guilds_members WHERE user_id = ? AND level_id < 3 LIMIT 100"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, habbo.getHabboInfo().getId());
|
statement.setInt(1, habboInfo.getId());
|
||||||
try (ResultSet set = statement.executeQuery())
|
try (ResultSet set = statement.executeQuery())
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -405,7 +409,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (PreparedStatement statement = connection.prepareStatement("SELECT room_id FROM room_votes WHERE user_id = ?"))
|
try (PreparedStatement statement = connection.prepareStatement("SELECT room_id FROM room_votes WHERE user_id = ?"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, habbo.getHabboInfo().getId());
|
statement.setInt(1, habboInfo.getId());
|
||||||
try (ResultSet set = statement.executeQuery())
|
try (ResultSet set = statement.executeQuery())
|
||||||
{
|
{
|
||||||
while (set.next())
|
while (set.next())
|
||||||
@ -417,7 +421,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_achievements WHERE user_id = ?"))
|
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_achievements WHERE user_id = ?"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, habbo.getHabboInfo().getId());
|
statement.setInt(1, habboInfo.getId());
|
||||||
try (ResultSet set = statement.executeQuery())
|
try (ResultSet set = statement.executeQuery())
|
||||||
{
|
{
|
||||||
while (set.next())
|
while (set.next())
|
||||||
@ -566,7 +570,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_favorite_rooms (user_id, room_id) VALUES (?, ?)"))
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_favorite_rooms (user_id, room_id) VALUES (?, ?)"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, this.habbo.getHabboInfo().getId());
|
statement.setInt(1, this.habboInfo.getId());
|
||||||
statement.setInt(2, roomId);
|
statement.setInt(2, roomId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
@ -585,7 +589,7 @@ public class HabboStats implements Runnable
|
|||||||
{
|
{
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_favorite_rooms WHERE user_id = ? AND room_id = ? LIMIT 1"))
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_favorite_rooms WHERE user_id = ? AND room_id = ? LIMIT 1"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, this.habbo.getHabboInfo().getId());
|
statement.setInt(1, this.habboInfo.getId());
|
||||||
statement.setInt(2, roomId);
|
statement.setInt(2, roomId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
@ -618,7 +622,7 @@ public class HabboStats implements Runnable
|
|||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_recipes (user_id, recipe) VALUES (?, ?)"))
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_recipes (user_id, recipe) VALUES (?, ?)"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, this.habbo.getHabboInfo().getId());
|
statement.setInt(1, this.habboInfo.getId());
|
||||||
statement.setInt(2, id);
|
statement.setInt(2, id);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
@ -723,7 +727,7 @@ public class HabboStats implements Runnable
|
|||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)"))
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, this.habbo.getHabboInfo().getId());
|
statement.setInt(1, this.habboInfo.getId());
|
||||||
statement.setInt(2, userId);
|
statement.setInt(2, userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
@ -743,7 +747,7 @@ public class HabboStats implements Runnable
|
|||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM users_ignored WHERE user_id = ? AND target_id = ?"))
|
PreparedStatement statement = connection.prepareStatement("DELETE FROM users_ignored WHERE user_id = ? AND target_id = ?"))
|
||||||
{
|
{
|
||||||
statement.setInt(1, this.habbo.getHabboInfo().getId());
|
statement.setInt(1, this.habboInfo.getId());
|
||||||
statement.setInt(2, userId);
|
statement.setInt(2, userId);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,9 @@ public class BadgesComponent
|
|||||||
{
|
{
|
||||||
boolean delete = true;
|
boolean delete = true;
|
||||||
|
|
||||||
for (Rank rank : Emulator.getGameEnvironment().getPermissionsManager().getRanks(badge.getCode()))
|
for (Rank rank : Emulator.getGameEnvironment().getPermissionsManager().getRanksByBadgeCode(badge.getCode()))
|
||||||
{
|
{
|
||||||
if (rank.getId() == habbo.getHabboInfo().getId())
|
if (rank.getId() == habbo.getHabboInfo().getRank().getId())
|
||||||
{
|
{
|
||||||
delete = false;
|
delete = false;
|
||||||
break;
|
break;
|
||||||
|
@ -117,7 +117,7 @@ public class ItemsComponent
|
|||||||
|
|
||||||
public HabboItem getHabboItem(int itemId)
|
public HabboItem getHabboItem(int itemId)
|
||||||
{
|
{
|
||||||
return this.items.get(itemId);
|
return this.items.get(Math.abs(itemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HabboItem getAndRemoveHabboItem(final Item item)
|
public HabboItem getAndRemoveHabboItem(final Item item)
|
||||||
|
@ -217,7 +217,7 @@ public class WiredHandler
|
|||||||
private static boolean triggerEffect(InteractionWiredEffect effect, RoomUnit roomUnit, Room room, Object[] stuff, long millis)
|
private static boolean triggerEffect(InteractionWiredEffect effect, RoomUnit roomUnit, Room room, Object[] stuff, long millis)
|
||||||
{
|
{
|
||||||
boolean executed = false;
|
boolean executed = false;
|
||||||
if (effect.canExecute(millis))
|
if (effect != null && effect.canExecute(millis))
|
||||||
{
|
{
|
||||||
executed = true;
|
executed = true;
|
||||||
if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser()))
|
if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser()))
|
||||||
|
@ -549,9 +549,9 @@ public class PacketManager
|
|||||||
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
|
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
|
||||||
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
|
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
|
||||||
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
|
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
|
||||||
this.registerHandler(Incoming.HorseUseItemEvent, HorseUseItemEvent.class);
|
this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class);
|
||||||
this.registerHandler(Incoming.HorseRideSettingsEvent, HorseRideSettingsEvent.class);
|
this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class);
|
||||||
this.registerHandler(Incoming.HorseRideEvent, HorseRideEvent.class);
|
this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class);
|
||||||
this.registerHandler(Incoming.ToggleMonsterplantBreedableEvent, ToggleMonsterplantBreedableEvent.class);
|
this.registerHandler(Incoming.ToggleMonsterplantBreedableEvent, ToggleMonsterplantBreedableEvent.class);
|
||||||
this.registerHandler(Incoming.CompostMonsterplantEvent, CompostMonsterplantEvent.class);
|
this.registerHandler(Incoming.CompostMonsterplantEvent, CompostMonsterplantEvent.class);
|
||||||
this.registerHandler(Incoming.BreedMonsterplantsEvent, BreedMonsterplantsEvent.class);
|
this.registerHandler(Incoming.BreedMonsterplantsEvent, BreedMonsterplantsEvent.class);
|
||||||
|
@ -396,9 +396,9 @@ public class PacketManager_1006
|
|||||||
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
|
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
|
||||||
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
|
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
|
||||||
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
|
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
|
||||||
this.registerHandler(Incoming.HorseUseItemEvent, HorseUseItemEvent.class);
|
this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class);
|
||||||
this.registerHandler(Incoming.HorseRideSettingsEvent, HorseRideSettingsEvent.class);
|
this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class);
|
||||||
this.registerHandler(Incoming.HorseRideEvent, HorseRideEvent.class);
|
this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerWired()
|
void registerWired()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.eu.habbo.messages.incoming.ambassadors;
|
package com.eu.habbo.messages.incoming.ambassadors;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.modtool.ScripterManager;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||||
@ -13,7 +14,7 @@ public class AmbassadorAlertCommandEvent extends MessageHandler
|
|||||||
public void handle() throws Exception
|
public void handle() throws Exception
|
||||||
{
|
{
|
||||||
if(!this.client.getHabbo().hasPermission("acc_ambassador")) {
|
if(!this.client.getHabbo().hasPermission("acc_ambassador")) {
|
||||||
Emulator.getGameEnvironment().getModToolManager().quickTicket(client.getHabbo(), "Scripter", Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", client.getHabbo().getHabboInfo().getUsername()).replace("%message%", "${notification.ambassador.alert.warning.message}"));
|
ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", client.getHabbo().getHabboInfo().getUsername()).replace("%message%", "${notification.ambassador.alert.warning.message}"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.catalog;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
||||||
|
import com.eu.habbo.habbohotel.modtool.ScripterManager;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.catalog.CatalogPageComposer;
|
import com.eu.habbo.messages.outgoing.catalog.CatalogPageComposer;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ public class RequestCatalogPageEvent extends MessageHandler
|
|||||||
{
|
{
|
||||||
if(!page.isVisible())
|
if(!page.isVisible())
|
||||||
{
|
{
|
||||||
Emulator.getGameEnvironment().getModToolManager().quickTicket(this.client.getHabbo(), "Scripter", Emulator.getTexts().getValue("scripter.warning.catalog.page").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%pagename%", page.getCaption()));
|
ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.catalog.page").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%pagename%", page.getCaption()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.catalog.marketplace;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace;
|
import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace;
|
||||||
|
import com.eu.habbo.habbohotel.modtool.ScripterManager;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseFailedComposer;
|
import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseFailedComposer;
|
||||||
@ -30,7 +31,7 @@ public class SellItemEvent extends MessageHandler
|
|||||||
if (!item.getBaseItem().allowMarketplace())
|
if (!item.getBaseItem().allowMarketplace())
|
||||||
{
|
{
|
||||||
String message = Emulator.getTexts().getValue("scripter.warning.marketplace.forbidden").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + "");
|
String message = Emulator.getTexts().getValue("scripter.warning.marketplace.forbidden").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + "");
|
||||||
Emulator.getGameEnvironment().getModToolManager().quickTicket(this.client.getHabbo(), "Scripter", message);
|
ScripterManager.scripterDetected(this.client, message);
|
||||||
Emulator.getLogging().logUserLine(message);
|
Emulator.getLogging().logUserLine(message);
|
||||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
return;
|
return;
|
||||||
@ -39,7 +40,7 @@ public class SellItemEvent extends MessageHandler
|
|||||||
if(credits < 0)
|
if(credits < 0)
|
||||||
{
|
{
|
||||||
String message = Emulator.getTexts().getValue("scripter.warning.marketplace.negative").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + "");
|
String message = Emulator.getTexts().getValue("scripter.warning.marketplace.negative").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + "");
|
||||||
Emulator.getGameEnvironment().getModToolManager().quickTicket(this.client.getHabbo(), "Scripter", message);
|
ScripterManager.scripterDetected(this.client, message);
|
||||||
Emulator.getLogging().logUserLine(message);
|
Emulator.getLogging().logUserLine(message);
|
||||||
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
|
||||||
return;
|
return;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user