2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.messages.outgoing.catalog;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import com.eu.habbo.habbohotel.catalog.CatalogPage;
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
|
|
|
import com.eu.habbo.messages.ServerMessage;
|
|
|
|
import com.eu.habbo.messages.outgoing.MessageComposer;
|
|
|
|
import com.eu.habbo.messages.outgoing.Outgoing;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class CatalogPagesListComposer extends MessageComposer {
|
2018-07-06 15:30:00 +02:00
|
|
|
private final Habbo habbo;
|
|
|
|
private final String mode;
|
|
|
|
private final boolean hasPermission;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public CatalogPagesListComposer(Habbo habbo, String mode) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.habbo = habbo;
|
|
|
|
this.mode = mode;
|
|
|
|
this.hasPermission = this.habbo.hasPermission("acc_catalog_ids");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public ServerMessage compose() {
|
|
|
|
try {
|
2018-07-06 15:30:00 +02:00
|
|
|
List<CatalogPage> pages = Emulator.getGameEnvironment().getCatalogManager().getCatalogPages(-1, this.habbo);
|
|
|
|
|
|
|
|
this.response.init(Outgoing.CatalogPagesListComposer);
|
|
|
|
|
|
|
|
this.response.appendBoolean(true);
|
|
|
|
this.response.appendInt(0);
|
|
|
|
this.response.appendInt(-1);
|
|
|
|
this.response.appendString("root");
|
|
|
|
this.response.appendString("");
|
|
|
|
this.response.appendInt(0);
|
|
|
|
this.response.appendInt(pages.size());
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
for (CatalogPage category : pages) {
|
2019-03-18 02:22:00 +01:00
|
|
|
this.append(category);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.response.appendBoolean(false);
|
|
|
|
this.response.appendString(this.mode);
|
|
|
|
|
|
|
|
return this.response;
|
2019-05-26 20:14:53 +02:00
|
|
|
} catch (Exception e) {
|
2019-03-18 02:22:00 +01:00
|
|
|
Emulator.getLogging().logErrorLine(e);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
private void append(CatalogPage category) {
|
2018-07-06 15:30:00 +02:00
|
|
|
List<CatalogPage> pagesList = Emulator.getGameEnvironment().getCatalogManager().getCatalogPages(category.getId(), this.habbo);
|
|
|
|
|
|
|
|
this.response.appendBoolean(category.isVisible());
|
|
|
|
this.response.appendInt(category.getIconImage());
|
|
|
|
this.response.appendInt(category.isEnabled() ? category.getId() : -1);
|
|
|
|
this.response.appendString(category.getPageName());
|
2019-03-18 02:22:00 +01:00
|
|
|
this.response.appendString(category.getCaption() + (this.hasPermission ? " (" + category.getId() + ")" : ""));
|
2018-07-06 15:30:00 +02:00
|
|
|
this.response.appendInt(category.getOfferIds().size());
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
for (int i : category.getOfferIds().toArray()) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.response.appendInt(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.response.appendInt(pagesList.size());
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
for (CatalogPage page : pagesList) {
|
2019-03-18 02:22:00 +01:00
|
|
|
this.append(page);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|