birdniczek

dodaj zminne na topki hajsu i formated balance i balance

Kodari AI
KodariJan 29 at 4:41 pm 1,922 (v2)

[Generation stopped]

birdniczek

dodaj zminne na topki hajsu i formated balance i balance placeholderapi

Kodari AI
KodariJan 29 at 4:45 pm 22,015 (v2)
birdniczek

podaj teraz te zminne

Kodari AI
KodariJan 29 at 4:47 pm 6,270 (v2)

Oto lista publicznych zmiennych (pól) z klasy Config.java w projekcie:

  • costFormat: String = “{cost} wPLN”

  • discountPercentage: double = 50.0

  • discountCostFormat: String = “{cost} wPLN &8(&ddiscount -{percent}%&8)”

  • dailyRewardMin: double = 0.01

  • dailyRewardMax: double = 0.05

  • mainGui: GuiBuilder (konfiguracja GUI dla głównego menu ItemShop)

  • quantitySelectionGui: GuiBuilder (konfiguracja GUI dla wyboru ilości)

  • purchaseConfirmationGui: GuiBuilder (konfiguracja GUI dla potwierdzenia zakupu)

  • processingGui: GuiBuilder (konfiguracja GUI dla przetwarzania)

  • loreOfferSufficientFunds: List<String> (linie lore dla oferty z wystarczającymi funduszami)

  • loreOfferInsufficientFunds: List<String> (linie lore dla oferty z niewystarczającymi funduszami)

  • offers: List<Offer> (lista ofert, np. “legendary-keys”, “vip-rank”, “svip-rank”)

Jeśli potrzebujesz szczegółów, modyfikacji lub kodu z innej klasy, daj znać!

birdniczek

ale %%

Kodari AI
KodariJan 29 at 4:48 pm 1,764 (v2)

I’m sorry, but “ale %%” doesn’t seem like a clear query or instruction related to the Minecraft plugin development. Could you please provide more details or clarify what you’d like assistance with?

birdniczek

%placeholder%

Kodari AI
KodariJan 29 at 4:53 pm 7,141 (v2)

Available Placeholders in Wallet Plugin

Based on the plugin’s PlaceholderAPI expansion, here are the supported placeholders (assuming PlaceholderAPI is installed on the server):

  • %wallet_balance%: Displays the player’s raw wallet balance (e.g., “100.0”).

  • %wallet_balance_formatted%: Displays the player’s formatted wallet balance with suffix (e.g., “100 wPLN”).

  • %wallet_balance_<name>%: Displays the raw wallet balance for a specific player by name (e.g., %wallet_balance_steve%).

  • %wallet_balance_formatted_<name>%: Displays the formatted wallet balance for a specific player by name (e.g., “100 wPLN”).

  • %wallet_top_name_<position>%: Displays the capitalized name of the player at the specified top position (1-10, e.g., %wallet_top_name_1% for the richest player).

  • %wallet_top_balance_<position>%: Displays the raw balance of the player at the specified top position (1-10, e.g., %wallet_top_balance_1%).

  • %wallet_top_balance_formatted_<position>%: Displays the formatted balance of the player at the specified top position (1-10, e.g., “1000 wPLN”).

If the position is invalid or out of range for top placeholders, it returns “N/A”. These are resolved asynchronously using the plugin’s user services.

If this isn’t what you meant by “%placeholder%”, provide more details!

Kodari can make mistakes. Review important code before using.
Files
plugin
build.gradle.kts
README.md
settings.gradle.kts
Code
29 2,002
plugin/src/main/java/net/masternation/wallet/gui/MainGui.java
package net.masternation.wallet.gui;

import lombok.RequiredArgsConstructor;
import me.masterkaiser.bukkit.BukkitApp;
import me.masterkaiser.bukkit.api.item.ItemBuilder;
import me.masterkaiser.bukkit.api.item.ItemConverterService;
import me.masterkaiser.bukkit.gui.Gui;
import me.masterkaiser.util.RoundUtil;
import net.masternation.wallet.config.Config;
import net.masternation.wallet.config.Messages;
import net.masternation.wallet.offer.OfferService;
import net.masternation.wallet.user.UserService;
import net.masternation.wallet.util.FormatUtil;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

@Component
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class MainGui {

    private final BukkitApp bukkitApp;
    private final UserService userService;
    private final Config config;
    private final OfferConfirmGui offerConfirmGui;
    private final MountableGui mountableGui;
    private final Messages messages;
    private final ProcessingGui processingGui;
    private final OfferService offerService;
    private final Set<UUID> dailyCoolDown = new HashSet<>();

    public CompletableFuture<Gui> build(@NotNull Player object) {
        CompletableFuture<Gui> guiCompletableFuture = new CompletableFuture<>();
        Gui gui = Gui.create(this.bukkitApp, this.config.mainGui, true, false, null);
        this.userService.getWallet(object.getUniqueId()).thenAccept(pln -> {
            if (pln == null) {
                return;
            }

            account(gui, object, pln);

            this.userService.canClaimDailyReward(object.getUniqueId()).thenAccept(aBoolean -> {
                if (gui.getInventoryNullable() != null) {
                    if (aBoolean) {
                        Optional.ofNullable(this.config.mainGui.getStateItems().get("daily")).ifPresent(itemSlot -> {
                            gui.setItem(itemSlot.getSlot(), itemSlot.getItemBuilder().build(m -> m
                                    .replace("{max}", FormatUtil.formatNumber(this.config.dailyRewardMax))
                                    .replace("{min}", FormatUtil.formatNumber(this.config.dailyRewardMin))), event -> {
                                if (this.dailyCoolDown.contains(object.getUniqueId())) {
                                    return;
                                }

                                this.dailyCoolDown.add(object.getUniqueId());
                                this.userService.canClaimDailyReward(object.getUniqueId()).thenAccept(d -> {
                                    if (!d) {
                                        this.dailyCoolDown.remove(object.getUniqueId());
                                        object.closeInventory();
                                    } else {
                                        this.userService.claimDailyReward(object.getUniqueId()).thenAccept(wPLN -> {
                                            this.messages.receiveDailyReward.send(object, m -> m.replace("{reward}", FormatUtil.formatNumber(wPLN)));

                                            if (gui.getInventoryNullable() != null) {
                                                dailyTaken(gui);
                                                account(gui, object, wPLN);
                                            }

                                            this.dailyCoolDown.remove(object.getUniqueId());
                                        });
                                    }
                                });
                            });
                        });
                    } else {
                        dailyTaken(gui);
                    }
                }
            });

            this.config.offers.forEach(offer -> {
                ItemBuilder itemBuilder = ItemConverterService.itemConverter.fromItemStack(offer.getIcon().build());
                if (pln >= offer.getCost()) {
                    itemBuilder.mergeLore(this.config.loreOfferSufficientFunds, m -> {
                        return m.replace("{cost}", offerService.getCostString(offer, 1));
                    });
                } else {
                    itemBuilder.mergeLore(this.config.loreOfferInsufficientFunds, m -> {
                        return m.replace("{cost}", offerService.getCostString(offer, 1));
                    });
                }

                gui.setItem(offer.getSlot(), itemBuilder.build(), event -> {
                    Player player = (Player) event.getWhoClicked();
                    if (!this.userService.canDoAction(player.getUniqueId())) {
                        return;
                    }

                    if (pln < this.offerService.getCost(offer, 1)) {
                        this.messages.insufficientFunds.send(player);
                        return;
                    }

                    if (!offer.isMountable()) {
                        this.processingGui.open(player);
                        this.offerConfirmGui.build(player, offer, 1).thenAccept(gui1 -> {
                            if (player.isOnline()) {
                                gui1.open(player);
                            } else {
                                gui1.dispose(true);
                            }
                        });
                    } else {
                        this.processingGui.open(player);
                        this.mountableGui.build(player, offer).thenAccept(gui1 -> {
                            if (player.isOnline()) {
                                gui1.open(player);
                            } else {
                                gui1.dispose(true);
                            }
                        });
                    }
                });
            });

            guiCompletableFuture.complete(gui);
        });


        return guiCompletableFuture;
    }

    public void dailyTaken(@NotNull Gui gui) {
        Optional.ofNullable(this.config.mainGui.getStateItems().get("daily-claimed")).ifPresent(itemSlot -> {
            gui.setItem(itemSlot.getSlot(), itemSlot.getItemBuilder().build(m -> m
                    .replace("{max}", FormatUtil.formatNumber(this.config.dailyRewardMax))
                    .replace("{min}", FormatUtil.formatNumber(this.config.dailyRewardMin))), event -> {});
        });
    }

    public void account(@NotNull Gui gui, @NotNull Player object, @NotNull Double pln) {
        Optional.ofNullable(this.config.mainGui.getStateItems().get("account")).ifPresent(itemSlot -> {
            ItemStack is = itemSlot.getItemBuilder().build(m -> m.replace("{pln}", FormatUtil.formatNumber(RoundUtil.roundToDecimalPlaces(pln, 2))));
            ItemMeta meta = is.getItemMeta();
            if (meta instanceof SkullMeta skullMeta) {
                skullMeta.setOwningPlayer(object);
                is.setItemMeta(skullMeta);
            }

            gui.setItem(itemSlot.getSlot(), is);
        });
    }

}