Files
src
pom.xml
Code
4 1,379
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.List;
public final class GKCWeapons extends JavaPlugin implements CommandExecutor, TabCompleter {
public static NamespacedKey WEAPON_KEY;
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");
if (getCommand("start") != null) {
getCommand("start").setExecutor(this);
}
if (getCommand("gkc") != null) {
getCommand("gkc").setExecutor(this);
getCommand("gkc").setTabCompleter(this);
}
getServer().getPluginManager().registerEvents(new WeaponListener(this), this);
for (World world : Bukkit.getWorlds()) {
WorldBorder border = world.getWorldBorder();
border.setCenter(world.getSpawnLocation());
border.setSize(16.0);
}
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.12 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, 1, true, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 240, 0, 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.ABSORPTION, 45, 0, true, false));
}
}
}
@Override
public void onDisable() {
getLogger().info("[GKC] GKC Legendary Weapons Plugin Disabled.");
}
private boolean isAdmin(CommandSender sender) {
return sender.isOp() || sender.hasPermission("gkc.admin");
}
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: Shadow Blink (Teleport)",
"Shift+Left-Click: Void Pull (Black Hole)"
);
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: Blazing Uppercut"
);
w.addUnsafeEnchantment(Enchantment.SHARPNESS, 7);
yield w;
}
case "frostbite_katana" -> {
ItemStack w = createWeapon(
Material.DIAMOND_SWORD,
"&b&lFrostbite Katana",
"frostbite_katana",
1003,
"Shift+Right-Click: Cryo God Buff (Res IV + Regen VIII)",
"Shift+Left-Click: Frost Teleport (20 Blocks)"
);
w.addUnsafeEnchantment(Enchantment.SHARPNESS, 8);
yield w;
}
case "stormbreaker_trident", "stormbreaker" -> {
ItemStack w = createWeapon(
Material.TRIDENT,
"&9&lStormbreaker",
"stormbreaker_trident",
1004,
"Shift+Right-Click: Thunder Judgment (6 Bolts)",
"Shift+Left-Click: Storm Shockwave (Water Riptide III)"
);
w.addUnsafeEnchantment(Enchantment.IMPALING, 7);
w.addUnsafeEnchantment(Enchantment.RIPTIDE, 3);
yield w;
}
case "venom_fang", "venom_fang_dagger" -> {
ItemStack w = createWeapon(
Material.IRON_SWORD,
"&2&lVenom Fang Dagger",
"venom_fang",
1005,
"Shift+Right-Click: Shadow Stalker (Invis + Poison)",
"Shift+Left-Click: Viper Bite"
);
w.addUnsafeEnchantment(Enchantment.SHARPNESS, 6);
yield w;
}
case "gravity_mace" -> {
ItemStack w = createWeapon(
Material.MACE,
"&8&lGravity Mace",
"gravity_mace",
1006,
"Shift+Right-Click: Skyward Launch (No Water Needed | 6s CD)",