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