DDDs

goblin warrior

Kodari AI
KodariOct 31 at 11:33 am 1
GoblinWarriorPlugin
A Minecraft plugin that adds a Goblin Warrior mob with custom AI, combat behavior, loot drops, and spawn mechanics. The plugin registers a custom entity type with configurable health, damage, speed, and armor values. Goblin Warriors spawn naturally in specified biomes and dimensions, attack players and villagers on sight, use melee combat with occasional special attacks, and drop unique loot including goblin weapons and armor. Includes configurable spawn rates, drop tables, and boss variants with enhanced stats.

I’ll create a Paper plugin that spawns a named goblin warrior with a sword and helmet using /goblinwarrior.

Created the GoblinWarrior plugin. Players with permission can use /goblinwarrior to summon an armed, named zombie goblin.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 82
src/main/java/com/kodari/goblinwarrior/GoblinWarriorPlugin.java
package com.kodari.goblinwarrior;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.plugin.java.JavaPlugin;

public final class GoblinWarriorPlugin extends JavaPlugin implements CommandExecutor {
    @Override
    public void onEnable() {
        getCommand("goblinwarrior").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("Only players can spawn a goblin warrior.");
            return true;
        }

        Zombie goblin = player.getWorld().spawn(player.getLocation().add(1, 0, 0), Zombie.class);
        goblin.setAdult();
        goblin.setCustomName(ChatColor.DARK_GREEN + "Goblin Warrior");
        goblin.setCustomNameVisible(true);
        goblin.setCanPickupItems(false);
        goblin.setRemoveWhenFarAway(false);

        EntityEquipment equipment = goblin.getEquipment();
        if (equipment != null) {
            XMaterial.matchXMaterial("IRON_SWORD")
                    .map(XMaterial::parseItem)
                    .ifPresent(equipment::setItemInMainHand);
            XMaterial.matchXMaterial("CHAINMAIL_HELMET")
                    .map(XMaterial::parseItem)
                    .ifPresent(equipment::setHelmet);
            equipment.setItemInMainHandDropChance(0.0F);
            equipment.setHelmetDropChance(0.0F);
        }

        player.sendMessage(ChatColor.GREEN + "A Goblin Warrior has been summoned!");
        return true;
    }
}