use of com.almuradev.almura.feature.store.network.ClientboundStoreGuiResponsePacket in project Almura by AlmuraDev.
the class ServerStoreManager method openStoreSpecific.
void openStoreSpecific(final Player player, final Store store) {
checkNotNull(player);
checkNotNull(store);
if (!player.hasPermission(store.getPermission())) {
this.notificationManager.sendPopupNotification(player, Text.of(TextColors.RED, "Store"), Text.of("You do not have permission " + "to open this store!"), 5);
return;
}
this.network.sendTo(player, new ClientboundStoreGuiResponsePacket(StoreGuiType.SPECIFIC, store.getId(), player.hasPermission(Almura.ID + ".store.admin")));
if (!store.isLoaded()) {
this.playerSpecificInitiatorIds.add(player.getUniqueId());
this.databaseManager.getQueue().queue(DatabaseQueue.ActionType.FETCH_IGNORE_DUPLICATES, store.getId(), () -> {
this.loadSellingItems(store);
this.loadBuyingItems(store);
this.scheduler.createTaskBuilder().execute(() -> {
store.setLoaded(true);
final Iterator<UUID> iterator = this.playerSpecificInitiatorIds.iterator();
while (iterator.hasNext()) {
final UUID uniqueId = iterator.next();
iterator.remove();
final Player p = Sponge.getServer().getPlayer(uniqueId).orElse(null);
if (p != null && p.isOnline() && !p.isRemoved()) {
this.network.sendTo(p, new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.BUYING, store.getBuyingItems()));
this.network.sendTo(p, new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.SELLING, store.getSellingItems()));
}
}
}).submit(this.container);
});
} else {
this.network.sendTo(player, new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.SELLING, store.getSellingItems()));
this.network.sendTo(player, new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.BUYING, store.getBuyingItems()));
}
}
use of com.almuradev.almura.feature.store.network.ClientboundStoreGuiResponsePacket in project Almura by AlmuraDev.
the class ServerStoreManager method openStoreManage.
public void openStoreManage(final Player player) {
checkNotNull(player);
if (!player.hasPermission(Almura.ID + ".store.admin")) {
this.notificationManager.sendPopupNotification(player, Text.of(TextColors.RED, "Store"), Text.of("You do not have permission " + "to manage stores!"), 5);
return;
}
this.network.sendTo(player, new ClientboundStoreGuiResponsePacket(StoreGuiType.MANAGE));
}
Aggregations