Chess 66

Create an Overworld Spear, a Nether Spear, and an End Spear for me, each with unique advantages. They should be combinable at a crafting table—using an Ender Dragon Egg, a Nether Star, and Beacons—to forge a "Dimension Spear." All of these items must be indestructible (Unbreaking). The Dimension Spear should come with Level 10 enchantments and an overpowered (OP) ability; also, please apply enchantments to the individual spears as well.

Kodari AI
KodariSep 28 at 11:00 am 1
DimensionSpearForge
Adds three craftable, indestructible spears—Overworld, Nether, and End—each with unique elemental advantages and custom enchantments. Players combine the three spears with an Ender Dragon Egg, a Nether Star, and Beacons at a crafting table to forge the legendary Dimension Spear. The Dimension Spear features Level 10 enchantments, an overpowered special ability, and full Unbreaking, making it a powerful end-game weapon.
  1. Create the Paper plugin project and register crafting recipes for all four spears.

  2. Add Unbreaking, tier-specific enchantments, and unique right-click abilities.

  3. Gate the Dimension Spear recipe on the three exact custom spears plus an egg, star, and four beacons.

Created the DimensionSpears Paper plugin. It adds crafting recipes for the Overworld, Nether, and End Spears, plus a Dimension Spear recipe requiring those three specific spears, an Ender Dragon Egg, a Nether Star, and four Beacons.

All four spears are unbreakable and have Unbreaking X. The Dimension Spear has level-10 enchantments and a powerful area ability; each individual spear also has its own enchantments and right-click ability.

Chess 66

okay how i test it

Kodari AI
KodariSep 28 at 11:05 am 1
  1. Build the plugin with JDK 21 and Gradle from the project folder:

    Shell
    gradle clean build
    

    There’s no Gradle wrapper in the project. The JAR should be build/libs/DimensionSpears-1.0.0.jar.

  2. Copy that JAR into a Paper 1.21.4 test server’s plugins folder, start the server, and check the console for a successful plugin load.

  3. Craft the spears at a crafting table:

    • Overworld: D / S / S — D = Diamond, S = Stick

    • Nether: B / NMS / S — B = Blaze Rod, N = Netherite Ingot, M = Magma Cream, S = Stick

    • End: E / DSD / S — E = Ender Pearl, D = Diamond, S = Stick

  4. Test the Dimension Spear recipe using this exact layout:

    Plain Text
    B E B
    O N T
    B S B
    

    B = Beacon, E = Ender Dragon Egg, O/N/T = the Overworld/Nether/End custom spears, S = Nether Star. The three spears must be in those exact middle-row positions; regular tridents won’t work.

  5. Hold each spear and right-click to test its ability. The individual spears have a 20-second cooldown; the Dimension Spear has a 60-second cooldown. All spears should be unbreakable and have Unbreaking X.

There are no test or give commands added—the items are obtained through their crafting recipes.

Chess 66

can you speak indonesian??

Kodari AI
KodariSep 28 at 11:09 am 1

Ya, saya bisa berbahasa Indonesia. Saya juga bisa menjelaskan cara menguji plugin tadi dalam bahasa Indonesia kalau kamu mau.

Chess 66

aku ga ngerti cara kerja nya kamu bisa jelasin dari awak

Kodari AI
KodariSep 28 at 11:10 am 1

Bisa. Anggap kamu mau mencoba plugin ini di server sendiri. Ikuti dari awal:

1. Siapkan Java

Install JDK 21, lalu buka Command Prompt atau PowerShell dan cek:

Shell
java -version

Pastikan versinya 21.

2. Buat file plugin .jar

Buka terminal di folder proyek—folder yang berisi build.gradle—lalu jalankan:

Shell
gradle clean build

Setelah selesai, file plugin akan ada di folder build/libs/. Nama file .jar bisa berbeda; yang penting salin file JAR dari folder itu.

Kalau muncul pesan gradle is not recognized, berarti Gradle belum terpasang. Kamu perlu memasang Gradle, atau membuka proyek lewat IntelliJ IDEA dengan Gradle terpasang.

3. Siapkan server uji Paper

  1. Unduh server Paper 1.21.4 dari papermc.io/downloads/paper.

  2. Buat folder khusus untuk server, lalu masukkan file Paper .jar ke situ.

  3. Jalankan server sekali:

    Shell
    java -jar paper.jar --nogui
    

    Kalau nama file Paper berbeda, ganti paper.jar dengan nama file yang benar.

  4. Buka eula.txt, ubah eula=false menjadi eula=true, simpan, lalu jalankan server lagi dengan perintah yang sama.

  5. Salin JAR plugin dari build/libs/ ke folder plugins di folder server. Kalau folder plugins belum ada, jalankan server sekali lagi setelah menerima EULA.

  6. Restart server. Cek konsol atau jalankan /plugins; plugin harus muncul sebagai aktif.

4. Buat tiga spear pertama

Di dalam game, gunakan crafting table. . berarti slot kosong:

Overworld Spear

Plain Text
. D .
. S .
. S .

D = Diamond, S = Stick.

Nether Spear

Plain Text
. B .
N M S
. S .

B = Blaze Rod, N = Netherite Ingot, M = Magma Cream, S = Stick.

End Spear

Plain Text
. E .
D S D
. S .

E = Ender Pearl, D = Diamond, S = Stick.

5. Buat Dimension Spear

Susun bahan ini di crafting table:

Plain Text
B E B
O N T
B S B
  • B = Beacon — perlu 4

  • E = Ender Dragon Egg

  • O = Overworld Spear buatan plugin

  • N = Nether Spear buatan plugin

  • T = End Spear buatan plugin

  • S = Nether Star

Pakai spear hasil plugin, bukan Trident biasa. Ketiga spear harus berada di posisi yang ditunjukkan.

6. Uji efeknya

Pegang spear lalu klik kanan untuk memakai kemampuannya. Coba tiap spear dan Dimension Spear secara terpisah. Enchantment dan kemampuan masing-masing berbeda; itemnya juga dibuat tidak bisa rusak. Untuk pengujian, sebaiknya gunakan server uji, bukan server utama.

Plugin ini tidak menyediakan command khusus untuk memberikan item—kamu mendapatkannya lewat resep crafting di atas.

Chess 66

server singleplayer ga bisa??

Kodari AI
KodariSep 28 at 11:10 am 1

Bisa main sendirian, tapi plugin tidak bisa dipasang langsung di Singleplayer biasa. Plugin ini perlu server Paper. Servernya bisa dijalankan di komputer yang sama, lalu kamu masuk sendirian.

Singkatnya:

  1. Jalankan server Paper di komputer.

  2. Masukkan file plugin .jar ke folder plugins server.

  3. Jalankan server, lalu buka Minecraft Java Edition dengan versi yang cocok.

  4. Pilih Multiplayer → Direct Connection, masukkan localhost.

Jadi tetap bisa dimainkan sendiri—hanya cara menjalankannya lewat server lokal, bukan tombol Singleplayer biasa. Minecraft Bedrock tidak bisa menjalankan plugin Paper.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 287
src/main/java/com/kodari/dimensionspears/DimensionSpearsPlugin.java
package com.kodari.dimensionspears;

import com.cryptomorin.xseries.XEnchantment;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

public final class DimensionSpearsPlugin extends JavaPlugin implements Listener {
    private static final String OVERWORLD = "overworld";
    private static final String NETHER = "nether";
    private static final String END = "end";
    private static final String DIMENSION = "dimension";

    private NamespacedKey spearTypeKey;
    private NamespacedKey dimensionRecipeKey;
    private final Map<String, Long> cooldowns = new HashMap<>();

    @Override
    public void onEnable() {
        spearTypeKey = new NamespacedKey(this, "spear_type");
        dimensionRecipeKey = new NamespacedKey(this, "dimension_spear");
        Bukkit.getPluginManager().registerEvents(this, this);
        registerRecipes();
    }

    private void registerRecipes() {
        addRecipe("overworld_spear", createSpear(OVERWORLD), new String[]{"  D", " S ", " S "},
                'D', "DIAMOND", 'S', "STICK");
        addRecipe("nether_spear", createSpear(NETHER), new String[]{" B ", "NMS", " S "},
                'B', "BLAZE_ROD", 'N', "NETHERITE_INGOT", 'M', "MAGMA_CREAM", 'S', "STICK");
        addRecipe("end_spear", createSpear(END), new String[]{" E ", "DSD", " S "},
                'E', "ENDER_PEARL", 'D', "DIAMOND", 'S', "STICK");

        ShapedRecipe dimensionRecipe = new ShapedRecipe(dimensionRecipeKey, createSpear(DIMENSION));
        dimensionRecipe.shape("BEB", "ONT", "BSB");
        dimensionRecipe.setIngredient('B', material("BEACON"));
        dimensionRecipe.setIngredient('E', material("DRAGON_EGG"));
        dimensionRecipe.setIngredient('O', material("TRIDENT"));
        dimensionRecipe.setIngredient('N', material("TRIDENT"));
        dimensionRecipe.setIngredient('T', material("TRIDENT"));
        dimensionRecipe.setIngredient('S', material("NETHER_STAR"));
        Bukkit.addRecipe(dimensionRecipe);
    }

    private void addRecipe(String key, ItemStack result, String[] shape, Object... ingredients) {
        ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, key), result);
        recipe.shape(shape);
        for (int index = 0; index < ingredients.length; index += 2) {
            recipe.setIngredient((Character) ingredients[index], material((String) ingredients[index + 1]));
        }
        Bukkit.addRecipe(recipe);
    }

    private ItemStack createSpear(String type) {
        ItemStack item = new ItemStack(material("TRIDENT"));
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(displayName(type));
        meta.setLore(Arrays.asList(lore(type)));
        meta.setUnbreakable(true);
        meta.getPersistentDataContainer().set(spearTypeKey, PersistentDataType.STRING, type);

        switch (type) {
            case OVERWORLD -> {
                addEnchantment(meta, "SHARPNESS", 5);
                addEnchantment(meta, "LOOTING", 3);
                addEnchantment(meta, "UNBREAKING", 10);
            }
            case NETHER -> {
                addEnchantment(meta, "SHARPNESS", 6);
                addEnchantment(meta, "FIRE_ASPECT", 3);
                addEnchantment(meta, "UNBREAKING", 10);
            }
            case END -> {
                addEnchantment(meta, "SHARPNESS", 6);
                addEnchantment(meta, "KNOCKBACK", 3);
                addEnchantment(meta, "UNBREAKING", 10);
            }
            case DIMENSION -> {
                addEnchantment(meta, "SHARPNESS", 10);
                addEnchantment(meta, "FIRE_ASPECT", 10);
                addEnchantment(meta, "LOOTING", 10);
                addEnchantment(meta, "KNOCKBACK", 10);
                addEnchantment(meta, "MENDING", 10);
                addEnchantment(meta, "UNBREAKING", 10);
            }
            default -> throw new IllegalArgumentException("Unknown spear type: " + type);
        }

        item.setItemMeta(meta);
        return item;
    }

    private String displayName(String type) {
        return switch (type) {
            case OVERWORLD -> ChatColor.GREEN + "Overworld Spear";
            case NETHER -> ChatColor.RED + "Nether Spear";
            case END -> ChatColor.LIGHT_PURPLE + "End Spear";
            case DIMENSION -> ChatColor.GOLD + "Dimension Spear";
            default -> type;
        };
    }

    private String[] lore(String type) {
        return switch (type) {
            case OVERWORLD -> new String[]{ChatColor.GRAY + "Right-click: regeneration and absorption"};
            case NETHER -> new String[]{ChatColor.GRAY + "Right-click: ignite and blast nearby enemies"};
            case END -> new String[]{ChatColor.GRAY + "Right-click: swift movement and lift nearby enemies"};
            case DIMENSION -> new String[]{ChatColor.GOLD + "Right-click: unleash a devastating dimensional pulse"};
            default -> new String[0];
        };
    }

    private void addEnchantment(ItemMeta meta, String name, int level) {
        XEnchantment.matchXEnchantment(name).ifPresent(enchantment ->
                meta.addEnchant(enchantment.getEnchant(), level, true));
    }

    private Material material(String name) {
        return XMaterial.matchXMaterial(name)
                .map(XMaterial::parseMaterial)
                .orElseThrow(() -> new IllegalStateException("Required material is unavailable: " + name));
    }

    @EventHandler
    public void onPrepareCraft(PrepareItemCraftEvent event) {
        if (!(event.getRecipe() instanceof Keyed keyed) || !keyed.getKey().equals(dimensionRecipeKey)) {
            return;
        }

        ItemStack[] matrix = event.getInventory().getMatrix();
        if (matrix.length != 9
                || !hasType(matrix[3], OVERWORLD)
                || !hasType(matrix[4], NETHER)
                || !hasType(matrix[5], END)) {
            event.getInventory().setResult(null);
        }
    }

    private boolean hasType(ItemStack item, String type) {
        if (item == null || !item.hasItemMeta()) {
            return false;
        }
        return type.equals(item.getItemMeta().getPersistentDataContainer()
                .get(spearTypeKey, PersistentDataType.STRING));
    }

    @EventHandler
    public void onSpearUse(PlayerInteractEvent event) {
        if (event.getHand() == null || event.getHand().name().equals("OFF_HAND")
                || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)) {
            return;
        }

        ItemStack item = event.getItem();
        if (item == null || !item.hasItemMeta()) {
            return;
        }
        String type = item.getItemMeta().getPersistentDataContainer()
                .get(spearTypeKey, PersistentDataType.STRING);
        if (type == null) {
            return;
        }

        Player player = event.getPlayer();
        long now = System.currentTimeMillis();
        String cooldownKey = player.getUniqueId() + ":" + type;
        long remaining = cooldowns.getOrDefault(cooldownKey, 0L) - now;
        if (remaining > 0) {
            player.sendMessage(ChatColor.RED + "Ability ready in " + (remaining + 999) / 1000 + "s.");
            return;
        }

        long cooldownMillis = type.equals(DIMENSION) ? 60_000L : 20_000L;
        cooldowns.put(cooldownKey, now + cooldownMillis);
        useAbility(player, type);