use of com.almuradev.almura.feature.exchange.network.ClientboundExchangeGuiResponsePacket in project Almura by AlmuraDev.
the class ServerExchangeManager method openExchangeSpecific.
void openExchangeSpecific(final Player player, final Exchange axs) {
checkNotNull(player);
checkNotNull(axs);
if (!player.hasPermission(axs.getPermission())) {
this.notificationManager.sendPopupNotification(player, Text.of(TextColors.RED, "Exchange"), Text.of("You do not have permission " + "to open this exchange!"), 5);
return;
}
this.network.sendTo(player, new ClientboundExchangeGuiResponsePacket(ExchangeGuiType.SPECIFIC, axs.getId(), this.getListingsLimit(player)));
if (!axs.isLoaded()) {
this.playerSpecificInitiatorIds.add(player.getUniqueId());
this.databaseManager.getQueue().queue(DatabaseQueue.ActionType.FETCH_IGNORE_DUPLICATES, axs.getId(), () -> {
this.loadListItems(axs);
this.loadForSaleItems(axs);
this.scheduler.createTaskBuilder().execute(() -> {
axs.setLoaded(true);
final Iterator<UUID> iter = this.playerSpecificInitiatorIds.iterator();
while (iter.hasNext()) {
final UUID uniqueId = iter.next();
iter.remove();
final Player p = Sponge.getServer().getPlayer(uniqueId).orElse(null);
if (p != null && p.isOnline() && !p.isRemoved()) {
final List<ListItem> listItems = axs.getListItemsFor(p.getUniqueId()).orElse(null);
this.network.sendTo(p, new ClientboundListItemsResponsePacket(axs.getId(), listItems));
if (listItems != null && !listItems.isEmpty()) {
final List<ForSaleItem> forSaleItems = axs.getForSaleItemsFor(p.getUniqueId()).orElse(null);
if (forSaleItems != null && !forSaleItems.isEmpty()) {
this.network.sendTo(p, new ClientboundListItemsSaleStatusPacket(axs.getId(), forSaleItems, null));
}
}
this.network.sendTo(p, new ClientboundForSaleFilterRequestPacket(axs.getId()));
}
}
}).submit(this.container);
});
} else {
final List<ListItem> listItems = axs.getListItemsFor(player.getUniqueId()).orElse(null);
this.network.sendTo(player, new ClientboundListItemsResponsePacket(axs.getId(), listItems));
if (listItems != null && !listItems.isEmpty()) {
final List<ForSaleItem> forSaleItems = axs.getForSaleItemsFor(player.getUniqueId()).orElse(null);
if (forSaleItems != null && !forSaleItems.isEmpty()) {
this.network.sendTo(player, new ClientboundListItemsSaleStatusPacket(axs.getId(), forSaleItems, null));
}
}
this.network.sendTo(player, new ClientboundForSaleFilterRequestPacket(axs.getId()));
}
}
use of com.almuradev.almura.feature.exchange.network.ClientboundExchangeGuiResponsePacket in project Almura by AlmuraDev.
the class ServerExchangeManager method handleExchangeSpecificOffer.
public void handleExchangeSpecificOffer(final Player player, final String id) {
checkNotNull(player);
checkNotNull(id);
final Exchange axs = this.getExchange(id).orElse(null);
if (axs == null) {
this.logger.error("Player '{}' attempted to open an offer screen for exchange '{}' but the server has no knowledge of it. Syncing " + "exchange registry...", player.getName(), id);
this.syncExchangeRegistryTo(player);
return;
}
this.network.sendTo(player, new ClientboundExchangeGuiResponsePacket(ExchangeGuiType.SPECIFIC_OFFER, id));
}
use of com.almuradev.almura.feature.exchange.network.ClientboundExchangeGuiResponsePacket in project Almura by AlmuraDev.
the class ServerExchangeManager method openExchangeManage.
void openExchangeManage(final Player player) {
checkNotNull(player);
if (!player.hasPermission(Almura.ID + ".exchange.admin")) {
this.notificationManager.sendPopupNotification(player, Text.of(TextColors.RED, "Exchange"), Text.of("You do not have permission " + "to manage exchanges!"), 5);
return;
}
this.network.sendTo(player, new ClientboundExchangeGuiResponsePacket(ExchangeGuiType.MANAGE));
}
Aggregations