pingwinek0229

stwórz blecak skurzany żelazny dizmenkowy i netcherytowy kture działają jak blecak ale im lepsze tm większe. można je założyć na tors

Kodari AI
KodariOct 24 at 2:37 pm 1
ElytraTiers
Adds craftable leather, iron, diamond, and netherite elytra variants that function like the standard elytra but with progressively improved flight capabilities. Higher-tier elytra provide greater flight speed, longer glide duration, and enhanced durability. All tiers are equippable in the chest armor slot and maintain vanilla elytra mechanics while offering a natural progression system. Crafting recipes combine the base elytra with tier-appropriate materials, allowing players to upgrade their flight gear as they advance through the game.
  1. Utworzę konfigurację pluginu i komendę /plecak do zdobywania plecaków.

  2. Dodam cztery plecaki-zbroje o rosnącej pojemności, zakładane prawym przyciskiem.

  3. Dodam otwieranie noszonego plecaka oraz trwały zapis zawartości.

Gotowe. Dodałem plecaki skórzany, żelazny, diamentowy i netherytowy o pojemnościach odpowiednio 9, 18, 27 i 36 miejsc. Prawy przycisk zakłada plecak na tors, a kolejne kliknięcie prawym przyciskiem otwiera jego zawartość. Zawartość zapisuje się po zamknięciu i jest przypisana do konkretnego plecaka.

Plecaki można zdobyć komendą /plecak <skorzany|zelazny|diamentowy|netheriteowy>.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
8 483
src/main/java/com/kodari/backpacks/TorsoBackpacksPlugin.java
package com.kodari.backpacks;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Arrays;
import java.util.UUID;

public final class TorsoBackpacksPlugin extends JavaPlugin {
    private NamespacedKey typeKey;
    private NamespacedKey idKey;
    private BackpackStorage storage;

    @Override
    public void onEnable() {
        typeKey = new NamespacedKey(this, "backpack_type");
        idKey = new NamespacedKey(this, "backpack_id");
        storage = new BackpackStorage(this);
        getServer().getPluginManager().registerEvents(new BackpackListener(this), this);
        BackpackCommand command = new BackpackCommand(this);
        getCommand("plecak").setExecutor(command);
        getCommand("plecak").setTabCompleter(command);
    }

    @Override
    public void onDisable() {
        if (storage != null) {
            storage.saveActiveInventories();
        }
    }

    public BackpackStorage getStorage() {
        return storage;
    }

    public ItemStack createBackpack(BackpackType type) {
        ItemStack item = XMaterial.matchXMaterial(type.getMaterialName())
                .map(XMaterial::parseItem)
                .orElse(null);
        if (item == null) {
            return null;
        }

        ItemMeta meta = item.getItemMeta();
        if (meta == null) {
            return null;
        }
        meta.setDisplayName(ChatColor.GOLD + type.getDisplayName());
        meta.setLore(Arrays.asList(
                ChatColor.GRAY + "Pojemność: " + type.getSize() + " miejsc",
                ChatColor.YELLOW + "Kliknij prawym przyciskiem, aby założyć.",
                ChatColor.YELLOW + "Kliknij prawym przyciskiem, mając go na torsie, aby otworzyć."
        ));
        meta.getPersistentDataContainer().set(typeKey, PersistentDataType.STRING, type.name());
        meta.getPersistentDataContainer().set(idKey, PersistentDataType.STRING, UUID.randomUUID().toString());
        item.setItemMeta(meta);
        return item;
    }

    public BackpackType getBackpackType(ItemStack item) {
        if (item == null || !item.hasItemMeta()) {
            return null;
        }
        ItemMeta meta = item.getItemMeta();
        if (meta == null || getBackpackId(item) == null) {
            return null;
        }
        String name = meta.getPersistentDataContainer().get(typeKey, PersistentDataType.STRING);
        if (name == null) {
            return null;
        }
        try {
            return BackpackType.valueOf(name);
        } catch (IllegalArgumentException exception) {
            return null;
        }
    }

    public UUID getBackpackId(ItemStack item) {
        if (item == null || !item.hasItemMeta()) {
            return null;
        }
        ItemMeta meta = item.getItemMeta();
        if (meta == null) {
            return null;
        }
        String id = meta.getPersistentDataContainer().get(idKey, PersistentDataType.STRING);
        if (id == null) {
            return null;
        }
        try {
            return UUID.fromString(id);
        } catch (IllegalArgumentException exception) {
            return null;
        }
    }
}