mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-19 07:56:26 +01:00
WiredSettings Serialization on Database
This commit is contained in:
parent
7cf3e3e863
commit
00a81ed5c3
@ -3,11 +3,11 @@ package com.eu.habbo.habbohotel.items.interactions;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.effects.WiredEffectWhisper;
|
|
||||||
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction;
|
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredInteraction;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
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.incoming.wired.WiredSaveException;
|
||||||
@ -40,7 +40,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
private long cooldown;
|
private long cooldown;
|
||||||
private final TLongLongHashMap userExecutionCache = new TLongLongHashMap(3);
|
private final TLongLongHashMap userExecutionCache = new TLongLongHashMap(3);
|
||||||
|
|
||||||
InteractionWired(ResultSet set, Item baseItem) throws SQLException {
|
public InteractionWired(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
this.items = new THashSet<>();
|
this.items = new THashSet<>();
|
||||||
this.wiredData = "";
|
this.wiredData = "";
|
||||||
@ -57,17 +57,14 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff);
|
public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff);
|
||||||
|
|
||||||
public abstract boolean saveData() throws WiredSaveException;
|
public abstract boolean saveData() throws WiredSaveException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (this.needsUpdate()) {
|
if (this.needsUpdate()) {
|
||||||
String wiredData = this.getWiredData();
|
WiredExclusionStrategy exclusionStrategy = new WiredExclusionStrategy(this.wiredSettings);
|
||||||
|
|
||||||
if (wiredData == null) {
|
String wiredData = WiredHandler.getGsonBuilder().setExclusionStrategies(exclusionStrategy).create().toJson(this.wiredSettings);
|
||||||
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) {
|
||||||
@ -105,7 +102,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
return 50L;
|
return 50L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean canExecute(long newMillis) {
|
public boolean canExecute(long newMillis) {
|
||||||
return newMillis - this.cooldown >= this.requiredCooldown();
|
return newMillis - this.cooldown >= this.requiredCooldown();
|
||||||
}
|
}
|
||||||
@ -143,7 +139,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
this.userExecutionCache.put(roomUnitId, timestamp);
|
this.userExecutionCache.put(roomUnitId, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WiredSettings loadWiredSettings(ClientMessage packet, boolean isWiredEffect) {
|
public void loadWiredSettings(ClientMessage packet, boolean isWiredEffect) {
|
||||||
WiredSettings settings = new WiredSettings();
|
WiredSettings settings = new WiredSettings();
|
||||||
|
|
||||||
int intParamCount = packet.readInt();
|
int intParamCount = packet.readInt();
|
||||||
@ -157,8 +153,6 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
settings.setIntegerParams(integerParams);
|
settings.setIntegerParams(integerParams);
|
||||||
settings.setStringParam(packet.readString());
|
settings.setStringParam(packet.readString());
|
||||||
|
|
||||||
System.out.println(settings.getStringParam());
|
|
||||||
|
|
||||||
int itemCount = packet.readInt();
|
int itemCount = packet.readInt();
|
||||||
int[] itemIds = new int[itemCount];
|
int[] itemIds = new int[itemCount];
|
||||||
|
|
||||||
@ -177,29 +171,17 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
|||||||
settings.setSelectionType(packet.readInt());
|
settings.setSelectionType(packet.readInt());
|
||||||
|
|
||||||
this.wiredSettings = settings;
|
this.wiredSettings = settings;
|
||||||
|
|
||||||
return this.wiredSettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadWiredSettings(ResultSet set, Room room) throws SQLException {
|
public void loadWiredSettings(ResultSet set, Room room) throws SQLException {
|
||||||
WiredSettings settings = new WiredSettings();
|
|
||||||
|
|
||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
// if(wiredData.startsWith("{")) {
|
WiredSettings settings = new WiredSettings();
|
||||||
// WiredEffectWhisper.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredEffectWhisper.JsonData.class);
|
|
||||||
// this.getWiredSettings().setDelay(data.delay);
|
if(wiredData.startsWith("{")) {
|
||||||
// this.message = data.message;
|
settings = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredSettings.class);
|
||||||
// }
|
}
|
||||||
// else {
|
|
||||||
// this.message = "";
|
this.wiredSettings = settings;
|
||||||
//
|
|
||||||
// if (wiredData.split("\t").length >= 2) {
|
|
||||||
// super.setDelay(Integer.parseInt(wiredData.split("\t")[0]));
|
|
||||||
// this.message = wiredData.split("\t")[1];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this.needsUpdate(true);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions.wired;
|
package com.eu.habbo.habbohotel.items.interactions.wired;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
public class WiredSettings {
|
public class WiredSettings implements IWiredSettings {
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private int[] integerParams;
|
private int[] integerParams;
|
||||||
|
@ -38,9 +38,6 @@ public class WiredConditionGroupMember extends InteractionWiredCondition {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadWiredSettings(ResultSet set, Room room) {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WiredConditionType getType() {
|
public WiredConditionType getType() {
|
||||||
return type;
|
return type;
|
||||||
|
@ -23,7 +23,7 @@ public class WiredEffectAlert extends WiredEffectWhisper {
|
|||||||
Habbo habbo = room.getHabbo(roomUnit);
|
Habbo habbo = room.getHabbo(roomUnit);
|
||||||
|
|
||||||
if (habbo != null) {
|
if (habbo != null) {
|
||||||
habbo.alert(this.message
|
habbo.alert(this.getWiredSettings().getStringParam()
|
||||||
.replace("%online%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "")
|
.replace("%online%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "")
|
||||||
.replace("%username%", habbo.getHabboInfo().getUsername())
|
.replace("%username%", habbo.getHabboInfo().getUsername())
|
||||||
.replace("%roomsloaded%", Emulator.getGameEnvironment().getRoomManager().loadedRoomsCount() + ""));
|
.replace("%roomsloaded%", Emulator.getGameEnvironment().getRoomManager().loadedRoomsCount() + ""));
|
||||||
|
@ -21,7 +21,7 @@ public class WiredEffectGiveEffect extends WiredEffectWhisper {
|
|||||||
int effectId;
|
int effectId;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
effectId = Integer.parseInt(this.message);
|
effectId = Integer.parseInt(this.getWiredSettings().getStringParam());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper {
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||||
try {
|
try {
|
||||||
int itemId = Integer.parseInt(this.message);
|
int itemId = Integer.parseInt(this.getWiredSettings().getStringParam());
|
||||||
|
|
||||||
Habbo habbo = room.getHabbo(roomUnit);
|
Habbo habbo = room.getHabbo(roomUnit);
|
||||||
|
|
||||||
|
@ -20,8 +20,6 @@ import java.sql.SQLException;
|
|||||||
public class WiredEffectWhisper extends InteractionWiredEffect {
|
public class WiredEffectWhisper extends InteractionWiredEffect {
|
||||||
public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE;
|
public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE;
|
||||||
|
|
||||||
protected String message = "";
|
|
||||||
|
|
||||||
public WiredEffectWhisper(ResultSet set, Item baseItem) throws SQLException {
|
public WiredEffectWhisper(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
}
|
}
|
||||||
@ -31,31 +29,18 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData() throws WiredSaveException {
|
public boolean saveData() {
|
||||||
String message = this.getWiredSettings().getStringParam();
|
|
||||||
|
|
||||||
//TODO Removed ability to `If user has rights of SUPER WIRED can override these two lines`
|
|
||||||
message = Emulator.getGameEnvironment().getWordFilter().filter(message, null);
|
|
||||||
message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
|
|
||||||
|
|
||||||
int delay = this.getWiredSettings().getDelay();
|
|
||||||
|
|
||||||
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
|
|
||||||
throw new WiredSaveException("Delay too long");
|
|
||||||
|
|
||||||
this.message = message;
|
|
||||||
this.getWiredSettings().setDelay(delay);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||||
if (this.message.length() > 0) {
|
if (this.getWiredSettings().getStringParam().length() > 0) {
|
||||||
if (roomUnit != null) {
|
if (roomUnit != null) {
|
||||||
Habbo habbo = room.getHabbo(roomUnit);
|
Habbo habbo = room.getHabbo(roomUnit);
|
||||||
|
|
||||||
if (habbo != null) {
|
if (habbo != null) {
|
||||||
String msg = this.message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + "");
|
String msg = this.getWiredSettings().getStringParam().replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + "");
|
||||||
habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(msg, habbo, habbo, RoomChatMessageBubbles.WIRED)));
|
habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(msg, habbo, habbo, RoomChatMessageBubbles.WIRED)));
|
||||||
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, roomUnit, room, new Object[]{ msg }));
|
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, roomUnit, room, new Object[]{ msg }));
|
||||||
|
|
||||||
@ -66,7 +51,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Habbo h : room.getHabbos()) {
|
for (Habbo h : room.getHabbos()) {
|
||||||
h.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.message.replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED)));
|
h.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.getWiredSettings().getStringParam().replace("%user%", h.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), h, h, RoomChatMessageBubbles.WIRED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -75,11 +60,6 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getWiredData() {
|
|
||||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getWiredSettings().getDelay()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WiredEffectType getType() {
|
public WiredEffectType getType() {
|
||||||
return type;
|
return type;
|
||||||
@ -89,14 +69,4 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
|
|||||||
public boolean requiresTriggeringUser() {
|
public boolean requiresTriggeringUser() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class JsonData {
|
|
||||||
String message;
|
|
||||||
int delay;
|
|
||||||
|
|
||||||
public JsonData(String message, int delay) {
|
|
||||||
this.message = message;
|
|
||||||
this.delay = delay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items.interactions.wired.interfaces;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
public interface IWiredSettings {
|
||||||
|
int[] getIntegerParams();
|
||||||
|
void setIntegerParams(int[] value);
|
||||||
|
String getStringParam();
|
||||||
|
void setStringParam(String value);
|
||||||
|
int[] getItems();
|
||||||
|
void setItems(int[] value);
|
||||||
|
int getDelay();
|
||||||
|
void setDelay(int value);
|
||||||
|
int getSelectionType();
|
||||||
|
void setSelectionType(int value);
|
||||||
|
}
|
@ -16,54 +16,37 @@ import java.sql.SQLException;
|
|||||||
public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
||||||
private static final WiredTriggerType type = WiredTriggerType.SAY_SOMETHING;
|
private static final WiredTriggerType type = WiredTriggerType.SAY_SOMETHING;
|
||||||
|
|
||||||
private boolean ownerOnly = false;
|
private static int PARAM_OWNER_ONLY = 0;
|
||||||
private String key = "";
|
|
||||||
|
|
||||||
public WiredTriggerHabboSaysKeyword(ResultSet set, Item baseItem) throws SQLException {
|
public WiredTriggerHabboSaysKeyword(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WiredTriggerHabboSaysKeyword(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
public WiredTriggerHabboSaysKeyword(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||||
if (this.key.length() > 0) {
|
if (this.getWiredSettings().getStringParam().isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean ownerOnly = this.getWiredSettings().getIntegerParams()[PARAM_OWNER_ONLY] == 1;
|
||||||
|
|
||||||
if (stuff[0] instanceof String) {
|
if (stuff[0] instanceof String) {
|
||||||
if (((String) stuff[0]).toLowerCase().contains(this.key.toLowerCase())) {
|
if (((String) stuff[0]).toLowerCase().contains(this.getWiredSettings().getStringParam().toLowerCase())) {
|
||||||
Habbo habbo = room.getHabbo(roomUnit);
|
Habbo habbo = room.getHabbo(roomUnit);
|
||||||
return !this.ownerOnly || (habbo != null && room.getOwnerId() == habbo.getHabboInfo().getId());
|
return !ownerOnly || (habbo != null && room.getOwnerId() == habbo.getHabboInfo().getId());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWiredData() {
|
public String getWiredData() {
|
||||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
return "";
|
||||||
this.ownerOnly,
|
|
||||||
this.key
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadWiredSettings(ResultSet set, Room room) throws SQLException {
|
|
||||||
String wiredData = set.getString("wired_data");
|
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
|
||||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
|
||||||
this.ownerOnly = data.ownerOnly;
|
|
||||||
this.key = data.key;
|
|
||||||
} else {
|
|
||||||
String[] data = wiredData.split("\t");
|
|
||||||
|
|
||||||
if (data.length == 2) {
|
|
||||||
this.ownerOnly = data[0].equalsIgnoreCase("1");
|
|
||||||
this.key = data[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,10 +56,6 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData() {
|
public boolean saveData() {
|
||||||
if(this.getWiredSettings().getIntegerParams().length < 1) return false;
|
|
||||||
this.ownerOnly = this.getWiredSettings().getIntegerParams()[0] == 1;
|
|
||||||
this.key = this.getWiredSettings().getStringParam();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,14 +63,4 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
|||||||
public boolean isTriggeredByRoomUnit() {
|
public boolean isTriggeredByRoomUnit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class JsonData {
|
|
||||||
boolean ownerOnly;
|
|
||||||
String key;
|
|
||||||
|
|
||||||
public JsonData(boolean ownerOnly, String key) {
|
|
||||||
this.ownerOnly = ownerOnly;
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.eu.habbo.habbohotel.wired;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
|
||||||
|
import com.google.gson.ExclusionStrategy;
|
||||||
|
import com.google.gson.FieldAttributes;
|
||||||
|
|
||||||
|
public class WiredExclusionStrategy implements ExclusionStrategy {
|
||||||
|
private WiredSettings wiredSettings;
|
||||||
|
public WiredExclusionStrategy(WiredSettings settings) {
|
||||||
|
this.wiredSettings = settings;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
|
||||||
|
String fieldName = fieldAttributes.getName();
|
||||||
|
|
||||||
|
switch (fieldName) {
|
||||||
|
case "stringParam":
|
||||||
|
return this.wiredSettings.getStringParam().isEmpty();
|
||||||
|
case "integerParams":
|
||||||
|
return this.wiredSettings.getIntegerParams().length == 0;
|
||||||
|
case "delay":
|
||||||
|
return this.wiredSettings.getDelay() == 0;
|
||||||
|
case "items":
|
||||||
|
return this.wiredSettings.getItems().length == 0;
|
||||||
|
case "selectionType":
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSkipClass(Class<?> aClass) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -29,13 +29,10 @@ public class UpdateActionEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
effect.loadWiredSettings(this.packet, true);
|
effect.loadWiredSettings(this.packet, true);
|
||||||
|
|
||||||
if (effect.saveData()) {
|
|
||||||
this.client.sendResponse(new WiredSavedComposer());
|
this.client.sendResponse(new WiredSavedComposer());
|
||||||
effect.needsUpdate(true);
|
effect.needsUpdate(true);
|
||||||
Emulator.getThreading().run(effect);
|
Emulator.getThreading().run(effect);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (WiredSaveException e) {
|
catch (WiredSaveException e) {
|
||||||
this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage()));
|
this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,10 @@ public class UpdateConditionEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
condition.loadWiredSettings(this.packet, true);
|
condition.loadWiredSettings(this.packet, true);
|
||||||
|
|
||||||
if (condition.saveData()) {
|
|
||||||
this.client.sendResponse(new WiredSavedComposer());
|
this.client.sendResponse(new WiredSavedComposer());
|
||||||
condition.needsUpdate(true);
|
condition.needsUpdate(true);
|
||||||
Emulator.getThreading().run(condition);
|
Emulator.getThreading().run(condition);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (WiredSaveException e) {
|
catch (WiredSaveException e) {
|
||||||
this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage()));
|
this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,10 @@ public class UpdateTriggerEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trigger.loadWiredSettings(this.packet, false);
|
trigger.loadWiredSettings(this.packet, false);
|
||||||
|
|
||||||
if (trigger.saveData()) {
|
|
||||||
this.client.sendResponse(new WiredSavedComposer());
|
this.client.sendResponse(new WiredSavedComposer());
|
||||||
trigger.needsUpdate(true);
|
trigger.needsUpdate(true);
|
||||||
Emulator.getThreading().run(trigger);
|
Emulator.getThreading().run(trigger);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (WiredSaveException e) {
|
catch (WiredSaveException e) {
|
||||||
this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage()));
|
this.client.sendResponse(new WiredValidationErrorComposer(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user