mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 09:50:51 +01:00
More refactoring
This commit is contained in:
parent
94dd34a11e
commit
a152105453
@ -1,6 +1,7 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions;
|
package com.eu.habbo.habbohotel.items.interactions;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
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.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction;
|
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction;
|
||||||
@ -9,8 +10,11 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
|||||||
import com.eu.habbo.habbohotel.wired.WiredExclusionStrategy;
|
import com.eu.habbo.habbohotel.wired.WiredExclusionStrategy;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.messages.ClientMessage;
|
import com.eu.habbo.messages.ClientMessage;
|
||||||
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
|
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer;
|
import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer;
|
||||||
import gnu.trove.map.hash.TLongLongHashMap;
|
import gnu.trove.map.hash.TLongLongHashMap;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -25,10 +29,6 @@ import java.util.List;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class InteractionWired extends InteractionDefault implements IWiredInteraction {
|
public abstract class InteractionWired extends InteractionDefault implements IWiredInteraction {
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String wiredData;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private WiredSettings wiredSettings;
|
private WiredSettings wiredSettings;
|
||||||
@ -38,20 +38,111 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
|
|
||||||
public InteractionWired(ResultSet set, Item baseItem) throws SQLException {
|
public InteractionWired(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
this.wiredData = "";
|
|
||||||
this.wiredSettings = new WiredSettings();
|
this.wiredSettings = new WiredSettings();
|
||||||
this.setExtradata("0");
|
this.setExtradata("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
this.wiredData = "";
|
|
||||||
this.wiredSettings = new WiredSettings();
|
this.wiredSettings = new WiredSettings();
|
||||||
this.setExtradata("0");
|
this.setExtradata("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff);
|
public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On Room Loading run this, get Wired Data from Database and save it into the item
|
||||||
|
*
|
||||||
|
* @param set
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public void loadWiredSettings(ResultSet set) throws SQLException {
|
||||||
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
|
this.wiredSettings = new WiredSettings();
|
||||||
|
|
||||||
|
if(wiredData.startsWith("{")) {
|
||||||
|
this.wiredSettings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loadDefaultParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* When double clicking into the wired, verify items first and load its default parameters
|
||||||
|
* then create a composer based on it's Wired Settings
|
||||||
|
*
|
||||||
|
* @param client
|
||||||
|
* @param room
|
||||||
|
* @param objects
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||||
|
this.wiredSettings.getItems(room);
|
||||||
|
|
||||||
|
//TODO Im not sure about this, the function is optional on its children maybe later just make it abstract
|
||||||
|
this.loadDefaultParams();
|
||||||
|
|
||||||
|
if (client != null) {
|
||||||
|
if (room.hasRights(client.getHabbo())) {
|
||||||
|
MessageComposer composer = null;
|
||||||
|
if(this instanceof InteractionWiredEffect) {
|
||||||
|
composer = new WiredEffectDataComposer((InteractionWiredEffect) this, room);
|
||||||
|
} else if(this instanceof InteractionWiredCondition) {
|
||||||
|
composer = new WiredConditionDataComposer((InteractionWiredCondition) this, room);
|
||||||
|
} else if(this instanceof InteractionWiredTrigger) {
|
||||||
|
composer = new WiredTriggerDataComposer((InteractionWiredTrigger) this, room);
|
||||||
|
}
|
||||||
|
|
||||||
|
client.sendResponse(composer);
|
||||||
|
this.activateBox(room);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When click save changes on the wired this executes, reads all the packet
|
||||||
|
* And updates wired current Wired Settings
|
||||||
|
*
|
||||||
|
* @param packet
|
||||||
|
*/
|
||||||
|
public void saveWiredSettings(ClientMessage packet) {
|
||||||
|
int intParamCount = packet.readInt();
|
||||||
|
List<Integer> integerParams = new ArrayList<>();
|
||||||
|
|
||||||
|
for(int i = 0; i < intParamCount; i++)
|
||||||
|
{
|
||||||
|
integerParams.add(packet.readInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wiredSettings.setIntegerParams(integerParams);
|
||||||
|
this.wiredSettings.setStringParam(packet.readString());
|
||||||
|
|
||||||
|
int itemCount = packet.readInt();
|
||||||
|
List<Integer> itemIds = new ArrayList<>();
|
||||||
|
|
||||||
|
for(int i = 0; i < itemCount; i++)
|
||||||
|
{
|
||||||
|
itemIds.add(packet.readInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wiredSettings.setItemIds(itemIds);
|
||||||
|
|
||||||
|
if(this instanceof InteractionWiredEffect) {
|
||||||
|
this.wiredSettings.setDelay(packet.readInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wiredSettings.setSelectionType(packet.readInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is executed on 3 different situations
|
||||||
|
* When finishing executing: `saveWiredSettings`, when placing this item on floor, and when picking it up.
|
||||||
|
* This what it does is converts Wired Settings into a JSON string
|
||||||
|
* and updates wired_data in the database
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (this.needsUpdate()) {
|
if (this.needsUpdate()) {
|
||||||
@ -62,6 +153,10 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
|
|
||||||
String wiredData = WiredHandler.getGsonBuilder().setExclusionStrategies(exclusionStrategy).create().toJson(this.wiredSettings);
|
String wiredData = WiredHandler.getGsonBuilder().setExclusionStrategies(exclusionStrategy).create().toJson(this.wiredSettings);
|
||||||
|
|
||||||
|
if(wiredData.equalsIgnoreCase("{}")) {
|
||||||
|
wiredData = "";
|
||||||
|
}
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE items SET wired_data = ? WHERE id = ?")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE items SET wired_data = ? WHERE id = ?")) {
|
||||||
if (this.getRoomId() != 0) {
|
if (this.getRoomId() != 0) {
|
||||||
statement.setString(1, wiredData);
|
statement.setString(1, wiredData);
|
||||||
@ -77,12 +172,18 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
super.run();
|
super.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When picking up the wired, all its settings are erased and updated in database
|
||||||
|
*
|
||||||
|
* @param room
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPickUp(Room room) {
|
public void onPickUp(Room room) {
|
||||||
this.wiredSettings = null;
|
this.wiredSettings.dispose();
|
||||||
//TODO not sure about this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadDefaultParams() {}
|
||||||
|
|
||||||
public void activateBox(Room room) {
|
public void activateBox(Room room) {
|
||||||
this.activateBox(room, null, 0L);
|
this.activateBox(room, null, 0L);
|
||||||
}
|
}
|
||||||
@ -123,7 +224,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
long lastTimestamp = this.userExecutionCache.get(roomUnitId);
|
long lastTimestamp = this.userExecutionCache.get(roomUnitId);
|
||||||
return timestamp - lastTimestamp >= 100L;
|
return timestamp - lastTimestamp >= 100L;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -135,50 +235,4 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
public void addUserExecutionCache(int roomUnitId, long timestamp) {
|
public void addUserExecutionCache(int roomUnitId, long timestamp) {
|
||||||
this.userExecutionCache.put(roomUnitId, timestamp);
|
this.userExecutionCache.put(roomUnitId, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadWiredSettings(ClientMessage packet, boolean isWiredEffect) {
|
|
||||||
WiredSettings settings = new WiredSettings();
|
|
||||||
|
|
||||||
int intParamCount = packet.readInt();
|
|
||||||
List<Integer> integerParams = new ArrayList<>();
|
|
||||||
|
|
||||||
for(int i = 0; i < intParamCount; i++)
|
|
||||||
{
|
|
||||||
integerParams.add(packet.readInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.setIntegerParams(integerParams);
|
|
||||||
settings.setStringParam(packet.readString());
|
|
||||||
|
|
||||||
int itemCount = packet.readInt();
|
|
||||||
List<Integer> itemIds = new ArrayList<>();
|
|
||||||
|
|
||||||
for(int i = 0; i < itemCount; i++)
|
|
||||||
{
|
|
||||||
itemIds.add(packet.readInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.setItemIds(itemIds);
|
|
||||||
|
|
||||||
if(isWiredEffect)
|
|
||||||
{
|
|
||||||
settings.setDelay(packet.readInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.setSelectionType(packet.readInt());
|
|
||||||
|
|
||||||
this.wiredSettings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadWiredSettings(ResultSet set, Room room) throws SQLException {
|
|
||||||
String wiredData = set.getString("wired_data");
|
|
||||||
|
|
||||||
WiredSettings settings = new WiredSettings();
|
|
||||||
|
|
||||||
if(wiredData.startsWith("{")) {
|
|
||||||
settings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.wiredSettings = settings;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,6 @@ public abstract class InteractionWiredCondition extends InteractionWired {
|
|||||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) {
|
|
||||||
if (client != null) {
|
|
||||||
if (room.hasRights(client.getHabbo())) {
|
|
||||||
client.sendResponse(new WiredConditionDataComposer(this, room));
|
|
||||||
this.activateBox(room);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract WiredConditionType getType();
|
public abstract WiredConditionType getType();
|
||||||
|
|
||||||
public WiredConditionOperator operator() {
|
public WiredConditionOperator operator() {
|
||||||
|
@ -48,16 +48,6 @@ public abstract class InteractionWiredEffect extends InteractionWired implements
|
|||||||
return blockedTriggers;
|
return blockedTriggers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
|
||||||
if (client != null) {
|
|
||||||
if (room.hasRights(client.getHabbo())) {
|
|
||||||
client.sendResponse(new WiredEffectDataComposer(this, room));
|
|
||||||
this.activateBox(room);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean requiresTriggeringUser() {
|
public boolean requiresTriggeringUser() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -45,18 +45,7 @@ public abstract class InteractionWiredTrigger extends InteractionWired implement
|
|||||||
return blockedEffects;
|
return blockedEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(GameClient client, Room room, Object[] objects) {
|
|
||||||
if (client != null) {
|
|
||||||
if (room.hasRights(client.getHabbo())) {
|
|
||||||
client.sendResponse(new WiredTriggerDataComposer(this, room));
|
|
||||||
this.activateBox(room);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTriggeredByRoomUnit() {
|
public boolean isTriggeredByRoomUnit() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired;
|
|||||||
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings;
|
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
@ -29,7 +30,7 @@ public class WiredSettings implements IWiredSettings {
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private int selectionType;
|
private transient int selectionType;
|
||||||
|
|
||||||
public WiredSettings() {
|
public WiredSettings() {
|
||||||
this.itemIds = new ArrayList<>();
|
this.itemIds = new ArrayList<>();
|
||||||
@ -42,11 +43,15 @@ public class WiredSettings implements IWiredSettings {
|
|||||||
public THashSet<HabboItem> getItems(Room room) {
|
public THashSet<HabboItem> getItems(Room room) {
|
||||||
THashSet<HabboItem> items = new THashSet<>();
|
THashSet<HabboItem> items = new THashSet<>();
|
||||||
|
|
||||||
for(int itemId : this.itemIds) {
|
if(this.itemIds.size() == 0) {
|
||||||
HabboItem item = room.getHabboItem(itemId);
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < this.itemIds.size(); i++) {
|
||||||
|
HabboItem item = room.getHabboItem(this.itemIds.get(i));
|
||||||
|
|
||||||
if(item == null || item.getRoomId() == 0) {
|
if(item == null || item.getRoomId() == 0) {
|
||||||
this.itemIds.remove(itemId);
|
this.itemIds.remove(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,4 +60,12 @@ public class WiredSettings implements IWiredSettings {
|
|||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
this.integerParams.clear();
|
||||||
|
this.itemIds.clear();
|
||||||
|
this.stringParam = "";
|
||||||
|
this.delay = 0;
|
||||||
|
this.selectionType = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement
|
|||||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadDefaultParams() {
|
||||||
|
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||||
|
this.getWiredSettings().getIntegerParams().add(0);
|
||||||
|
this.getWiredSettings().getIntegerParams().add(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||||
if(this.getWiredSettings().getItemIds().isEmpty()) {
|
if(this.getWiredSettings().getItemIds().isEmpty()) {
|
||||||
|
@ -4,8 +4,6 @@ import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
|||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
public interface IWiredInteraction {
|
public interface IWiredInteraction {
|
||||||
String getWiredData();
|
|
||||||
void setWiredData(String value);
|
|
||||||
WiredSettings getWiredSettings();
|
WiredSettings getWiredSettings();
|
||||||
void setWiredSettings(WiredSettings value);
|
void setWiredSettings(WiredSettings value);
|
||||||
boolean execute(RoomUnit roomUnit, Room room, Object[] stuff);
|
boolean execute(RoomUnit roomUnit, Room room, Object[] stuff);
|
||||||
|
@ -2,18 +2,16 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
|
|||||||
|
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
|
||||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
|
public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
|
||||||
|
public final int PARAM_ANY_USER = 0;
|
||||||
public WiredTriggerHabboEntersRoom(ResultSet set, Item baseItem) throws SQLException {
|
public WiredTriggerHabboEntersRoom(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
}
|
}
|
||||||
@ -24,7 +22,9 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||||
if(this.getWiredSettings().getStringParam().isEmpty()) {
|
boolean anyUser = this.getWiredSettings().getIntegerParams().get(PARAM_ANY_USER) == 0;
|
||||||
|
|
||||||
|
if(this.getWiredSettings().getStringParam().isEmpty() && !anyUser || anyUser) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +37,13 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadDefaultParams() {
|
||||||
|
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||||
|
this.getWiredSettings().getIntegerParams().add(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WiredTriggerType getType() {
|
public WiredTriggerType getType() {
|
||||||
return WiredTriggerType.ENTER_ROOM;
|
return WiredTriggerType.ENTER_ROOM;
|
||||||
|
@ -24,6 +24,13 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
|||||||
super(id, userId, item, extraData, limitedStack, limitedSells);
|
super(id, userId, item, extraData, limitedStack, limitedSells);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadDefaultParams() {
|
||||||
|
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||||
|
this.getWiredSettings().getIntegerParams().add(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||||
if (this.getWiredSettings().getStringParam().isEmpty()) {
|
if (this.getWiredSettings().getStringParam().isEmpty()) {
|
||||||
|
@ -31,24 +31,15 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadDefaultParams() {
|
||||||
|
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||||
|
this.getWiredSettings().getIntegerParams().add(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cycle(Room room) {
|
public void cycle(Room room) {
|
||||||
if(this.getWiredSettings() == null) {
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
|
|
||||||
try (PreparedStatement statement = connection.prepareStatement("SELECT id, wired_data FROM items WHERE room_id = ? AND wired_data<>''")) {
|
|
||||||
statement.setInt(1, room.getId());
|
|
||||||
|
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
|
||||||
while (set.next()) {
|
|
||||||
this.loadWiredSettings(set, room);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.counter += 500;
|
this.counter += 500;
|
||||||
if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500) {
|
if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500) {
|
||||||
this.counter = 0;
|
this.counter = 0;
|
||||||
|
@ -14,9 +14,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset {
|
public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset {
|
||||||
public static final int DEFAULT_DELAY = 10 * 5000;
|
|
||||||
private static final int PARAM_REPEAT_TIME = 0;
|
private static final int PARAM_REPEAT_TIME = 0;
|
||||||
private int repeatTime = DEFAULT_DELAY;
|
|
||||||
private int counter = 0;
|
private int counter = 0;
|
||||||
|
|
||||||
public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException {
|
public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException {
|
||||||
@ -32,6 +30,13 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadDefaultParams() {
|
||||||
|
if(this.getWiredSettings().getIntegerParams().size() == 0) {
|
||||||
|
this.getWiredSettings().getIntegerParams().add(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cycle(Room room) {
|
public void cycle(Room room) {
|
||||||
this.counter += 500;
|
this.counter += 500;
|
||||||
|
@ -498,7 +498,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
HabboItem item = this.getHabboItem(set.getInt("id"));
|
HabboItem item = this.getHabboItem(set.getInt("id"));
|
||||||
|
|
||||||
if (item instanceof InteractionWired interactionWired) {
|
if (item instanceof InteractionWired interactionWired) {
|
||||||
interactionWired.loadWiredSettings(set, this);
|
interactionWired.loadWiredSettings(set);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.eu.habbo.messages.incoming.wired;
|
package com.eu.habbo.messages.incoming.wired;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
@ -28,7 +26,7 @@ public class UpdateActionEvent extends MessageHandler {
|
|||||||
throw new WiredSaveException(String.format("Wired effect with item id %s not found in room", itemId));
|
throw new WiredSaveException(String.format("Wired effect with item id %s not found in room", itemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
effect.loadWiredSettings(this.packet, true);
|
effect.saveWiredSettings(this.packet);
|
||||||
this.client.sendResponse(new WiredSavedComposer());
|
this.client.sendResponse(new WiredSavedComposer());
|
||||||
effect.needsUpdate(true);
|
effect.needsUpdate(true);
|
||||||
Emulator.getThreading().run(effect);
|
Emulator.getThreading().run(effect);
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.eu.habbo.messages.incoming.wired;
|
package com.eu.habbo.messages.incoming.wired;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
@ -26,7 +24,7 @@ public class UpdateConditionEvent extends MessageHandler {
|
|||||||
throw new WiredSaveException(String.format("Wired condition with item id %s not found in room", itemId));
|
throw new WiredSaveException(String.format("Wired condition with item id %s not found in room", itemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
condition.loadWiredSettings(this.packet, true);
|
condition.saveWiredSettings(this.packet);
|
||||||
this.client.sendResponse(new WiredSavedComposer());
|
this.client.sendResponse(new WiredSavedComposer());
|
||||||
condition.needsUpdate(true);
|
condition.needsUpdate(true);
|
||||||
Emulator.getThreading().run(condition);
|
Emulator.getThreading().run(condition);
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.eu.habbo.messages.incoming.wired;
|
package com.eu.habbo.messages.incoming.wired;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
@ -26,7 +24,7 @@ public class UpdateTriggerEvent extends MessageHandler {
|
|||||||
throw new WiredSaveException(String.format("Wired trigger with item id %s not found in room", itemId));
|
throw new WiredSaveException(String.format("Wired trigger with item id %s not found in room", itemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger.loadWiredSettings(this.packet, false);
|
trigger.saveWiredSettings(this.packet);
|
||||||
this.client.sendResponse(new WiredSavedComposer());
|
this.client.sendResponse(new WiredSavedComposer());
|
||||||
trigger.needsUpdate(true);
|
trigger.needsUpdate(true);
|
||||||
Emulator.getThreading().run(trigger);
|
Emulator.getThreading().run(trigger);
|
||||||
|
@ -16,7 +16,6 @@ public class WiredConditionDataComposer extends MessageComposer {
|
|||||||
@Override
|
@Override
|
||||||
protected ServerMessage composeInternal() {
|
protected ServerMessage composeInternal() {
|
||||||
this.response.init(Outgoing.wiredConditionDataComposer);
|
this.response.init(Outgoing.wiredConditionDataComposer);
|
||||||
// this.condition.serializeWiredData(this.response, this.room); @DEPRECATED
|
|
||||||
|
|
||||||
this.response.appendBoolean(false);
|
this.response.appendBoolean(false);
|
||||||
this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||||
|
@ -17,8 +17,6 @@ public class WiredEffectDataComposer extends MessageComposer {
|
|||||||
protected ServerMessage composeInternal() {
|
protected ServerMessage composeInternal() {
|
||||||
this.response.init(Outgoing.wiredEffectDataComposer);
|
this.response.init(Outgoing.wiredEffectDataComposer);
|
||||||
|
|
||||||
// this.effect.serializeWiredData(this.response, this.room); @DEPRECATED
|
|
||||||
|
|
||||||
this.response.appendBoolean(false);
|
this.response.appendBoolean(false);
|
||||||
this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||||
this.response.appendInt(this.effect.getWiredSettings().getItemIds().size());
|
this.response.appendInt(this.effect.getWiredSettings().getItemIds().size());
|
||||||
|
@ -16,7 +16,6 @@ public class WiredTriggerDataComposer extends MessageComposer {
|
|||||||
@Override
|
@Override
|
||||||
protected ServerMessage composeInternal() {
|
protected ServerMessage composeInternal() {
|
||||||
this.response.init(Outgoing.wiredTriggerDataComposer);
|
this.response.init(Outgoing.wiredTriggerDataComposer);
|
||||||
// this.trigger.serializeWiredData(this.response, this.room); @DEPRECATED
|
|
||||||
|
|
||||||
this.response.appendBoolean(false);
|
this.response.appendBoolean(false);
|
||||||
this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
this.response.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
|
||||||
|
Loading…
Reference in New Issue
Block a user