K
📎 5 files 12,540 chars
📄
ItemListener.java
java 46 lines
▶
/*    */ package sayu.listeners;
/*    */ 
/*    */ import org.bukkit.event.EventHandler;
/*    */ import org.bukkit.event.Listener;
/*    */ import org.bukkit.event.inventory.InventoryClickEvent;
/*    */ import org.bukkit.event.player.PlayerDropItemEvent;
/*    */ import org.bukkit.event.player.PlayerItemHeldEvent;
/*    */ import org.bukkit.inventory.ItemStack;
/*    */ import sayu.manager.TimeLimitedItemManager;
/*    */ 
/*    */ public class ItemListener implements Listener {
/*    */   private final TimeLimitedItemManager itemManager;
/*    */   
/*    */   public ItemListener(TimeLimitedItemManager paramTimeLimitedItemManager) {
/* 15 */     this.itemManager = paramTimeLimitedItemManager;
/*    */   }
/*    */   
/*    */   @EventHandler
/*    */   public void onInventoryClick(InventoryClickEvent paramInventoryClickEvent) {
/* 20 */     if (this.itemManager.isExpired(paramInventoryClickEvent.getCurrentItem())) {
/* 21 */       paramInventoryClickEvent.setCurrentItem((ItemStack)null);
/*    */     }
/*    */   }
/*    */ 
/*    */   
/*    */   @EventHandler
/*    */   public void onItemDrop(PlayerDropItemEvent paramPlayerDropItemEvent) {
/* 28 */     if (this.itemManager.isExpired(paramPlayerDropItemEvent.getItemDrop().getItemStack())) {
/* 29 */       paramPlayerDropItemEvent.getItemDrop().remove();
/*    */     }
/*    */   }
/*    */ 
/*    */   
/*    */   @EventHandler
/*    */   public void onItemHeld(PlayerItemHeldEvent paramPlayerItemHeldEvent) {
/* 36 */     ItemStack itemStack = paramPlayerItemHeldEvent.getPlayer().getInventory().getItem(paramPlayerItemHeldEvent.getNewSlot());
/* 37 */     if (this.itemManager.isExpired(itemStack))
/* 38 */       paramPlayerItemHeldEvent.getPlayer().getInventory().setItem(paramPlayerItemHeldEvent.getNewSlot(), (ItemStack)null); 
/*    */   }
/*    */ }


/* Location:              H:\folia\plugins\Sayu-1.2.jar!\sayu\listeners\ItemListener.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */
📄
SayuPlugin.java
java 50 lines
▶
/*    */ package sayu;
/*    */ import me.libs.serverlibs.ServiceSupport;
/*    */ import org.bukkit.command.CommandExecutor;
/*    */ import org.bukkit.event.Listener;
/*    */ import org.bukkit.plugin.Plugin;
/*    */ import org.bukkit.plugin.java.JavaPlugin;
/*    */ import sayu.commands.SgCommand;
/*    */ import sayu.manager.TimeLimitedItemManager;
/*    */ 
/*    */ public final class SayuPlugin extends JavaPlugin {
/*    */   private static SayuPlugin instance;
/*    */   
/*    */   public void onEnable() {
/* 14 */     2144219755; ServiceSupport.inject(this); 517560779; ServiceSupport.inject(this); "b564c007a9393859"; int i = 1054646770;
/* 15 */     ServiceSupport.inject(this);
/* 16 */     String str = "ebff06cfaea63847";
/* 17 */     long l = 3820690479753827798L;
/* 18 */     ServiceSupport.inject(this);
/* 19 */     l = -6544292079533283379L;
/* 20 */     instance = this;
/* 21 */     saveDefaultConfig();
/* 22 */     this.itemManager = new TimeLimitedItemManager(this);
/* 23 */     getCommand("tisa").setExecutor((CommandExecutor)new SgCommand(this.itemManager));
/* 24 */     getServer().getPluginManager().registerEvents((Listener)new ItemListener(this.itemManager), (Plugin)this);
/* 25 */     this.itemManager.startCleanupTask();
/* 26 */     getLogger().info("Sayu enabled.");
/*    */   }
/*    */   private TimeLimitedItemManager itemManager;
/*    */   public void onDisable() {
/* 30 */     if (this.itemManager != null) {
/* 31 */       this.itemManager.stopCleanupTask();
/*    */     }
/*    */     
/* 34 */     getLogger().info("Sayu disabled.");
/*    */   }
/*    */   
/*    */   public static SayuPlugin getInstance() {
/* 38 */     return instance;
/*    */   }
/*    */   
/*    */   public TimeLimitedItemManager getItemManager() {
/* 42 */     return this.itemManager;
/*    */   }
/*    */ }


/* Location:              H:\folia\plugins\Sayu-1.2.jar!\sayu\SayuPlugin.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */
📄
SgCommand.java
java 66 lines
▶
/*    */ package sayu.commands;
/*    */ 
/*    */ import org.bukkit.Bukkit;
/*    */ import org.bukkit.command.Command;
/*    */ import org.bukkit.command.CommandExecutor;
/*    */ import org.bukkit.command.CommandSender;
/*    */ import org.bukkit.entity.Player;
/*    */ import org.bukkit.inventory.ItemStack;
/*    */ import sayu.ItemConfig;
/*    */ import sayu.manager.TimeLimitedItemManager;
/*    */ 
/*    */ public class SgCommand implements CommandExecutor {
/*    */   private final TimeLimitedItemManager itemManager;
/*    */   
/*    */   public SgCommand(TimeLimitedItemManager paramTimeLimitedItemManager) {
/* 16 */     this.itemManager = paramTimeLimitedItemManager;
/*    */   }
/*    */   
/*    */   public boolean onCommand(CommandSender paramCommandSender, Command paramCommand, String paramString, String[] paramArrayOfString) {
/* 20 */     if (paramArrayOfString.length == 0) {
/* 21 */       paramCommandSender.sendMessage("§cUsage: /tisa   ");
/* 22 */       return true;
/*    */     } 
/*    */     
/* 25 */     String str = paramArrayOfString[0].toLowerCase();
/*    */     
/* 27 */     if (str.equals("give")) {
/* 28 */       if (paramArrayOfString.length < 3) {
/* 29 */         paramCommandSender.sendMessage("§cUsage: /tisa give  ");
/* 30 */         return true;
/*    */       } 
/*    */       
/* 33 */       Player player = Bukkit.getPlayer(paramArrayOfString[1]);
/* 34 */       if (player == null) {
/* 35 */         paramCommandSender.sendMessage("§cPlayer not found: " + paramArrayOfString[1]);
/* 36 */         return true;
/*    */       } 
/*    */       
/* 39 */       String str1 = paramArrayOfString[2];
/* 40 */       ItemConfig itemConfig = this.itemManager.getItemConfig(str1);
/* 41 */       if (itemConfig == null) {
/* 42 */         paramCommandSender.sendMessage("§cUnknown item: " + str1);
/* 43 */         return true;
/*    */       } 
/*    */       
/* 46 */       ItemStack itemStack = itemConfig.createItemStack();
/* 47 */       player.getInventory().addItem(new ItemStack[] { itemStack });
/* 48 */       paramCommandSender.sendMessage("§aGave " + str1 + " to " + player.getName());
/* 49 */       return true;
/*    */     } 
/* 51 */     if (str.equals("reload")) {
/* 52 */       this.itemManager.reloadConfig();
/* 53 */       paramCommandSender.sendMessage("§aConfiguration reloaded successfully!");
/* 54 */       return true;
/*    */     } 
/*    */     
/* 57 */     paramCommandSender.sendMessage("§cUsage: /tisa   ");
/* 58 */     return true;
/*    */   }
/*    */ }


/* Location:              H:\folia\plugins\Sayu-1.2.jar!\sayu\commands\SgCommand.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */
📄
TimeLimitedItemManager.java
java 1 lines
▶
// INTERNAL ERROR //
📄
ItemConfig.java
java 109 lines
▶
/*     */ package sayu;
/*     */ 
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.stream.Collectors;
/*     */ import org.bukkit.Material;
/*     */ import org.bukkit.NamespacedKey;
/*     */ import org.bukkit.configuration.ConfigurationSection;
/*     */ import org.bukkit.enchantments.Enchantment;
/*     */ import org.bukkit.inventory.ItemStack;
/*     */ import org.bukkit.inventory.meta.ItemMeta;
/*     */ import org.bukkit.persistence.PersistentDataType;
/*     */ import org.bukkit.plugin.Plugin;
/*     */ 
/*     */ 
/*     */ public class ItemConfig
/*     */ {
/*     */   private final String id;
/*     */   private final Material material;
/*     */   private final String displayName;
/*     */   
/*     */   public ItemConfig(String paramString, ConfigurationSection paramConfigurationSection) {
/*  24 */     this.id = paramString;
/*  25 */     this.material = Material.valueOf(paramConfigurationSection.getString("material", "DIRT"));
/*  26 */     this.displayName = paramConfigurationSection.getString("display_name", paramString);
/*  27 */     this.lore = paramConfigurationSection.getStringList("lore");
/*  28 */     ConfigurationSection configurationSection = paramConfigurationSection.getConfigurationSection("enchantments");
/*  29 */     this.enchantments = (configurationSection != null) ? (Map)configurationSection.getValues(false).entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, paramEntry -> Integer.valueOf(((Number)paramEntry.getValue()).intValue()))) : Map.of();
/*  30 */     this.durationSeconds = paramConfigurationSection.getLong("duration_seconds", 3600L);
/*     */   }
/*     */   private final List lore; private final Map enchantments; private final long durationSeconds;
/*     */   public String getId() {
/*  34 */     return this.id;
/*     */   }
/*     */   
/*     */   public long getDurationSeconds() {
/*  38 */     return this.durationSeconds;
/*     */   }
/*     */   
/*     */   public List getLore() {
/*  42 */     return this.lore;
/*     */   }
/*     */   
/*     */   public ItemStack createItemStack() {
/*  46 */     ItemStack itemStack = new ItemStack(this.material);
/*  47 */     ItemMeta itemMeta = itemStack.getItemMeta();
/*  48 */     if (itemMeta != null) {
/*  49 */       if (this.displayName != null) {
/*  50 */         itemMeta.setDisplayName(colorize(this.displayName));
/*     */       }
/*     */       
/*  53 */       if (this.lore != null && !this.lore.isEmpty()) {
/*  54 */         long l1 = System.currentTimeMillis() + this.durationSeconds * 1000L;
/*  55 */         String str = SayuPlugin.getInstance().getItemManager().getTimePlaceholder(Long.valueOf(l1));
/*  56 */         ArrayList arrayList = new ArrayList();
/*     */         
/*  58 */         for (String str1 : this.lore) {
/*  59 */           String str2 = str1.replace("{time}", str);
/*  60 */           arrayList.add(colorize(str2));
/*     */         } 
/*     */         
/*  63 */         itemMeta.setLore(arrayList);
/*     */       } 
/*     */       
/*  66 */       long l = System.currentTimeMillis() + this.durationSeconds * 1000L;
/*  67 */       NamespacedKey namespacedKey1 = new NamespacedKey((Plugin)SayuPlugin.getInstance(), "sayu_expiry");
/*  68 */       itemMeta.getPersistentDataContainer().set(namespacedKey1, PersistentDataType.LONG, Long.valueOf(l));
/*  69 */       NamespacedKey namespacedKey2 = new NamespacedKey((Plugin)SayuPlugin.getInstance(), "sayu_item_id");
/*  70 */       itemMeta.getPersistentDataContainer().set(namespacedKey2, PersistentDataType.STRING, this.id);
/*  71 */       itemStack.setItemMeta(itemMeta);
/*     */     } 
/*     */     
/*  74 */     for (Map.Entry entry : this.enchantments.entrySet()) {
/*  75 */       Enchantment enchantment = Enchantment.getByName(((String)entry.getKey()).toUpperCase());
/*  76 */       if (enchantment != null) {
/*  77 */         itemStack.addUnsafeEnchantment(enchantment, ((Integer)entry.getValue()).intValue()); continue;
/*     */       } 
/*     */       try {
/*  80 */         Enchantment enchantment1 = Enchantment.getByKey(NamespacedKey.fromString(((String)entry.getKey()).toLowerCase()));
/*  81 */         if (enchantment1 == null) {
/*  82 */           enchantment1 = Enchantment.getByKey(NamespacedKey.fromString((String)entry.getKey()));
/*     */         }
/*     */         
/*  85 */         if (enchantment1 != null) {
/*  86 */           itemStack.addUnsafeEnchantment(enchantment1, ((Integer)entry.getValue()).intValue()); continue;
/*     */         } 
/*  88 */         SayuPlugin.getInstance().getLogger().warning("Unknown enchantment: " + (String)entry.getKey());
/*     */       }
/*  90 */       catch (IllegalArgumentException illegalArgumentException) {
/*  91 */         SayuPlugin.getInstance().getLogger().warning("Unknown enchantment: " + (String)entry.getKey());
/*     */       } 
/*     */     } 
/*     */ 
/*     */     
/*  96 */     return itemStack;
/*     */   }
/*     */   
/*     */   private static String colorize(String paramString) {
/* 100 */     char c = '§';
/* 101 */     return paramString.replace('&', c);
/*     */   }
/*     */ }


/* Location:              H:\folia\plugins\Sayu-1.2.jar!\sayu\ItemConfig.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */
Kodari AI
KodariMay 23 at 6:24 am 9,461 (v2)

I’ll create a time-limited items plugin based on the attached decompiled code.

TimeLimitedItems
A Minecraft plugin that creates items with expiration times. Items automatically disappear after their configured duration expires. Features include configurable item types with custom materials, display names, lore, enchantments, and durations. Includes automatic cleanup tasks, persistent data storage, and admin commands for giving items and reloading configuration. Expired items are removed from inventories when clicked, dropped, or held.

Creating a time-limited items plugin with automatic expiration and cleanup.

Plan:

  • Main plugin class with manager initialization

  • ItemConfig class to parse and create items from config

  • TimeLimitedItemManager for expiry checking and cleanup

  • Listener to remove expired items on interaction

  • Command for giving items and reloading config

Plugin created successfully!

Features:

  • Time-limited items with configurable durations

  • Automatic expiration checking via cleanup task

  • Items removed on click, drop, or held when expired

  • Persistent data storage using PDC

  • Commands: /tli give <player> <item>, /tli reload, /tli list

  • Dynamic time formatting in lore with {time} placeholder

  • XSeries for cross-version compatibility (1.8-1.21+)

  • Configurable enchantments and item properties

Items are stored with expiry timestamps and automatically cleaned from inventories when they expire.

K

เพิ่ม config settings: actionbar-enabled: true actionbar-format: "§x§E§4§A§C§E§Fɪ§x§E§4§A§9§E§Fᴛ§x§E§5§A§6§E§Fᴇ§x§E§5§A§3§E§Fᴍ §x§E§6§9§D§E§Fɴ§x§E§7§9§A§E§Fᴇ§x§E§7§9§7§E§Fᴡ§x§E§8§9§4§E§Fʙ§x§E§8§9§1§E§Fɪ§x§E§9§8§E§F§0ᴇ §x§E§A§8§8§F§0» §x§E§B§8§2§F§0ไ§x§E§B§7§F§F§0อ§x§E§C§7§C§F§0เ§x§E§C§7§9§F§0ท§x§E§D§7§6§F§0ม§x§E§D§7§4§F§0จ§x§E§D§7§1§F§0ะ§x§E§E§6§E§F§0ห§x§E§E§6§B§F§0ม§x§E§F§6§8§F§0ด§x§E§F§6§5§F§0เ§x§F§0§6§2§F§0ว§x§F§0§5§F§F§0ล§x§F§1§5§C§F§0า§x§F§1§5§9§F§0ใ§x§F§2§5§6§F§1น§x§F§2§5§3§F§1อ§x§F§3§5§0§F§1ี§x§F§3§4§D§F§1ก§x§F§4§4§A§F§1: {time} §x§F§5§4§4§F§1น§x§F§5§4§1§F§1า§x§F§6§3§E§F§1ท§x§F§6§3§B§F§1ี" #{time} actionbar-update-interval: 20 cleanup-interval: 100

Kodari AI
KodariMay 23 at 6:27 am 4,749 (v2)

I’ll read the current config.yml file first, then add the new settings.

Now I’ll update the config.yml to add the new settings section with actionbar configuration and reorganize the cleanup-interval:

Added the settings section to config.yml with actionbar configuration (enabled, custom format with hex colors, update interval of 20 ticks) and cleanup interval of 100 ticks.

K

แปลภาษาให้เป็น ภาษาไทย

Kodari AI
KodariMay 23 at 6:29 am 15,311 (v2)

ผมจะอ่านไฟล์ต่างๆ ในโปรเจคก่อนเพื่อดูว่ามีข้อความอะไรที่ต้องแปลเป็นภาษาไทย

ผมจะแปลข้อความทั้งหมดในโปรเจคให้เป็นภาษาไทย

แปลภาษาเป็นภาษาไทยเรียบร้อยแล้ว ได้แปลในส่วนต่อไปนี้:

config.yml: แปลคอมเมนต์และรายละเอียดไอเท็ม (ชุดเพชร, แอปเปิ้ลทองคำ, รองเท้าแห่งความเร็ว)

plugin.yml: แปลคำอธิบายและวิธีใช้คำสั่ง

คำสั่งและข้อความ (ItemCommand.java): แปลข้อความแจ้งเตือนทั้งหมด เช่น “ไม่พบผู้เล่น”, “โหลดการตั้งค่าใหม่สำเร็จ”, “ไอเท็มจำกัดเวลาที่มี”

ข้อความระบบ (TimeLimitedItemsPlugin.java & TimeLimitedItemManager.java): แปลข้อความ log และข้อความ “หมดอายุ”

K

เพิ่มการรองรับ foliaserver

Kodari AI
KodariMay 23 at 6:32 am 20,060 (v2)

ผมจะอ่าน documentation ของ folialib และไฟล์ในโปรเจคเพื่อเพิ่มการรองรับ Folia server

ผมจะเพิ่มการรองรับ Folia server ให้กับปลั๊กอิน โดยใช้ FoliaLib

ตอนนี้ผมจะเพิ่มการรองรับ Folia:

K

ข้อความบน actionbar ใน configไม่แสดงผล เปลี่ยนข้อความบน actionbar <ชื่ออุปกรณ์> เวลาที่เลือ : DD:HH:MM:SS items เพิ่ม custom_model_data เพิ่มการรองรับจาก excellentenchants ผ่าน config เช่น pickaxe มี enchants tunnel

Kodari AI
KodariMay 23 at 6:42 am 25,361 (v2)

ผมจะอ่านไฟล์ทั้งหมดเพื่อดูโค้ดปัจจุบันและแก้ไขปัญหา actionbar พร้อมเพิ่มฟีเจอร์ที่ขอ

ผมจะอ่าน documentation ของ ExcellentEnchants แล้วแก้ไขปัญหาทั้งหมด

ผมจะแก้ไขปัญหาทั้งหมด พร้อมเพิ่มฟีเจอร์ที่ขอ:

เสร็จแล้ว! ผมได้แก้ไขปัญหาและเพิ่มฟีเจอร์ทั้งหมด:

1. แก้ไข Actionbar

  • เปลี่ยน format เป็น "{name} §7เวลาที่เหลือ : §c{time}"

  • เพิ่มฟังก์ชัน getTimePlaceholderForActionbar() ที่แสดงเวลาในรูปแบบ DD:HH:MM:SS

  • สร้าง actionbarTask ที่ update ทุก 20 ticks แสดงชื่อไอเทมที่ถืออยู่ + เวลาที่เหลือ

2. เพิ่ม custom_model_data

  • เพิ่ม field customModelData ใน ItemConfig.java

  • อ่านค่าจาก config และตั้งค่าให้ ItemStack ด้วย meta.setCustomModelData()

  • เพิ่ม custom_model_data: 0 ให้ทุกไอเทมใน config (0 = ไม่ใช้)

3. รองรับ ExcellentEnchants

  • แก้ไขระบบ enchant เพื่อรองรับทั้ง vanilla และ custom enchants

  • ถ้า XEnchantment ไม่เจอ จะใช้ Enchantment.getByName() เพื่อหา custom enchants

  • เพิ่มตัวอย่าง example_pickaxe ใน config ที่มี enchant tunnel: 3 จาก ExcellentEnchants

ตอนนี้ actionbar จะแสดงชื่ออุปกรณ์และเวลาที่เหลือในรูปแบบ DD:HH:MM:SS เมื่อผู้เล่นถือไอเทมจำกัดเวลา!

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
9 656
src/main/java/com/timelimited/TimeLimitedItemsPlugin.java
package com.timelimited;

import com.tcoded.folialib.FoliaLib;
import com.timelimited.command.ItemCommand;
import com.timelimited.listener.ItemListener;
import com.timelimited.manager.TimeLimitedItemManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class TimeLimitedItemsPlugin extends JavaPlugin {
    private static TimeLimitedItemsPlugin instance;
    private FoliaLib foliaLib;
    private TimeLimitedItemManager itemManager;
    
    @Override
    public void onEnable() {
        instance = this;
        
        this.foliaLib = new FoliaLib(this);
        
        saveDefaultConfig();
        
        this.itemManager = new TimeLimitedItemManager(this, this.foliaLib);
        
        getCommand("timelimiteditem").setExecutor(new ItemCommand(this.itemManager));
        
        Bukkit.getPluginManager().registerEvents(new ItemListener(this.itemManager), this);
        
        this.itemManager.startCleanupTask();
        
        getLogger().info("เปิดใช้งาน TimeLimitedItems สำเร็จ!");
    }
    
    @Override
    public void onDisable() {
        if (this.itemManager != null) {
            this.itemManager.stopCleanupTask();
        }
        
        if (this.foliaLib != null) {
            this.foliaLib.getScheduler().cancelAllTasks();
        }
        
        getLogger().info("ปิดการทำงาน TimeLimitedItems");
    }
    
    public static TimeLimitedItemsPlugin getInstance() {
        return instance;
    }
    
    public TimeLimitedItemManager getItemManager() {
        return this.itemManager;
    }
    
    public FoliaLib getFoliaLib() {
        return this.foliaLib;
    }
}