Search in sources :

Example 11 with Results

use of org.jooq.Results in project Almura by AlmuraDev.

the class ServerExchangeManager method handleTransaction.

/**
 * Transaction
 */
public void handleTransaction(final Player player, final String id, final int listItemRecNo, final int quantity) {
    checkNotNull(player);
    checkNotNull(id);
    checkState(listItemRecNo >= 0);
    checkState(quantity > 0);
    final Exchange axs = this.getExchange(id).orElse(null);
    if (axs == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to make a transaction for exchange '{}' but the server has no knowledge of it. Syncing exchange " + "registry...", player.getName(), id);
        this.syncExchangeRegistryTo(player);
        return;
    }
    final EconomyService economyService = this.serviceManager.provide(EconomyService.class).orElse(null);
    if (economyService == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to make a transaction for exchange '{}' but the economy service no longer exists. This is a " + "critical error that should be reported to your economy plugin ASAP.", player.getName(), id);
        return;
    }
    final UniqueAccount buyerAccount = economyService.getOrCreateAccount(player.getUniqueId()).orElse(null);
    if (buyerAccount == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to make a transaction for exchange '{}' but the economy service returned no account for them. " + "This is a critical error that should be reported to your economy plugin ASAP.", player.getName(), id);
        return;
    }
    ListItem found = null;
    for (final Map.Entry<UUID, List<ListItem>> kv : axs.getListItems().entrySet()) {
        final ListItem listItem = kv.getValue().stream().filter(item -> item.getRecord() == listItemRecNo).findAny().orElse(null);
        if (listItem != null) {
            found = listItem;
            break;
        }
    }
    if (found == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("This item is no longer for sale!"));
        this.network.sendTo(player, new ClientboundForSaleFilterRequestPacket(axs.getId()));
        return;
    }
    final UUID seller = found.getSeller();
    final UUID buyer = player.getUniqueId();
    if (buyer.equals(seller)) {
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("You cannot purchase your own items."));
        return;
    }
    final UniqueAccount sellerAccount = economyService.getOrCreateAccount(seller).orElse(null);
    if (sellerAccount == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to make a transaction for exchange '{}' but the economy service returned no account for seller" + " '{}'. This is a critical error that should be reported to your economy plugin ASAP.", player.getName(), id, seller);
        return;
    }
    final ForSaleItem forSaleItem = found.getForSaleItem().orElse(null);
    if (forSaleItem == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("This item is no longer for sale!"));
        this.network.sendTo(player, new ClientboundForSaleFilterRequestPacket(axs.getId()));
        return;
    }
    if (found.getQuantity() < quantity) {
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("There is not enough quantity left to " + "purchase this item!"));
        this.network.sendTo(player, new ClientboundForSaleFilterRequestPacket(axs.getId()));
        return;
    }
    final BigDecimal balance = buyerAccount.getBalance(economyService.getDefaultCurrency());
    final BigDecimal price = forSaleItem.getPrice();
    final double total = price.doubleValue() * quantity;
    if (total > balance.doubleValue()) {
        final String formattedTotal = FeatureConstants.CURRENCY_DECIMAL_FORMAT.format(total);
        final String formattedBalance = FeatureConstants.CURRENCY_DECIMAL_FORMAT.format(balance.doubleValue());
        final String formattedDifference = FeatureConstants.CURRENCY_DECIMAL_FORMAT.format(total - balance.doubleValue());
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("You attempted to purchase items totaling to ", TextColors.RED, formattedTotal, TextColors.RESET, " while you only have ", TextColors.GREEN, formattedBalance, TextColors.RESET, ".", Text.NEW_LINE, Text.NEW_LINE, "You need ", TextColors.LIGHT_PURPLE, formattedDifference, TextColors.RESET, " more!"));
        return;
    }
    EntityPlayerMP serverPlayer = (EntityPlayerMP) player;
    final IItemHandler inventory = serverPlayer.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
    final ListItem copyStack = found.copy();
    copyStack.setQuantity(quantity);
    final ItemStack simulatedResultStack = ItemHandlerHelper.insertItemStacked(inventory, copyStack.asRealStack(), true);
    if (!simulatedResultStack.isEmpty()) {
        this.notificationManager.sendWindowMessage(player, Text.of("Exchange"), Text.of("You lack sufficient inventory space to " + "purchase these item(s)!"));
        return;
    }
    final int originalQuantity = found.getQuantity();
    final int quantityRemaining = originalQuantity - (quantity - simulatedResultStack.getCount());
    final int forSaleItemRecord = forSaleItem.getRecord();
    // Charge the buyer
    try (final CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) {
        frame.pushCause(axs);
        buyerAccount.transfer(sellerAccount, economyService.getDefaultCurrency(), BigDecimal.valueOf(total), frame.getCurrentCause());
    }
    this.scheduler.createTaskBuilder().async().execute(() -> {
        try (final DSLContext context = this.databaseManager.createContext(true)) {
            // Update listed quantity
            int result = ExchangeQueries.createUpdateListItemQuantity(listItemRecNo, quantityRemaining, true).build(context).execute();
            if (result == 0) {
                this.logger.error("Player '{}' attempted to make a transaction for exchange '{}' to the database but it failed. Discarding " + "changes...", player.getName(), id);
                return;
            }
            if (quantityRemaining == 0) {
                result = ExchangeQueries.createUpdateForSaleItemIsHidden(forSaleItemRecord, true).build(context).execute();
                if (result == 0) {
                    this.logger.error("Player '{}' attempted to make a transaction in-which was the entire listing for exchange '{}' to the " + "database but it failed. Discarding changes...", player.getName(), id);
                    ExchangeQueries.createUpdateListItemQuantity(listItemRecNo, originalQuantity, true).build(context).execute();
                    return;
                }
            }
            // Issue a transaction
            result = ExchangeQueries.createInsertTransaction(Instant.now(), forSaleItemRecord, buyer, price, quantity).build(context).execute();
            if (result == 0) {
                this.logger.error("Player '{}' attempted to make a transaction for exchange '{}' to the database but it failed. Discarding " + "changes...", player.getName(), id);
                ExchangeQueries.createUpdateListItemQuantity(listItemRecNo, originalQuantity, false).build(context).execute();
                ExchangeQueries.createUpdateForSaleItemIsHidden(forSaleItemRecord, false).build(context).execute();
                return;
            }
            final Results listItemResults = ExchangeQueries.createFetchListItemsAndDataFor(seller, false).build(context).keepStatement(false).fetchMany();
            final Results forSaleItemResults = ExchangeQueries.createFetchForSaleItemsFor(seller, false).build(context).keepStatement(false).fetchMany();
            this.scheduler.createTaskBuilder().execute(() -> {
                final List<ListItem> listItems = new ArrayList<>();
                listItemResults.forEach(r -> listItems.addAll(this.parseListItemsFrom(r)));
                final List<ForSaleItem> forSaleItems = new ArrayList<>();
                forSaleItemResults.forEach(r -> forSaleItems.addAll(this.parseForSaleItemsFrom(listItems, r)));
                axs.putListItemsFor(seller, listItems);
                axs.putForSaleItemsFor(seller, forSaleItems);
                final ItemStack resultStack = ItemHandlerHelper.insertItemStacked(inventory, copyStack.asRealStack(), false);
                if (!resultStack.isEmpty()) {
                // TODO Inventory changed awaiting DB and now we're full...could drop it on the ground? It is an off-case
                }
                // If the seller is online, send them a list item update
                final Player sellerPlayer = Sponge.getServer().getPlayer(seller).orElse(null);
                if (sellerPlayer != null) {
                    this.network.sendTo(sellerPlayer, new ClientboundListItemsResponsePacket(axs.getId(), listItems));
                    this.network.sendTo(sellerPlayer, new ClientboundListItemsSaleStatusPacket(axs.getId(), forSaleItems, null));
                }
                this.network.sendToAll(new ClientboundForSaleFilterRequestPacket(axs.getId()));
                Sponge.getServer().getPlayer(buyer).ifPresent(buyerPlayer -> this.network.sendTo(buyerPlayer, new ClientboundTransactionCompletePacket()));
            }).submit(this.container);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }).submit(this.container);
}
Also used : UniqueAccount(org.spongepowered.api.service.economy.account.UniqueAccount) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ClientboundListItemsResponsePacket(com.almuradev.almura.feature.exchange.network.ClientboundListItemsResponsePacket) EconomyService(org.spongepowered.api.service.economy.EconomyService) BasicForSaleItem(com.almuradev.almura.feature.exchange.basic.listing.BasicForSaleItem) AxsForSaleItem(com.almuradev.generated.axs.tables.AxsForSaleItem) ForSaleItem(com.almuradev.almura.feature.exchange.listing.ForSaleItem) CauseStackManager(org.spongepowered.api.event.CauseStackManager) ClientboundListItemsSaleStatusPacket(com.almuradev.almura.feature.exchange.network.ClientboundListItemsSaleStatusPacket) List(java.util.List) ArrayList(java.util.ArrayList) UUID(java.util.UUID) ClientboundTransactionCompletePacket(com.almuradev.almura.feature.exchange.network.ClientboundTransactionCompletePacket) Player(org.spongepowered.api.entity.living.player.Player) IItemHandler(net.minecraftforge.items.IItemHandler) DSLContext(org.jooq.DSLContext) BigDecimal(java.math.BigDecimal) BasicExchange(com.almuradev.almura.feature.exchange.basic.BasicExchange) Results(org.jooq.Results) ClientboundForSaleFilterRequestPacket(com.almuradev.almura.feature.exchange.network.ClientboundForSaleFilterRequestPacket) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) AxsListItem(com.almuradev.generated.axs.tables.AxsListItem) BasicListItem(com.almuradev.almura.feature.exchange.basic.listing.BasicListItem) ListItem(com.almuradev.almura.feature.exchange.listing.ListItem) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with Results

use of org.jooq.Results in project Almura by AlmuraDev.

the class ServerStoreManager method handleSellingItemTransaction.

public void handleSellingItemTransaction(final Player player, final String id, final int recNo, final int quantity) {
    checkNotNull(player);
    checkNotNull(id);
    checkState(recNo >= 0);
    checkState(quantity >= 0);
    final Store store = this.getStore(id).orElse(null);
    if (store == null) {
        this.logger.error("Player '{}' attempted to sell an item to store '{}' but the server has no knowledge of it. Syncing " + "store registry...", player.getName(), id);
        this.syncStoreRegistryTo(player);
        return;
    }
    final EconomyService economyService = this.serviceManager.provide(EconomyService.class).orElse(null);
    if (economyService == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to sell an to from store '{}' but the economy service no longer exists. This is a " + "critical error that should be reported to your economy plugin ASAP.", player.getName(), id);
        return;
    }
    final UniqueAccount account = economyService.getOrCreateAccount(player.getUniqueId()).orElse(null);
    if (account == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to sell an item to store '{}' but the economy service returned no account for them. " + "This is a critical error that should be reported to your economy plugin ASAP.", player.getName(), id);
        return;
    }
    final List<SellingItem> sellingItems = store.getSellingItems();
    if (sellingItems.isEmpty()) {
        this.logger.error("Player '{}' attempted to sell an item to store '{}' but the server knows of no " + "selling items for it. This could be a de-sync or an exploit.", player.getName(), store.getId());
        this.network.sendTo(player, new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.SELLING, sellingItems));
        return;
    }
    final SellingItem found = sellingItems.stream().filter(v -> v.getRecord() == recNo).findAny().orElse(null);
    if (found == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to sell item '{}' to store '{}' but the server knows of no knowledge of it. This could be a " + "de-sync or an exploit. Discarding...", player.getName(), recNo, store.getId());
        this.network.sendTo(player, new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.SELLING, sellingItems));
        return;
    }
    final boolean infinite = found.getQuantity() == FeatureConstants.UNLIMITED;
    if (!infinite && found.getQuantity() < quantity) {
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("There is not enough quantity left to sell " + "your product!"));
        return;
    }
    final BigDecimal price = found.getPrice();
    final double total = price.doubleValue() * quantity;
    final EntityPlayerMP serverPlayer = (EntityPlayerMP) player;
    final IItemHandler inventory = serverPlayer.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
    final SellingItem copyStack = found.copy();
    copyStack.setQuantity(quantity);
    int amountLeft = copyStack.getQuantity();
    for (int j = 0; j < inventory.getSlots(); j++) {
        final ItemStack slotStack = inventory.getStackInSlot(j);
        if (ItemHandlerHelper.canItemStacksStack(slotStack, copyStack.asRealStack())) {
            amountLeft -= inventory.extractItem(j, amountLeft, false).getCount();
        }
        if (amountLeft <= 0) {
            break;
        }
    }
    if (amountLeft != 0) {
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to sell item '{}' to store '{}' but they do not have enough inventory quantity. " + "This could be a de-sync or an exploit. Discarding...", player.getName(), recNo, store.getId());
        return;
    }
    this.scheduler.createTaskBuilder().async().execute(() -> {
        try (final DSLContext context = this.databaseManager.createContext(true)) {
            int result;
            if (!infinite) {
                result = StoreQueries.createUpdateSellingItem(found.getRecord(), found.getQuantity() - quantity, found.getIndex(), found.getPrice()).build(context).execute();
                if (result == 0) {
                    // TODO It failed, message
                    return;
                }
            }
            result = StoreQueries.createInsertSellingTransaction(Instant.now(), found.getRecord(), player.getUniqueId(), found.getPrice(), quantity).build(context).execute();
            if (result == 0) {
                // TODO It failed, message
                StoreQueries.createUpdateSellingItem(found.getRecord(), found.getQuantity(), found.getIndex(), found.getPrice()).build(context).execute();
                return;
            }
            final List<SellingItem> finalSellingItems = new ArrayList<>();
            if (!infinite) {
                final Results results = StoreQueries.createFetchSellingItemsAndDataFor(store.getId(), false).build(context).fetchMany();
                results.forEach(r -> finalSellingItems.addAll(this.parseSellingItemsFrom(r)));
            }
            this.scheduler.createTaskBuilder().execute(() -> {
                if (!infinite) {
                    store.putSellingItems(finalSellingItems);
                }
                // Pay the seller
                try (final CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) {
                    frame.pushCause(store);
                    account.deposit(economyService.getDefaultCurrency(), BigDecimal.valueOf(total), frame.getCurrentCause());
                    this.notificationManager.sendPopupNotification(player, Text.of(TextColors.GREEN, "Transaction Complete"), Text.of("Sold ", TextColors.AQUA, quantity, TextColors.WHITE, " x ", TextColors.YELLOW, found.asRealStack().getDisplayName(), TextColors.RESET, " for a total of ", TextColors.GOLD, "$", FeatureConstants.CURRENCY_DECIMAL_FORMAT.format(total)), 3);
                }
                if (!infinite) {
                    this.network.sendToAll(new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.SELLING, store.getSellingItems()));
                }
            }).submit(this.container);
        } catch (final SQLException e) {
            e.printStackTrace();
        }
    }).submit(this.container);
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) FilterRegistry(com.almuradev.almura.shared.feature.filter.FilterRegistry) Results(org.jooq.Results) Item(net.minecraft.item.Item) Inject(com.google.inject.Inject) StoreQueries(com.almuradev.almura.feature.store.database.StoreQueries) BuyingItem(com.almuradev.almura.feature.store.listing.BuyingItem) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) DatabaseManager(com.almuradev.almura.shared.database.DatabaseManager) BigDecimal(java.math.BigDecimal) Map(java.util.Map) DSLContext(org.jooq.DSLContext) StoreBuyingItem(com.almuradev.generated.store.tables.StoreBuyingItem) BasicBuyingItem(com.almuradev.almura.feature.store.basic.listing.BasicBuyingItem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EconomyService(org.spongepowered.api.service.economy.EconomyService) VanillaStack(com.almuradev.almura.shared.item.VanillaStack) Timestamp(java.sql.Timestamp) ClientboundListItemsResponsePacket(com.almuradev.almura.feature.store.network.ClientboundListItemsResponsePacket) FeatureConstants(com.almuradev.almura.shared.feature.FeatureConstants) Sponge(org.spongepowered.api.Sponge) DatabaseQueue(com.almuradev.almura.shared.database.DatabaseQueue) ServiceManager(org.spongepowered.api.service.ServiceManager) NetworkConfig(com.almuradev.almura.shared.network.NetworkConfig) UUID(java.util.UUID) Result(org.jooq.Result) Instant(java.time.Instant) StoreSellingItemDataRecord(com.almuradev.generated.store.tables.records.StoreSellingItemDataRecord) Collectors(java.util.stream.Collectors) Preconditions.checkState(com.google.common.base.Preconditions.checkState) ClientConnectionEvent(org.spongepowered.api.event.network.ClientConnectionEvent) ChannelBinding(org.spongepowered.api.network.ChannelBinding) List(java.util.List) Stream(java.util.stream.Stream) StoreSellingItemData(com.almuradev.generated.store.tables.StoreSellingItemData) ClientboundStoreGuiResponsePacket(com.almuradev.almura.feature.store.network.ClientboundStoreGuiResponsePacket) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) StoreSellingItemRecord(com.almuradev.generated.store.tables.records.StoreSellingItemRecord) ChannelId(org.spongepowered.api.network.ChannelId) IngameFeature(com.almuradev.almura.shared.feature.IngameFeature) Optional(java.util.Optional) Player(org.spongepowered.api.entity.living.player.Player) Query(org.jooq.Query) Almura(com.almuradev.almura.Almura) Getter(org.spongepowered.api.event.filter.Getter) StoreBuyingItemData(com.almuradev.generated.store.tables.StoreBuyingItemData) BasicSellingItem(com.almuradev.almura.feature.store.basic.listing.BasicSellingItem) GameStartingServerEvent(org.spongepowered.api.event.game.state.GameStartingServerEvent) HashMap(java.util.HashMap) ServerboundListItemsRequestPacket(com.almuradev.almura.feature.store.network.ServerboundListItemsRequestPacket) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) SQLException(java.sql.SQLException) Lists(com.google.common.collect.Lists) ItemHandlerHelper(net.minecraftforge.items.ItemHandlerHelper) Text(org.spongepowered.api.text.Text) StoreBuyingItemRecord(com.almuradev.generated.store.tables.records.StoreBuyingItemRecord) BasicStore(com.almuradev.almura.feature.store.basic.BasicStore) SellingItem(com.almuradev.almura.feature.store.listing.SellingItem) StoreItem(com.almuradev.almura.feature.store.listing.StoreItem) StoreSellingItem(com.almuradev.generated.store.tables.StoreSellingItem) GameState(org.spongepowered.api.GameState) CauseStackManager(org.spongepowered.api.event.CauseStackManager) PluginContainer(org.spongepowered.api.plugin.PluginContainer) TextColors(org.spongepowered.api.text.format.TextColors) Nullable(javax.annotation.Nullable) Record(org.jooq.Record) StoreBuyingItemDataRecord(com.almuradev.generated.store.tables.records.StoreBuyingItemDataRecord) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Scheduler(org.spongepowered.api.scheduler.Scheduler) ServerNotificationManager(com.almuradev.almura.feature.notification.ServerNotificationManager) EnumFacing(net.minecraft.util.EnumFacing) IOException(java.io.IOException) SerializationUtil(com.almuradev.almura.shared.util.SerializationUtil) Witness(com.almuradev.core.event.Witness) ClientboundStoresRegistryPacket(com.almuradev.almura.feature.store.network.ClientboundStoresRegistryPacket) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) Listener(org.spongepowered.api.event.Listener) UniqueAccount(org.spongepowered.api.service.economy.account.UniqueAccount) Comparator(java.util.Comparator) ServerboundModifyItemsPacket(com.almuradev.almura.feature.store.network.ServerboundModifyItemsPacket) UniqueAccount(org.spongepowered.api.service.economy.account.UniqueAccount) IItemHandler(net.minecraftforge.items.IItemHandler) SQLException(java.sql.SQLException) BasicStore(com.almuradev.almura.feature.store.basic.BasicStore) ClientboundListItemsResponsePacket(com.almuradev.almura.feature.store.network.ClientboundListItemsResponsePacket) DSLContext(org.jooq.DSLContext) BasicSellingItem(com.almuradev.almura.feature.store.basic.listing.BasicSellingItem) SellingItem(com.almuradev.almura.feature.store.listing.SellingItem) StoreSellingItem(com.almuradev.generated.store.tables.StoreSellingItem) BigDecimal(java.math.BigDecimal) EconomyService(org.spongepowered.api.service.economy.EconomyService) Results(org.jooq.Results) CauseStackManager(org.spongepowered.api.event.CauseStackManager) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) List(java.util.List) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 13 with Results

use of org.jooq.Results in project Almura by AlmuraDev.

the class ServerStoreManager method handleDelistSellingItems.

public void handleDelistSellingItems(final Player player, final String id, final List<Integer> recNos) {
    checkNotNull(player);
    checkNotNull(id);
    checkNotNull(recNos);
    checkState(!recNos.isEmpty());
    if (!player.hasPermission(Almura.ID + ".store.admin")) {
        this.notificationManager.sendPopupNotification(player, Text.of(TextColors.RED, "Store"), Text.of("You do not have permission " + "to unlist items!"), 5);
        return;
    }
    final Store store = this.getStore(id).orElse(null);
    if (store == null) {
        this.logger.error("Player '{}' attempted to de-list selling items for store '{}' but the server has no knowledge of it. Syncing " + "store registry...", player.getName(), id);
        this.syncStoreRegistryTo(player);
        return;
    }
    final List<SellingItem> sellingItems = store.getSellingItems();
    if (sellingItems.isEmpty()) {
        this.logger.error("Player '{}' attempted to de-list selling items for store '{}' but the server knows of no " + " buying items for it. This could be a de-sync or an exploit.", player.getName(), store.getId());
        this.network.sendTo(player, new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.SELLING, sellingItems));
        return;
    }
    final List<Integer> copyRecNos = Lists.newArrayList(recNos);
    final Iterator<Integer> iter = copyRecNos.iterator();
    while (iter.hasNext()) {
        final Integer recNo = iter.next();
        final SellingItem found = sellingItems.stream().filter(v -> v.getRecord() == recNo).findAny().orElse(null);
        if (found == null) {
            this.logger.error("Player '{}' attempted to de-list selling item '{}' for store '{}' but the server knows of no knowledge of it. " + "This could be a de-sync or an exploit. Discarding...", player.getName(), recNo, store.getId());
            iter.remove();
        }
    }
    this.scheduler.createTaskBuilder().async().execute(() -> {
        try (final DSLContext context = this.databaseManager.createContext(true)) {
            final List<Query> toUpdate = new ArrayList<>();
            for (final Integer recNo : recNos) {
                toUpdate.add(StoreQueries.createUpdateSellingItemIsHidden(recNo, true).build(context));
            }
            context.batch(toUpdate).execute();
            final Results results = StoreQueries.createFetchSellingItemsAndDataFor(store.getId(), false).build(context).fetchMany();
            final List<SellingItem> finalSellingItems = new ArrayList<>();
            results.forEach(result -> finalSellingItems.addAll(this.parseSellingItemsFrom(result)));
            this.scheduler.createTaskBuilder().execute(() -> {
                store.putSellingItems(finalSellingItems);
                this.network.sendToAll(new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.SELLING, finalSellingItems));
            }).submit(this.container);
        } catch (final SQLException e) {
            e.printStackTrace();
        }
    }).submit(this.container);
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) FilterRegistry(com.almuradev.almura.shared.feature.filter.FilterRegistry) Results(org.jooq.Results) Item(net.minecraft.item.Item) Inject(com.google.inject.Inject) StoreQueries(com.almuradev.almura.feature.store.database.StoreQueries) BuyingItem(com.almuradev.almura.feature.store.listing.BuyingItem) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) DatabaseManager(com.almuradev.almura.shared.database.DatabaseManager) BigDecimal(java.math.BigDecimal) Map(java.util.Map) DSLContext(org.jooq.DSLContext) StoreBuyingItem(com.almuradev.generated.store.tables.StoreBuyingItem) BasicBuyingItem(com.almuradev.almura.feature.store.basic.listing.BasicBuyingItem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EconomyService(org.spongepowered.api.service.economy.EconomyService) VanillaStack(com.almuradev.almura.shared.item.VanillaStack) Timestamp(java.sql.Timestamp) ClientboundListItemsResponsePacket(com.almuradev.almura.feature.store.network.ClientboundListItemsResponsePacket) FeatureConstants(com.almuradev.almura.shared.feature.FeatureConstants) Sponge(org.spongepowered.api.Sponge) DatabaseQueue(com.almuradev.almura.shared.database.DatabaseQueue) ServiceManager(org.spongepowered.api.service.ServiceManager) NetworkConfig(com.almuradev.almura.shared.network.NetworkConfig) UUID(java.util.UUID) Result(org.jooq.Result) Instant(java.time.Instant) StoreSellingItemDataRecord(com.almuradev.generated.store.tables.records.StoreSellingItemDataRecord) Collectors(java.util.stream.Collectors) Preconditions.checkState(com.google.common.base.Preconditions.checkState) ClientConnectionEvent(org.spongepowered.api.event.network.ClientConnectionEvent) ChannelBinding(org.spongepowered.api.network.ChannelBinding) List(java.util.List) Stream(java.util.stream.Stream) StoreSellingItemData(com.almuradev.generated.store.tables.StoreSellingItemData) ClientboundStoreGuiResponsePacket(com.almuradev.almura.feature.store.network.ClientboundStoreGuiResponsePacket) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) StoreSellingItemRecord(com.almuradev.generated.store.tables.records.StoreSellingItemRecord) ChannelId(org.spongepowered.api.network.ChannelId) IngameFeature(com.almuradev.almura.shared.feature.IngameFeature) Optional(java.util.Optional) Player(org.spongepowered.api.entity.living.player.Player) Query(org.jooq.Query) Almura(com.almuradev.almura.Almura) Getter(org.spongepowered.api.event.filter.Getter) StoreBuyingItemData(com.almuradev.generated.store.tables.StoreBuyingItemData) BasicSellingItem(com.almuradev.almura.feature.store.basic.listing.BasicSellingItem) GameStartingServerEvent(org.spongepowered.api.event.game.state.GameStartingServerEvent) HashMap(java.util.HashMap) ServerboundListItemsRequestPacket(com.almuradev.almura.feature.store.network.ServerboundListItemsRequestPacket) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) SQLException(java.sql.SQLException) Lists(com.google.common.collect.Lists) ItemHandlerHelper(net.minecraftforge.items.ItemHandlerHelper) Text(org.spongepowered.api.text.Text) StoreBuyingItemRecord(com.almuradev.generated.store.tables.records.StoreBuyingItemRecord) BasicStore(com.almuradev.almura.feature.store.basic.BasicStore) SellingItem(com.almuradev.almura.feature.store.listing.SellingItem) StoreItem(com.almuradev.almura.feature.store.listing.StoreItem) StoreSellingItem(com.almuradev.generated.store.tables.StoreSellingItem) GameState(org.spongepowered.api.GameState) CauseStackManager(org.spongepowered.api.event.CauseStackManager) PluginContainer(org.spongepowered.api.plugin.PluginContainer) TextColors(org.spongepowered.api.text.format.TextColors) Nullable(javax.annotation.Nullable) Record(org.jooq.Record) StoreBuyingItemDataRecord(com.almuradev.generated.store.tables.records.StoreBuyingItemDataRecord) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Scheduler(org.spongepowered.api.scheduler.Scheduler) ServerNotificationManager(com.almuradev.almura.feature.notification.ServerNotificationManager) EnumFacing(net.minecraft.util.EnumFacing) IOException(java.io.IOException) SerializationUtil(com.almuradev.almura.shared.util.SerializationUtil) Witness(com.almuradev.core.event.Witness) ClientboundStoresRegistryPacket(com.almuradev.almura.feature.store.network.ClientboundStoresRegistryPacket) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) Listener(org.spongepowered.api.event.Listener) UniqueAccount(org.spongepowered.api.service.economy.account.UniqueAccount) Comparator(java.util.Comparator) ServerboundModifyItemsPacket(com.almuradev.almura.feature.store.network.ServerboundModifyItemsPacket) SQLException(java.sql.SQLException) BasicStore(com.almuradev.almura.feature.store.basic.BasicStore) ClientboundListItemsResponsePacket(com.almuradev.almura.feature.store.network.ClientboundListItemsResponsePacket) DSLContext(org.jooq.DSLContext) BasicSellingItem(com.almuradev.almura.feature.store.basic.listing.BasicSellingItem) SellingItem(com.almuradev.almura.feature.store.listing.SellingItem) StoreSellingItem(com.almuradev.generated.store.tables.StoreSellingItem) Results(org.jooq.Results) List(java.util.List) ArrayList(java.util.ArrayList)

Example 14 with Results

use of org.jooq.Results in project Almura by AlmuraDev.

the class ServerStoreManager method handleBuyingItemTransaction.

/**
 * Transaction (Selling/Buying)
 */
public void handleBuyingItemTransaction(final Player player, final String id, final int recNo, final int quantity) {
    checkNotNull(player);
    checkNotNull(id);
    checkState(recNo >= 0);
    checkState(quantity >= 0);
    final Store store = this.getStore(id).orElse(null);
    if (store == null) {
        this.logger.error("Player '{}' attempted to buy an item from store '{}' but the server has no knowledge of it. Syncing " + "store registry...", player.getName(), id);
        this.syncStoreRegistryTo(player);
        return;
    }
    final EconomyService economyService = this.serviceManager.provide(EconomyService.class).orElse(null);
    if (economyService == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to buy an item from store '{}' but the economy service no longer exists. This is a " + "critical error that should be reported to your economy plugin ASAP.", player.getName(), id);
        return;
    }
    final UniqueAccount account = economyService.getOrCreateAccount(player.getUniqueId()).orElse(null);
    if (account == null) {
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("Critical error encountered, check the " + "server console for more details!"));
        this.logger.error("Player '{}' attempted to buy an item from store '{}' but the economy service returned no account for them. " + "This is a critical error that should be reported to your economy plugin ASAP.", player.getName(), id);
        return;
    }
    final List<BuyingItem> buyingItems = store.getBuyingItems();
    if (buyingItems.isEmpty()) {
        this.logger.error("Player '{}' attempted to buy an item from store '{}' but the server knows of no " + " buying items for it. This could be a de-sync or an exploit.", player.getName(), store.getId());
        this.network.sendTo(player, new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.BUYING, buyingItems));
        return;
    }
    final BuyingItem found = buyingItems.stream().filter(v -> v.getRecord() == recNo).findAny().orElse(null);
    if (found == null) {
        this.logger.error("Player '{}' attempted to buy item '{}' from store '{}' but the server knows of no knowledge of it. " + "This could be a de-sync or an exploit. Discarding...", player.getName(), recNo, store.getId());
        this.network.sendTo(player, new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.BUYING, buyingItems));
        return;
    }
    final boolean infinite = found.getQuantity() == FeatureConstants.UNLIMITED;
    if (!infinite && found.getQuantity() < quantity) {
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("There is not enough quantity left to fulfill your order!"));
        return;
    }
    final BigDecimal balance = account.getBalance(economyService.getDefaultCurrency());
    final BigDecimal price = found.getPrice();
    final double total = price.doubleValue() * quantity;
    if (total > balance.doubleValue()) {
        final String formattedTotal = FeatureConstants.CURRENCY_DECIMAL_FORMAT.format(total);
        final String formattedBalance = FeatureConstants.CURRENCY_DECIMAL_FORMAT.format(balance.doubleValue());
        final String formattedDifference = FeatureConstants.CURRENCY_DECIMAL_FORMAT.format(total - balance.doubleValue());
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("You attempted to purchase items totaling to ", TextColors.RED, formattedTotal, TextColors.RESET, " while you only have ", TextColors.GREEN, formattedBalance, TextColors.RESET, ".", Text.NEW_LINE, Text.NEW_LINE, "You need ", TextColors.LIGHT_PURPLE, formattedDifference, TextColors.RESET, " more!"));
        return;
    }
    EntityPlayerMP serverPlayer = (EntityPlayerMP) player;
    final IItemHandler inventory = serverPlayer.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
    final BuyingItem copyStack = found.copy();
    copyStack.setQuantity(quantity);
    final ItemStack simulatedResultStack = ItemHandlerHelper.insertItemStacked(inventory, copyStack.asRealStack(), true);
    if (!simulatedResultStack.isEmpty()) {
        this.notificationManager.sendWindowMessage(player, Text.of("Store"), Text.of("You lack sufficient inventory space to " + "purchase these item(s)!"));
        return;
    }
    // Charge the buyer
    try (final CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) {
        frame.pushCause(store);
        account.withdraw(economyService.getDefaultCurrency(), BigDecimal.valueOf(total), frame.getCurrentCause());
        this.notificationManager.sendPopupNotification(player, Text.of(TextColors.GREEN, "Transaction Complete"), Text.of("Purchased ", TextColors.AQUA, quantity, TextColors.WHITE, " x ", TextColors.YELLOW, found.asRealStack().getDisplayName(), TextColors.RESET, " for a total of ", TextColors.GOLD, "$", FeatureConstants.CURRENCY_DECIMAL_FORMAT.format(total)), 3);
    }
    this.scheduler.createTaskBuilder().async().execute(() -> {
        try (final DSLContext context = this.databaseManager.createContext(true)) {
            int result;
            if (!infinite) {
                result = StoreQueries.createUpdateBuyingItem(found.getRecord(), found.getQuantity() - quantity, found.getIndex(), found.getPrice()).build(context).execute();
                if (result == 0) {
                    // TODO It failed, message
                    return;
                }
            }
            result = StoreQueries.createInsertBuyingTransaction(Instant.now(), found.getRecord(), player.getUniqueId(), found.getPrice(), quantity).build(context).execute();
            if (result == 0) {
                // TODO It failed, message
                StoreQueries.createUpdateBuyingItem(found.getRecord(), found.getQuantity(), found.getIndex(), found.getPrice()).build(context).execute();
                return;
            }
            final List<BuyingItem> finalBuyingItems = new ArrayList<>();
            if (!infinite) {
                final Results results = StoreQueries.createFetchBuyingItemsAndDataFor(store.getId(), false).build(context).fetchMany();
                results.forEach(r -> finalBuyingItems.addAll(this.parseBuyingItemsFor(r)));
            }
            this.scheduler.createTaskBuilder().execute(() -> {
                if (!infinite) {
                    store.putBuyingItems(finalBuyingItems);
                }
                final ItemStack resultStack = ItemHandlerHelper.insertItemStacked(inventory, copyStack.asRealStack(), false);
                if (!resultStack.isEmpty()) {
                // TODO Inventory changed awaiting DB and now we're full...could drop it on the ground? It is an off-case
                }
                if (!infinite) {
                    this.network.sendToAll(new ClientboundListItemsResponsePacket(store.getId(), StoreItemSegmentType.BUYING, store.getBuyingItems()));
                }
            }).submit(this.container);
        } catch (final SQLException e) {
            e.printStackTrace();
        }
    }).submit(this.container);
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) FilterRegistry(com.almuradev.almura.shared.feature.filter.FilterRegistry) Results(org.jooq.Results) Item(net.minecraft.item.Item) Inject(com.google.inject.Inject) StoreQueries(com.almuradev.almura.feature.store.database.StoreQueries) BuyingItem(com.almuradev.almura.feature.store.listing.BuyingItem) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) DatabaseManager(com.almuradev.almura.shared.database.DatabaseManager) BigDecimal(java.math.BigDecimal) Map(java.util.Map) DSLContext(org.jooq.DSLContext) StoreBuyingItem(com.almuradev.generated.store.tables.StoreBuyingItem) BasicBuyingItem(com.almuradev.almura.feature.store.basic.listing.BasicBuyingItem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EconomyService(org.spongepowered.api.service.economy.EconomyService) VanillaStack(com.almuradev.almura.shared.item.VanillaStack) Timestamp(java.sql.Timestamp) ClientboundListItemsResponsePacket(com.almuradev.almura.feature.store.network.ClientboundListItemsResponsePacket) FeatureConstants(com.almuradev.almura.shared.feature.FeatureConstants) Sponge(org.spongepowered.api.Sponge) DatabaseQueue(com.almuradev.almura.shared.database.DatabaseQueue) ServiceManager(org.spongepowered.api.service.ServiceManager) NetworkConfig(com.almuradev.almura.shared.network.NetworkConfig) UUID(java.util.UUID) Result(org.jooq.Result) Instant(java.time.Instant) StoreSellingItemDataRecord(com.almuradev.generated.store.tables.records.StoreSellingItemDataRecord) Collectors(java.util.stream.Collectors) Preconditions.checkState(com.google.common.base.Preconditions.checkState) ClientConnectionEvent(org.spongepowered.api.event.network.ClientConnectionEvent) ChannelBinding(org.spongepowered.api.network.ChannelBinding) List(java.util.List) Stream(java.util.stream.Stream) StoreSellingItemData(com.almuradev.generated.store.tables.StoreSellingItemData) ClientboundStoreGuiResponsePacket(com.almuradev.almura.feature.store.network.ClientboundStoreGuiResponsePacket) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) StoreSellingItemRecord(com.almuradev.generated.store.tables.records.StoreSellingItemRecord) ChannelId(org.spongepowered.api.network.ChannelId) IngameFeature(com.almuradev.almura.shared.feature.IngameFeature) Optional(java.util.Optional) Player(org.spongepowered.api.entity.living.player.Player) Query(org.jooq.Query) Almura(com.almuradev.almura.Almura) Getter(org.spongepowered.api.event.filter.Getter) StoreBuyingItemData(com.almuradev.generated.store.tables.StoreBuyingItemData) BasicSellingItem(com.almuradev.almura.feature.store.basic.listing.BasicSellingItem) GameStartingServerEvent(org.spongepowered.api.event.game.state.GameStartingServerEvent) HashMap(java.util.HashMap) ServerboundListItemsRequestPacket(com.almuradev.almura.feature.store.network.ServerboundListItemsRequestPacket) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) SQLException(java.sql.SQLException) Lists(com.google.common.collect.Lists) ItemHandlerHelper(net.minecraftforge.items.ItemHandlerHelper) Text(org.spongepowered.api.text.Text) StoreBuyingItemRecord(com.almuradev.generated.store.tables.records.StoreBuyingItemRecord) BasicStore(com.almuradev.almura.feature.store.basic.BasicStore) SellingItem(com.almuradev.almura.feature.store.listing.SellingItem) StoreItem(com.almuradev.almura.feature.store.listing.StoreItem) StoreSellingItem(com.almuradev.generated.store.tables.StoreSellingItem) GameState(org.spongepowered.api.GameState) CauseStackManager(org.spongepowered.api.event.CauseStackManager) PluginContainer(org.spongepowered.api.plugin.PluginContainer) TextColors(org.spongepowered.api.text.format.TextColors) Nullable(javax.annotation.Nullable) Record(org.jooq.Record) StoreBuyingItemDataRecord(com.almuradev.generated.store.tables.records.StoreBuyingItemDataRecord) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Scheduler(org.spongepowered.api.scheduler.Scheduler) ServerNotificationManager(com.almuradev.almura.feature.notification.ServerNotificationManager) EnumFacing(net.minecraft.util.EnumFacing) IOException(java.io.IOException) SerializationUtil(com.almuradev.almura.shared.util.SerializationUtil) Witness(com.almuradev.core.event.Witness) ClientboundStoresRegistryPacket(com.almuradev.almura.feature.store.network.ClientboundStoresRegistryPacket) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) Listener(org.spongepowered.api.event.Listener) UniqueAccount(org.spongepowered.api.service.economy.account.UniqueAccount) Comparator(java.util.Comparator) ServerboundModifyItemsPacket(com.almuradev.almura.feature.store.network.ServerboundModifyItemsPacket) UniqueAccount(org.spongepowered.api.service.economy.account.UniqueAccount) IItemHandler(net.minecraftforge.items.IItemHandler) SQLException(java.sql.SQLException) BasicStore(com.almuradev.almura.feature.store.basic.BasicStore) ClientboundListItemsResponsePacket(com.almuradev.almura.feature.store.network.ClientboundListItemsResponsePacket) DSLContext(org.jooq.DSLContext) BigDecimal(java.math.BigDecimal) EconomyService(org.spongepowered.api.service.economy.EconomyService) Results(org.jooq.Results) CauseStackManager(org.spongepowered.api.event.CauseStackManager) BuyingItem(com.almuradev.almura.feature.store.listing.BuyingItem) StoreBuyingItem(com.almuradev.generated.store.tables.StoreBuyingItem) BasicBuyingItem(com.almuradev.almura.feature.store.basic.listing.BasicBuyingItem) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) List(java.util.List) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 15 with Results

use of org.jooq.Results in project Almura by AlmuraDev.

the class ServerStoreManager method loadStores.

/**
 * Store
 */
private void loadStores() {
    final Map<String, Store> stores = new HashMap<>();
    try (final DSLContext context = this.databaseManager.createContext(true)) {
        final Results results = StoreQueries.createFetchAllStores().build(context).keepStatement(false).fetchMany();
        results.forEach(result -> {
            for (Record record : result) {
                final String id = record.getValue(com.almuradev.generated.store.tables.Store.STORE.ID);
                final Timestamp created = record.getValue(com.almuradev.generated.store.tables.Store.STORE.CREATED);
                final UUID creator = SerializationUtil.uniqueIdFromBytes(record.getValue(com.almuradev.generated.store.tables.Store.STORE.CREATOR));
                final String name = record.getValue(com.almuradev.generated.store.tables.Store.STORE.NAME);
                final String permission = record.getValue(com.almuradev.generated.store.tables.Store.STORE.PERMISSION);
                final boolean isHidden = record.getValue(com.almuradev.generated.store.tables.Store.STORE.IS_HIDDEN);
                this.logger.info("Loaded store '{}' ({})", name, id);
                stores.put(id, new BasicStore(id, created.toInstant(), creator, name, permission, isHidden));
            }
        });
    } catch (final SQLException e) {
        e.printStackTrace();
    }
    this.scheduler.createTaskBuilder().execute(() -> {
        this.stores.clear();
        this.stores.putAll(stores);
        if (this.stores.isEmpty()) {
            // TODO TEST CODE, remove before going live
            final BasicStore store = new BasicStore("almura.store.test", Instant.now(), FeatureConstants.UNKNOWN_OWNER, "Test Store", "almura.store.test", false);
            this.stores.put("almura.store.test", store);
            // Yes, I am purposely running this sync
            try (final DSLContext context1 = this.databaseManager.createContext(true)) {
                StoreQueries.createInsertStore(store.getCreated(), store.getCreator(), store.getId(), store.getName(), store.getPermission(), store.isHidden()).build(context1).keepStatement(false).execute();
                this.logger.info("Loaded store '{}' ({})", store.getName(), store.getId());
            } catch (final SQLException e) {
                e.printStackTrace();
            }
        }
        this.logger.info("Loaded [{}] store(s).", this.stores.size());
        this.stores.values().forEach(IngameFeature::syncCreatorNameToUniqueId);
        Sponge.getServer().getOnlinePlayers().forEach(this::syncStoreRegistryTo);
    }).submit(this.container);
}
Also used : HashMap(java.util.HashMap) Results(org.jooq.Results) SQLException(java.sql.SQLException) BasicStore(com.almuradev.almura.feature.store.basic.BasicStore) DSLContext(org.jooq.DSLContext) BasicStore(com.almuradev.almura.feature.store.basic.BasicStore) StoreSellingItemDataRecord(com.almuradev.generated.store.tables.records.StoreSellingItemDataRecord) StoreSellingItemRecord(com.almuradev.generated.store.tables.records.StoreSellingItemRecord) StoreBuyingItemRecord(com.almuradev.generated.store.tables.records.StoreBuyingItemRecord) Record(org.jooq.Record) StoreBuyingItemDataRecord(com.almuradev.generated.store.tables.records.StoreBuyingItemDataRecord) UUID(java.util.UUID) Timestamp(java.sql.Timestamp)

Aggregations

SQLException (java.sql.SQLException)15 DSLContext (org.jooq.DSLContext)15 Results (org.jooq.Results)15 UUID (java.util.UUID)13 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 Timestamp (java.sql.Timestamp)11 Record (org.jooq.Record)11 Map (java.util.Map)10 Player (org.spongepowered.api.entity.living.player.Player)10 Almura (com.almuradev.almura.Almura)9 ServerNotificationManager (com.almuradev.almura.feature.notification.ServerNotificationManager)9 DatabaseManager (com.almuradev.almura.shared.database.DatabaseManager)9 NetworkConfig (com.almuradev.almura.shared.network.NetworkConfig)9 SerializationUtil (com.almuradev.almura.shared.util.SerializationUtil)9 Witness (com.almuradev.core.event.Witness)9 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)9 Optional (java.util.Optional)9 Collectors (java.util.stream.Collectors)9 Nullable (javax.annotation.Nullable)9