S

ทุกครั้งที่เข้าเกม จะได้รับสมุด knowledge_book คลิ๊กขวาเพื่อใช้คำสั่ง ไอเทมนี้ไม่สามารถโยนทิ้ง หรือ ใส่กล่องได้ แยกสมุดกันระหว่าง java กับ bedrock

Kodari AI
KodariMay 22 at 8:42 am 6,077 (v2)

I’ll create a plugin that gives players a special knowledge book on join, with different commands for Java and Bedrock players.

StarterBook
Automatically gives players a special knowledge book when they join the server. Right-clicking the book executes configurable commands, with separate commands for Java and Bedrock players. The book is protected from being dropped or placed in containers, ensuring players always have access to essential server commands. Includes Floodgate integration for automatic Bedrock player detection.

Now I’ll create the plugin structure:

S

The compilation failed with this error:

code
Compilation failed with 8 error(s):

ERROR in src/main/java/com/starterbook/listeners/InventoryListener.java at line 42: class, interface, enum, or record expected
Project created! Here's what I've built:
^

ERROR in src/main/java/com/starterbook/listeners/InventoryListener.java at line 42: unclosed character literal
Project created! Here's what I've built:
                     ^

ERROR in src/main/java/com/starterbook/listeners/InventoryListener.java at line 42: unclosed character literal
Project created! Here's what I've built:
                              ^

ERROR in src/main/java/com/starterbook/listeners/InventoryListener.java at line 49: illegal character: '`'
- **Reload command**: `/starterbook reload` to refresh config
                      ^

ERROR in src/main/java/com/starterbook/listeners/InventoryListener.java at line 49: illegal character: '`'
- **Reload command**: `/starterbook reload` to refresh config
                                          ^

ERROR in src/main/java/com/starterbook/listeners/InventoryListener.java at line 52: '{' expected
- Main plugin class with listener registration
                        ^

ERROR in src/main/java/com/starterbook/listeners/InventoryListener.java at line 60: illegal character: '`'
Edit `config.yml` to set commands for Java and Bedrock players. The book is marked with NBT data and checked using PersistentDataContainer for reliable identification.
     ^

ERROR in src/main/java/com/starterbook/listeners/InventoryListener.java at line 60: illegal character: '`'
Edit `config.yml` to set commands for Java and Bedrock players. The book is marked with NBT data and checked using PersistentDataContainer for reliable identification.
                ^


=== COMPILATION ERROR ANALYSIS ===

SYNTAX ERRORS:
  - Line 42: class, interface, enum, or record expected
  - Line 52: '{' expected
ACTION: Check for missing semicolons or brackets

FILES TO INVESTIGATE:
  - src/main/java/com/starterbook/listeners/InventoryListener.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariMay 22 at 8:43 am 10,369 (v2)

I’ll read the problematic file and fix the compilation error:

I see the issue - there’s explanatory text accidentally included in the Java file. I’ll fix it:

All files have been created successfully! The plugin is now complete with:

Core Features:

  • ✅ Auto-gives knowledge book on every join

  • ✅ Separate books for Java and Bedrock players (detected via Floodgate)

  • ✅ Right-click executes configurable commands

  • ✅ Cannot be dropped (cancels PlayerDropItemEvent)

  • ✅ Cannot be placed in containers (cancels InventoryClickEvent when moving to non-player inventory)

  • ✅ Uses PersistentDataContainer for reliable book identification

  • ✅ Reload command: /starterbook reload

Configuration: Edit config.yml to customize commands for Java and Bedrock players. The give-if-missing option controls whether to check if the player already has the book before giving a new one.

S

เพิ่ม config ชื่อ lore ของสมุด เป็นภาษาไทย

Kodari AI
KodariMay 22 at 8:54 am 8,218 (v2)

ฉันจะอ่านไฟล์ที่เกี่ยวข้องก่อนเพื่อเพิ่ม config lore ภาษาไทย

ตอนนี้ฉันจะเพิ่ม config lore ภาษาไทยและอัปเดตให้ใช้จาก config

เสร็จแล้ว! ฉันได้เพิ่ม config lore ภาษาไทยให้แล้ว:

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

  1. config.yml - เพิ่ม lore แยกสำหรับ Java และ Bedrock:

    • java-book.lore และ bedrock-book.lore

    • ข้อความภาษาไทย: “คลิกขวาเพื่อเปิดเมนู” และ “สมุดนี้ไม่สามารถโยนหรือเก็บได้”

  2. ConfigManager - เพิ่ม methods getJavaLore() และ getBedrockLore()

  3. BookUtil - อัปเดตให้ดึง lore จาก config และแปลง color codes (&7 → §7) อัตโนมัติ

การใช้งาน: คุณสามารถแก้ไข lore ในไฟล์ config.yml ได้เลย รองรับ color codes แบบ & (เช่น &a, &7, &l)

S

เพิ่ม config ชื่อของไอเทม เป็นภาษาไทย

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
9 365
src/main/java/com/starterbook/StarterBook.java
package com.starterbook;

import com.starterbook.config.ConfigManager;
import com.starterbook.listeners.InteractListener;
import com.starterbook.listeners.InventoryListener;
import com.starterbook.listeners.JoinListener;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public class StarterBook extends JavaPlugin {

    private ConfigManager configManager;
    private NamespacedKey bookKey;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.bookKey = new NamespacedKey(this, "starter_book");
        
        getServer().getPluginManager().registerEvents(new JoinListener(this), this);
        getServer().getPluginManager().registerEvents(new InteractListener(this), this);
        getServer().getPluginManager().registerEvents(new InventoryListener(this), this);
        
        getLogger().info("StarterBook has been enabled!");
    }

    @Override
    public void onDisable() {
        getLogger().info("StarterBook has been disabled!");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("starterbook")) {
            if (args.length > 0 && args[0].equalsIgnoreCase("reload")) {
                if (!sender.hasPermission("starterbook.reload")) {
                    sender.sendMessage("§cYou don't have permission to use this command.");
                    return true;
                }
                
                reloadConfig();
                configManager = new ConfigManager(this);
                sender.sendMessage("§aStarterBook configuration reloaded!");
                return true;
            }
        }
        return false;
    }

    public ConfigManager getConfigManager() {
        return configManager;
    }

    public NamespacedKey getBookKey() {
        return bookKey;
    }
}