mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-29 17:40:52 +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));
|
Emulator.getThreading().run(new QueryDeleteHabboItems(items));
|
||||||
|
|
||||||
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
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);
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,20 +17,23 @@ public class RequestInventoryItemsEvent extends MessageHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
int totalItems = this.client.getHabbo().getInventory().getItemsComponent().getItems().size();
|
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) {
|
if (totalFragments == 0) {
|
||||||
pages = 1;
|
totalFragments = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this.client.getHabbo().getInventory().getItemsComponent().getItems()) {
|
synchronized (this.client.getHabbo().getInventory().getItemsComponent().getItems()) {
|
||||||
TIntObjectMap<HabboItem> items = new TIntObjectHashMap<>();
|
TIntObjectMap<HabboItem> items = new TIntObjectHashMap<>();
|
||||||
TIntObjectIterator<HabboItem> iterator = this.client.getHabbo().getInventory().getItemsComponent().getItems().iterator();
|
TIntObjectIterator<HabboItem> iterator = this.client.getHabbo().getInventory().getItemsComponent().getItems().iterator();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int page = 0;
|
int fragmentNumber = 0;
|
||||||
|
|
||||||
for (int i = this.client.getHabbo().getInventory().getItemsComponent().getItems().size(); i-- > 0; ) {
|
for (int i = this.client.getHabbo().getInventory().getItemsComponent().getItems().size(); i-- > 0; ) {
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
page++;
|
fragmentNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -43,13 +46,13 @@ public class RequestInventoryItemsEvent extends MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count == 1000) {
|
if (count == 1000) {
|
||||||
this.client.sendResponse(new InventoryItemsComposer(page, pages, items));
|
this.client.sendResponse(new InventoryItemsComposer(fragmentNumber, totalFragments, items));
|
||||||
count = 0;
|
count = 0;
|
||||||
items.clear();
|
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> {
|
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);
|
||||||
|
|
||||||
private final int page;
|
private final int fragmentNumber;
|
||||||
private final int out;
|
private final int totalFragments;
|
||||||
private final TIntObjectMap<HabboItem> items;
|
private final TIntObjectMap<HabboItem> items;
|
||||||
|
|
||||||
public InventoryItemsComposer(int page, int out, TIntObjectMap<HabboItem> items) {
|
public InventoryItemsComposer(int fragmentNumber, int totalFragments, TIntObjectMap<HabboItem> items) {
|
||||||
this.page = page;
|
this.fragmentNumber = fragmentNumber;
|
||||||
this.out = out;
|
this.totalFragments = totalFragments;
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,8 +28,8 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec
|
|||||||
protected ServerMessage composeInternal() {
|
protected ServerMessage composeInternal() {
|
||||||
try {
|
try {
|
||||||
this.response.init(Outgoing.InventoryItemsComposer);
|
this.response.init(Outgoing.InventoryItemsComposer);
|
||||||
this.response.appendInt(this.out);
|
this.response.appendInt(this.totalFragments);
|
||||||
this.response.appendInt(this.page - 1);
|
this.response.appendInt(this.fragmentNumber - 1);
|
||||||
this.response.appendInt(this.items.size());
|
this.response.appendInt(this.items.size());
|
||||||
|
|
||||||
this.items.forEachEntry(this);
|
this.items.forEachEntry(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user