WiredData now saves as JSON import fixes

This commit is contained in:
Remco 2021-01-04 19:03:42 +01:00
parent 5720adf61c
commit 75b61b1809
14 changed files with 38 additions and 23 deletions

View File

@ -19,6 +19,8 @@ import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implements ICycleable {

View File

@ -10,6 +10,7 @@ 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.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;

View File

@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.WiredResetTimers;
@ -92,15 +93,15 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException {
String data = set.getString("wired_data");
String wiredData = set.getString("wired_data");
if (data.startsWith("{")) {
if (wiredData.startsWith("{")) {
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
this.delay = data.delay;
} else {
try {
if (!data.equals("")) {
this.delay = Integer.valueOf(data);
if (!wiredData.equals("")) {
this.delay = Integer.parseInt(wiredData);
}
} catch (Exception e) {
}

View File

@ -26,6 +26,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class WiredEffectTeleport extends InteractionWiredEffect {
public static final WiredEffectType type = WiredEffectType.TELEPORT;
@ -182,7 +183,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
@Override
public String getWiredData() {
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.delay,
this.getDelay(),
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
));
}
@ -205,12 +206,12 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
String[] wiredDataOld = wiredData.split("\t");
if (wiredDataOld.length >= 1) {
this.setDelay(Integer.valueOf(wiredDataOld[0]));
this.setDelay(Integer.parseInt(wiredDataOld[0]));
}
if (wiredDataOld.length == 2) {
if (wiredDataOld[1].contains(";")) {
for (String s : wiredDataOld[1].split(";")) {
HabboItem item = room.getHabboItem(Integer.valueOf(s));
HabboItem item = room.getHabboItem(Integer.parseInt(s));
if (item != null)
this.items.add(item);

View File

@ -35,6 +35,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class WiredEffectToggleFurni extends InteractionWiredEffect {
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleFurni.class);
@ -193,7 +194,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
int state = 0;
if (!item.getExtradata().isEmpty()) {
try {
state = Integer.valueOf(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc.
state = Integer.parseInt(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc.
} catch (NumberFormatException ignored) {
}
@ -241,12 +242,12 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
String[] wiredDataOld = wiredData.split("\t");
if (wiredDataOld.length >= 1) {
this.setDelay(Integer.valueOf(wiredDataOld[0]));
this.setDelay(Integer.parseInt(wiredDataOld[0]));
}
if (wiredDataOld.length == 2) {
if (wiredDataOld[1].contains(";")) {
for (String s : wiredDataOld[1].split(";")) {
HabboItem item = room.getHabboItem(Integer.valueOf(s));
HabboItem item = room.getHabboItem(Integer.parseInt(s));
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
continue;

View File

@ -32,6 +32,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class WiredEffectToggleRandom extends InteractionWiredEffect {
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleRandom.class);
@ -219,12 +220,12 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
String[] wiredDataOld = wiredData.split("\t");
if (wiredDataOld.length >= 1) {
this.setDelay(Integer.valueOf(wiredDataOld[0]));
this.setDelay(Integer.parseInt(wiredDataOld[0]));
}
if (wiredDataOld.length == 2) {
if (wiredDataOld[1].contains(";")) {
for (String s : wiredDataOld[1].split(";")) {
HabboItem item = room.getHabboItem(Integer.valueOf(s));
HabboItem item = room.getHabboItem(Integer.parseInt(s));
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
continue;

View File

@ -21,6 +21,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class WiredEffectTriggerStacks extends InteractionWiredEffect {
public static final WiredEffectType type = WiredEffectType.CALL_STACKS;
@ -180,12 +181,12 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
String[] wiredDataOld = wiredData.split("\t");
if (wiredDataOld.length >= 1) {
this.setDelay(Integer.valueOf(wiredDataOld[0]));
this.setDelay(Integer.parseInt(wiredDataOld[0]));
}
if (wiredDataOld.length == 2) {
if (wiredDataOld[1].contains(";")) {
for (String s : wiredDataOld[1].split(";")) {
HabboItem item = room.getHabboItem(Integer.valueOf(s));
HabboItem item = room.getHabboItem(Integer.parseInt(s));
if (item != null)
this.items.add(item);

View File

@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
import com.eu.habbo.habbohotel.rooms.Room;
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.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
@ -53,7 +54,7 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi
this.executeTime = data.executeTime;
} else {
if (wiredData.length() >= 1) {
this.executeTime = (Integer.valueOf(wiredData));
this.executeTime = (Integer.parseInt(wiredData));
}
}

View File

@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
import com.eu.habbo.habbohotel.rooms.Room;
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.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
@ -52,7 +53,7 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W
this.executeTime = data.executeTime;
} else {
if (wiredData.length() >= 1) {
this.executeTime = (Integer.valueOf(wiredData));
this.executeTime = (Integer.parseInt(wiredData));
}
}

View File

@ -21,6 +21,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
private static final Logger LOGGER = LoggerFactory.getLogger(WiredTriggerBotReachedFurni.class);
@ -154,9 +155,9 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
String[] items = data[1].split(";");
for (int i = 0; i < items.length; i++) {
for (String id : items) {
try {
HabboItem item = room.getHabboItem(Integer.valueOf(items[i]));
HabboItem item = room.getHabboItem(Integer.parseInt(id));
if (item != null)
this.items.add(item);

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
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.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
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.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
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.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;

View File

@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
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.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
@ -51,7 +52,7 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger {
this.score = data.score;
} else {
try {
this.score = Integer.valueOf(wiredData);
this.score = Integer.parseInt(wiredData);
} catch (Exception e) {
}
}