Techno Gamerz.

Like I want something unique ,guns ,multiplayer,custom items

Kodari AI
KodariOct 26 at 4:51 am 1
GunCraftArena
GunCraftArena is a Minecraft plugin that introduces a complete first-person shooter experience with custom firearms, multiplayer combat modes, and unique weapon crafting. Players can acquire over 20 distinct guns including pistols, rifles, shotguns, and sniper rifles, each with custom sounds, projectiles, and damage profiles. The plugin features team-based deathmatch and free-for-all arena modes with scoreboards, respawn systems, and match timers. Custom items include armor piercing rounds, explosive ammunition, and tactical gear like grenades and medkits. A weapon crafting system allows players to combine materials and upgrade parts for enhanced performance. The plugin includes a comprehensive gun customization menu with attachments like scopes, suppressors, and extended magazines. Multiplayer functionality supports up to 32 players with lobby management, team balancing, and killstreak rewards. The system integrates with Minecraft's existing damage system while adding headshot multipliers, recoil patterns, and bullet drop mechanics for realistic combat.
  1. Build Rift Arsenal, a multiplayer PvP plugin with three distinct custom weapons.

  2. Add magazine-based shooting, reloadable Rift Cells, and weapon hit damage.

  3. Wire /arsenal give and the plugin/build metadata.

Created Rift Arsenal with three multiplayer PvP weapons: the Needle Pistol, Pulse Carbine, and six-pellet Rift Scatterer. Weapons have custom names, magazines, firing rates, and damage; Rift Cells are custom reload ammo.

Use /arsenal give <player> <needle|pulse|scatter|cell> [amount] to distribute items. Right-click to fire; sneak + right-click with a Rift Cell in your inventory to reload.

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

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
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.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;
import java.util.concurrent.ThreadLocalRandom;

public final class RiftArsenalPlugin extends JavaPlugin implements Listener {
    private NamespacedKey weaponKey;
    private NamespacedKey ammoKey;
    private NamespacedKey projectileKey;
    private NamespacedKey cellKey;
    private final Map<java.util.UUID, Long> nextShotAt = new HashMap<>();

    @Override
    public void onEnable() {
        weaponKey = new NamespacedKey(this, "weapon");
        ammoKey = new NamespacedKey(this, "magazine_ammo");
        projectileKey = new NamespacedKey(this, "projectile_weapon");
        cellKey = new NamespacedKey(this, "rift_cell");
        Bukkit.getPluginManager().registerEvents(this, this);
        getCommand("arsenal").setExecutor(this::handleCommand);
        getCommand("arsenal").setTabCompleter((sender, command, alias, args) -> completeCommand(args));
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        if (event.getHand() == null || !event.getHand().name().equals("HAND")) {
            return;
        }
        Action action = event.getAction();
        if (action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) {
            return;
        }

        Player player = event.getPlayer();
        ItemStack held = player.getInventory().getItemInMainHand();
        Weapon weapon = getWeapon(held);
        if (weapon == null) {
            return;
        }

        event.setCancelled(true);
        if (player.isSneaking()) {
            reload(player, held, weapon);
        } else {
            fire(player, held, weapon);
        }
    }

    @EventHandler
    public void onProjectileHit(ProjectileHitEvent event) {
        if (!(event.getEntity() instanceof Snowball snowball)) {
            return;
        }
        String weaponId = snowball.getPersistentDataContainer().get(projectileKey, PersistentDataType.STRING);
        Weapon weapon = weaponById(weaponId);
        if (weapon == null || !(event.getHitEntity() instanceof LivingEntity target)) {
            return;
        }
        if (snowball.getShooter() instanceof LivingEntity shooter && shooter != target) {
            target.damage(weapon.damage, shooter);
        } else {
            target.damage(weapon.damage);
        }
    }

    @EventHandler
    public void onQuit(PlayerQuitEvent event) {
        nextShotAt.remove(event.getPlayer().getUniqueId());
    }

    private void fire(Player player, ItemStack gun, Weapon weapon) {
        long now = System.currentTimeMillis();
        long readyAt = nextShotAt.getOrDefault(player.getUniqueId(), 0L);
        if (now < readyAt) {
            return;
        }

        ItemMeta meta = gun.getItemMeta();
        Integer ammo = meta.getPersistentDataContainer().get(ammoKey, PersistentDataType.INTEGER);
        if (ammo == null || ammo <= 0) {
            player.sendMessage(color("&cMagazine empty. Sneak + right-click with a Rift Cell to reload."));
            return;
        }

        meta.getPersistentDataContainer().set(ammoKey, PersistentDataType.INTEGER, ammo - 1);
        updateGunLore(meta, weapon, ammo - 1);
        gun.setItemMeta(meta);
        nextShotAt.put(player.getUniqueId(), now + weapon.cooldownMillis);

        for (int i = 0; i < weapon.projectiles; i++) {
            Vector direction = player.getEyeLocation().getDirection().clone();
            if (weapon.spread > 0) {
                direction.add(new Vector(
                        ThreadLocalRandom.current().nextDouble(-weapon.spread, weapon.spread),
                        ThreadLocalRandom.current().nextDouble(-weapon.spread, weapon.spread),
                        ThreadLocalRandom.current().nextDouble(-weapon.spread, weapon.spread)
                )).normalize();
            }
            Snowball projectile = player.launchProjectile(Snowball.class);
            projectile.setVelocity(direction.multiply(weapon.projectileSpeed));
            projectile.getPersistentDataContainer().set(projectileKey, PersistentDataType.STRING, weapon.id);
        }
    }

    private void reload(Player player, ItemStack gun, Weapon weapon) {
        ItemMeta meta = gun.getItemMeta();
        Integer ammo = meta.getPersistentDataContainer().get(ammoKey, PersistentDataType.INTEGER);
        if (ammo == null || ammo >= weapon.magazineSize) {
            player.sendMessage(color("&eYour " + weapon.displayName + " is already full."));
            return;
        }

        int cellSlot = findCell(player);
        if (cellSlot < 0) {
            player.sendMessage(color("&cYou need a Rift Cell to reload."));
            return;
        }

        ItemStack cells = player.getInventory().getItem(cellSlot);
        if (cells.getAmount() == 1) {
            player.getInventory().setItem(cellSlot, null);
        } else {
            cells.setAmount(cells.getAmount() - 1);
        }
        meta.getPersistentDataContainer().set(ammoKey, PersistentDataType.INTEGER, weapon.magazineSize);
        updateGunLore(meta, weapon, weapon.magazineSize);
        gun.setItemMeta(meta);
        player.sendMessage(color("&bRift Cell loaded: &f" + weapon.magazineSize + " rounds."));
    }

    private int findCell(Player player) {
        ItemStack[] contents = player.getInventory().getStorageContents();
        for (int i = 0; i < contents.length; i++) {
            ItemStack item = contents[i];
            if (item == null || !item.hasItemMeta()) {
                continue;
            }
            if (item.getItemMeta().getPersistentDataContainer().has(cellKey, PersistentDataType.BYTE)) {
                return i;
            }
        }
        return -1;
    }

    private boolean handleCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
        if (args.length == 0 || !args[0].equalsIgnoreCase("give")) {
            sender.sendMessage(color("&bRift Arsenal &7— &f/arsenal give <player> <needle|pulse|scatter|cell> [amount]"));
            return true;
        }
        if (!sender.hasPermission("riftarsenal.admin")) {
            sender.sendMessage(color("&cYou do not have permission to do that."));
            return true;
        }
        if (args.length < 3 || args.length > 4) {
            sender.sendMessage(color("&cUsage: /arsenal give <player> <needle|pulse|scatter|cell> [amount]"));
            return true;
        }

        Player target = Bukkit.getPlayerExact(args[1]);
        if (target == null) {
            sender.sendMessage(color("&cThat player is not online."));
            return true;
        }

        String itemId = args[2].toLowerCase(Locale.ROOT);
        int amount = 1;
        if (args.length == 4) {
            try {
                amount = Integer.parseInt(args[3]);
            } catch (NumberFormatException exception) {
                sender.sendMessage(color("&cAmount must be a number."));
                return true;
            }
            if (amount < 1 || amount > 64) {
                sender.sendMessage(color("&cAmount must be between 1 and 64."));
                return true;
            }