S

ยกเลิก custom-formats ทั้งหมด เปลี่ยนมาใช้ชื่อจาก Display Name ของไอเทมแทน

Kodari AI
KodariMay 21 at 6:49 am 15,671 (v2)

ให้ผมอ่านไฟล์ทั้งหมดก่อนเพื่อดูว่า custom-formats ใช้งานอยู่ที่ไหนบ้าง

ผมจะยกเลิก custom-formats ทั้งหมดและเปลี่ยนมาใช้ Display Name ของไอเทมแทน

แผนการแก้ไข:

  • ลบ custom-formats ออกจาก config.yml

  • ลบการโหลด custom-formats จาก ItemMerge.java

  • แก้ไข ItemMergeManager.java ให้ใช้ Display Name ของไอเทม (ถ้ามี)

เสร็จแล้ว! ยกเลิก custom-formats ทั้งหมดและเปลี่ยนมาใช้ Display Name ของไอเทมแล้ว

สิ่งที่เปลี่ยนแปลง:

  1. ✅ ลบ custom-formats section ทั้งหมดออกจาก config.yml

  2. ✅ ลบการโหลด custom-formats จาก ItemMerge.java

  3. ✅ แก้ไข ItemMergeManager.java ให้ตรวจสอบและใช้ Display Name จากไอเทม (ถ้ามี) พร้อมกับจำนวน - ถ้าไม่มี Display Name ก็จะ format ชื่อจาก Material แบบเดิม

ตอนนี้ระบบจะแสดงชื่อตามลำดับความสำคัญ:

  1. Display Name ของไอเทม (ถ้ามีการตั้งชื่อ custom)

  2. ชื่อ Material (auto-format จาก Material enum เช่น DIAMOND_SWORD → Diamond Sword)

รูปแบบการแสดงผล: ▶ x{จำนวน} {ชื่อไอเทม} (สีจำนวนเปลี่ยนตามปริมาณ: แดง/เหลือง/เขียว)

S

เพิ่ม config ตั้งค่า ชื่อที่แสดงด้านบนของไอเทม "▶ x{จำนวน} {ชื่อไอเทม}"

Kodari AI
KodariMay 21 at 6:52 am 12,660 (v2)

ให้ผมอ่านไฟล์เพื่อเพิ่ม config สำหรับตั้งค่ารูปแบบชื่อที่แสดง

เพิ่ม config สำหรับตั้งค่ารูปแบบ hologram ให้ปรับแต่งได้

เสร็จแล้ว! เพิ่ม config สำหรับตั้งค่ารูปแบบชื่อที่แสดงบนไอเทมแล้ว

สิ่งที่เพิ่ม:

  1. ✅ เพิ่ม hologram section ใน config.yml พร้อม:

    • format รูปแบบการแสดงผล (รองรับ MiniMessage format)

    • thresholds ค่าขีดจำนวนที่เปลี่ยนสี (medium/high)

  2. ✅ เพิ่ม methods ใน ItemMerge.java:

    • getHologramFormat() อ่านรูปแบบจาก config

    • getMediumThreshold() อ่านเกณฑ์สีเหลือง (default: 61)

    • getHighThreshold() อ่านเกณฑ์สีเขียว (default: 251)

  3. ✅ แก้ไข ItemMergeManager.java ใช้ MiniMessage parser แทน hardcode

การใช้งาน config:

YAML
hologram:
  format: "<yellow>▶ <amount_color>x{amount} <white>{name}"
  thresholds:
    medium: 61   # >= 61 ใช้สีเหลือง
    high: 251    # >= 251 ใช้สีเขียว

Placeholders:

  • {amount} = จำนวนไอเทม

  • {name} = ชื่อไอเทม (Display Name หรือ Material name)

  • <amount_color> = สีที่เปลี่ยนตามจำนวน (แดง/เหลือง/เขียว)

ตัวอย่างการปรับแต่ง:

  • "<gold>★ <amount_color>×{amount} <gradient:green:blue>{name}"

  • "<gray>[<amount_color>{amount}<gray>] <white>{name}"

Kodari can make mistakes. Review important code before using.
Files
org
config.yml
paper-plugin.yml
Code
8 416
org/sayu/SayuStacker/ItemMerge.java
package org.sayu.SayuStacker;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.sayu.SayuStacker.listener.ItemMergeTask;
import org.sayu.SayuStacker.listener.ItemSpawnListener;
import org.sayu.SayuStacker.listener.PlayerPickupListener;
import org.sayu.SayuStacker.manager.ItemMergeManager;

public class ItemMerge extends JavaPlugin {
   private static ItemMerge instance;

   public void onEnable() {
      instance = this;
      this.saveDefaultConfig();
      Bukkit.getPluginManager().registerEvents(new ItemSpawnListener(), this);
      Bukkit.getPluginManager().registerEvents(new PlayerPickupListener(), this);
      (new ItemMergeTask()).runTaskTimer(this, 40L, 40L);
      this.getLogger().info("ItemMerge Plugin Enabled!");
   }

   public void onDisable() {
      this.getLogger().info("ItemMerge Plugin Disabled!");
   }

   public static ItemMerge getInstance() {
      return instance;
   }

   public String getHologramFormat() {
      return this.getConfig().getString("hologram.format", "<yellow>▶ <amount_color>x{amount} <white>{name}");
   }

   public int getMediumThreshold() {
      return this.getConfig().getInt("hologram.thresholds.medium", 61);
   }

   public int getHighThreshold() {
      return this.getConfig().getInt("hologram.thresholds.high", 251);
   }
}