bummbuno

Develop a Star Wars-themed addon for Minecraft Java that introduces multiple lightsabers and iconic Star Wars guns, each with unique abilities and effects. Implement custom crafting recipes utilizing a new ore called "Cyber-Crystal," which can be mined to obtain crystals that determine the color of the lightsaber's beam. Additionally, ensure that players can combine and upgrade weapons using these ores to enhance their combat experience.

Kodari AI
KodariSep 17 at 5:09 pm 2
StarWarsArmory
A Star Wars-themed Minecraft plugin introducing multiple lightsabers and iconic blaster guns, each with unique abilities and effects. Adds a new mineable ore called Cyber-Crystal that drops colored crystals determining lightsaber beam color. Implements custom crafting recipes for all weapons, plus a combination and upgrade system allowing players to enhance weapons using additional crystals and ores for improved combat performance.
  1. Core addon: create the Paper plugin, custom item identity, abilities, combat effects, and upgrade handling.

  2. Content: add Cyber-Crystal drops, crafting recipes, weapon recipes, and /starwars give.

  3. Packaging: add Gradle metadata, plugin descriptor, and configurable drop/upgrade settings.

Built the Star Wars addon from scratch with:

  • Blue, green, and red lightsabers with Force Push abilities and unique effects.

  • DL-44, E-11, and Westar-35 blasters using projectile-based attacks.

  • Cyber-Crystal items obtained from diamond ore mining.

  • Custom recipes for Cyber-Crystals and all weapons.

  • Anvil-based weapon upgrades up to configurable levels.

  • /starwars give <item> command with tab completion.

  • Configurable drop rates, upgrade limits, and blaster cooldowns.

  • Complete Gradle setup and Paper plugin metadata.

bummbuno

how can i play it now

Kodari AI
KodariSep 17 at 5:16 pm 1
  1. Install Java 21 and a Paper 1.21.4 server.

  2. Build the plugin from the project root:

Shell
gradle build

The plugin JAR will be created at:

Plain Text
build/libs/star-wars-addon-1.0.0.jar
  1. Copy that JAR into your server’s:

Plain Text
plugins/
  1. Start the server:

Shell
java -Xms2G -Xmx4G -jar paper-1.21.4-*.jar --nogui
  1. Join the server, become an operator, and reload/restart the server:

Plain Text
/op YourMinecraftName
  1. Get weapons for testing:

Plain Text
/starwars give blue_saber
/starwars give green_saber
/starwars give red_saber
/starwars give dl44
/starwars give e11
/starwars give westar
/starwars give crystal

Controls

  • Lightsabers

    • Left-click: melee attack

    • Right-click: Force Push

    • Green saber applies slowness

    • Red saber ignites targets

  • Blasters

    • Right-click: fire a projectile

    • DL-44 ignites targets

    • Westar-35 slows targets

    • E-11 fires a rapid bolt

  • Cyber-Crystals

    • Mine diamond ore or deepslate diamond ore.

    • The default drop chance is 25%.

    • Combine a weapon and a Cyber-Crystal in an anvil to upgrade it.

    • Upgrades cost experience and go up to level 5.

One current limitation: the implementation does not yet generate a separate underground Cyber-Crystal ore block. Cyber-Crystals currently drop from diamond ore. Also, the weapon recipes require color-specific crystals, while the command and mining currently provide a generic “prismatic” crystal, so use the /starwars give commands to play with the weapons immediately.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 487
src/main/java/com/kodari/starwars/StarWarsAddon.java
package com.kodari.starwars;

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

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.attribute.Attribute;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.inventory.PrepareAnvilEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import org.bukkit.plugin.java.JavaPlugin;

public final class StarWarsAddon extends JavaPlugin implements Listener, CommandExecutor, TabCompleter {
    private static final String PREFIX = "&8[&bStar Wars&8] &f";
    private static final String CRYSTAL_ID = "cyber_crystal";

    private final Map<UUID, Long> gunCooldowns = new HashMap<>();
    private NamespacedKey itemKey;
    private NamespacedKey weaponKey;
    private NamespacedKey levelKey;
    private NamespacedKey colorKey;
    private NamespacedKey projectileKey;
    private double crystalDropChance;
    private int minimumCrystalDrop;
    private int maximumCrystalDrop;
    private int maximumUpgrade;
    private int gunCooldownTicks;

    @Override
    public void onEnable() {
        itemKey = new NamespacedKey(this, "item");
        weaponKey = new NamespacedKey(this, "weapon");
        levelKey = new NamespacedKey(this, "upgrade_level");
        colorKey = new NamespacedKey(this, "crystal_color");
        projectileKey = new NamespacedKey(this, "projectile_weapon");

        saveDefaultConfig();
        crystalDropChance = getConfig().getDouble("cyber-crystal.mining-drop-chance", 0.25D);
        minimumCrystalDrop = getConfig().getInt("cyber-crystal.minimum-drop", 1);
        maximumCrystalDrop = getConfig().getInt("cyber-crystal.maximum-drop", 2);
        maximumUpgrade = getConfig().getInt("weapons.maximum-upgrade", 5);
        gunCooldownTicks = getConfig().getInt("weapons.gun-cooldown-ticks", 10);

        getServer().getPluginManager().registerEvents(this, this);
        getCommand("starwars").setExecutor(this);
        getCommand("starwars").setTabCompleter(this);
        registerRecipes();
    }

    @Override
    public void onDisable() {
        gunCooldowns.clear();
    }

    private void registerRecipes() {
        Material quartz = material("QUARTZ");
        Material ironNugget = material("IRON_NUGGET");
        Material amethyst = material("AMETHYST_SHARD");
        Material diamond = material("DIAMOND");
        Material iron = material("IRON_INGOT");
        Material redstone = material("REDSTONE");
        Material stick = material("STICK");

        ShapedRecipe crystalRecipe = new ShapedRecipe(new NamespacedKey(this, CRYSTAL_ID), createCyberCrystal());
        crystalRecipe.shape("QQQ", "QIQ", "QQQ");
        crystalRecipe.setIngredient('Q', exact(quartz));
        crystalRecipe.setIngredient('I', exact(ironNugget));
        getServer().addRecipe(crystalRecipe);

        for (WeaponType type : WeaponType.values()) {
            ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, type.id), createWeapon(type, 0));
            if (type.isLightsaber) {
                recipe.shape(" C ", " D ", " I ");
                recipe.setIngredient('C', new RecipeChoice.ExactChoice(createCyberCrystal(type.crystalColor)));
                recipe.setIngredient('D', exact(diamond));
                recipe.setIngredient('I', exact(iron));
            } else if (type == WeaponType.DL44) {
                recipe.shape("IRC", " II", " SI");
                recipe.setIngredient('I', exact(iron));
                recipe.setIngredient('R', exact(redstone));
                recipe.setIngredient('C', new RecipeChoice.ExactChoice(createCyberCrystal("amber")));
                recipe.setIngredient('S', exact(stick));
            } else if (type == WeaponType.E11) {
                recipe.shape(" II", "IRC", " SI");
                recipe.setIngredient('I', exact(iron));
                recipe.setIngredient('R', exact(redstone));
                recipe.setIngredient('C', new RecipeChoice.ExactChoice(createCyberCrystal("blue")));
                recipe.setIngredient('S', exact(stick));
            } else {
                recipe.shape(" II", "ICR", " SI");
                recipe.setIngredient('I', exact(iron));
                recipe.setIngredient('R', exact(redstone));
                recipe.setIngredient('C', new RecipeChoice.ExactChoice(createCyberCrystal("green")));
                recipe.setIngredient('S', exact(stick));
            }
            getServer().addRecipe(recipe);
        }
    }

    private RecipeChoice.ExactChoice exact(Material material) {
        return new RecipeChoice.ExactChoice(new ItemStack(material));
    }

    @EventHandler
    public void onCyberCrystalOreBreak(BlockBreakEvent event) {
        String blockType = event.getBlock().getType().name();
        if (!blockType.equals("DIAMOND_ORE") && !blockType.equals("DEEPSLATE_DIAMOND_ORE")) {
            return;
        }
        if (Math.random() > crystalDropChance) {
            return;
        }
        int amount = minimumCrystalDrop;
        if (maximumCrystalDrop > minimumCrystalDrop) {
            amount += (int) (Math.random() * (maximumCrystalDrop - minimumCrystalDrop + 1));
        }
        ItemStack drop = createCyberCrystal();
        drop.setAmount(amount);
        event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), drop);
    }

    @EventHandler
    public void onWeaponUse(PlayerInteractEvent event) {
        if (event.getItem() == null || !isWeapon(event.getItem())) {
            return;
        }
        if (!event.getAction().name().startsWith("RIGHT_CLICK")) {
            return;
        }

        WeaponType type = getWeaponType(event.getItem());
        if (type == null) {
            return;
        }
        event.setCancelled(true);
        if (type.isLightsaber) {
            useForcePush(event.getPlayer(), type);
        } else {
            fireBlaster(event.getPlayer(), type);
        }
    }

    private void useForcePush(Player player, WeaponType type) {
        World world = player.getWorld();
        for (Entity entity : player.getNearbyEntities(7.0D, 4.0D, 7.0D)) {
            if (!(entity instanceof LivingEntity target) || entity.equals(player)) {
                continue;
            }
            Vector push = target.getLocation().toVector().subtract(player.getLocation().toVector());
            if (push.lengthSquared() == 0.0D) {
                continue;
            }
            target.setVelocity(push.normalize().multiply(1.35D).setY(0.6D));
            target.damage(2.0D, player);
            if (type == WeaponType.RED_SABER) {
                target.setFireTicks(80);
            }
        }
        player.sendMessage(color(PREFIX + type.displayName + " &7Force Push unleashed."));
        world.playSound(player.getLocation(), "entity.generic.explode", 0.45F, 1.8F);
    }

    private void fireBlaster(Player player, WeaponType type) {
        long now = System.currentTimeMillis();
        long cooldown = gunCooldownTicks * 50L;
        Long lastShot = gunCooldowns.get(player.getUniqueId());
        if (lastShot != null && now - lastShot < cooldown) {
            return;
        }
        gunCooldowns.put(player.getUniqueId(), now);
        Snowball projectile = player.launchProjectile(Snowball.class);
        PersistentDataContainer data = projectile.getPersistentDataContainer();