mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 16:30:52 +01:00
Merge branch 'wired-to-json' into 'dev'
Big WiredData to JSON overhaul See merge request morningstar/Arcturus-Community!363
This commit is contained in:
commit
3485e888ab
@ -117,8 +117,5 @@ ADD COLUMN `bubble_id` int(3) NULL DEFAULT 31 AFTER `effect`;
|
||||
ALTER TABLE `permissions` ADD `acc_see_tentchat` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_see_whispers`;
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.room.tent.prefix', 'Tent');
|
||||
|
||||
-- Roombadge command
|
||||
ALTER TABLE `permissions` ADD `cmd_roombadge` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_massbadge`;
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_roombadge.no_badge', 'No badge specified!');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_roombadge', 'roombadge');
|
||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_roombadge', ':roombadge <badge>');
|
||||
-- Making items.wired_data column bigger since wired data is saved as JSON now
|
||||
ALTER TABLE `items` MODIFY COLUMN `wired_data` varchar(10000)
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -64,18 +65,29 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.startDate + "\t" + this.endDate;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.startDate,
|
||||
this.endDate
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
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 == 2) {
|
||||
try {
|
||||
this.startDate = Integer.valueOf(data[0]);
|
||||
this.endDate = Integer.valueOf(data[1]);
|
||||
} catch (Exception e) {
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.startDate = data.startDate;
|
||||
this.endDate = data.endDate;
|
||||
} else {
|
||||
String[] data = wiredData.split("\t");
|
||||
|
||||
if (data.length == 2) {
|
||||
try {
|
||||
this.startDate = Integer.parseInt(data[0]);
|
||||
this.endDate = Integer.parseInt(data[1]);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -85,4 +97,14 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
|
||||
this.startDate = 0;
|
||||
this.endDate = 0;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int startDate;
|
||||
int endDate;
|
||||
|
||||
public JsonData(int startDate, int endDate) {
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI;
|
||||
@ -58,30 +60,43 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
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 >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
if (data.length == 2) {
|
||||
String[] items = data[1].split(";");
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
|
||||
if (data.length == 2) {
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -166,4 +181,14 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean all;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(boolean all, List<Integer> itemIds) {
|
||||
this.all = all;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
|
||||
@ -66,33 +66,43 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
data.append(item.getId()).append(";");
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (data.length == 2) {
|
||||
String[] items = data[1].split(";");
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
if (data.length == 2) {
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -170,4 +180,14 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean all;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(boolean all, List<Integer> itemIds) {
|
||||
this.all = all;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.STUFF_IS;
|
||||
@ -55,23 +57,37 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
|
||||
for (String s : data)
|
||||
this.items.add(room.getHabboItem(Integer.valueOf(s)));
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(";");
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,4 +154,12 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -34,15 +35,26 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.lowerLimit + ":" + this.upperLimit;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.lowerLimit,
|
||||
this.upperLimit
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
this.lowerLimit = Integer.valueOf(data[0]);
|
||||
this.upperLimit = Integer.valueOf(data[1]);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.lowerLimit = data.lowerLimit;
|
||||
this.upperLimit = data.upperLimit;
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
this.lowerLimit = Integer.parseInt(data[0]);
|
||||
this.upperLimit = Integer.parseInt(data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,4 +94,14 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int lowerLimit;
|
||||
int upperLimit;
|
||||
|
||||
public JsonData(int lowerLimit, int upperLimit) {
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -32,12 +33,21 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.effectId + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.effectId
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.effectId = 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.effectId = data.effectId;
|
||||
} else {
|
||||
this.effectId = Integer.parseInt(wiredData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,4 +83,12 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int effectId;
|
||||
|
||||
public JsonData(int effectId) {
|
||||
this.effectId = effectId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import org.slf4j.Logger;
|
||||
@ -66,13 +67,22 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.handItem + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.handItem
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
try {
|
||||
this.handItem = 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.handItem = data.handItemId;
|
||||
} else {
|
||||
this.handItem = Integer.parseInt(wiredData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
}
|
||||
@ -82,4 +92,12 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
|
||||
public void onPickUp() {
|
||||
this.handItem = 0;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int handItemId;
|
||||
|
||||
public JsonData(int handItemId) {
|
||||
this.handItemId = handItemId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -44,12 +45,21 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.badge;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.badge
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.badge = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.badge = data.badge;
|
||||
} else {
|
||||
this.badge = wiredData;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,4 +95,12 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String badge;
|
||||
|
||||
public JsonData(String badge) {
|
||||
this.badge = badge;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -32,16 +33,23 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.cycles + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.cycles
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String data = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
try {
|
||||
if (!data.equals(""))
|
||||
this.cycles = Integer.valueOf(data);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.cycles = data.cycles;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
this.cycles = Integer.parseInt(wiredData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
@ -80,4 +88,12 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int cycles;
|
||||
|
||||
public JsonData(int cycles) {
|
||||
this.cycles = cycles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WiredConditionMatchStatePosition extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT;
|
||||
@ -138,38 +140,42 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder data = new StringBuilder(this.settings.size() + ":");
|
||||
|
||||
if (this.settings.isEmpty()) {
|
||||
data.append("\t;");
|
||||
} else {
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
data.append(item.toString()).append(";");
|
||||
}
|
||||
|
||||
data.append(":").append(this.state ? 1 : 0).append(":").append(this.direction ? 1 : 0).append(":").append(this.position ? 1 : 0);
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.state,
|
||||
this.position,
|
||||
this.direction,
|
||||
new ArrayList<>(this.settings)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
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.valueOf(data[0]);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.state = data.state;
|
||||
this.position = data.position;
|
||||
this.direction = data.direction;
|
||||
this.settings.addAll(data.settings);
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
String[] items = data[1].split(";");
|
||||
int itemCount = Integer.parseInt(data[0]);
|
||||
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
String[] stuff = items[i].split("-");
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
if (stuff.length >= 5)
|
||||
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
String[] stuff = items[i].split("-");
|
||||
|
||||
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])));
|
||||
}
|
||||
|
||||
this.state = data[2].equals("1");
|
||||
this.direction = data[3].equals("1");
|
||||
this.position = data[4].equals("1");
|
||||
}
|
||||
|
||||
this.state = data[2].equals("1");
|
||||
this.direction = data[3].equals("1");
|
||||
this.position = data[4].equals("1");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -198,4 +204,18 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean state;
|
||||
boolean position;
|
||||
boolean direction;
|
||||
List<WiredMatchFurniSetting> settings;
|
||||
|
||||
public JsonData(boolean state, boolean position, boolean direction, List<WiredMatchFurniSetting> settings) {
|
||||
this.state = state;
|
||||
this.position = position;
|
||||
this.direction = direction;
|
||||
this.settings = settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -32,16 +33,23 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.cycles + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.cycles
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String data = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
try {
|
||||
if (!data.equals(""))
|
||||
this.cycles = Integer.valueOf(data);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.cycles = data.cycles;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
this.cycles = Integer.parseInt(wiredData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
@ -80,4 +88,12 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int cycles;
|
||||
|
||||
public JsonData(int cycles) {
|
||||
this.cycles = cycles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI;
|
||||
@ -59,32 +61,43 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
for (int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (data.length == 2) {
|
||||
String[] items = data[1].split(";");
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
if (data.length == 2) {
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,4 +188,14 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
|
||||
//return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR;
|
||||
return WiredConditionOperator.AND;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean all;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(boolean all, List<Integer> itemIds) {
|
||||
this.all = all;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO;
|
||||
@ -66,33 +66,43 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder((this.all ? "1" : "0") + ":");
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
data.append(item.getId()).append(";");
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.all,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class);
|
||||
this.all = data.all;
|
||||
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (data.length == 2) {
|
||||
String[] items = data[1].split(";");
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (data.length >= 1) {
|
||||
this.all = (data[0].equals("1"));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
if (data.length == 2) {
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (String s : items) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,4 +179,14 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean all;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(boolean all, List<Integer> itemIds) {
|
||||
this.all = all;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS;
|
||||
@ -50,23 +52,37 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
|
||||
|
||||
for (String s : data)
|
||||
this.items.add(room.getHabboItem(Integer.valueOf(s)));
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,4 +154,12 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
|
||||
this.items.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -34,14 +35,25 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.lowerLimit + ":" + this.upperLimit;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.lowerLimit,
|
||||
this.upperLimit
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
this.lowerLimit = Integer.valueOf(data[0]);
|
||||
this.upperLimit = Integer.valueOf(data[1]);
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionHabboCount.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionHabboCount.JsonData.class);
|
||||
this.lowerLimit = data.lowerLimit;
|
||||
this.upperLimit = data.upperLimit;
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
this.lowerLimit = Integer.parseInt(data[0]);
|
||||
this.upperLimit = Integer.parseInt(data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,4 +93,14 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int lowerLimit;
|
||||
int upperLimit;
|
||||
|
||||
public JsonData(int lowerLimit, int upperLimit) {
|
||||
this.lowerLimit = lowerLimit;
|
||||
this.upperLimit = upperLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -32,12 +33,21 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.effectId + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.effectId
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.effectId = 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.effectId = data.effectId;
|
||||
} else {
|
||||
this.effectId = Integer.parseInt(wiredData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,4 +83,12 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int effectId;
|
||||
|
||||
public JsonData(int effectId) {
|
||||
this.effectId = effectId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -45,12 +46,21 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.badge;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.badge
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.badge = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.badge = data.badge;
|
||||
} else {
|
||||
this.badge = wiredData;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,4 +96,12 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String badge;
|
||||
|
||||
public JsonData(String badge) {
|
||||
this.badge = badge;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -39,16 +40,23 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.teamColor.type + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.teamColor
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String data = set.getString("wired_data");
|
||||
|
||||
try {
|
||||
if (!data.equals(""))
|
||||
this.teamColor = GameTeamColors.values()[Integer.valueOf(data)];
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.teamColor = data.teamColor;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)];
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.teamColor = GameTeamColors.RED;
|
||||
}
|
||||
@ -88,4 +96,12 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
GameTeamColors teamColor;
|
||||
|
||||
public JsonData(GameTeamColors teamColor) {
|
||||
this.teamColor = teamColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WiredConditionNotMatchStatePosition extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT;
|
||||
@ -68,38 +70,42 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder data = new StringBuilder(this.settings.size() + ":");
|
||||
|
||||
if (this.settings.isEmpty()) {
|
||||
data.append("\t;");
|
||||
} else {
|
||||
for (WiredMatchFurniSetting item : this.settings)
|
||||
data.append(item.toString()).append(";");
|
||||
}
|
||||
|
||||
data.append(":").append(this.state ? 1 : 0).append(":").append(this.rotation ? 1 : 0).append(":").append(this.position ? 1 : 0);
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new WiredConditionMatchStatePosition.JsonData(
|
||||
this.state,
|
||||
this.position,
|
||||
this.rotation,
|
||||
new ArrayList<>(this.settings)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
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.valueOf(data[0]);
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.state = data.state;
|
||||
this.position = data.position;
|
||||
this.rotation = data.direction;
|
||||
this.settings.addAll(data.settings);
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
String[] items = data[1].split(";");
|
||||
int itemCount = Integer.parseInt(data[0]);
|
||||
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
String[] stuff = items[i].split("-");
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
if (stuff.length >= 5)
|
||||
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
String[] stuff = items[i].split("-");
|
||||
|
||||
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])));
|
||||
}
|
||||
|
||||
this.state = data[2].equals("1");
|
||||
this.rotation = data[3].equals("1");
|
||||
this.position = data[4].equals("1");
|
||||
}
|
||||
|
||||
this.state = data[2].equals("1");
|
||||
this.rotation = data[3].equals("1");
|
||||
this.position = data[4].equals("1");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -189,4 +195,18 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean state;
|
||||
boolean position;
|
||||
boolean direction;
|
||||
List<WiredMatchFurniSetting> settings;
|
||||
|
||||
public JsonData(boolean state, boolean position, boolean direction, List<WiredMatchFurniSetting> settings) {
|
||||
this.state = state;
|
||||
this.position = position;
|
||||
this.direction = direction;
|
||||
this.settings = settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
@ -15,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_ON_FURNI;
|
||||
@ -44,26 +45,35 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
for (HabboItem item : this.items)
|
||||
data.append(item.getId()).append(";");
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
if (wiredData.startsWith("{")) {
|
||||
WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(";");
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -139,4 +149,12 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
|
||||
|
||||
this.items.removeAll(items);
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredConditionType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
@ -41,16 +42,23 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.teamColor.type + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.teamColor
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String data = set.getString("wired_data");
|
||||
|
||||
try {
|
||||
if (!data.equals(""))
|
||||
this.teamColor = GameTeamColors.values()[Integer.valueOf(data)];
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.teamColor = data.teamColor;
|
||||
} else {
|
||||
if (!wiredData.equals(""))
|
||||
this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)];
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.teamColor = GameTeamColors.RED;
|
||||
}
|
||||
@ -90,4 +98,12 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
GameTeamColors teamColor;
|
||||
|
||||
public JsonData(GameTeamColors teamColor) {
|
||||
this.teamColor = teamColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
public static final WiredConditionType type = WiredConditionType.TRIGGER_ON_FURNI;
|
||||
@ -67,27 +69,35 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
this.refresh();
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
data.append(item.getId()).append(";");
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(";");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
for(int id : data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(";");
|
||||
|
||||
for (String s : data) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,4 +178,12 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
|
||||
public WiredConditionOperator operator() {
|
||||
return WiredConditionOperator.AND;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 com.eu.habbo.messages.outgoing.hotelview.BonusRareComposer;
|
||||
@ -70,7 +71,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
|
||||
packet.readInt();
|
||||
|
||||
try {
|
||||
this.amount = Integer.valueOf(packet.readString());
|
||||
this.amount = Integer.parseInt(packet.readString());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
@ -103,20 +104,26 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "\t" + this.amount;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.getDelay(), this.amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
super.setDelay(Integer.valueOf(wireData.split("\t")[0]));
|
||||
if(wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.amount = data.amount;
|
||||
} else {
|
||||
if (wiredData.split("\t").length >= 2) {
|
||||
super.setDelay(Integer.parseInt(wiredData.split("\t")[0]));
|
||||
|
||||
try {
|
||||
this.amount = Integer.valueOf(this.getWiredData().split("\t")[1]);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
this.amount = Integer.parseInt(wiredData.split("\t")[1]);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,4 +138,14 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
int amount;
|
||||
|
||||
public JsonData(int delay, int amount) {
|
||||
this.delay = delay;
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.FLEE;
|
||||
@ -98,32 +99,40 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
||||
|
||||
if (this.items != null && !this.items.isEmpty()) {
|
||||
for (HabboItem item : this.items) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items = new THashSet<>();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.length >= 1) {
|
||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
||||
}
|
||||
if (wiredData.length == 2) {
|
||||
if (wiredData[1].contains(";")) {
|
||||
for (String s : wiredData[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] wiredDataOld = wiredData.split("\t");
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
if (wiredDataOld.length >= 1) {
|
||||
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||
}
|
||||
if (wiredDataOld.length == 2) {
|
||||
if (wiredDataOld[1].contains(";")) {
|
||||
for (String s : wiredDataOld[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -206,4 +215,14 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
protected long requiredCooldown() {
|
||||
return 495;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(int delay, List<Integer> itemIds) {
|
||||
this.delay = delay;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.MOVE_FURNI_TO;
|
||||
@ -123,24 +124,23 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
THashSet<HabboItem> items = new THashSet<>();
|
||||
THashSet<HabboItem> itemsToRemove = new THashSet<>();
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
|
||||
items.add(item);
|
||||
itemsToRemove.add(item);
|
||||
}
|
||||
|
||||
for (HabboItem item : items) {
|
||||
for (HabboItem item : itemsToRemove) {
|
||||
this.items.remove(item);
|
||||
}
|
||||
|
||||
StringBuilder data = new StringBuilder(this.direction + "\t" + this.spacing + "\t" + this.getDelay() + "\t");
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
data.append(item.getId()).append("\r");
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.direction,
|
||||
this.spacing,
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -176,22 +176,37 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split("\t");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.direction = data.direction;
|
||||
this.spacing = data.spacing;
|
||||
this.setDelay(data.delay);
|
||||
|
||||
if (data.length == 4) {
|
||||
try {
|
||||
this.direction = Integer.valueOf(data[0]);
|
||||
this.spacing = Integer.valueOf(data[1]);
|
||||
this.setDelay(Integer.valueOf(data[2]));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
for (String s : data[3].split("\r")) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
|
||||
if (item != null)
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split("\t");
|
||||
|
||||
if (data.length == 4) {
|
||||
try {
|
||||
this.direction = Integer.parseInt(data[0]);
|
||||
this.spacing = Integer.parseInt(data[1]);
|
||||
this.setDelay(Integer.parseInt(data[2]));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
for (String s : data[3].split("\r")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -209,4 +224,18 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
|
||||
protected long requiredCooldown() {
|
||||
return 495;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int direction;
|
||||
int spacing;
|
||||
int delay;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(int direction, int spacing, int delay, List<Integer> itemIds) {
|
||||
this.direction = direction;
|
||||
this.spacing = spacing;
|
||||
this.delay = delay;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Wired effect: move to closest user
|
||||
@ -233,32 +234,41 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
||||
|
||||
if (this.items != null && !this.items.isEmpty()) {
|
||||
for (HabboItem item : this.items) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items = new THashSet<>();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.length >= 1) {
|
||||
this.setDelay(Integer.parseInt(wiredData[0]));
|
||||
}
|
||||
if (wiredData.length == 2) {
|
||||
if (wiredData[1].contains(";")) {
|
||||
for (String s : wiredData[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] wiredDataOld = wiredData.split("\t");
|
||||
|
||||
if (wiredDataOld.length >= 1) {
|
||||
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||
}
|
||||
if (wiredDataOld.length == 2) {
|
||||
if (wiredDataOld[1].contains(";")) {
|
||||
for (String s : wiredDataOld[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -342,4 +352,14 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
protected long requiredCooldown() {
|
||||
return 495;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(int delay, List<Integer> itemIds) {
|
||||
this.delay = delay;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ import org.slf4j.LoggerFactory;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implements ICycleable {
|
||||
|
||||
@ -80,50 +82,61 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
THashSet<HabboItem> items = new THashSet<>(this.items.size() / 2);
|
||||
THashSet<HabboItem> itemsToRemove = new THashSet<>(this.items.size() / 2);
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() != this.getRoomId() || (room != null && room.getHabboItem(item.getId()) == null))
|
||||
items.add(item);
|
||||
itemsToRemove.add(item);
|
||||
}
|
||||
|
||||
for (HabboItem item : items) {
|
||||
for (HabboItem item : itemsToRemove) {
|
||||
this.items.remove(item);
|
||||
}
|
||||
|
||||
StringBuilder data = new StringBuilder(this.direction + "\t" +
|
||||
this.rotation + "\t" +
|
||||
this.getDelay() + "\t");
|
||||
|
||||
for (HabboItem item : this.items) {
|
||||
data.append(item.getId()).append("\r");
|
||||
}
|
||||
|
||||
return data.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.direction,
|
||||
this.rotation,
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split("\t");
|
||||
|
||||
if (data.length == 4) {
|
||||
try {
|
||||
this.direction = Integer.parseInt(data[0]);
|
||||
this.rotation = Integer.parseInt(data[1]);
|
||||
this.setDelay(Integer.parseInt(data[2]));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
for (String s : data[3].split("\r")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.direction = data.direction;
|
||||
this.rotation = data.rotation;
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split("\t");
|
||||
|
||||
if (data.length == 4) {
|
||||
try {
|
||||
this.direction = Integer.parseInt(data[0]);
|
||||
this.rotation = Integer.parseInt(data[1]);
|
||||
this.setDelay(Integer.parseInt(data[2]));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
for (String s : data[3].split("\r")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -303,4 +316,18 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement
|
||||
public void cycle(Room room) {
|
||||
this.itemCooldowns.clear();
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int direction;
|
||||
int rotation;
|
||||
int delay;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(int direction, int rotation, int delay, List<Integer> itemIds) {
|
||||
this.direction = direction;
|
||||
this.rotation = rotation;
|
||||
this.delay = delay;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
|
||||
@ -79,19 +80,32 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.getDelay() + "\t" + this.length + "\t" + this.message;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.getDelay(),
|
||||
this.length,
|
||||
this.message
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
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 >= 3) {
|
||||
try {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
this.length = Integer.valueOf(data[1]);
|
||||
this.message = data[2];
|
||||
} catch (Exception e) {
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
this.length = data.length;
|
||||
this.message = data.message;
|
||||
} else {
|
||||
String[] data = wiredData.split("\t");
|
||||
|
||||
if (data.length >= 3) {
|
||||
try {
|
||||
this.setDelay(Integer.valueOf(data[0]));
|
||||
this.length = Integer.valueOf(data[1]);
|
||||
this.message = data[2];
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,4 +126,16 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect {
|
||||
public boolean requiresTriggeringUser() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
int length;
|
||||
String message;
|
||||
|
||||
public JsonData(int delay, int length, String message) {
|
||||
this.delay = delay;
|
||||
this.length = length;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.threading.runnables.WiredResetTimers;
|
||||
@ -85,17 +86,25 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.delay + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.delay
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
String data = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
try {
|
||||
if (!data.equals(""))
|
||||
this.delay = Integer.valueOf(data);
|
||||
} catch (Exception e) {
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.delay = data.delay;
|
||||
} else {
|
||||
try {
|
||||
if (!wiredData.equals("")) {
|
||||
this.delay = Integer.parseInt(wiredData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
this.setDelay(this.delay);
|
||||
@ -111,4 +120,12 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
|
||||
public WiredEffectType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
|
||||
public JsonData(int delay) {
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.TELEPORT;
|
||||
@ -181,32 +182,40 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
||||
|
||||
if (this.items != null && !this.items.isEmpty()) {
|
||||
for (HabboItem item : this.items) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items = new ArrayList<>();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.length >= 1) {
|
||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
||||
}
|
||||
if (wiredData.length == 2) {
|
||||
if (wiredData[1].contains(";")) {
|
||||
for (String s : wiredData[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] wiredDataOld = wiredData.split("\t");
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
if (wiredDataOld.length >= 1) {
|
||||
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||
}
|
||||
if (wiredDataOld.length == 2) {
|
||||
if (wiredDataOld[1].contains(";")) {
|
||||
for (String s : wiredDataOld[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -232,4 +241,14 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
protected long requiredCooldown() {
|
||||
return 50L;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(int delay, List<Integer> itemIds) {
|
||||
this.delay = delay;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleFurni.class);
|
||||
@ -193,7 +194,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
||||
int state = 0;
|
||||
if (!item.getExtradata().isEmpty()) {
|
||||
try {
|
||||
state = Integer.valueOf(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc.
|
||||
state = Integer.parseInt(item.getExtradata()); // assumes that extradata is state, could be something else for trophies etc.
|
||||
} catch (NumberFormatException ignored) {
|
||||
|
||||
}
|
||||
@ -212,35 +213,48 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
||||
|
||||
if (this.items != null && !this.items.isEmpty()) {
|
||||
for (HabboItem item : this.items) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.length >= 1) {
|
||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
||||
}
|
||||
if (wiredData.length == 2) {
|
||||
if (wiredData[1].contains(";")) {
|
||||
for (String s : wiredData[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
|
||||
continue;
|
||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] wiredDataOld = wiredData.split("\t");
|
||||
|
||||
if (wiredDataOld.length >= 1) {
|
||||
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||
}
|
||||
if (wiredDataOld.length == 2) {
|
||||
if (wiredDataOld[1].contains(";")) {
|
||||
for (String s : wiredDataOld[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
|
||||
continue;
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -256,4 +270,14 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
|
||||
public WiredEffectType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(int delay, List<Integer> itemIds) {
|
||||
this.delay = delay;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleRandom.class);
|
||||
@ -192,35 +193,46 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
||||
|
||||
if (!this.items.isEmpty()) {
|
||||
for (HabboItem item : this.items) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.length >= 1) {
|
||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
||||
}
|
||||
if (wiredData.length == 2) {
|
||||
if (wiredData[1].contains(";")) {
|
||||
for (String s : wiredData[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
|
||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
|
||||
continue;
|
||||
|
||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
|
||||
continue;
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
} else {
|
||||
String[] wiredDataOld = wiredData.split("\t");
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
if (wiredDataOld.length >= 1) {
|
||||
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||
}
|
||||
if (wiredDataOld.length == 2) {
|
||||
if (wiredDataOld[1].contains(";")) {
|
||||
for (String s : wiredDataOld[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
|
||||
continue;
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,4 +248,14 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
|
||||
public WiredEffectType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(int delay, List<Integer> itemIds) {
|
||||
this.delay = delay;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredEffectTriggerStacks extends InteractionWiredEffect {
|
||||
public static final WiredEffectType type = WiredEffectType.CALL_STACKS;
|
||||
@ -156,32 +157,40 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.getDelay() + "\t");
|
||||
|
||||
if (this.items != null && !this.items.isEmpty()) {
|
||||
for (HabboItem item : this.items) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.getDelay(),
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items = new THashSet<>();
|
||||
String[] wiredData = set.getString("wired_data").split("\t");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.length >= 1) {
|
||||
this.setDelay(Integer.valueOf(wiredData[0]));
|
||||
}
|
||||
if (wiredData.length == 2) {
|
||||
if (wiredData[1].contains(";")) {
|
||||
for (String s : wiredData[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.setDelay(data.delay);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] wiredDataOld = wiredData.split("\t");
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
if (wiredDataOld.length >= 1) {
|
||||
this.setDelay(Integer.parseInt(wiredDataOld[0]));
|
||||
}
|
||||
if (wiredDataOld.length == 2) {
|
||||
if (wiredDataOld[1].contains(";")) {
|
||||
for (String s : wiredDataOld[1].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -202,4 +211,14 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
|
||||
protected long requiredCooldown() {
|
||||
return 250;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int delay;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(int delay, List<Integer> itemIds) {
|
||||
this.delay = delay;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
@ -39,13 +40,22 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.executeTime + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.executeTime
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
if (set.getString("wired_data").length() >= 1) {
|
||||
this.executeTime = (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.executeTime = data.executeTime;
|
||||
} else {
|
||||
if (wiredData.length() >= 1) {
|
||||
this.executeTime = (Integer.parseInt(wiredData));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.executeTime < 500) {
|
||||
@ -115,4 +125,12 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi
|
||||
|
||||
Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime);
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int executeTime;
|
||||
|
||||
public JsonData(int executeTime) {
|
||||
this.executeTime = executeTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
@ -38,13 +39,22 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.executeTime + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.executeTime
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
if (set.getString("wired_data").length() >= 1) {
|
||||
this.executeTime = (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.executeTime = data.executeTime;
|
||||
} else {
|
||||
if (wiredData.length() >= 1) {
|
||||
this.executeTime = (Integer.parseInt(wiredData));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.executeTime < 500) {
|
||||
@ -113,4 +123,12 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W
|
||||
|
||||
Emulator.getThreading().run(new WiredExecuteTask(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())), this.executeTime);
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int executeTime;
|
||||
|
||||
public JsonData(int executeTime) {
|
||||
this.executeTime = executeTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WiredTriggerBotReachedFurni.class);
|
||||
@ -124,38 +125,45 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(this.botName + ":");
|
||||
|
||||
if (!this.items.isEmpty()) {
|
||||
for (HabboItem item : this.items) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.botName,
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
String[] data = set.getString("wired_data").split(":");
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.botName = data.botName;
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] data = wiredData.split(":");
|
||||
|
||||
if (data.length == 1) {
|
||||
this.botName = data[0];
|
||||
} else if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
if (data.length == 1) {
|
||||
this.botName = data[0];
|
||||
} else if (data.length == 2) {
|
||||
this.botName = data[0];
|
||||
|
||||
String[] items = data[1].split(";");
|
||||
String[] items = data[1].split(";");
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
try {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(items[i]));
|
||||
for (String id : items) {
|
||||
try {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(id));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Caught exception", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -166,4 +174,14 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
|
||||
this.items.clear();
|
||||
this.botName = "";
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String botName;
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(String botName, List<Integer> itemIds) {
|
||||
this.botName = botName;
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
@ -62,12 +63,21 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.botName;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.botName
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.botName = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.botName = data.botName;
|
||||
} else {
|
||||
this.botName = wiredData;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,4 +89,12 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger {
|
||||
public boolean isTriggeredByRoomUnit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String botName;
|
||||
|
||||
public JsonData(String botName) {
|
||||
this.botName = botName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,13 @@ import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
||||
private static final WiredTriggerType type = WiredTriggerType.STATE_CHANGED;
|
||||
|
||||
private THashSet<HabboItem> items;
|
||||
private String message = "";
|
||||
|
||||
public WiredTriggerFurniStateToggled(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@ -55,34 +56,35 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:");
|
||||
|
||||
if (this.items != null) {
|
||||
if (!this.items.isEmpty()) {
|
||||
for (HabboItem item : this.items) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
}
|
||||
} else
|
||||
wiredData.append("\t");
|
||||
}
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items = new THashSet<>();
|
||||
String wiredData = set.getString("wired_data");
|
||||
if (wiredData.split(":").length >= 3) {
|
||||
super.setDelay(Integer.valueOf(wiredData.split(":")[0]));
|
||||
this.message = wiredData.split(":")[1];
|
||||
|
||||
if (!wiredData.split(":")[2].equals("\t")) {
|
||||
for (String s : wiredData.split(":")[2].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (wiredData.split(":").length >= 3) {
|
||||
super.setDelay(Integer.parseInt(wiredData.split(":")[0]));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
if (!wiredData.split(":")[2].equals("\t")) {
|
||||
for (String s : wiredData.split(":")[2].split(";")) {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,7 +93,6 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
this.items.clear();
|
||||
this.message = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -126,7 +127,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
||||
}
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString(this.message);
|
||||
message.appendString("");
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
@ -153,4 +154,12 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
|
||||
public boolean isTriggeredByRoomUnit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
@ -41,12 +42,21 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.username;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.username
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.username = set.getString("wired_data");
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.username = data.username;
|
||||
} else {
|
||||
this.username = wiredData;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,4 +96,12 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
|
||||
public boolean isTriggeredByRoomUnit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
String username;
|
||||
|
||||
public JsonData(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
@ -41,16 +42,27 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return (this.ownerOnly ? "1" : "0") + "\t" + this.key;
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.ownerOnly,
|
||||
this.key
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
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 == 2) {
|
||||
this.ownerOnly = data[0].equalsIgnoreCase("1");
|
||||
this.key = data[1];
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.ownerOnly = data.ownerOnly;
|
||||
this.key = data.key;
|
||||
} else {
|
||||
String[] data = wiredData.split("\t");
|
||||
|
||||
if (data.length == 2) {
|
||||
this.ownerOnly = data[0].equalsIgnoreCase("1");
|
||||
this.key = data[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,4 +105,14 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger {
|
||||
public boolean isTriggeredByRoomUnit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
boolean ownerOnly;
|
||||
String key;
|
||||
|
||||
public JsonData(boolean ownerOnly, String key) {
|
||||
this.ownerOnly = ownerOnly;
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,14 +14,13 @@ 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.stream.Collectors;
|
||||
|
||||
public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
||||
public static final WiredTriggerType type = WiredTriggerType.WALKS_OFF_FURNI;
|
||||
|
||||
private THashSet<HabboItem> items;
|
||||
private String message = "";
|
||||
|
||||
public WiredTriggerHabboWalkOffFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@ -45,55 +44,49 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:");
|
||||
|
||||
if (!this.items.isEmpty()) {
|
||||
List<HabboItem> toRemove = new ArrayList<>(0);
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() == this.getRoomId()) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
} else {
|
||||
toRemove.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
this.items.removeAll(toRemove);
|
||||
} else
|
||||
wiredData.append("\t");
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new WiredTriggerFurniStateToggled.JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
if (wiredData.split(":").length >= 3) {
|
||||
super.setDelay(Integer.valueOf(wiredData.split(":")[0]));
|
||||
this.message = wiredData.split(":")[1];
|
||||
|
||||
if (!wiredData.split(":")[2].equals("\t")) {
|
||||
for (String s : wiredData.split(":")[2].split(";")) {
|
||||
if (s.isEmpty())
|
||||
continue;
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (wiredData.split(":").length >= 3) {
|
||||
super.setDelay(Integer.parseInt(wiredData.split(":")[0]));
|
||||
|
||||
try {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (!wiredData.split(":")[2].equals("\t")) {
|
||||
for (String s : wiredData.split(":")[2].split(";")) {
|
||||
if (s.isEmpty())
|
||||
continue;
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
this.items.clear();
|
||||
this.message = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -126,7 +119,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
||||
}
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString(this.message);
|
||||
message.appendString("");
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
@ -154,4 +147,12 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
|
||||
public boolean isTriggeredByRoomUnit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
||||
public static final WiredTriggerType type = WiredTriggerType.WALKS_ON_FURNI;
|
||||
|
||||
private THashSet<HabboItem> items;
|
||||
private String message = "";
|
||||
|
||||
public WiredTriggerHabboWalkOnFurni(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@ -73,7 +73,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
||||
}
|
||||
message.appendInt(this.getBaseItem().getSpriteId());
|
||||
message.appendInt(this.getId());
|
||||
message.appendString(this.message);
|
||||
message.appendString("");
|
||||
message.appendInt(0);
|
||||
message.appendInt(0);
|
||||
message.appendInt(this.getType().code);
|
||||
@ -99,44 +99,40 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
StringBuilder wiredData = new StringBuilder(super.getDelay() + ":\t:");
|
||||
|
||||
if (!this.items.isEmpty()) {
|
||||
List<HabboItem> toRemove = new ArrayList<>(0);
|
||||
for (HabboItem item : this.items) {
|
||||
if (item.getRoomId() == this.getRoomId()) {
|
||||
wiredData.append(item.getId()).append(";");
|
||||
} else {
|
||||
toRemove.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
this.items.removeAll(toRemove);
|
||||
} else
|
||||
wiredData.append("\t");
|
||||
|
||||
return wiredData.toString();
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
this.items.clear();
|
||||
String wiredData = set.getString("wired_data");
|
||||
if (wiredData.split(":").length >= 3) {
|
||||
super.setDelay(Integer.valueOf(wiredData.split(":")[0]));
|
||||
this.message = wiredData.split(":")[1];
|
||||
|
||||
if (!wiredData.split(":")[2].equals("\t")) {
|
||||
for (String s : wiredData.split(":")[2].split(";")) {
|
||||
if (s.isEmpty())
|
||||
continue;
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
for (Integer id: data.itemIds) {
|
||||
HabboItem item = room.getHabboItem(id);
|
||||
if (item != null) {
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (wiredData.split(":").length >= 3) {
|
||||
super.setDelay(Integer.parseInt(wiredData.split(":")[0]));
|
||||
|
||||
try {
|
||||
HabboItem item = room.getHabboItem(Integer.valueOf(s));
|
||||
if (!wiredData.split(":")[2].equals("\t")) {
|
||||
for (String s : wiredData.split(":")[2].split(";")) {
|
||||
if (s.isEmpty())
|
||||
continue;
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
HabboItem item = room.getHabboItem(Integer.parseInt(s));
|
||||
|
||||
if (item != null)
|
||||
this.items.add(item);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,11 +142,18 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
|
||||
@Override
|
||||
public void onPickUp() {
|
||||
this.items.clear();
|
||||
this.message = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTriggeredByRoomUnit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
List<Integer> itemIds;
|
||||
|
||||
public JsonData(List<Integer> itemIds) {
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,13 +41,22 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.repeatTime + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.repeatTime
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
if (set.getString("wired_data").length() >= 1) {
|
||||
this.repeatTime = (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.repeatTime = data.repeatTime;
|
||||
} else {
|
||||
if (wiredData.length() >= 1) {
|
||||
this.repeatTime = (Integer.valueOf(wiredData));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.repeatTime < 500) {
|
||||
@ -136,4 +145,12 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int repeatTime;
|
||||
|
||||
public JsonData(int repeatTime) {
|
||||
this.repeatTime = repeatTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,13 +40,22 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.repeatTime + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.repeatTime
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
if (set.getString("wired_data").length() >= 1) {
|
||||
this.repeatTime = (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.repeatTime = data.repeatTime;
|
||||
} else {
|
||||
if (wiredData.length() >= 1) {
|
||||
this.repeatTime = (Integer.valueOf(wiredData));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.repeatTime < 5000) {
|
||||
@ -130,4 +139,12 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int repeatTime;
|
||||
|
||||
public JsonData(int repeatTime) {
|
||||
this.repeatTime = repeatTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
|
||||
import com.eu.habbo.messages.ClientMessage;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
@ -37,14 +38,23 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger {
|
||||
|
||||
@Override
|
||||
public String getWiredData() {
|
||||
return this.score + "";
|
||||
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
|
||||
this.score
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadWiredData(ResultSet set, Room room) throws SQLException {
|
||||
try {
|
||||
this.score = Integer.valueOf(set.getString("wired_data"));
|
||||
} catch (Exception e) {
|
||||
String wiredData = set.getString("wired_data");
|
||||
|
||||
if (wiredData.startsWith("{")) {
|
||||
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
|
||||
this.score = data.score;
|
||||
} else {
|
||||
try {
|
||||
this.score = Integer.parseInt(wiredData);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,4 +95,12 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger {
|
||||
public boolean isTriggeredByRoomUnit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static class JsonData {
|
||||
int score;
|
||||
|
||||
public JsonData(int score) {
|
||||
this.score = score;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user