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
fix(wired): guard extra selector payloads
This commit is contained in:
+1
-1
@@ -80,7 +80,7 @@ public class WiredExtraAnimationTime extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
this.durationMs = normalizeDuration((data != null) ? data.durationMs : WiredMovementsComposer.DEFAULT_DURATION);
|
this.durationMs = normalizeDuration((data != null) ? data.durationMs : WiredMovementsComposer.DEFAULT_DURATION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ public class WiredExtraContextVariable extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.variableName = WiredVariableNameValidator.normalizeLegacy(data.variableName);
|
this.variableName = WiredVariableNameValidator.normalizeLegacy(data.variableName);
|
||||||
|
|||||||
+1
-1
@@ -86,7 +86,7 @@ public class WiredExtraExecutionLimit extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.maxExecutions = normalizeExecutions(data.maxExecutions);
|
this.maxExecutions = normalizeExecutions(data.maxExecutions);
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ public class WiredExtraFilterFurni extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
this.amount = normalizeAmount((data != null) ? data.amount : 0);
|
this.amount = normalizeAmount((data != null) ? data.amount : 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ public class WiredExtraFilterUser extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
this.amount = normalizeAmount((data != null) ? data.amount : 0);
|
this.amount = normalizeAmount((data != null) ? data.amount : 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -89,7 +89,7 @@ public class WiredExtraFurniVariable extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.variableName = WiredVariableNameValidator.normalizeLegacy(data.variableName);
|
this.variableName = WiredVariableNameValidator.normalizeLegacy(data.variableName);
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ public class WiredExtraMoveCarryUsers extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.carryMode = this.normalizeCarryMode(data.carryMode);
|
this.carryMode = this.normalizeCarryMode(data.carryMode);
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ public class WiredExtraMovePhysics extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.keepAltitude = data.keepAltitude;
|
this.keepAltitude = data.keepAltitude;
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ public class WiredExtraOrEval extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.evaluationMode = normalizeEvaluationMode(data.evaluationMode);
|
this.evaluationMode = normalizeEvaluationMode(data.evaluationMode);
|
||||||
|
|||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items.interactions.wired.extra;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||||
|
|
||||||
|
final class WiredExtraPayloadGuard {
|
||||||
|
private WiredExtraPayloadGuard() {
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> T fromJson(String wiredData, Class<T> type) {
|
||||||
|
if (wiredData == null || !wiredData.startsWith("{")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return WiredManager.getGson().fromJson(wiredData, type);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -92,7 +92,7 @@ public class WiredExtraRandom extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
this.pickAmount = normalizePickAmount((data != null) ? data.pickAmount : DEFAULT_PICK_AMOUNT);
|
this.pickAmount = normalizePickAmount((data != null) ? data.pickAmount : DEFAULT_PICK_AMOUNT);
|
||||||
this.skipExecutions = normalizeSkipExecutions((data != null) ? data.skipExecutions : DEFAULT_SKIP_EXECUTIONS);
|
this.skipExecutions = normalizeSkipExecutions((data != null) ? data.skipExecutions : DEFAULT_SKIP_EXECUTIONS);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+1
-1
@@ -91,7 +91,7 @@ public class WiredExtraRoomVariable extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.variableName = WiredVariableNameValidator.normalizeLegacy(data.variableName);
|
this.variableName = WiredVariableNameValidator.normalizeLegacy(data.variableName);
|
||||||
|
|||||||
+1
-1
@@ -110,7 +110,7 @@ public class WiredExtraTextInputVariable extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.variableToken = normalizeVariableToken((data.variableToken != null)
|
this.variableToken = normalizeVariableToken((data.variableToken != null)
|
||||||
|
|||||||
+1
-1
@@ -131,7 +131,7 @@ public class WiredExtraTextOutputFurniName extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.placeholderName = normalizePlaceholderName(data.placeholderName);
|
this.placeholderName = normalizePlaceholderName(data.placeholderName);
|
||||||
|
|||||||
+1
-1
@@ -88,7 +88,7 @@ public class WiredExtraTextOutputUsername extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.placeholderName = normalizePlaceholderName(data.placeholderName);
|
this.placeholderName = normalizePlaceholderName(data.placeholderName);
|
||||||
|
|||||||
+1
-1
@@ -181,7 +181,7 @@ public class WiredExtraTextOutputVariable extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.targetType = normalizeTargetType(data.targetType);
|
this.targetType = normalizeTargetType(data.targetType);
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ public class WiredExtraUserVariable extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.variableName = WiredVariableNameValidator.normalizeLegacy(data.variableName);
|
this.variableName = WiredVariableNameValidator.normalizeLegacy(data.variableName);
|
||||||
|
|||||||
+2
-2
@@ -148,7 +148,7 @@ public class WiredExtraVariableEcho extends InteractionWiredExtra {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -488,7 +488,7 @@ public class WiredExtraVariableEcho extends InteractionWiredExtra {
|
|||||||
return new ConfigData();
|
return new ConfigData();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigData config = WiredManager.getGson().fromJson(value, ConfigData.class);
|
ConfigData config = WiredExtraPayloadGuard.fromJson(value, ConfigData.class);
|
||||||
return (config != null) ? config : new ConfigData();
|
return (config != null) ? config : new ConfigData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -215,7 +215,7 @@ public abstract class WiredExtraVariableFilterBase extends InteractionWiredExtra
|
|||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
if (wiredData == null || wiredData.isEmpty() || !wiredData.startsWith("{")) return;
|
if (wiredData == null || wiredData.isEmpty() || !wiredData.startsWith("{")) return;
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
|
|
||||||
this.sortBy = normalizeSortBy(data.sortBy);
|
this.sortBy = normalizeSortBy(data.sortBy);
|
||||||
|
|||||||
+1
-1
@@ -188,7 +188,7 @@ public class WiredExtraVariableLevelUpSystem extends InteractionWiredExtra {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (value.trim().startsWith("{")) {
|
if (value.trim().startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(value, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(value, JsonData.class);
|
||||||
return (data != null) ? data : new JsonData();
|
return (data != null) ? data : new JsonData();
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
|||||||
+2
-2
@@ -120,7 +120,7 @@ public class WiredExtraVariableReference extends InteractionWiredExtra {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ public class WiredExtraVariableReference extends InteractionWiredExtra {
|
|||||||
return new ConfigData();
|
return new ConfigData();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigData config = WiredManager.getGson().fromJson(value, ConfigData.class);
|
ConfigData config = WiredExtraPayloadGuard.fromJson(value, ConfigData.class);
|
||||||
return (config != null) ? config : new ConfigData();
|
return (config != null) ? config : new ConfigData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ public class WiredExtraVariableTextConnector extends InteractionWiredExtra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredExtraPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.setMappingsText(data.mappingsText);
|
this.setMappingsText(data.mappingsText);
|
||||||
|
|||||||
+2
-2
@@ -338,7 +338,7 @@ public final class WiredVariableReferenceSupport {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDefinitionData data = WiredManager.getGson().fromJson(wiredData, UserDefinitionData.class);
|
UserDefinitionData data = WiredExtraPayloadGuard.fromJson(wiredData, UserDefinitionData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -352,7 +352,7 @@ public final class WiredVariableReferenceSupport {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomDefinitionData data = WiredManager.getGson().fromJson(wiredData, RoomDefinitionData.class);
|
RoomDefinitionData data = WiredExtraPayloadGuard.fromJson(wiredData, RoomDefinitionData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -120,7 +120,7 @@ public class WiredEffectFurniAltitude extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -115,7 +115,7 @@ public class WiredEffectFurniArea extends InteractionWiredEffect {
|
|||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
if (wiredData != null && wiredData.startsWith("{")) {
|
if (wiredData != null && wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
this.rootX = data.rootX;
|
this.rootX = data.rootX;
|
||||||
this.rootY = data.rootY;
|
this.rootY = data.rootY;
|
||||||
this.areaWidth = data.width;
|
this.areaWidth = data.width;
|
||||||
|
|||||||
+1
-1
@@ -170,7 +170,7 @@ public class WiredEffectFurniByType extends InteractionWiredEffect {
|
|||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
if (wiredData != null && wiredData.startsWith("{")) {
|
if (wiredData != null && wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
this.sourceType = normalizeSourceType(data.sourceType);
|
this.sourceType = normalizeSourceType(data.sourceType);
|
||||||
this.matchState = data.matchState;
|
this.matchState = data.matchState;
|
||||||
this.filterExisting = data.filterExisting;
|
this.filterExisting = data.filterExisting;
|
||||||
|
|||||||
+1
-1
@@ -329,7 +329,7 @@ public class WiredEffectFurniNeighborhood extends InteractionWiredEffect {
|
|||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
if (wiredData != null && wiredData.startsWith("{")) {
|
if (wiredData != null && wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
this.sourceType = data.sourceType;
|
this.sourceType = data.sourceType;
|
||||||
this.filterExisting = data.filterExisting;
|
this.filterExisting = data.filterExisting;
|
||||||
this.invert = data.invert;
|
this.invert = data.invert;
|
||||||
|
|||||||
+1
-1
@@ -156,7 +156,7 @@ public class WiredEffectFurniOnFurni extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -110,7 +110,7 @@ public class WiredEffectFurniPicks extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ public class WiredEffectFurniSignal extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ public class WiredEffectUsersArea extends InteractionWiredEffect {
|
|||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
|
|
||||||
if (wiredData != null && wiredData.startsWith("{")) {
|
if (wiredData != null && wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
this.rootX = data.rootX;
|
this.rootX = data.rootX;
|
||||||
this.rootY = data.rootY;
|
this.rootY = data.rootY;
|
||||||
this.areaWidth = data.width;
|
this.areaWidth = data.width;
|
||||||
|
|||||||
+1
-1
@@ -120,7 +120,7 @@ public class WiredEffectUsersByAction extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -110,7 +110,7 @@ public class WiredEffectUsersByName extends InteractionWiredEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wiredData.startsWith("{")) {
|
if (wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ public class WiredEffectUsersByType extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -109,7 +109,7 @@ public class WiredEffectUsersGroup extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ public class WiredEffectUsersHandItem extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -333,7 +333,7 @@ public class WiredEffectUsersNeighborhood extends InteractionWiredEffect {
|
|||||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
if (wiredData != null && wiredData.startsWith("{")) {
|
if (wiredData != null && wiredData.startsWith("{")) {
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
this.sourceType = data.sourceType;
|
this.sourceType = data.sourceType;
|
||||||
this.filterExisting = data.filterExisting;
|
this.filterExisting = data.filterExisting;
|
||||||
this.invert = data.invert;
|
this.invert = data.invert;
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ public class WiredEffectUsersOnFurni extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ public class WiredEffectUsersSignal extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ public class WiredEffectUsersTeam extends InteractionWiredEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -222,7 +222,7 @@ public abstract class WiredEffectVariableSelectorBase extends InteractionWiredEf
|
|||||||
String wiredData = set.getString("wired_data");
|
String wiredData = set.getString("wired_data");
|
||||||
if (wiredData == null || wiredData.isEmpty() || !wiredData.startsWith("{")) return;
|
if (wiredData == null || wiredData.isEmpty() || !wiredData.startsWith("{")) return;
|
||||||
|
|
||||||
JsonData data = WiredManager.getGson().fromJson(wiredData, JsonData.class);
|
JsonData data = WiredSelectorPayloadGuard.fromJson(wiredData, JsonData.class);
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
|
|
||||||
this.selectByValue = data.selectByValue;
|
this.selectByValue = data.selectByValue;
|
||||||
|
|||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items.interactions.wired.selector;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.wired.core.WiredManager;
|
||||||
|
|
||||||
|
final class WiredSelectorPayloadGuard {
|
||||||
|
private WiredSelectorPayloadGuard() {
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> T fromJson(String wiredData, Class<T> type) {
|
||||||
|
if (wiredData == null || !wiredData.startsWith("{")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return WiredManager.getGson().fromJson(wiredData, type);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items.interactions.wired.extra;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
|
class WiredExtraPayloadGuardTest {
|
||||||
|
@Test
|
||||||
|
void malformedJsonReturnsNull() {
|
||||||
|
assertNull(WiredExtraPayloadGuard.fromJson("{broken", WiredExtraAnimationTime.JsonData.class));
|
||||||
|
assertNull(WiredExtraPayloadGuard.fromJson(null, WiredExtraAnimationTime.JsonData.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package com.eu.habbo.habbohotel.items.interactions.wired.selector;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
|
class WiredSelectorPayloadGuardTest {
|
||||||
|
@Test
|
||||||
|
void malformedJsonReturnsNull() {
|
||||||
|
assertNull(WiredSelectorPayloadGuard.fromJson("{broken", WiredEffectFurniArea.JsonData.class));
|
||||||
|
assertNull(WiredSelectorPayloadGuard.fromJson(null, WiredEffectFurniArea.JsonData.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user