mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 00:40:52 +01:00
Merge branch 'dev' into 'master'
2-3-0 Closes #480, #351, #352, #349, #339, #340, #331, #333, #328, #337, #338, #327, #336, #335, #326, #320, #305, #302, #308, #309, #310, #312, #314, #315, #313, and #107 See merge request morningstar/Arcturus-Community!107
This commit is contained in:
commit
0782929e72
15
.gitlab-ci.yml
Normal file
15
.gitlab-ci.yml
Normal file
@ -0,0 +1,15 @@
|
||||
image: maven:latest
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- target/
|
||||
|
||||
build:
|
||||
script:
|
||||
- mvn package
|
||||
only:
|
||||
- dev
|
||||
- master
|
||||
artifacts:
|
||||
paths:
|
||||
- target/Habbo-*.jar
|
@ -11,8 +11,8 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha
|
||||
Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt).
|
||||
|
||||
## Versions ##
|
||||
![image](https://img.shields.io/badge/VERSION-2.2.2-success.svg?style=for-the-badge&logo=appveyor)
|
||||
![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor)
|
||||
![image](https://img.shields.io/badge/VERSION-2.3.0-success.svg?style=for-the-badge&logo=appveyor)
|
||||
![image](https://img.shields.io/badge/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor)
|
||||
|
||||
Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases
|
||||
|
||||
@ -32,8 +32,7 @@ When making an bug report or a feature request use the template we provide so th
|
||||
- Harmony
|
||||
- Quadral (Pathfinder)
|
||||
- Skeletor
|
||||
- Arpyage
|
||||
- ItsGiuseppe
|
||||
- z
|
||||
|
||||
## Discord ##
|
||||
Join us on Discord at https://discord.gg/BzfFsTp
|
||||
|
24
pom.xml
24
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.eu.habbo</groupId>
|
||||
<artifactId>Habbo</artifactId>
|
||||
<version>2.2.2</version>
|
||||
<version>2.3.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -79,7 +79,11 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<url>http://repo1.maven.org/maven2/</url>
|
||||
<url>https://repo1.maven.org/maven2/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mvnrepo</id>
|
||||
<url>https://mvnrepository.com/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
@ -91,6 +95,14 @@
|
||||
<version>4.1.36.Final</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.fusesource.jansi/jansi -->
|
||||
<dependency>
|
||||
<groupId>org.fusesource.jansi</groupId>
|
||||
<artifactId>jansi</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-codec-http</artifactId>
|
||||
@ -182,4 +194,12 @@
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Internal repo</name>
|
||||
<url>file:///home/thara/testesb/in</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
32
sqlupdates/2_2_2_TO_2_3_0-RC-1.sql
Normal file
32
sqlupdates/2_2_2_TO_2_3_0-RC-1.sql
Normal file
@ -0,0 +1,32 @@
|
||||
CREATE TABLE `sanctions` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`habbo_id` int(11) NOT NULL DEFAULT '0',
|
||||
`sanction_level` int(11) NOT NULL DEFAULT '0',
|
||||
`probation_timestamp` int(32) NOT NULL DEFAULT '0',
|
||||
`reason` varchar(255) NOT NULL DEFAULT '',
|
||||
`trade_locked_until` int(32) NOT NULL DEFAULT '0',
|
||||
`is_muted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`mute_duration` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `sanction_levels` (
|
||||
`level` int(1) NOT NULL,
|
||||
`type` enum('ALERT', 'BAN', 'MUTE') NOT NULL,
|
||||
`hour_length` int(12) NOT NULL,
|
||||
`probation_days` int(12) NOT NULL,
|
||||
PRIMARY KEY (`level`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
ALTER TABLE `sanction_levels`
|
||||
ADD CONSTRAINT `level` CHECK (`level`<=7);
|
||||
|
||||
INSERT INTO `sanction_levels` VALUES (1, 'ALERT', 0, 30);
|
||||
INSERT INTO `sanction_levels` VALUES (2, 'MUTE', 1, 30);
|
||||
INSERT INTO `sanction_levels` VALUES (3, 'BAN', 18, 30);
|
||||
INSERT INTO `sanction_levels` VALUES (4, 'BAN', 168, 30);
|
||||
INSERT INTO `sanction_levels` VALUES (5, 'BAN', 720, 60);
|
||||
INSERT INTO `sanction_levels` VALUES (6, 'BAN', 720, 60);
|
||||
INSERT INTO `sanction_levels` VALUES (7, 'BAN', 876581, 876581);
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.sanctions.enabled', '1');
|
23
sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql
Normal file
23
sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql
Normal file
@ -0,0 +1,23 @@
|
||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish', '5');
|
||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish.type', '0');
|
||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.type', '0');
|
||||
|
||||
ALTER TABLE `room_promotions`
|
||||
ADD COLUMN `start_timestamp` int(11) NOT NULL DEFAULT -1 AFTER `end_timestamp`;
|
||||
ALTER TABLE `room_promotions`
|
||||
ADD COLUMN `category` int(11) NOT NULL DEFAULT 0 AFTER `start_timestamp`;
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('navigator.eventcategories', '1,Hottest Events,false;2,Parties & Music,true;3,Role Play,true;4,Help Desk,true;5,Trading,true;6,Games,true;7,Debates & Discussions,true;8,Grand Openings,true;9,Friending,true;10,Jobs,true;11,Group Events,true');
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('room.promotion.badge', 'RADZZ');
|
||||
|
||||
CREATE TABLE `guild_forum_views` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`guild_id` int(11) NOT NULL,
|
||||
`timestamp` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
ALTER TABLE `support_tickets`
|
||||
ADD COLUMN `photo_item_id` int(11) NOT NULL DEFAULT -1 AFTER `comment_id`;
|
7
sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql
Normal file
7
sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql
Normal file
@ -0,0 +1,7 @@
|
||||
ALTER TABLE `users_pets`
|
||||
ADD COLUMN `saddle_item_id` int(11) NULL;
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!');
|
||||
|
||||
UPDATE `items_base` SET `customparams` = '1,true' WHERE `item_name` = 'wf_blob';
|
||||
UPDATE `items_base` SET `customparams` = '5,false' WHERE `item_name` = 'wf_blob2';
|
7
sqlupdates/2_3_0-RC-2_TO_2_3_0.sql
Normal file
7
sqlupdates/2_3_0-RC-2_TO_2_3_0.sql
Normal file
@ -0,0 +1,7 @@
|
||||
ALTER TABLE `users_pets`
|
||||
ADD COLUMN `saddle_item_id` int(11) NULL;
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!');
|
||||
|
||||
UPDATE `items_base` SET `customparams` = '1,true' WHERE `item_name` = 'wf_blob';
|
||||
UPDATE `items_base` SET `customparams` = '5,false' WHERE `item_name` = 'wf_blob2';
|
2
sqlupdates/2_3_0-RC-3 TO 2_3_0.sql
Normal file
2
sqlupdates/2_3_0-RC-3 TO 2_3_0.sql
Normal file
@ -0,0 +1,2 @@
|
||||
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.generic.cmd_commands.text', 'Your Commands');
|
||||
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_stand', 'stand');
|
@ -17,6 +17,7 @@ import com.eu.habbo.plugin.events.emulator.EmulatorStartShutdownEvent;
|
||||
import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent;
|
||||
import com.eu.habbo.threading.ThreadPooling;
|
||||
import com.eu.habbo.util.imager.badges.BadgeImager;
|
||||
import org.fusesource.jansi.AnsiConsole;
|
||||
|
||||
import java.io.*;
|
||||
import java.security.MessageDigest;
|
||||
@ -28,32 +29,37 @@ import java.util.Random;
|
||||
|
||||
public final class Emulator {
|
||||
|
||||
|
||||
public final static int MAJOR = 2;
|
||||
public final static int MINOR = 3;
|
||||
public final static int BUILD = 0;
|
||||
public static final String ANSI_RED = "\u001B[31m";
|
||||
public static final String ANSI_BLUE = "\u001B[34m";
|
||||
public static final String ANSI_PURPLE = "\u001B[35m";
|
||||
public static final String ANSI_WHITE = "\u001B[37m";
|
||||
public static final String ANSI_YELLOW = "\u001B[33m";
|
||||
|
||||
|
||||
public final static int MINOR = 2;
|
||||
|
||||
|
||||
public final static int BUILD = 2;
|
||||
|
||||
|
||||
public final static String PREVIEW = "Stable";
|
||||
public final static String PREVIEW = "RC-3";
|
||||
|
||||
public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW;
|
||||
private static final String logo =
|
||||
"\n" +
|
||||
"███╗ ███╗ ██████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ ███████╗████████╗ █████╗ ██████╗ \n" +
|
||||
"████╗ ████║██╔═══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗\n" +
|
||||
"██╔████╔██║██║ ██║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗███████╗ ██║ ███████║██████╔╝\n" +
|
||||
"██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" +
|
||||
"██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" +
|
||||
"╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" +
|
||||
" ";
|
||||
|
||||
" \n" +
|
||||
" __ ___ _ A R C T U R U S __ \n" +
|
||||
" / |/ /___ _________ (_)___ ____ ______/ /_____ ______ \n" +
|
||||
" / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" +
|
||||
" / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" +
|
||||
"/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" +
|
||||
" /____/ \n" ;
|
||||
public static String build = "";
|
||||
public static boolean isReady = false;
|
||||
public static boolean isShuttingDown = false;
|
||||
public static boolean stopped = false;
|
||||
public static boolean debugging = false;
|
||||
private static String classPath = System.getProperty("java.class.path");
|
||||
private static String osName = System.getProperty("os.name");
|
||||
private static int timeStarted = 0;
|
||||
private static Runtime runtime;
|
||||
private static ConfigurationManager config;
|
||||
@ -81,14 +87,20 @@ public final class Emulator {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) {
|
||||
AnsiConsole.systemInstall();
|
||||
}
|
||||
Locale.setDefault(new Locale("en"));
|
||||
|
||||
setBuild();
|
||||
Emulator.stopped = false;
|
||||
ConsoleCommand.load();
|
||||
Emulator.logging = new Logging();
|
||||
Emulator.getLogging().logStart("\r" + Emulator.logo +
|
||||
" Build: " + build + "\n");
|
||||
System.out.println(ANSI_PURPLE + logo );
|
||||
System.out.println(ANSI_WHITE + "This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral.");
|
||||
System.out.println(ANSI_BLUE + "[VERSION] " + ANSI_WHITE + version);
|
||||
System.out.println(ANSI_RED + "[BUILD] " + ANSI_WHITE + build + "\n");
|
||||
System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Remember to sign up your hotel to join our toplist beta at https://bit.ly/2NN0rxq" );
|
||||
System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Join our discord at https://discord.gg/syuqgN" + "\n");
|
||||
random = new Random();
|
||||
long startTime = System.nanoTime();
|
||||
|
||||
@ -119,7 +131,6 @@ public final class Emulator {
|
||||
Emulator.getLogging().logStart("Memory: " + (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024) + "/" + (runtime.freeMemory()) / (1024 * 1024) + "MB");
|
||||
|
||||
Emulator.debugging = Emulator.getConfig().getBoolean("debug.mode");
|
||||
|
||||
if (debugging) {
|
||||
Emulator.getLogging().logDebugLine("Debugging Enabled!");
|
||||
}
|
||||
@ -134,10 +145,6 @@ public final class Emulator {
|
||||
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: ");
|
||||
Emulator.getLogging().logStart("https://discord.gg/syuqgN");
|
||||
Emulator.getLogging().logStart("Please report bugs on our git at Krews.org.");
|
||||
System.out.println("Waiting for commands: ");
|
||||
}, 1500);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||
@ -189,11 +196,11 @@ public final class Emulator {
|
||||
}
|
||||
|
||||
private static void dispose() {
|
||||
|
||||
Emulator.getThreading().setCanAdd(false);
|
||||
Emulator.isShuttingDown = true;
|
||||
Emulator.isReady = false;
|
||||
Emulator.getLogging().logShutdownLine("Stopping Arcturus Emulator " + version + "...");
|
||||
|
||||
try {
|
||||
if (Emulator.getPluginManager() != null)
|
||||
Emulator.getPluginManager().fireEvent(new EmulatorStartShutdownEvent());
|
||||
@ -245,7 +252,6 @@ public final class Emulator {
|
||||
Emulator.gameServer.stop();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
Emulator.getLogging().logShutdownLine("Stopped Arcturus Emulator " + version + "...");
|
||||
|
||||
if (Emulator.database != null) {
|
||||
@ -253,8 +259,12 @@ public final class Emulator {
|
||||
}
|
||||
Emulator.stopped = true;
|
||||
|
||||
if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) {
|
||||
AnsiConsole.systemUninstall();
|
||||
}
|
||||
try {
|
||||
if (Emulator.threading != null)
|
||||
|
||||
Emulator.threading.shutDown();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class Logging {
|
||||
if (Emulator.getConfig().getBoolean("logging.debug")) {
|
||||
this.write(debugFileWriter, line.toString());
|
||||
}
|
||||
System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_GREEN + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString());
|
||||
System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_RED + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString());
|
||||
}
|
||||
|
||||
public void logUserLine(Object line) {
|
||||
|
@ -15,6 +15,7 @@ import com.eu.habbo.habbohotel.guilds.GuildManager;
|
||||
import com.eu.habbo.habbohotel.hotelview.HotelViewManager;
|
||||
import com.eu.habbo.habbohotel.items.ItemManager;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolManager;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
|
||||
import com.eu.habbo.habbohotel.modtool.WordFilter;
|
||||
import com.eu.habbo.habbohotel.navigation.NavigatorManager;
|
||||
import com.eu.habbo.habbohotel.permissions.PermissionsManager;
|
||||
@ -39,6 +40,7 @@ public class GameEnvironment {
|
||||
private PermissionsManager permissionsManager;
|
||||
private BotManager botManager;
|
||||
private ModToolManager modToolManager;
|
||||
private ModToolSanctions modToolSanctions;
|
||||
private PetManager petManager;
|
||||
private AchievementManager achievementManager;
|
||||
private GuideManager guideManager;
|
||||
@ -62,6 +64,7 @@ public class GameEnvironment {
|
||||
this.navigatorManager = new NavigatorManager();
|
||||
this.commandHandler = new CommandHandler();
|
||||
this.modToolManager = new ModToolManager();
|
||||
this.modToolSanctions = new ModToolSanctions();
|
||||
this.achievementManager = new AchievementManager();
|
||||
this.achievementManager.reload();
|
||||
this.guideManager = new GuideManager();
|
||||
@ -145,6 +148,10 @@ public class GameEnvironment {
|
||||
return this.modToolManager;
|
||||
}
|
||||
|
||||
public ModToolSanctions getModToolSanctions() {
|
||||
return this.modToolSanctions;
|
||||
}
|
||||
|
||||
public PetManager getPetManager() {
|
||||
return this.petManager;
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ import java.util.Arrays;
|
||||
|
||||
public class Bot implements Runnable {
|
||||
public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}";
|
||||
public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";");
|
||||
|
||||
private final ArrayList<String> chatLines;
|
||||
private transient int id;
|
||||
private String name;
|
||||
@ -240,6 +242,8 @@ public class Bot implements Runnable {
|
||||
if (this.roomUnit != null) {
|
||||
room.giveEffect(this.roomUnit, this.effect, -1);
|
||||
}
|
||||
|
||||
this.talk(PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)]);
|
||||
}
|
||||
|
||||
public void onPickUp(Habbo habbo, Room room) {
|
||||
|
@ -113,15 +113,19 @@ public class BotManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!room.hasHabbosAt(location.x, location.y) && !location.isWalkable() && location.state != RoomTileState.SIT)
|
||||
if (room.hasHabbosAt(location.x, location.y) || (!location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY))
|
||||
return;
|
||||
|
||||
RoomUnit roomUnit = new RoomUnit();
|
||||
roomUnit.setRotation(RoomUserRotation.SOUTH);
|
||||
roomUnit.setLocation(location);
|
||||
HabboItem topItem = room.getTopItemAt(location.x, location.y);
|
||||
roomUnit.setZ(roomUnit.getCurrentLocation().getStackHeight());
|
||||
roomUnit.setPreviousLocationZ(roomUnit.getCurrentLocation().getStackHeight());
|
||||
|
||||
double topItemHeight = 0;
|
||||
if (topItem != null) topItemHeight = Item.getCurrentHeight(topItem);
|
||||
roomUnit.setPreviousLocationZ(roomUnit.getCurrentLocation().getStackHeight() - topItemHeight);
|
||||
|
||||
|
||||
roomUnit.setPathFinderRoom(room);
|
||||
roomUnit.setRoomUnitType(RoomUnitType.BOT);
|
||||
roomUnit.setCanWalk(room.isAllowBotsWalk());
|
||||
@ -136,7 +140,6 @@ public class BotManager {
|
||||
bot.onPlace(habbo, room);
|
||||
|
||||
if (topItem != null) {
|
||||
roomUnit.setZ(topItem.getBaseItem().allowSit() ? topItem.getZ() : topItem.getZ() + Item.getCurrentHeight(topItem));
|
||||
try {
|
||||
topItem.onWalkOn(bot.getRoomUnit(), room, null);
|
||||
} catch (Exception e) {
|
||||
|
@ -40,6 +40,7 @@ import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -729,6 +730,8 @@ public class CatalogManager {
|
||||
if (pageClazz != null) {
|
||||
try {
|
||||
catalogPage = pageClazz.getConstructor(ResultSet.class).newInstance(page);
|
||||
} catch (InvocationTargetException e) {
|
||||
Emulator.getLogging().logErrorLine(e.getCause());
|
||||
} catch (Exception e) {
|
||||
Emulator.getLogging().logErrorLine(e);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public class MarketPlace {
|
||||
|
||||
|
||||
public static void serializeItemInfo(int itemId, ServerMessage message) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(timestamp))")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(marketplace_items.price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(marketplace_items.timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND marketplace_items.state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(marketplace_items.timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(marketplace_items.timestamp))")) {
|
||||
statement.setInt(1, itemId);
|
||||
|
||||
message.appendInt(avarageLastXDays(itemId, 7));
|
||||
|
@ -245,6 +245,7 @@ public class CommandHandler {
|
||||
addCommand(new ShoutCommand());
|
||||
addCommand(new ShutdownCommand());
|
||||
addCommand(new SitCommand());
|
||||
addCommand(new StandCommand());
|
||||
addCommand(new SitDownCommand());
|
||||
addCommand(new StaffAlertCommand());
|
||||
addCommand(new StaffOnlineCommand());
|
||||
|
@ -12,7 +12,7 @@ public class CommandsCommand extends Command {
|
||||
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||
StringBuilder message = new StringBuilder("Your Commands");
|
||||
StringBuilder message = new StringBuilder(Emulator.getTexts().getValue("commands.generic.cmd_commands.text"));
|
||||
List<Command> commands = Emulator.getGameEnvironment().getCommandHandler().getCommandsForRank(gameClient.getHabbo().getHabboInfo().getRank().getId());
|
||||
message.append("(").append(commands.size()).append("):\r\n");
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class MuteCommand extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
habbo.mute(duration);
|
||||
habbo.mute(duration, false);
|
||||
|
||||
if (habbo.getHabboInfo().getCurrentRoom() != null) {
|
||||
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.MUTED).compose()); //: RoomUserIgnoredComposer.UNIGNORED
|
||||
|
@ -9,7 +9,7 @@ import java.util.Collections;
|
||||
|
||||
public class PluginsCommand extends Command {
|
||||
public PluginsCommand() {
|
||||
super("cmd_plugins", Emulator.getTexts().getValue("commands.keys.cmd_plugins").split(";"));
|
||||
super(null, Emulator.getTexts().getValue("commands.keys.cmd_plugins").split(";"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.eu.habbo.habbohotel.commands;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
|
||||
public class StandCommand extends Command {
|
||||
public StandCommand() {
|
||||
super(null, Emulator.getTexts().getValue("commands.keys.cmd_stand").split(";"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||
if (gameClient.getHabbo().getHabboInfo().getRiding() == null)
|
||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeStand(gameClient.getHabbo());
|
||||
return true;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import com.eu.habbo.core.Logging;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.PacketManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -17,12 +18,12 @@ import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class GameClient {
|
||||
|
||||
public final ConcurrentHashMap<Integer, Integer> incomingPacketCounter = new ConcurrentHashMap<>(25);
|
||||
private final Channel channel;
|
||||
public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp();
|
||||
private Habbo habbo;
|
||||
private String machineId = "";
|
||||
public final ConcurrentHashMap<Class<? extends MessageHandler>, Long> messageTimestamps = new ConcurrentHashMap<>();
|
||||
|
||||
public GameClient(Channel channel) {
|
||||
this.channel = channel;
|
||||
|
@ -12,6 +12,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.outgoing.guides.GuideSessionPartnerIsPlayingComposer;
|
||||
import com.eu.habbo.plugin.Event;
|
||||
import com.eu.habbo.plugin.events.games.GameHabboJoinEvent;
|
||||
import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent;
|
||||
@ -68,7 +69,7 @@ public abstract class Game implements Runnable {
|
||||
habbo.getHabboInfo().setCurrentGame(this.getClass());
|
||||
habbo.getHabboInfo().setGamePlayer(player);
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new GuideSessionPartnerIsPlayingComposer(true));
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -90,33 +91,19 @@ public abstract class Game implements Runnable {
|
||||
|
||||
GameTeam team = this.getTeamForHabbo(habbo);
|
||||
if (team != null && team.isMember(habbo)) {
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
team.removeMember(habbo.getHabboInfo().getGamePlayer());
|
||||
habbo.getHabboInfo().getGamePlayer().reset();
|
||||
}
|
||||
|
||||
habbo.getHabboInfo().setCurrentGame(null);
|
||||
habbo.getHabboInfo().setGamePlayer(null);
|
||||
|
||||
habbo.getClient().sendResponse(new GuideSessionPartnerIsPlayingComposer(false));
|
||||
if (this.countsAchievements && this.endTime > this.startTime) {
|
||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GamePlayed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
boolean deleteGame = true;
|
||||
for (GameTeam team : this.teams.values())
|
||||
{
|
||||
if (team.getMembers().size() > 0 )
|
||||
{
|
||||
deleteGame = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (deleteGame)
|
||||
{
|
||||
this.room.deleteGame(this);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -131,8 +118,7 @@ public abstract class Game implements Runnable {
|
||||
}
|
||||
|
||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
|
||||
item.setExtradata("0");
|
||||
this.room.updateItem(item);
|
||||
((WiredBlob) item).onGameStart(this.room);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,6 +176,10 @@ public abstract class Game implements Runnable {
|
||||
((InteractionWiredHighscore) item).reloadData();
|
||||
this.room.updateItem(item);
|
||||
}
|
||||
|
||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
|
||||
((WiredBlob) item).onGameEnd(this.room);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void run();
|
||||
|
@ -29,6 +29,9 @@ public class GamePlayer {
|
||||
public synchronized void addScore(int amount) {
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) {
|
||||
this.score += amount;
|
||||
|
||||
if (this.score < 0) this.score = 0;
|
||||
|
||||
WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class GameTeam {
|
||||
for (GamePlayer player : this.members) {
|
||||
if (player == null || player.getHabbo() == null) continue;
|
||||
|
||||
player.getHabbo().getHabboInfo().getGamePlayer().reset();
|
||||
if (player.getHabbo().getHabboInfo().getGamePlayer() != null) player.getHabbo().getHabboInfo().getGamePlayer().reset();
|
||||
player.getHabbo().getHabboInfo().setCurrentGame(null);
|
||||
player.getHabbo().getHabboInfo().setGamePlayer(null);
|
||||
}
|
||||
|
@ -157,11 +157,14 @@ public class BattleBanzaiGame extends Game {
|
||||
public void onEnd() {
|
||||
GameTeam winningTeam = null;
|
||||
|
||||
boolean singleTeamGame = this.teams.values().stream().filter(t -> t.getMembers().size() > 0).count() == 1;
|
||||
|
||||
for (GameTeam team : this.teams.values()) {
|
||||
if (!singleTeamGame) {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,12 +174,14 @@ public class BattleBanzaiGame extends Game {
|
||||
}
|
||||
|
||||
if (winningTeam != null) {
|
||||
if (!singleTeamGame) {
|
||||
for (GamePlayer player : winningTeam.getMembers()) {
|
||||
if (player.getScore() > 0) {
|
||||
this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose());
|
||||
AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
|
||||
item.setExtradata((6 + winningTeam.teamColor.type) + "");
|
||||
|
@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.guilds;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.guilds.forums.ForumView;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionGuildFurni;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
@ -14,10 +15,8 @@ import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GuildManager {
|
||||
|
||||
@ -25,12 +24,16 @@ public class GuildManager {
|
||||
|
||||
private final TIntObjectMap<Guild> guilds;
|
||||
|
||||
private final THashSet<ForumView> views = new THashSet<>();
|
||||
|
||||
public GuildManager() {
|
||||
long millis = System.currentTimeMillis();
|
||||
this.guildParts = new THashMap<GuildPartType, THashMap<Integer, GuildPart>>();
|
||||
this.guilds = TCollections.synchronizedMap(new TIntObjectHashMap<Guild>());
|
||||
|
||||
this.loadGuildParts();
|
||||
this.loadGuildViews();
|
||||
|
||||
Emulator.getLogging().logStart("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
||||
}
|
||||
|
||||
@ -53,6 +56,19 @@ public class GuildManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadGuildViews() {
|
||||
this.views.clear();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet set = statement.executeQuery("SELECT * FROM guild_forum_views")) {
|
||||
while (set.next()) {
|
||||
this.views.add(new ForumView(set));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Guild createGuild(Habbo habbo, int roomId, String roomName, String name, String description, String badge, int colorOne, int colorTwo) {
|
||||
Guild guild = new Guild(habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), roomId, roomName, name, description, colorOne, colorTwo, badge);
|
||||
@ -203,7 +219,7 @@ public class GuildManager {
|
||||
}
|
||||
|
||||
if (userId == 0 && !error) {
|
||||
if (guild.getState() == GuildState.LOCKED) {
|
||||
if (guild.getState() == GuildState.EXCLUSIVE) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(id) as total FROM guilds_members WHERE guild_id = ? AND level_id = 3")) {
|
||||
statement.setInt(1, guild.getId());
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
@ -236,7 +252,7 @@ public class GuildManager {
|
||||
statement.setInt(1, guild.getId());
|
||||
statement.setInt(2, client.getHabbo().getHabboInfo().getId());
|
||||
statement.setInt(3, Emulator.getIntUnixTimestamp());
|
||||
statement.setInt(4, guild.getState() == GuildState.LOCKED ? GuildRank.REQUESTED.type : GuildRank.MEMBER.type);
|
||||
statement.setInt(4, guild.getState() == GuildState.EXCLUSIVE ? GuildRank.REQUESTED.type : GuildRank.MEMBER.type);
|
||||
statement.execute();
|
||||
}
|
||||
}
|
||||
@ -251,7 +267,7 @@ public class GuildManager {
|
||||
}
|
||||
|
||||
if (userId == 0 && !error) {
|
||||
if (guild.getState() == GuildState.LOCKED)
|
||||
if (guild.getState() == GuildState.EXCLUSIVE)
|
||||
guild.increaseRequestCount();
|
||||
else {
|
||||
guild.increaseMemberCount();
|
||||
@ -594,4 +610,38 @@ public class GuildManager {
|
||||
}
|
||||
Emulator.getLogging().logShutdownLine("Guild Manager -> Disposed!");
|
||||
}
|
||||
|
||||
public boolean hasViewedForum(int userId, int guildId) {
|
||||
return this.views.stream()
|
||||
.anyMatch(v -> v.getUserId() == userId && v.getGuildId() == guildId && v.getTimestamp() > (Emulator.getIntUnixTimestamp() - 7 * 24 * 60 * 60));
|
||||
}
|
||||
|
||||
public void addView(int userId, int guildId) {
|
||||
ForumView view = new ForumView(userId, guildId, Emulator.getIntUnixTimestamp());
|
||||
|
||||
this.views.add(view);
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `guild_forum_views`(`user_id`, `guild_id`, `timestamp`) VALUES (?, ?, ?)")) {
|
||||
statement.setInt(1, view.getUserId());
|
||||
statement.setInt(2, view.getGuildId());
|
||||
statement.setInt(3, view.getTimestamp());
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Guild> getMostViewed() {
|
||||
return this.views.stream()
|
||||
.filter(v -> v.getTimestamp() > (Emulator.getIntUnixTimestamp() - 7 * 24 * 60 * 60))
|
||||
.collect(Collectors.groupingBy(ForumView::getGuildId))
|
||||
.entrySet()
|
||||
.stream()
|
||||
.sorted(Comparator.comparingInt((Map.Entry<Integer, List<ForumView>> a) -> a.getValue().size()))
|
||||
.map(k -> this.getGuild(k.getKey()))
|
||||
.filter(g -> g != null && g.canReadForum() == SettingsState.EVERYONE)
|
||||
.limit(100)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
@ -62,4 +62,12 @@ public class GuildMember implements Comparable {
|
||||
public int compareTo(Object o) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public GuildMembershipStatus getMembershipStatus() {
|
||||
if (this.rank == GuildRank.DELETED) return GuildMembershipStatus.NOT_MEMBER;
|
||||
if (this.rank == GuildRank.OWNER || this.rank == GuildRank.ADMIN || this.rank == GuildRank.MEMBER) return GuildMembershipStatus.MEMBER;
|
||||
if (this.rank == GuildRank.REQUESTED) return GuildMembershipStatus.PENDING;
|
||||
|
||||
return GuildMembershipStatus.NOT_MEMBER;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.eu.habbo.habbohotel.guilds;
|
||||
|
||||
public enum GuildMembershipStatus {
|
||||
NOT_MEMBER(0),
|
||||
MEMBER(1),
|
||||
PENDING(2);
|
||||
|
||||
private int status;
|
||||
|
||||
GuildMembershipStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.eu.habbo.habbohotel.guilds;
|
||||
|
||||
public enum GuildRank {
|
||||
ADMIN(0),
|
||||
MOD(1),
|
||||
OWNER(0),
|
||||
ADMIN(1),
|
||||
MEMBER(2),
|
||||
REQUESTED(3),
|
||||
DELETED(4);
|
||||
|
@ -2,8 +2,10 @@ package com.eu.habbo.habbohotel.guilds;
|
||||
|
||||
public enum GuildState {
|
||||
OPEN(0),
|
||||
LOCKED(1),
|
||||
CLOSED(2);
|
||||
EXCLUSIVE(1),
|
||||
CLOSED(2),
|
||||
LARGE(3),
|
||||
LARGE_CLOSED(4);
|
||||
|
||||
public final int state;
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class ForumThreadComment implements Runnable, ISerialize {
|
||||
if (!this.needsUpdate)
|
||||
return;
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments` SET `state` = ?, `admin_id` = ? WHERE `id` = ?;")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments SET `state` = ?, `admin_id` = ? WHERE `id` = ?")) {
|
||||
statement.setInt(1, this.state.getStateId());
|
||||
statement.setInt(2, this.adminId);
|
||||
statement.setInt(3, this.commentId);
|
||||
|
@ -0,0 +1,34 @@
|
||||
package com.eu.habbo.habbohotel.guilds.forums;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class ForumView {
|
||||
private final int userId;
|
||||
private final int guildId;
|
||||
private final int timestamp;
|
||||
|
||||
public ForumView(int userId, int guildId, int timestamp) {
|
||||
this.userId = userId;
|
||||
this.guildId = guildId;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public ForumView(ResultSet set) throws SQLException {
|
||||
this.userId = set.getInt("user_id");
|
||||
this.guildId = set.getInt("guild_id");
|
||||
this.timestamp = set.getInt("timestamp");
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public int getGuildId() {
|
||||
return guildId;
|
||||
}
|
||||
|
||||
public int getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun.Interaction
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagField;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagPole;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.rollerskate.InteractionRollerskateField;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemHead;
|
||||
import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemLegs;
|
||||
import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemPlanet;
|
||||
@ -177,6 +178,8 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class));
|
||||
this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class));
|
||||
this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class));
|
||||
this.interactionsList.add(new ItemInteraction("random_state", InteractionRandomState.class));
|
||||
this.interactionsList.add(new ItemInteraction("vendingmachine_no_sides", InteractionNoSidesVendingMachine.class));
|
||||
|
||||
this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class));
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.eu.habbo.habbohotel.items;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RandomStateParams {
|
||||
private int states = -1;
|
||||
private int delay = -1;
|
||||
|
||||
public RandomStateParams(String customparams) throws Exception {
|
||||
Arrays.stream(customparams.split(",")).forEach(pair -> {
|
||||
String[] keyValue = pair.split("=");
|
||||
|
||||
if (keyValue.length != 2) return;
|
||||
|
||||
switch (keyValue[0]) {
|
||||
case "states":
|
||||
this.states = Integer.parseInt(keyValue[1]);
|
||||
break;
|
||||
case "delay":
|
||||
this.delay = Integer.parseInt(keyValue[1]);
|
||||
break;
|
||||
default:
|
||||
Emulator.getLogging().logDebugLine("RandomStateParams: unknown key: " + keyValue[0]);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
if (this.states < 0) throw new Exception("RandomStateParams: states not defined");
|
||||
if (this.delay < 0) throw new Exception("RandomStateParams: states not defined");
|
||||
}
|
||||
|
||||
public int getStates() {
|
||||
return states;
|
||||
}
|
||||
|
||||
public int getDelay() {
|
||||
return delay;
|
||||
}
|
||||
}
|
@ -77,6 +77,7 @@ public class YoutubeManager {
|
||||
|
||||
long millis = System.currentTimeMillis();
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10);
|
||||
|
||||
Emulator.getLogging().logStart("YouTube Manager -> Loading...");
|
||||
@ -113,6 +114,7 @@ public class YoutubeManager {
|
||||
}
|
||||
|
||||
Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
||||
});
|
||||
}
|
||||
|
||||
public YoutubePlaylist getPlaylistDataById(String playlistId) {
|
||||
|
@ -3,20 +3,21 @@ package com.eu.habbo.habbohotel.items.interactions;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitVendingMachineAction;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||
import com.eu.habbo.util.pathfinding.Rotation;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InteractionEffectVendingMachine extends InteractionDefault {
|
||||
public class InteractionEffectVendingMachine extends InteractionVendingMachine {
|
||||
public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
this.setExtradata("0");
|
||||
@ -28,46 +29,7 @@ public class InteractionEffectVendingMachine extends InteractionDefault {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (client != null) {
|
||||
RoomTile tile = getSquareInFront(room.getLayout(), this);
|
||||
|
||||
if (tile != null) {
|
||||
if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
||||
if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) {
|
||||
room.updateHabbo(client.getHabbo());
|
||||
if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) {
|
||||
client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]);
|
||||
client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||
room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
||||
public void giveVendingMachineItem(Habbo habbo, Room room) {
|
||||
room.giveEffect(habbo.getRoomUnit(), this.getBaseItem().getRandomVendingItem(), 30);
|
||||
}
|
||||
this.setExtradata("1");
|
||||
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
|
||||
Emulator.getThreading().run(this, 1000);
|
||||
HabboItem instance = this;
|
||||
Emulator.getThreading().run(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
room.giveEffect(client.getHabbo().getRoomUnit(), instance.getBaseItem().getRandomVendingItem(), 30);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (!tile.isWalkable()) {
|
||||
for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
|
||||
if (t != null && t.isWalkable()) {
|
||||
tile = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
client.getHabbo().getRoomUnit().setGoalLocation(tile);
|
||||
Emulator.getThreading().run(new RoomUnitVendingMachineAction(client.getHabbo(), this, room), client.getHabbo().getRoomUnit().getPath().size() + 2 * 510);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -38,8 +38,6 @@ public class InteractionGate extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
boolean isWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
|
||||
if (client != null && !room.hasRights(client.getHabbo()) && !isWired)
|
||||
return;
|
||||
@ -54,6 +52,8 @@ public class InteractionGate extends HabboItem {
|
||||
room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
|
||||
this.needsUpdate(true);
|
||||
room.updateItemState(this);
|
||||
|
||||
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
||||
}
|
||||
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitType;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
@ -13,9 +11,14 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.apache.commons.math3.util.Pair;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class InteractionMultiHeight extends HabboItem {
|
||||
public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
@ -55,6 +58,11 @@ public class InteractionMultiHeight extends HabboItem {
|
||||
|
||||
if (objects.length > 0) {
|
||||
if (objects[0] instanceof Integer && room != null) {
|
||||
HabboItem topItem = room.getTopItemAt(this.getX(), this.getY());
|
||||
if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top
|
||||
return;
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
|
||||
if (this.getExtradata().length() == 0)
|
||||
@ -69,26 +77,27 @@ public class InteractionMultiHeight extends HabboItem {
|
||||
}
|
||||
|
||||
if (this.isWalkable()) {
|
||||
THashSet<Habbo> habbos = room.getHabbosOnItem(this);
|
||||
THashSet<RoomUnit> updatedUnits = new THashSet<>();
|
||||
for (Habbo habbo : habbos) {
|
||||
if (habbo.getRoomUnit() == null)
|
||||
continue;
|
||||
List<RoomUnit> unitsOnItem = new ArrayList<>();
|
||||
unitsOnItem.addAll(room.getHabbosOnItem(this).stream().map(Habbo::getRoomUnit).filter(Objects::nonNull).collect(Collectors.toList()));
|
||||
unitsOnItem.addAll(room.getBotsOnItem(this).stream().map(Bot::getRoomUnit).filter(Objects::nonNull).collect(Collectors.toList()));
|
||||
|
||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
|
||||
THashSet<RoomUnit> updatedUnits = new THashSet<>();
|
||||
for (RoomUnit unit : unitsOnItem) {
|
||||
if (unit.hasStatus(RoomUnitStatus.MOVE))
|
||||
continue;
|
||||
|
||||
if (this.getBaseItem().getMultiHeights().length >= 0) {
|
||||
if (this.getBaseItem().allowSit()) {
|
||||
habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + "");
|
||||
unit.setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + "");
|
||||
} else {
|
||||
habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||
habbo.getRoomUnit().setPreviousLocationZ(habbo.getRoomUnit().getZ());
|
||||
unit.setZ(unit.getCurrentLocation().getStackHeight());
|
||||
unit.setPreviousLocationZ(unit.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
updatedUnits.add(habbo.getRoomUnit());
|
||||
updatedUnits.add(unit);
|
||||
}
|
||||
|
||||
room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose());
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import java.sql.SQLException;
|
||||
|
||||
public class InteractionMusicDisc extends HabboItem {
|
||||
private int songId;
|
||||
private boolean inQueue;
|
||||
|
||||
public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@ -74,21 +73,13 @@ public class InteractionMusicDisc extends HabboItem {
|
||||
public void onPlace(Room room) {
|
||||
super.onPlace(room);
|
||||
|
||||
room.sendComposer(new JukeBoxMySongsComposer(room.getTraxManager().myList()).compose());
|
||||
room.getTraxManager().sendUpdatedSongList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
super.onPickUp(room);
|
||||
|
||||
room.getTraxManager().removeSong(this.getId());
|
||||
}
|
||||
|
||||
public boolean inQueue() {
|
||||
return this.inQueue;
|
||||
}
|
||||
|
||||
public void inQueue(boolean inQueue) {
|
||||
this.inQueue = inQueue;
|
||||
room.getTraxManager().sendUpdatedSongList();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionNoSidesVendingMachine extends InteractionVendingMachine {
|
||||
public InteractionNoSidesVendingMachine(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
|
||||
public InteractionNoSidesVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoomTile getRequiredTile(Habbo habbo, Room room) {
|
||||
return habbo.getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), true);
|
||||
}
|
||||
}
|
@ -6,10 +6,12 @@ import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Optional;
|
||||
|
||||
public class InteractionPuzzleBox extends HabboItem {
|
||||
public InteractionPuzzleBox(ResultSet set, Item baseItem) throws SQLException {
|
||||
@ -22,43 +24,56 @@ public class InteractionPuzzleBox extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if (client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
|
||||
return;
|
||||
|
||||
if (!RoomLayout.tilesAdjecent(room.getLayout().getTile(super.getX(), super.getY()), client.getHabbo().getRoomUnit().getCurrentLocation()))
|
||||
return;
|
||||
|
||||
|
||||
RoomTile boxLocation = room.getLayout().getTile(this.getX(), this.getY());
|
||||
client.getHabbo().getRoomUnit().lookAtPoint(boxLocation);
|
||||
room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
||||
RoomUserRotation rotation = null;
|
||||
|
||||
switch (client.getHabbo().getRoomUnit().getBodyRotation()) {
|
||||
case NORTH_EAST:
|
||||
case NORTH_WEST:
|
||||
case SOUTH_EAST:
|
||||
case SOUTH_WEST:
|
||||
if (this.getX() == client.getHabbo().getRoomUnit().getX()) {
|
||||
if (this.getY() == client.getHabbo().getRoomUnit().getY() + 1) {
|
||||
rotation = RoomUserRotation.SOUTH;
|
||||
} else if (this.getY() == client.getHabbo().getRoomUnit().getY() - 1) {
|
||||
rotation = RoomUserRotation.NORTH;
|
||||
}
|
||||
} else if (this.getY() == client.getHabbo().getRoomUnit().getY()) {
|
||||
if (this.getX() == client.getHabbo().getRoomUnit().getX() + 1) {
|
||||
rotation = RoomUserRotation.EAST;
|
||||
} else if (this.getX() == client.getHabbo().getRoomUnit().getX() - 1) {
|
||||
rotation = RoomUserRotation.WEST;
|
||||
}
|
||||
}
|
||||
|
||||
if (rotation == null) {
|
||||
RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), false);
|
||||
|
||||
if (nearestTile != null) client.getHabbo().getRoomUnit().setGoalLocation(nearestTile);
|
||||
return;
|
||||
}
|
||||
|
||||
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getBodyRotation().getValue());
|
||||
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
||||
|
||||
if (tile == null || !room.tileWalkable(tile) || room.hasHabbosAt(tile.x, tile.y)) {
|
||||
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), rotation.getValue());
|
||||
|
||||
if (tile == null || tile.getState() == RoomTileState.INVALID || room.hasHabbosAt(tile.x, tile.y)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double offset = room.getStackHeight(tile.x, tile.y, false) - this.getZ();
|
||||
|
||||
if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), client.getHabbo().getRoomUnit().getBodyRotation().getValue())))
|
||||
if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), rotation.getValue())))
|
||||
return;
|
||||
|
||||
HabboItem item = room.getTopItemAt(tile.x, tile.y);
|
||||
|
||||
if (item == null || (item.getZ() <= this.getZ() && item.getBaseItem().allowWalk())) {
|
||||
room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, offset, room).compose());
|
||||
client.getHabbo().getRoomUnit().setGoalLocation(boxLocation);
|
||||
if (item != null && !room.getTopItemAt(tile.x, tile.y).getBaseItem().allowStack()) return;
|
||||
|
||||
this.setZ(room.getStackHeight(tile.x, tile.y, false));
|
||||
this.needsUpdate(true);
|
||||
room.updateItem(this);
|
||||
|
||||
room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose());
|
||||
room.scheduledTasks.add(() -> {
|
||||
client.getHabbo().getRoomUnit().setGoalLocation(boxLocation);
|
||||
|
||||
room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation));
|
||||
});
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.RandomStateParams;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionRandomState extends InteractionDefault {
|
||||
public InteractionRandomState(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
|
||||
public InteractionRandomState(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(Room room) {
|
||||
super.onPlace(room);
|
||||
|
||||
this.setExtradata("");
|
||||
room.updateItemState(this);
|
||||
}
|
||||
|
||||
public void onRandomStateClick(GameClient client, Room room) throws Exception {
|
||||
RandomStateParams params = new RandomStateParams(this.getBaseItem().getCustomParams());
|
||||
|
||||
this.setExtradata("");
|
||||
room.updateItemState(this);
|
||||
|
||||
int randomState = Emulator.getRandom().nextInt(params.getStates()) + 1;
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
this.setExtradata(randomState + "");
|
||||
room.updateItemState(this);
|
||||
}, params.getDelay());
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ import java.util.List;
|
||||
|
||||
public class InteractionRoller extends HabboItem {
|
||||
public static boolean NO_RULES = false;
|
||||
public static int DELAY = 400;
|
||||
|
||||
public InteractionRoller(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
|
@ -1,14 +1,18 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InteractionSwitch extends InteractionDefault {
|
||||
public InteractionSwitch(ResultSet set, Item baseItem) throws SQLException {
|
||||
@ -43,12 +47,22 @@ public class InteractionSwitch extends InteractionDefault {
|
||||
RoomTile closestTile = null;
|
||||
for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
|
||||
if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) {
|
||||
closestTile = client.getHabbo().getRoomUnit().getCurrentLocation();
|
||||
closestTile = tile;
|
||||
}
|
||||
}
|
||||
|
||||
if (closestTile != null) {
|
||||
if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
||||
List<Runnable> onSuccess = new ArrayList<>();
|
||||
onSuccess.add(() -> {
|
||||
try {
|
||||
this.onClick(client, room, objects);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
|
||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,12 @@ public class InteractionTeleport extends HabboItem {
|
||||
if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) {
|
||||
startTeleport(room, habbo);
|
||||
walkable = true;
|
||||
|
||||
try {
|
||||
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) {
|
||||
// set state 1 and walk on item
|
||||
this.roomUnitID = unit.getId();
|
||||
@ -133,9 +139,7 @@ public class InteractionTeleport extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (room != null && client != null && objects.length <= 1) {
|
||||
if (room != null && client != null && objects != null && objects.length <= 1) {
|
||||
tryTeleport(client, room);
|
||||
}
|
||||
}
|
||||
@ -201,7 +205,7 @@ public class InteractionTeleport extends HabboItem {
|
||||
if (habbo.getHabboInfo().getRiding() != null)
|
||||
return false;
|
||||
|
||||
return this.roomUnitID == -1 || this.roomUnitID == unit.getId();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void startTeleport(Room room, Habbo habbo) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -13,4 +15,9 @@ public class InteractionTent extends InteractionDefault {
|
||||
public InteractionTent(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,11 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionTrophy extends HabboItem {
|
||||
public class InteractionTrophy extends InteractionDefault {
|
||||
public InteractionTrophy(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
@ -18,41 +13,4 @@ public class InteractionTrophy extends HabboItem {
|
||||
public InteractionTrophy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeExtradata(ServerMessage serverMessage) {
|
||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
||||
serverMessage.appendString(this.getExtradata());
|
||||
super.serializeExtradata(serverMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,21 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitVendingMachineAction;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||
import com.eu.habbo.util.pathfinding.Rotation;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class InteractionVendingMachine extends HabboItem {
|
||||
public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException {
|
||||
@ -42,26 +46,32 @@ public class InteractionVendingMachine extends HabboItem {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (client != null) {
|
||||
RoomTile tile = getSquareInFront(room.getLayout(), this);
|
||||
RoomTile tile = this.getRequiredTile(client.getHabbo(), room);
|
||||
|
||||
if (tile != null) {
|
||||
if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
||||
if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) {
|
||||
if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) && (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || tile.equals(client.getHabbo().getRoomUnit().getGoal()))) {
|
||||
room.updateHabbo(client.getHabbo());
|
||||
if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) {
|
||||
client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]);
|
||||
this.rotateToMachine(client.getHabbo().getRoomUnit());
|
||||
client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||
room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
||||
}
|
||||
|
||||
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
||||
|
||||
this.setExtradata("1");
|
||||
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
Emulator.getThreading().run(this, 1000);
|
||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(client.getHabbo().getRoomUnit(), room, this.getBaseItem().getRandomVendingItem()));
|
||||
this.giveVendingMachineItem(client.getHabbo(), room);
|
||||
|
||||
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
|
||||
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
|
||||
}, 500);
|
||||
}
|
||||
} else {
|
||||
if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) {
|
||||
@ -72,8 +82,43 @@ public class InteractionVendingMachine extends HabboItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RoomTile finalTile = tile;
|
||||
client.getHabbo().getRoomUnit().setGoalLocation(tile);
|
||||
Emulator.getThreading().run(new RoomUnitVendingMachineAction(client.getHabbo(), this, room), client.getHabbo().getRoomUnit().getPath().size() + 2 * 510);
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, () -> {
|
||||
this.setExtradata("1");
|
||||
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
|
||||
|
||||
try {
|
||||
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(() -> {
|
||||
if (client.getHabbo().getRoomUnit().getCurrentLocation().equals(finalTile)) {
|
||||
this.rotateToMachine(client.getHabbo().getRoomUnit());
|
||||
room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
|
||||
}
|
||||
|
||||
try {
|
||||
Emulator.getThreading().run(() -> {
|
||||
Emulator.getThreading().run(this, 1000);
|
||||
this.giveVendingMachineItem(client.getHabbo(), room);
|
||||
|
||||
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
|
||||
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
|
||||
}, 500).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 300));
|
||||
}, 250);
|
||||
}, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -119,4 +164,45 @@ public class InteractionVendingMachine extends HabboItem {
|
||||
public boolean isUsable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void rotateToMachine(RoomUnit unit) {
|
||||
RoomUserRotation rotation = RoomUserRotation.values()[Rotation.Calculate(unit.getX(), unit.getY(), this.getX(), this.getY())];
|
||||
boolean onlyHead = false;
|
||||
|
||||
switch (unit.getBodyRotation()) {
|
||||
case NORTH_EAST:
|
||||
if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.EAST))
|
||||
onlyHead = true;
|
||||
break;
|
||||
|
||||
case NORTH_WEST:
|
||||
if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.WEST))
|
||||
onlyHead = true;
|
||||
break;
|
||||
|
||||
case SOUTH_EAST:
|
||||
if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.EAST))
|
||||
onlyHead = true;
|
||||
break;
|
||||
|
||||
case SOUTH_WEST:
|
||||
if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.WEST))
|
||||
onlyHead = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (onlyHead) {
|
||||
unit.setHeadRotation(rotation);
|
||||
} else {
|
||||
unit.setRotation(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
public void giveVendingMachineItem(Habbo habbo, Room room) {
|
||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.getBaseItem().getRandomVendingItem()));
|
||||
}
|
||||
|
||||
public RoomTile getRequiredTile(Habbo habbo, Room room) {
|
||||
return getSquareInFront(room.getLayout(), this);
|
||||
}
|
||||
}
|
||||
|
@ -153,16 +153,20 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
this.timeNow--;
|
||||
if (this.timeNow < 0) this.timeNow = 0;
|
||||
|
||||
if (this.timeNow > 0) {
|
||||
this.threadActive = true;
|
||||
Emulator.getThreading().run(this, 1000);
|
||||
this.timeNow--;
|
||||
room.updateItem(this);
|
||||
} else {
|
||||
this.threadActive = false;
|
||||
this.timeNow = 0;
|
||||
this.endGame(room);
|
||||
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
|
||||
}
|
||||
|
||||
room.updateItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,10 +124,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
|
||||
|
||||
@Override
|
||||
public boolean validMove(Room room, RoomTile from, RoomTile to) {
|
||||
if (room == null || from == null || to == null) return false;
|
||||
|
||||
HabboItem topItem = room.getTopItemAt(to.x, to.y, this);
|
||||
return topItem != null;
|
||||
return room != null && from != null && to != null;
|
||||
//return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
|
||||
}
|
||||
|
||||
|
@ -99,4 +99,23 @@ public class InteractionBattleBanzaiTile extends HabboItem {
|
||||
|
||||
return super.canStackAt(room, itemsAtLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
super.onPickUp(room);
|
||||
|
||||
this.setExtradata("0");
|
||||
room.updateItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(Room room) {
|
||||
super.onPlace(room);
|
||||
|
||||
BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class);
|
||||
|
||||
if (game != null && game.getState() != GameState.IDLE) {
|
||||
this.setExtradata("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.games.Game;
|
||||
import com.eu.habbo.habbohotel.games.GameState;
|
||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||
@ -28,17 +29,19 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
if (room == null)
|
||||
return false;
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
|
||||
return (this.getExtradata() == null || this.getExtradata().isEmpty() || Integer.valueOf(this.getExtradata()) < 5) && ((room.getGame(BattleBanzaiGame.class))) == null || ((BattleBanzaiGame) (room.getGame(BattleBanzaiGame.class))).state.equals(GameState.IDLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
public boolean isWalkable() {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
if (room == null) return false;
|
||||
|
||||
Game game = room.getGame(BattleBanzaiGame.class);
|
||||
|
||||
return game == null || game.getState() == GameState.IDLE;
|
||||
}
|
||||
|
||||
//TODO: Move to upper class
|
||||
|
@ -76,7 +76,7 @@ public class InteractionFreezeTile extends HabboItem {
|
||||
@Override
|
||||
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<HabboItem>>> itemsAtLocation) {
|
||||
for (Pair<RoomTile, THashSet<HabboItem>> set : itemsAtLocation) {
|
||||
if (!set.getValue().isEmpty()) return false;
|
||||
if (set.getValue() != null && !set.getValue().isEmpty()) return false;
|
||||
}
|
||||
|
||||
return super.canStackAt(room, itemsAtLocation);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.games.Game;
|
||||
import com.eu.habbo.habbohotel.games.GameState;
|
||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||
@ -27,18 +29,18 @@ public class InteractionFreezeGate extends InteractionGameGate {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
if (this.getRoomId() == 0)
|
||||
return false;
|
||||
|
||||
return (this.getExtradata().isEmpty() ||
|
||||
Integer.valueOf(this.getExtradata()) < 5);
|
||||
//((Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))) == null ||
|
||||
//!((FreezeGame)(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))).isRunning;
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
public boolean isWalkable() {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
if (room == null) return false;
|
||||
|
||||
Game game = room.getGame(FreezeGame.class);
|
||||
|
||||
return game == null || game.getState() == GameState.IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
@ -33,7 +33,7 @@ public class InteractionMonsterPlantSeed extends HabboItem {
|
||||
public static int randomRarityLevel() {
|
||||
int number = Emulator.getRandom().nextInt(66);
|
||||
int count = 0;
|
||||
for (int i = 1; i <= 11; i++) {
|
||||
for (int i = 1; i < 11; i++) {
|
||||
count += 11 - i;
|
||||
if (number <= count) {
|
||||
return i;
|
@ -1,4 +1,4 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
@ -1,4 +1,4 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
@ -1,8 +1,9 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||
import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
@ -1,7 +1,8 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||
import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
@ -1,7 +1,8 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||
import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
@ -35,7 +35,12 @@ public class InteractionTotemHead extends InteractionDefault {
|
||||
}
|
||||
|
||||
public TotemColor getTotemColor() {
|
||||
int extraData = Integer.parseInt(this.getExtradata());
|
||||
int extraData;
|
||||
try {
|
||||
extraData = Integer.parseInt(this.getExtradata());
|
||||
}catch(NumberFormatException ex) {
|
||||
extraData = 0;
|
||||
}
|
||||
if(extraData < 3) {
|
||||
return TotemColor.NONE;
|
||||
}
|
||||
|
@ -31,7 +31,12 @@ public class InteractionTotemLegs extends InteractionDefault {
|
||||
}
|
||||
|
||||
public TotemColor getTotemColor() {
|
||||
int extraData = Integer.parseInt(this.getExtradata());
|
||||
int extraData;
|
||||
try {
|
||||
extraData = Integer.parseInt(this.getExtradata());
|
||||
} catch(NumberFormatException ex) {
|
||||
extraData = 0;
|
||||
}
|
||||
return TotemColor.fromInt(extraData - (4 * (getTotemType().type - 1)));
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,11 @@ public class InteractionTotemPlanet extends InteractionDefault {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if(client.getHabbo().getHabboInfo().getId() != this.getUserId()) {
|
||||
super.onClick(client, room, objects);
|
||||
return;
|
||||
}
|
||||
|
||||
InteractionTotemLegs legs = null;
|
||||
InteractionTotemHead head = null;
|
||||
|
||||
|
@ -34,6 +34,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
return !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor);
|
||||
}
|
||||
return true; // user is not part of any team
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -96,8 +96,13 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
List<Runnable> tasks = new ArrayList<>();
|
||||
tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
|
||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, null));
|
||||
|
||||
List<Runnable> failedReach = new ArrayList<>();
|
||||
failedReach.add(() -> tasks.forEach(Runnable::run));
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, failedReach));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -107,7 +107,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
int currentEffect = bot.getRoomUnit().getEffectId();
|
||||
|
||||
room.giveEffect(bot.getRoomUnit(), 4, -1);
|
||||
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, bot.getRoomUnit()), WiredHandler.TELEPORT_DELAY + 1000);
|
||||
Emulator.getThreading().run(() -> room.giveEffect(bot.getRoomUnit(), 0, -1), WiredHandler.TELEPORT_DELAY + 1000);
|
||||
Emulator.getThreading().run(new RoomUnitTeleport(bot.getRoomUnit(), room, item.getX(), item.getY(), item.getZ() + item.getBaseItem().getHeight() + (item.getBaseItem().allowSit() ? -0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY);
|
||||
break;
|
||||
} else {
|
||||
|
@ -62,7 +62,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue());
|
||||
|
||||
int count = 1;
|
||||
while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID) && count < 8) {
|
||||
while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID || targetTile.state == RoomTileState.BLOCKED) && count < 8) {
|
||||
entry.setValue(this.nextRotation(entry.getValue()));
|
||||
targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue());
|
||||
count++;
|
||||
|
@ -16,7 +16,6 @@ import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@ -45,6 +44,9 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
THashSet<RoomTile> tilesToUpdate = new THashSet<>(this.settings.size());
|
||||
//this.refresh();
|
||||
|
||||
if(this.settings.isEmpty())
|
||||
return false;
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
if (item != null) {
|
||||
@ -57,19 +59,30 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
|
||||
int oldRotation = item.getRotation();
|
||||
boolean slideAnimation = true;
|
||||
if (this.direction) {
|
||||
double offsetZ = 0;
|
||||
|
||||
if (this.direction && item.getRotation() != setting.rotation) {
|
||||
item.setRotation(setting.rotation);
|
||||
slideAnimation = false;
|
||||
|
||||
room.scheduledTasks.add(() -> {
|
||||
room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation).forEach(t -> {
|
||||
room.updateBotsAt(t.x, t.y);
|
||||
room.updateHabbosAt(t.x, t.y);
|
||||
});
|
||||
room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation).forEach(t -> {
|
||||
room.updateBotsAt(t.x, t.y);
|
||||
room.updateHabbosAt(t.x, t.y);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//room.sendComposer(new ItemStateComposer(item).compose());
|
||||
room.sendComposer(new FloorItemUpdateComposer(item).compose());
|
||||
RoomTile t = null;
|
||||
|
||||
if (this.position) {
|
||||
RoomTile t = room.getLayout().getTile((short) setting.x, (short) setting.y);
|
||||
t = room.getLayout().getTile((short) setting.x, (short) setting.y);
|
||||
|
||||
if (t != null) {
|
||||
if (t.state != RoomTileState.INVALID) {
|
||||
if (t != null && t.state != RoomTileState.INVALID) {
|
||||
boolean canMove = true;
|
||||
|
||||
if (t.x == item.getX() && t.y == item.getY()) {
|
||||
@ -100,21 +113,24 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
if (highestZ != -1d) {
|
||||
tilesToUpdate.addAll(tiles);
|
||||
|
||||
double offsetZ = highestZ - item.getZ();
|
||||
offsetZ = highestZ - item.getZ();
|
||||
double totalHeight = item.getZ() + offsetZ;
|
||||
if(totalHeight > 40) break;
|
||||
if (totalHeight > 40) break;
|
||||
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation));
|
||||
|
||||
if (!slideAnimation) {
|
||||
item.setX(t.x);
|
||||
item.setY(t.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slideAnimation && t != null) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
room.updateItem(item);
|
||||
}
|
||||
|
||||
item.needsUpdate(true);
|
||||
|
@ -39,98 +39,38 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
THashSet<HabboItem> items = new THashSet<>(this.items.size());
|
||||
// remove items that are no longer in the room
|
||||
this.items.removeIf( item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
|
||||
|
||||
THashSet<RoomTile> tilesToUpdate = new THashSet<>(Math.min(this.items.size(), 10));
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
for (HabboItem item : items) {
|
||||
this.items.remove(item);
|
||||
}
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
//Handle rotation
|
||||
int rotationToAdd = 0;
|
||||
if (this.rotation > 0) {
|
||||
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
|
||||
if (this.rotation == 1) {
|
||||
rotationToAdd = 2;
|
||||
} else if (this.rotation == 2) {
|
||||
rotationToAdd = 6;
|
||||
}
|
||||
//Random rotation
|
||||
else if (this.rotation == 3) {
|
||||
if (Emulator.getRandom().nextInt(2) == 1) {
|
||||
rotationToAdd = 2;
|
||||
} else {
|
||||
rotationToAdd = 6;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int newRotation = ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8);
|
||||
int newRotation = this.getNewRotation(item);
|
||||
|
||||
//Verify if rotation result in a valid position
|
||||
if (rotationToAdd > 0 && room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation).equals(FurnitureMovementError.NONE))//room.canPlaceFurnitureAt(item, null, room.getLayout().getTile(item.getX(), item.getY()), item.getRotation() + rotationToAdd))
|
||||
FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation);
|
||||
if (item.getRotation() != newRotation && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) ||
|
||||
rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE)))
|
||||
{
|
||||
item.setRotation(newRotation);
|
||||
|
||||
if (this.direction == 0) {
|
||||
if(this.direction == 0) {
|
||||
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
|
||||
room.sendComposer(new FloorItemUpdateComposer(item).compose());
|
||||
for (RoomTile t : tilesToUpdate) {
|
||||
room.updateHabbosAt(t.x, t.y);
|
||||
room.updateBotsAt(t.x, t.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//handle movement
|
||||
if (this.direction > 0) {
|
||||
int nextDirectionOffset = 0;
|
||||
RoomUserRotation startMoveDirection = RoomUserRotation.NORTH;
|
||||
RoomUserRotation moveDirection = null;
|
||||
if (this.direction == 1) {
|
||||
startMoveDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2];
|
||||
nextDirectionOffset = 2;
|
||||
} else if (this.direction == 2) {
|
||||
if (Emulator.getRandom().nextInt(2) == 1) {
|
||||
startMoveDirection = RoomUserRotation.EAST;
|
||||
nextDirectionOffset = 4;
|
||||
} else {
|
||||
startMoveDirection = RoomUserRotation.WEST;
|
||||
nextDirectionOffset = 4;
|
||||
}
|
||||
} else if (this.direction == 3) {
|
||||
if (Emulator.getRandom().nextInt(2) == 1) {
|
||||
startMoveDirection = RoomUserRotation.NORTH;
|
||||
nextDirectionOffset = 4;
|
||||
} else {
|
||||
startMoveDirection = RoomUserRotation.SOUTH;
|
||||
nextDirectionOffset = 4;
|
||||
}
|
||||
} else if (this.direction == 4) {
|
||||
startMoveDirection = RoomUserRotation.SOUTH;
|
||||
nextDirectionOffset = 8;
|
||||
} else if (this.direction == 5) {
|
||||
startMoveDirection = RoomUserRotation.EAST;
|
||||
nextDirectionOffset = 8;
|
||||
} else if (this.direction == 6) {
|
||||
startMoveDirection = RoomUserRotation.NORTH;
|
||||
nextDirectionOffset = 8;
|
||||
} else if (this.direction == 7) {
|
||||
startMoveDirection = RoomUserRotation.WEST;
|
||||
nextDirectionOffset = 8;
|
||||
}
|
||||
|
||||
RoomUserRotation moveDirection = this.getMovementDirection();
|
||||
boolean validMove = false;
|
||||
|
||||
int count = 0;
|
||||
int maxCount = 8 / nextDirectionOffset;
|
||||
while (moveDirection != startMoveDirection && !validMove && count < maxCount) {
|
||||
count++;
|
||||
if (moveDirection == null) {
|
||||
moveDirection = startMoveDirection;
|
||||
}
|
||||
RoomLayout layout = room.getLayout();
|
||||
if (layout == null) return false;
|
||||
|
||||
@ -161,7 +101,6 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
||||
|
||||
for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) {
|
||||
RoomTile tile = layout.getTile(x, y);
|
||||
|
||||
if (tile == null || tile.state == RoomTileState.INVALID || !tile.getAllowStack()) {
|
||||
validMove = false;
|
||||
break;
|
||||
@ -173,7 +112,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
||||
break;
|
||||
}
|
||||
|
||||
java.util.List tileItems = new ArrayList<Pair<RoomTile, THashSet<HabboItem>>>(rectangle.width * rectangle.height);
|
||||
ArrayList<Pair<RoomTile, THashSet<HabboItem>>> tileItems = new ArrayList<>(rectangle.width * rectangle.height);
|
||||
tileItems.add(Pair.create(tile, itemsAtNewTile));
|
||||
if (!item.canStackAt(room, tileItems)) {
|
||||
validMove = false;
|
||||
@ -181,9 +120,13 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
HabboItem i = room.getTopItemAt(x, y, item);
|
||||
if (i == null || i == item || i.getBaseItem().allowStack()) {
|
||||
offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset);
|
||||
if (i != null && !i.getBaseItem().allowStack()) {
|
||||
validMove = false;
|
||||
break;
|
||||
}
|
||||
|
||||
offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset);
|
||||
|
||||
tilesToUpdate.add(tile);
|
||||
}
|
||||
}
|
||||
@ -192,13 +135,21 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
if (validMove) {
|
||||
if(this.rotation > 0) {
|
||||
item.setX(newTile.x);
|
||||
item.setY(newTile.y);
|
||||
item.setZ(item.getZ() + offset);
|
||||
room.sendComposer(new FloorItemUpdateComposer(item).compose());
|
||||
for (RoomTile t : tilesToUpdate) {
|
||||
room.updateHabbosAt(t.x, t.y);
|
||||
room.updateBotsAt(t.x, t.y);
|
||||
}
|
||||
}
|
||||
else {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!validMove) {
|
||||
moveDirection = RoomUserRotation.fromValue(moveDirection.getValue() + nextDirectionOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -244,14 +195,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
||||
|
||||
if (data.length == 4) {
|
||||
try {
|
||||
this.direction = Integer.valueOf(data[0]);
|
||||
this.rotation = Integer.valueOf(data[1]);
|
||||
this.setDelay(Integer.valueOf(data[2]));
|
||||
this.direction = Integer.parseInt(data[0]);
|
||||
this.rotation = Integer.parseInt(data[1]);
|
||||
this.setDelay(Integer.parseInt(data[2]));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
for (String s : data[3].split("\r")) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
@ -328,8 +279,60 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long requiredCooldown() {
|
||||
return 100;
|
||||
|
||||
/**
|
||||
* Returns a new rotation for an item based on the wired options
|
||||
* @param item
|
||||
* @return new rotation
|
||||
*/
|
||||
private int getNewRotation(HabboItem item) {
|
||||
int rotationToAdd = 0;
|
||||
if (this.rotation == 1) {
|
||||
rotationToAdd = 2;
|
||||
} else if (this.rotation == 2) {
|
||||
rotationToAdd = 6;
|
||||
}
|
||||
//Random rotation
|
||||
else if (this.rotation == 3) {
|
||||
if (Emulator.getRandom().nextInt(2) == 1) {
|
||||
rotationToAdd = 2;
|
||||
} else {
|
||||
rotationToAdd = 6;
|
||||
}
|
||||
}
|
||||
|
||||
return ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction of movement based on the wired settings
|
||||
* @return direction
|
||||
*/
|
||||
private RoomUserRotation getMovementDirection() {
|
||||
RoomUserRotation movemementDirection = RoomUserRotation.NORTH;
|
||||
if (this.direction == 1) {
|
||||
movemementDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2];
|
||||
} else if (this.direction == 2) {
|
||||
if (Emulator.getRandom().nextInt(2) == 1) {
|
||||
movemementDirection = RoomUserRotation.EAST;
|
||||
} else {
|
||||
movemementDirection = RoomUserRotation.WEST;
|
||||
}
|
||||
} else if (this.direction == 3) {
|
||||
if (Emulator.getRandom().nextInt(2) == 1) {
|
||||
movemementDirection = RoomUserRotation.NORTH;
|
||||
} else {
|
||||
movemementDirection = RoomUserRotation.SOUTH;
|
||||
}
|
||||
} else if (this.direction == 4) {
|
||||
movemementDirection = RoomUserRotation.SOUTH;
|
||||
} else if (this.direction == 5) {
|
||||
movemementDirection = RoomUserRotation.EAST;
|
||||
} else if (this.direction == 6) {
|
||||
movemementDirection = RoomUserRotation.NORTH;
|
||||
} else if (this.direction == 7) {
|
||||
movemementDirection = RoomUserRotation.WEST;
|
||||
}
|
||||
return movemementDirection;
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
|
||||
if (roomUnit == null || tile == null)
|
||||
if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting)
|
||||
return;
|
||||
|
||||
Room room = roomUnit.getRoom();
|
||||
@ -63,6 +63,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
for (RoomTile optionalTile : optionalTiles) {
|
||||
if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED) {
|
||||
alternativeTile = optionalTile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,30 +140,13 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
for (HabboItem item : items) {
|
||||
this.items.remove(item);
|
||||
}
|
||||
this.items.removeIf(item -> item == null || item.getRoomId() != this.getRoomId()
|
||||
|| Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
|
||||
|
||||
if (!this.items.isEmpty()) {
|
||||
int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
|
||||
int j = 1;
|
||||
|
||||
int tryCount = 0;
|
||||
while (tryCount < this.items.size()) {
|
||||
tryCount++;
|
||||
HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size());
|
||||
|
||||
int i = Emulator.getRandom().nextInt(this.items.size());
|
||||
HabboItem item = this.items.get(i);
|
||||
teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY()));
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -220,6 +204,6 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
protected long requiredCooldown() {
|
||||
return 0;
|
||||
return 50L;
|
||||
}
|
||||
}
|
||||
|
@ -1,66 +1,120 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.extra;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.games.Game;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.games.GamePlayer;
|
||||
import com.eu.habbo.habbohotel.games.GameTeam;
|
||||
import com.eu.habbo.habbohotel.games.GameState;
|
||||
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
|
||||
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class WiredBlob extends InteractionDefault {
|
||||
enum WiredBlobState {
|
||||
ACTIVE("0"),
|
||||
USED("1");
|
||||
|
||||
private String state;
|
||||
WiredBlobState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
private int POINTS_REWARD = 0;
|
||||
private boolean RESETS_WITH_GAME = true;
|
||||
|
||||
public WiredBlob(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
|
||||
this.parseCustomParams();
|
||||
}
|
||||
|
||||
public WiredBlob(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
|
||||
this.parseCustomParams();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(Room room) {
|
||||
super.onPlace(room);
|
||||
|
||||
this.setExtradata(WiredBlobState.USED.getState());
|
||||
room.updateItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
|
||||
if (this.getExtradata().equals("0")) {
|
||||
if (!this.getExtradata().equals(WiredBlobState.ACTIVE.getState())) return;
|
||||
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) {
|
||||
int points = Emulator.getConfig().getInt("hotel.item.wiredblob." + this.getBaseItem().getName());
|
||||
|
||||
if (points == 0) {
|
||||
Emulator.getConfig().register("hotel.item.wiredblob." + this.getBaseItem().getName(), "3000");
|
||||
points = 1;
|
||||
}
|
||||
|
||||
boolean triggered = false;
|
||||
Game game = room.getGame(habbo.getHabboInfo().getCurrentGame());
|
||||
|
||||
if (game != null) {
|
||||
GameTeam team = game.getTeamForHabbo(habbo);
|
||||
|
||||
if (team != null) {
|
||||
team.addTeamScore(points);
|
||||
triggered = true;
|
||||
} else {
|
||||
if (habbo != null) {
|
||||
GamePlayer player = habbo.getHabboInfo().getGamePlayer();
|
||||
|
||||
if (player != null) {
|
||||
player.addScore(points);
|
||||
triggered = true;
|
||||
}
|
||||
}
|
||||
player.addScore(this.POINTS_REWARD);
|
||||
|
||||
BattleBanzaiGame battleBanzaiGame = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class);
|
||||
|
||||
if (battleBanzaiGame != null && battleBanzaiGame.getState() != GameState.IDLE) {
|
||||
battleBanzaiGame.refreshCounters(habbo.getHabboInfo().getGamePlayer().getTeamColor());
|
||||
}
|
||||
|
||||
if (triggered) {
|
||||
this.setExtradata("1");
|
||||
this.setExtradata(WiredBlobState.USED.getState());
|
||||
room.updateItem(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if (!this.RESETS_WITH_GAME && objects != null && objects.length == 2 && objects[1].equals(WiredEffectType.TOGGLE_STATE) && room.getGames().stream().anyMatch(game -> game.getState().equals(GameState.RUNNING) || game.getState().equals(GameState.PAUSED))) {
|
||||
this.setExtradata(this.getExtradata().equals(WiredBlobState.ACTIVE.getState()) ? WiredBlobState.USED.getState() : WiredBlobState.ACTIVE.getState());
|
||||
room.updateItem(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void onGameStart(Room room) {
|
||||
if (this.RESETS_WITH_GAME) {
|
||||
this.setExtradata(WiredBlobState.ACTIVE.getState());
|
||||
room.updateItem(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void onGameEnd(Room room) {
|
||||
this.setExtradata(WiredBlobState.USED.getState());
|
||||
room.updateItem(this);
|
||||
}
|
||||
|
||||
private void parseCustomParams() {
|
||||
String[] params = this.getBaseItem().getCustomParams().split(",");
|
||||
|
||||
if (params.length != 2) {
|
||||
Emulator.getLogging().logErrorLine("Wired blobs should have customparams with two parameters (points,resetsWithGame)");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.POINTS_REWARD = Integer.parseInt(params[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
Emulator.getLogging().logErrorLine("Wired blobs should have customparams with the first parameter being the amount of points (number)");
|
||||
return;
|
||||
}
|
||||
|
||||
this.RESETS_WITH_GAME = params[1].equalsIgnoreCase("true");
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class WiredTriggerHabboUnidle extends InteractionWiredTrigger {
|
||||
private static final WiredTriggerType type = WiredTriggerType.IDLES;
|
||||
private static final WiredTriggerType type = WiredTriggerType.UNIDLES;
|
||||
|
||||
public WiredTriggerHabboUnidle(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.ICycleable;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
@ -17,9 +19,9 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable {
|
||||
public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset {
|
||||
public static final WiredTriggerType type = WiredTriggerType.PERIODICALLY;
|
||||
public static final int DEFAULT_DELAY = 20 * 500;
|
||||
public static final int DEFAULT_DELAY = 10 * 500;
|
||||
|
||||
protected int repeatTime = DEFAULT_DELAY;
|
||||
protected int counter = 0;
|
||||
@ -123,4 +125,15 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTimer() {
|
||||
this.counter = 0;
|
||||
if (this.getRoomId() != 0) {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
if (room != null && room.isLoaded()) {
|
||||
WiredHandler.handle(this, null, room, new Object[]{this});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.ICycleable;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
@ -17,8 +19,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable {
|
||||
public static final int DEFAULT_DELAY = 20 * 5000;
|
||||
public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset {
|
||||
public static final int DEFAULT_DELAY = 10 * 5000;
|
||||
private static final WiredTriggerType type = WiredTriggerType.PERIODICALLY_LONG;
|
||||
private int repeatTime = DEFAULT_DELAY;
|
||||
private int counter = 0;
|
||||
@ -117,4 +119,15 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTimer() {
|
||||
this.counter = 0;
|
||||
if (this.getRoomId() != 0) {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
if (room != null && room.isLoaded()) {
|
||||
WiredHandler.handle(this, null, room, new Object[]{this});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,15 @@ public class ModToolIssue implements ISerialize {
|
||||
this.modName = set.getString("mod_username");
|
||||
this.type = ModToolTicketType.values()[set.getInt("type") - 1];
|
||||
this.category = set.getInt("category");
|
||||
this.groupId = set.getInt("group_id");
|
||||
this.threadId = set.getInt("thread_id");
|
||||
this.commentId = set.getInt("comment_id");
|
||||
|
||||
int photoItemId = set.getInt("photo_item_id");
|
||||
|
||||
if (photoItemId != -1) {
|
||||
this.photoItem = Emulator.getGameEnvironment().getItemManager().loadHabboItem(photoItemId);;
|
||||
}
|
||||
|
||||
if (this.modId <= 0) {
|
||||
this.modName = "";
|
||||
@ -79,8 +88,8 @@ public class ModToolIssue implements ISerialize {
|
||||
message.appendString(this.senderUsername); //Reporter user name.
|
||||
message.appendInt(this.reportedId); //Reported user ID.
|
||||
message.appendString(this.reportedUsername); //Reported user name.
|
||||
message.appendInt(this.modId); //MOD User ID?
|
||||
message.appendString(this.modName); //MOD User name?
|
||||
message.appendInt(this.modId); //ADMIN User ID?
|
||||
message.appendString(this.modName); //ADMIN User name?
|
||||
message.appendString(this.message);
|
||||
message.appendInt(0);
|
||||
|
||||
|
@ -278,12 +278,12 @@ public class ModToolManager {
|
||||
return chatlogs;
|
||||
}
|
||||
|
||||
public THashSet<ModToolRoomVisit> requestUserRoomVisits(Habbo habbo) {
|
||||
public THashSet<ModToolRoomVisit> getUserRoomVisits(int userId) {
|
||||
THashSet<ModToolRoomVisit> roomVisits = new THashSet<>();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, room_enter_log.* FROM room_enter_log INNER JOIN rooms ON rooms.id = room_enter_log.room_id WHERE user_id = ? AND timestamp >= ? ORDER BY timestamp DESC LIMIT 50")) {
|
||||
statement.setInt(1, habbo.getHabboInfo().getId());
|
||||
statement.setInt(2, Emulator.getIntUnixTimestamp() - 84600);
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, room_enter_log.* FROM room_enter_log INNER JOIN rooms ON rooms.id = room_enter_log.room_id WHERE user_id = ? ORDER BY timestamp DESC LIMIT 50")) {
|
||||
statement.setInt(1, userId);
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
roomVisits.add(new ModToolRoomVisit(set));
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.eu.habbo.habbohotel.modtool;
|
||||
|
||||
public class ModToolSanctionItem {
|
||||
public int id;
|
||||
public int habboId;
|
||||
public int sanctionLevel;
|
||||
public int probationTimestamp;
|
||||
public boolean isMuted;
|
||||
public int muteDuration;
|
||||
public int tradeLockedUntil;
|
||||
public String reason;
|
||||
|
||||
public ModToolSanctionItem(int id, int habboId, int sanctionLevel, int probationTimestamp, boolean isMuted, int muteDuration, int tradeLockedUntil, String reason) {
|
||||
this.id = id;
|
||||
this.habboId = habboId;
|
||||
this.sanctionLevel = sanctionLevel;
|
||||
this.probationTimestamp = probationTimestamp;
|
||||
this.isMuted = isMuted;
|
||||
this.muteDuration = muteDuration;
|
||||
this.tradeLockedUntil = tradeLockedUntil;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.eu.habbo.habbohotel.modtool;
|
||||
|
||||
public class ModToolSanctionLevelItem {
|
||||
public int sanctionLevel;
|
||||
public String sanctionType;
|
||||
public int sanctionHourLength;
|
||||
public int sanctionProbationDays;
|
||||
|
||||
public ModToolSanctionLevelItem(int sanctionLevel, String sanctionType, int sanctionHourLength, int sanctionProbationDays) {
|
||||
this.sanctionLevel = sanctionLevel;
|
||||
this.sanctionType = sanctionType;
|
||||
this.sanctionHourLength = sanctionHourLength;
|
||||
this.sanctionProbationDays = sanctionProbationDays;
|
||||
}
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
package com.eu.habbo.habbohotel.modtool;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.plugin.events.sanctions.SanctionEvent;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
public class ModToolSanctions {
|
||||
|
||||
private final THashMap<Integer, ArrayList<ModToolSanctionItem>> sanctionHashmap;
|
||||
private final THashMap<Integer, ModToolSanctionLevelItem> sanctionLevelsHashmap;
|
||||
|
||||
public ModToolSanctions() {
|
||||
long millis = System.currentTimeMillis();
|
||||
this.sanctionHashmap = new THashMap<>();
|
||||
this.sanctionLevelsHashmap = new THashMap<>();
|
||||
this.loadModSanctions();
|
||||
Emulator.getLogging().logStart("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
||||
|
||||
}
|
||||
|
||||
public synchronized void loadModSanctions() {
|
||||
this.sanctionHashmap.clear();
|
||||
this.sanctionLevelsHashmap.clear();
|
||||
|
||||
this.loadSanctionLevels();
|
||||
}
|
||||
|
||||
private void loadSanctionLevels() {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanction_levels")) {
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
this.sanctionLevelsHashmap.put(set.getInt("level"), new ModToolSanctionLevelItem(set.getInt("level"), set.getString("type"), set.getInt("hour_length"), set.getInt("probation_days")));
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public ModToolSanctionLevelItem getSanctionLevelItem(int sanctionLevel) {
|
||||
return this.sanctionLevelsHashmap.get(sanctionLevel);
|
||||
}
|
||||
|
||||
public THashMap<Integer, ArrayList<ModToolSanctionItem>> getSanctions(int habboId) {
|
||||
synchronized (this.sanctionHashmap) {
|
||||
this.sanctionHashmap.clear();
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanctions WHERE habbo_id = ? ORDER BY id ASC")) {
|
||||
statement.setInt(1, habboId);
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
if (this.sanctionHashmap.get(set.getInt("habbo_id")) == null) {
|
||||
this.sanctionHashmap.put(set.getInt("habbo_id"), new ArrayList<>());
|
||||
}
|
||||
|
||||
ModToolSanctionItem item = new ModToolSanctionItem(set.getInt("id"), set.getInt("habbo_id"), set.getInt("sanction_level"), set.getInt("probation_timestamp"), set.getBoolean("is_muted"), set.getInt("mute_duration"), set.getInt("trade_locked_until"), set.getString("reason"));
|
||||
|
||||
if (!this.sanctionHashmap.get(set.getInt("habbo_id")).contains(item)) {
|
||||
this.sanctionHashmap.get(set.getInt("habbo_id")).add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
|
||||
return this.sanctionHashmap;
|
||||
}
|
||||
}
|
||||
|
||||
private void insertSanction(int habboId, int sanctionLevel, int probationTimestamp, String reason, int tradeLockedUntil, boolean isMuted, int muteDuration) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO sanctions (habbo_id, sanction_level, probation_timestamp, reason, trade_locked_until, is_muted, mute_duration) VALUES (?, ?, ?, ?, ?, ?, ?)")) {
|
||||
statement.setInt(1, habboId);
|
||||
statement.setInt(2, sanctionLevel);
|
||||
statement.setInt(3, probationTimestamp);
|
||||
statement.setString(4, reason);
|
||||
statement.setInt(5, tradeLockedUntil);
|
||||
statement.setBoolean(6, isMuted);
|
||||
statement.setInt(7, muteDuration);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSanction(int rowId, int probationTimestamp) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET probation_timestamp = ? WHERE id = ?")) {
|
||||
statement.setInt(1, probationTimestamp);
|
||||
statement.setInt(2, rowId);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTradeLockedUntil(int rowId, int tradeLockedUntil) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET trade_locked_until = ? WHERE id = ?")) {
|
||||
statement.setInt(1, tradeLockedUntil);
|
||||
statement.setInt(2, rowId);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMuteDuration(int rowId, int muteDuration) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET mute_duration = ? WHERE id = ?")) {
|
||||
statement.setInt(1, muteDuration);
|
||||
statement.setInt(2, rowId);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void run(int habboId, Habbo self, int sanctionLevel, int cfhTopic, String reason, int tradeLockedUntil, boolean isMuted, int muteDuration) {
|
||||
sanctionLevel++;
|
||||
|
||||
ModToolSanctionLevelItem sanctionLevelItem = getSanctionLevelItem(sanctionLevel);
|
||||
|
||||
insertSanction(habboId, sanctionLevel, buildProbationTimestamp(sanctionLevelItem), reason, tradeLockedUntil, isMuted, muteDuration);
|
||||
|
||||
runSanctionBasedOnLevel(sanctionLevelItem, habboId, reason, cfhTopic, self, muteDuration);
|
||||
|
||||
Emulator.getPluginManager().fireEvent(new SanctionEvent(self, Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId), sanctionLevel));
|
||||
}
|
||||
|
||||
private int buildProbationTimestamp(ModToolSanctionLevelItem sanctionLevelItem) {
|
||||
return Emulator.getIntUnixTimestamp() + (sanctionLevelItem.sanctionProbationDays * 24 * 60 * 60);
|
||||
}
|
||||
|
||||
public int getProbationDays(ModToolSanctionLevelItem sanctionLevelItem) {
|
||||
return sanctionLevelItem.sanctionProbationDays;
|
||||
}
|
||||
|
||||
private void runSanctionBasedOnLevel(ModToolSanctionLevelItem sanctionLevelItem, int habboId, String reason, int cfhTopic, Habbo self, int muteDuration) {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId);
|
||||
|
||||
int muteDurationSeconds = 0;
|
||||
|
||||
if (muteDuration > 0) {
|
||||
Date muteDurationDate = new Date((long) muteDuration * 1000);
|
||||
long diff = muteDurationDate.getTime() - Emulator.getDate().getTime();
|
||||
muteDurationSeconds = Math.toIntExact(diff / 1000);
|
||||
}
|
||||
|
||||
switch (sanctionLevelItem.sanctionType) {
|
||||
case "ALERT": habbo.alert(reason); break;
|
||||
case "BAN": Emulator.getGameEnvironment().getModToolManager().ban(habboId, self, reason, sanctionLevelItem.sanctionHourLength, ModToolBanType.ACCOUNT, cfhTopic); break;
|
||||
case "MUTE": habbo.mute(muteDurationSeconds == 0 ? 3600 : muteDurationSeconds, false); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSanctionType(ModToolSanctionLevelItem sanctionLevelItem) {
|
||||
return sanctionLevelItem.sanctionType;
|
||||
}
|
||||
|
||||
public int getTimeOfSanction(ModToolSanctionLevelItem sanctionLevelItem) {
|
||||
return sanctionLevelItem.sanctionHourLength;
|
||||
}
|
||||
}
|
@ -150,7 +150,7 @@ public class WordFilter {
|
||||
foundShit = true;
|
||||
|
||||
if (habbo != null && word.muteTime > 0) {
|
||||
habbo.mute(word.muteTime);
|
||||
habbo.mute(word.muteTime, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.eu.habbo.habbohotel.navigation;
|
||||
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
public class EventCategory {
|
||||
private int id;
|
||||
private String caption;
|
||||
private boolean visible;
|
||||
|
||||
public EventCategory(int id, String caption, boolean visible) {
|
||||
this.id = id;
|
||||
this.caption = caption;
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public EventCategory(String serialized) throws Exception {
|
||||
String[] parts = serialized.split(",");
|
||||
|
||||
if (parts.length != 3) throw new Exception("A serialized event category should contain 3 fields");
|
||||
|
||||
this.id = Integer.valueOf(parts[0]);
|
||||
this.caption = parts[1];
|
||||
this.visible = parts[2].equalsIgnoreCase("true");
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void serialize(ServerMessage message) {
|
||||
message.appendInt(this.id);
|
||||
message.appendString(this.caption);
|
||||
message.appendBoolean(this.visible);
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ public class HorsePet extends RideablePet {
|
||||
this.hairStyle = set.getInt("hair_style");
|
||||
this.hasSaddle(set.getString("saddle").equalsIgnoreCase("1"));
|
||||
this.setAnyoneCanRide(set.getString("ride").equalsIgnoreCase("1"));
|
||||
this.setSaddleItemId(set.getInt("saddle_item_id"));
|
||||
}
|
||||
|
||||
public HorsePet(int type, int race, String color, String name, int userId) {
|
||||
@ -30,12 +31,13 @@ public class HorsePet extends RideablePet {
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ? WHERE id = ?")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ?, saddle_item_id = ? WHERE id = ?")) {
|
||||
statement.setInt(1, this.hairStyle);
|
||||
statement.setInt(2, this.hairColor);
|
||||
statement.setString(3, this.hasSaddle() ? "1" : "0");
|
||||
statement.setString(4, this.anyoneCanRide() ? "1" : "0");
|
||||
statement.setInt(5, super.getId());
|
||||
statement.setInt(5, this.getSaddleItemId());
|
||||
statement.setInt(6, super.getId());
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
|
@ -2,10 +2,10 @@ package com.eu.habbo.habbohotel.pets;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionNest;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionPetDrink;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionPetFood;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionPetToy;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
@ -3,10 +3,10 @@ package com.eu.habbo.habbohotel.pets;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionNest;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionPetDrink;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionPetFood;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionPetToy;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy;
|
||||
import com.eu.habbo.habbohotel.pets.actions.*;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
|
@ -10,6 +10,7 @@ public class RideablePet extends Pet {
|
||||
private Habbo rider;
|
||||
private boolean hasSaddle;
|
||||
private boolean anyoneCanRide;
|
||||
private int saddleItemId;
|
||||
|
||||
public RideablePet(ResultSet set) throws SQLException {
|
||||
super(set);
|
||||
@ -44,4 +45,12 @@ public class RideablePet extends Pet {
|
||||
public void setRider(Habbo rider) {
|
||||
this.rider = rider;
|
||||
}
|
||||
|
||||
public int getSaddleItemId() {
|
||||
return saddleItemId;
|
||||
}
|
||||
|
||||
public void setSaddleItemId(int saddleItemId) {
|
||||
this.saddleItemId = saddleItemId;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.eu.habbo.habbohotel.pets.actions;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionPetBreedingNest;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest;
|
||||
import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.PetAction;
|
||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||
|
@ -19,6 +19,10 @@ import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.Interaction
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
|
||||
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
@ -26,7 +30,8 @@ import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.PetManager;
|
||||
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||
import com.eu.habbo.habbohotel.users.*;
|
||||
import com.eu.habbo.habbohotel.wired.*;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ISerialize;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
@ -78,6 +83,7 @@ import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
public static final Comparator SORT_SCORE = new Comparator() {
|
||||
@ -466,6 +472,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection()));
|
||||
} else {
|
||||
b.getRoomUnit().setZ(set.getDouble("z"));
|
||||
b.getRoomUnit().setPreviousLocationZ(set.getDouble("z"));
|
||||
b.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]);
|
||||
}
|
||||
b.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
|
||||
@ -547,7 +554,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
tile.setState(this.calculateTileState(tile));
|
||||
}
|
||||
|
||||
this.sendComposer(new UpdateStackHeightComposer(tiles).compose());
|
||||
this.sendComposer(new UpdateStackHeightComposer(this, tiles).compose());
|
||||
}
|
||||
|
||||
private RoomTileState calculateTileState(RoomTile tile) {
|
||||
@ -563,6 +570,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
HabboItem lowestChair = this.getLowestChair(tile);
|
||||
THashSet<HabboItem> items = this.getItemsAt(tile);
|
||||
if (items == null) return RoomTileState.INVALID;
|
||||
|
||||
if (items.stream().anyMatch(i -> i.getBaseItem().allowLay())) return RoomTileState.LAY;
|
||||
|
||||
for (HabboItem item : items) {
|
||||
if (exclude != null && item == exclude) continue;
|
||||
|
||||
@ -573,10 +583,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (lowestItem == null || lowestItem.getZ() < item.getZ()) {
|
||||
lowestItem = item;
|
||||
|
||||
result = this.checkStateForItem(lowestItem);
|
||||
result = this.checkStateForItem(lowestItem, tile);
|
||||
} else if (lowestItem.getZ() == item.getZ()) {
|
||||
if (result == RoomTileState.OPEN) {
|
||||
result = this.checkStateForItem(item);
|
||||
result = this.checkStateForItem(item, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -586,7 +596,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return result;
|
||||
}
|
||||
|
||||
private RoomTileState checkStateForItem(HabboItem item) {
|
||||
private RoomTileState checkStateForItem(HabboItem item, RoomTile tile) {
|
||||
RoomTileState result = RoomTileState.BLOCKED;
|
||||
|
||||
if (item.isWalkable()) {
|
||||
@ -601,6 +611,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
result = RoomTileState.LAY;
|
||||
}
|
||||
|
||||
RoomTileState overriddenState = item.getOverrideTileState(tile, this);
|
||||
if (overriddenState != null) {
|
||||
result = overriddenState;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -655,7 +670,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.sendComposer(new UpdateStackHeightComposer(updatedTiles).compose());
|
||||
this.sendComposer(new UpdateStackHeightComposer(this, updatedTiles).compose());
|
||||
this.updateTiles(updatedTiles);
|
||||
for (RoomTile tile : updatedTiles) {
|
||||
this.updateHabbosAt(tile.x, tile.y);
|
||||
@ -719,8 +734,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
public void updateHabbosAt(short x, short y) {
|
||||
THashSet<Habbo> habbos = this.getHabbosAt(x, y);
|
||||
this.updateHabbosAt(x, y, this.getHabbosAt(x, y));
|
||||
}
|
||||
|
||||
public void updateHabbosAt(short x, short y, THashSet<Habbo> habbos) {
|
||||
HabboItem item = this.getTopItemAt(x, y);
|
||||
|
||||
THashSet<RoomUnit> roomUnits = new THashSet<>();
|
||||
@ -751,7 +768,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBotsAt(short x, short y) {
|
||||
public void updateBotsAt(short x, short y) {
|
||||
HabboItem topItem = this.getTopItemAt(x, y);
|
||||
|
||||
THashSet<RoomUnit> roomUnits = new THashSet<>();
|
||||
@ -763,7 +780,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
bot.getRoomUnit().setPreviousLocationZ(topItem.getZ());
|
||||
bot.getRoomUnit().setRotation(RoomUserRotation.fromValue(topItem.getRotation()));
|
||||
} else {
|
||||
bot.getRoomUnit().setZ(topItem.getZ() + topItem.getBaseItem().getHeight());
|
||||
bot.getRoomUnit().setZ(topItem.getZ() + Item.getCurrentHeight(topItem));
|
||||
|
||||
if (topItem.getBaseItem().allowLay()) {
|
||||
bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + "");
|
||||
@ -771,6 +788,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
} else {
|
||||
bot.getRoomUnit().setZ(bot.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||
bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||
}
|
||||
|
||||
roomUnits.add(bot.getRoomUnit());
|
||||
@ -838,10 +856,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return;
|
||||
|
||||
if (this.loaded) {
|
||||
try {
|
||||
if (!this.traxManager.disposed()) {
|
||||
this.traxManager.dispose();
|
||||
}
|
||||
try {
|
||||
|
||||
this.roomCycleTask.cancel(false);
|
||||
this.scheduledTasks.clear();
|
||||
this.scheduledComposers.clear();
|
||||
@ -921,12 +940,16 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
this.wordQuiz = "";
|
||||
this.yesVotes = 0;
|
||||
this.noVotes = 0;
|
||||
this.updateDatabaseUserCount();
|
||||
this.preLoaded = true;
|
||||
this.layout = null;
|
||||
} catch (Exception e) {
|
||||
Emulator.getLogging().logErrorLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getPluginManager().fireEvent(new RoomUnloadedEvent(this));
|
||||
@ -1457,7 +1480,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
}, this.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1603,7 +1626,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.dance(unit, DanceType.NONE);
|
||||
//int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z;
|
||||
unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + "");
|
||||
unit.setPreviousLocationZ(topItem.getZ());
|
||||
unit.setZ(topItem.getZ());
|
||||
unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]);
|
||||
unit.sitUpdate = false;
|
||||
@ -2095,25 +2117,29 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void createPromotion(String title, String description) {
|
||||
public void createPromotion(String title, String description, int category) {
|
||||
this.promoted = true;
|
||||
|
||||
if (this.promotion == null) {
|
||||
this.promotion = new RoomPromotion(this, title, description, Emulator.getIntUnixTimestamp() + (120 * 60));
|
||||
this.promotion = new RoomPromotion(this, title, description, Emulator.getIntUnixTimestamp() + (120 * 60), Emulator.getIntUnixTimestamp(), category);
|
||||
} else {
|
||||
this.promotion.setTitle(title);
|
||||
this.promotion.setDescription(description);
|
||||
this.promotion.setEndTimestamp(Emulator.getIntUnixTimestamp() + (120 * 60));
|
||||
this.promotion.setCategory(category);
|
||||
}
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp, start_timestamp, category) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?, category = ?")) {
|
||||
statement.setInt(1, this.id);
|
||||
statement.setString(2, title);
|
||||
statement.setString(3, description);
|
||||
statement.setInt(4, this.promotion.getEndTimestamp());
|
||||
statement.setString(5, this.promotion.getTitle());
|
||||
statement.setString(6, this.promotion.getDescription());
|
||||
statement.setInt(7, this.promotion.getEndTimestamp());
|
||||
statement.setInt(5, this.promotion.getStartTimestamp());
|
||||
statement.setInt(6, category);
|
||||
statement.setString(7, this.promotion.getTitle());
|
||||
statement.setString(8, this.promotion.getDescription());
|
||||
statement.setInt(9, this.promotion.getEndTimestamp());
|
||||
statement.setInt(10, this.promotion.getCategory());
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
@ -2359,6 +2385,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
public HabboItem getHabboItem(int id) {
|
||||
if (this.roomItems == null || this.roomSpecialTypes == null)
|
||||
return null; // room not loaded completely
|
||||
|
||||
HabboItem item;
|
||||
synchronized (this.roomItems) {
|
||||
item = this.roomItems.get(id);
|
||||
@ -2577,6 +2606,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose());
|
||||
}
|
||||
|
||||
if (habbo.getRoomUnit().getCurrentLocation() != null) {
|
||||
HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY());
|
||||
|
||||
if (item != null) {
|
||||
@ -2586,6 +2616,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
Emulator.getLogging().logErrorLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (this.roomUnitLock) {
|
||||
this.currentHabbos.remove(habbo.getHabboInfo().getId());
|
||||
@ -2971,7 +3002,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
habbo.getHabboStats().mutedCount++;
|
||||
timeOut += (timeOut * (int) Math.ceil(Math.pow(habbo.getHabboStats().mutedCount, 2)));
|
||||
habbo.getHabboStats().chatCounter = 0;
|
||||
habbo.mute(timeOut);
|
||||
habbo.mute(timeOut, true);
|
||||
}
|
||||
|
||||
public void talk(Habbo habbo, RoomChatMessage roomChatMessage, RoomChatType chatType) {
|
||||
@ -3962,6 +3993,18 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
|
||||
}
|
||||
|
||||
public void makeStand(Habbo habbo) {
|
||||
if (habbo.getRoomUnit() == null) return;
|
||||
|
||||
HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY());
|
||||
if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) {
|
||||
habbo.getRoomUnit().cmdStand = true;
|
||||
habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]);
|
||||
habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT);
|
||||
this.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
|
||||
}
|
||||
}
|
||||
|
||||
public void giveEffect(Habbo habbo, int effectId, int duration) {
|
||||
if (this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) {
|
||||
this.giveEffect(habbo.getRoomUnit(), effectId, duration);
|
||||
@ -4089,11 +4132,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (habbo != null && iterator.value().getUserId() == habbo.getHabboInfo().getId())
|
||||
continue;
|
||||
|
||||
if (userItemsMap.get(iterator.value().getUserId()) == null) {
|
||||
userItemsMap.put(iterator.value().getUserId(), new THashSet<>());
|
||||
}
|
||||
if (iterator.value() instanceof InteractionPostIt)
|
||||
continue;
|
||||
|
||||
userItemsMap.get(iterator.value().getUserId()).add(iterator.value());
|
||||
userItemsMap.computeIfAbsent(iterator.value().getUserId(), k -> new THashSet<>()).add(iterator.value());
|
||||
}
|
||||
}
|
||||
|
||||
@ -4161,6 +4203,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
public void idle(Habbo habbo) {
|
||||
habbo.getRoomUnit().setIdle();
|
||||
|
||||
if (habbo.getRoomUnit().getDanceType() != DanceType.NONE) {
|
||||
this.dance(habbo, DanceType.NONE);
|
||||
}
|
||||
|
||||
this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose());
|
||||
WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
|
||||
}
|
||||
@ -4331,6 +4378,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))
|
||||
return FurnitureMovementError.INVALID_MOVE;
|
||||
|
||||
if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE;
|
||||
|
||||
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
|
||||
@ -4339,9 +4388,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
|
||||
}
|
||||
|
||||
boolean magicTile = item instanceof InteractionStackHelper;
|
||||
|
||||
if (!magicTile) {
|
||||
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>();
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
|
||||
@ -4355,7 +4401,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (!item.canStackAt(this, tileFurniList)) {
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
}
|
||||
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
@ -4438,8 +4483,12 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
boolean magicTile = item instanceof InteractionStackHelper;
|
||||
|
||||
Optional<HabboItem> stackHelper = this.getItemsAt(tile).stream().filter(i -> i instanceof InteractionStackHelper).findAny();
|
||||
|
||||
//Check if can be placed at new position
|
||||
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
|
||||
if (!stackHelper.isPresent()) {
|
||||
if (topItem != item) {
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
HabboItem tileTopItem = this.getTopItemAt(t.x, t.y);
|
||||
@ -4459,6 +4508,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (!magicTile && !item.canStackAt(this, tileFurniList)) {
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
}
|
||||
|
||||
THashSet<RoomTile> oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
|
||||
@ -4477,8 +4527,19 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
//Place at new position
|
||||
double height = this.getStackHeight(tile.x, tile.y, false, item);
|
||||
|
||||
double height;
|
||||
|
||||
if (stackHelper.isPresent()) {
|
||||
height = stackHelper.get().getExtradata().isEmpty() ? Double.valueOf("0.0") : (Double.valueOf(stackHelper.get().getExtradata()) / 100);
|
||||
} else if (item.equals(topItem) && tile.x == item.getX() && tile.y == item.getY()) {
|
||||
height = item.getZ();
|
||||
} else {
|
||||
height = this.getStackHeight(tile.x, tile.y, false, item);
|
||||
}
|
||||
|
||||
if(height > 40d) return FurnitureMovementError.CANT_STACK;
|
||||
|
||||
item.setX(tile.x);
|
||||
item.setY(tile.y);
|
||||
item.setZ(height);
|
||||
@ -4504,7 +4565,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
//Update Habbos at old position
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
this.updateHabbosAt(t.x, t.y);
|
||||
this.updateHabbosAt(
|
||||
t.x,
|
||||
t.y,
|
||||
this.getHabbosAt(t.x, t.y)
|
||||
.stream()
|
||||
.filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
|
||||
.collect(Collectors.toCollection(THashSet::new))
|
||||
);
|
||||
this.updateBotsAt(t.x, t.y);
|
||||
}
|
||||
return FurnitureMovementError.NONE;
|
||||
|
@ -210,7 +210,7 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
this.habbo.mute(Emulator.getConfig().getInt("hotel.wordfilter.automute"));
|
||||
this.habbo.mute(Emulator.getConfig().getInt("hotel.wordfilter.automute"), false);
|
||||
}
|
||||
|
||||
this.message = "";
|
||||
|
@ -257,25 +257,32 @@ public class RoomLayout {
|
||||
return this.heightmap.replace("\r\n", "\r");
|
||||
}//re
|
||||
|
||||
/// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3
|
||||
public final Deque<RoomTile> findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) {
|
||||
return this.findPath(oldTile, newTile, goalLocation, roomUnit, false);
|
||||
}
|
||||
|
||||
/// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3
|
||||
public final Deque<RoomTile> findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit, boolean isWalktroughRetry) {
|
||||
if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID)
|
||||
return new LinkedList<>();
|
||||
|
||||
LinkedList<RoomTile> openList = new LinkedList<>();
|
||||
List<RoomTile> closedList = new LinkedList<>();
|
||||
RoomTile current;
|
||||
openList.add(oldTile.copy());
|
||||
while (!openList.isEmpty()) {
|
||||
current = this.lowestFInOpen(openList);
|
||||
if ((current.x == newTile.x) && (current.y == newTile.y)) {
|
||||
return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current);
|
||||
|
||||
while (!openList.isEmpty()) {
|
||||
RoomTile current = this.lowestFInOpen(openList);
|
||||
if (current.x == newTile.x && current.y == newTile.y) {
|
||||
return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current);
|
||||
}
|
||||
|
||||
closedList.add(current);
|
||||
openList.remove(current);
|
||||
List<RoomTile> adjacentNodes = this.getAdjacent(openList, current, newTile);
|
||||
|
||||
List<RoomTile> adjacentNodes = this.getAdjacent(openList, current, newTile, roomUnit);
|
||||
for (RoomTile currentAdj : adjacentNodes) {
|
||||
if (closedList.contains(currentAdj)) continue;
|
||||
|
||||
if (roomUnit.canOverrideTile(currentAdj) || (currentAdj.state != RoomTileState.BLOCKED && currentAdj.x == doorX && currentAdj.y == doorY)) {
|
||||
currentAdj.setPrevious(current);
|
||||
currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y));
|
||||
@ -283,19 +290,23 @@ public class RoomLayout {
|
||||
openList.add(currentAdj);
|
||||
continue;
|
||||
}
|
||||
if ((currentAdj.state == RoomTileState.BLOCKED) || ((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) {
|
||||
|
||||
if (currentAdj.state == RoomTileState.BLOCKED || ((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) {
|
||||
closedList.add(currentAdj);
|
||||
openList.remove(currentAdj);
|
||||
continue;
|
||||
}
|
||||
|
||||
double height = currentAdj.getStackHeight() - current.getStackHeight();
|
||||
if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue;
|
||||
if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue;
|
||||
if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) {
|
||||
|
||||
if (currentAdj.hasUnits() && ((!isWalktroughRetry && !this.room.isAllowWalkthrough()) || currentAdj.equals(goalLocation))) {
|
||||
closedList.add(currentAdj);
|
||||
openList.remove(currentAdj);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!openList.contains(currentAdj)) {
|
||||
currentAdj.setPrevious(current);
|
||||
currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y));
|
||||
@ -307,8 +318,12 @@ public class RoomLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
// System.out.println("Invalid Path.");
|
||||
return new LinkedList<>();
|
||||
|
||||
if (!this.room.isAllowWalkthrough() && !isWalktroughRetry) {
|
||||
return this.findPath(oldTile, newTile, goalLocation, roomUnit, true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private RoomTile findTile(List<RoomTile> tiles, short x, short y) {
|
||||
@ -326,7 +341,7 @@ public class RoomLayout {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Deque<RoomTile> calcPath(RoomTile start, RoomTile goal) {
|
||||
public Deque<RoomTile> calcPath(RoomTile start, RoomTile goal) {
|
||||
LinkedList<RoomTile> path = new LinkedList<>();
|
||||
if (start == null)
|
||||
return path;
|
||||
@ -355,13 +370,13 @@ public class RoomLayout {
|
||||
return cheapest;
|
||||
}
|
||||
|
||||
private List<RoomTile> getAdjacent(List<RoomTile> openList, RoomTile node, RoomTile nextTile) {
|
||||
private List<RoomTile> getAdjacent(List<RoomTile> openList, RoomTile node, RoomTile nextTile, RoomUnit unit) {
|
||||
short x = node.x;
|
||||
short y = node.y;
|
||||
List<RoomTile> adj = new LinkedList<>();
|
||||
if (x > 0) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x - 1), y);
|
||||
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
temp.isDiagonally(false);
|
||||
if (!adj.contains(temp))
|
||||
@ -371,7 +386,7 @@ public class RoomLayout {
|
||||
}
|
||||
if (x < this.mapSizeX) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x + 1), y);
|
||||
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
temp.isDiagonally(false);
|
||||
if (!adj.contains(temp))
|
||||
@ -381,7 +396,7 @@ public class RoomLayout {
|
||||
}
|
||||
if (y > 0) {
|
||||
RoomTile temp = this.findTile(openList, x, (short) (y - 1));
|
||||
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
temp.isDiagonally(false);
|
||||
if (!adj.contains(temp))
|
||||
@ -391,7 +406,7 @@ public class RoomLayout {
|
||||
}
|
||||
if (y < this.mapSizeY) {
|
||||
RoomTile temp = this.findTile(openList, x, (short) (y + 1));
|
||||
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
temp.isDiagonally(false);
|
||||
if (!adj.contains(temp))
|
||||
@ -405,7 +420,7 @@ public class RoomLayout {
|
||||
RoomTile offY = this.findTile(openList, x, (short) (y + 1));
|
||||
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y + 1));
|
||||
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
temp.isDiagonally(true);
|
||||
if (!adj.contains(temp))
|
||||
@ -419,7 +434,7 @@ public class RoomLayout {
|
||||
RoomTile offY = this.findTile(openList, x, (short) (y - 1));
|
||||
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y - 1));
|
||||
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
temp.isDiagonally(true);
|
||||
if (!adj.contains(temp))
|
||||
@ -433,7 +448,7 @@ public class RoomLayout {
|
||||
RoomTile offY = this.findTile(openList, x, (short) (y + 1));
|
||||
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y + 1));
|
||||
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
temp.isDiagonally(true);
|
||||
if (!adj.contains(temp))
|
||||
@ -447,7 +462,7 @@ public class RoomLayout {
|
||||
RoomTile offY = this.findTile(openList, x, (short) (y - 1));
|
||||
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y - 1));
|
||||
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) {
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
temp.isDiagonally(true);
|
||||
if (!adj.contains(temp))
|
||||
@ -460,6 +475,10 @@ public class RoomLayout {
|
||||
return adj;
|
||||
}
|
||||
|
||||
private boolean canWalkOn(RoomTile tile, RoomUnit unit) {
|
||||
return tile != null && (unit.canOverrideTile(tile) || (tile.state != RoomTileState.BLOCKED && tile.state != RoomTileState.INVALID));
|
||||
}
|
||||
|
||||
public void moveDiagonally(boolean value) {
|
||||
this.CANMOVEDIAGONALY = value;
|
||||
}
|
||||
@ -536,10 +555,14 @@ public class RoomLayout {
|
||||
}
|
||||
|
||||
public List<RoomTile> getTilesAround(RoomTile tile, int directionOffset) {
|
||||
List<RoomTile> tiles = new ArrayList<>(8);
|
||||
return getTilesAround(tile, directionOffset, true);
|
||||
}
|
||||
|
||||
public List<RoomTile> getTilesAround(RoomTile tile, int directionOffset, boolean diagonal) {
|
||||
List<RoomTile> tiles = new ArrayList<>(diagonal ? 8 : 4);
|
||||
|
||||
if (tile != null) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 8; i += (diagonal ? 1 : 2)) {
|
||||
RoomTile t = this.getTileInFront(tile, (i + directionOffset) % 8);
|
||||
if (t != null) {
|
||||
tiles.add(t);
|
||||
|
@ -596,7 +596,7 @@ public class RoomManager {
|
||||
habbo.getRoomUnit().clearStatus();
|
||||
if (habbo.getRoomUnit().getCurrentLocation() == null) {
|
||||
habbo.getRoomUnit().setLocation(doorLocation != null ? doorLocation : room.getLayout().getDoorTile());
|
||||
habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||
if (habbo.getRoomUnit().getCurrentLocation() != null) habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||
|
||||
if (doorLocation == null) {
|
||||
habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
|
||||
@ -713,21 +713,23 @@ public class RoomManager {
|
||||
if (!room.getCurrentHabbos().isEmpty()) {
|
||||
|
||||
Collection<Habbo> habbosToSendEnter = room.getCurrentHabbos().values();
|
||||
Collection<Habbo> visibleHabbos = room.getHabbos();
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) {
|
||||
HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter));
|
||||
HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter, visibleHabbos));
|
||||
habbosToSendEnter = event.habbosToSendEnter;
|
||||
visibleHabbos = event.visibleHabbos;
|
||||
}
|
||||
|
||||
for (Habbo habboToSendEnter : habbosToSendEnter) {
|
||||
GameClient client = habboToSendEnter.getClient();
|
||||
if (client != null) {
|
||||
client.sendResponse(new RoomUsersComposer(habbo).compose());
|
||||
habboToSendEnter.getClient().sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
|
||||
client.sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
|
||||
}
|
||||
}
|
||||
|
||||
for (Habbo h : room.getHabbos()) {
|
||||
for (Habbo h : visibleHabbos) {
|
||||
if (!h.getRoomUnit().isInvisible()) {
|
||||
habbos.add(h);
|
||||
}
|
||||
@ -747,11 +749,6 @@ public class RoomManager {
|
||||
}
|
||||
|
||||
int effect = habbo.getInventory().getEffectsComponent().activatedEffect;
|
||||
|
||||
if (effect == 0) {
|
||||
effect = habbo.getHabboInfo().getRank().getRoomEffect();
|
||||
}
|
||||
|
||||
room.giveEffect(habbo.getRoomUnit(), effect, -1);
|
||||
}
|
||||
|
||||
@ -770,7 +767,7 @@ public class RoomManager {
|
||||
habbo.getClient().sendResponse(new RoomUserDanceComposer(bot.getRoomUnit()));
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit()));
|
||||
habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit(), bot.getRoomUnit().getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,16 @@ public class RoomPromotion {
|
||||
private String title;
|
||||
private String description;
|
||||
private int endTimestamp;
|
||||
private int startTimestamp;
|
||||
private int category;
|
||||
|
||||
public RoomPromotion(Room room, String title, String description, int endTimestamp) {
|
||||
public RoomPromotion(Room room, String title, String description, int endTimestamp, int startTimestamp, int category) {
|
||||
this.room = room;
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.endTimestamp = endTimestamp;
|
||||
this.startTimestamp = startTimestamp;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public RoomPromotion(Room room, ResultSet set) throws SQLException {
|
||||
@ -26,14 +30,17 @@ public class RoomPromotion {
|
||||
this.title = set.getString("title");
|
||||
this.description = set.getString("description");
|
||||
this.endTimestamp = set.getInt("end_timestamp");
|
||||
this.startTimestamp = set.getInt("start_timestamp");
|
||||
this.category = set.getInt("category");
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (this.needsUpdate) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_promotions SET title = ?, description = ? WHERE room_id = ?")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_promotions SET title = ?, description = ?, category = ? WHERE room_id = ?")) {
|
||||
statement.setString(1, this.title);
|
||||
statement.setString(2, this.description);
|
||||
statement.setInt(3, this.room.getId());
|
||||
statement.setInt(3, this.category);
|
||||
statement.setInt(4, this.room.getId());
|
||||
statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
@ -74,4 +81,20 @@ public class RoomPromotion {
|
||||
public void addEndTimestamp(int time) {
|
||||
this.endTimestamp += time;
|
||||
}
|
||||
|
||||
public int getStartTimestamp() {
|
||||
return startTimestamp;
|
||||
}
|
||||
|
||||
public void setStartTimestamp(int startTimestamp) {
|
||||
this.startTimestamp = startTimestamp;
|
||||
}
|
||||
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(int category) {
|
||||
this.category = category;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ import com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards.Int
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
|
||||
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.eu.habbo.habbohotel.rooms;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionHabboClubGate;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWater;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem;
|
||||
import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||
import com.eu.habbo.habbohotel.users.DanceType;
|
||||
@ -21,18 +25,20 @@ import gnu.trove.map.TMap;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RoomUnit {
|
||||
public boolean isWiredTeleporting = false;
|
||||
private final ConcurrentHashMap<RoomUnitStatus, String> status;
|
||||
private final THashMap<String, Object> cacheable;
|
||||
public boolean canRotate = true;
|
||||
public boolean animateWalk = false;
|
||||
public boolean cmdTeleport = false;
|
||||
public boolean cmdSit = false;
|
||||
public boolean cmdStand = false;
|
||||
public boolean cmdLay = false;
|
||||
public boolean sitUpdate = false;
|
||||
public boolean isTeleporting = false;
|
||||
@ -63,6 +69,7 @@ public class RoomUnit {
|
||||
private int walkTimeOut;
|
||||
private int effectId;
|
||||
private int effectEndTimestamp;
|
||||
private ScheduledFuture moveBlockingTask;
|
||||
|
||||
private int idleTimer;
|
||||
private Room room;
|
||||
@ -173,6 +180,9 @@ public class RoomUnit {
|
||||
}
|
||||
|
||||
Deque<RoomTile> peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this);
|
||||
|
||||
if (peekPath == null) peekPath = new LinkedList<>();
|
||||
|
||||
if (peekPath.size() >= 3) {
|
||||
if (path.isEmpty()) return true;
|
||||
|
||||
@ -282,7 +292,7 @@ public class RoomUnit {
|
||||
if (item != null) {
|
||||
if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) {
|
||||
if (item.canWalkOn(this, room, null)) {
|
||||
item.onWalkOn(this, room, null);
|
||||
item.onWalkOn(this, room, new Object[]{this.getCurrentLocation(), next});
|
||||
} else if (item instanceof InteractionGuildGate || item instanceof InteractionHabboClubGate) {
|
||||
this.setRotation(oldRotation);
|
||||
this.tilesWalked--;
|
||||
@ -297,7 +307,7 @@ public class RoomUnit {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
item.onWalk(this, room, null);
|
||||
item.onWalk(this, room, new Object[]{this.getCurrentLocation(), next});
|
||||
}
|
||||
|
||||
zHeight += item.getZ();
|
||||
@ -391,6 +401,13 @@ public class RoomUnit {
|
||||
|
||||
public void setZ(double z) {
|
||||
this.z = z;
|
||||
|
||||
if (this.room != null) {
|
||||
Bot bot = this.room.getBot(this);
|
||||
if (bot != null) {
|
||||
bot.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInRoom() {
|
||||
@ -532,10 +549,9 @@ public class RoomUnit {
|
||||
|
||||
public void findPath()
|
||||
{
|
||||
if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation)))
|
||||
{
|
||||
|
||||
this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
|
||||
if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) {
|
||||
Deque<RoomTile> path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
|
||||
if (path != null) this.path = path;
|
||||
}
|
||||
}
|
||||
|
||||
@ -700,6 +716,9 @@ public class RoomUnit {
|
||||
public boolean canOverrideTile(RoomTile tile) {
|
||||
if (tile == null || room == null || room.getLayout() == null) return false;
|
||||
|
||||
if (room.getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, room, tile)))
|
||||
return true;
|
||||
|
||||
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
|
||||
return this.overridableTiles.contains(tileIndex);
|
||||
}
|
||||
@ -712,6 +731,8 @@ public class RoomUnit {
|
||||
}
|
||||
|
||||
public void removeOverrideTile(RoomTile tile) {
|
||||
if (room == null || room.getLayout() == null) return;
|
||||
|
||||
int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1;
|
||||
this.overridableTiles.remove(tileIndex);
|
||||
}
|
||||
@ -735,4 +756,44 @@ public class RoomUnit {
|
||||
|
||||
return topItem == null || (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem));
|
||||
}
|
||||
|
||||
public RoomTile getClosestTile(List<RoomTile> tiles) {
|
||||
return tiles.stream().min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null);
|
||||
}
|
||||
|
||||
public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) {
|
||||
if(room == null) return null;
|
||||
|
||||
RoomTile baseTile = room.getLayout().getTile(x, y);
|
||||
|
||||
if (baseTile == null) return null;
|
||||
|
||||
List<Integer> rotations = new ArrayList<>();
|
||||
rotations.add(RoomUserRotation.SOUTH.getValue());
|
||||
rotations.add(RoomUserRotation.NORTH.getValue());
|
||||
rotations.add(RoomUserRotation.EAST.getValue());
|
||||
rotations.add(RoomUserRotation.WEST.getValue());
|
||||
|
||||
if (diagonal) {
|
||||
rotations.add(RoomUserRotation.NORTH_EAST.getValue());
|
||||
rotations.add(RoomUserRotation.NORTH_WEST.getValue());
|
||||
rotations.add(RoomUserRotation.SOUTH_EAST.getValue());
|
||||
rotations.add(RoomUserRotation.SOUTH_WEST.getValue());
|
||||
}
|
||||
|
||||
return this.getClosestTile(
|
||||
rotations.stream()
|
||||
.map(rotation -> room.getLayout().getTileInFront(baseTile, rotation))
|
||||
.filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) || !room.hasHabbosAt(t.x, t.y)))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
public ScheduledFuture getMoveBlockingTask() {
|
||||
return moveBlockingTask;
|
||||
}
|
||||
|
||||
public void setMoveBlockingTask(ScheduledFuture moveBlockingTask) {
|
||||
this.moveBlockingTask = moveBlockingTask;
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,15 @@ package com.eu.habbo.habbohotel.rooms;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.core.Disposable;
|
||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.SoundTrack;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionJukeBox;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxNowPlayingMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxPlayListComposer;
|
||||
@ -18,6 +22,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TraxManager implements Disposable {
|
||||
private final Room room;
|
||||
@ -38,8 +43,18 @@ public class TraxManager implements Disposable {
|
||||
statement.setInt(1, this.room.getId());
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
HabboItem musicDisc = this.room.getHabboItem(set.getInt("item_id"));
|
||||
if (musicDisc instanceof InteractionMusicDisc) {
|
||||
HabboItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id"));
|
||||
|
||||
if (!(musicDisc instanceof InteractionMusicDisc) || musicDisc.getRoomId() != -1) {
|
||||
try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ? AND item_id = ? LIMIT 1")) {
|
||||
stmt.setInt(1, this.room.getId());
|
||||
stmt.setInt(2, musicDisc.getId());
|
||||
stmt.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId());
|
||||
|
||||
if (track != null) {
|
||||
@ -128,19 +143,16 @@ public class TraxManager implements Disposable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addSong(int itemId) {
|
||||
HabboItem musicDisc = this.room.getHabboItem(itemId);
|
||||
|
||||
if (musicDisc instanceof InteractionMusicDisc) {
|
||||
SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId());
|
||||
public void addSong(InteractionMusicDisc musicDisc, Habbo habbo) {
|
||||
SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(musicDisc.getSongId());
|
||||
|
||||
if (track != null) {
|
||||
this.totalLength += track.getLength();
|
||||
this.songs.add((InteractionMusicDisc) musicDisc);
|
||||
this.songs.add(musicDisc);
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_trax_playlist (room_id, item_id) VALUES (?, ?)")) {
|
||||
statement.setInt(1, this.room.getId());
|
||||
statement.setInt(2, itemId);
|
||||
statement.setInt(2, musicDisc.getId());
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
@ -148,9 +160,15 @@ public class TraxManager implements Disposable {
|
||||
}
|
||||
|
||||
this.room.sendComposer(new JukeBoxPlayListComposer(this.songs, this.totalLength).compose());
|
||||
this.room.sendComposer(new JukeBoxMySongsComposer(this.myList()).compose());
|
||||
}
|
||||
|
||||
musicDisc.setRoomId(-1);
|
||||
musicDisc.needsUpdate(true);
|
||||
|
||||
habbo.getInventory().getItemsComponent().removeHabboItem(musicDisc);
|
||||
habbo.getClient().sendResponse(new RemoveHabboItemComposer(musicDisc.getGiftAdjustedId()));
|
||||
}
|
||||
|
||||
this.sendUpdatedSongList();
|
||||
}
|
||||
|
||||
public void removeSong(int itemId) {
|
||||
@ -174,8 +192,34 @@ public class TraxManager implements Disposable {
|
||||
}
|
||||
|
||||
this.room.sendComposer(new JukeBoxPlayListComposer(this.songs, this.totalLength).compose());
|
||||
|
||||
musicDisc.setRoomId(0);
|
||||
musicDisc.needsUpdate(true);
|
||||
|
||||
Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getUserId());
|
||||
|
||||
if (owner != null) {
|
||||
owner.getInventory().getItemsComponent().addItem(musicDisc);
|
||||
|
||||
GameClient client = owner.getClient();
|
||||
if (client != null) {
|
||||
client.sendResponse(new AddHabboItemComposer(musicDisc));
|
||||
client.sendResponse(new InventoryRefreshComposer());
|
||||
}
|
||||
this.room.sendComposer(new JukeBoxMySongsComposer(this.myList()).compose());
|
||||
}
|
||||
}
|
||||
|
||||
this.sendUpdatedSongList();
|
||||
}
|
||||
|
||||
public void sendUpdatedSongList() {
|
||||
this.room.getHabbos().forEach(h -> {
|
||||
GameClient client = h.getClient();
|
||||
|
||||
if (client != null) {
|
||||
client.sendResponse(new JukeBoxMySongsComposer(this.myList(h)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int timePlaying() {
|
||||
@ -208,21 +252,16 @@ public class TraxManager implements Disposable {
|
||||
return trax;
|
||||
}
|
||||
|
||||
public List<InteractionMusicDisc> myList() {
|
||||
List<InteractionMusicDisc> trax = new ArrayList<>();
|
||||
|
||||
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionMusicDisc.class)) {
|
||||
if (!this.songs.contains(item)) {
|
||||
trax.add((InteractionMusicDisc) item);
|
||||
}
|
||||
}
|
||||
|
||||
return trax;
|
||||
public List<InteractionMusicDisc> myList(Habbo habbo) {
|
||||
return habbo.getInventory().getItemsComponent().getItems().valueCollection().stream()
|
||||
.filter(i -> i instanceof InteractionMusicDisc && i.getRoomId() == 0)
|
||||
.map(i -> (InteractionMusicDisc) i)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public InteractionMusicDisc fromItemId(int itemId) {
|
||||
for (InteractionMusicDisc musicDisc : this.songs) {
|
||||
if (musicDisc.getId() == itemId) {
|
||||
if (musicDisc != null && musicDisc.getId() == itemId) {
|
||||
return musicDisc;
|
||||
}
|
||||
}
|
||||
|
@ -378,14 +378,14 @@ public class Habbo implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void mute(int seconds) {
|
||||
public void mute(int seconds, boolean isFlood) {
|
||||
if (!this.hasPermission("acc_no_mute")) {
|
||||
int remaining = this.habboStats.addMuteTime(seconds);
|
||||
this.client.sendResponse(new FloodCounterComposer(remaining));
|
||||
this.client.sendResponse(new MutedWhisperComposer(remaining));
|
||||
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
if (room != null) {
|
||||
if (room != null && !isFlood) {
|
||||
room.sendComposer(new RoomUserIgnoredComposer(this, RoomUserIgnoredComposer.MUTED).compose());
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,8 @@ import com.eu.habbo.habbohotel.items.FurnitureType;
|
||||
import com.eu.habbo.habbohotel.items.IEventTriggers;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
@ -20,20 +18,28 @@ import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
|
||||
import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer;
|
||||
import com.eu.habbo.util.figure.FigureUtil;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.math3.util.Pair;
|
||||
|
||||
import java.awt.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class HabboItem implements Runnable, IEventTriggers {
|
||||
private static Class[] TOGGLING_INTERACTIONS = new Class[]{
|
||||
InteractionGameTimer.class,
|
||||
InteractionWired.class,
|
||||
InteractionWiredHighscore.class,
|
||||
InteractionMultiHeight.class
|
||||
};
|
||||
|
||||
private int id;
|
||||
private int userId;
|
||||
private int roomId;
|
||||
@ -60,7 +66,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
||||
this.y = set.getShort("y");
|
||||
this.z = set.getDouble("z");
|
||||
this.rotation = set.getInt("rot");
|
||||
this.extradata = set.getString("extra_data");
|
||||
this.extradata = set.getString("extra_data").isEmpty() ? "0" : set.getString("extra_data");
|
||||
|
||||
String ltdData = set.getString("limited_data");
|
||||
if (!ltdData.isEmpty()) {
|
||||
@ -79,7 +85,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
||||
this.y = 0;
|
||||
this.z = 0;
|
||||
this.rotation = 0;
|
||||
this.extradata = extradata;
|
||||
this.extradata = extradata.isEmpty() ? "0" : extradata;
|
||||
this.limitedSells = limitedSells;
|
||||
this.limitedStack = limitedStack;
|
||||
}
|
||||
@ -283,10 +289,11 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((this.getBaseItem().getStateCount() > 1 && !(this instanceof InteractionDice)) || Arrays.asList(HabboItem.TOGGLING_INTERACTIONS).contains(this.getClass()) || (objects != null && objects.length == 1 && objects[0].equals("TOGGLE_OVERRIDE"))) {
|
||||
WiredHandler.handle(WiredTriggerType.STATE_CHANGED, client.getHabbo().getRoomUnit(), room, new Object[]{this});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
@ -479,4 +486,30 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
||||
}
|
||||
|
||||
public boolean invalidatesToRoomKick() { return false; }
|
||||
|
||||
public List<RoomTile> getOccupyingTiles(RoomLayout layout) {
|
||||
List<RoomTile> tiles = new ArrayList<>();
|
||||
|
||||
Rectangle rect = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
|
||||
|
||||
for (int i = rect.x; i < rect.x + rect.getWidth(); i++) {
|
||||
for (int j = rect.y; j < rect.y + rect.getHeight(); j++) {
|
||||
tiles.add(layout.getTile((short) i, (short) j));
|
||||
}
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
public RoomTile getOverrideGoalTile(RoomUnit unit, Room room, RoomTile tile) {
|
||||
return tile;
|
||||
}
|
||||
|
||||
public RoomTileState getOverrideTileState(RoomTile tile, Room room) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canOverrideTile(RoomUnit unit, Room room, RoomTile tile) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolBan;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.permissions.Rank;
|
||||
import com.eu.habbo.habbohotel.users.inventory.EffectsComponent;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.catalog.*;
|
||||
import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer;
|
||||
@ -246,7 +247,9 @@ public class HabboManager {
|
||||
Rank oldRank = habbo.getHabboInfo().getRank();
|
||||
if (!oldRank.getBadge().isEmpty()) {
|
||||
habbo.deleteBadge(habbo.getInventory().getBadgesComponent().getBadge(oldRank.getBadge()));
|
||||
//BadgesComponent.deleteBadge(userId, oldRank.getBadge()); // unnecessary as Habbo.deleteBadge does this
|
||||
}
|
||||
if(oldRank.getRoomEffect() > 0) {
|
||||
habbo.getInventory().getEffectsComponent().effects.remove(oldRank.getRoomEffect());
|
||||
}
|
||||
|
||||
habbo.getHabboInfo().setRank(newRank);
|
||||
@ -255,6 +258,10 @@ public class HabboManager {
|
||||
habbo.addBadge(newRank.getBadge());
|
||||
}
|
||||
|
||||
if(newRank.getRoomEffect() > 0) {
|
||||
habbo.getInventory().getEffectsComponent().createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect());
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new UserPermissionsComposer(habbo));
|
||||
habbo.getClient().sendResponse(new UserPerksComposer(habbo));
|
||||
|
||||
|
@ -14,12 +14,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class EffectsComponent {
|
||||
public final THashMap<Integer, HabboEffect> effects;
|
||||
public final THashMap<Integer, HabboEffect> effects = new THashMap<>();
|
||||
public final Habbo habbo;
|
||||
public int activatedEffect = 0;
|
||||
|
||||
public EffectsComponent(Habbo habbo) {
|
||||
this.effects = new THashMap<>();
|
||||
this.habbo = habbo;
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_effects WHERE user_id = ?")) {
|
||||
statement.setInt(1, habbo.getHabboInfo().getId());
|
||||
@ -31,6 +30,8 @@ public class EffectsComponent {
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
if(habbo.getHabboInfo().getRank().getRoomEffect() > 0)
|
||||
this.createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect());
|
||||
}
|
||||
|
||||
public HabboEffect createEffect(int effectId) {
|
||||
@ -58,6 +59,17 @@ public class EffectsComponent {
|
||||
return effect;
|
||||
}
|
||||
|
||||
public HabboEffect createRankEffect(int effectId) {
|
||||
HabboEffect rankEffect = new HabboEffect(effectId, habbo.getHabboInfo().getId());
|
||||
rankEffect.duration = 0;
|
||||
rankEffect.isRankEnable = true;
|
||||
rankEffect.activationTimestamp = Emulator.getIntUnixTimestamp();
|
||||
rankEffect.enabled = true;
|
||||
this.effects.put(effectId, rankEffect);
|
||||
this.activatedEffect = effectId; // enabled by default
|
||||
return rankEffect;
|
||||
}
|
||||
|
||||
public void addEffect(HabboEffect effect) {
|
||||
this.effects.put(effect.effect, effect);
|
||||
|
||||
@ -67,9 +79,8 @@ public class EffectsComponent {
|
||||
public void dispose() {
|
||||
synchronized (this.effects) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET duration = ?, activation_timestamp = ?, total = ? WHERE user_id = ? AND effect = ?")) {
|
||||
this.effects.forEachValue(new TObjectProcedure<HabboEffect>() {
|
||||
@Override
|
||||
public boolean execute(HabboEffect effect) {
|
||||
this.effects.forEachValue(effect -> {
|
||||
if(!effect.isRankEnable) {
|
||||
try {
|
||||
statement.setInt(1, effect.duration);
|
||||
statement.setInt(2, effect.activationTimestamp);
|
||||
@ -80,9 +91,8 @@ public class EffectsComponent {
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
statement.executeBatch();
|
||||
@ -145,6 +155,7 @@ public class EffectsComponent {
|
||||
public int activationTimestamp = -1;
|
||||
public int total = 1;
|
||||
public boolean enabled = false;
|
||||
public boolean isRankEnable = false;
|
||||
|
||||
public HabboEffect(ResultSet set) throws SQLException {
|
||||
this.effect = set.getInt("effect");
|
||||
|
@ -139,11 +139,10 @@ public class WiredHandler {
|
||||
}
|
||||
|
||||
for (InteractionWiredCondition condition : conditions) {
|
||||
if ((condition.operator() == WiredConditionOperator.OR && matchedConditions.contains(condition.getType())) ||
|
||||
(condition.operator() == WiredConditionOperator.AND && condition.execute(roomUnit, room, stuff))) {
|
||||
condition.activateBox(room);
|
||||
} else {
|
||||
if (!Emulator.getPluginManager().fireEvent(new WiredConditionFailedEvent(room, roomUnit, trigger, condition)).isCancelled())
|
||||
if (!((condition.operator() == WiredConditionOperator.OR && matchedConditions.contains(condition.getType())) ||
|
||||
(condition.operator() == WiredConditionOperator.AND && condition.execute(roomUnit, room, stuff))) &&
|
||||
!Emulator.getPluginManager().fireEvent(new WiredConditionFailedEvent(room, roomUnit, trigger, condition)).isCancelled()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -194,9 +193,7 @@ public class WiredHandler {
|
||||
if (effect != null && effect.canExecute(millis)) {
|
||||
executed = true;
|
||||
if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) {
|
||||
Emulator.getThreading().run(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Emulator.getThreading().run(() -> {
|
||||
if (room.isLoaded()) {
|
||||
try {
|
||||
if (!effect.execute(roomUnit, room, stuff)) return;
|
||||
@ -207,7 +204,6 @@ public class WiredHandler {
|
||||
|
||||
effect.activateBox(room);
|
||||
}
|
||||
}
|
||||
}, effect.getDelay() * 500);
|
||||
}
|
||||
}
|
||||
@ -415,16 +411,16 @@ public class WiredHandler {
|
||||
}
|
||||
|
||||
public static void resetTimers(Room room) {
|
||||
if (!room.isLoaded())
|
||||
if (!room.isLoaded() || room.getRoomSpecialTypes() == null)
|
||||
return;
|
||||
|
||||
THashSet<InteractionWiredTrigger> triggers = room.getRoomSpecialTypes().getTriggers(WiredTriggerType.AT_GIVEN_TIME);
|
||||
room.getRoomSpecialTypes().getTriggers().forEach(t -> {
|
||||
if (t == null) return;
|
||||
|
||||
if (triggers != null) {
|
||||
for (InteractionWiredTrigger trigger : triggers) {
|
||||
((WiredTriggerReset) trigger).resetTimer();
|
||||
}
|
||||
if (t.getType() == WiredTriggerType.AT_GIVEN_TIME || t.getType() == WiredTriggerType.PERIODICALLY || t.getType() == WiredTriggerType.PERIODICALLY_LONG) {
|
||||
((WiredTriggerReset) t).resetTimer();
|
||||
}
|
||||
});
|
||||
|
||||
room.setLastTimerReset(Emulator.getIntUnixTimestamp());
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class WiredHighscoreManager {
|
||||
public List<WiredHighscoreRow> getHighscoreRowsForItem(int itemId, WiredHighscoreClearType clearType, WiredHighscoreScoreType scoreType) {
|
||||
if (!this.data.containsKey(itemId)) return null;
|
||||
|
||||
Stream<WiredHighscoreRow> highscores = this.data.get(itemId).stream()
|
||||
Stream<WiredHighscoreRow> highscores = new ArrayList<>(this.data.get(itemId)).stream()
|
||||
.filter(entry -> this.timeMatchesEntry(entry, clearType) && (scoreType != WiredHighscoreScoreType.MOSTWIN || entry.isWin()))
|
||||
.map(entry -> new WiredHighscoreRow(
|
||||
entry.getUserIds().stream()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user