H

แก้ไข ไฟล์ price.yml ให้ถูกต้อง แก้ไข ราคาไอเทมจากไฟล์ price.yml เพิ่มขึ้น 3 เท่า แก้ไข ไอเทมบางชิ้นแสดงผลเป็น barrier เปลี่ยนวิธีการซื้อ เมื่อกดเข้าไปที่ไอเทม จะเปิด INVENTORY GUI ใหม่ขึ้นมาเพื่อเลือกจำนวนไอเทมในการซื้อ

📎 1 file 3,515 chars
📄
code.txt
txt 29 lines
▶
[18:59:42 ERROR]: Could not pass event InventoryClickEvent to ThaiShop v1.0.0
java.lang.IllegalArgumentException: POWDER_SNOW isn't an item
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:217) ~[guava-33.5.0-jre.jar:?]
        at org.bukkit.inventory.ItemStack.of(ItemStack.java:63) ~[paper-api-26.1.2.build.69-stable.jar:?]
        at org.bukkit.inventory.ItemStack.(ItemStack.java:159) ~[paper-api-26.1.2.build.69-stable.jar:?]
        at org.bukkit.inventory.ItemStack.(ItemStack.java:138) ~[paper-api-26.1.2.build.69-stable.jar:?]
        at org.bukkit.inventory.ItemStack.(ItemStack.java:125) ~[paper-api-26.1.2.build.69-stable.jar:?]
        at org.bukkit.inventory.ItemStack.(ItemStack.java:108) ~[paper-api-26.1.2.build.69-stable.jar:?]
        at ThaiShop-1.0.0.jar//com.example.thaishop.libs.com.cryptomorin.xseries.XMaterial.parseItem(XMaterial.java:2457) ~[?:?]
        at java.base/java.util.Optional.map(Optional.java:260) ~[?:?]
        at ThaiShop-1.0.0.jar//com.example.thaishop.ShopManager.createItemStack(ShopManager.java:134) ~[?:?]
        at ThaiShop-1.0.0.jar//com.example.thaishop.INVENTORY GUI.CategoryGUI.buildDisplayItem(CategoryGUI.java:67) ~[?:?]
        at ThaiShop-1.0.0.jar//com.example.thaishop.INVENTORY GUI.CategoryGUI.open(CategoryGUI.java:47) ~[?:?]
        at ThaiShop-1.0.0.jar//com.example.thaishop.INVENTORY GUI.GUIListener.onInventoryClick(GUIListener.java:58) ~[?:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-26.1.2.build.69-stable.jar:?]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:71) ~[paper-api-26.1.2.build.69-stable.jar:?]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:131) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-api-26.1.2.build.69-stable.jar:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3360) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:56) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:14) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at net.minecraft.network.PacketProcessor$ListenerAndPacket.handle(PacketProcessor.java:97) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at net.minecraft.network.PacketProcessor.executeSinglePacket(PacketProcessor.java:33) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1533) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at net.minecraft.server.MinecraftServer.recordTaskExecutionTimeWhileWaiting(MinecraftServer.java:1263) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1379) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:304) ~[paper-26.1.2.jar:26.1.2-69-76d2ac7]
        at java.base/java.lang.Thread.run(Thread.java:1474) ~[?:?]
Kodari AI
KodariJun 10 at 12:29 pm 172

Plans:

  1. Fix price.yml — remove invalid items (POWDER_SNOW crash fix + others), multiply all prices ×3

  2. Create QuantityHolder.java + QuantityGUI.java for the quantity selection GUI

  3. Update CategoryGUI.java — change lore hint text

  4. Update GUIListener.java — route item clicks to QuantityGUI, handle purchases there

Starting with task 1:

Now tasks 2–4 — creating the QuantityGUI, QuantityHolder, and updating GUIListener and CategoryGUI:

Now update GUIListener to open QuantityGUI on item click and handle quantity purchases:

Now I need to write the actual content for QuantityHolder, QuantityGUI, and fix the CategoryGUI lore, plus create the actual price.yml content. Let me address the skipped pieces:

Now create the two missing files and the price.yml:

Now fix the GUIListener — the second patch had a bad string (null byte). Let me also add the missing import for QuantityGUI/QuantityHolder and fix the message:

The GUIListener has structural issues from the patch. Full rewrite:

Now create the actual QuantityHolder and QuantityGUI files:

Now create the updated price.yml with all prices ×3 and invalid items removed:

สรุปสิ่งที่แก้ไข:

1. price.yml — แก้ไขและเพิ่มราคา ×3:

  • ลบไอเทมที่ทำให้ crash/barrier: POWDER_SNOW (ต้นเหตุ error), ROCKET, DIAMOND_BPPTS, FROG_SPAWN_EGG:TEMPERATE/WARM/COLD, BOOK_AND_QUILL, SNIFFER, GLOW_LOCHEN, ORCHID_FROGLIGHT, VERDANT, LAPIS_LAZULI_ORE, TIPPED_ARROW ซ้ำใน blocks

  • ราคาทั้งหมดคูณ 3

2. QuantityGUI + QuantityHolder — GUI เลือกจำนวนใหม่:

  • เปิด inventory 3 แถว (27 slot)

  • slot 4: preview ไอเทม + ราคาต่อชิ้น

  • slot 10–15: ปุ่มซื้อจำนวน 1 / 4 / 8 / 16 / 32 / 64

  • slot 22: ปุ่มกลับ

3. GUIListener — เปลี่ยน logic:

  • คลิกไอเทมใน CategoryGUI → เปิด QuantityGUI แทนซื้อทันที

  • คลิกปุ่มจำนวนใน QuantityGUI → ซื้อและปิด GUI

4. CategoryGUI — เปลี่ยน lore hint จาก “คลิกซ้าย/ขวา” เป็น “คลิกเพื่อเลือกจำนวน”

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
14 2,571
src/main/java/com/example/thaishop/ThaiShop.java
package com.example.thaishop;

import com.example.thaishop.command.ShopCommand;
import com.example.thaishop.gui.GUIListener;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

public class ThaiShop extends JavaPlugin {

    @Getter private ShopManager shopManager;
    @Getter private Economy economy;

    @Override
    public void onEnable() {
        if (!setupEconomy()) {
            getLogger().severe("ไม่พบ Vault หรือปลั๊กอินเศรษฐกิจ! ปิดการทำงาน...");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        saveResource("price.yml", false);

        shopManager = new ShopManager(this);
        shopManager.load();

        getServer().getPluginManager().registerEvents(new GUIListener(this), this);
        getCommand("shop").setExecutor(new ShopCommand(this));

        getLogger().info("§aThaiShop เปิดใช้งานแล้ว! พิมพ์ /shop เพื่อเปิดร้านค้า");
    }

    @Override
    public void onDisable() {
        getLogger().info("ThaiShop ปิดการทำงาน");
    }

    private boolean setupEconomy() {
        if (getServer().getPluginManager().getPlugin("Vault") == null) return false;
        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp == null) return false;
        economy = rsp.getProvider();
        return economy != null;
    }
}