fix wired condition furni has avatars sending wrong data

This commit is contained in:
dank074 2022-03-22 20:49:28 -05:00
parent dbd40c195b
commit e3b0c62d5b
2 changed files with 15 additions and 37 deletions

View File

@ -25,8 +25,6 @@ import java.util.stream.Collectors;
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO; public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
protected boolean all;
protected THashSet<HabboItem> items; protected THashSet<HabboItem> items;
public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException {
@ -42,7 +40,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
@Override @Override
public void onPickUp() { public void onPickUp() {
this.items.clear(); this.items.clear();
this.all = false;
} }
@Override @Override
@ -68,7 +65,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
public String getWiredData() { public String getWiredData() {
this.refresh(); this.refresh();
return WiredHandler.getGsonBuilder().create().toJson(new JsonData( return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.all,
this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
)); ));
} }
@ -80,7 +76,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
if (wiredData.startsWith("{")) { if (wiredData.startsWith("{")) {
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
this.all = data.all;
for(int id : data.itemIds) { for(int id : data.itemIds) {
HabboItem item = room.getHabboItem(id); HabboItem item = room.getHabboItem(id);
@ -93,17 +88,14 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
String[] data = wiredData.split(":"); String[] data = wiredData.split(":");
if (data.length >= 1) { if (data.length >= 1) {
this.all = (data[0].equals("1"));
if (data.length == 2) { String[] items = data[1].split(";");
String[] items = data[1].split(";");
for (String s : items) { for (String s : items) {
HabboItem item = room.getHabboItem(Integer.parseInt(s)); HabboItem item = room.getHabboItem(Integer.parseInt(s));
if (item != null) if (item != null)
this.items.add(item); this.items.add(item);
}
} }
} }
} }
@ -128,8 +120,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId()); message.appendInt(this.getId());
message.appendString(""); message.appendString("");
message.appendInt(1); message.appendInt(0);
message.appendInt(this.all ? 1 : 0);
message.appendInt(0); message.appendInt(0);
message.appendInt(this.getType().code); message.appendInt(this.getType().code);
message.appendInt(0); message.appendInt(0);
@ -179,11 +170,9 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
} }
static class JsonData { static class JsonData {
boolean all;
List<Integer> itemIds; List<Integer> itemIds;
public JsonData(boolean all, List<Integer> itemIds) { public JsonData(List<Integer> itemIds) {
this.all = all;
this.itemIds = itemIds; this.itemIds = itemIds;
} }
} }

View File

@ -26,7 +26,6 @@ import java.util.stream.Collectors;
public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO; public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO;
protected boolean all;
protected THashSet<HabboItem> items; protected THashSet<HabboItem> items;
public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException {
@ -42,7 +41,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
@Override @Override
public void onPickUp() { public void onPickUp() {
this.items.clear(); this.items.clear();
this.all = false;
} }
@Override @Override
@ -68,7 +66,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
public String getWiredData() { public String getWiredData() {
this.refresh(); this.refresh();
return WiredHandler.getGsonBuilder().create().toJson(new JsonData( return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.all,
this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
)); ));
} }
@ -80,7 +77,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
if (wiredData.startsWith("{")) { if (wiredData.startsWith("{")) {
WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class); WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class);
this.all = data.all;
for(int id : data.itemIds) { for(int id : data.itemIds) {
HabboItem item = room.getHabboItem(id); HabboItem item = room.getHabboItem(id);
@ -93,17 +89,13 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
String[] data = wiredData.split(":"); String[] data = wiredData.split(":");
if (data.length >= 1) { if (data.length >= 1) {
this.all = (data[0].equals("1")); String[] items = data[1].split(";");
if (data.length == 2) { for (String s : items) {
String[] items = data[1].split(";"); HabboItem item = room.getHabboItem(Integer.parseInt(s));
for (String s : items) { if (item != null)
HabboItem item = room.getHabboItem(Integer.parseInt(s)); this.items.add(item);
if (item != null)
this.items.add(item);
}
} }
} }
} }
@ -128,8 +120,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId()); message.appendInt(this.getId());
message.appendString(""); message.appendString("");
message.appendInt(1); message.appendInt(0);
message.appendInt(this.all ? 1 : 0);
message.appendInt(0); message.appendInt(0);
message.appendInt(this.getType().code); message.appendInt(this.getType().code);
message.appendInt(0); message.appendInt(0);
@ -178,11 +169,9 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
} }
static class JsonData { static class JsonData {
boolean all;
List<Integer> itemIds; List<Integer> itemIds;
public JsonData(boolean all, List<Integer> itemIds) { public JsonData(List<Integer> itemIds) {
this.all = all;
this.itemIds = itemIds; this.itemIds = itemIds;
} }
} }