WiredConditionTeamMember now saves as JSON

This commit is contained in:
Remco 2021-01-04 23:07:36 +01:00
parent bea21b715e
commit 5617cd3da2

View File

@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
@ -41,16 +42,23 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
@Override
public String getWiredData() {
return this.teamColor.type + "";
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.teamColor
));
}
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException {
String data = set.getString("wired_data");
try {
if (!data.equals(""))
this.teamColor = GameTeamColors.values()[Integer.valueOf(data)];
String wiredData = set.getString("wired_data");
if (wiredData.startsWith("{")) {
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
this.teamColor = data.teamColor;
} else {
if (!wiredData.equals(""))
this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)];
}
} catch (Exception e) {
this.teamColor = GameTeamColors.RED;
}
@ -90,4 +98,12 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
return true;
}
static class JsonData {
GameTeamColors teamColor;
public JsonData(GameTeamColors teamColor) {
this.teamColor = teamColor;
}
}
}