You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-19 15:06:19 +00:00
🆙 Start of Beta
This commit is contained in:
@@ -9,7 +9,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
|
||||
import com.eu.habbo.plugin.EventHandler;
|
||||
import com.eu.habbo.plugin.events.users.UserSavedMottoEvent;
|
||||
|
||||
public final class Easter {
|
||||
public class Easter {
|
||||
@EventHandler
|
||||
public static void onUserChangeMotto(UserSavedMottoEvent event) {
|
||||
if (Emulator.getConfig().getBoolean("easter_eggs.enabled") && event.newMotto.equalsIgnoreCase("crickey!")) {
|
||||
|
||||
@@ -25,9 +25,6 @@ public class RoomUserPetComposer extends MessageComposer {
|
||||
this.response.appendInt(this.habbo.getHabboInfo().getId());
|
||||
this.response.appendString(this.habbo.getHabboInfo().getUsername());
|
||||
this.response.appendString("");
|
||||
this.response.appendInt(0);
|
||||
this.response.appendInt(0);
|
||||
this.response.appendInt(0);
|
||||
this.response.appendString(this.petType + " " + this.race + " " + this.color + " 2 2 -1 0 3 -1 0");
|
||||
this.response.appendInt(this.habbo.getRoomUnit().getId());
|
||||
this.response.appendInt(this.habbo.getRoomUnit().getX());
|
||||
|
||||
@@ -88,11 +88,11 @@ public class HabboDiffieHellman {
|
||||
}
|
||||
|
||||
if (this.DHPrime.compareTo(BigInteger.valueOf(2)) < 1) {
|
||||
throw new HabboCryptoException("Prime cannot be <= 2!\nPrime: " + this.DHPrime);
|
||||
throw new HabboCryptoException("Prime cannot be <= 2!\nPrime: " + this.DHPrime.toString());
|
||||
}
|
||||
|
||||
if (this.DHGenerator.compareTo(this.DHPrime) > -1) {
|
||||
throw new HabboCryptoException("Generator cannot be >= Prime!\nPrime: " + this.DHPrime + "\nGenerator: " + this.DHGenerator.toString());
|
||||
throw new HabboCryptoException("Generator cannot be >= Prime!\nPrime: " + this.DHPrime.toString() + "\nGenerator: " + this.DHGenerator.toString());
|
||||
}
|
||||
|
||||
generateDHKeys();
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.eu.habbo.habbohotel;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.core.CreditsScheduler;
|
||||
import com.eu.habbo.core.GotwPointsScheduler;
|
||||
import com.eu.habbo.core.PixelScheduler;
|
||||
import com.eu.habbo.core.PointsScheduler;
|
||||
import com.eu.habbo.core.*;
|
||||
import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||
import com.eu.habbo.habbohotel.bots.BotManager;
|
||||
import com.eu.habbo.habbohotel.campaign.calendar.CalendarManager;
|
||||
@@ -22,6 +19,7 @@ import com.eu.habbo.habbohotel.navigation.NavigatorManager;
|
||||
import com.eu.habbo.habbohotel.permissions.PermissionsManager;
|
||||
import com.eu.habbo.habbohotel.pets.PetManager;
|
||||
import com.eu.habbo.habbohotel.polls.PollManager;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatBubbleManager;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomManager;
|
||||
import com.eu.habbo.habbohotel.users.HabboManager;
|
||||
import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionManager;
|
||||
@@ -59,6 +57,7 @@ public class GameEnvironment {
|
||||
private PollManager pollManager;
|
||||
private SubscriptionManager subscriptionManager;
|
||||
private CalendarManager calendarManager;
|
||||
private RoomChatBubbleManager roomChatBubbleManager;
|
||||
|
||||
public void load() throws Exception {
|
||||
LOGGER.info("GameEnvironment -> Loading...");
|
||||
@@ -84,6 +83,7 @@ public class GameEnvironment {
|
||||
this.craftingManager = new CraftingManager();
|
||||
this.pollManager = new PollManager();
|
||||
this.calendarManager = new CalendarManager();
|
||||
this.roomChatBubbleManager = new RoomChatBubbleManager();
|
||||
|
||||
this.roomManager.loadPublicRooms();
|
||||
this.navigatorManager.loadNavigator();
|
||||
@@ -215,4 +215,8 @@ public class GameEnvironment {
|
||||
}
|
||||
|
||||
public CalendarManager getCalendarManager() { return this.calendarManager; }
|
||||
|
||||
public RoomChatBubbleManager getRoomChatBubbleManager() {
|
||||
return roomChatBubbleManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ public class AchievementManager {
|
||||
progressAchievement(habbo, achievement, amount);
|
||||
} else {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_achievements_queue (user_id, achievement_id, amount) VALUES (?, ?, ?) " +
|
||||
PreparedStatement statement = connection.prepareStatement("" +
|
||||
"INSERT INTO users_achievements_queue (user_id, achievement_id, amount) VALUES (?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE amount = amount + ?")) {
|
||||
statement.setInt(1, habboId);
|
||||
statement.setInt(2, achievement.id);
|
||||
@@ -360,7 +361,7 @@ public class AchievementManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (level.badges != null) {
|
||||
if (level.badges != null && level.badges.length > 0) {
|
||||
for (String badge : level.badges) {
|
||||
if (!badge.isEmpty()) {
|
||||
if (!habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
|
||||
@@ -373,11 +374,10 @@ public class AchievementManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (level.perks != null) {
|
||||
if (level.perks != null && level.perks.length > 0) {
|
||||
for (String perk : level.perks) {
|
||||
if (perk.equalsIgnoreCase("TRADE")) {
|
||||
habbo.getHabboStats().perkTrade = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.*;
|
||||
import com.eu.habbo.plugin.events.bots.BotChatEvent;
|
||||
import com.eu.habbo.plugin.events.bots.BotShoutEvent;
|
||||
@@ -21,7 +20,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Bot implements Runnable {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class);
|
||||
@@ -113,7 +111,7 @@ public class Bot implements Runnable {
|
||||
this.chatRandom = false;
|
||||
this.chatDelay = 10;
|
||||
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
|
||||
this.chatLines = new ArrayList<>(List.of("Default Message :D"));
|
||||
this.chatLines = new ArrayList<>(Arrays.asList("Default Message :D"));
|
||||
this.type = bot.getType();
|
||||
this.effect = bot.getEffect();
|
||||
this.bubble = bot.getBubbleId();
|
||||
@@ -140,26 +138,30 @@ public class Bot implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) {
|
||||
statement.setString(1, this.name);
|
||||
statement.setString(2, this.motto);
|
||||
statement.setString(3, this.figure);
|
||||
statement.setString(4, this.gender.toString());
|
||||
statement.setInt(5, this.ownerId);
|
||||
statement.setInt(6, this.room == null ? 0 : this.room.getId());
|
||||
statement.setInt(7, this.roomUnit == null ? 0 : this.roomUnit.getDanceType().getType());
|
||||
statement.setString(8, this.canWalk ? "1" : "0");
|
||||
statement.setInt(7, this.roomUnit == null ? 0 : this.roomUnit.getX());
|
||||
statement.setInt(8, this.roomUnit == null ? 0 : this.roomUnit.getY());
|
||||
statement.setDouble(9, this.roomUnit == null ? 0 : this.roomUnit.getZ());
|
||||
statement.setInt(10, this.roomUnit == null ? 0 : this.roomUnit.getBodyRotation().getValue());
|
||||
statement.setInt(11, this.roomUnit == null ? 0 : this.roomUnit.getDanceType().getType());
|
||||
statement.setString(12, this.canWalk ? "1" : "0");
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (String s : this.chatLines) {
|
||||
text.append(s).append("\r");
|
||||
}
|
||||
statement.setString(9, text.toString());
|
||||
statement.setString(10, this.chatAuto ? "1" : "0");
|
||||
statement.setString(11, this.chatRandom ? "1" : "0");
|
||||
statement.setInt(12, this.chatDelay);
|
||||
statement.setInt(13, this.effect);
|
||||
statement.setInt(14, this.bubble);
|
||||
statement.setInt(15, this.id);
|
||||
statement.setString(13, text.toString());
|
||||
statement.setString(14, this.chatAuto ? "1" : "0");
|
||||
statement.setString(15, this.chatRandom ? "1" : "0");
|
||||
statement.setInt(16, this.chatDelay);
|
||||
statement.setInt(17, this.effect);
|
||||
statement.setInt(18, this.bubble);
|
||||
statement.setInt(19, this.id);
|
||||
statement.execute();
|
||||
this.needsUpdate = false;
|
||||
} catch (SQLException e) {
|
||||
@@ -177,7 +179,7 @@ public class Bot implements Runnable {
|
||||
Bot.BOT_LIMIT_WALKING_DISTANCE
|
||||
? this.room.getRandomWalkableTilesAround(
|
||||
this.getRoomUnit(),
|
||||
this.room.getLayout().getTile(this.roomUnit.getX(), this.roomUnit.getY()),
|
||||
this.room.getLayout().getTile(this.roomUnit.getBotStartLocation().x, this.roomUnit.getBotStartLocation().y),
|
||||
Bot.BOT_WALKING_DISTANCE_RADIUS)
|
||||
: this.room.getRandomWalkableTile()
|
||||
);
|
||||
@@ -187,7 +189,7 @@ public class Bot implements Runnable {
|
||||
}
|
||||
}/* else {
|
||||
for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) {
|
||||
WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray());
|
||||
WiredManager.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -205,7 +207,7 @@ public class Bot implements Runnable {
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getUserCount() + "");
|
||||
|
||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{ message })) {
|
||||
if(!WiredManager.triggerUserSays(room, this.getRoomUnit(), message)) {
|
||||
this.talk(message);
|
||||
}
|
||||
|
||||
@@ -273,7 +275,7 @@ public class Bot implements Runnable {
|
||||
|
||||
if(PLACEMENT_MESSAGES.length > 0) {
|
||||
String message = PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)];
|
||||
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{message})) {
|
||||
if (!WiredManager.triggerUserSays(room, this.getRoomUnit(), message)) {
|
||||
this.talk(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ package com.eu.habbo.habbohotel.bots;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.plugin.events.bots.BotServerItemEvent;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit;
|
||||
@@ -100,7 +99,7 @@ public class ButlerBot extends Bot {
|
||||
.replace("%key%", key)
|
||||
.replace("%username%", serveEvent.habbo.getHabboInfo().getUsername());
|
||||
|
||||
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{ botMessage })) {
|
||||
if (!WiredManager.triggerUserSays(this.getRoom(), this.getRoomUnit(), botMessage)) {
|
||||
bot.talk(botMessage);
|
||||
}
|
||||
}
|
||||
@@ -128,7 +127,7 @@ public class ButlerBot extends Bot {
|
||||
this.getRoom().giveHandItem(serveEvent.habbo, serveEvent.itemId);
|
||||
|
||||
String msg = Emulator.getTexts().getValue("bots.butler.given").replace("%key%", keyword).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername());
|
||||
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{msg})) {
|
||||
if (!WiredManager.triggerUserSays(this.getRoom(), this.getRoomUnit(), msg)) {
|
||||
this.talk(msg);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -9,10 +9,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.time.temporal.ChronoUnit.DAYS;
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class CatalogPage implements Comparable<CatalogPage>, ISerialize
|
||||
if (!set.getString("includes").isEmpty()) {
|
||||
for (String id : set.getString("includes").split(";")) {
|
||||
try {
|
||||
this.included.add(Integer.parseInt(id));
|
||||
this.included.add(Integer.valueOf(id));
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
LOGGER.error("Failed to parse includes column value of ({}) for catalog page ({})", id, this.id);
|
||||
|
||||
+12
-9
@@ -26,7 +26,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public final class MarketPlace {
|
||||
public class MarketPlace {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlace.class);
|
||||
|
||||
//Configuration. Loaded from database & updated accordingly.
|
||||
@@ -142,9 +142,10 @@ public final class MarketPlace {
|
||||
case 2:
|
||||
query += " ORDER BY minPrice ASC";
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
case 1:
|
||||
query += " ORDER BY minPrice DESC";
|
||||
break;
|
||||
}
|
||||
|
||||
query += ")";
|
||||
@@ -365,13 +366,15 @@ public final class MarketPlace {
|
||||
THashSet<MarketPlaceOffer> offers = new THashSet<>();
|
||||
offers.addAll(client.getHabbo().getInventory().getMarketplaceItems());
|
||||
|
||||
for (MarketPlaceOffer offer : offers) {
|
||||
if (offer.getState().equals(MarketPlaceState.SOLD)) {
|
||||
client.getHabbo().getInventory().removeMarketplaceOffer(offer);
|
||||
credits += offer.getPrice();
|
||||
removeUser(offer);
|
||||
offer.needsUpdate(true);
|
||||
Emulator.getThreading().run(offer);
|
||||
synchronized (client.getHabbo().getInventory()) {
|
||||
for (MarketPlaceOffer offer : offers) {
|
||||
if (offer.getState().equals(MarketPlaceState.SOLD)) {
|
||||
client.getHabbo().getInventory().removeMarketplaceOffer(offer);
|
||||
credits += offer.getPrice();
|
||||
removeUser(offer);
|
||||
offer.needsUpdate(true);
|
||||
Emulator.getThreading().run(offer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ public class MarketPlaceOffer implements Runnable {
|
||||
public int avarage;
|
||||
public int count;
|
||||
private int offerId;
|
||||
private final Item baseItem;
|
||||
private final int itemId;
|
||||
private Item baseItem;
|
||||
private int itemId;
|
||||
private int price;
|
||||
private int limitedStack;
|
||||
private int limitedNumber;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class AboutCommand extends Command {
|
||||
}
|
||||
public static String credits = "Arcturus Morningstar is an opensource project based on Arcturus By TheGeneral \n" +
|
||||
"The Following people have all contributed to this emulator:\n" +
|
||||
" TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Quadral \n Harmony\n Swirny\n ArpyAge\n Mikkel\n Rodolfo\n Rasmus\n Kitt Mustang\n Snaiker\n nttzx\n necmi\n Dome\n Jose Flores\n Cam\n Oliver\n Narzo\n Tenshie\n MartenM\n Ridge\n SenpaiDipper\n Snaiker\n Thijmen\n DuckieTM";
|
||||
" TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Quadral \n Harmony\n Swirny\n ArpyAge\n Mikkel\n Rodolfo\n Rasmus\n Kitt Mustang\n Snaiker\n nttzx\n necmi\n Dome\n Jose Flores\n Cam\n Oliver\n Narzo\n Tenshie\n MartenM\n Ridge\n SenpaiDipper\n Snaiker\n Thijmen";
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) {
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ public class CommandHandler {
|
||||
addCommand(new ControlCommand());
|
||||
addCommand(new CoordsCommand());
|
||||
addCommand(new CreditsCommand());
|
||||
addCommand(new DanceCommand());
|
||||
addCommand(new DanceCommand());
|
||||
addCommand(new DiagonalCommand());
|
||||
addCommand(new DisconnectCommand());
|
||||
addCommand(new EjectAllCommand());
|
||||
@@ -231,7 +231,7 @@ public class CommandHandler {
|
||||
addCommand(new MutePetsCommand());
|
||||
addCommand(new PetInfoCommand());
|
||||
addCommand(new PickallCommand());
|
||||
addCommand(new PingCommand());
|
||||
addCommand(new PingCommand());
|
||||
addCommand(new PixelCommand());
|
||||
addCommand(new PluginsCommand());
|
||||
addCommand(new PointsCommand());
|
||||
@@ -296,6 +296,7 @@ public class CommandHandler {
|
||||
addCommand(new AddYoutubePlaylistCommand());
|
||||
addCommand(new SoftKickCommand());
|
||||
addCommand(new SubscriptionCommand());
|
||||
addCommand(new UpdateChatBubblesCommand());
|
||||
|
||||
addCommand(new TestCommand());
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||
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.core.WiredManager;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
|
||||
@@ -31,7 +30,7 @@ public class InvisibleCommand extends Command {
|
||||
roomUnit.getRoom().sendComposer(new RoomUsersComposer(gameClient.getHabbo()).compose());
|
||||
roomUnit.getRoom().sendComposer(new RoomUserStatusComposer(roomUnit).compose());
|
||||
|
||||
WiredHandler.handle(WiredTriggerType.ENTER_ROOM, roomUnit, roomUnit.getRoom(), null);
|
||||
WiredManager.triggerUserEntersRoom(roomUnit.getRoom(), roomUnit);
|
||||
roomUnit.getRoom().habboEntered(gameClient.getHabbo());
|
||||
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_invisible.updated.back"));
|
||||
|
||||
@@ -24,7 +24,8 @@ public class PetInfoCommand extends Command {
|
||||
@Override
|
||||
public boolean execute(int a, Pet pet) {
|
||||
if (pet.getName().equalsIgnoreCase(name)) {
|
||||
gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" +
|
||||
gameClient.getHabbo().alert("" +
|
||||
Emulator.getTexts().getValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" +
|
||||
Emulator.getTexts().getValue("generic.pet.id") + ": " + pet.getId() + "\r" +
|
||||
Emulator.getTexts().getValue("generic.pet.name") + ": " + pet.getName() + "\r" +
|
||||
Emulator.getTexts().getValue("generic.pet.age") + ": " + pet.daysAlive() + " " + Emulator.getTexts().getValue("generic.pet.days.alive") + "\r" +
|
||||
@@ -37,7 +38,7 @@ public class PetInfoCommand extends Command {
|
||||
Emulator.getTexts().getValue("generic.pet.level.thirst") + ": " + pet.levelThirst + "\r" +
|
||||
Emulator.getTexts().getValue("generic.pet.level.hunger") + ": " + pet.levelHunger + "\r" +
|
||||
Emulator.getTexts().getValue("generic.pet.current_action") + ": " + (pet.getTask() == null ? Emulator.getTexts().getValue("generic.nothing") : pet.getTask().name()) + "\r" +
|
||||
Emulator.getTexts().getValue("generic.can.walk") + ": " + (pet.getRoomUnit().canWalk() ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no"))
|
||||
Emulator.getTexts().getValue("generic.can.walk") + ": " + (pet.getRoomUnit().canWalk() ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + ""
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ public class PixelCommand extends Command {
|
||||
if (Integer.parseInt(params[2]) != 0) {
|
||||
habbo.givePixels(Integer.parseInt(params[2]));
|
||||
if (habbo.getHabboInfo().getCurrentRoom() != null)
|
||||
habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.parseInt(params[2]) + ""), RoomChatMessageBubbles.ALERT);
|
||||
habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(params[2]) + ""), RoomChatMessageBubbles.ALERT);
|
||||
else
|
||||
habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.parseInt(params[2]) + ""));
|
||||
habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(params[2]) + ""));
|
||||
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_duckets.send").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_duckets.send").replace("%amount%", Integer.valueOf(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
||||
|
||||
} else {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_duckets.invalid_amount"), RoomChatMessageBubbles.ALERT);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class RedeemCommand extends Command {
|
||||
|
||||
if (pixels > 0) {
|
||||
message[0] += ", " + Emulator.getTexts().getValue("generic.pixels");
|
||||
message[0] += ": " + pixels;
|
||||
message[0] += ": " + pixels + "";
|
||||
}
|
||||
|
||||
if (!points.isEmpty()) {
|
||||
|
||||
@@ -26,27 +26,14 @@ public class SetSpeedCommand extends Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
// First check against the config bounds
|
||||
int configMax = Emulator.getConfig().getInt("hotel.rollers.speed.maximum");
|
||||
if (newSpeed < -1 || newSpeed > configMax) {
|
||||
if (newSpeed < -1 || newSpeed > Emulator.getConfig().getInt("hotel.rollers.speed.maximum")) {
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_setspeed.bounds"), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Enforce maximum speed of 10 regardless of config.
|
||||
if (newSpeed > 10) {
|
||||
newSpeed = 10;
|
||||
gameClient.getHabbo().whisper("Speed cannot be set above 10. Setting speed to 10.", RoomChatMessageBubbles.ALERT);
|
||||
}
|
||||
|
||||
room.setRollerSpeed(newSpeed);
|
||||
|
||||
gameClient.getHabbo().whisper(
|
||||
Emulator.getTexts().getValue("commands.succes.cmd_setspeed")
|
||||
.replace("%oldspeed%", oldSpeed + "")
|
||||
.replace("%newspeed%", newSpeed + ""),
|
||||
RoomChatMessageBubbles.ALERT
|
||||
);
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_setspeed").replace("%oldspeed%", oldSpeed + "").replace("%newspeed%", newSpeed + ""), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ public class TestCommand extends Command {
|
||||
message.appendString("");
|
||||
}
|
||||
} else if (data[0].equals("i")) {
|
||||
message.appendInt(Integer.parseInt(data[1]));
|
||||
message.appendInt(Integer.valueOf(data[1]));
|
||||
} else if (data[0].equalsIgnoreCase("by")) {
|
||||
message.appendByte(Integer.parseInt(data[1]));
|
||||
message.appendByte(Integer.valueOf(data[1]));
|
||||
} else if (data[0].equalsIgnoreCase("sh")) {
|
||||
message.appendShort(Integer.parseInt(data[1]));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
|
||||
public class UpdateChatBubblesCommand extends Command {
|
||||
|
||||
public UpdateChatBubblesCommand() {
|
||||
super("cmd_update_chat_bubbles", Emulator.getTexts().getValue("commands.keys.cmd_update_chat_bubbles").split(";"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) {
|
||||
RoomChatMessageBubbles.removeDynamicBubbles();
|
||||
Emulator.getGameEnvironment().getRoomChatBubbleManager().reload();
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.success.cmd_update_chat_bubbles"), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ 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.MessageComposer;
|
||||
import com.eu.habbo.plugin.events.emulator.OutgoingPacketEvent;
|
||||
import io.netty.channel.Channel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -20,7 +21,8 @@ public class GameClient {
|
||||
|
||||
private final Channel channel;
|
||||
private final HabboEncryption encryption;
|
||||
private final LatencyTracker latencyTracker;
|
||||
private final LatencyTracker latencyTracker;
|
||||
|
||||
private Habbo habbo;
|
||||
private boolean handshakeFinished;
|
||||
private String machineId = "";
|
||||
@@ -37,7 +39,7 @@ public class GameClient {
|
||||
Emulator.getCrypto().getModulus(),
|
||||
Emulator.getCrypto().getPrivateExponent())
|
||||
: null;
|
||||
this.latencyTracker = new LatencyTracker();
|
||||
this.latencyTracker = new LatencyTracker();
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
@@ -47,8 +49,10 @@ public class GameClient {
|
||||
public HabboEncryption getEncryption() {
|
||||
return encryption;
|
||||
}
|
||||
|
||||
public LatencyTracker getLatencyTracker() { return latencyTracker; }
|
||||
|
||||
public LatencyTracker getLatencyTracker() {
|
||||
return latencyTracker;
|
||||
}
|
||||
|
||||
public Habbo getHabbo() {
|
||||
return this.habbo;
|
||||
@@ -88,6 +92,17 @@ public class GameClient {
|
||||
return;
|
||||
}
|
||||
|
||||
OutgoingPacketEvent event = new OutgoingPacketEvent(this.habbo, response.getComposer(), response);
|
||||
Emulator.getPluginManager().fireEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.hasCustomMessage()) {
|
||||
response = event.getCustomMessage();
|
||||
}
|
||||
|
||||
this.channel.write(response, this.channel.voidPromise());
|
||||
this.channel.flush();
|
||||
}
|
||||
@@ -100,14 +115,25 @@ public class GameClient {
|
||||
return;
|
||||
}
|
||||
|
||||
OutgoingPacketEvent event = new OutgoingPacketEvent(this.habbo, response.getComposer(), response);
|
||||
Emulator.getPluginManager().fireEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event.hasCustomMessage()) {
|
||||
response = event.getCustomMessage();
|
||||
}
|
||||
|
||||
this.channel.write(response);
|
||||
}
|
||||
|
||||
this.channel.flush();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendKeepAlive() {
|
||||
|
||||
public void sendKeepAlive() {
|
||||
if (this.channel != null && this.channel.isOpen()) {
|
||||
this.channel.writeAndFlush(new ServerMessage(-1));
|
||||
}
|
||||
|
||||
@@ -5,13 +5,11 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreDataEntry;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreDataEntry;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.outgoing.guides.GuideSessionPartnerIsPlayingComposer;
|
||||
import com.eu.habbo.plugin.Event;
|
||||
import com.eu.habbo.plugin.events.games.GameHabboJoinEvent;
|
||||
@@ -153,7 +151,7 @@ public abstract class Game implements Runnable {
|
||||
|
||||
if (winningTeam != null) {
|
||||
for (GamePlayer player : winningTeam.getMembers()) {
|
||||
WiredHandler.handleCustomTrigger(WiredTriggerTeamWins.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this});
|
||||
WiredManager.triggerTeamWins(this.room, player.getHabbo().getRoomUnit());
|
||||
|
||||
Habbo winner = player.getHabbo();
|
||||
if (winner != null) {
|
||||
@@ -171,7 +169,7 @@ public abstract class Game implements Runnable {
|
||||
if (team == winningTeam) continue;
|
||||
|
||||
for (GamePlayer player : team.getMembers()) {
|
||||
WiredHandler.handleCustomTrigger(WiredTriggerTeamLoses.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this});
|
||||
WiredManager.triggerTeamLoses(this.room, player.getHabbo().getRoomUnit());
|
||||
}
|
||||
|
||||
if (team.getMembers().size() > 0 && team.getTotalScore() > 0) {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.eu.habbo.habbohotel.games;
|
||||
|
||||
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.core.WiredManager;
|
||||
|
||||
public class GamePlayer {
|
||||
|
||||
private final Habbo habbo;
|
||||
|
||||
|
||||
private final GameTeamColors teamColor;
|
||||
private GameTeamColors teamColor;
|
||||
|
||||
|
||||
private int score;
|
||||
@@ -41,7 +40,7 @@ public class GamePlayer {
|
||||
this.wiredScore += amount;
|
||||
}
|
||||
|
||||
WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
|
||||
WiredManager.triggerScoreAchieved(this.habbo.getHabboInfo().getCurrentRoom(), this.habbo.getRoomUnit(), this.score);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.Map;
|
||||
|
||||
|
||||
public class FootballGame extends Game {
|
||||
private final Room room;
|
||||
private Room room;
|
||||
|
||||
public FootballGame(Room room) {
|
||||
super(null, null, room, true);
|
||||
|
||||
@@ -5,16 +5,16 @@ import java.sql.SQLException;
|
||||
|
||||
public class HallOfFameWinner implements Comparable<HallOfFameWinner> {
|
||||
|
||||
private final int id;
|
||||
private int id;
|
||||
|
||||
|
||||
private final String username;
|
||||
private String username;
|
||||
|
||||
|
||||
private final String look;
|
||||
private String look;
|
||||
|
||||
|
||||
private final int points;
|
||||
private int points;
|
||||
|
||||
public HallOfFameWinner(ResultSet set) throws SQLException {
|
||||
this.id = set.getInt("id");
|
||||
|
||||
@@ -3,10 +3,7 @@ package com.eu.habbo.habbohotel.items;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiPuck;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTeleporter;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates.InteractionBattleBanzaiGateBlue;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates.InteractionBattleBanzaiGateGreen;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates.InteractionBattleBanzaiGateRed;
|
||||
@@ -48,12 +45,13 @@ import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemPlanet;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.conditions.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.effects.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraOrEval;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.*;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager;
|
||||
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
|
||||
import com.eu.habbo.plugin.events.emulator.EmulatorLoadItemsManagerEvent;
|
||||
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
|
||||
@@ -170,6 +168,7 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("youtube", InteractionYoutubeTV.class));
|
||||
this.interactionsList.add(new ItemInteraction("jukebox", InteractionJukeBox.class));
|
||||
this.interactionsList.add(new ItemInteraction("switch", InteractionSwitch.class));
|
||||
this.interactionsList.add(new ItemInteraction("switch_remote_control", InteractionSwitchRemoteControl.class));
|
||||
this.interactionsList.add(new ItemInteraction("fx_box", InteractionFXBox.class));
|
||||
this.interactionsList.add(new ItemInteraction("blackhole", InteractionBlackHole.class));
|
||||
this.interactionsList.add(new ItemInteraction("effect_toggle", InteractionEffectToggle.class));
|
||||
@@ -191,6 +190,7 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class));
|
||||
this.interactionsList.add(new ItemInteraction("random_state", InteractionRandomState.class));
|
||||
this.interactionsList.add(new ItemInteraction("vendingmachine_no_sides", InteractionNoSidesVendingMachine.class));
|
||||
this.interactionsList.add(new ItemInteraction("tile_walkmagic", InteractionTileWalkMagic.class));
|
||||
|
||||
this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class));
|
||||
|
||||
@@ -268,11 +268,13 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("wf_cnd_trggrer_on_frn", WiredConditionTriggerOnFurni.class));
|
||||
this.interactionsList.add(new ItemInteraction("wf_cnd_has_handitem", WiredConditionHabboHasHandItem.class));
|
||||
this.interactionsList.add(new ItemInteraction("wf_cnd_date_rng_active", WiredConditionDateRangeActive.class));
|
||||
this.interactionsList.add(new ItemInteraction("wf_cnd_valid_moves", WiredConditionMovementValidation.class));
|
||||
|
||||
|
||||
this.interactionsList.add(new ItemInteraction("wf_xtra_random", WiredExtraRandom.class));
|
||||
this.interactionsList.add(new ItemInteraction("wf_xtra_unseen", WiredExtraUnseen.class));
|
||||
this.interactionsList.add(new ItemInteraction("wf_blob", WiredBlob.class));
|
||||
this.interactionsList.add(new ItemInteraction("wf_xtra_or_eval", WiredExtraOrEval.class));
|
||||
|
||||
|
||||
this.interactionsList.add(new ItemInteraction("wf_highscore", InteractionWiredHighscore.class));
|
||||
@@ -344,9 +346,7 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("totem_leg", InteractionTotemLegs.class));
|
||||
this.interactionsList.add(new ItemInteraction("totem_head", InteractionTotemHead.class));
|
||||
this.interactionsList.add(new ItemInteraction("totem_planet", InteractionTotemPlanet.class));
|
||||
|
||||
this.interactionsList.add(new ItemInteraction("tile_walkmagic", InteractionTileWalkMagic.class));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addItemInteraction(ItemInteraction itemInteraction) {
|
||||
@@ -519,20 +519,6 @@ public class ItemManager {
|
||||
}
|
||||
}
|
||||
|
||||
public HabboItem createItemNoSql(int habboId, Item item, int limitedStack, int limitedSells, String extraData) {
|
||||
Class<? extends HabboItem> itemClass = item.getInteractionType().getType();
|
||||
int id = new Random().nextInt(10000000) + 1000000000;
|
||||
if (itemClass != null) {
|
||||
try {
|
||||
return itemClass.getDeclaredConstructor(int.class, int.class, Item.class, String.class, int.class, int.class).newInstance(id, habboId, item, extraData, limitedStack, limitedSells);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
return new InteractionDefault(id, habboId, item, extraData, limitedStack, limitedSells);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addNewUserGift(NewUserGift gift) {
|
||||
this.newuserGifts.put(gift.getId(), gift);
|
||||
}
|
||||
@@ -784,7 +770,6 @@ public class ItemManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public YoutubeManager getYoutubeManager() {
|
||||
return this.youtubeManager;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class SoundTrack {
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final String author;
|
||||
private final String code;
|
||||
private final String data;
|
||||
private final int length;
|
||||
private int id;
|
||||
private String name;
|
||||
private String author;
|
||||
private String code;
|
||||
private String data;
|
||||
private int length;
|
||||
|
||||
public SoundTrack(ResultSet set) throws SQLException {
|
||||
this.id = set.getInt("id");
|
||||
|
||||
@@ -16,10 +16,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.*;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
+4
-4
@@ -28,10 +28,10 @@ public class InteractionBackgroundToner extends HabboItem {
|
||||
serverMessage.appendInt(4);
|
||||
if (this.getExtradata().split(":").length == 4) {
|
||||
String[] colorData = this.getExtradata().split(":");
|
||||
serverMessage.appendInt(Integer.parseInt(colorData[0]));
|
||||
serverMessage.appendInt(Integer.parseInt(colorData[1]));
|
||||
serverMessage.appendInt(Integer.parseInt(colorData[2]));
|
||||
serverMessage.appendInt(Integer.parseInt(colorData[3]));
|
||||
serverMessage.appendInt(Integer.valueOf(colorData[0]));
|
||||
serverMessage.appendInt(Integer.valueOf(colorData[1]));
|
||||
serverMessage.appendInt(Integer.valueOf(colorData[2]));
|
||||
serverMessage.appendInt(Integer.valueOf(colorData[3]));
|
||||
} else {
|
||||
serverMessage.appendInt(0);
|
||||
serverMessage.appendInt(126);
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
|
||||
}
|
||||
};
|
||||
|
||||
private final THashSet<RoomTile> tiles;
|
||||
private THashSet<RoomTile> tiles;
|
||||
|
||||
public InteractionBuildArea(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem, defaultValues);
|
||||
|
||||
+25
-20
@@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
@@ -12,6 +13,7 @@ import com.eu.habbo.threading.runnables.CannonResetCooldownAction;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public class InteractionCannon extends HabboItem {
|
||||
public boolean cooldown = false;
|
||||
@@ -46,30 +48,33 @@ public class InteractionCannon extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if (client != null) {
|
||||
super.onClick(client, room, objects);
|
||||
}
|
||||
|
||||
if (room == null)
|
||||
return;
|
||||
|
||||
if (client != null) {
|
||||
RoomUnit roomUnit = client.getHabbo().getRoomUnit();
|
||||
int rotation = this.getRotation();
|
||||
int dx = (rotation == 4) ? -1 : (rotation == 0) ? 2 : 0;
|
||||
int dy = (rotation == 2) ? 2 : (rotation == 6) ? -1 : 0;
|
||||
int x = this.getX() + dx;
|
||||
int y = this.getY() + dy;
|
||||
if (roomUnit.getX() == x && roomUnit.getY() == y) {
|
||||
this.shoot(room, client);
|
||||
}
|
||||
} else {
|
||||
this.shoot(room, null);
|
||||
}
|
||||
}
|
||||
RoomTile tile = room.getLayout().getTile(this.getX(), this.getY());
|
||||
RoomTile fuseTile = this.getRotation() >= 4 ? tile : room.getLayout().getTileInFront(tile, ((this.getRotation() % 2) + 2) % 8);
|
||||
List<RoomTile> tiles = room.getLayout().getTilesAround(fuseTile);
|
||||
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? -1 : 0)) % 8));
|
||||
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? 5 : 4)) % 8));
|
||||
|
||||
private void shoot(Room room, GameClient client) {
|
||||
this.cooldown = true;
|
||||
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
|
||||
room.updateItemState(this);
|
||||
Emulator.getThreading().run(new CannonKickAction(this, room, client), 750);
|
||||
Emulator.getThreading().run(new CannonResetCooldownAction(this), 2000);
|
||||
if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentLocation())) && client.getHabbo().getRoomUnit().canWalk()) && !this.cooldown) {
|
||||
if (client != null) {
|
||||
client.getHabbo().getRoomUnit().setCanWalk(false);
|
||||
client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentLocation());
|
||||
client.getHabbo().getRoomUnit().lookAtPoint(fuseTile);
|
||||
client.getHabbo().getRoomUnit().statusUpdate(true);
|
||||
}
|
||||
|
||||
this.cooldown = true;
|
||||
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
|
||||
room.updateItemState(this);
|
||||
Emulator.getThreading().run(new CannonKickAction(this, room, client), 750);
|
||||
Emulator.getThreading().run(new CannonResetCooldownAction(this), 2000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class InteractionCrackable extends HabboItem {
|
||||
serverMessage.appendInt(7 + (this.isLimited() ? 256 : 0));
|
||||
|
||||
serverMessage.appendString(Emulator.getGameEnvironment().getItemManager().calculateCrackState(Integer.parseInt(this.getExtradata()), Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()), this.getBaseItem()) + "");
|
||||
serverMessage.appendInt(Integer.parseInt(this.getExtradata()));
|
||||
serverMessage.appendInt(Integer.valueOf(this.getExtradata()));
|
||||
serverMessage.appendInt(Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()));
|
||||
|
||||
super.serializeExtradata(serverMessage);
|
||||
|
||||
+2
-1
@@ -143,7 +143,8 @@ public class InteractionDefault extends HabboItem {
|
||||
int nextEffectF = 0;
|
||||
|
||||
if (objects != null && objects.length == 2) {
|
||||
if (objects[0] instanceof RoomTile goalTile && objects[1] instanceof RoomTile) {
|
||||
if (objects[0] instanceof RoomTile && objects[1] instanceof RoomTile) {
|
||||
RoomTile goalTile = (RoomTile) objects[0];
|
||||
HabboItem topItem = room.getTopItemAt(goalTile.x, goalTile.y, (objects[0] != objects[1]) ? this : null);
|
||||
|
||||
if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) {
|
||||
|
||||
+2
-3
@@ -8,8 +8,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitType;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -38,7 +37,7 @@ public class InteractionEffectTile extends InteractionPressurePlate {
|
||||
Emulator.getThreading().run(() -> updateState(room), 100);
|
||||
|
||||
if(objects != null && objects.length > 0) {
|
||||
WiredHandler.handle(WiredTriggerType.WALKS_OFF_FURNI, roomUnit, room, new Object[]{this});
|
||||
WiredManager.triggerUserWalksOff(room, roomUnit, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class InteractionMuteArea extends InteractionCustomValues {
|
||||
}
|
||||
};
|
||||
|
||||
private final THashSet<RoomTile> tiles;
|
||||
private THashSet<RoomTile> tiles;
|
||||
|
||||
public InteractionMuteArea(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem, defaultValues);
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.Objects;
|
||||
|
||||
public class InteractionObstacle extends HabboItem implements ICycleable {
|
||||
|
||||
private final THashSet<RoomTile> middleTiles;
|
||||
private THashSet<RoomTile> middleTiles;
|
||||
|
||||
public InteractionObstacle(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
|
||||
+4
-3
@@ -7,8 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemIntStateComposer;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||
@@ -89,7 +88,9 @@ public class InteractionOneWayGate extends HabboItem {
|
||||
unit.setGoalLocation(tile);
|
||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail));
|
||||
|
||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500);
|
||||
Emulator.getThreading().run(() -> {
|
||||
WiredManager.triggerUserWalksOn(room, unit, this);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
onFail.add(() -> {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class InteractionVoteCounter extends HabboItem {
|
||||
|
||||
private boolean frozen;
|
||||
private int votes;
|
||||
private final List<Integer> votedUsers;
|
||||
private List<Integer> votedUsers;
|
||||
|
||||
public InteractionVoteCounter(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
|
||||
+2
-1
@@ -274,7 +274,8 @@ public class InteractionWater extends InteractionDefault {
|
||||
|
||||
private boolean isValidForMask(Room room, int x, int y, double z, boolean corner) {
|
||||
for (HabboItem item : room.getItemsAt(x, y, z)) {
|
||||
if (item instanceof InteractionWater water) {
|
||||
if (item instanceof InteractionWater) {
|
||||
InteractionWater water = (InteractionWater) item;
|
||||
|
||||
// Take out picked up water from the recalculation.
|
||||
if (!water.isInRoom) {
|
||||
|
||||
+89
-5
@@ -15,12 +15,54 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Base abstract class for all wired furniture items (triggers, effects, conditions, extras).
|
||||
* <p>
|
||||
* The wired system allows room owners to create automated behaviors in their rooms.
|
||||
* It consists of:
|
||||
* <ul>
|
||||
* <li><b>Triggers</b> ({@link InteractionWiredTrigger}) - Events that start the wired chain</li>
|
||||
* <li><b>Conditions</b> ({@link InteractionWiredCondition}) - Requirements that must be met</li>
|
||||
* <li><b>Effects</b> ({@link InteractionWiredEffect}) - Actions that are executed</li>
|
||||
* <li><b>Extras</b> ({@link InteractionWiredExtra}) - Modifiers like random selection</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* <p>
|
||||
* Wired items at the same tile coordinates form a "stack" and execute together.
|
||||
* The {@link com.eu.habbo.habbohotel.wired.core.WiredManager} orchestrates execution.
|
||||
* </p>
|
||||
* <p>
|
||||
* Key features:
|
||||
* <ul>
|
||||
* <li>Cooldown system to prevent spam triggering</li>
|
||||
* <li>Per-user execution caching with automatic cleanup</li>
|
||||
* <li>JSON-based data persistence via {@link #getWiredData()}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
* @see com.eu.habbo.habbohotel.wired.core.WiredManager
|
||||
* @see com.eu.habbo.habbohotel.rooms.RoomSpecialTypes
|
||||
*/
|
||||
public abstract class InteractionWired extends InteractionDefault {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class);
|
||||
|
||||
/**
|
||||
* Maximum number of entries in the user execution cache to prevent memory leaks.
|
||||
*/
|
||||
private static final int MAX_USER_CACHE_SIZE = 500;
|
||||
|
||||
/**
|
||||
* Cache entries older than this (in milliseconds) will be cleaned up.
|
||||
* Default: 5 minutes
|
||||
*/
|
||||
private static final long CACHE_EXPIRY_MS = 5 * 60 * 1000;
|
||||
|
||||
private long cooldown;
|
||||
private final HashMap<Long,Long> userExecutionCache = new HashMap<>();
|
||||
private final ConcurrentHashMap<Long, Long> userExecutionCache = new ConcurrentHashMap<>();
|
||||
|
||||
InteractionWired(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@@ -32,6 +74,14 @@ public abstract class InteractionWired extends InteractionDefault {
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes this wired item's logic.
|
||||
*
|
||||
* @param roomUnit the room unit that triggered this (may be null for non-user triggers)
|
||||
* @param room the room where this is happening
|
||||
* @param stuff additional context data passed from the trigger
|
||||
* @return true if execution was successful, false otherwise
|
||||
*/
|
||||
public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff);
|
||||
|
||||
public abstract String getWiredData();
|
||||
@@ -72,7 +122,7 @@ public abstract class InteractionWired extends InteractionDefault {
|
||||
public abstract void onPickUp();
|
||||
|
||||
public void activateBox(Room room) {
|
||||
this.activateBox(room, null, 0L);
|
||||
this.activateBox(room, (RoomUnit)null, 0L);
|
||||
}
|
||||
|
||||
public void activateBox(Room room, RoomUnit roomUnit, long millis) {
|
||||
@@ -126,7 +176,41 @@ public abstract class InteractionWired extends InteractionDefault {
|
||||
}
|
||||
|
||||
public void addUserExecutionCache(int roomUnitId, long timestamp) {
|
||||
this.userExecutionCache.put((long)roomUnitId, timestamp);
|
||||
// Enforce max size limit to prevent memory leaks
|
||||
if (this.userExecutionCache.size() >= MAX_USER_CACHE_SIZE) {
|
||||
cleanExpiredCacheEntries(timestamp);
|
||||
|
||||
// If still too large after cleanup, remove oldest entries
|
||||
if (this.userExecutionCache.size() >= MAX_USER_CACHE_SIZE) {
|
||||
// Remove approximately 10% of entries
|
||||
int toRemove = MAX_USER_CACHE_SIZE / 10;
|
||||
Iterator<Map.Entry<Long, Long>> iterator = this.userExecutionCache.entrySet().iterator();
|
||||
while (iterator.hasNext() && toRemove > 0) {
|
||||
iterator.next();
|
||||
iterator.remove();
|
||||
toRemove--;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.userExecutionCache.put((long) roomUnitId, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes cache entries older than CACHE_EXPIRY_MS.
|
||||
* @param currentTimestamp the current timestamp to compare against
|
||||
*/
|
||||
public void cleanExpiredCacheEntries(long currentTimestamp) {
|
||||
this.userExecutionCache.entrySet().removeIf(
|
||||
entry -> currentTimestamp - entry.getValue() > CACHE_EXPIRY_MS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current size of the user execution cache.
|
||||
* @return the number of cached entries
|
||||
*/
|
||||
public int getUserExecutionCacheSize() {
|
||||
return this.userExecutionCache.size();
|
||||
}
|
||||
|
||||
public static WiredSettings readSettings(ClientMessage packet, boolean isEffect)
|
||||
@@ -159,4 +243,4 @@ public abstract class InteractionWired extends InteractionDefault {
|
||||
settings.setStuffTypeSelectionCode(packet.readInt());
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-1
@@ -7,12 +7,21 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.api.IWiredCondition;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public abstract class InteractionWiredCondition extends InteractionWired {
|
||||
/**
|
||||
* Base class for all wired conditions in the game.
|
||||
* <p>
|
||||
* Conditions are evaluated before effects execute to determine if they should run.
|
||||
* They now implement {@link IWiredCondition} for the new context-driven architecture.
|
||||
* </p>
|
||||
*/
|
||||
public abstract class InteractionWiredCondition extends InteractionWired implements IWiredCondition {
|
||||
public InteractionWiredCondition(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
@@ -48,5 +57,17 @@ public abstract class InteractionWiredCondition extends InteractionWired {
|
||||
public WiredConditionOperator operator() {
|
||||
return WiredConditionOperator.AND;
|
||||
}
|
||||
|
||||
// ========== IWiredCondition Implementation ==========
|
||||
|
||||
/**
|
||||
* Evaluates whether this condition passes.
|
||||
* Subclasses must implement this to define their evaluation logic.
|
||||
*
|
||||
* @param ctx the wired context containing event data
|
||||
* @return true if the condition passes
|
||||
*/
|
||||
@Override
|
||||
public abstract boolean evaluate(WiredContext ctx);
|
||||
|
||||
}
|
||||
|
||||
+140
-1
@@ -1,18 +1,60 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.api.IWiredEffect;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class InteractionWiredEffect extends InteractionWired {
|
||||
/**
|
||||
* Base class for all wired effects in the game.
|
||||
* <p>
|
||||
* Wired effects are triggered by {@link InteractionWiredTrigger} when conditions
|
||||
* (defined by {@link InteractionWiredCondition}) are met. Effects can perform
|
||||
* various actions like moving furniture, teleporting users, toggling states, etc.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subclasses must implement:
|
||||
* <ul>
|
||||
* <li>{@link #execute(RoomUnit, Room, Object[])} - The actual effect logic</li>
|
||||
* <li>{@link #getType()} - Returns the effect type enum</li>
|
||||
* <li>{@link #saveData(WiredSettings, GameClient)} - Saves configuration from client</li>
|
||||
* <li>{@link #getWiredData()} - Serializes data for database storage</li>
|
||||
* <li>{@link #loadWiredData(java.sql.ResultSet, Room)} - Loads data from database</li>
|
||||
* <li>{@link #serializeWiredData(com.eu.habbo.messages.ServerMessage, Room)} - Sends config to client</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
* @see InteractionWiredTrigger
|
||||
* @see InteractionWiredCondition
|
||||
* @see com.eu.habbo.habbohotel.wired.core.WiredManager
|
||||
*/
|
||||
public abstract class InteractionWiredEffect extends InteractionWired implements IWiredEffect {
|
||||
|
||||
// Common cooldown constants (in milliseconds)
|
||||
/** No cooldown - effect can trigger as fast as possible */
|
||||
public static final long COOLDOWN_NONE = 0L;
|
||||
/** Default cooldown for most effects */
|
||||
public static final long COOLDOWN_DEFAULT = 50L;
|
||||
/** Cooldown for movement effects (move to, move towards, move away) */
|
||||
public static final long COOLDOWN_MOVEMENT = 495L;
|
||||
/** Cooldown for trigger stacks effect to prevent rapid re-triggering */
|
||||
public static final long COOLDOWN_TRIGGER_STACKS = 250L;
|
||||
/** Cooldown for teleport effect */
|
||||
public static final long COOLDOWN_TELEPORT = 500L;
|
||||
|
||||
private int delay;
|
||||
|
||||
public InteractionWiredEffect(ResultSet set, Item baseItem) throws SQLException {
|
||||
@@ -55,8 +97,105 @@ public abstract class InteractionWiredEffect extends InteractionWired {
|
||||
|
||||
public abstract WiredEffectType getType();
|
||||
|
||||
// ========== IWiredEffect Implementation ==========
|
||||
|
||||
/**
|
||||
* Executes this effect with the given context.
|
||||
* Subclasses must implement this to define their effect logic.
|
||||
*
|
||||
* @param ctx the wired context containing event data
|
||||
*/
|
||||
@Override
|
||||
public abstract void execute(WiredContext ctx);
|
||||
|
||||
/**
|
||||
* Returns whether this effect requires an actor (user) to execute.
|
||||
*/
|
||||
@Override
|
||||
public boolean requiresActor() {
|
||||
return requiresTriggeringUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this effect requires a triggering user (RoomUnit) to execute.
|
||||
* Effects that require a user will not execute if no user triggered them.
|
||||
*
|
||||
* @return true if this effect requires a triggering user, false otherwise
|
||||
*/
|
||||
public boolean requiresTriggeringUser() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the room this wired effect is placed in.
|
||||
* Convenience method to avoid repeated lookups.
|
||||
*
|
||||
* @return the Room, or null if not found
|
||||
*/
|
||||
protected Room getRoom() {
|
||||
return Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and cleans a collection of items, removing those that are no longer valid.
|
||||
* An item is invalid if:
|
||||
* <ul>
|
||||
* <li>It's null</li>
|
||||
* <li>Its room ID doesn't match this effect's room ID</li>
|
||||
* <li>It no longer exists in the room</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param items the collection of items to validate
|
||||
* @param <T> the type extending HabboItem
|
||||
* @return the number of items removed
|
||||
*/
|
||||
protected <T extends HabboItem> int validateItems(Collection<T> items) {
|
||||
if (items == null || items.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Room room = this.getRoom();
|
||||
if (room == null) {
|
||||
int size = items.size();
|
||||
items.clear();
|
||||
return size;
|
||||
}
|
||||
|
||||
int roomId = this.getRoomId();
|
||||
int sizeBefore = items.size();
|
||||
items.removeIf(item -> item == null
|
||||
|| item.getRoomId() != roomId
|
||||
|| room.getHabboItem(item.getId()) == null);
|
||||
return sizeBefore - items.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and cleans a collection of items with an additional custom predicate.
|
||||
* Items matching the predicate will be removed in addition to standard validation.
|
||||
*
|
||||
* @param items the collection of items to validate
|
||||
* @param additionalRemoveCondition additional condition that, if true, causes removal
|
||||
* @param <T> the type extending HabboItem
|
||||
* @return the number of items removed
|
||||
*/
|
||||
protected <T extends HabboItem> int validateItems(Collection<T> items, Predicate<T> additionalRemoveCondition) {
|
||||
if (items == null || items.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Room room = this.getRoom();
|
||||
if (room == null) {
|
||||
int size = items.size();
|
||||
items.clear();
|
||||
return size;
|
||||
}
|
||||
|
||||
int roomId = this.getRoomId();
|
||||
int sizeBefore = items.size();
|
||||
items.removeIf(item -> item == null
|
||||
|| item.getRoomId() != roomId
|
||||
|| room.getHabboItem(item.getId()) == null
|
||||
|| additionalRemoveCondition.test(item));
|
||||
return sizeBefore - items.size();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -7,8 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreClearType;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreRow;
|
||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreScoreType;
|
||||
@@ -97,7 +96,7 @@ public class InteractionWiredHighscore extends HabboItem {
|
||||
}
|
||||
|
||||
if(client != null && !(objects.length >= 2 && objects[1] instanceof WiredEffectType)) {
|
||||
WiredHandler.handle(WiredTriggerType.STATE_CHANGED, client.getHabbo().getRoomUnit(), room, new Object[]{this});
|
||||
WiredManager.triggerFurniStateChanged(room, client.getHabbo().getRoomUnit(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+43
-1
@@ -5,13 +5,23 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.api.IWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredEvent;
|
||||
import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public abstract class InteractionWiredTrigger extends InteractionWired {
|
||||
/**
|
||||
* Base class for all wired triggers in the game.
|
||||
* <p>
|
||||
* Triggers are the entry points for wired execution. They now implement
|
||||
* {@link IWiredTrigger} for the new context-driven architecture.
|
||||
* </p>
|
||||
*/
|
||||
public abstract class InteractionWiredTrigger extends InteractionWired implements IWiredTrigger {
|
||||
private int delay;
|
||||
|
||||
protected InteractionWiredTrigger(ResultSet set, Item baseItem) throws SQLException {
|
||||
@@ -57,5 +67,37 @@ public abstract class InteractionWiredTrigger extends InteractionWired {
|
||||
public boolean isTriggeredByRoomUnit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ========== IWiredTrigger Implementation ==========
|
||||
|
||||
/**
|
||||
* Returns the event type this trigger responds to.
|
||||
* Maps the WiredTriggerType to the new WiredEvent.Type.
|
||||
*
|
||||
* @return the event type this trigger responds to
|
||||
*/
|
||||
@Override
|
||||
public WiredEvent.Type listensTo() {
|
||||
return WiredEvent.Type.fromLegacyType(this.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this trigger matches the given event.
|
||||
* Subclasses must implement this to define their matching logic.
|
||||
*
|
||||
* @param triggerItem the wired trigger furniture item
|
||||
* @param event the event that occurred
|
||||
* @return true if this trigger should activate
|
||||
*/
|
||||
@Override
|
||||
public abstract boolean matches(HabboItem triggerItem, WiredEvent event);
|
||||
|
||||
/**
|
||||
* Returns whether this trigger requires an actor (user) to activate.
|
||||
*/
|
||||
@Override
|
||||
public boolean requiresActor() {
|
||||
return isTriggeredByRoomUnit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-7
@@ -11,8 +11,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.threading.runnables.games.GameTimer;
|
||||
import org.slf4j.Logger;
|
||||
@@ -208,7 +207,7 @@ public class InteractionGameTimer extends HabboItem {
|
||||
this.endGame(room, true);
|
||||
|
||||
if(wasPaused) {
|
||||
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
|
||||
WiredManager.triggerGameEnds(room);
|
||||
}
|
||||
|
||||
this.createNewGame(room);
|
||||
@@ -218,7 +217,7 @@ public class InteractionGameTimer extends HabboItem {
|
||||
this.isPaused = false;
|
||||
|
||||
room.updateItem(this);
|
||||
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{});
|
||||
WiredManager.triggerGameStarts(room);
|
||||
|
||||
if (!this.threadActive) {
|
||||
this.threadActive = true;
|
||||
@@ -255,7 +254,7 @@ public class InteractionGameTimer extends HabboItem {
|
||||
room.updateItem(this);
|
||||
|
||||
this.createNewGame(room);
|
||||
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{this});
|
||||
WiredManager.triggerGameStarts(room);
|
||||
|
||||
if (!this.threadActive) {
|
||||
this.threadActive = true;
|
||||
@@ -271,7 +270,7 @@ public class InteractionGameTimer extends HabboItem {
|
||||
} else if (this.isPaused) {
|
||||
this.endGame(room);
|
||||
this.increaseTimer(room);
|
||||
WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{});
|
||||
WiredManager.triggerGameEnds(room);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -296,7 +295,7 @@ public class InteractionGameTimer extends HabboItem {
|
||||
room.updateItem(this);
|
||||
}
|
||||
this.createNewGame(room);
|
||||
WiredHandler.handle(WiredTriggerType.GAME_STARTS, null, room, new Object[]{this});
|
||||
WiredManager.triggerGameStarts(room);
|
||||
if (!threadActive) {
|
||||
threadActive = true;
|
||||
Emulator.getThreading().run(new GameTimer(this), 1000);
|
||||
|
||||
+5
-36
@@ -3,19 +3,15 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.threading.runnables.BanzaiRandomTeleport;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class InteractionBattleBanzaiTeleporter extends HabboItem {
|
||||
public InteractionBattleBanzaiTeleporter(ResultSet set, Item baseItem) throws SQLException {
|
||||
@@ -60,43 +56,16 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem {
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
|
||||
if (objects.length < 3) {
|
||||
if(objects.length < 3) {
|
||||
HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(null, this);
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
if (target == null) return;
|
||||
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
roomUnit.removeStatus(RoomUnitStatus.MOVE);
|
||||
roomUnit.setGoalLocation(roomUnit.getCurrentLocation());
|
||||
roomUnit.setCanWalk(false);
|
||||
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
RoomUserRotation rotation = RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8));
|
||||
ArrayList<RoomUnit> roomUnitsToTeleport = new ArrayList<>();
|
||||
if (habbo != null) {
|
||||
RideablePet pet = habbo.getHabboInfo().getRiding();
|
||||
if (pet != null)
|
||||
roomUnitsToTeleport.add(pet.getRoomUnit());
|
||||
}
|
||||
|
||||
roomUnitsToTeleport.add(roomUnit);
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
target.setExtradata("1");
|
||||
room.updateItemState(target);
|
||||
|
||||
for (RoomUnit ru : roomUnitsToTeleport) {
|
||||
ru.removeStatus(RoomUnitStatus.MOVE);
|
||||
ru.setCanWalk(false);
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
this.setExtradata("0");
|
||||
room.updateItemState(this);
|
||||
|
||||
new BanzaiRandomTeleport(this, target, ru, room, rotation).run();
|
||||
}, 500);
|
||||
}
|
||||
}, 500);
|
||||
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate {
|
||||
|
||||
@Override
|
||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
return room.getGame(BattleBanzaiGame.class) == null || room.getGame(BattleBanzaiGame.class).state.equals(GameState.IDLE);
|
||||
return room.getGame(BattleBanzaiGame.class) == null || ((BattleBanzaiGame) room.getGame(BattleBanzaiGame.class)).state.equals(GameState.IDLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ public class InteractionFootball extends InteractionPushable {
|
||||
BigDecimal topItemHeight = BigDecimal.valueOf(topItem.getZ() + topItem.getBaseItem().getHeight());
|
||||
BigDecimal ballHeight = BigDecimal.valueOf(this.getZ());
|
||||
|
||||
if (topItemHeight.subtract(ballHeight).compareTo(new BigDecimal("1.65")) > 0) {
|
||||
if (topItemHeight.subtract(ballHeight).compareTo(new BigDecimal(1.65)) > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class InteractionFreezeGate extends InteractionGameGate {
|
||||
|
||||
@Override
|
||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
return room.getGame(FreezeGame.class) == null || room.getGame(FreezeGame.class).state.equals(GameState.IDLE);
|
||||
return room.getGame(FreezeGame.class) == null || ((FreezeGame) room.getGame(FreezeGame.class)).state.equals(GameState.IDLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
|
||||
public interface ConditionalGate {
|
||||
void onRejected(RoomUnit roomUnit, Room room, Object[] objects);
|
||||
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects);
|
||||
}
|
||||
|
||||
+11
-4
@@ -7,7 +7,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -58,14 +59,20 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
int time = Emulator.getIntUnixTimestamp();
|
||||
return this.startDate < time && this.endDate >= time;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.startDate,
|
||||
this.endDate
|
||||
));
|
||||
@@ -76,7 +83,7 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.startDate = data.startDate;
|
||||
this.endDate = data.endDate;
|
||||
} else {
|
||||
|
||||
+30
-10
@@ -9,7 +9,8 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
@@ -22,7 +23,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI;
|
||||
|
||||
private boolean all;
|
||||
private final THashSet<HabboItem> items;
|
||||
private THashSet<HabboItem> items;
|
||||
|
||||
public WiredConditionFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@@ -35,32 +36,51 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
|
||||
this.refresh();
|
||||
|
||||
if(this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
if (room.getLayout() == null)
|
||||
return false;
|
||||
|
||||
if(this.all) {
|
||||
return this.items.stream().allMatch(item -> {
|
||||
if (item == null) return false;
|
||||
RoomTile baseTile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (baseTile == null) return false;
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(baseTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
if (occupiedTiles == null) return false;
|
||||
return occupiedTiles.stream().anyMatch(tile -> tile != null && room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
else {
|
||||
return this.items.stream().anyMatch(item -> {
|
||||
if (item == null) return false;
|
||||
RoomTile baseTile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (baseTile == null) return false;
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(baseTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
if (occupiedTiles == null) return false;
|
||||
return occupiedTiles.stream().anyMatch(tile -> tile != null && room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
@@ -71,7 +91,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
@@ -118,7 +138,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
|
||||
+28
-31
@@ -12,7 +12,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
@@ -25,7 +26,6 @@ import java.util.stream.Collectors;
|
||||
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
|
||||
protected THashSet<HabboItem> items;
|
||||
private boolean all;
|
||||
|
||||
public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@@ -40,44 +40,45 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
this.items.clear();
|
||||
this.all = false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
|
||||
this.refresh();
|
||||
|
||||
if (this.items.isEmpty()) {
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
}
|
||||
|
||||
if (room.getLayout() == null)
|
||||
return false;
|
||||
|
||||
Collection<Habbo> habbos = room.getHabbos();
|
||||
Collection<Bot> bots = room.getCurrentBots().valueCollection();
|
||||
Collection<Pet> pets = room.getCurrentPets().valueCollection();
|
||||
|
||||
if (this.all) {
|
||||
return this.items.stream().allMatch(item -> {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||
});
|
||||
} else {
|
||||
return this.items.stream().anyMatch(item -> {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||
});
|
||||
}
|
||||
return this.items.stream().filter(item -> item != null).allMatch(item -> {
|
||||
RoomTile baseTile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (baseTile == null) return false;
|
||||
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(baseTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return habbos.stream().anyMatch(character -> character.getRoomUnit() != null && occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
bots.stream().anyMatch(character -> character.getRoomUnit() != null && occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
pets.stream().anyMatch(character -> character.getRoomUnit() != null && occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.all,
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
@@ -88,8 +89,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.all = data.all;
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
@@ -102,7 +102,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
@@ -126,7 +125,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
@@ -185,11 +184,9 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean all;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(boolean all, List<Integer> itemIds) {
|
||||
this.all = all;
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-12
@@ -8,7 +8,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
@@ -20,7 +21,7 @@ import java.util.stream.Collectors;
|
||||
public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.STUFF_IS;
|
||||
|
||||
private final THashSet<HabboItem> items = new THashSet<>();
|
||||
private THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
public WiredConditionFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@@ -36,27 +37,30 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
this.refresh();
|
||||
|
||||
if(items.isEmpty())
|
||||
return false;
|
||||
|
||||
if (stuff != null) {
|
||||
if (stuff.length >= 1) {
|
||||
if (stuff[0] instanceof HabboItem triggeringItem) {
|
||||
return this.items.stream().anyMatch(item -> item == triggeringItem);
|
||||
}
|
||||
}
|
||||
HabboItem triggeringItem = ctx.sourceItem().orElse(null);
|
||||
if (triggeringItem != null) {
|
||||
return this.items.stream().anyMatch(item -> item == triggeringItem);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
@@ -67,7 +71,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
@@ -99,7 +103,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
|
||||
+10
-1
@@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -24,7 +25,9 @@ public class WiredConditionGroupMember extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
Room room = ctx.room();
|
||||
if (room.getGuildId() == 0)
|
||||
return false;
|
||||
|
||||
@@ -33,6 +36,12 @@ public class WiredConditionGroupMember extends InteractionWiredCondition {
|
||||
return habbo != null && habbo.getHabboStats().hasGuild(room.getGuildId());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return "";
|
||||
|
||||
+12
-5
@@ -6,7 +6,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -27,15 +28,21 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
int count = room.getUserCount();
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
int count = ctx.room().getUserCount();
|
||||
|
||||
return count >= this.lowerLimit && count <= this.upperLimit;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.lowerLimit,
|
||||
this.upperLimit
|
||||
));
|
||||
@@ -46,7 +53,7 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.lowerLimit = data.lowerLimit;
|
||||
this.upperLimit = data.upperLimit;
|
||||
} else {
|
||||
|
||||
+15
-6
@@ -6,7 +6,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -26,14 +27,21 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
if (roomUnit == null) return false;
|
||||
return roomUnit.getEffectId() == this.effectId;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.effectId
|
||||
));
|
||||
}
|
||||
@@ -43,7 +51,7 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.effectId = data.effectId;
|
||||
} else {
|
||||
this.effectId = Integer.parseInt(wiredData);
|
||||
@@ -67,8 +75,9 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString(this.effectId + "");
|
||||
message.appendInt(0);
|
||||
message.appendString("");
|
||||
message.appendInt(1);
|
||||
message.appendInt(this.effectId);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
message.appendInt(0);
|
||||
|
||||
+12
-4
@@ -6,7 +6,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -59,14 +60,21 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
if (roomUnit == null) return false;
|
||||
return roomUnit.getHandItem() == this.handItem;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.handItem
|
||||
));
|
||||
}
|
||||
@@ -77,7 +85,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.handItem = data.handItemId;
|
||||
} else {
|
||||
this.handItem = Integer.parseInt(wiredData);
|
||||
|
||||
+13
-4
@@ -8,7 +8,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -28,7 +29,9 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
@@ -43,9 +46,15 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.badge
|
||||
));
|
||||
}
|
||||
@@ -55,7 +64,7 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.badge = data.badge;
|
||||
} else {
|
||||
this.badge = wiredData;
|
||||
|
||||
+11
-4
@@ -7,7 +7,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -26,14 +27,20 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
return (Emulator.getIntUnixTimestamp() - ctx.room().getLastTimerReset()) / 0.5 < this.cycles;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 < this.cycles;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.cycles
|
||||
));
|
||||
}
|
||||
@@ -44,7 +51,7 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
try {
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.cycles = data.cycles;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
|
||||
+14
-6
@@ -8,8 +8,9 @@ import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWi
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
@@ -22,7 +23,7 @@ import java.util.List;
|
||||
public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings {
|
||||
public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT;
|
||||
|
||||
private final THashSet<WiredMatchFurniSetting> settings;
|
||||
private THashSet<WiredMatchFurniSetting> settings;
|
||||
|
||||
private boolean state;
|
||||
private boolean position;
|
||||
@@ -48,7 +49,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.settings.size());
|
||||
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
@@ -97,7 +98,8 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
if (this.settings.isEmpty())
|
||||
return true;
|
||||
|
||||
@@ -135,9 +137,15 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.state,
|
||||
this.position,
|
||||
this.direction,
|
||||
@@ -150,7 +158,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.state = data.state;
|
||||
this.position = data.position;
|
||||
this.direction = data.direction;
|
||||
|
||||
+11
-4
@@ -7,7 +7,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -26,14 +27,20 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
return (Emulator.getIntUnixTimestamp() - ctx.room().getLastTimerReset()) / 0.5 > this.cycles;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 > this.cycles;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.cycles
|
||||
));
|
||||
}
|
||||
@@ -44,7 +51,7 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
try {
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.cycles = data.cycles;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.api.IWiredEffect;
|
||||
import com.eu.habbo.habbohotel.wired.api.WiredStack;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredSimulation;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Wired condition that validates all movement effects can complete successfully.
|
||||
* <p>
|
||||
* When this condition is present in a wired stack, all movement effects are first
|
||||
* simulated to verify they can complete. If ANY movement would fail (e.g., destination
|
||||
* has a user, bot, furniture, or is a hole), this condition returns FALSE and the
|
||||
* stack does not execute.
|
||||
* </p>
|
||||
* <p>
|
||||
* <b>Key Feature:</b> The simulation tracks cumulative position changes. If Effect 1
|
||||
* moves an item from tile 0 to tile 1, and Effect 2 moves it forward again, the
|
||||
* simulation correctly validates the move from tile 1 to tile 2 (not from tile 0).
|
||||
* </p>
|
||||
* <p>
|
||||
* Use cases:
|
||||
* <ul>
|
||||
* <li>Moving furniture in formation - if one piece can't move, none should</li>
|
||||
* <li>Puzzles where partial movement would break the puzzle state</li>
|
||||
* <li>Chain movements where items depend on each other's positions</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
* @see WiredSimulation
|
||||
* @see IWiredEffect#simulate
|
||||
*/
|
||||
public class WiredConditionMovementValidation extends InteractionWiredCondition {
|
||||
|
||||
public static final WiredConditionType type = WiredConditionType.MOVEMENT_VALIDATION;
|
||||
|
||||
public WiredConditionMovementValidation(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
|
||||
public WiredConditionMovementValidation(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
WiredStack stack = ctx.stack();
|
||||
if (stack == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
WiredSimulation simulation = new WiredSimulation(ctx.room());
|
||||
|
||||
for (IWiredEffect effect : stack.effects()) {
|
||||
if (effect.requiresActor() && !ctx.hasActor()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
boolean success = effect.simulate(ctx, simulation);
|
||||
if (!success || simulation.hasFailed()) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WiredConditionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeWiredData(ServerMessage message, Room room) {
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(5);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString("");
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveData(WiredSettings settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+30
-10
@@ -10,7 +10,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI;
|
||||
|
||||
private boolean all;
|
||||
private final THashSet<HabboItem> items;
|
||||
private THashSet<HabboItem> items;
|
||||
|
||||
public WiredConditionNotFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@@ -36,32 +37,51 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
|
||||
this.refresh();
|
||||
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
if (room.getLayout() == null)
|
||||
return true;
|
||||
|
||||
if(this.all) {
|
||||
return this.items.stream().allMatch(item -> {
|
||||
if (item == null) return true;
|
||||
RoomTile baseTile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (baseTile == null) return true;
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(baseTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
if (occupiedTiles == null) return true;
|
||||
return occupiedTiles.stream().noneMatch(tile -> tile != null && room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
else {
|
||||
return this.items.stream().anyMatch(item -> {
|
||||
if (item == null) return true;
|
||||
RoomTile baseTile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (baseTile == null) return true;
|
||||
double minZ = item.getZ() + Item.getCurrentHeight(item);
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(baseTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
if (occupiedTiles == null) return true;
|
||||
return occupiedTiles.stream().noneMatch(tile -> tile != null && room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
@@ -73,7 +93,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
for (int id : data.itemIds) {
|
||||
@@ -119,7 +139,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
|
||||
+25
-10
@@ -12,7 +12,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
@@ -43,28 +44,42 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
|
||||
this.refresh();
|
||||
|
||||
if (this.items.isEmpty())
|
||||
return true;
|
||||
|
||||
if (room.getLayout() == null)
|
||||
return false;
|
||||
|
||||
Collection<Habbo> habbos = room.getHabbos();
|
||||
Collection<Bot> bots = room.getCurrentBots().valueCollection();
|
||||
Collection<Pet> pets = room.getCurrentPets().valueCollection();
|
||||
|
||||
return this.items.stream().noneMatch(item -> {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||
return this.items.stream().filter(item -> item != null).noneMatch(item -> {
|
||||
RoomTile baseTile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (baseTile == null) return false;
|
||||
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(baseTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
return habbos.stream().anyMatch(character -> character.getRoomUnit() != null && occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
bots.stream().anyMatch(character -> character.getRoomUnit() != null && occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
|
||||
pets.stream().anyMatch(character -> character.getRoomUnit() != null && occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
@@ -75,7 +90,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class);
|
||||
WiredConditionFurniHaveHabbo.JsonData data = WiredManager.getGson().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class);
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
@@ -110,7 +125,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
|
||||
+16
-12
@@ -8,7 +8,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
@@ -20,7 +21,7 @@ import java.util.stream.Collectors;
|
||||
public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS;
|
||||
|
||||
private final THashSet<HabboItem> items = new THashSet<>();
|
||||
private THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
public WiredConditionNotFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@@ -31,27 +32,30 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
this.refresh();
|
||||
|
||||
if(items.isEmpty())
|
||||
return true;
|
||||
|
||||
if (stuff != null) {
|
||||
if (stuff.length >= 1) {
|
||||
if (stuff[0] instanceof HabboItem triggeringItem) {
|
||||
return this.items.stream().noneMatch(item -> item == triggeringItem);
|
||||
}
|
||||
}
|
||||
HabboItem triggeringItem = ctx.sourceItem().orElse(null);
|
||||
if (triggeringItem != null) {
|
||||
return this.items.stream().noneMatch(item -> item == triggeringItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
@@ -62,7 +66,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
|
||||
WiredConditionFurniTypeMatch.JsonData data = WiredManager.getGson().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
@@ -99,7 +103,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
|
||||
+12
-5
@@ -6,7 +6,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -27,15 +28,21 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
int count = room.getUserCount();
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
int count = ctx.room().getUserCount();
|
||||
|
||||
return count < this.lowerLimit || count > this.upperLimit;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.lowerLimit,
|
||||
this.upperLimit
|
||||
));
|
||||
@@ -46,7 +53,7 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionHabboCount.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionHabboCount.JsonData.class);
|
||||
WiredConditionHabboCount.JsonData data = WiredManager.getGson().fromJson(wiredData, WiredConditionHabboCount.JsonData.class);
|
||||
this.lowerLimit = data.lowerLimit;
|
||||
this.upperLimit = data.upperLimit;
|
||||
} else {
|
||||
|
||||
+12
-4
@@ -6,7 +6,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -26,14 +27,21 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
if (roomUnit == null) return false;
|
||||
return roomUnit.getEffectId() != this.effectId;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.effectId
|
||||
));
|
||||
}
|
||||
@@ -43,7 +51,7 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.effectId = data.effectId;
|
||||
} else {
|
||||
this.effectId = Integer.parseInt(wiredData);
|
||||
|
||||
+13
-4
@@ -8,7 +8,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -28,7 +29,9 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
@@ -44,9 +47,15 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.badge
|
||||
));
|
||||
}
|
||||
@@ -56,7 +65,7 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.badge = data.badge;
|
||||
} else {
|
||||
this.badge = wiredData;
|
||||
|
||||
+10
-1
@@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -24,7 +25,9 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
Room room = ctx.room();
|
||||
if (room.getGuildId() == 0)
|
||||
return false;
|
||||
|
||||
@@ -33,6 +36,12 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition {
|
||||
return habbo == null || !habbo.getHabboStats().hasGuild(room.getGuildId());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return "";
|
||||
|
||||
+13
-4
@@ -7,8 +7,9 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -28,7 +29,9 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
@@ -38,9 +41,15 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.teamColor
|
||||
));
|
||||
}
|
||||
@@ -51,7 +60,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.teamColor = data.teamColor;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
|
||||
+8
-1
@@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -19,9 +20,15 @@ public class WiredConditionNotMatchStatePosition extends WiredConditionMatchStat
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
return !super.evaluate(ctx);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return !super.execute(roomUnit, room, stuff);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+11
-1
@@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -20,7 +21,10 @@ public class WiredConditionNotTriggerOnFurni extends WiredConditionTriggerOnFurn
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
Room room = ctx.room();
|
||||
|
||||
if (roomUnit == null)
|
||||
return false;
|
||||
|
||||
@@ -32,6 +36,12 @@ public class WiredConditionNotTriggerOnFurni extends WiredConditionTriggerOnFurn
|
||||
return !triggerOnFurni(roomUnit, room);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WiredConditionType getType() {
|
||||
return type;
|
||||
|
||||
+13
-4
@@ -8,7 +8,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -28,7 +29,9 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
@@ -40,9 +43,15 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.teamColor
|
||||
));
|
||||
}
|
||||
@@ -53,7 +62,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.teamColor = data.teamColor;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
|
||||
+15
-5
@@ -9,7 +9,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
@@ -32,7 +33,10 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public boolean evaluate(WiredContext ctx) {
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
Room room = ctx.room();
|
||||
|
||||
if (roomUnit == null)
|
||||
return false;
|
||||
|
||||
@@ -44,6 +48,12 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
return triggerOnFurni(roomUnit, room);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean triggerOnFurni(RoomUnit roomUnit, Room room) {
|
||||
THashSet<HabboItem> itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation());
|
||||
return this.items.stream().anyMatch(itemsAtUser::contains);
|
||||
@@ -52,7 +62,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
@@ -63,7 +73,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
@@ -100,7 +110,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
|
||||
+5
-7
@@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -19,17 +19,15 @@ public class WiredEffectAlert extends WiredEffectWhisper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.alert(this.message
|
||||
.replace("%online%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "")
|
||||
.replace("%username%", habbo.getHabboInfo().getUsername())
|
||||
.replace("%roomsloaded%", Emulator.getGameEnvironment().getRoomManager().loadedRoomsCount() + ""));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-6
@@ -9,7 +9,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
|
||||
@@ -39,7 +40,7 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString(this.botName + ((char) 9) + this.botLook);
|
||||
message.appendString(this.botName + ((char) 9) + "" + this.botLook);
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
@@ -77,20 +78,25 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (bots.size() == 1) {
|
||||
Bot bot = bots.get(0);
|
||||
bot.setFigure(this.botLook);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.botLook, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.botName, this.botLook, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,7 +104,7 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.botName = data.bot_name;
|
||||
this.botLook = data.look;
|
||||
|
||||
+13
-7
@@ -11,7 +11,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
@@ -99,9 +100,12 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
if (roomUnit == null) return;
|
||||
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (habbo != null && bots.size() == 1) {
|
||||
@@ -112,16 +116,18 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
} else {
|
||||
bot.stopFollowingHabbo();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.botName, this.mode, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,7 +135,7 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.mode = data.mode;
|
||||
this.botName = data.bot_name;
|
||||
|
||||
+14
-8
@@ -12,8 +12,8 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
|
||||
@@ -102,7 +102,11 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
if (roomUnit == null) return;
|
||||
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
@@ -114,7 +118,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
|
||||
tasks.add(() -> {
|
||||
if(roomUnit.getRoom() != null && roomUnit.getRoom().getId() == room.getId() && roomUnit.getCurrentLocation().distance(bot.getRoomUnit().getCurrentLocation()) < 2) {
|
||||
WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, bot.getRoomUnit(), room, new Object[]{});
|
||||
WiredManager.triggerBotReachedHabbo(room, bot.getRoomUnit(), roomUnit);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -126,16 +130,18 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
|
||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(bot.getRoomUnit(), tile, room, tasks, tasks));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.itemId, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.botName, this.itemId, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,7 +149,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.itemId = data.item_id;
|
||||
this.botName = data.bot_name;
|
||||
|
||||
+15
-9
@@ -10,8 +10,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString(this.botName + ((char) 9) + this.message);
|
||||
message.appendString(this.botName + "" + ((char) 9) + "" + this.message);
|
||||
message.appendInt(1);
|
||||
message.appendInt(this.mode);
|
||||
message.appendInt(0);
|
||||
@@ -89,10 +89,12 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
String message = this.message;
|
||||
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
Habbo habbo = roomUnit != null ? room.getHabbo(roomUnit) : null;
|
||||
|
||||
if (habbo != null) {
|
||||
message = message.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername())
|
||||
@@ -111,7 +113,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
if (bots.size() == 1) {
|
||||
Bot bot = bots.get(0);
|
||||
|
||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ message })) {
|
||||
if(!WiredManager.triggerUserSays(room, bot.getRoomUnit(), message)) {
|
||||
if (this.mode == 1) {
|
||||
bot.shout(message);
|
||||
} else {
|
||||
@@ -119,13 +121,17 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,7 +139,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.mode = data.mode;
|
||||
this.botName = data.bot_name;
|
||||
|
||||
+16
-10
@@ -11,8 +11,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
@@ -45,7 +45,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString(this.botName + ((char) 9) + this.message);
|
||||
message.appendString(this.botName + "" + ((char) 9) + "" + this.message);
|
||||
message.appendInt(1);
|
||||
message.appendInt(this.mode);
|
||||
message.appendInt(0);
|
||||
@@ -109,7 +109,11 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
if (roomUnit == null) return;
|
||||
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
@@ -127,28 +131,30 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (bots.size() != 1) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
Bot bot = bots.get(0);
|
||||
|
||||
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ m })) {
|
||||
if(!WiredManager.triggerUserSays(room, bot.getRoomUnit(), m)) {
|
||||
if (this.mode == 1) {
|
||||
bot.whisper(m, habbo);
|
||||
} else {
|
||||
bot.talk(habbo.getHabboInfo().getUsername() + ": " + m);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,7 +162,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.mode = data.mode;
|
||||
this.botName = data.bot_name;
|
||||
|
||||
+26
-13
@@ -12,7 +12,8 @@ import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer;
|
||||
@@ -56,7 +57,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
|
||||
roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit));
|
||||
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
|
||||
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000);
|
||||
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredManager.TELEPORT_DELAY + 1000);
|
||||
|
||||
if (tile == roomUnit.getCurrentLocation()) {
|
||||
return;
|
||||
@@ -79,8 +80,8 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> { roomUnit.isWiredTeleporting = true; }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
|
||||
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
|
||||
Emulator.getThreading().run(() -> { roomUnit.isWiredTeleporting = true; }, Math.max(0, WiredManager.TELEPORT_DELAY - 500));
|
||||
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredManager.TELEPORT_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +98,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
for (HabboItem item : this.items)
|
||||
message.appendInt(item.getId());
|
||||
@@ -152,14 +153,19 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
|
||||
if (this.items.isEmpty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
if (room.getLayout() == null)
|
||||
return;
|
||||
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (bots.size() != 1) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
Bot bot = bots.get(0);
|
||||
@@ -170,15 +176,22 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
|
||||
if (i == j) {
|
||||
teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getX(), item.getY()));
|
||||
return true;
|
||||
RoomTile tile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (tile != null) {
|
||||
teleportUnitToTile(bot.getRoomUnit(), tile);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,7 +206,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.botName, itemIds, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,7 +216,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.botName = data.bot_name;
|
||||
|
||||
|
||||
+16
-8
@@ -10,7 +10,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
@@ -51,7 +52,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
for (HabboItem item : this.items)
|
||||
message.appendInt(item.getId());
|
||||
@@ -106,11 +107,12 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
List<Bot> bots = room.getBots(this.botName);
|
||||
|
||||
if (this.items.isEmpty() || bots.size() != 1) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
Bot bot = bots.get(0);
|
||||
@@ -126,11 +128,17 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
HabboItem item = possibleItems.get(Emulator.getRandom().nextInt(possibleItems.size()));
|
||||
|
||||
if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
|
||||
bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
if (room.getLayout() != null) {
|
||||
bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,7 +153,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.botName, itemIds, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,7 +163,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.botName = data.bot_name;
|
||||
|
||||
|
||||
+37
-17
@@ -7,10 +7,9 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredChangeDirectionSetting;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.*;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
@@ -47,11 +46,14 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
if (room == null || room.getLayout() == null) return;
|
||||
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
for (HabboItem item : this.items.keySet()) {
|
||||
if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
||||
if (item == null || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
@@ -59,17 +61,22 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
this.items.remove(item);
|
||||
}
|
||||
|
||||
if (this.items.isEmpty()) return false;
|
||||
if (this.items.isEmpty()) return;
|
||||
|
||||
for (Map.Entry<HabboItem, WiredChangeDirectionSetting> entry : this.items.entrySet()) {
|
||||
HabboItem item = entry.getKey();
|
||||
RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().direction.getValue());
|
||||
if (item == null || entry.getValue() == null) continue;
|
||||
|
||||
RoomTile itemTile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (itemTile == null) continue;
|
||||
|
||||
RoomTile targetTile = room.getLayout().getTileInFront(itemTile, entry.getValue().direction.getValue());
|
||||
|
||||
int count = 1;
|
||||
while ((targetTile == null || targetTile.state == RoomTileState.INVALID || room.furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) {
|
||||
entry.getValue().direction = this.nextRotation(entry.getValue().direction);
|
||||
|
||||
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().direction.getValue());
|
||||
RoomTile tile = room.getLayout().getTileInFront(itemTile, entry.getValue().direction.getValue());
|
||||
if (tile != null && tile.state != RoomTileState.INVALID) {
|
||||
targetTile = tile;
|
||||
}
|
||||
@@ -80,47 +87,60 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
|
||||
for (Map.Entry<HabboItem, WiredChangeDirectionSetting> entry : this.items.entrySet()) {
|
||||
HabboItem item = entry.getKey();
|
||||
if (item == null || entry.getValue() == null) continue;
|
||||
|
||||
int newDirection = entry.getValue().direction.getValue();
|
||||
|
||||
RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), newDirection);
|
||||
RoomTile itemTile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (itemTile == null) continue;
|
||||
|
||||
RoomTile targetTile = room.getLayout().getTileInFront(itemTile, newDirection);
|
||||
|
||||
if(item.getRotation() != entry.getValue().rotation) {
|
||||
if(room.furnitureFitsAt(targetTile, item, entry.getValue().rotation, false) != FurnitureMovementError.NONE)
|
||||
if(targetTile == null || room.furnitureFitsAt(targetTile, item, entry.getValue().rotation, false) != FurnitureMovementError.NONE)
|
||||
continue;
|
||||
|
||||
room.moveFurniTo(entry.getKey(), targetTile, entry.getValue().rotation, null, true);
|
||||
}
|
||||
|
||||
if (targetTile == null) continue;
|
||||
|
||||
boolean hasRoomUnits = false;
|
||||
THashSet<RoomTile> newOccupiedTiles = room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
for(RoomTile tile : newOccupiedTiles) {
|
||||
for (RoomUnit _roomUnit : room.getRoomUnits(tile)) {
|
||||
hasRoomUnits = true;
|
||||
if(_roomUnit.getCurrentLocation() == targetTile) {
|
||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, _roomUnit, room, new Object[]{entry.getKey()}));
|
||||
Emulator.getThreading().run(() -> {
|
||||
WiredManager.triggerBotCollision(room, _roomUnit);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetTile != null && targetTile.state != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) {
|
||||
if (targetTile.state != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) {
|
||||
if (!hasRoomUnits) {
|
||||
RoomTile oldLocation = room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY());
|
||||
double oldZ = entry.getKey().getZ();
|
||||
if(room.moveFurniTo(entry.getKey(), targetTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) {
|
||||
if(oldLocation != null && room.moveFurniTo(entry.getKey(), targetTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(entry.getKey(), null, oldLocation, oldZ, targetTile, entry.getKey().getZ(), 0, room).compose());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
ArrayList<WiredChangeDirectionSetting> settings = new ArrayList<>(this.items.values());
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.startRotation, this.blockedAction, settings, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.startRotation, this.blockedAction, settings, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,7 +151,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.startRotation = data.start_direction;
|
||||
this.blockedAction = data.blocked_action;
|
||||
@@ -195,7 +215,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
@Override
|
||||
public void serializeWiredData(ServerMessage message, Room room) {
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
for (Map.Entry<HabboItem, WiredChangeDirectionSetting> item : this.items.entrySet()) {
|
||||
message.appendInt(item.getKey().getId());
|
||||
|
||||
+8
-7
@@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -17,20 +18,20 @@ public class WiredEffectGiveEffect extends WiredEffectWhisper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
int effectId;
|
||||
|
||||
try {
|
||||
effectId = Integer.parseInt(this.message);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (effectId >= 0) {
|
||||
Room room = ctx.room();
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
|
||||
if (effectId >= 0 && roomUnit != null) {
|
||||
room.giveEffect(roomUnit, effectId, Integer.MAX_VALUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -2,8 +2,8 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -18,17 +18,17 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
try {
|
||||
int itemId = Integer.parseInt(this.message);
|
||||
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null);
|
||||
|
||||
if (habbo != null) {
|
||||
room.giveHandItem(habbo, itemId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-7
@@ -10,7 +10,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.hotelview.BonusRareComposer;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
@@ -85,23 +86,27 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
public void execute(WiredContext ctx) {
|
||||
Habbo habbo = ctx.actor().map(unit -> ctx.room().getHabbo(unit)).orElse(null);
|
||||
|
||||
if (habbo == null)
|
||||
return false;
|
||||
return;
|
||||
|
||||
if (this.amount > 0) {
|
||||
habbo.givePoints(Emulator.getConfig().getInt("hotelview.promotional.points.type"), this.amount);
|
||||
habbo.getClient().sendResponse(new BonusRareComposer(habbo));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getDelay(), this.amount));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.getDelay(), this.amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +115,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
|
||||
this.amount = 0;
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.amount = data.amount;
|
||||
} else {
|
||||
|
||||
+12
-7
@@ -10,7 +10,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
@@ -84,23 +85,27 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
public void execute(WiredContext ctx) {
|
||||
Habbo habbo = ctx.actor().map(unit -> ctx.room().getHabbo(unit)).orElse(null);
|
||||
|
||||
if (habbo == null)
|
||||
return false;
|
||||
return;
|
||||
|
||||
if (this.amount > 0) {
|
||||
habbo.getHabboStats().hofPoints += this.amount;
|
||||
Emulator.getThreading().run(habbo.getHabboStats());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.amount, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.amount, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,7 +113,7 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.amount = data.amount;
|
||||
this.setDelay(data.delay);
|
||||
}
|
||||
|
||||
+14
-8
@@ -11,7 +11,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
|
||||
@@ -85,21 +86,26 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null);
|
||||
|
||||
if (habbo == null)
|
||||
return false;
|
||||
return;
|
||||
|
||||
habbo.getHabboStats().respectPointsReceived += this.respects;
|
||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned"), this.respects);
|
||||
}
|
||||
|
||||
return true;
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.respects, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.respects, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,7 +113,7 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.respects = data.amount;
|
||||
this.setDelay(data.delay);
|
||||
}
|
||||
@@ -148,4 +154,4 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect {
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+86
-19
@@ -13,7 +13,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredGiveRewardItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer;
|
||||
@@ -26,19 +27,19 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
public final static int LIMIT_ONCE = 0;
|
||||
public final static int LIMIT_N_DAY = 1;
|
||||
public final static int LIMIT_N_HOURS = 2;
|
||||
public final static int LIMIT_N_MINUTES = 3;
|
||||
public static final int LIMIT_ONCE = 0;
|
||||
public static final int LIMIT_N_DAY = 1;
|
||||
public static final int LIMIT_N_HOURS = 2;
|
||||
public static final int LIMIT_N_MINUTES = 3;
|
||||
|
||||
public final static WiredEffectType type = WiredEffectType.GIVE_REWARD;
|
||||
public int limit;
|
||||
public int limitationInterval;
|
||||
public int given;
|
||||
public int rewardTime;
|
||||
public boolean uniqueRewards;
|
||||
|
||||
public THashSet<WiredGiveRewardItem> rewardItems = new THashSet<>();
|
||||
public static final WiredEffectType type = WiredEffectType.GIVE_REWARD;
|
||||
|
||||
private int limit;
|
||||
private int limitationInterval;
|
||||
private int given;
|
||||
private int rewardTime;
|
||||
private boolean uniqueRewards;
|
||||
private THashSet<WiredGiveRewardItem> rewardItems = new THashSet<>();
|
||||
|
||||
public WiredEffectGiveReward(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@@ -49,17 +50,29 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
RoomUnit roomUnit = ctx.actor().orElse(null);
|
||||
if (roomUnit == null) return;
|
||||
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
return habbo != null && WiredHandler.getReward(habbo, this);
|
||||
if (habbo != null) {
|
||||
WiredManager.getReward(habbo, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
|
||||
ArrayList<WiredGiveRewardItem> rewards = new ArrayList<>(this.rewardItems);
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.limit, this.given, this.rewardTime, this.uniqueRewards, this.limitationInterval, rewards, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.limit, this.given, this.rewardTime, this.uniqueRewards, this.limitationInterval, rewards, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +80,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.limit = data.limit;
|
||||
this.given = data.given;
|
||||
@@ -207,7 +220,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
|
||||
this.setDelay(settings.getDelay());
|
||||
|
||||
WiredHandler.dropRewards(this.getId());
|
||||
WiredManager.dropRewards(this.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -222,7 +235,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
protected long requiredCooldown() {
|
||||
return 0;
|
||||
return COOLDOWN_NONE;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
@@ -244,4 +257,58 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
public int getLimit() {
|
||||
return this.limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public int getLimitationInterval() {
|
||||
return this.limitationInterval;
|
||||
}
|
||||
|
||||
public void setLimitationInterval(int limitationInterval) {
|
||||
this.limitationInterval = limitationInterval;
|
||||
}
|
||||
|
||||
public int getGiven() {
|
||||
return this.given;
|
||||
}
|
||||
|
||||
public void setGiven(int given) {
|
||||
this.given = given;
|
||||
}
|
||||
|
||||
public void incrementGiven() {
|
||||
this.given++;
|
||||
}
|
||||
|
||||
public int getRewardTime() {
|
||||
return this.rewardTime;
|
||||
}
|
||||
|
||||
public void setRewardTime(int rewardTime) {
|
||||
this.rewardTime = rewardTime;
|
||||
}
|
||||
|
||||
public boolean isUniqueRewards() {
|
||||
return this.uniqueRewards;
|
||||
}
|
||||
|
||||
public void setUniqueRewards(boolean uniqueRewards) {
|
||||
this.uniqueRewards = uniqueRewards;
|
||||
}
|
||||
|
||||
public THashSet<WiredGiveRewardItem> getRewardItems() {
|
||||
return this.rewardItems;
|
||||
}
|
||||
|
||||
public void setRewardItems(THashSet<WiredGiveRewardItem> rewardItems) {
|
||||
this.rewardItems = rewardItems;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-10
@@ -11,7 +11,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.iterator.TObjectIntIterator;
|
||||
@@ -32,7 +33,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
private int score;
|
||||
private int count;
|
||||
|
||||
private final TObjectIntMap<Map.Entry<Integer, Integer>> data = new TObjectIntHashMap<>();
|
||||
private TObjectIntMap<Map.Entry<Integer, Integer>> data = new TObjectIntHashMap<>();
|
||||
|
||||
public WiredEffectGiveScore(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@@ -43,14 +44,15 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null);
|
||||
|
||||
if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) {
|
||||
Game game = room.getGame(habbo.getHabboInfo().getCurrentGame());
|
||||
|
||||
if (game == null)
|
||||
return false;
|
||||
return;
|
||||
|
||||
int gameStartTime = game.getStartTime();
|
||||
|
||||
@@ -70,7 +72,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
|
||||
habbo.getHabboInfo().getGamePlayer().addScore(this.score, true);
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
iterator.remove();
|
||||
@@ -89,16 +91,18 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
if (habbo.getHabboInfo().getGamePlayer() != null) {
|
||||
habbo.getHabboInfo().getGamePlayer().addScore(this.score, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.score, this.count, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.score, this.count, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,7 +110,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.score = data.score;
|
||||
this.count = data.count;
|
||||
this.setDelay(data.delay);
|
||||
|
||||
+12
-6
@@ -12,7 +12,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.map.hash.TIntIntHashMap;
|
||||
@@ -27,7 +28,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
|
||||
private int count;
|
||||
private GameTeamColors teamColor = GameTeamColors.RED;
|
||||
|
||||
private final TIntIntHashMap startTimes = new TIntIntHashMap();
|
||||
private TIntIntHashMap startTimes = new TIntIntHashMap();
|
||||
|
||||
public WiredEffectGiveScoreToTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
@@ -38,7 +39,8 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
for (Game game : room.getGames()) {
|
||||
if (game != null && game.state.equals(GameState.RUNNING)) {
|
||||
int c = this.startTimes.get(game.getStartTime());
|
||||
@@ -54,13 +56,17 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.points, this.count, this.teamColor, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.points, this.count, this.teamColor, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,7 +74,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.points = data.score;
|
||||
this.count = data.count;
|
||||
this.teamColor = data.team;
|
||||
|
||||
+11
-7
@@ -13,7 +13,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
@@ -37,8 +38,9 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null);
|
||||
|
||||
if (habbo != null) {
|
||||
WiredGame game = (WiredGame) room.getGameOrCreate(WiredGame.class);
|
||||
@@ -52,16 +54,18 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
|
||||
if(habbo.getHabboInfo().getGamePlayer() == null) {
|
||||
game.addHabbo(habbo, this.teamColor);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.teamColor, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.teamColor, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,7 +73,7 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.teamColor = data.team;
|
||||
}
|
||||
|
||||
+13
-12
@@ -13,7 +13,8 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
|
||||
@@ -39,21 +40,19 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
if (room == null)
|
||||
return false;
|
||||
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null);
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.hasPermission(Permission.ACC_UNKICKABLE)) {
|
||||
habbo.whisper(Emulator.getTexts().getValue("hotel.wired.kickexception.unkickable"));
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getId() == room.getOwnerId()) {
|
||||
habbo.whisper(Emulator.getTexts().getValue("hotel.wired.kickexception.owner"));
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
room.giveEffect(habbo, 4, 2);
|
||||
@@ -62,16 +61,18 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect {
|
||||
habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(this.message, habbo, habbo, RoomChatMessageBubbles.ALERT)));
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitKick(habbo, room, true), 2000);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.message, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +80,7 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.message = data.message;
|
||||
}
|
||||
|
||||
+12
-6
@@ -12,7 +12,8 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
@@ -34,8 +35,9 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
Habbo habbo = ctx.actor().map(room::getHabbo).orElse(null);
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getCurrentGame() != null) {
|
||||
@@ -47,16 +49,20 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect {
|
||||
|
||||
if (game != null) {
|
||||
game.removeHabbo(habbo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +70,7 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
}
|
||||
else {
|
||||
|
||||
+20
-20
@@ -8,8 +8,9 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
@@ -45,10 +46,14 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
|
||||
if(this.settings.isEmpty())
|
||||
return true;
|
||||
return;
|
||||
|
||||
if (room.getLayout() == null)
|
||||
return;
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
@@ -61,6 +66,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
}
|
||||
|
||||
RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (oldLocation == null) continue;
|
||||
double oldZ = item.getZ();
|
||||
|
||||
if(this.direction && !this.position) {
|
||||
@@ -84,14 +90,18 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.state, this.direction, this.position, new ArrayList<WiredMatchFurniSetting>(this.settings), this.getDelay()));
|
||||
return WiredManager.getGson().toJson(new JsonData(this.state, this.direction, this.position, new ArrayList<WiredMatchFurniSetting>(this.settings), this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,7 +109,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.state = data.state;
|
||||
this.direction = data.direction;
|
||||
@@ -155,7 +165,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
this.refresh();
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.settings.size());
|
||||
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
@@ -196,7 +206,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
|
||||
for (int i = 0; i < itemsCount; i++) {
|
||||
int itemId = settings.getFurniIds()[i];
|
||||
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
|
||||
HabboItem it = room.getHabboItem(itemId);
|
||||
|
||||
if(it == null)
|
||||
throw new WiredSaveException(String.format("Item %s not found", itemId));
|
||||
@@ -223,18 +233,8 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
if (room != null && room.isLoaded()) {
|
||||
THashSet<WiredMatchFurniSetting> remove = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
if (item == null) {
|
||||
remove.add(setting);
|
||||
}
|
||||
}
|
||||
|
||||
for (WiredMatchFurniSetting setting : remove) {
|
||||
this.settings.remove(setting);
|
||||
}
|
||||
// Use removeIf for O(n) instead of O(n²) with separate remove set
|
||||
this.settings.removeIf(setting -> room.getHabboItem(setting.item_id) == null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+67
-7
@@ -8,8 +8,9 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredSimulation;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
@@ -36,7 +37,10 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
if (room.getLayout() == null) return;
|
||||
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
@@ -47,13 +51,18 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
this.items.removeAll(items);
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (item == null) continue;
|
||||
|
||||
RoomTile t = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (t == null) continue;
|
||||
|
||||
RoomUnit target = room.getRoomUnits().stream().min(Comparator.comparingDouble(a -> a.getCurrentLocation().distance(t))).orElse(null);
|
||||
|
||||
if (target != null) {
|
||||
if (target.getCurrentLocation().distance(t) <= 1) {
|
||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, target, room, new Object[]{item}), 500);
|
||||
Emulator.getThreading().run(() -> {
|
||||
WiredManager.triggerBotCollision(room, target);
|
||||
}, 500);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -93,12 +102,63 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean simulate(WiredContext ctx, WiredSimulation simulation) {
|
||||
Room room = ctx.room();
|
||||
if (room.getLayout() == null) return true;
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (item == null) continue;
|
||||
|
||||
WiredSimulation.SimulatedPosition currentPos = simulation.getItemPosition(item);
|
||||
RoomTile t = room.getLayout().getTile(currentPos.x, currentPos.y);
|
||||
if (t == null) continue;
|
||||
|
||||
RoomUnit target = room.getRoomUnits().stream()
|
||||
.min(Comparator.comparingDouble(a -> a.getCurrentLocation().distance(t)))
|
||||
.orElse(null);
|
||||
|
||||
if (target != null && target.getCurrentLocation().distance(t) > 1) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
if (target.getX() == currentPos.x) {
|
||||
y = currentPos.y < target.getY() ? -1 : 1;
|
||||
} else if (target.getY() == currentPos.y) {
|
||||
x = currentPos.x < target.getX() ? -1 : 1;
|
||||
} else if (target.getX() - currentPos.x > target.getY() - currentPos.y) {
|
||||
x = target.getX() - currentPos.x > 0 ? -1 : 1;
|
||||
} else {
|
||||
y = target.getY() - currentPos.y > 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
short newX = (short) (currentPos.x + x);
|
||||
short newY = (short) (currentPos.y + y);
|
||||
|
||||
if (!simulation.isTileValidForItem(newX, newY, item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!simulation.moveItem(item, newX, newY, currentPos.z, currentPos.rotation)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
@@ -110,7 +170,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
@@ -161,7 +221,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
this.items.remove(item);
|
||||
}
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
for (HabboItem item : this.items)
|
||||
message.appendInt(item.getId());
|
||||
|
||||
+69
-12
@@ -10,7 +10,9 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredSimulation;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
@@ -29,7 +31,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
private final List<HabboItem> items = new ArrayList<>();
|
||||
private int direction;
|
||||
private int spacing = 1;
|
||||
private final Map<Integer, Integer> indexOffset = new LinkedHashMap<>();
|
||||
private Map<Integer, Integer> indexOffset = new LinkedHashMap<>();
|
||||
|
||||
public WiredEffectMoveFurniTo(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@@ -69,11 +71,14 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
if (room == null || room.getLayout() == null) return;
|
||||
|
||||
List<HabboItem> items = new ArrayList<>();
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
||||
if (item == null || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
@@ -82,9 +87,10 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
if (this.items.isEmpty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
if (stuff != null) {
|
||||
Object[] stuff = ctx.legacySettings();
|
||||
if (stuff != null && stuff.length > 0) {
|
||||
for (Object object : stuff) {
|
||||
if (object instanceof HabboItem) {
|
||||
HabboItem targetItem = this.items.get(Emulator.getRandom().nextInt(this.items.size()));
|
||||
@@ -100,7 +106,10 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
RoomTile objectTile = room.getLayout().getTile(targetItem.getX(), targetItem.getY());
|
||||
|
||||
if (objectTile != null) {
|
||||
THashSet<RoomTile> refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation());
|
||||
RoomTile sourceTile = room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY());
|
||||
if (sourceTile == null) continue;
|
||||
|
||||
THashSet<RoomTile> refreshTiles = room.getLayout().getTilesAt(sourceTile, ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation());
|
||||
|
||||
RoomTile tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset);
|
||||
if (tile == null || !tile.getAllowStack()) {
|
||||
@@ -108,8 +117,16 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset);
|
||||
}
|
||||
|
||||
if(tile == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
room.sendComposer(new FloorItemOnRollerComposer((HabboItem) object, null, tile, tile.getStackHeight() - ((HabboItem) object).getZ(), room).compose());
|
||||
refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation()));
|
||||
|
||||
RoomTile newSourceTile = room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY());
|
||||
if (newSourceTile != null) {
|
||||
refreshTiles.addAll(room.getLayout().getTilesAt(newSourceTile, ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation()));
|
||||
}
|
||||
room.updateTiles(refreshTiles);
|
||||
this.indexOffset.put(targetItem.getId(), indexOffset);
|
||||
}
|
||||
@@ -117,7 +134,47 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean simulate(WiredContext ctx, WiredSimulation simulation) {
|
||||
Room room = ctx.room();
|
||||
if (room == null || room.getLayout() == null) return true;
|
||||
|
||||
Object[] stuff = ctx.legacySettings();
|
||||
if (stuff == null || stuff.length == 0) return true;
|
||||
|
||||
for (Object object : stuff) {
|
||||
if (object instanceof HabboItem) {
|
||||
HabboItem item = (HabboItem) object;
|
||||
|
||||
if (this.items.isEmpty()) continue;
|
||||
HabboItem targetItem = this.items.get(0);
|
||||
if (targetItem == null) continue;
|
||||
|
||||
WiredSimulation.SimulatedPosition targetPos = simulation.getItemPosition(targetItem);
|
||||
RoomTile objectTile = room.getLayout().getTile(targetPos.x, targetPos.y);
|
||||
if (objectTile == null) continue;
|
||||
|
||||
RoomTile tile = room.getLayout().getTileInFront(objectTile, this.direction, 0);
|
||||
if (tile == null) continue;
|
||||
|
||||
WiredSimulation.SimulatedPosition currentPos = simulation.getItemPosition(item);
|
||||
if (!simulation.isTileValidForItem(tile.x, tile.y, item)) {
|
||||
return false;
|
||||
}
|
||||
if (!simulation.moveItem(item, tile.x, tile.y, tile.getStackHeight(), currentPos.rotation)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -134,7 +191,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
this.items.remove(item);
|
||||
}
|
||||
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.direction,
|
||||
this.spacing,
|
||||
this.getDelay(),
|
||||
@@ -156,7 +213,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
for (HabboItem item : this.items)
|
||||
message.appendInt(item.getId());
|
||||
@@ -178,7 +235,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.direction = data.direction;
|
||||
this.spacing = data.spacing;
|
||||
this.setDelay(data.delay);
|
||||
@@ -237,4 +294,4 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+87
-9
@@ -8,7 +8,9 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredContext;
|
||||
import com.eu.habbo.habbohotel.wired.core.WiredSimulation;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
@@ -34,7 +36,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
|
||||
private THashSet<HabboItem> items;
|
||||
|
||||
private final THashMap<Integer, RoomUserRotation> lastDirections;
|
||||
private THashMap<Integer, RoomUserRotation> lastDirections;
|
||||
|
||||
|
||||
public WiredEffectMoveFurniTowards(ResultSet set, Item baseItem) throws SQLException {
|
||||
@@ -53,7 +55,10 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
List<RoomUserRotation> availableDirections = new ArrayList<>();
|
||||
RoomLayout layout = room.getLayout();
|
||||
|
||||
if (layout == null) return availableDirections;
|
||||
|
||||
RoomTile currentTile = layout.getTile(item.getX(), item.getY());
|
||||
if (currentTile == null) return availableDirections;
|
||||
|
||||
RoomUserRotation[] rotations = new RoomUserRotation[]{RoomUserRotation.NORTH, RoomUserRotation.EAST, RoomUserRotation.SOUTH, RoomUserRotation.WEST};
|
||||
|
||||
@@ -82,7 +87,8 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
public void execute(WiredContext ctx) {
|
||||
Room room = ctx.room();
|
||||
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
|
||||
@@ -135,7 +141,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
target = roomUnitsAtTile.iterator().next();
|
||||
if (i == 0) { // i = 0 means right next to it
|
||||
collided = true;
|
||||
Emulator.getThreading().run(new WiredCollissionRunnable(target, room, new Object[]{item}));
|
||||
Emulator.getThreading().run(new WiredCollissionRunnable(target, room));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -213,9 +219,11 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
RoomTile newTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), moveDirection.getValue());
|
||||
|
||||
RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY());
|
||||
if (oldLocation == null) continue;
|
||||
|
||||
RoomTile newTile = room.getLayout().getTileInFront(oldLocation, moveDirection.getValue());
|
||||
|
||||
double oldZ = item.getZ();
|
||||
|
||||
if(newTile != null) {
|
||||
@@ -227,13 +235,83 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean simulate(WiredContext ctx, WiredSimulation simulation) {
|
||||
Room room = ctx.room();
|
||||
RoomLayout layout = room.getLayout();
|
||||
if (layout == null) return true;
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (item == null) continue;
|
||||
|
||||
WiredSimulation.SimulatedPosition currentPos = simulation.getItemPosition(item);
|
||||
RoomTile currentTile = layout.getTile(currentPos.x, currentPos.y);
|
||||
if (currentTile == null) continue;
|
||||
|
||||
RoomUnit target = null;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (target != null) break;
|
||||
|
||||
RoomUserRotation[] rotations = new RoomUserRotation[]{RoomUserRotation.NORTH, RoomUserRotation.EAST, RoomUserRotation.SOUTH, RoomUserRotation.WEST};
|
||||
|
||||
for (RoomUserRotation rot : rotations) {
|
||||
RoomTile startTile = currentTile;
|
||||
|
||||
for (int ii = 0; ii <= i; ii++) {
|
||||
if (startTile == null) break;
|
||||
startTile = layout.getTileInFront(startTile, rot.getValue());
|
||||
}
|
||||
|
||||
if (startTile != null && layout.tileExists(startTile.x, startTile.y)) {
|
||||
Collection<RoomUnit> roomUnitsAtTile = room.getRoomUnitsAt(startTile);
|
||||
if (!roomUnitsAtTile.isEmpty()) {
|
||||
target = roomUnitsAtTile.iterator().next();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (target != null) {
|
||||
RoomUserRotation moveDirection;
|
||||
|
||||
if (target.getX() == currentPos.x) {
|
||||
moveDirection = currentPos.y < target.getY() ? RoomUserRotation.SOUTH : RoomUserRotation.NORTH;
|
||||
} else if (target.getY() == currentPos.y) {
|
||||
moveDirection = currentPos.x < target.getX() ? RoomUserRotation.EAST : RoomUserRotation.WEST;
|
||||
} else if (target.getX() - currentPos.x > target.getY() - currentPos.y) {
|
||||
moveDirection = target.getX() - currentPos.x > 0 ? RoomUserRotation.EAST : RoomUserRotation.WEST;
|
||||
} else {
|
||||
moveDirection = target.getY() - currentPos.y > 0 ? RoomUserRotation.SOUTH : RoomUserRotation.NORTH;
|
||||
}
|
||||
|
||||
RoomTile newTile = layout.getTileInFront(currentTile, moveDirection.getValue());
|
||||
if (newTile != null && newTile.state != RoomTileState.INVALID) {
|
||||
if (!simulation.isTileValidForItem(newTile.x, newTile.y, item)) {
|
||||
return false;
|
||||
}
|
||||
if (!simulation.moveItem(item, newTile.x, newTile.y, currentPos.z, currentPos.rotation)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
return WiredManager.getGson().toJson(new JsonData(
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
@@ -245,7 +323,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
|
||||
for (Integer id: data.itemIds) {
|
||||
@@ -297,7 +375,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
this.items.remove(item);
|
||||
}
|
||||
message.appendBoolean(false);
|
||||
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(WiredManager.MAXIMUM_FURNI_SELECTION);
|
||||
message.appendInt(this.items.size());
|
||||
for (HabboItem item : this.items)
|
||||
message.appendInt(item.getId());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user