Files
GKC_Custom_Weapons_Bedrock_v4
GKC-Legendary-Weapons-v26.2.16
Code
21 2,402
GKC-Legendary-Weapons-v26.2.16/src/main/java/com/gkc/weapons/GKCWeapons.java
package com.gkc.weapons;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemFlag;
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.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.EulerAngle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public final class GKCWeapons extends JavaPlugin implements CommandExecutor, TabCompleter {
public static NamespacedKey WEAPON_KEY;
// Prevents duplicate overlapping spins for the same player
private final Set<UUID> activeSpinningPlayers = new HashSet<>();
private boolean startCountdownRunning = false;
public static final List<String> WEAPON_IDS = Arrays.asList(
"void_riever",
"solaris_greataxe",
"frostbite_katana",
"stormbreaker_trident",
"venom_fang",
"gravity_mace",
"soul_harvester"
);
@Override
public void onEnable() {
WEAPON_KEY = new NamespacedKey(this, "gkc_weapon_id");
saveDefaultConfig();
reloadConfig();
if (getCommand("start") != null) {
getCommand("start").setExecutor(this);
}
if (getCommand("event") != null) {
getCommand("event").setExecutor(this);
}
if (getCommand("gkc") != null) {
getCommand("gkc").setExecutor(this);
getCommand("gkc").setTabCompleter(this);
}
getServer().getPluginManager().registerEvents(new WeaponListener(this), this);
// Persistent World Border check: 1 chunk (16 blocks) until /start is run once
boolean borderAlreadyOpened = getConfig().getBoolean("border-opened", false);
if (!borderAlreadyOpened) {
for (World world : Bukkit.getWorlds()) {
WorldBorder border = world.getWorldBorder();
border.setCenter(world.getSpawnLocation());
border.setSize(16.0);
}
getLogger().info("[GKC] World Border initialized to 1 chunk (16 blocks) - waiting for /start.");
} else {
for (World world : Bukkit.getWorlds()) {
WorldBorder border = world.getWorldBorder();
if (border.getSize() < 1000.0) {
border.setSize(59999968.0);
}
}
getLogger().info("[GKC] World Border was already opened previously! Keeping border open.");
}
// Apply Hand Buffs for Main & Off-Hand
Bukkit.getScheduler().runTaskTimer(this, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
applyHandBuffs(player, player.getInventory().getItemInMainHand());
applyHandBuffs(player, player.getInventory().getItemInOffHand());
}
}, 20L, 20L);
getLogger().info("[GKC] 7 Legendary Weapons v26.2.16 Enabled!");
}
private void applyHandBuffs(Player player, ItemStack item) {
if (item == null || !item.hasItemMeta()) return;
ItemMeta meta = item.getItemMeta();
if (!meta.getPersistentDataContainer().has(WEAPON_KEY, PersistentDataType.STRING)) return;
String id = meta.getPersistentDataContainer().get(WEAPON_KEY, PersistentDataType.STRING);
if (id == null) return;
switch (id) {
case "void_riever" -> {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 45, 2, true, false));
}
case "solaris_greataxe" -> {
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 45, 0, true, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.STRENGTH, 45, 0, true, false));
}
case "frostbite_katana" -> {
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP_BOOST, 45, 4, true, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 45, 0, true, false));
}
case "stormbreaker_trident" -> {
player.addPotionEffect(new PotionEffect(PotionEffectType.HASTE, 45, 1, true, false));
if (player.isInWater() || player.getWorld().hasStorm()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.STRENGTH, 45, 1, true, false));
}
}
case "venom_fang" -> {
player.addPotionEffect(new PotionEffect(PotionEffectType.RESISTANCE, 45, 3, true, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.DOLPHINS_GRACE, 45, 0, true, false));
}
case "gravity_mace" -> {
player.addPotionEffect(new PotionEffect(PotionEffectType.RESISTANCE, 45, 1, true, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP_BOOST, 45, 2, true, false));
}
case "soul_harvester" -> {
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 45, 0, true, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.STRENGTH, 45, 1, true, false));
}
}
}
@Override
public void onDisable() {
saveConfig();
getLogger().info("[GKC] GKC Legendary Weapons Plugin Disabled & Config Saved.");
}
private boolean isAdmin(CommandSender sender) {
return sender.isOp() || sender.hasPermission("gkc.admin");
}
public boolean isSpinEnabled() {
return getConfig().getBoolean("spin-enabled", false);
}
public boolean hasPlayerReceivedWeapon(UUID uuid) {
List<String> rewarded = getConfig().getStringList("rewarded-players");
return rewarded.contains(uuid.toString());
}
public void markPlayerRewarded(UUID uuid) {
List<String> rewarded = new ArrayList<>(getConfig().getStringList("rewarded-players"));
String idStr = uuid.toString();
if (!rewarded.contains(idStr)) {
rewarded.add(idStr);
getConfig().set("rewarded-players", rewarded);
saveConfig();
}
}
public static ItemStack getWeaponById(String id) {
ItemStack item = switch (id.toLowerCase()) {
case "void_riever", "void_reaver" -> {
ItemStack w = createWeapon(
Material.NETHERITE_SWORD,
"&5&lVoid Reaver",
"void_riever",
1001,
"Shift+Right-Click: 40 Weakness Arrows Volley (15 Blocks)",
"Shift+Left-Click: Aim Target -> 5 Cobwebs + Slowness IV (6s)"
);
w.addUnsafeEnchantment(Enchantment.SHARPNESS, 7);
yield w;
}
case "solaris_greataxe" -> {
ItemStack w = createWeapon(
Material.NETHERITE_AXE,
"&6&lSolaris Greataxe",
"solaris_greataxe",
1002,
"Shift+Right-Click: Solar Flare Slam",
"Shift+Left-Click: Hit Entity -> 9-Block Deep Crater (3-Block Radius)"
);