Fixes the song disk bug

This commit is contained in:
Julimar Melo 2023-01-03 01:36:03 -03:00
parent 3bd6b8d461
commit 3858483988

View File

@ -11,6 +11,9 @@ import gnu.trove.procedure.TIntObjectProcedure;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure<HabboItem> { public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure<HabboItem> {
private static final Logger LOGGER = LoggerFactory.getLogger(InventoryItemsComposer.class); private static final Logger LOGGER = LoggerFactory.getLogger(InventoryItemsComposer.class);
@ -48,7 +51,7 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec
this.response.appendInt(habboItem.getId()); this.response.appendInt(habboItem.getId());
this.response.appendInt(habboItem.getBaseItem().getSpriteId()); this.response.appendInt(habboItem.getBaseItem().getSpriteId());
if (habboItem.getBaseItem().getName().equals("floor") || habboItem.getBaseItem().getName().equals("landscape") || habboItem.getBaseItem().getName().equals("wallpaper") || habboItem.getBaseItem().getName().equals("poster")) { if (habboItem.getBaseItem().getName().equals("floor") || habboItem.getBaseItem().getName().equals("landscape") || habboItem.getBaseItem().getName().equals("song_disk") || habboItem.getBaseItem().getName().equals("wallpaper") || habboItem.getBaseItem().getName().equals("poster")) {
switch (habboItem.getBaseItem().getName()) { switch (habboItem.getBaseItem().getName()) {
case "landscape": case "landscape":
this.response.appendInt(4); this.response.appendInt(4);
@ -62,10 +65,11 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec
case "poster": case "poster":
this.response.appendInt(6); this.response.appendInt(6);
break; break;
case "song_disk":
this.response.appendInt(8);
break;
} }
this.addExtraDataToResponse(habboItem);
this.response.appendInt(0);
this.response.appendString(habboItem.getExtradata());
} else { } else {
if (habboItem.getBaseItem().getName().equals("gnome_box")) if (habboItem.getBaseItem().getName().equals("gnome_box"))
this.response.appendInt(13); this.response.appendInt(13);
@ -82,12 +86,25 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec
this.response.appendBoolean(true); this.response.appendBoolean(true);
this.response.appendInt(-1); this.response.appendInt(-1);
if (habboItem.getBaseItem().getType() == FurnitureType.FLOOR) { if (habboItem.getBaseItem().getType() == FurnitureType.FLOOR) {
this.response.appendString(""); this.response.appendString("");
if(habboItem.getBaseItem().getName().equals("song_disk")) {
List<String> extraDataAsList = Arrays.asList(habboItem.getExtradata().split("\n"));
this.response.appendInt(Integer.valueOf(extraDataAsList.get(extraDataAsList.size() - 1)));
return true;
}
this.response.appendInt(habboItem instanceof InteractionGift ? ((((InteractionGift) habboItem).getColorId() * 1000) + ((InteractionGift) habboItem).getRibbonId()) : 1); this.response.appendInt(habboItem instanceof InteractionGift ? ((((InteractionGift) habboItem).getColorId() * 1000) + ((InteractionGift) habboItem).getRibbonId()) : 1);
} }
return true; return true;
} }
} public void addExtraDataToResponse(HabboItem habboItem) {
this.response.appendInt(0);
this.response.appendString(habboItem.getExtradata());
}
}