mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Merge branch 'dev' into fix/wired-bot-talk
This commit is contained in:
commit
ca26e7cf37
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
FROM maven:latest AS builder
|
||||||
|
|
||||||
|
# Copy the Emulator sources to the container
|
||||||
|
COPY . .
|
||||||
|
# Package it
|
||||||
|
RUN mvn package && mv /target/Habbo*-with-dependencies.jar /target/Habbo.jar
|
||||||
|
|
||||||
|
# Use Java 8 for running
|
||||||
|
FROM java:8 AS runner
|
||||||
|
|
||||||
|
# Copy the generated source
|
||||||
|
COPY --from=builder /target/Habbo.jar /
|
||||||
|
|
||||||
|
# Save the script to wait for the database, among running the Arcturus Emulator
|
||||||
|
RUN echo "#!/bin/bash \n java -Dfile.encoding=UTF-8 -jar /Habbo.jar" > /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
# Run the Emulator with Java
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
@ -101,9 +101,13 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscr
|
|||||||
|
|
||||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('subscriptions.hc.payday.message', 'Woohoo HC Payday has arrived! You have received %amount% credits to your purse. Enjoy!');
|
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('subscriptions.hc.payday.message', 'Woohoo HC Payday has arrived! You have received %amount% credits to your purse. Enjoy!');
|
||||||
|
|
||||||
|
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.roomuser.idle.not_dancing.ignore.wired_idle', '0');
|
||||||
|
|
||||||
-- OPTIONAL HC MIGRATION
|
-- OPTIONAL HC MIGRATION
|
||||||
-- INSERT INTO users_subscriptions SELECT NULL, user_id, 'HABBO_CLUB' as `subscription_type`, UNIX_TIMESTAMP() AS `timestamp_start`, (club_expire_timestamp - UNIX_TIMESTAMP()) AS `duration`, 1 AS `active` FROM users_settings WHERE club_expire_timestamp > UNIX_TIMESTAMP();
|
-- INSERT INTO users_subscriptions SELECT NULL, user_id, 'HABBO_CLUB' as `subscription_type`, UNIX_TIMESTAMP() AS `timestamp_start`, (club_expire_timestamp - UNIX_TIMESTAMP()) AS `duration`, 1 AS `active` FROM users_settings WHERE club_expire_timestamp > UNIX_TIMESTAMP();
|
||||||
|
|
||||||
|
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.rooms.deco_hosting', '1');
|
||||||
|
|
||||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('easter_eggs.enabled', '1');
|
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('easter_eggs.enabled', '1');
|
||||||
|
|
||||||
ALTER TABLE `bots`
|
ALTER TABLE `bots`
|
||||||
@ -112,3 +116,13 @@ ADD COLUMN `bubble_id` int(3) NULL DEFAULT 31 AFTER `effect`;
|
|||||||
-- Permissions to see tent chat
|
-- Permissions to see tent chat
|
||||||
ALTER TABLE `permissions` ADD `acc_see_tentchat` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_see_whispers`;
|
ALTER TABLE `permissions` ADD `acc_see_tentchat` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_see_whispers`;
|
||||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', 'Tent');
|
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', 'Tent');
|
||||||
|
|
||||||
|
-- Roombadge command
|
||||||
|
ALTER TABLE `permissions` ADD `cmd_roombadge` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_massbadge`;
|
||||||
|
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_roombadge.no_badge', 'No badge specified!');
|
||||||
|
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_roombadge', 'roombadge');
|
||||||
|
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_roombadge', ':roombadge <badge>');
|
||||||
|
|
||||||
|
-- Making items.wired_data column bigger since wired data is saved as JSON now
|
||||||
|
ALTER TABLE `items` MODIFY COLUMN `wired_data` varchar(10000);
|
||||||
|
|
||||||
|
@ -3,7 +3,10 @@ package com.eu.habbo.habbohotel.commands;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.catalog.CatalogManager;
|
import com.eu.habbo.habbohotel.catalog.CatalogManager;
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboManager;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
@ -11,9 +14,12 @@ public class AboutCommand extends Command {
|
|||||||
public AboutCommand() {
|
public AboutCommand() {
|
||||||
super(null, new String[]{"about", "info", "online", "server"});
|
super(null, new String[]{"about", "info", "online", "server"});
|
||||||
}
|
}
|
||||||
|
public static String credits = "Arcturus Morningstar is an opensource project based on Arcturus By TheGeneral \n" +
|
||||||
|
"The Following people have all contributed to this emulator:\n" +
|
||||||
|
" TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Quadral \n Harmony\n Swirny\n ArpyAge\n Mikkel\n Rodolfo\n Rasmus\n Kitt Mustang\n Snaiker\n nttzx\n necmi\n Dome\n Jose Flores\n Cam\n Oliver\n Narzo\n Tenshie\n MartenM\n Ridge\n SenpaiDipper";
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(GameClient gameClient, String[] params) {
|
public boolean handle(GameClient gameClient, String[] params) {
|
||||||
|
|
||||||
Emulator.getRuntime().gc();
|
Emulator.getRuntime().gc();
|
||||||
|
|
||||||
int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted();
|
int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted();
|
||||||
@ -42,9 +48,8 @@ public class AboutCommand extends Command {
|
|||||||
|
|
||||||
"<b>Thanks for using Arcturus. Report issues on the forums. http://arcturus.wf \r\r" +
|
"<b>Thanks for using Arcturus. Report issues on the forums. http://arcturus.wf \r\r" +
|
||||||
" - The General";
|
" - The General";
|
||||||
|
|
||||||
gameClient.getHabbo().alert(message);
|
gameClient.getHabbo().alert(message);
|
||||||
|
gameClient.sendResponse(new MessagesForYouComposer(Collections.singletonList(credits)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,6 +217,7 @@ public class CommandHandler {
|
|||||||
addCommand(new LayCommand());
|
addCommand(new LayCommand());
|
||||||
addCommand(new MachineBanCommand());
|
addCommand(new MachineBanCommand());
|
||||||
addCommand(new MassBadgeCommand());
|
addCommand(new MassBadgeCommand());
|
||||||
|
addCommand(new RoomBadgeCommand());
|
||||||
addCommand(new MassCreditsCommand());
|
addCommand(new MassCreditsCommand());
|
||||||
addCommand(new MassGiftCommand());
|
addCommand(new MassGiftCommand());
|
||||||
addCommand(new MassPixelsCommand());
|
addCommand(new MassPixelsCommand());
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.eu.habbo.habbohotel.commands;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||||
|
import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
|
||||||
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||||
|
import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer;
|
||||||
|
import gnu.trove.map.hash.THashMap;
|
||||||
|
|
||||||
|
public class RoomBadgeCommand extends Command {
|
||||||
|
public RoomBadgeCommand() {
|
||||||
|
super("cmd_roombadge", Emulator.getTexts().getValue("commands.keys.cmd_roombadge").split(";"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||||
|
if (gameClient == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (params.length == 2) {
|
||||||
|
String badge;
|
||||||
|
|
||||||
|
badge = params[1];
|
||||||
|
|
||||||
|
if (!badge.isEmpty()) {
|
||||||
|
THashMap<String, String> keys = new THashMap<>();
|
||||||
|
keys.put("display", "BUBBLE");
|
||||||
|
keys.put("image", "${image.library.url}album1584/" + badge + ".gif");
|
||||||
|
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
|
||||||
|
ServerMessage message = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
|
||||||
|
|
||||||
|
for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getHabbos()) {
|
||||||
|
if (habbo.isOnline()) {
|
||||||
|
if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
|
||||||
|
HabboBadge b = BadgesComponent.createBadge(badge, habbo);
|
||||||
|
|
||||||
|
habbo.getClient().sendResponse(new AddUserBadgeComposer(b));
|
||||||
|
habbo.getClient().sendResponse(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roombadge.no_badge"), RoomChatMessageBubbles.ALERT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -45,7 +45,7 @@ public class UserInfoCommand extends Command {
|
|||||||
Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" +
|
Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" +
|
||||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_MAIL, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") +
|
((habbo.getRank().hasPermission(Permission.ACC_HIDE_MAIL, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") +
|
||||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
|
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
|
||||||
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getClient().getChannel().remoteAddress().toString() + "\r") +
|
((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getHabboInfo().getIpLogin() + "\r") +
|
||||||
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : ""));
|
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : ""));
|
||||||
|
|
||||||
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId());
|
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId());
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions;
|
package com.eu.habbo.habbohotel.items.interactions;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.bots.Bot;
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
@ -7,6 +8,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUnitType;
|
import com.eu.habbo.habbohotel.rooms.RoomUnitType;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -32,7 +35,11 @@ public class InteractionEffectTile extends InteractionPressurePlate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||||
super.onWalkOff(roomUnit, room, objects);
|
Emulator.getThreading().run(() -> updateState(room), 100);
|
||||||
|
|
||||||
|
if(objects != null && objects.length > 0) {
|
||||||
|
WiredHandler.handle(WiredTriggerType.WALKS_OFF_FURNI, roomUnit, room, new Object[]{this});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,14 +5,28 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
|||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||||
|
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InteractionFireworks extends InteractionDefault {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionFireworks.class);
|
||||||
|
|
||||||
|
private static final String STATE_EMPTY = "0"; // Not used since the removal of pixels
|
||||||
|
private static final String STATE_CHARGED = "1";
|
||||||
|
private static final String STATE_EXPLOSION = "2";
|
||||||
|
|
||||||
public class InteractionFireworks extends HabboItem {
|
|
||||||
public InteractionFireworks(ResultSet set, Item baseItem) throws SQLException {
|
public InteractionFireworks(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
}
|
}
|
||||||
@ -26,35 +40,103 @@ public class InteractionFireworks extends HabboItem {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean isWalkable() {
|
* Checked in Habbo on 2021-01-03
|
||||||
return this.getBaseItem().allowWalk();
|
* - Fireworks should be charged to be able to detonate them
|
||||||
}
|
* - Habbos with Rights can detonate fireworks from anywhere in a room
|
||||||
|
* - Habbos without rights have to walk to an adjecent tile to be able to detonate (see Interaction Switch)
|
||||||
@Override
|
* - Wired can always detonate fireworks
|
||||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
*/
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serializeExtradata(ServerMessage serverMessage) {
|
|
||||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
|
||||||
serverMessage.appendString(this.getExtradata());
|
|
||||||
super.serializeExtradata(serverMessage); //Design flaw ;(
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||||
|
if (room == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Wireds can always detonate fireworks if charged
|
||||||
|
if (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE) {
|
||||||
|
if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) {
|
||||||
super.onClick(client, room, objects);
|
super.onClick(client, room, objects);
|
||||||
|
|
||||||
if (client != null && this.getExtradata().equalsIgnoreCase("2")) //2 explodes I think (0 = empty, 1 = charged, 2 = effect)
|
if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) {
|
||||||
|
this.reCharge(room);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Habbos without rights have to walk to an adjecent tile to be able to detonate the fireworks
|
||||||
|
if (!this.canToggle(client.getHabbo(), room)) {
|
||||||
|
RoomTile closestTile = null;
|
||||||
|
for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
|
||||||
|
if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) {
|
||||||
|
closestTile = tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
|
||||||
|
List<Runnable> onSuccess = new ArrayList<>();
|
||||||
|
onSuccess.add(() -> {
|
||||||
|
try {
|
||||||
|
this.onClick(client, room, objects);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
|
||||||
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) {
|
||||||
|
super.onClick(client, room, objects);
|
||||||
|
|
||||||
|
if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION))
|
||||||
{
|
{
|
||||||
|
this.reCharge(room);
|
||||||
AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger"));
|
AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean allowWiredResetState() {
|
public boolean allowWiredResetState() {
|
||||||
return true;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlace(Room room) {
|
||||||
|
super.onPlace(room);
|
||||||
|
this.setExtradata(STATE_CHARGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canToggle(Habbo habbo, Room room) {
|
||||||
|
return room.hasRights(habbo) || RoomLayout.tilesAdjecent(
|
||||||
|
room.getLayout().getTile(this.getX(), this.getY()),
|
||||||
|
habbo.getRoomUnit().getCurrentLocation()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reCharge(Room room) {
|
||||||
|
// Default = 5000, Nuclear Firework should have 10000 in its custom params according to Habbo
|
||||||
|
int explodeDuration = 5000;
|
||||||
|
if (!this.getBaseItem().getCustomParams().isEmpty()) {
|
||||||
|
try {
|
||||||
|
explodeDuration = Integer.parseInt(this.getBaseItem().getCustomParams());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
LOGGER.error("Incorrect customparams (" + this.getBaseItem().getCustomParams() + ") for base item ID (" + this.getBaseItem().getId() + ") of type (" + this.getBaseItem().getName() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
this.setExtradata(STATE_CHARGED);
|
||||||
|
this.needsUpdate(true);
|
||||||
|
room.updateItemState(this);
|
||||||
|
}, explodeDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -64,25 +65,46 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.startDate + "\t" + this.endDate;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.startDate,
|
||||||
|
this.endDate
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String[] data = set.getString("wired_data").split("\t");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.startDate = data.startDate;
|
||||||
|
this.endDate = data.endDate;
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split("\t");
|
||||||
|
|
||||||
if (data.length == 2) {
|
if (data.length == 2) {
|
||||||
try {
|
try {
|
||||||
this.startDate = Integer.valueOf(data[0]);
|
this.startDate = Integer.parseInt(data[0]);
|
||||||
this.endDate = Integer.valueOf(data[1]);
|
this.endDate = Integer.parseInt(data[1]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
this.startDate = 0;
|
this.startDate = 0;
|
||||||
this.endDate = 0;
|
this.endDate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int startDate;
|
||||||
|
int endDate;
|
||||||
|
|
||||||
|
public JsonData(int startDate, int endDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI;
|
public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI;
|
||||||
@ -58,18 +60,30 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
this.all,
|
||||||
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items)
|
));
|
||||||
data.append(item.getId()).append(";");
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String[] data = set.getString("wired_data").split(":");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.all = data.all;
|
||||||
|
|
||||||
|
for(int id : data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(":");
|
||||||
|
|
||||||
if (data.length >= 1) {
|
if (data.length >= 1) {
|
||||||
this.all = (data[0].equals("1"));
|
this.all = (data[0].equals("1"));
|
||||||
@ -78,7 +92,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
|||||||
String[] items = data[1].split(";");
|
String[] items = data[1].split(";");
|
||||||
|
|
||||||
for (String s : items) {
|
for (String s : items) {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -86,6 +100,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -166,4 +181,14 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
|||||||
this.items.remove(item);
|
this.items.remove(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
boolean all;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(boolean all, List<Integer> itemIds) {
|
||||||
|
this.all = all;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,13 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
|||||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import gnu.trove.map.hash.THashMap;
|
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
|
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
|
||||||
@ -66,21 +66,30 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
this.all,
|
||||||
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
data.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
String[] data = set.getString("wired_data").split(":");
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.all = data.all;
|
||||||
|
|
||||||
|
for(int id : data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(":");
|
||||||
|
|
||||||
if (data.length >= 1) {
|
if (data.length >= 1) {
|
||||||
this.all = (data[0].equals("1"));
|
this.all = (data[0].equals("1"));
|
||||||
@ -89,7 +98,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
String[] items = data[1].split(";");
|
String[] items = data[1].split(";");
|
||||||
|
|
||||||
for (String s : items) {
|
for (String s : items) {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -97,6 +106,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WiredConditionType getType() {
|
public WiredConditionType getType() {
|
||||||
@ -170,4 +180,14 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
this.items.remove(item);
|
this.items.remove(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
boolean all;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(boolean all, List<Integer> itemIds) {
|
||||||
|
this.all = all;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.STUFF_IS;
|
public static final WiredConditionType type = WiredConditionType.STUFF_IS;
|
||||||
@ -55,23 +57,37 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
StringBuilder data = new StringBuilder();
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
|
));
|
||||||
for (HabboItem item : this.items)
|
|
||||||
data.append(item.getId()).append(";");
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
String[] data = set.getString("wired_data").split(";");
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
for (String s : data)
|
for(int id : data.itemIds) {
|
||||||
this.items.add(room.getHabboItem(Integer.valueOf(s)));
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(";");
|
||||||
|
|
||||||
|
for (String s : data) {
|
||||||
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -138,4 +154,12 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
|||||||
this.items.remove(item);
|
this.items.remove(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(List<Integer> itemIds) {
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -34,15 +35,26 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.lowerLimit + ":" + this.upperLimit;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.lowerLimit,
|
||||||
|
this.upperLimit
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String[] data = set.getString("wired_data").split(":");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
this.lowerLimit = Integer.valueOf(data[0]);
|
if (wiredData.startsWith("{")) {
|
||||||
this.upperLimit = Integer.valueOf(data[1]);
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.lowerLimit = data.lowerLimit;
|
||||||
|
this.upperLimit = data.upperLimit;
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(":");
|
||||||
|
|
||||||
|
this.lowerLimit = Integer.parseInt(data[0]);
|
||||||
|
this.upperLimit = Integer.parseInt(data[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,4 +94,14 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int lowerLimit;
|
||||||
|
int upperLimit;
|
||||||
|
|
||||||
|
public JsonData(int lowerLimit, int upperLimit) {
|
||||||
|
this.lowerLimit = lowerLimit;
|
||||||
|
this.upperLimit = upperLimit;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -32,12 +33,21 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.effectId + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.effectId
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.effectId = Integer.valueOf(set.getString("wired_data"));
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.effectId = data.effectId;
|
||||||
|
} else {
|
||||||
|
this.effectId = Integer.parseInt(wiredData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,4 +83,12 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int effectId;
|
||||||
|
|
||||||
|
public JsonData(int effectId) {
|
||||||
|
this.effectId = effectId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -66,13 +67,22 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.handItem + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.handItem
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
try {
|
try {
|
||||||
this.handItem = Integer.valueOf(set.getString("wired_data"));
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.handItem = data.handItemId;
|
||||||
|
} else {
|
||||||
|
this.handItem = Integer.parseInt(wiredData);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Caught exception", e);
|
LOGGER.error("Caught exception", e);
|
||||||
}
|
}
|
||||||
@ -82,4 +92,12 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
|
|||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
this.handItem = 0;
|
this.handItem = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int handItemId;
|
||||||
|
|
||||||
|
public JsonData(int handItemId) {
|
||||||
|
this.handItemId = handItemId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
|||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -44,12 +45,21 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.badge;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.badge
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.badge = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.badge = data.badge;
|
||||||
|
} else {
|
||||||
|
this.badge = wiredData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -85,4 +95,12 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
String badge;
|
||||||
|
|
||||||
|
public JsonData(String badge) {
|
||||||
|
this.badge = badge;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -32,16 +33,23 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.cycles + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.cycles
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String data = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!data.equals(""))
|
if (wiredData.startsWith("{")) {
|
||||||
this.cycles = Integer.valueOf(data);
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.cycles = data.cycles;
|
||||||
|
} else {
|
||||||
|
if (!wiredData.equals(""))
|
||||||
|
this.cycles = Integer.parseInt(wiredData);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,4 +88,12 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int cycles;
|
||||||
|
|
||||||
|
public JsonData(int cycles) {
|
||||||
|
this.cycles = cycles;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
@ -15,8 +16,10 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class WiredConditionMatchStatePosition extends InteractionWiredCondition {
|
public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings {
|
||||||
public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT;
|
public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT;
|
||||||
|
|
||||||
private THashSet<WiredMatchFurniSetting> settings;
|
private THashSet<WiredMatchFurniSetting> settings;
|
||||||
@ -138,25 +141,28 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder data = new StringBuilder(this.settings.size() + ":");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.state,
|
||||||
if (this.settings.isEmpty()) {
|
this.position,
|
||||||
data.append("\t;");
|
this.direction,
|
||||||
} else {
|
new ArrayList<>(this.settings)
|
||||||
for (WiredMatchFurniSetting item : this.settings)
|
));
|
||||||
data.append(item.toString()).append(";");
|
|
||||||
}
|
|
||||||
|
|
||||||
data.append(":").append(this.state ? 1 : 0).append(":").append(this.direction ? 1 : 0).append(":").append(this.position ? 1 : 0);
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String[] data = set.getString("wired_data").split(":");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
int itemCount = Integer.valueOf(data[0]);
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.state = data.state;
|
||||||
|
this.position = data.position;
|
||||||
|
this.direction = data.direction;
|
||||||
|
this.settings.addAll(data.settings);
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(":");
|
||||||
|
|
||||||
|
int itemCount = Integer.parseInt(data[0]);
|
||||||
|
|
||||||
String[] items = data[1].split(";");
|
String[] items = data[1].split(";");
|
||||||
|
|
||||||
@ -164,13 +170,14 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
|||||||
String[] stuff = items[i].split("-");
|
String[] stuff = items[i].split("-");
|
||||||
|
|
||||||
if (stuff.length >= 5)
|
if (stuff.length >= 5)
|
||||||
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
|
this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4])));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state = data[2].equals("1");
|
this.state = data[2].equals("1");
|
||||||
this.direction = data[3].equals("1");
|
this.direction = data[3].equals("1");
|
||||||
this.position = data[4].equals("1");
|
this.position = data[4].equals("1");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -198,4 +205,38 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public THashSet<WiredMatchFurniSetting> getMatchFurniSettings() {
|
||||||
|
return this.settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldMatchState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldMatchRotation() {
|
||||||
|
return this.direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldMatchPosition() {
|
||||||
|
return this.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
boolean state;
|
||||||
|
boolean position;
|
||||||
|
boolean direction;
|
||||||
|
List<WiredMatchFurniSetting> settings;
|
||||||
|
|
||||||
|
public JsonData(boolean state, boolean position, boolean direction, List<WiredMatchFurniSetting> settings) {
|
||||||
|
this.state = state;
|
||||||
|
this.position = position;
|
||||||
|
this.direction = direction;
|
||||||
|
this.settings = settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -32,16 +33,23 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.cycles + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.cycles
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String data = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!data.equals(""))
|
if (wiredData.startsWith("{")) {
|
||||||
this.cycles = Integer.valueOf(data);
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.cycles = data.cycles;
|
||||||
|
} else {
|
||||||
|
if (!wiredData.equals(""))
|
||||||
|
this.cycles = Integer.parseInt(wiredData);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,4 +88,12 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int cycles;
|
||||||
|
|
||||||
|
public JsonData(int cycles) {
|
||||||
|
this.cycles = cycles;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI;
|
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI;
|
||||||
@ -59,20 +61,30 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
this.all,
|
||||||
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items)
|
));
|
||||||
data.append(item.getId()).append(";");
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
String[] data = set.getString("wired_data").split(":");
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.all = data.all;
|
||||||
|
|
||||||
|
for (int id : data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(":");
|
||||||
|
|
||||||
if (data.length >= 1) {
|
if (data.length >= 1) {
|
||||||
this.all = (data[0].equals("1"));
|
this.all = (data[0].equals("1"));
|
||||||
@ -89,6 +101,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -175,4 +188,14 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
|||||||
//return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR;
|
//return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR;
|
||||||
return WiredConditionOperator.AND;
|
return WiredConditionOperator.AND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
boolean all;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(boolean all, List<Integer> itemIds) {
|
||||||
|
this.all = all;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,13 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
|||||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import gnu.trove.map.hash.THashMap;
|
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO;
|
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO;
|
||||||
@ -66,21 +66,30 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
this.all,
|
||||||
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
data.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
String[] data = set.getString("wired_data").split(":");
|
if (wiredData.startsWith("{")) {
|
||||||
|
WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class);
|
||||||
|
this.all = data.all;
|
||||||
|
|
||||||
|
for(int id : data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(":");
|
||||||
|
|
||||||
if (data.length >= 1) {
|
if (data.length >= 1) {
|
||||||
this.all = (data[0].equals("1"));
|
this.all = (data[0].equals("1"));
|
||||||
@ -89,7 +98,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
String[] items = data[1].split(";");
|
String[] items = data[1].split(";");
|
||||||
|
|
||||||
for (String s : items) {
|
for (String s : items) {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -97,6 +106,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WiredConditionType getType() {
|
public WiredConditionType getType() {
|
||||||
@ -169,4 +179,14 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
|||||||
this.items.remove(item);
|
this.items.remove(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
boolean all;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(boolean all, List<Integer> itemIds) {
|
||||||
|
this.all = all;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS;
|
public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS;
|
||||||
@ -50,23 +52,37 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
StringBuilder data = new StringBuilder();
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
|
));
|
||||||
for (HabboItem item : this.items)
|
|
||||||
data.append(item.getId()).append(";");
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
|
||||||
|
|
||||||
|
for(int id : data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
String[] data = set.getString("wired_data").split(";");
|
String[] data = set.getString("wired_data").split(";");
|
||||||
|
|
||||||
for (String s : data)
|
for (String s : data) {
|
||||||
this.items.add(room.getHabboItem(Integer.valueOf(s)));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -138,4 +154,12 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
|||||||
this.items.remove(item);
|
this.items.remove(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(List<Integer> itemIds) {
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -34,14 +35,25 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.lowerLimit + ":" + this.upperLimit;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.lowerLimit,
|
||||||
|
this.upperLimit
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String[] data = set.getString("wired_data").split(":");
|
String wiredData = set.getString("wired_data");
|
||||||
this.lowerLimit = Integer.valueOf(data[0]);
|
|
||||||
this.upperLimit = Integer.valueOf(data[1]);
|
if (wiredData.startsWith("{")) {
|
||||||
|
WiredConditionHabboCount.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionHabboCount.JsonData.class);
|
||||||
|
this.lowerLimit = data.lowerLimit;
|
||||||
|
this.upperLimit = data.upperLimit;
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(":");
|
||||||
|
this.lowerLimit = Integer.parseInt(data[0]);
|
||||||
|
this.upperLimit = Integer.parseInt(data[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,4 +93,14 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int lowerLimit;
|
||||||
|
int upperLimit;
|
||||||
|
|
||||||
|
public JsonData(int lowerLimit, int upperLimit) {
|
||||||
|
this.lowerLimit = lowerLimit;
|
||||||
|
this.upperLimit = upperLimit;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -32,12 +33,21 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.effectId + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.effectId
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.effectId = Integer.valueOf(set.getString("wired_data"));
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.effectId = data.effectId;
|
||||||
|
} else {
|
||||||
|
this.effectId = Integer.parseInt(wiredData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,4 +83,12 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int effectId;
|
||||||
|
|
||||||
|
public JsonData(int effectId) {
|
||||||
|
this.effectId = effectId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
|||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -45,12 +46,21 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.badge;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.badge
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.badge = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.badge = data.badge;
|
||||||
|
} else {
|
||||||
|
this.badge = wiredData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,4 +96,12 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
String badge;
|
||||||
|
|
||||||
|
public JsonData(String badge) {
|
||||||
|
this.badge = badge;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -39,16 +40,23 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.teamColor.type + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.teamColor
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String data = set.getString("wired_data");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!data.equals(""))
|
String wiredData = set.getString("wired_data");
|
||||||
this.teamColor = GameTeamColors.values()[Integer.valueOf(data)];
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.teamColor = data.teamColor;
|
||||||
|
} else {
|
||||||
|
if (!wiredData.equals(""))
|
||||||
|
this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)];
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.teamColor = GameTeamColors.RED;
|
this.teamColor = GameTeamColors.RED;
|
||||||
}
|
}
|
||||||
@ -88,4 +96,12 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
GameTeamColors teamColor;
|
||||||
|
|
||||||
|
public JsonData(GameTeamColors teamColor) {
|
||||||
|
this.teamColor = teamColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
@ -15,8 +16,10 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition {
|
public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings {
|
||||||
public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT;
|
public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT;
|
||||||
|
|
||||||
private THashSet<WiredMatchFurniSetting> settings;
|
private THashSet<WiredMatchFurniSetting> settings;
|
||||||
@ -68,25 +71,28 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder data = new StringBuilder(this.settings.size() + ":");
|
return WiredHandler.getGsonBuilder().create().toJson(new WiredConditionMatchStatePosition.JsonData(
|
||||||
|
this.state,
|
||||||
if (this.settings.isEmpty()) {
|
this.position,
|
||||||
data.append("\t;");
|
this.rotation,
|
||||||
} else {
|
new ArrayList<>(this.settings)
|
||||||
for (WiredMatchFurniSetting item : this.settings)
|
));
|
||||||
data.append(item.toString()).append(";");
|
|
||||||
}
|
|
||||||
|
|
||||||
data.append(":").append(this.state ? 1 : 0).append(":").append(this.rotation ? 1 : 0).append(":").append(this.position ? 1 : 0);
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String[] data = set.getString("wired_data").split(":");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
int itemCount = Integer.valueOf(data[0]);
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.state = data.state;
|
||||||
|
this.position = data.position;
|
||||||
|
this.rotation = data.direction;
|
||||||
|
this.settings.addAll(data.settings);
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(":");
|
||||||
|
|
||||||
|
int itemCount = Integer.parseInt(data[0]);
|
||||||
|
|
||||||
String[] items = data[1].split(";");
|
String[] items = data[1].split(";");
|
||||||
|
|
||||||
@ -94,13 +100,14 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
String[] stuff = items[i].split("-");
|
String[] stuff = items[i].split("-");
|
||||||
|
|
||||||
if (stuff.length >= 5)
|
if (stuff.length >= 5)
|
||||||
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
|
this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4])));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state = data[2].equals("1");
|
this.state = data[2].equals("1");
|
||||||
this.rotation = data[3].equals("1");
|
this.rotation = data[3].equals("1");
|
||||||
this.position = data[4].equals("1");
|
this.position = data[4].equals("1");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -189,4 +196,38 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public THashSet<WiredMatchFurniSetting> getMatchFurniSettings() {
|
||||||
|
return this.settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldMatchState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldMatchRotation() {
|
||||||
|
return this.rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldMatchPosition() {
|
||||||
|
return this.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
boolean state;
|
||||||
|
boolean position;
|
||||||
|
boolean direction;
|
||||||
|
List<WiredMatchFurniSetting> settings;
|
||||||
|
|
||||||
|
public JsonData(boolean state, boolean position, boolean direction, List<WiredMatchFurniSetting> settings) {
|
||||||
|
this.state = state;
|
||||||
|
this.position = position;
|
||||||
|
this.direction = direction;
|
||||||
|
this.settings = settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
@ -15,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_ON_FURNI;
|
public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_ON_FURNI;
|
||||||
@ -44,28 +45,37 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
StringBuilder data = new StringBuilder();
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
|
));
|
||||||
for (HabboItem item : this.items)
|
|
||||||
data.append(item.getId()).append(";");
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
String[] data = set.getString("wired_data").split(";");
|
if (wiredData.startsWith("{")) {
|
||||||
|
WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
|
||||||
|
|
||||||
for (String s : data) {
|
for(int id : data.itemIds) {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(";");
|
||||||
|
|
||||||
|
for (String s : data) {
|
||||||
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -139,4 +149,12 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
|||||||
|
|
||||||
this.items.removeAll(items);
|
this.items.removeAll(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(List<Integer> itemIds) {
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
|
|
||||||
@ -41,16 +42,23 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.teamColor.type + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.teamColor
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String data = set.getString("wired_data");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!data.equals(""))
|
String wiredData = set.getString("wired_data");
|
||||||
this.teamColor = GameTeamColors.values()[Integer.valueOf(data)];
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.teamColor = data.teamColor;
|
||||||
|
} else {
|
||||||
|
if (!wiredData.equals(""))
|
||||||
|
this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)];
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.teamColor = GameTeamColors.RED;
|
this.teamColor = GameTeamColors.RED;
|
||||||
}
|
}
|
||||||
@ -90,4 +98,12 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
GameTeamColors teamColor;
|
||||||
|
|
||||||
|
public JsonData(GameTeamColors teamColor) {
|
||||||
|
this.teamColor = teamColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||||
public static final WiredConditionType type = WiredConditionType.TRIGGER_ON_FURNI;
|
public static final WiredConditionType type = WiredConditionType.TRIGGER_ON_FURNI;
|
||||||
@ -67,21 +69,28 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
|||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
StringBuilder data = new StringBuilder();
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
|
));
|
||||||
for (HabboItem item : this.items) {
|
|
||||||
data.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
String[] data = set.getString("wired_data").split(";");
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
|
for(int id : data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(";");
|
||||||
|
|
||||||
for (String s : data) {
|
for (String s : data) {
|
||||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
@ -91,6 +100,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -168,4 +178,12 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
|||||||
public WiredConditionOperator operator() {
|
public WiredConditionOperator operator() {
|
||||||
return WiredConditionOperator.AND;
|
return WiredConditionOperator.AND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(List<Integer> itemIds) {
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.messages.outgoing.hotelview.BonusRareComposer;
|
import com.eu.habbo.messages.outgoing.hotelview.BonusRareComposer;
|
||||||
@ -70,7 +71,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
|
|||||||
packet.readInt();
|
packet.readInt();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.amount = Integer.valueOf(packet.readString());
|
this.amount = Integer.parseInt(packet.readString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -103,23 +104,29 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.getDelay() + "\t" + this.amount;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getDelay(), this.amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String wireData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
this.amount = 0;
|
this.amount = 0;
|
||||||
|
|
||||||
if (wireData.split("\t").length >= 2) {
|
if(wiredData.startsWith("{")) {
|
||||||
super.setDelay(Integer.valueOf(wireData.split("\t")[0]));
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.setDelay(data.delay);
|
||||||
|
this.amount = data.amount;
|
||||||
|
} else {
|
||||||
|
if (wiredData.split("\t").length >= 2) {
|
||||||
|
super.setDelay(Integer.parseInt(wiredData.split("\t")[0]));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.amount = Integer.valueOf(this.getWiredData().split("\t")[1]);
|
this.amount = Integer.parseInt(wiredData.split("\t")[1]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -131,4 +138,14 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
|
|||||||
public boolean requiresTriggeringUser() {
|
public boolean requiresTriggeringUser() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int delay;
|
||||||
|
int amount;
|
||||||
|
|
||||||
|
public JsonData(int delay, int amount) {
|
||||||
|
this.delay = delay;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
|
||||||
import com.eu.habbo.habbohotel.rooms.*;
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||||
@ -24,7 +24,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
public class WiredEffectMatchFurni extends InteractionWiredEffect implements InteractionWiredMatchFurniSettings {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class);
|
||||||
|
|
||||||
private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT;
|
private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT;
|
||||||
@ -241,6 +241,26 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public THashSet<WiredMatchFurniSetting> getMatchFurniSettings() {
|
||||||
|
return this.settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldMatchState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldMatchRotation() {
|
||||||
|
return this.direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldMatchPosition() {
|
||||||
|
return this.position;
|
||||||
|
}
|
||||||
|
|
||||||
static class JsonData {
|
static class JsonData {
|
||||||
boolean state;
|
boolean state;
|
||||||
boolean direction;
|
boolean direction;
|
||||||
|
@ -21,6 +21,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||||
public static final WiredEffectType type = WiredEffectType.FLEE;
|
public static final WiredEffectType type = WiredEffectType.FLEE;
|
||||||
@ -98,29 +99,36 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.getDelay(),
|
||||||
if (this.items != null && !this.items.isEmpty()) {
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items = new THashSet<>();
|
this.items = new THashSet<>();
|
||||||
String[] wiredData = set.getString("wired_data").split("\t");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
if (wiredData.length >= 1) {
|
if (wiredData.startsWith("{")) {
|
||||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.setDelay(data.delay);
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
}
|
}
|
||||||
if (wiredData.length == 2) {
|
}
|
||||||
if (wiredData[1].contains(";")) {
|
} else {
|
||||||
for (String s : wiredData[1].split(";")) {
|
String[] wiredDataOld = wiredData.split("\t");
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
|
||||||
|
if (wiredDataOld.length >= 1) {
|
||||||
|
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||||
|
}
|
||||||
|
if (wiredDataOld.length == 2) {
|
||||||
|
if (wiredDataOld[1].contains(";")) {
|
||||||
|
for (String s : wiredDataOld[1].split(";")) {
|
||||||
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -128,6 +136,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -206,4 +215,14 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
|||||||
protected long requiredCooldown() {
|
protected long requiredCooldown() {
|
||||||
return 495;
|
return 495;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int delay;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(int delay, List<Integer> itemIds) {
|
||||||
|
this.delay = delay;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||||
public static final WiredEffectType type = WiredEffectType.MOVE_FURNI_TO;
|
public static final WiredEffectType type = WiredEffectType.MOVE_FURNI_TO;
|
||||||
@ -123,24 +124,23 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
THashSet<HabboItem> items = new THashSet<>();
|
THashSet<HabboItem> itemsToRemove = new THashSet<>();
|
||||||
|
|
||||||
for (HabboItem item : this.items) {
|
for (HabboItem item : this.items) {
|
||||||
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
||||||
items.add(item);
|
itemsToRemove.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (HabboItem item : items) {
|
for (HabboItem item : itemsToRemove) {
|
||||||
this.items.remove(item);
|
this.items.remove(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder data = new StringBuilder(this.direction + "\t" + this.spacing + "\t" + this.getDelay() + "\t");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.direction,
|
||||||
for (HabboItem item : this.items) {
|
this.spacing,
|
||||||
data.append(item.getId()).append("\r");
|
this.getDelay(),
|
||||||
}
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
|
));
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -176,25 +176,40 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
|||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
String[] data = set.getString("wired_data").split("\t");
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.direction = data.direction;
|
||||||
|
this.spacing = data.spacing;
|
||||||
|
this.setDelay(data.delay);
|
||||||
|
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split("\t");
|
||||||
|
|
||||||
if (data.length == 4) {
|
if (data.length == 4) {
|
||||||
try {
|
try {
|
||||||
this.direction = Integer.valueOf(data[0]);
|
this.direction = Integer.parseInt(data[0]);
|
||||||
this.spacing = Integer.valueOf(data[1]);
|
this.spacing = Integer.parseInt(data[1]);
|
||||||
this.setDelay(Integer.valueOf(data[2]));
|
this.setDelay(Integer.parseInt(data[2]));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String s : data[3].split("\r")) {
|
for (String s : data[3].split("\r")) {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -209,4 +224,18 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
|||||||
protected long requiredCooldown() {
|
protected long requiredCooldown() {
|
||||||
return 495;
|
return 495;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int direction;
|
||||||
|
int spacing;
|
||||||
|
int delay;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(int direction, int spacing, int delay, List<Integer> itemIds) {
|
||||||
|
this.direction = direction;
|
||||||
|
this.spacing = spacing;
|
||||||
|
this.delay = delay;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -22,6 +22,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wired effect: move to closest user
|
* Wired effect: move to closest user
|
||||||
@ -233,28 +234,36 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.getDelay(),
|
||||||
if (this.items != null && !this.items.isEmpty()) {
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items = new THashSet<>();
|
this.items = new THashSet<>();
|
||||||
String[] wiredData = set.getString("wired_data").split("\t");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
if (wiredData.length >= 1) {
|
if (wiredData.startsWith("{")) {
|
||||||
this.setDelay(Integer.parseInt(wiredData[0]));
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.setDelay(data.delay);
|
||||||
|
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
}
|
}
|
||||||
if (wiredData.length == 2) {
|
}
|
||||||
if (wiredData[1].contains(";")) {
|
} else {
|
||||||
for (String s : wiredData[1].split(";")) {
|
String[] wiredDataOld = wiredData.split("\t");
|
||||||
|
|
||||||
|
if (wiredDataOld.length >= 1) {
|
||||||
|
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||||
|
}
|
||||||
|
if (wiredDataOld.length == 2) {
|
||||||
|
if (wiredDataOld[1].contains(";")) {
|
||||||
|
for (String s : wiredDataOld[1].split(";")) {
|
||||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
@ -263,6 +272,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -342,4 +352,14 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
|||||||
protected long requiredCooldown() {
|
protected long requiredCooldown() {
|
||||||
return 495;
|
return 495;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int delay;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(int delay, List<Integer> itemIds) {
|
||||||
|
this.delay = delay;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implements ICycleable {
|
public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implements ICycleable {
|
||||||
|
|
||||||
@ -80,35 +82,45 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
THashSet<HabboItem> items = new THashSet<>(this.items.size() / 2);
|
THashSet<HabboItem> itemsToRemove = new THashSet<>(this.items.size() / 2);
|
||||||
|
|
||||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||||
|
|
||||||
for (HabboItem item : this.items) {
|
for (HabboItem item : this.items) {
|
||||||
if (item.getRoomId() != this.getRoomId() || (room != null && room.getHabboItem(item.getId()) == null))
|
if (item.getRoomId() != this.getRoomId() || (room != null && room.getHabboItem(item.getId()) == null))
|
||||||
items.add(item);
|
itemsToRemove.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (HabboItem item : items) {
|
for (HabboItem item : itemsToRemove) {
|
||||||
this.items.remove(item);
|
this.items.remove(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder data = new StringBuilder(this.direction + "\t" +
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
this.rotation + "\t" +
|
this.direction,
|
||||||
this.getDelay() + "\t");
|
this.rotation,
|
||||||
|
this.getDelay(),
|
||||||
for (HabboItem item : this.items) {
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
data.append(item.getId()).append("\r");
|
));
|
||||||
}
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
String[] data = set.getString("wired_data").split("\t");
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.setDelay(data.delay);
|
||||||
|
this.direction = data.direction;
|
||||||
|
this.rotation = data.rotation;
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split("\t");
|
||||||
|
|
||||||
if (data.length == 4) {
|
if (data.length == 4) {
|
||||||
try {
|
try {
|
||||||
@ -127,6 +139,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -303,4 +316,18 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement
|
|||||||
public void cycle(Room room) {
|
public void cycle(Room room) {
|
||||||
this.itemCooldowns.clear();
|
this.itemCooldowns.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int direction;
|
||||||
|
int rotation;
|
||||||
|
int delay;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(int direction, int rotation, int delay, List<Integer> itemIds) {
|
||||||
|
this.direction = direction;
|
||||||
|
this.rotation = rotation;
|
||||||
|
this.delay = delay;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
|
||||||
@ -79,12 +80,24 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.getDelay() + "\t" + this.length + "\t" + this.message;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.getDelay(),
|
||||||
|
this.length,
|
||||||
|
this.message
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String[] data = set.getString("wired_data").split("\t");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.setDelay(data.delay);
|
||||||
|
this.length = data.length;
|
||||||
|
this.message = data.message;
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split("\t");
|
||||||
|
|
||||||
if (data.length >= 3) {
|
if (data.length >= 3) {
|
||||||
try {
|
try {
|
||||||
@ -95,6 +108,7 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -112,4 +126,16 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect {
|
|||||||
public boolean requiresTriggeringUser() {
|
public boolean requiresTriggeringUser() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int delay;
|
||||||
|
int length;
|
||||||
|
String message;
|
||||||
|
|
||||||
|
public JsonData(int delay, int length, String message) {
|
||||||
|
this.delay = delay;
|
||||||
|
this.length = length;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.threading.runnables.WiredResetTimers;
|
import com.eu.habbo.threading.runnables.WiredResetTimers;
|
||||||
@ -85,18 +86,26 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.delay + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.delay
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String data = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.delay = data.delay;
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
if (!data.equals(""))
|
if (!wiredData.equals("")) {
|
||||||
this.delay = Integer.valueOf(data);
|
this.delay = Integer.parseInt(wiredData);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.setDelay(this.delay);
|
this.setDelay(this.delay);
|
||||||
}
|
}
|
||||||
@ -111,4 +120,12 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
|
|||||||
public WiredEffectType getType() {
|
public WiredEffectType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int delay;
|
||||||
|
|
||||||
|
public JsonData(int delay) {
|
||||||
|
this.delay = delay;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredEffectTeleport extends InteractionWiredEffect {
|
public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||||
public static final WiredEffectType type = WiredEffectType.TELEPORT;
|
public static final WiredEffectType type = WiredEffectType.TELEPORT;
|
||||||
@ -181,29 +182,36 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.getDelay(),
|
||||||
if (this.items != null && !this.items.isEmpty()) {
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items = new ArrayList<>();
|
this.items = new ArrayList<>();
|
||||||
String[] wiredData = set.getString("wired_data").split("\t");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
if (wiredData.length >= 1) {
|
if (wiredData.startsWith("{")) {
|
||||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.setDelay(data.delay);
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
}
|
}
|
||||||
if (wiredData.length == 2) {
|
}
|
||||||
if (wiredData[1].contains(";")) {
|
} else {
|
||||||
for (String s : wiredData[1].split(";")) {
|
String[] wiredDataOld = wiredData.split("\t");
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
|
||||||
|
if (wiredDataOld.length >= 1) {
|
||||||
|
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||||
|
}
|
||||||
|
if (wiredDataOld.length == 2) {
|
||||||
|
if (wiredDataOld[1].contains(";")) {
|
||||||
|
for (String s : wiredDataOld[1].split(";")) {
|
||||||
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -211,6 +219,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -232,4 +241,14 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
|||||||
protected long requiredCooldown() {
|
protected long requiredCooldown() {
|
||||||
return 50L;
|
return 50L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int delay;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(int delay, List<Integer> itemIds) {
|
||||||
|
this.delay = delay;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleFurni.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleFurni.class);
|
||||||
@ -193,7 +194,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
|||||||
int state = 0;
|
int state = 0;
|
||||||
if (!item.getExtradata().isEmpty()) {
|
if (!item.getExtradata().isEmpty()) {
|
||||||
try {
|
try {
|
||||||
state = Integer.valueOf(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc.
|
state = Integer.parseInt(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc.
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -212,29 +213,41 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.getDelay(),
|
||||||
if (this.items != null && !this.items.isEmpty()) {
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
String[] wiredData = set.getString("wired_data").split("\t");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
if (wiredData.length >= 1) {
|
if (wiredData.startsWith("{")) {
|
||||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.setDelay(data.delay);
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
|
||||||
|
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (wiredData.length == 2) {
|
|
||||||
if (wiredData[1].contains(";")) {
|
if (item != null) {
|
||||||
for (String s : wiredData[1].split(";")) {
|
this.items.add(item);
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] wiredDataOld = wiredData.split("\t");
|
||||||
|
|
||||||
|
if (wiredDataOld.length >= 1) {
|
||||||
|
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||||
|
}
|
||||||
|
if (wiredDataOld.length == 2) {
|
||||||
|
if (wiredDataOld[1].contains(";")) {
|
||||||
|
for (String s : wiredDataOld[1].split(";")) {
|
||||||
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
|
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
|
||||||
continue;
|
continue;
|
||||||
@ -245,6 +258,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -256,4 +270,14 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
|||||||
public WiredEffectType getType() {
|
public WiredEffectType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int delay;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(int delay, List<Integer> itemIds) {
|
||||||
|
this.delay = delay;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleRandom.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleRandom.class);
|
||||||
@ -192,29 +193,22 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.getDelay(),
|
||||||
if (!this.items.isEmpty()) {
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
String[] wiredData = set.getString("wired_data").split("\t");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
if (wiredData.length >= 1) {
|
if (wiredData.startsWith("{")) {
|
||||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
}
|
this.setDelay(data.delay);
|
||||||
if (wiredData.length == 2) {
|
for (Integer id: data.itemIds) {
|
||||||
if (wiredData[1].contains(";")) {
|
HabboItem item = room.getHabboItem(id);
|
||||||
for (String s : wiredData[1].split(";")) {
|
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
|
||||||
|
|
||||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
|
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
|
||||||
continue;
|
continue;
|
||||||
@ -222,6 +216,24 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
|||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
String[] wiredDataOld = wiredData.split("\t");
|
||||||
|
|
||||||
|
if (wiredDataOld.length >= 1) {
|
||||||
|
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||||
|
}
|
||||||
|
if (wiredDataOld.length == 2) {
|
||||||
|
if (wiredDataOld[1].contains(";")) {
|
||||||
|
for (String s : wiredDataOld[1].split(";")) {
|
||||||
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
|
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,4 +248,14 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
|||||||
public WiredEffectType getType() {
|
public WiredEffectType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int delay;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(int delay, List<Integer> itemIds) {
|
||||||
|
this.delay = delay;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredEffectTriggerStacks extends InteractionWiredEffect {
|
public class WiredEffectTriggerStacks extends InteractionWiredEffect {
|
||||||
public static final WiredEffectType type = WiredEffectType.CALL_STACKS;
|
public static final WiredEffectType type = WiredEffectType.CALL_STACKS;
|
||||||
@ -156,29 +157,36 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.getDelay(),
|
||||||
if (this.items != null && !this.items.isEmpty()) {
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items = new THashSet<>();
|
this.items = new THashSet<>();
|
||||||
String[] wiredData = set.getString("wired_data").split("\t");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
if (wiredData.length >= 1) {
|
if (wiredData.startsWith("{")) {
|
||||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.setDelay(data.delay);
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
}
|
}
|
||||||
if (wiredData.length == 2) {
|
}
|
||||||
if (wiredData[1].contains(";")) {
|
} else {
|
||||||
for (String s : wiredData[1].split(";")) {
|
String[] wiredDataOld = wiredData.split("\t");
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
|
||||||
|
if (wiredDataOld.length >= 1) {
|
||||||
|
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||||
|
}
|
||||||
|
if (wiredDataOld.length == 2) {
|
||||||
|
if (wiredDataOld[1].contains(";")) {
|
||||||
|
for (String s : wiredDataOld[1].split(";")) {
|
||||||
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -186,6 +194,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -202,4 +211,14 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
|
|||||||
protected long requiredCooldown() {
|
protected long requiredCooldown() {
|
||||||
return 250;
|
return 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int delay;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(int delay, List<Integer> itemIds) {
|
||||||
|
this.delay = delay;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items.interactions.wired.interfaces;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
|
||||||
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
|
public interface InteractionWiredMatchFurniSettings {
|
||||||
|
public THashSet<WiredMatchFurniSetting> getMatchFurniSettings();
|
||||||
|
public boolean shouldMatchState();
|
||||||
|
public boolean shouldMatchRotation();
|
||||||
|
public boolean shouldMatchPosition();
|
||||||
|
}
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
|||||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
|
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
@ -39,13 +40,22 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.executeTime + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.executeTime
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
if (set.getString("wired_data").length() >= 1) {
|
String wiredData = set.getString("wired_data");
|
||||||
this.executeTime = (Integer.valueOf(set.getString("wired_data")));
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.executeTime = data.executeTime;
|
||||||
|
} else {
|
||||||
|
if (wiredData.length() >= 1) {
|
||||||
|
this.executeTime = (Integer.parseInt(wiredData));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.executeTime < 500) {
|
if (this.executeTime < 500) {
|
||||||
@ -115,4 +125,12 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi
|
|||||||
|
|
||||||
Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime);
|
Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int executeTime;
|
||||||
|
|
||||||
|
public JsonData(int executeTime) {
|
||||||
|
this.executeTime = executeTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
|||||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
|
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
@ -38,13 +39,22 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.executeTime + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.executeTime
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
if (set.getString("wired_data").length() >= 1) {
|
String wiredData = set.getString("wired_data");
|
||||||
this.executeTime = (Integer.valueOf(set.getString("wired_data")));
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.executeTime = data.executeTime;
|
||||||
|
} else {
|
||||||
|
if (wiredData.length() >= 1) {
|
||||||
|
this.executeTime = (Integer.parseInt(wiredData));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.executeTime < 500) {
|
if (this.executeTime < 500) {
|
||||||
@ -113,4 +123,12 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W
|
|||||||
|
|
||||||
Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime);
|
Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int executeTime;
|
||||||
|
|
||||||
|
public JsonData(int executeTime) {
|
||||||
|
this.executeTime = executeTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredTriggerBotReachedFurni.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(WiredTriggerBotReachedFurni.class);
|
||||||
@ -124,22 +125,28 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(this.botName + ":");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.botName,
|
||||||
if (!this.items.isEmpty()) {
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
for (HabboItem item : this.items) {
|
));
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
String[] data = set.getString("wired_data").split(":");
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.botName = data.botName;
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split(":");
|
||||||
|
|
||||||
if (data.length == 1) {
|
if (data.length == 1) {
|
||||||
this.botName = data[0];
|
this.botName = data[0];
|
||||||
@ -148,9 +155,9 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
String[] items = data[1].split(";");
|
String[] items = data[1].split(";");
|
||||||
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (String id : items) {
|
||||||
try {
|
try {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(items[i]));
|
HabboItem item = room.getHabboItem(Integer.parseInt(id));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -160,10 +167,21 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
this.botName = "";
|
this.botName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
String botName;
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(String botName, List<Integer> itemIds) {
|
||||||
|
this.botName = botName;
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
|||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
@ -62,12 +63,21 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.botName;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.botName
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.botName = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.botName = data.botName;
|
||||||
|
} else {
|
||||||
|
this.botName = wiredData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,4 +89,12 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger {
|
|||||||
public boolean isTriggeredByRoomUnit() {
|
public boolean isTriggeredByRoomUnit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
String botName;
|
||||||
|
|
||||||
|
public JsonData(String botName) {
|
||||||
|
this.botName = botName;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,13 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
||||||
private static final WiredTriggerType type = WiredTriggerType.STATE_CHANGED;
|
private static final WiredTriggerType type = WiredTriggerType.STATE_CHANGED;
|
||||||
|
|
||||||
private THashSet<HabboItem> items;
|
private THashSet<HabboItem> items;
|
||||||
private String message = "";
|
|
||||||
|
|
||||||
public WiredTriggerFurniStateToggled(ResultSet set, Item baseItem) throws SQLException {
|
public WiredTriggerFurniStateToggled(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
@ -55,31 +56,31 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
if (this.items != null) {
|
));
|
||||||
if (!this.items.isEmpty()) {
|
|
||||||
for (HabboItem item : this.items) {
|
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
wiredData.append("\t");
|
|
||||||
}
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items = new THashSet<>();
|
this.items = new THashSet<>();
|
||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (wiredData.split(":").length >= 3) {
|
if (wiredData.split(":").length >= 3) {
|
||||||
super.setDelay(Integer.valueOf(wiredData.split(":")[0]));
|
super.setDelay(Integer.parseInt(wiredData.split(":")[0]));
|
||||||
this.message = wiredData.split(":")[1];
|
|
||||||
|
|
||||||
if (!wiredData.split(":")[2].equals("\t")) {
|
if (!wiredData.split(":")[2].equals("\t")) {
|
||||||
for (String s : wiredData.split(":")[2].split(";")) {
|
for (String s : wiredData.split(":")[2].split(";")) {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -87,11 +88,11 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
this.message = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -126,7 +127,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
|||||||
}
|
}
|
||||||
message.appendInt(this.getBaseItem().getSpriteId());
|
message.appendInt(this.getBaseItem().getSpriteId());
|
||||||
message.appendInt(this.getId());
|
message.appendInt(this.getId());
|
||||||
message.appendString(this.message);
|
message.appendString("");
|
||||||
message.appendInt(0);
|
message.appendInt(0);
|
||||||
message.appendInt(0);
|
message.appendInt(0);
|
||||||
message.appendInt(this.getType().code);
|
message.appendInt(this.getType().code);
|
||||||
@ -153,4 +154,12 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
|||||||
public boolean isTriggeredByRoomUnit() {
|
public boolean isTriggeredByRoomUnit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(List<Integer> itemIds) {
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
@ -41,12 +42,21 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.username;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.username
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.username = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.username = data.username;
|
||||||
|
} else {
|
||||||
|
this.username = wiredData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,4 +96,12 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
|
|||||||
public boolean isTriggeredByRoomUnit() {
|
public boolean isTriggeredByRoomUnit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
String username;
|
||||||
|
|
||||||
|
public JsonData(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
@ -41,18 +42,29 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return (this.ownerOnly ? "1" : "0") + "\t" + this.key;
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.ownerOnly,
|
||||||
|
this.key
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String[] data = set.getString("wired_data").split("\t");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.ownerOnly = data.ownerOnly;
|
||||||
|
this.key = data.key;
|
||||||
|
} else {
|
||||||
|
String[] data = wiredData.split("\t");
|
||||||
|
|
||||||
if (data.length == 2) {
|
if (data.length == 2) {
|
||||||
this.ownerOnly = data[0].equalsIgnoreCase("1");
|
this.ownerOnly = data[0].equalsIgnoreCase("1");
|
||||||
this.key = data[1];
|
this.key = data[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -93,4 +105,14 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
|||||||
public boolean isTriggeredByRoomUnit() {
|
public boolean isTriggeredByRoomUnit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
boolean ownerOnly;
|
||||||
|
String key;
|
||||||
|
|
||||||
|
public JsonData(boolean ownerOnly, String key) {
|
||||||
|
this.ownerOnly = ownerOnly;
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,13 @@ import gnu.trove.set.hash.THashSet;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
||||||
public static final WiredTriggerType type = WiredTriggerType.WALKS_OFF_FURNI;
|
public static final WiredTriggerType type = WiredTriggerType.WALKS_OFF_FURNI;
|
||||||
|
|
||||||
private THashSet<HabboItem> items;
|
private THashSet<HabboItem> items;
|
||||||
private String message = "";
|
|
||||||
|
|
||||||
public WiredTriggerHabboWalkOffFurni(ResultSet set, Item baseItem) throws SQLException {
|
public WiredTriggerHabboWalkOffFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
@ -45,32 +44,27 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:");
|
return WiredHandler.getGsonBuilder().create().toJson(new WiredTriggerFurniStateToggled.JsonData(
|
||||||
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
if (!this.items.isEmpty()) {
|
));
|
||||||
List<HabboItem> toRemove = new ArrayList<>(0);
|
|
||||||
for (HabboItem item : this.items) {
|
|
||||||
if (item.getRoomId() == this.getRoomId()) {
|
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
} else {
|
|
||||||
toRemove.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.items.removeAll(toRemove);
|
|
||||||
} else
|
|
||||||
wiredData.append("\t");
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (wiredData.split(":").length >= 3) {
|
if (wiredData.split(":").length >= 3) {
|
||||||
super.setDelay(Integer.valueOf(wiredData.split(":")[0]));
|
super.setDelay(Integer.parseInt(wiredData.split(":")[0]));
|
||||||
this.message = wiredData.split(":")[1];
|
|
||||||
|
|
||||||
if (!wiredData.split(":")[2].equals("\t")) {
|
if (!wiredData.split(":")[2].equals("\t")) {
|
||||||
for (String s : wiredData.split(":")[2].split(";")) {
|
for (String s : wiredData.split(":")[2].split(";")) {
|
||||||
@ -78,7 +72,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -87,13 +81,12 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
this.message = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -126,7 +119,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
|||||||
}
|
}
|
||||||
message.appendInt(this.getBaseItem().getSpriteId());
|
message.appendInt(this.getBaseItem().getSpriteId());
|
||||||
message.appendInt(this.getId());
|
message.appendInt(this.getId());
|
||||||
message.appendString(this.message);
|
message.appendString("");
|
||||||
message.appendInt(0);
|
message.appendInt(0);
|
||||||
message.appendInt(0);
|
message.appendInt(0);
|
||||||
message.appendInt(this.getType().code);
|
message.appendInt(this.getType().code);
|
||||||
@ -154,4 +147,12 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
|||||||
public boolean isTriggeredByRoomUnit() {
|
public boolean isTriggeredByRoomUnit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(List<Integer> itemIds) {
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,12 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
||||||
public static final WiredTriggerType type = WiredTriggerType.WALKS_ON_FURNI;
|
public static final WiredTriggerType type = WiredTriggerType.WALKS_ON_FURNI;
|
||||||
|
|
||||||
private THashSet<HabboItem> items;
|
private THashSet<HabboItem> items;
|
||||||
private String message = "";
|
|
||||||
|
|
||||||
public WiredTriggerHabboWalkOnFurni(ResultSet set, Item baseItem) throws SQLException {
|
public WiredTriggerHabboWalkOnFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
@ -73,7 +73,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
|||||||
}
|
}
|
||||||
message.appendInt(this.getBaseItem().getSpriteId());
|
message.appendInt(this.getBaseItem().getSpriteId());
|
||||||
message.appendInt(this.getId());
|
message.appendInt(this.getId());
|
||||||
message.appendString(this.message);
|
message.appendString("");
|
||||||
message.appendInt(0);
|
message.appendInt(0);
|
||||||
message.appendInt(0);
|
message.appendInt(0);
|
||||||
message.appendInt(this.getType().code);
|
message.appendInt(this.getType().code);
|
||||||
@ -99,32 +99,27 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:");
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||||
if (!this.items.isEmpty()) {
|
));
|
||||||
List<HabboItem> toRemove = new ArrayList<>(0);
|
|
||||||
for (HabboItem item : this.items) {
|
|
||||||
if (item.getRoomId() == this.getRoomId()) {
|
|
||||||
wiredData.append(item.getId()).append(";");
|
|
||||||
} else {
|
|
||||||
toRemove.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.items.removeAll(toRemove);
|
|
||||||
} else
|
|
||||||
wiredData.append("\t");
|
|
||||||
|
|
||||||
return wiredData.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
for (Integer id: data.itemIds) {
|
||||||
|
HabboItem item = room.getHabboItem(id);
|
||||||
|
if (item != null) {
|
||||||
|
this.items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (wiredData.split(":").length >= 3) {
|
if (wiredData.split(":").length >= 3) {
|
||||||
super.setDelay(Integer.valueOf(wiredData.split(":")[0]));
|
super.setDelay(Integer.parseInt(wiredData.split(":")[0]));
|
||||||
this.message = wiredData.split(":")[1];
|
|
||||||
|
|
||||||
if (!wiredData.split(":")[2].equals("\t")) {
|
if (!wiredData.split(":")[2].equals("\t")) {
|
||||||
for (String s : wiredData.split(":")[2].split(";")) {
|
for (String s : wiredData.split(":")[2].split(";")) {
|
||||||
@ -132,7 +127,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
this.items.add(item);
|
this.items.add(item);
|
||||||
@ -142,15 +137,23 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
this.message = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTriggeredByRoomUnit() {
|
public boolean isTriggeredByRoomUnit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
List<Integer> itemIds;
|
||||||
|
|
||||||
|
public JsonData(List<Integer> itemIds) {
|
||||||
|
this.itemIds = itemIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,13 +41,22 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.repeatTime + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.repeatTime
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
if (set.getString("wired_data").length() >= 1) {
|
String wiredData = set.getString("wired_data");
|
||||||
this.repeatTime = (Integer.valueOf(set.getString("wired_data")));
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.repeatTime = data.repeatTime;
|
||||||
|
} else {
|
||||||
|
if (wiredData.length() >= 1) {
|
||||||
|
this.repeatTime = (Integer.valueOf(wiredData));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.repeatTime < 500) {
|
if (this.repeatTime < 500) {
|
||||||
@ -136,4 +145,12 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int repeatTime;
|
||||||
|
|
||||||
|
public JsonData(int repeatTime) {
|
||||||
|
this.repeatTime = repeatTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,22 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.repeatTime + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.repeatTime
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
if (set.getString("wired_data").length() >= 1) {
|
String wiredData = set.getString("wired_data");
|
||||||
this.repeatTime = (Integer.valueOf(set.getString("wired_data")));
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.repeatTime = data.repeatTime;
|
||||||
|
} else {
|
||||||
|
if (wiredData.length() >= 1) {
|
||||||
|
this.repeatTime = (Integer.valueOf(wiredData));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.repeatTime < 5000) {
|
if (this.repeatTime < 5000) {
|
||||||
@ -130,4 +139,12 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int repeatTime;
|
||||||
|
|
||||||
|
public JsonData(int repeatTime) {
|
||||||
|
this.repeatTime = repeatTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
|||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
@ -37,16 +38,25 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return this.score + "";
|
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||||
|
this.score
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
if (wiredData.startsWith("{")) {
|
||||||
|
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||||
|
this.score = data.score;
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
this.score = Integer.valueOf(set.getString("wired_data"));
|
this.score = Integer.parseInt(wiredData);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp() {
|
public void onPickUp() {
|
||||||
@ -85,4 +95,12 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger {
|
|||||||
public boolean isTriggeredByRoomUnit() {
|
public boolean isTriggeredByRoomUnit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JsonData {
|
||||||
|
int score;
|
||||||
|
|
||||||
|
public JsonData(int score) {
|
||||||
|
this.score = score;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,6 +505,7 @@ public class ModToolManager {
|
|||||||
return ban;
|
return ban;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public boolean hasIPBan(Channel habbo) {
|
public boolean hasIPBan(Channel habbo) {
|
||||||
if (habbo == null)
|
if (habbo == null)
|
||||||
return false;
|
return false;
|
||||||
@ -512,9 +513,13 @@ public class ModToolManager {
|
|||||||
if (habbo.remoteAddress() == null || ((InetSocketAddress) habbo.remoteAddress()).getAddress() == null)
|
if (habbo.remoteAddress() == null || ((InetSocketAddress) habbo.remoteAddress()).getAddress() == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
return this.hasIPBan(((InetSocketAddress) habbo.remoteAddress()).getAddress().getHostAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasIPBan(String ipAddress) {
|
||||||
boolean banned = false;
|
boolean banned = false;
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE ip = ? AND (type = 'ip' OR type = 'super') AND ban_expire > ? LIMIT 1")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans WHERE ip = ? AND (type = 'ip' OR type = 'super') AND ban_expire > ? LIMIT 1")) {
|
||||||
statement.setString(1, ((InetSocketAddress) habbo.remoteAddress()).getAddress().getHostAddress());
|
statement.setString(1, ipAddress);
|
||||||
statement.setInt(2, Emulator.getIntUnixTimestamp());
|
statement.setInt(2, Emulator.getIntUnixTimestamp());
|
||||||
|
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
try (ResultSet set = statement.executeQuery()) {
|
||||||
@ -525,7 +530,6 @@ public class ModToolManager {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("Caught SQL exception", e);
|
LOGGER.error("Caught SQL exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return banned;
|
return banned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,6 +578,7 @@ public class Pet implements ISerialize, Runnable {
|
|||||||
this.addHappyness(10);
|
this.addHappyness(10);
|
||||||
this.addExperience(10);
|
this.addExperience(10);
|
||||||
this.addRespect();
|
this.addRespect();
|
||||||
|
this.needsUpdate = true;
|
||||||
|
|
||||||
if (habbo != null) {
|
if (habbo != null) {
|
||||||
habbo.getHabboStats().petRespectPointsToGive--;
|
habbo.getHabboStats().petRespectPointsToGive--;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.eu.habbo.habbohotel.rooms;
|
package com.eu.habbo.habbohotel.rooms;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||||
import com.eu.habbo.habbohotel.bots.Bot;
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
import com.eu.habbo.habbohotel.bots.VisitorBot;
|
import com.eu.habbo.habbohotel.bots.VisitorBot;
|
||||||
import com.eu.habbo.habbohotel.commands.CommandHandler;
|
import com.eu.habbo.habbohotel.commands.CommandHandler;
|
||||||
@ -382,6 +383,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
this.updateItem(item);
|
this.updateItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (HabboItem item : this.roomSpecialTypes.getItemsOfType(InteractionFireworks.class)) {
|
||||||
|
item.setExtradata("1");
|
||||||
|
this.updateItem(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getPluginManager().fireEvent(new RoomLoadedEvent(this));
|
Emulator.getPluginManager().fireEvent(new RoomLoadedEvent(this));
|
||||||
@ -1204,7 +1210,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
habbo.getRoomUnit().increaseIdleTimer();
|
habbo.getRoomUnit().increaseIdleTimer();
|
||||||
|
|
||||||
if (habbo.getRoomUnit().isIdle()) {
|
if (habbo.getRoomUnit().isIdle()) {
|
||||||
|
boolean danceIsNone = (habbo.getRoomUnit().getDanceType() == DanceType.NONE);
|
||||||
|
if (danceIsNone)
|
||||||
this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose());
|
this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose());
|
||||||
|
if (danceIsNone && !Emulator.getConfig().getBoolean("hotel.roomuser.idle.not_dancing.ignore.wired_idle"))
|
||||||
WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
|
WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1221,6 +1230,19 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Emulator.getConfig().getBoolean("hotel.rooms.deco_hosting")) {
|
||||||
|
//Check if the user isn't the owner id
|
||||||
|
if (this.ownerId != habbo.getHabboInfo().getId()) {
|
||||||
|
//Check if the time already have 1 minute (120 / 2 = 60s)
|
||||||
|
if (habbo.getRoomUnit().getTimeInRoom() >= 120) {
|
||||||
|
AchievementManager.progressAchievement(this.ownerId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"));
|
||||||
|
habbo.getRoomUnit().resetTimeInRoom();
|
||||||
|
} else {
|
||||||
|
habbo.getRoomUnit().increaseTimeInRoom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (habbo.getHabboStats().mutedBubbleTracker && habbo.getHabboStats().allowTalk()) {
|
if (habbo.getHabboStats().mutedBubbleTracker && habbo.getHabboStats().allowTalk()) {
|
||||||
habbo.getHabboStats().mutedBubbleTracker = false;
|
habbo.getHabboStats().mutedBubbleTracker = false;
|
||||||
this.sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.UNIGNORED).compose());
|
this.sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.UNIGNORED).compose());
|
||||||
@ -2405,7 +2427,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
this.roomSpecialTypes.addUndefined(item);
|
this.roomSpecialTypes.addUndefined(item);
|
||||||
} else if (item instanceof InteractionSnowboardSlope) {
|
} else if (item instanceof InteractionSnowboardSlope) {
|
||||||
this.roomSpecialTypes.addUndefined(item);
|
this.roomSpecialTypes.addUndefined(item);
|
||||||
|
} else if (item instanceof InteractionFireworks) {
|
||||||
|
this.roomSpecialTypes.addUndefined(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,7 +672,7 @@ public class RoomManager {
|
|||||||
habbo.getClient().sendResponse(new RoomPromotionMessageComposer(null, null));
|
habbo.getClient().sendResponse(new RoomPromotionMessageComposer(null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (room.getOwnerId() != habbo.getHabboInfo().getId()) {
|
if (room.getOwnerId() != habbo.getHabboInfo().getId() && !habbo.getHabboStats().visitedRoom(room.getId())) {
|
||||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomEntry"));
|
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomEntry"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -916,6 +916,9 @@ public class RoomManager {
|
|||||||
statement.setInt(2, habbo.getHabboInfo().getId());
|
statement.setInt(2, habbo.getHabboInfo().getId());
|
||||||
statement.setInt(3, (int) (habbo.getHabboStats().roomEnterTimestamp));
|
statement.setInt(3, (int) (habbo.getHabboStats().roomEnterTimestamp));
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
|
||||||
|
if (!habbo.getHabboStats().visitedRoom(room.getId()))
|
||||||
|
habbo.getHabboStats().addVisitRoom(room.getId());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("Caught SQL exception", e);
|
LOGGER.error("Caught SQL exception", e);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ public class RoomUnit {
|
|||||||
private int effectId;
|
private int effectId;
|
||||||
private int effectEndTimestamp;
|
private int effectEndTimestamp;
|
||||||
private ScheduledFuture moveBlockingTask;
|
private ScheduledFuture moveBlockingTask;
|
||||||
|
private int timeInRoom;
|
||||||
|
|
||||||
private int idleTimer;
|
private int idleTimer;
|
||||||
private Room room;
|
private Room room;
|
||||||
@ -93,6 +94,7 @@ public class RoomUnit {
|
|||||||
this.effectId = 0;
|
this.effectId = 0;
|
||||||
this.isKicked = false;
|
this.isKicked = false;
|
||||||
this.overridableTiles = new THashSet<>();
|
this.overridableTiles = new THashSet<>();
|
||||||
|
this.timeInRoom = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearWalking() {
|
public void clearWalking() {
|
||||||
@ -639,6 +641,18 @@ public class RoomUnit {
|
|||||||
this.walkTimeOut = walkTimeOut;
|
this.walkTimeOut = walkTimeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void increaseTimeInRoom() {
|
||||||
|
this.timeInRoom++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimeInRoom() {
|
||||||
|
return this.timeInRoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetTimeInRoom() {
|
||||||
|
this.timeInRoom = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void increaseIdleTimer() {
|
public void increaseIdleTimer() {
|
||||||
this.idleTimer++;
|
this.idleTimer++;
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,10 @@ import com.eu.habbo.messages.outgoing.rooms.FloodCounterComposer;
|
|||||||
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
|
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.*;
|
import com.eu.habbo.messages.outgoing.rooms.users.*;
|
||||||
import com.eu.habbo.messages.outgoing.users.*;
|
import com.eu.habbo.messages.outgoing.users.*;
|
||||||
|
import com.eu.habbo.plugin.events.furniture.FurnitureBuildheightEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserCreditsEvent;
|
import com.eu.habbo.plugin.events.users.UserCreditsEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserDisconnectEvent;
|
import com.eu.habbo.plugin.events.users.UserDisconnectEvent;
|
||||||
|
import com.eu.habbo.plugin.events.users.UserGetIPAddressEvent;
|
||||||
import com.eu.habbo.plugin.events.users.UserPointsEvent;
|
import com.eu.habbo.plugin.events.users.UserPointsEvent;
|
||||||
import gnu.trove.TIntCollection;
|
import gnu.trove.TIntCollection;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
@ -114,11 +116,31 @@ public class Habbo implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void connect() {
|
public boolean connect() {
|
||||||
|
String ip = "";
|
||||||
|
|
||||||
if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) {
|
if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) {
|
||||||
SocketAddress address = this.client.getChannel().remoteAddress();
|
SocketAddress address = this.client.getChannel().remoteAddress();
|
||||||
|
ip = ((InetSocketAddress) address).getAddress().getHostAddress();
|
||||||
|
}
|
||||||
|
|
||||||
if (address != null) this.habboInfo.setIpLogin(((InetSocketAddress) address).getAddress().getHostAddress());
|
if (Emulator.getPluginManager().isRegistered(UserGetIPAddressEvent.class, true)) {
|
||||||
|
UserGetIPAddressEvent event = Emulator.getPluginManager().fireEvent(new UserGetIPAddressEvent(this, ip));
|
||||||
|
if (event.hasChangedIP()) {
|
||||||
|
ip = event.getUpdatedIp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ip.isEmpty()) {
|
||||||
|
this.habboInfo.setIpLogin(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Emulator.getGameEnvironment().getModToolManager().hasMACBan(this.client)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Emulator.getGameEnvironment().getModToolManager().hasIPBan(this.habboInfo.getIpLogin())) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.habboInfo.setMachineID(this.client.getMachineId());
|
this.habboInfo.setMachineID(this.client.getMachineId());
|
||||||
@ -128,6 +150,7 @@ public class Habbo implements Runnable {
|
|||||||
|
|
||||||
Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this);
|
Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this);
|
||||||
LOGGER.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin());
|
LOGGER.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ public class HabboManager {
|
|||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE ip_register = ? OR ip_current = ? AND id != ? ORDER BY id DESC LIMIT ?")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE ip_register = ? OR ip_current = ? AND id != ? ORDER BY id DESC LIMIT ?")) {
|
||||||
statement.setString(1, habbo.getHabboInfo().getIpRegister());
|
statement.setString(1, habbo.getHabboInfo().getIpRegister());
|
||||||
statement.setString(2, habbo.getClient().getChannel().remoteAddress().toString());
|
statement.setString(2, habbo.getHabboInfo().getIpLogin());
|
||||||
statement.setInt(3, habbo.getHabboInfo().getId());
|
statement.setInt(3, habbo.getHabboInfo().getId());
|
||||||
statement.setInt(4, limit);
|
statement.setInt(4, limit);
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ public class HabboStats implements Runnable {
|
|||||||
private final THashMap<Integer, CatalogItem> recentPurchases;
|
private final THashMap<Integer, CatalogItem> recentPurchases;
|
||||||
private final TIntArrayList favoriteRooms;
|
private final TIntArrayList favoriteRooms;
|
||||||
private final TIntArrayList ignoredUsers;
|
private final TIntArrayList ignoredUsers;
|
||||||
|
private TIntArrayList roomsVists;
|
||||||
public int achievementScore;
|
public int achievementScore;
|
||||||
public int respectPointsReceived;
|
public int respectPointsReceived;
|
||||||
public int respectPointsGiven;
|
public int respectPointsGiven;
|
||||||
@ -106,6 +107,7 @@ public class HabboStats implements Runnable {
|
|||||||
this.recentPurchases = new THashMap<>(0);
|
this.recentPurchases = new THashMap<>(0);
|
||||||
this.favoriteRooms = new TIntArrayList(0);
|
this.favoriteRooms = new TIntArrayList(0);
|
||||||
this.ignoredUsers = new TIntArrayList(0);
|
this.ignoredUsers = new TIntArrayList(0);
|
||||||
|
this.roomsVists = new TIntArrayList(0);
|
||||||
this.secretRecipes = new TIntArrayList(0);
|
this.secretRecipes = new TIntArrayList(0);
|
||||||
this.calendarRewardsClaimed = new TIntArrayList(0);
|
this.calendarRewardsClaimed = new TIntArrayList(0);
|
||||||
|
|
||||||
@ -236,6 +238,15 @@ public class HabboStats implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try (PreparedStatement loadRoomsVisit = set.getStatement().getConnection().prepareStatement("SELECT DISTINCT room_id FROM room_enter_log WHERE user_id = ?")) {
|
||||||
|
loadRoomsVisit.setInt(1, this.habboInfo.getId());
|
||||||
|
try (ResultSet roomSet = loadRoomsVisit.executeQuery()) {
|
||||||
|
while (roomSet.next()) {
|
||||||
|
this.roomsVists.add(roomSet.getInt("room_id"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HabboStats createNewStats(HabboInfo habboInfo) {
|
private static HabboStats createNewStats(HabboInfo habboInfo) {
|
||||||
@ -622,6 +633,10 @@ public class HabboStats implements Runnable {
|
|||||||
return this.favoriteRooms.contains(roomId);
|
return this.favoriteRooms.contains(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean visitedRoom(int roomId) { return this.roomsVists.contains(roomId); }
|
||||||
|
|
||||||
|
public void addVisitRoom(int roomId) { this.roomsVists.add(roomId); }
|
||||||
|
|
||||||
public TIntArrayList getFavoriteRooms() {
|
public TIntArrayList getFavoriteRooms() {
|
||||||
return this.favoriteRooms;
|
return this.favoriteRooms;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ import com.eu.habbo.messages.incoming.trading.*;
|
|||||||
import com.eu.habbo.messages.incoming.unknown.RequestResolutionEvent;
|
import com.eu.habbo.messages.incoming.unknown.RequestResolutionEvent;
|
||||||
import com.eu.habbo.messages.incoming.unknown.UnknownEvent1;
|
import com.eu.habbo.messages.incoming.unknown.UnknownEvent1;
|
||||||
import com.eu.habbo.messages.incoming.users.*;
|
import com.eu.habbo.messages.incoming.users.*;
|
||||||
|
import com.eu.habbo.messages.incoming.wired.WiredApplySetConditionsEvent;
|
||||||
import com.eu.habbo.messages.incoming.wired.WiredConditionSaveDataEvent;
|
import com.eu.habbo.messages.incoming.wired.WiredConditionSaveDataEvent;
|
||||||
import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent;
|
import com.eu.habbo.messages.incoming.wired.WiredEffectSaveDataEvent;
|
||||||
import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent;
|
import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent;
|
||||||
@ -579,6 +580,7 @@ public class PacketManager {
|
|||||||
this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class);
|
this.registerHandler(Incoming.WiredTriggerSaveDataEvent, WiredTriggerSaveDataEvent.class);
|
||||||
this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class);
|
this.registerHandler(Incoming.WiredEffectSaveDataEvent, WiredEffectSaveDataEvent.class);
|
||||||
this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class);
|
this.registerHandler(Incoming.WiredConditionSaveDataEvent, WiredConditionSaveDataEvent.class);
|
||||||
|
this.registerHandler(Incoming.WiredApplySetConditionsEvent, WiredApplySetConditionsEvent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerUnknown() throws Exception {
|
void registerUnknown() throws Exception {
|
||||||
|
@ -155,6 +155,7 @@ public class Incoming {
|
|||||||
public static final int RequestInventoryItemsEvent = 3150;
|
public static final int RequestInventoryItemsEvent = 3150;
|
||||||
public static final int ModToolRoomAlertEvent = 3842;
|
public static final int ModToolRoomAlertEvent = 3842;
|
||||||
public static final int WiredEffectSaveDataEvent = 2281;
|
public static final int WiredEffectSaveDataEvent = 2281;
|
||||||
|
public static final int WiredApplySetConditionsEvent = 3373;
|
||||||
public static final int CheckPetNameEvent = 2109;
|
public static final int CheckPetNameEvent = 2109;
|
||||||
public static final int SecureLoginEvent = 2419;
|
public static final int SecureLoginEvent = 2419;
|
||||||
public static final int BotSaveSettingsEvent = 2624;
|
public static final int BotSaveSettingsEvent = 2624;
|
||||||
|
@ -2,11 +2,15 @@ package com.eu.habbo.messages.incoming.guilds;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||||
|
import com.eu.habbo.habbohotel.guilds.GuildMember;
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.messages.outgoing.guilds.GuildFavoriteRoomUserUpdateComposer;
|
||||||
import com.eu.habbo.messages.outgoing.guilds.RemoveGuildFromRoomComposer;
|
import com.eu.habbo.messages.outgoing.guilds.RemoveGuildFromRoomComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer;
|
import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer;
|
||||||
import com.eu.habbo.plugin.events.guilds.GuildDeletedEvent;
|
import com.eu.habbo.plugin.events.guilds.GuildDeletedEvent;
|
||||||
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
public class GuildDeleteEvent extends MessageHandler {
|
public class GuildDeleteEvent extends MessageHandler {
|
||||||
@Override
|
@Override
|
||||||
@ -18,6 +22,15 @@ public class GuildDeleteEvent extends MessageHandler {
|
|||||||
if (guild != null) {
|
if (guild != null) {
|
||||||
if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) //TODO Add staff permission override.
|
if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) //TODO Add staff permission override.
|
||||||
{
|
{
|
||||||
|
THashSet<GuildMember> members = Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild.getId());
|
||||||
|
|
||||||
|
for (GuildMember member : members) {
|
||||||
|
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(member.getUserId());
|
||||||
|
if (habbo != null)
|
||||||
|
if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null)
|
||||||
|
habbo.getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(habbo.getRoomUnit(), null).compose());
|
||||||
|
}
|
||||||
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().deleteGuild(guild);
|
Emulator.getGameEnvironment().getGuildManager().deleteGuild(guild);
|
||||||
Emulator.getPluginManager().fireEvent(new GuildDeletedEvent(guild, this.client.getHabbo()));
|
Emulator.getPluginManager().fireEvent(new GuildDeletedEvent(guild, this.client.getHabbo()));
|
||||||
Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()).sendComposer(new RemoveGuildFromRoomComposer(guildId).compose());
|
Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()).sendComposer(new RemoveGuildFromRoomComposer(guildId).compose());
|
||||||
|
@ -22,7 +22,7 @@ public class GuildRemoveFavoriteEvent extends MessageHandler {
|
|||||||
this.client.getHabbo().getHabboStats().guild = 0;
|
this.client.getHabbo().getHabboStats().guild = 0;
|
||||||
|
|
||||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && guild != null) {
|
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && guild != null) {
|
||||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(this.client.getHabbo().getRoomUnit(), guild).compose());
|
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(this.client.getHabbo().getRoomUnit(), null).compose());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.sendResponse(new UserProfileComposer(this.client.getHabbo(), this.client));
|
this.client.sendResponse(new UserProfileComposer(this.client.getHabbo(), this.client));
|
||||||
|
@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.permissions.Permission;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.messages.outgoing.guilds.GuildFavoriteRoomUserUpdateComposer;
|
||||||
import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer;
|
import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer;
|
||||||
import com.eu.habbo.messages.outgoing.guilds.GuildRefreshMembersListComposer;
|
import com.eu.habbo.messages.outgoing.guilds.GuildRefreshMembersListComposer;
|
||||||
import com.eu.habbo.plugin.events.guilds.GuildRemovedMemberEvent;
|
import com.eu.habbo.plugin.events.guilds.GuildRemovedMemberEvent;
|
||||||
@ -44,7 +45,10 @@ public class GuildRemoveMemberEvent extends MessageHandler {
|
|||||||
if (habbo.getHabboStats().guild == guildId)
|
if (habbo.getHabboStats().guild == guildId)
|
||||||
habbo.getHabboStats().guild = 0;
|
habbo.getHabboStats().guild = 0;
|
||||||
|
|
||||||
if (room != null && habbo.getHabboInfo().getCurrentRoom() == room) {
|
if (room != null) {
|
||||||
|
if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null)
|
||||||
|
habbo.getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(habbo.getRoomUnit(), null).compose());
|
||||||
|
if (habbo.getHabboInfo().getCurrentRoom() == room)
|
||||||
room.refreshRightsForHabbo(habbo);
|
room.refreshRightsForHabbo(habbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,19 +77,13 @@ public class SecureLoginEvent extends MessageHandler {
|
|||||||
if (this.client.getHabbo() == null) {
|
if (this.client.getHabbo() == null) {
|
||||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso);
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso);
|
||||||
if (habbo != null) {
|
if (habbo != null) {
|
||||||
if (Emulator.getGameEnvironment().getModToolManager().hasMACBan(this.client)) {
|
|
||||||
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Emulator.getGameEnvironment().getModToolManager().hasIPBan(this.client.getChannel())) {
|
|
||||||
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
habbo.setClient(this.client);
|
habbo.setClient(this.client);
|
||||||
this.client.setHabbo(habbo);
|
this.client.setHabbo(habbo);
|
||||||
this.client.getHabbo().connect();
|
if(!this.client.getHabbo().connect()) {
|
||||||
|
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.client.getHabbo().getHabboInfo() == null) {
|
if (this.client.getHabbo().getHabboInfo() == null) {
|
||||||
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
|
||||||
@ -191,7 +185,7 @@ public class SecureLoginEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress()));
|
Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getHabbo().getHabboInfo().getIpLogin()));
|
||||||
|
|
||||||
if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) {
|
if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) {
|
||||||
final Habbo finalHabbo = habbo;
|
final Habbo finalHabbo = habbo;
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
package com.eu.habbo.messages.incoming.handshake;
|
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
|
||||||
import com.eu.habbo.messages.outgoing.friends.FriendsComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.habboway.nux.NewUserIdentityComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.handshake.DebugConsoleComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.handshake.SecureLoginOKComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.handshake.SessionRightsComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.modtool.ModToolComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.navigator.*;
|
|
||||||
import com.eu.habbo.messages.outgoing.users.*;
|
|
||||||
import com.eu.habbo.plugin.events.users.UserLoginEvent;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class SecureLoginEvent_BACKUP extends MessageHandler {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle() throws Exception {
|
|
||||||
|
|
||||||
if (!Emulator.isReady)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String sso = this.packet.readString();
|
|
||||||
|
|
||||||
if (this.client.getHabbo() == null) {
|
|
||||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso);
|
|
||||||
if (habbo != null) {
|
|
||||||
habbo.setClient(this.client);
|
|
||||||
this.client.setHabbo(habbo);
|
|
||||||
this.client.getHabbo().connect();
|
|
||||||
//this.client.sendResponse(new DebugConsoleComposer());
|
|
||||||
Emulator.getThreading().run(habbo);
|
|
||||||
Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo);
|
|
||||||
|
|
||||||
ArrayList<ServerMessage> messages = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
messages.add(new SecureLoginOKComposer().compose());
|
|
||||||
messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0).compose());
|
|
||||||
messages.add(new UserPermissionsComposer(this.client.getHabbo()).compose());
|
|
||||||
messages.add(new UserClubComposer(this.client.getHabbo()).compose());
|
|
||||||
messages.add(new DebugConsoleComposer(Emulator.debugging).compose());
|
|
||||||
messages.add(new UserAchievementScoreComposer(this.client.getHabbo()).compose());
|
|
||||||
messages.add(new NewUserIdentityComposer(habbo).compose());
|
|
||||||
messages.add(new UserPerksComposer(habbo).compose());
|
|
||||||
messages.add(new SessionRightsComposer().compose());
|
|
||||||
messages.add(new FavoriteRoomsCountComposer(habbo).compose());
|
|
||||||
//messages.add(new FriendsComposer(this.client.getHabbo()).compose());
|
|
||||||
//messages.add(new NewUserIdentityComposer().compose());
|
|
||||||
//messages.add(new UserDataComposer(this.client.getHabbo()).compose());
|
|
||||||
//messages.add(new SessionRightsComposer().compose());
|
|
||||||
//messages.add(new MinimailCountComposer().compose());
|
|
||||||
//messages.add(new MessengerInitComposer(this.client.getHabbo()).compose());
|
|
||||||
//messages.add(new FriendsComposer(this.client.getHabbo()).compose());
|
|
||||||
|
|
||||||
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
|
|
||||||
messages.add(new ModToolComposer(this.client.getHabbo()).compose());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.client.sendResponses(messages);
|
|
||||||
|
|
||||||
//Hardcoded
|
|
||||||
this.client.sendResponse(new NewNavigatorMetaDataComposer());
|
|
||||||
this.client.sendResponse(new NewNavigatorLiftedRoomsComposer());
|
|
||||||
this.client.sendResponse(new NewNavigatorCollapsedCategoriesComposer());
|
|
||||||
this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches()));
|
|
||||||
this.client.sendResponse(new NewNavigatorEventCategoriesComposer());
|
|
||||||
//this.client.sendResponse(new HotelViewComposer());
|
|
||||||
//this.client.sendResponse(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom()));
|
|
||||||
//this.client.sendResponse(new UserEffectsListComposer());
|
|
||||||
|
|
||||||
|
|
||||||
Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress()));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.client.sendResponse(new GenericAlertComposer("Can't connect *sadpanda*"));
|
|
||||||
|
|
||||||
this.client.getChannel().close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,6 +11,9 @@ import com.eu.habbo.messages.incoming.MessageHandler;
|
|||||||
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
|
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.pets.PetPackageComposer;
|
import com.eu.habbo.messages.outgoing.rooms.pets.PetPackageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||||
|
import com.eu.habbo.plugin.Event;
|
||||||
|
import com.eu.habbo.plugin.events.furniture.FurniturePickedUpEvent;
|
||||||
|
import com.eu.habbo.plugin.events.furniture.FurnitureToggleEvent;
|
||||||
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
|
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -34,6 +37,12 @@ public class ToggleFloorItemEvent extends MessageHandler {
|
|||||||
if (item == null || item instanceof InteractionDice)
|
if (item == null || item instanceof InteractionDice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Event furnitureToggleEvent = new FurnitureToggleEvent(item, this.client.getHabbo(), state);
|
||||||
|
Emulator.getPluginManager().fireEvent(furnitureToggleEvent);
|
||||||
|
|
||||||
|
if (furnitureToggleEvent.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) {
|
if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) {
|
||||||
THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY()));
|
THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY()));
|
||||||
|
@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.plugin.Event;
|
||||||
|
import com.eu.habbo.plugin.events.furniture.FurnitureToggleEvent;
|
||||||
|
|
||||||
public class ToggleWallItemEvent extends MessageHandler {
|
public class ToggleWallItemEvent extends MessageHandler {
|
||||||
@Override
|
@Override
|
||||||
@ -21,6 +23,12 @@ public class ToggleWallItemEvent extends MessageHandler {
|
|||||||
if (item == null)
|
if (item == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Event furnitureToggleEvent = new FurnitureToggleEvent(item, this.client.getHabbo(), state);
|
||||||
|
Emulator.getPluginManager().fireEvent(furnitureToggleEvent);
|
||||||
|
|
||||||
|
if (furnitureToggleEvent.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
if (item.getBaseItem().getName().equalsIgnoreCase("poster"))
|
if (item.getBaseItem().getName().equalsIgnoreCase("poster"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.eu.habbo.messages.incoming.rooms.pets;
|
package com.eu.habbo.messages.incoming.rooms.pets;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.pets.MonsterplantPet;
|
import com.eu.habbo.habbohotel.pets.MonsterplantPet;
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
@ -22,6 +23,9 @@ public class ScratchPetEvent extends MessageHandler {
|
|||||||
|
|
||||||
if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) {
|
if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) {
|
||||||
pet.scratched(this.client.getHabbo());
|
pet.scratched(this.client.getHabbo());
|
||||||
|
|
||||||
|
// Update the stats to the database.
|
||||||
|
Emulator.getThreading().run(pet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class TradeOfferItemEvent extends MessageHandler {
|
|||||||
|
|
||||||
HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt());
|
HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(this.packet.readInt());
|
||||||
|
|
||||||
if (item == null)
|
if (item == null || !item.getBaseItem().allowTrade())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
trade.offerItem(this.client.getHabbo(), item);
|
trade.offerItem(this.client.getHabbo(), item);
|
||||||
|
@ -0,0 +1,103 @@
|
|||||||
|
package com.eu.habbo.messages.incoming.wired;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.FurnitureMovementError;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class WiredApplySetConditionsEvent extends MessageHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRatelimit() {
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle() throws Exception {
|
||||||
|
int itemId = this.packet.readInt();
|
||||||
|
|
||||||
|
// Executing Habbo has to be in a Room
|
||||||
|
if (!this.client.getHabbo().getRoomUnit().isInRoom()) {
|
||||||
|
this.client.sendResponse(new BubbleAlertComposer(
|
||||||
|
BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key,
|
||||||
|
FurnitureMovementError.NO_RIGHTS.errorCode
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||||
|
|
||||||
|
if (room != null) {
|
||||||
|
|
||||||
|
// Executing Habbo should be able to edit wireds
|
||||||
|
if (room.hasRights(this.client.getHabbo()) || room.isOwner(this.client.getHabbo())) {
|
||||||
|
|
||||||
|
List<HabboItem> wireds = new ArrayList<>();
|
||||||
|
wireds.addAll(room.getRoomSpecialTypes().getConditions());
|
||||||
|
wireds.addAll(room.getRoomSpecialTypes().getEffects());
|
||||||
|
|
||||||
|
// Find the item with the given ID in the room
|
||||||
|
Optional<HabboItem> item = wireds.stream()
|
||||||
|
.filter(wired -> wired.getId() == itemId)
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
|
// If the item exists
|
||||||
|
if (item.isPresent()) {
|
||||||
|
HabboItem wiredItem = item.get();
|
||||||
|
|
||||||
|
// The item should have settings to match furni state, position and rotation
|
||||||
|
if (wiredItem instanceof InteractionWiredMatchFurniSettings) {
|
||||||
|
|
||||||
|
InteractionWiredMatchFurniSettings wired = (InteractionWiredMatchFurniSettings) wiredItem;
|
||||||
|
|
||||||
|
// Try to apply the set settings to each item
|
||||||
|
wired.getMatchFurniSettings().forEach(setting -> {
|
||||||
|
HabboItem matchItem = room.getHabboItem(setting.item_id);
|
||||||
|
|
||||||
|
// Match state
|
||||||
|
if (wired.shouldMatchState() && matchItem.allowWiredResetState()) {
|
||||||
|
if (!setting.state.equals(" ") && !matchItem.getExtradata().equals(setting.state)) {
|
||||||
|
matchItem.setExtradata(setting.state);
|
||||||
|
room.updateItemState(matchItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RoomTile oldLocation = room.getLayout().getTile(matchItem.getX(), matchItem.getY());
|
||||||
|
double oldZ = matchItem.getZ();
|
||||||
|
|
||||||
|
// Match Position & Rotation
|
||||||
|
if(wired.shouldMatchRotation() && !wired.shouldMatchPosition()) {
|
||||||
|
if(matchItem.getRotation() != setting.rotation && room.furnitureFitsAt(oldLocation, matchItem, setting.rotation, false) == FurnitureMovementError.NONE) {
|
||||||
|
room.moveFurniTo(matchItem, oldLocation, setting.rotation, null, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(wired.shouldMatchPosition()) {
|
||||||
|
boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.rotation;
|
||||||
|
RoomTile newLocation = room.getLayout().getTile((short) setting.x, (short) setting.y);
|
||||||
|
int newRotation = wired.shouldMatchRotation() ? setting.rotation : matchItem.getRotation();
|
||||||
|
|
||||||
|
if(newLocation != null && newLocation.state != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) {
|
||||||
|
if(room.moveFurniTo(matchItem, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) {
|
||||||
|
if(slideAnimation) {
|
||||||
|
room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,9 +19,9 @@ public class GuildFavoriteRoomUserUpdateComposer extends MessageComposer {
|
|||||||
protected ServerMessage composeInternal() {
|
protected ServerMessage composeInternal() {
|
||||||
this.response.init(Outgoing.GuildFavoriteRoomUserUpdateComposer);
|
this.response.init(Outgoing.GuildFavoriteRoomUserUpdateComposer);
|
||||||
this.response.appendInt(this.roomUnit.getId());
|
this.response.appendInt(this.roomUnit.getId());
|
||||||
this.response.appendInt(this.guild.getId());
|
this.response.appendInt(this.guild != null ? this.guild.getId() : 0);
|
||||||
this.response.appendInt(this.guild.getState().state);
|
this.response.appendInt(this.guild != null ? this.guild.getState().state : 3);
|
||||||
this.response.appendString(this.guild.getName());
|
this.response.appendString(this.guild != null ? this.guild.getName() : "");
|
||||||
return this.response;
|
return this.response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,13 +59,13 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter {
|
|||||||
ctx.channel().close();
|
ctx.channel().close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (Emulator.getConfig().getBoolean("debug.mode")) {
|
||||||
if (cause instanceof TooLongFrameException) {
|
if (cause instanceof TooLongFrameException) {
|
||||||
LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\".");
|
LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\".");
|
||||||
} else {
|
} else {
|
||||||
LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause);
|
LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctx.channel().close();
|
ctx.channel().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.eu.habbo.plugin.events.furniture;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
|
||||||
|
public class FurnitureToggleEvent extends FurnitureUserEvent {
|
||||||
|
public int state;
|
||||||
|
|
||||||
|
public FurnitureToggleEvent(HabboItem furniture, Habbo habbo, int state) {
|
||||||
|
super(furniture, habbo);
|
||||||
|
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.eu.habbo.plugin.events.users;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
|
||||||
|
public class UserGetIPAddressEvent extends UserEvent{
|
||||||
|
public final String oldIp;
|
||||||
|
|
||||||
|
private String updatedIp;
|
||||||
|
private boolean changedIP = false;
|
||||||
|
|
||||||
|
public UserGetIPAddressEvent(Habbo habbo, String ip) {
|
||||||
|
super(habbo);
|
||||||
|
this.oldIp = ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedIp(String updatedIp) {
|
||||||
|
this.updatedIp = updatedIp;
|
||||||
|
this.changedIP = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChangedIP() {
|
||||||
|
return changedIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdatedIp() {
|
||||||
|
return updatedIp;
|
||||||
|
}
|
||||||
|
}
|
@ -6,10 +6,9 @@ import java.net.SocketAddress;
|
|||||||
|
|
||||||
public class UserLoginEvent extends UserEvent {
|
public class UserLoginEvent extends UserEvent {
|
||||||
|
|
||||||
public final SocketAddress ip;
|
public final String ip;
|
||||||
|
|
||||||
|
public UserLoginEvent(Habbo habbo, String ip) {
|
||||||
public UserLoginEvent(Habbo habbo, SocketAddress ip) {
|
|
||||||
super(habbo);
|
super(habbo);
|
||||||
|
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
|
Loading…
Reference in New Issue
Block a user