mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 08:20:51 +01:00
Fix the busted inventory fragments
This commit is contained in:
parent
6f7511af59
commit
66397c8d98
@ -42,7 +42,6 @@ public class EmptyInventoryCommand extends Command {
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItems(items));
|
||||
|
||||
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
||||
habbo.getClient().sendResponse(new InventoryItemsComposer(0, 1, gameClient.getHabbo().getInventory().getItemsComponent().getItems()));
|
||||
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
|
||||
} else {
|
||||
|
@ -17,20 +17,23 @@ public class RequestInventoryItemsEvent extends MessageHandler {
|
||||
@Override
|
||||
public void handle() throws Exception {
|
||||
int totalItems = this.client.getHabbo().getInventory().getItemsComponent().getItems().size();
|
||||
int pages = (int) Math.ceil((double) totalItems / 1000.0);
|
||||
int totalFragments = (int) Math.ceil((double) totalItems / 1000.0);
|
||||
|
||||
if (pages == 0) {
|
||||
pages = 1;
|
||||
if (totalFragments == 0) {
|
||||
totalFragments = 1;
|
||||
}
|
||||
|
||||
synchronized (this.client.getHabbo().getInventory().getItemsComponent().getItems()) {
|
||||
TIntObjectMap<HabboItem> items = new TIntObjectHashMap<>();
|
||||
TIntObjectIterator<HabboItem> iterator = this.client.getHabbo().getInventory().getItemsComponent().getItems().iterator();
|
||||
|
||||
int count = 0;
|
||||
int page = 0;
|
||||
int fragmentNumber = 0;
|
||||
|
||||
for (int i = this.client.getHabbo().getInventory().getItemsComponent().getItems().size(); i-- > 0; ) {
|
||||
|
||||
if (count == 0) {
|
||||
page++;
|
||||
fragmentNumber++;
|
||||
}
|
||||
|
||||
try {
|
||||
@ -43,13 +46,13 @@ public class RequestInventoryItemsEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
if (count == 1000) {
|
||||
this.client.sendResponse(new InventoryItemsComposer(page, pages, items));
|
||||
this.client.sendResponse(new InventoryItemsComposer(fragmentNumber, totalFragments, items));
|
||||
count = 0;
|
||||
items.clear();
|
||||
}
|
||||
}
|
||||
|
||||
this.client.sendResponse(new InventoryItemsComposer(page, pages, items));
|
||||
if(count > 0 && items.size() > 0) this.client.sendResponse(new InventoryItemsComposer(fragmentNumber, totalFragments, items));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ import org.slf4j.LoggerFactory;
|
||||
public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure<HabboItem> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(InventoryItemsComposer.class);
|
||||
|
||||
private final int page;
|
||||
private final int out;
|
||||
private final int fragmentNumber;
|
||||
private final int totalFragments;
|
||||
private final TIntObjectMap<HabboItem> items;
|
||||
|
||||
public InventoryItemsComposer(int page, int out, TIntObjectMap<HabboItem> items) {
|
||||
this.page = page;
|
||||
this.out = out;
|
||||
public InventoryItemsComposer(int fragmentNumber, int totalFragments, TIntObjectMap<HabboItem> items) {
|
||||
this.fragmentNumber = fragmentNumber;
|
||||
this.totalFragments = totalFragments;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@ -28,8 +28,8 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec
|
||||
protected ServerMessage composeInternal() {
|
||||
try {
|
||||
this.response.init(Outgoing.InventoryItemsComposer);
|
||||
this.response.appendInt(this.out);
|
||||
this.response.appendInt(this.page - 1);
|
||||
this.response.appendInt(this.totalFragments);
|
||||
this.response.appendInt(this.fragmentNumber - 1);
|
||||
this.response.appendInt(this.items.size());
|
||||
|
||||
this.items.forEachEntry(this);
|
||||
|
Loading…
Reference in New Issue
Block a user