Vincent Nielsen
  1. Rift System Command: /rift spawn - Spawns a walk-through portal at the command user's location. - Walking into the portal teleports players to a randomly generated open area relatively close to the portal's original location. - The portal disappears after 30 minutes unless an admin breaks it first. - At the destination, create a red 3×3 circle with a countdown timer above it. - Players inside the circle receive individual colours. - Only one player can occupy the circle at a time. If nobody is inside or multiple players enter, the timer pauses. - When the timer reaches zero, the player inside receives one random custom weapon. Every weapon has an equal chance of being selected. - Rift weapons disappear 48 hours after being awarded. The entire server can see the countdown, the current player holding the circle and its coordinates. 2. Custom Weapons Create seven custom weapons, accessible through /rift weapons. 1. Lightning Bringer – Mace - Functions like a normal mace. - A falling attack that hits an enemy summons lightning and deals extra damage. - Enchantment caps: Density III, Breach III, Wind Burst II, Fire Aspect I. 2. Bone Sword – Netherite Sword - Gains +0.5 damage for every player killed with it. - Enchantments: Sharpness IV, Fire Aspect II, Looting III, Mending I, Unbreaking III. 3. Artemis' Bow - Shoots a Sonic Boom instead of a normal arrow. - Deals 7 hearts of damage and ignores absorption. - Has a 5-minute cooldown. - Gets maximum normal bow enchantments, except Power IV. 4. Lifestealer – Diamond Sword - Every player killed with this sword grants the user one permanent heart. 5. God's Crossbow - Fires 10 arrows simultaneously. - Takes 15 seconds to load. - Costs the user 3 hearts per use. - Has all maximum crossbow enchantments. 6. Life Medallion – Totem - When activated, restores the player's hearts. - Grants an additional row of hearts for 5 minutes. 7. Rift Cleaver - 15-minute cooldown. - Hitting an enemy summons lightning. - Deals 4 hearts of damage without ignoring absorption. - Deals 95 durability damage to each of the enemy's four armour pieces. - Enchantment caps: Protection IV, Sharpness IV, Fire Aspect I, Density III, Breach III, Wind Burst II, Lunge II. 3. Custom Crafting Recipes Cobweb: 5 String arranged in an X, with one in the centre and one in each corner. Golden Apple: 1 Apple in the centre, surrounded by 4 Gold Ingots directly above, below, left and right. The corners remain empty. Strength Medallion – Totem: - Grants permanent Strength I while held in the offhand. - Drinking a Strength I potion upgrades the effect to Strength II for the potion's duration. Custom Netherite Sword: - Diamond Sword in the top-middle slot. - Enchanted Golden Apple in the centre. - 7 Netherite Ingots in the remaining slots. - Maximum of 3 crafted swords existing at once. - Every successful crafting is announced in server chat. - The plugin tracks the swords. If one is destroyed, another can be crafted. Custom Netherite Armour: - Each piece requires its corresponding Diamond Armour piece, 2 Netherite Ingots and 1 Netherite Block. - Only one of each armour piece can exist at a time. - If a piece is destroyed, another can be crafted. Rift Cleaver Recipe: - Dragon Egg in the centre. - Netherite Sword in the top-middle. - Enchanted Golden Apples in both top corners. - Nether Star in the bottom-middle. - Diamond Blocks in both bottom corners. 4. Netherite Crafting Restrictions Disable vanilla Netherite Sword and Armour crafting. Vanilla Netherite Pickaxes, Axes, Shovels and Hoes remain craftable. All custom Netherite Sword and Armour recipes must follow their individual crafting limits. 5. Weapon Cooldown System Custom weapons with cooldowns display a personal boss bar at the top of the screen. - Only the weapon's owner sees the cooldown. - The boss bar displays the weapon name and remaining time. - It disappears when the weapon is ready again. Cooldowns: - Artemis' Bow: 5 minutes. - God's Crossbow: 15-second loading time. - Rift Cleaver: 15 minutes. 6. Custom Event System Commands: - /event – Opens the event setup GUI. - /event time [amount] – Sets the event countdown. - /event spawn – Spawns the event at the admin's current location. When /event is opened, display a chest GUI where the admin can place the prize items. Once configured, the event creates a 3×3 circle at the specified location. The event follows the same occupancy rules as the Rift Event: - Only one player inside allows the timer to count down. - Nobody inside or multiple players inside pauses the timer. - When the timer reaches zero, the player inside wins all items placed in the GUI. The entire server sees the event countdown, the current player inside and the event coordinates. 7. General Requirements - All custom weapons and medallions must have unique identities and abilities. - Prevent duplication exploits involving custom items. - Track crafting limits even after server restarts. - Save weapon kill counts, cooldowns, expiration times and crafting statistics. - Custom weapon expiration must work even if items are moved between inventories, chests or other storage. - All events, weapons and crafting recipes must work reliably in multiplayer. - Admins should have permission to manage and remove rifts and events.
Kodari AI
KodariFri at 8:16 pm 6
RiftWeapons
A Minecraft plugin introducing a rift portal system with timed events, seven unique custom weapons with special abilities, custom crafting recipes with global limits, and a comprehensive cooldown system using boss bars. Features include weapon expiration tracking, kill-based stat progression, custom events with GUI configuration, and persistent data storage across restarts.

I’ll build the rift and event systems, custom items and recipes, then add persistent cooldowns, item expiry and crafting limits. I’ll note any limitations where Minecraft doesn’t expose enough information to guarantee tracking.

Created the plugin with rift portals, capture events, custom items, recipes, cooldowns and persistent data.

Important limitations: this is not yet a complete implementation of the specification. Expiry is enforced when items are accessed, not immediately in unloaded storage; crafting-limit tracking cannot detect every destruction path; active events are not restored after restart. Enchantment caps, individual circle colours, true crossbow loading and comprehensive duplication prevention also remain unfinished.

The project has not been compiled or tested.

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

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.block.Block;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
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.BlockDispenseEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityResurrectEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.inventory.PrepareSmithingEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

public final class RiftPlugin extends JavaPlugin implements Listener {
    private final Random random = new Random();
    private final Map<UUID, BossBar> cooldownBars = new HashMap<>();
    private final List<Capture> captures = new ArrayList<>();
    private final Map<UUID, String> pendingKills = new HashMap<>();
    private final Map<UUID, Long> strengthBoosts = new HashMap<>();
    private NamespacedKey kindKey, idKey, expiryKey;
    private File dataFile;
    private YamlConfiguration data;
    private Location portal;
    private Location portalDestination;
    private long portalExpires;
    private int eventSeconds = 60;
    private Inventory prizes;
    private final String[] weapons = {"lightning", "bone", "artemis", "lifestealer", "crossbow", "life", "cleaver"};

    @Override
    public void onEnable() {
        kindKey = new NamespacedKey(this, "kind");
        idKey = new NamespacedKey(this, "id");
        expiryKey = new NamespacedKey(this, "expires");
        dataFile = new File(getDataFolder(), "data.yml");
        data = YamlConfiguration.loadConfiguration(dataFile);
        eventSeconds = Math.max(1, data.getInt("event-seconds", 60));
        prizes = Bukkit.createInventory(new PrizeHolder(), 27, "Event prizes");
        List<?> saved = data.getList("prizes");
        if (saved != null) for (int i = 0; i < Math.min(saved.size(), prizes.getSize()); i++) if (saved.get(i) instanceof ItemStack item) prizes.setItem(i, item);
        registerRecipes();
        Bukkit.getPluginManager().registerEvents(this, this);
        Bukkit.getScheduler().runTaskTimer(this, this::tick, 20L, 20L);
    }

    @Override
    public void onDisable() {
        for (Capture capture : captures) capture.bar.removeAll();
        cooldownBars.values().forEach(BossBar::removeAll);
        save();
    }

    private void save() {
        data.set("event-seconds", eventSeconds);
        data.set("prizes", Arrays.asList(prizes.getContents()));
        try { data.save(dataFile); } catch (IOException e) { getLogger().severe("Could not save data: " + e.getMessage()); }
    }

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

    private String kind(ItemStack item) {
        if (item == null || !item.hasItemMeta()) return "";
        return item.getItemMeta().getPersistentDataContainer().getOrDefault(kindKey, PersistentDataType.STRING, "");
    }

    private String itemId(ItemStack item) {
        if (item == null || !item.hasItemMeta()) return null;
        return item.getItemMeta().getPersistentDataContainer().get(idKey, PersistentDataType.STRING);
    }

    private ItemStack custom(String type, boolean expiring) {
        String base = switch (type) {
            case "lightning" -> "MACE";
            case "bone", "limited_sword" -> "NETHERITE_SWORD";
            case "artemis" -> "BOW";
            case "lifestealer" -> "DIAMOND_SWORD";
            case "crossbow" -> "CROSSBOW";
            case "life", "strength" -> "TOTEM_OF_UNDYING";
            case "cleaver" -> "NETHERITE_AXE";
            case "limited_helmet" -> "NETHERITE_HELMET";
            case "limited_chestplate" -> "NETHERITE_CHESTPLATE";
            case "limited_leggings" -> "NETHERITE_LEGGINGS";
            case "limited_boots" -> "NETHERITE_BOOTS";
            default -> throw new IllegalArgumentException(type);
        };
        String name = switch (type) {
            case "lightning" -> "Lightning Bringer";
            case "bone" -> "Bone Sword";
            case "artemis" -> "Artemis' Bow";
            case "lifestealer" -> "Lifestealer";
            case "crossbow" -> "God's Crossbow";
            case "life" -> "Life Medallion";
            case "strength" -> "Strength Medallion";
            case "cleaver" -> "Rift Cleaver";
            default -> "Rift " + type.substring(8).replace('_', ' ');
        };
        ItemStack item = new ItemStack(material(base));
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.LIGHT_PURPLE + name);
        meta.getPersistentDataContainer().set(kindKey, PersistentDataType.STRING, type);
        meta.getPersistentDataContainer().set(idKey, PersistentDataType.STRING, UUID.randomUUID().toString());
        if (expiring) meta.getPersistentDataContainer().set(expiryKey, PersistentDataType.LONG, System.currentTimeMillis() + 172800000L);
        item.setItemMeta(meta);
        if (type.equals("bone")) { enchant(item, "sharpness", 4); enchant(item, "fire_aspect", 2); enchant(item, "looting", 3); enchant(item, "mending", 1); enchant(item, "unbreaking", 3); }
        if (type.equals("artemis")) { enchant(item, "power", 4); enchant(item, "punch", 2); enchant(item, "flame", 1); enchant(item, "unbreaking", 3); enchant(item, "mending", 1); }
        if (type.equals("crossbow")) { enchant(item, "quick_charge", 3); enchant(item, "multishot", 1); enchant(item, "piercing", 4); enchant(item, "unbreaking", 3); enchant(item, "mending", 1); }
        return item;
    }

    private void enchant(ItemStack item, String key, int level) {
        Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(key));
        if (enchantment != null) item.addUnsafeEnchantment(enchantment, level);
    }

    private boolean expired(ItemStack item) {
        if (item == null || !item.hasItemMeta()) return false;
        Long expires = item.getItemMeta().getPersistentDataContainer().get(expiryKey, PersistentDataType.LONG);
        return expires != null && expires <= System.currentTimeMillis();
    }

    private void clean(Inventory inventory) {
        for (int i = 0; i < inventory.getSize(); i++) if (expired(inventory.getItem(i))) inventory.setItem(i, null);
    }

    private void registerRecipes() {
        recipe("cobweb", new ItemStack(material("COBWEB")), new String[]{"S S", " S ", "S S"}, Map.of('S', "STRING"));
        recipe("golden_apple", new ItemStack(material("GOLDEN_APPLE")), new String[]{" G ", "GAG", " G "}, Map.of('G', "GOLD_INGOT", 'A', "APPLE"));
        recipe("netherite_sword", custom("limited_sword", false), new String[]{"IDI", "IAI", "III"}, Map.of('I', "NETHERITE_INGOT", 'D', "DIAMOND_SWORD", 'A', "ENCHANTED_GOLDEN_APPLE"));
        for (String piece : List.of("helmet", "chestplate", "leggings", "boots")) {
            recipe("netherite_" + piece, custom("limited_" + piece, false), new String[]{" I ", "DBI", "   "}, Map.of('I', "NETHERITE_INGOT", 'D', "DIAMOND_" + piece.toUpperCase(), 'B', "NETHERITE_BLOCK"));
        }
        recipe("cleaver", custom("cleaver", false), new String[]{"ASA", " E ", "DND"}, Map.of('A', "ENCHANTED_GOLDEN_APPLE", 'S', "NETHERITE_SWORD", 'E', "DRAGON_EGG", 'D', "DIAMOND_BLOCK", 'N', "NETHER_STAR"));
        recipe("strength", custom("strength", false), new String[]{" P ", "GTG", " P "}, Map.of('P', "BLAZE_POWDER", 'G', "GOLD_INGOT", 'T', "TOTEM_OF_UNDYING"));
    }

    private void recipe(String key, ItemStack result, String[] shape, Map<Character, String> ingredients) {
        ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, key), result);
        recipe.shape(shape);
        ingredients.forEach((letter, mat) -> recipe.setIngredient(letter, material(mat)));
        Bukkit.addRecipe(recipe);
    }

    private boolean limitedAllowed(String type) {
        if (!type.startsWith("limited_")) return true;