kingofthehomos

Can you create a minecraft java plugin for 1.21.11 which i can download and import to my minecraft server. The plugin is going to be, you get 3 classes when you join, Alchemist, Wizard and Sorcerer. The alchemist class will allow anyone with the class to shift and right click, generating a Zombie with strength 1 with 20 hearts to spawn, which wont attack you, or any player you /trust, it should have a 3 minute cooldown. The wizard class makes it so every 3 critical attacks you do, you gain haste 1 for 5 seconds, No cooldown. The Sorcerer class gives you Dolphins Grace when you shift and right click for 30 seconds with a 2 minute cooldown, and also throws your enemy 10 blocks in the air when u crit them 5 times. You should be able to change these using a Trader with a recipe of 4 omnious keys in the corners, 4 netherite ingots in the remaining space, and a heart of the sea in the middle.

Kodari AI
KodariOct 2 at 9:24 pm 1
ClassCraft
ClassCraft is a Bukkit plugin that assigns players one of three classes upon joining: Alchemist, Wizard, or Sorcerer. Alchemists shift-right-click to spawn a loyal Strength-boosted Zombie with a 3-minute cooldown. Wizards gain Haste after every three critical hits. Sorcerers gain Dolphins Grace on shift-right-click and launch enemies skyward after five critical hits. Classes are changed via a Trader GUI requiring four ominous keys, four netherite ingots, and a heart of the sea.
  1. Add the Paper 1.21.11 plugin project and first-join class selection.

  2. Implement the Alchemist, Wizard, and Sorcerer abilities, cooldowns, and trust protection.

  3. Add the class-change trader and the exact 3×3 crafting recipe for its change token.

Created the Gradle plugin project for Paper 1.21.11. Build the JAR with gradle build; the output will be build/libs/ThreeClasses-1.0.0.jar. Place it in your server’s plugins folder.

Players choose a class on their first join. Use /class to open the class menu, /class trust <player> or /class untrust <player> to manage companion protection, and /class trader to spawn a Class Trader (operators by default). The change token recipe uses four Ominous Trial Keys in the corners, four Netherite Ingots on the sides, and a Heart of the Sea in the center; take the token to the Trader to change classes.

The abilities, cooldowns, persistent class selection, and friendly zombie protection are implemented.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
6 499
src/main/java/com/kodari/classes/ClassPlugin.java
package com.kodari.classes;

import com.cryptomorin.xseries.XAttribute;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.util.Vector;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public final class ClassPlugin extends org.bukkit.plugin.java.JavaPlugin implements Listener, CommandExecutor {
    private static final long ALCHEMIST_COOLDOWN_MILLIS = 3 * 60 * 1000L;
    private static final long SORCERER_COOLDOWN_MILLIS = 2 * 60 * 1000L;
    private static final int EFFECT_DURATION_TICKS = 20 * 30;

    private NamespacedKey playerClassKey;
    private NamespacedKey alchemistCooldownKey;
    private NamespacedKey sorcererCooldownKey;
    private NamespacedKey minionOwnerKey;
    private NamespacedKey traderKey;
    private NamespacedKey changeTokenKey;
    private NamespacedKey recipeKey;
    private final Map<UUID, Integer> wizardCriticals = new HashMap<>();
    private final Map<UUID, Map<UUID, Integer>> sorcererCriticals = new HashMap<>();

    @Override
    public void onEnable() {
        playerClassKey = new NamespacedKey(this, "player_class");
        alchemistCooldownKey = new NamespacedKey(this, "alchemist_cooldown");
        sorcererCooldownKey = new NamespacedKey(this, "sorcerer_cooldown");
        minionOwnerKey = new NamespacedKey(this, "minion_owner");
        traderKey = new NamespacedKey(this, "class_trader");
        changeTokenKey = new NamespacedKey(this, "class_change_token");
        recipeKey = new NamespacedKey(this, "class_change_recipe");

        getServer().getPluginManager().registerEvents(this, this);
        getCommand("class").setExecutor(this);
        registerChangeTokenRecipe();
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        if (getPlayerClass(player) == null) {
            Bukkit.getScheduler().runTaskLater(this, () -> {
                if (player.isOnline() && getPlayerClass(player) == null) {
                    openClassMenu(player);
                    player.sendMessage(color("&eChoose your class to get started."));
                }
            }, 20L);
        } else {
            player.sendMessage(color("&eYour class: &b" + getPlayerClass(player).getDisplayName() + "&e. Use /class to view classes."));
        }
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND || !event.getPlayer().isSneaking()) {
            return;
        }
        if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) {
            return;
        }

        Player player = event.getPlayer();
        PlayerClass playerClass = getPlayerClass(player);
        if (playerClass == PlayerClass.ALCHEMIST) {
            event.setCancelled(true);
            summonCompanion(player);
        } else if (playerClass == PlayerClass.SORCERER) {
            event.setCancelled(true);
            grantDolphinsGrace(player);
        }
    }

    @EventHandler
    public void onCriticalAttack(EntityDamageByEntityEvent event) {
        if (!(event.getDamager() instanceof Player player) || !isCriticalAttack(player)) {
            return;
        }

        PlayerClass playerClass = getPlayerClass(player);
        if (playerClass == PlayerClass.WIZARD) {
            int criticals = wizardCriticals.merge(player.getUniqueId(), 1, Integer::sum);
            if (criticals >= 3) {
                wizardCriticals.remove(player.getUniqueId());
                XPotion.matchXPotion("HASTE").ifPresent(potion -> player.addPotionEffect(potion.buildPotionEffect(100, 0)));
                player.sendMessage(color("&bYour critical strikes grant you Haste I for 5 seconds."));
            }
        } else if (playerClass == PlayerClass.SORCERER && event.getEntity() instanceof Player target) {
            Map<UUID, Integer> targetCounts = sorcererCriticals.computeIfAbsent(player.getUniqueId(), ignored -> new HashMap<>());
            int criticals = targetCounts.merge(target.getUniqueId(), 1, Integer::sum);
            if (criticals >= 5) {
                targetCounts.remove(target.getUniqueId());
                target.setVelocity(new Vector(target.getVelocity().getX(), 1.25, target.getVelocity().getZ()));
                player.sendMessage(color("&5Your fifth critical hit launched " + target.getName() + " into the air."));
            }
        }
    }

    @EventHandler
    public void onMinionTarget(EntityTargetLivingEntityEvent event) {
        if (!(event.getEntity() instanceof Zombie zombie) || !(event.getTarget() instanceof Player target)) {
            return;
        }
        String ownerValue = zombie.getPersistentDataContainer().get(minionOwnerKey, PersistentDataType.STRING);
        if (ownerValue == null) {
            return;
        }
        UUID ownerId;
        try {
            ownerId = UUID.fromString(ownerValue);
        } catch (IllegalArgumentException exception) {
            return;
        }
        if (target.getUniqueId().equals(ownerId) || isTrusted(ownerId, target.getUniqueId())) {
            event.setCancelled(true);
            if (zombie.getTarget() == target) {
                zombie.setTarget(null);
            }
        }
    }

    @EventHandler
    public void onTraderInteract(PlayerInteractEntityEvent event) {
        PersistentDataContainer data = event.getRightClicked().getPersistentDataContainer();
        if (data.get(traderKey, PersistentDataType.BYTE) == null) {
            return;
        }
        event.setCancelled(true);
        openClassMenu(event.getPlayer());
    }

    @EventHandler
    public void onMenuClick(InventoryClickEvent event) {
        if (!(event.getView().getTopInventory().getHolder() instanceof ClassMenuHolder)) {
            return;
        }
        event.setCancelled(true);
        if (!(event.getWhoClicked() instanceof Player player) || event.getClickedInventory() != event.getView().getTopInventory()) {
            return;
        }
        PlayerClass selected = switch (event.getSlot()) {
            case 11 -> PlayerClass.ALCHEMIST;
            case 13 -> PlayerClass.WIZARD;
            case 15 -> PlayerClass.SORCERER;
            default -> null;
        };
        if (selected != null) {
            chooseClass(player, selected);
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 0) {
            if (sender instanceof Player player) {
                openClassMenu(player);
            } else {
                sender.sendMessage("Usage: /class trust|untrust <player> or /class trader");
            }
            return true;
        }

        String subcommand = args[0].toLowerCase();
        if ((subcommand.equals("trust") || subcommand.equals("untrust")) && args.length == 2) {
            if (!(sender instanceof Player player)) {
                sender.sendMessage("Only players can manage their trusted players.");
                return true;