mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-10-23 03:13:05 +02:00
Some wired saves as JSON now
This commit is contained in:
parent
8fb1aabc55
commit
31e069938c
@ -49,7 +49,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
message.appendInt(this.settings.size());
|
||||
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
message.appendInt(item.itemId);
|
||||
message.appendInt(item.item_id);
|
||||
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
@ -105,7 +105,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
THashSet<WiredMatchFurniSetting> s = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
|
||||
if (item != null) {
|
||||
if (this.state) {
|
||||
@ -187,7 +187,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
THashSet<WiredMatchFurniSetting> remove = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
if (item == null) {
|
||||
remove.add(setting);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
||||
THashSet<WiredMatchFurniSetting> s = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
|
||||
if (item != null) {
|
||||
boolean stateMatches = !this.state || item.getExtradata().equals(setting.state);
|
||||
@ -124,7 +124,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
||||
message.appendInt(this.settings.size());
|
||||
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
message.appendInt(item.itemId);
|
||||
message.appendInt(item.item_id);
|
||||
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
@ -178,7 +178,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
||||
THashSet<WiredMatchFurniSetting> remove = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
if (item == null) {
|
||||
remove.add(setting);
|
||||
}
|
||||
|
@ -8,9 +8,11 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
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.messages.incoming.wired.WiredSaveException;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -91,20 +93,30 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" +
|
||||
this.botName + ((char) 9) +
|
||||
this.botLook;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.botLook, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.botName = data.bot_name;
|
||||
this.botLook = data.look;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length >= 3) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
this.botName = data[1];
|
||||
this.botLook = data[2];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -129,4 +141,16 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
|
||||
public void setBotLook(String botLook) {
|
||||
this.botLook = botLook;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
String look;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, String look, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.look = look;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,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.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.incoming.wired.WiredSaveException;
|
||||
@ -119,18 +120,30 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + this.botName;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.mode = data.mode;
|
||||
this.botName = data.bot_name;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length == 3) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
this.mode = (data[1].equalsIgnoreCase("1") ? 1 : 0);
|
||||
this.botName = data[2];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -144,4 +157,16 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
int mode;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, int mode, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.mode = mode;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,18 +135,30 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" + this.itemId + "" + ((char) 9) + "" + this.botName;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.itemId, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.itemId = data.item_id;
|
||||
this.botName = data.bot_name;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length == 3) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
this.itemId = Integer.valueOf(data[1]);
|
||||
this.botName = data[2];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -160,4 +172,16 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
int item_id;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, int item_id, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.item_id = item_id;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,13 +122,22 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + "" + this.botName + "" + ((char) 9) + "" + this.message;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String d = set.getString("wired_data");
|
||||
String[] data = d.split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.mode = data.mode;
|
||||
this.botName = data.bot_name;
|
||||
this.message = data.message;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length == 4) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
@ -136,6 +145,9 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
this.botName = data[2];
|
||||
this.message = data[3];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -174,4 +186,18 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
protected long requiredCooldown() {
|
||||
return 500;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
int mode;
|
||||
String message;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, int mode, String message, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.mode = mode;
|
||||
this.message = message;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,12 +145,22 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "" + ((char) 9) + "" + this.mode + "" + ((char) 9) + "" + this.botName + "" + ((char) 9) + "" + this.message;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(((char) 9) + "");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.mode = data.mode;
|
||||
this.botName = data.bot_name;
|
||||
this.message = data.message;
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(((char) 9) + "");
|
||||
|
||||
if (data.length == 4) {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
@ -158,6 +168,9 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
this.botName = data[2];
|
||||
this.message = data[3];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -172,4 +185,18 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
int mode;
|
||||
String message;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, int mode, String message, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.mode = mode;
|
||||
this.message = message;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.BOT_TELEPORT;
|
||||
@ -184,27 +185,43 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t" + this.botName + ";");
|
||||
ArrayList<Integer> itemIds = new ArrayList<>();
|
||||
|
||||
if (this.items != null && !this.items.isEmpty()) {
|
||||
if (this.items != null) {
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() != 0) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
itemIds.add(item.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items = new THashSet<>();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
|
||||
if (wiredData.length >= 2) {
|
||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
||||
String[] data = wiredData[1].split(";");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.botName = data.bot_name;
|
||||
|
||||
for(int itemId : data.items) {
|
||||
HabboItem item = room.getHabboItem(itemId);
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String[] wiredDataSplit = set.getString("wired_data").split("\t");
|
||||
|
||||
if (wiredDataSplit.length >= 2) {
|
||||
this.setDelay(Integer.valueOf(wiredDataSplit[0]));
|
||||
String[] data = wiredDataSplit[1].split(";");
|
||||
|
||||
if (data.length > 1) {
|
||||
this.botName = data[0];
|
||||
@ -217,6 +234,9 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -225,4 +245,16 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
this.items.clear();
|
||||
this.setDelay(0);
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
List<Integer> items;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, List<Integer> items, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.items = items;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,29 +130,45 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t" + this.botName + ";");
|
||||
ArrayList<Integer> itemIds = new ArrayList<>();
|
||||
|
||||
if (this.items != null && !this.items.isEmpty()) {
|
||||
if (this.items != null) {
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() != 0) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
itemIds.add(item.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items = new ArrayList<>();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
|
||||
if (wiredData.length > 1) {
|
||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
||||
String[] data = wiredData[1].split(";");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (data.length >= 1) {
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.botName = data.bot_name;
|
||||
|
||||
for(int itemId : data.items) {
|
||||
HabboItem item = room.getHabboItem(itemId);
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String[] wiredDataSplit = set.getString("wired_data").split("\t");
|
||||
|
||||
if (wiredDataSplit.length >= 2) {
|
||||
this.setDelay(Integer.valueOf(wiredDataSplit[0]));
|
||||
String[] data = wiredDataSplit[1].split(";");
|
||||
|
||||
if (data.length > 1) {
|
||||
this.botName = data[0];
|
||||
|
||||
for (int i = 1; i < data.length; i++) {
|
||||
@ -163,6 +179,9 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -171,4 +190,16 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
|
||||
this.botName = "";
|
||||
this.setDelay(0);
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String bot_name;
|
||||
List<Integer> items;
|
||||
int delay;
|
||||
|
||||
public JsonData(String bot_name, List<Integer> items, int delay) {
|
||||
this.bot_name = bot_name;
|
||||
this.items = items;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
@ -114,18 +116,33 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder data = new StringBuilder(this.getDelay() + "\t" + this.startRotation.getValue() + "\t" + this.blockedAction + "\t" + this.items.size());
|
||||
|
||||
for (Map.Entry<HabboItem, WiredChangeDirectionSetting> entry : this.items.entrySet()) {
|
||||
data.append("\t").append(entry.getKey().getId()).append(":").append(entry.getValue().direction.getValue()).append(":").append(entry.getValue().rotation);
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
ArrayList<WiredChangeDirectionSetting> settings = new ArrayList<>(this.items.values());
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.startRotation, this.blockedAction, settings, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split("\t");
|
||||
|
||||
this.items.clear();
|
||||
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.startRotation = data.start_direction;
|
||||
this.blockedAction = data.blocked_action;
|
||||
|
||||
for(WiredChangeDirectionSetting setting : data.items) {
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.put(item, setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split("\t");
|
||||
|
||||
if (data.length >= 4) {
|
||||
this.setDelay(Integer.parseInt(data[0]));
|
||||
@ -154,6 +171,9 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -181,7 +201,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
message.appendInt(this.getId());
|
||||
message.appendString("");
|
||||
message.appendInt(2);
|
||||
message.appendInt(this.startRotation.getValue());
|
||||
message.appendInt(this.startRotation != null ? this.startRotation.getValue() : 0);
|
||||
message.appendInt(this.blockedAction);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
@ -264,4 +284,18 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
protected long requiredCooldown() {
|
||||
return 495;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
RoomUserRotation start_direction;
|
||||
int blocked_action;
|
||||
List<WiredChangeDirectionSetting> items;
|
||||
int delay;
|
||||
|
||||
public JsonData(RoomUserRotation start_direction, int blocked_action, List<WiredChangeDirectionSetting> items, int delay) {
|
||||
this.start_direction = start_direction;
|
||||
this.blocked_action = blocked_action;
|
||||
this.items = items;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,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.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
@ -101,22 +102,32 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "\t" + this.amount;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.amount, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String wireData = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.amount = data.amount;
|
||||
this.setDelay(data.delay);
|
||||
}
|
||||
else {
|
||||
this.amount = 0;
|
||||
|
||||
if (wireData.split("\t").length >= 2) {
|
||||
super.setDelay(Integer.valueOf(wireData.split("\t")[0]));
|
||||
if (wiredData.split("\t").length >= 2) {
|
||||
super.setDelay(Integer.valueOf(wiredData.split("\t")[0]));
|
||||
|
||||
try {
|
||||
this.amount = Integer.valueOf(this.getWiredData().split("\t")[1]);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -129,4 +140,14 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int amount;
|
||||
int delay;
|
||||
|
||||
public JsonData(int amount, int delay) {
|
||||
this.amount = amount;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,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.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.procedure.TObjectProcedure;
|
||||
@ -101,13 +102,20 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "\t" + this.respects;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.respects, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String wireData = set.getString("wired_data");
|
||||
String[] data = wireData.split("\t");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.respects = data.amount;
|
||||
this.setDelay(data.delay);
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split("\t");
|
||||
this.respects = 0;
|
||||
|
||||
if (data.length >= 2) {
|
||||
@ -118,6 +126,9 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,4 +141,14 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int amount;
|
||||
int delay;
|
||||
|
||||
public JsonData(int amount, int delay) {
|
||||
this.amount = amount;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
@ -56,22 +56,28 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder data = new StringBuilder(this.limit + ":" + this.given + ":" + this.rewardTime + ":" + (this.uniqueRewards ? 1 : 0) + ":" + this.limitationInterval + ":" + this.getDelay() + ":");
|
||||
|
||||
if (this.rewardItems.isEmpty()) {
|
||||
data.append("\t");
|
||||
} else {
|
||||
for (WiredGiveRewardItem item : this.rewardItems) {
|
||||
data.append(item.toString()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
ArrayList<WiredGiveRewardItem> rewards = new ArrayList<>(this.rewardItems);
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.limit, this.given, this.rewardTime, this.uniqueRewards, this.limitationInterval, rewards, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.limit = data.limit;
|
||||
this.given = data.given;
|
||||
this.rewardTime = data.reward_time;
|
||||
this.uniqueRewards = data.unique_rewards;
|
||||
this.limitationInterval = data.limit_interval;
|
||||
this.rewardItems.clear();
|
||||
this.rewardItems.addAll(data.rewards);
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(":");
|
||||
if (data.length > 0) {
|
||||
this.limit = Integer.valueOf(data[0]);
|
||||
this.given = Integer.valueOf(data[1]);
|
||||
@ -94,6 +100,9 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,8 +176,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
@Override
|
||||
public boolean saveData(ClientMessage packet, GameClient gameClient) {
|
||||
if (gameClient.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) {
|
||||
packet.readInt();
|
||||
|
||||
int argsLength = packet.readInt();
|
||||
this.rewardTime = packet.readInt();
|
||||
this.uniqueRewards = packet.readInt() == 1;
|
||||
this.limit = packet.readInt();
|
||||
@ -196,11 +204,10 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
return false;
|
||||
}
|
||||
|
||||
WiredHandler.dropRewards(this.getId());
|
||||
|
||||
packet.readString();
|
||||
packet.readInt();
|
||||
this.setDelay(packet.readInt());
|
||||
|
||||
WiredHandler.dropRewards(this.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -217,4 +224,24 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
|
||||
protected long requiredCooldown() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int limit;
|
||||
int given;
|
||||
int reward_time;
|
||||
boolean unique_rewards;
|
||||
int limit_interval;
|
||||
List<WiredGiveRewardItem> rewards;
|
||||
int delay;
|
||||
|
||||
public JsonData(int limit, int given, int reward_time, boolean unique_rewards, int limit_interval, List<WiredGiveRewardItem> rewards, int delay) {
|
||||
this.limit = limit;
|
||||
this.given = given;
|
||||
this.reward_time = reward_time;
|
||||
this.unique_rewards = unique_rewards;
|
||||
this.limit_interval = limit_interval;
|
||||
this.rewards = rewards;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,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.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.incoming.wired.WiredSaveException;
|
||||
@ -87,18 +88,30 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.score + ";" + this.count + ";" + this.getDelay();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.score, this.count, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.score = data.score;
|
||||
this.count = data.count;
|
||||
this.setDelay(data.delay);
|
||||
}
|
||||
else {
|
||||
String[] data = wiredData.split(";");
|
||||
|
||||
if (data.length == 3) {
|
||||
this.score = Integer.valueOf(data[0]);
|
||||
this.count = Integer.valueOf(data[1]);
|
||||
this.setDelay(Integer.valueOf(data[2]));
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -181,4 +194,16 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int score;
|
||||
int count;
|
||||
int delay;
|
||||
|
||||
public JsonData(int score, int count, int delay) {
|
||||
this.score = score;
|
||||
this.count = count;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
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.messages.incoming.wired.WiredSaveException;
|
||||
@ -59,11 +60,21 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.points + ";" + this.count + ";" + this.teamColor.type + ";" + this.getDelay();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.points, this.count, this.teamColor, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(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.points = data.score;
|
||||
this.count = data.count;
|
||||
this.teamColor = data.team;
|
||||
this.setDelay(data.delay);
|
||||
}
|
||||
else {
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
|
||||
if (data.length == 4) {
|
||||
@ -72,6 +83,9 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
|
||||
this.teamColor = GameTeamColors.values()[Integer.valueOf(data[2])];
|
||||
this.setDelay(Integer.valueOf(data[3]));
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -140,4 +154,18 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int score;
|
||||
int count;
|
||||
GameTeamColors team;
|
||||
int delay;
|
||||
|
||||
public JsonData(int score, int count, GameTeamColors team, int delay) {
|
||||
this.score = score;
|
||||
this.count = count;
|
||||
this.team = team;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,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.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.incoming.wired.WiredSaveException;
|
||||
@ -60,11 +61,19 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "\t" + this.teamColor.type + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.teamColor, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(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.setDelay(data.delay);
|
||||
this.teamColor = data.team;
|
||||
}
|
||||
else {
|
||||
String[] data = set.getString("wired_data").split("\t");
|
||||
|
||||
if (data.length >= 1) {
|
||||
@ -74,6 +83,9 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
|
||||
this.teamColor = GameTeamColors.values()[Integer.valueOf(data[1])];
|
||||
}
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -146,4 +158,14 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
GameTeamColors team;
|
||||
int delay;
|
||||
|
||||
public JsonData(GameTeamColors team, int delay) {
|
||||
this.team = team;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,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.incoming.wired.WiredSaveException;
|
||||
@ -70,11 +71,19 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "\t" + this.message;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(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.setDelay(data.delay);
|
||||
this.message = data.message;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
String[] data = set.getString("wired_data").split("\t");
|
||||
|
||||
@ -89,6 +98,9 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect {
|
||||
this.message = "";
|
||||
this.setDelay(0);
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -155,4 +167,14 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String message;
|
||||
int delay;
|
||||
|
||||
public JsonData(String message, int delay) {
|
||||
this.message = message;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,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.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.incoming.wired.WiredSaveException;
|
||||
@ -55,12 +56,20 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.setDelay(Integer.valueOf(set.getString("wired_data")));
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
}
|
||||
else {
|
||||
this.setDelay(Integer.valueOf(wiredData));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,4 +128,12 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect {
|
||||
this.setDelay(delay);
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
|
||||
public JsonData(int delay) {
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,8 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionMultiHeight;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionRoller;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
@ -52,7 +51,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
return true;
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
if (item != null) {
|
||||
if (this.state && (this.checkForWiredResetPermission && item.allowWiredResetState())) {
|
||||
if (!setting.state.equals(" ") && !item.getExtradata().equals(setting.state)) {
|
||||
@ -92,34 +91,23 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder(this.settings.size() + ":");
|
||||
|
||||
if (this.settings.isEmpty()) {
|
||||
data.append(";");
|
||||
} else {
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
for (WiredMatchFurniSetting item : this.settings) {
|
||||
HabboItem i;
|
||||
|
||||
if (room != null) {
|
||||
i = room.getHabboItem(item.itemId);
|
||||
|
||||
if (i != null) {
|
||||
data.append(item.toString(this.checkForWiredResetPermission && i.allowWiredResetState())).append(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.append(":").append(this.state ? 1 : 0).append(":").append(this.direction ? 1 : 0).append(":").append(this.position ? 1 : 0).append(":").append(this.getDelay());
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.state, this.direction, this.position, new ArrayList<WiredMatchFurniSetting>(this.settings), this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(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.setDelay(data.delay);
|
||||
this.state = data.state;
|
||||
this.direction = data.direction;
|
||||
this.position = data.position;
|
||||
this.settings.clear();
|
||||
this.settings.addAll(data.items);
|
||||
}
|
||||
else {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
|
||||
int itemCount = Integer.parseInt(data[0]);
|
||||
@ -144,6 +132,8 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
this.direction = data[3].equals("1");
|
||||
this.position = data[4].equals("1");
|
||||
this.setDelay(Integer.parseInt(data[5]));
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -169,7 +159,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
message.appendInt(this.settings.size());
|
||||
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
message.appendInt(item.itemId);
|
||||
message.appendInt(item.item_id);
|
||||
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
@ -239,7 +229,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
THashSet<WiredMatchFurniSetting> remove = new THashSet<>();
|
||||
|
||||
for (WiredMatchFurniSetting setting : this.settings) {
|
||||
HabboItem item = room.getHabboItem(setting.itemId);
|
||||
HabboItem item = room.getHabboItem(setting.item_id);
|
||||
if (item == null) {
|
||||
remove.add(setting);
|
||||
}
|
||||
@ -250,4 +240,20 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean state;
|
||||
boolean direction;
|
||||
boolean position;
|
||||
List<WiredMatchFurniSetting> items;
|
||||
int delay;
|
||||
|
||||
public JsonData(boolean state, boolean direction, boolean position, List<WiredMatchFurniSetting> items, int delay) {
|
||||
this.state = state;
|
||||
this.direction = direction;
|
||||
this.position = position;
|
||||
this.items = items;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,9 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredChangeDirectionSetting;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
@ -123,17 +121,27 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "\t" + this.message;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.message, this.getDelay()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String wireData = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.message = data.message;
|
||||
}
|
||||
else {
|
||||
this.message = "";
|
||||
|
||||
if (wireData.split("\t").length >= 2) {
|
||||
super.setDelay(Integer.valueOf(wireData.split("\t")[0]));
|
||||
this.message = wireData.split("\t")[1];
|
||||
if (wiredData.split("\t").length >= 2) {
|
||||
super.setDelay(Integer.valueOf(wiredData.split("\t")[0]));
|
||||
this.message = wiredData.split("\t")[1];
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,4 +160,14 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String message;
|
||||
int delay;
|
||||
|
||||
public JsonData(String message, int delay) {
|
||||
this.message = message;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ package com.eu.habbo.habbohotel.wired;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
||||
|
||||
public class WiredChangeDirectionSetting {
|
||||
public final int itemId;
|
||||
public final int item_id;
|
||||
public int rotation;
|
||||
public RoomUserRotation direction;
|
||||
|
||||
public WiredChangeDirectionSetting(int itemId, int rotation, RoomUserRotation direction) {
|
||||
this.itemId = itemId;
|
||||
this.item_id = itemId;
|
||||
this.rotation = rotation;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.eu.habbo.plugin.events.furniture.wired.WiredConditionFailedEvent;
|
||||
import com.eu.habbo.plugin.events.furniture.wired.WiredStackExecutedEvent;
|
||||
import com.eu.habbo.plugin.events.furniture.wired.WiredStackTriggeredEvent;
|
||||
import com.eu.habbo.plugin.events.users.UserWiredRewardReceived;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -46,6 +47,8 @@ public class WiredHandler {
|
||||
public static int MAXIMUM_FURNI_SELECTION = 5;
|
||||
public static int TELEPORT_DELAY = 500;
|
||||
|
||||
private static GsonBuilder gsonBuilder = null;
|
||||
|
||||
public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) {
|
||||
if (triggerType == WiredTriggerType.CUSTOM) return false;
|
||||
|
||||
@ -247,6 +250,12 @@ public class WiredHandler {
|
||||
return executed;
|
||||
}
|
||||
|
||||
public static GsonBuilder getGsonBuilder() {
|
||||
if(gsonBuilder == null) {
|
||||
gsonBuilder = new GsonBuilder();
|
||||
}
|
||||
return gsonBuilder;
|
||||
}
|
||||
|
||||
public static boolean executeEffectsAtTiles(THashSet<RoomTile> tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) {
|
||||
for (RoomTile tile : tiles) {
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.eu.habbo.habbohotel.wired;
|
||||
|
||||
public class WiredMatchFurniSetting {
|
||||
public final int itemId;
|
||||
public final int item_id;
|
||||
public final String state;
|
||||
public final int rotation;
|
||||
public final int x;
|
||||
public final int y;
|
||||
|
||||
public WiredMatchFurniSetting(int itemId, String state, int rotation, int x, int y) {
|
||||
this.itemId = itemId;
|
||||
this.item_id = itemId;
|
||||
this.state = state.replace("\t\t\t", " ");
|
||||
this.rotation = rotation;
|
||||
this.x = x;
|
||||
@ -21,7 +21,7 @@ public class WiredMatchFurniSetting {
|
||||
}
|
||||
|
||||
public String toString(boolean includeState) {
|
||||
return this.itemId + "-" + (this.state.isEmpty() || !includeState ? " " : this.state) + "-" + this.rotation + "-" + this.x + "-" + this.y;
|
||||
return this.item_id + "-" + (this.state.isEmpty() || !includeState ? " " : this.state) + "-" + this.rotation + "-" + this.x + "-" + this.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user