Files
resourcepack
src
build.gradle
README.md
settings.gradle
Code
44 671
src/main/java/com/kodari/legendaryweapons/LegendaryWeaponsPlugin.java
package com.kodari.legendaryweapons;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.attribute.Attribute;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.ShapedRecipe;
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;
public final class LegendaryWeaponsPlugin extends JavaPlugin {
public static final String PREFIX = "&8[&5Legendary&dWeapons&8] &r";
private final Map<UUID, Map<String, Long>> cooldowns = new HashMap<>();
private final Map<UUID, Double> energy = new HashMap<>();
private final Map<UUID, TimeSnapshot> timeSnapshots = new HashMap<>();
private FileConfiguration messages;
private PlayerDataStore data;
private org.bukkit.NamespacedKey weaponKey;
private org.bukkit.NamespacedKey instanceKey;
private org.bukkit.NamespacedKey chargesKey;
private org.bukkit.NamespacedKey ownerKey;
@Override public void onEnable() {
saveDefaultConfig();
if (!new File(getDataFolder(), "messages.yml").exists()) saveResource("messages.yml", false);
messages = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml"));
data = new PlayerDataStore(this);
weaponKey = new org.bukkit.NamespacedKey(this, "weapon");
instanceKey = new org.bukkit.NamespacedKey(this, "instance");
chargesKey = new org.bukkit.NamespacedKey(this, "charges");
ownerKey = new org.bukkit.NamespacedKey(this, "owner");
registerRecipes();
LegendaryCommand command = new LegendaryCommand(this);
getCommand("legendary").setExecutor(command);
getCommand("legendary").setTabCompleter(command);
getCommand("menu").setExecutor(command);
Bukkit.getPluginManager().registerEvents(new LegendaryListener(this), this);
Bukkit.getScheduler().runTaskTimer(this, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
double maximum = getConfig().getDouble("energy.maximum", 100.0);
double current = Math.min(maximum, energy(player) + getConfig().getDouble("energy.regeneration-per-second", 2.0));
energy.put(player.getUniqueId(), current);
data.energy(player.getUniqueId(), current);
sendStatus(player);
}
}, 20L, 20L);
}
@Override public void onDisable() { for (Player player : Bukkit.getOnlinePlayers()) data.energy(player.getUniqueId(), energy(player)); data.save(); Bukkit.getScheduler().cancelTasks(this); }
public String message(String path, String fallback) { return color(messages.getString(path, fallback)); }
public String color(String value) { return ChatColor.translateAlternateColorCodes('&', value == null ? "" : value); }
public void tell(CommandSender sender, String path, String fallback) { sender.sendMessage(message("prefix", PREFIX) + message(path, fallback)); }
public PlayerDataStore data() { return data; }
public org.bukkit.NamespacedKey weaponKey() { return weaponKey; }
public org.bukkit.NamespacedKey instanceKey() { return instanceKey; }
public org.bukkit.NamespacedKey chargesKey() { return chargesKey; }
public org.bukkit.NamespacedKey ownerKey() { return ownerKey; }
public boolean isWeapon(ItemStack stack) { return stack != null && stack.hasItemMeta() && stack.getItemMeta().getPersistentDataContainer().has(weaponKey, PersistentDataType.STRING); }
public WeaponType weapon(ItemStack stack) { if (!isWeapon(stack)) return null; return WeaponType.byId(stack.getItemMeta().getPersistentDataContainer().get(weaponKey, PersistentDataType.STRING)); }
public boolean enabled(WeaponType type) { return getConfig().getBoolean("weapons." + type.id() + ".enabled", true); }
public ItemStack createWeapon(WeaponType type, Player owner) {
ItemStack stack = new ItemStack(type.material());
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(type.color() + "β¦ " + type.displayName());
meta.setItemModel(new org.bukkit.NamespacedKey("legendaryweapons", type.id()));
meta.setCustomModelData(type.ordinal() + 1);
meta.setLore(List.of(
ChatColor.GRAY + type.typeName(),
type.color() + "Rarity: " + type.rarity(),
"", ChatColor.WHITE + "Passive: " + ChatColor.GRAY + type.passive(),
ChatColor.WHITE + "Ability 1: " + ChatColor.GRAY + type.abilityOne(),
ChatColor.WHITE + "Ability 2: " + ChatColor.GRAY + type.abilityTwo(),
ChatColor.WHITE + "Ultimate: " + ChatColor.GRAY + type.ultimate(), "",
ChatColor.DARK_GRAY + "Legendary ID: " + UUID.randomUUID().toString().substring(0, 8)));
var pdc = meta.getPersistentDataContainer();
pdc.set(weaponKey, PersistentDataType.STRING, type.id());
pdc.set(instanceKey, PersistentDataType.STRING, UUID.randomUUID().toString());
pdc.set(chargesKey, PersistentDataType.INTEGER, 0);
if (owner != null) pdc.set(ownerKey, PersistentDataType.STRING, owner.getUniqueId().toString());
stack.setItemMeta(meta);
return stack;
}
public int charges(ItemStack stack) { return isWeapon(stack) ? stack.getItemMeta().getPersistentDataContainer().getOrDefault(chargesKey, PersistentDataType.INTEGER, 0) : 0; }
public void charges(ItemStack stack, int value) { if (!isWeapon(stack)) return; ItemMeta meta = stack.getItemMeta(); meta.getPersistentDataContainer().set(chargesKey, PersistentDataType.INTEGER, Math.max(0, value)); stack.setItemMeta(meta); }
public double energy(Player player) { return energy.computeIfAbsent(player.getUniqueId(), id -> data.energy(id)); }
public String binding(Player player, int slot) { return data.binding(player.getUniqueId(), slot); }
public void setBinding(Player player, int slot, String key) { data.binding(player.getUniqueId(), slot, key); data.save(); }
public double remaining(Player player, String key) { return Math.max(0, (cooldowns.getOrDefault(player.getUniqueId(), Map.of()).getOrDefault(key, 0L) - System.currentTimeMillis()) / 1000.0); }
private void cooldown(Player player, String key, double seconds) { cooldowns.computeIfAbsent(player.getUniqueId(), id -> new HashMap<>()).put(key, System.currentTimeMillis() + (long) (seconds * 1000)); }
public boolean useAbility(Player player, WeaponType type, int slot) {
if (!enabled(type)) { tell(player, "disabled", "&cThis legendary weapon is disabled."); return false; }
String ability = slot == 1 ? type.abilityOne() : slot == 2 ? type.abilityTwo() : type.ultimate();
String path = "weapons." + type.id() + "." + (slot == 3 ? "ultimate" : "ability" + slot);
String cooldownKey = type.id() + ":" + slot;
double left = remaining(player, cooldownKey);
if (left > 0) { player.sendMessage(message("prefix", PREFIX) + color(message("cooldown", "&c{ability} is on cooldown for &e{time}s&c.").replace("{ability}", ability).replace("{time}", String.format("%.1f", left)))); return false; }
double cost = getConfig().getDouble(path + ".energy", 20);
if (energy(player) < cost) { player.sendMessage(message("prefix", PREFIX) + color(message("energy", "&cNot enough Legendary Energy. &7({current}/{max})").replace("{current}", String.format("%.0f", energy(player))).replace("{max}", String.format("%.0f", getConfig().getDouble("energy.maximum", 100))))); return false; }
energy.put(player.getUniqueId(), energy(player) - cost);
data.energy(player.getUniqueId(), energy(player));
cooldown(player, cooldownKey, getConfig().getDouble(path + ".cooldown", 10));
data.increment(player.getUniqueId(), slot == 3 ? "ultimates" : "ability-uses", 1);
if (slot == 3) ultimate(player, type); else ability(player, type, slot);
return true;
}
private void ability(Player p, WeaponType t, int slot) {
Location l = p.getLocation();
switch (t) {
case BLOODREAVER -> { if (slot == 1) { heal(p, 6); effect(p, PotionEffectType.SPEED, 100, 1); effect(p, PotionEffectType.STRENGTH, 100, 0); burst(l, Color.RED, 24); } else ray(p, 12, 5, Particle.REDSTONE, Color.RED); }
case STORMCALLER -> { if (slot == 1) { p.teleport(l.add(l.getDirection().multiply(7))); p.getWorld().strikeLightningEffect(p.getLocation()); } else { LivingEntity target = target(p, 14); if (target != null) { effect(target, PotionEffectType.GLOWING, 100, 0); Bukkit.getScheduler().runTaskLater(this, () -> p.getWorld().strikeLightningEffect(target.getLocation()), 30L); } } }
case GOLDEN_TOUCH -> { if (slot == 1) for (int i = 0; i < 5; i++) { Snowball ball = p.launchProjectile(Snowball.class); ball.setVelocity(p.getLocation().getDirection().add(new Vector((i - 2) * .08, 0, 0)).normalize().multiply(1.6)); } else { LivingEntity target = target(p, 12); if (target != null) { effect(target, PotionEffectType.SLOWNESS, 120, 2); effect(target, PotionEffectType.WEAKNESS, 120, 1); } } }
case VOIDFANG -> { if (slot == 1) ray(p, 16, 7, Particle.PORTAL, Color.PURPLE); else teleportStrike(p, 6, 5); }
case FROSTBITE -> { if (slot == 1) iceWall(p); else { burst(l, Color.AQUA, 40); damageNearby(p, l, 6, 5, 0.4, false); effectNearby(p, l, 6, PotionEffectType.SLOWNESS, 100, 2); } }
case SOULREND -> { if (slot == 1) { LivingEntity target = target(p, 10); if (target != null) { target.damage(8, p); heal(p, 4); soulParticles(target.getLocation()); } } else { Snowball ball = p.launchProjectile(Snowball.class); ball.setVelocity(p.getLocation().getDirection().multiply(1.8)); soulParticles(l); } }
case EARTHSHAKER -> { if (slot == 1) { damageNearby(p, l, 7, 7, 1.2, false); burst(l, Color.GRAY, 55); } else { Snowball ball = p.launchProjectile(Snowball.class); ball.setVelocity(p.getLocation().getDirection().multiply(1.7)); } }
case SHADOWBOW -> { if (slot == 1) { Arrow arrow = p.launchProjectile(Arrow.class); arrow.setPierceLevel(4); arrow.setDamage(9); } else teleportStrike(p, 5, 3); }
case SUNSPEAR -> { if (slot == 1) { LivingEntity target = target(p, 16); if (target != null) Bukkit.getScheduler().runTaskLater(this, () -> { target.getWorld().strikeLightningEffect(target.getLocation()); target.damage(10, p); }, 30L); } else dash(p, 8, 5); }
case PLAGUEBRINGER -> { if (slot == 1) { burst(l, Color.GREEN, 40); damageNearby(p, l, 5, 3, 0, false); effectNearby(p, l, 5, PotionEffectType.POISON, 100, 1); } else { Snowball ball = p.launchProjectile(Snowball.class); ball.setVelocity(p.getLocation().getDirection().multiply(1.8)); } }
case CHRONOBLADE -> { if (slot == 1) timeShift(p); else teleportStrike(p, 5, 2); }
case DRAGONFALL -> { if (slot == 1) { flameCone(p); } else dash(p, 8, 7); }
case WARDENS_WRATH -> { if (slot == 1) { ray(p, 18, 10, Particle.REDSTONE, Color.fromRGB(0, 180, 180)); p.playSound(l, Sound.ENTITY_WARDEN_SONIC_BOOM, 1, .7f); } else { effectNearby(p, l, 8, PotionEffectType.DARKNESS, 100, 0); effectNearby(p, l, 8, PotionEffectType.WEAKNESS, 100, 1); } }
case SCULK_SLICER -> { if (slot == 1) { LivingEntity target = target(p, 10); if (target != null) { target.damage(7, p); Bukkit.getScheduler().runTaskLater(this, () -> target.damage(7, p), 20L); } } else { burst(l, Color.fromRGB(0, 180, 180), 35); effectNearby(p, l, 8, PotionEffectType.SLOWNESS, 100, 1); } }
case ENDERFALL -> { if (slot == 1) { Location target = l.clone().add(l.getDirection().multiply(12)); p.teleport(target); burst(target, Color.PURPLE, 35); } else { ray(p, 14, 8, Particle.PORTAL, Color.PURPLE); } }
case SOULCLEAVER -> { if (slot == 1) ray(p, 12, 7, Particle.FLAME, Color.RED); else dash(p, 7, 6); }
}
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_STRONG, .8f, 1.2f);
}
private void ultimate(Player p, WeaponType t) {
Location l = p.getLocation();
double radius = t == WeaponType.ENDERFALL || t == WeaponType.EARTHSHAKER ? 12 : 9;
damageNearby(p, l, radius, getConfig().getDouble("weapons." + t.id() + ".damage", 10) * 1.8, 1.4, false);
effectNearby(p, l, radius, t == WeaponType.FROSTBITE ? PotionEffectType.SLOWNESS : PotionEffectType.WEAKNESS, 120, 1);
burst(l, t.color() == ChatColor.RED || t.color() == ChatColor.DARK_RED ? Color.RED : Color.PURPLE, 100);
if (t == WeaponType.STORMCALLER || t == WeaponType.SUNSPEAR) for (int i = 0; i < 5; i++) { Location strike = l.clone().add(ThreadLocalRandom.current().nextDouble(-radius, radius), 0, ThreadLocalRandom.current().nextDouble(-radius, radius)); p.getWorld().strikeLightningEffect(strike); }
if (t == WeaponType.BLOODREAVER || t == WeaponType.SOULREND) heal(p, 8);
if (t == WeaponType.PLAGUEBRINGER) effectNearby(p, l, radius, PotionEffectType.POISON, 160, 2);
if (t == WeaponType.DRAGONFALL || t == WeaponType.SOULCLEAVER) p.getWorld().createExplosion(l.getX(), l.getY(), l.getZ(), 0, false, false);
if (t == WeaponType.CHRONOBLADE) effectNearby(p, l, radius, PotionEffectType.SLOWNESS, 160, 5);
p.playSound(l, Sound.ENTITY_GENERIC_EXPLODE, 1.2f, .7f);
}
private void ray(Player p, int length, double damage, Particle particle, Color color) { Vector direction = p.getLocation().getDirection().normalize(); for (int i = 1; i <= length; i++) { Location point = p.getEyeLocation().clone().add(direction.clone().multiply(i)); p.getWorld().spawnParticle(particle, point, 4, .08, .08, .08, particle == Particle.REDSTONE ? new Particle.DustOptions(color, 1.2f) : null); damageNearby(p, point, 1.1, damage / length * 2, .2, false); } }
private void dash(Player p, int distance, double damage) { p.setVelocity(p.getLocation().getDirection().normalize().multiply(1.5).setY(.35)); Bukkit.getScheduler().runTaskLater(this, () -> damageNearby(p, p.getLocation(), 4, damage, .7, false), 8L); burst(p.getLocation(), Color.ORANGE, 35); }
private void teleportStrike(Player p, int distance, double damage) { Location target = p.getLocation().clone().add(p.getLocation().getDirection().normalize().multiply(distance)); p.teleport(target); damageNearby(p, target, 3, damage, .6, false); burst(target, Color.PURPLE, 30); }
private void flameCone(Player p) { Location point = p.getLocation().clone().add(p.getLocation().getDirection().multiply(3)); burst(point, Color.ORANGE, 50); damageNearby(p, point, 4, 9, .5, true); }
private void iceWall(Player p) { Location base = p.getLocation().clone().add(p.getLocation().getDirection().multiply(3)); if (!getConfig().getBoolean("settings.modify-terrain", false)) { burst(base, Color.AQUA, 80); return; } List<Location> changed = new ArrayList<>(); for (int x = -2; x <= 2; x++) for (int y = 0; y < 3; y++) { Location block = base.clone().add(x, y, 0); if (block.getBlock().getType().isAir()) { changed.add(block); block.getBlock().setType(Material.PACKED_ICE); } } Bukkit.getScheduler().runTaskLater(this, () -> changed.forEach(location -> location.getBlock().setType(Material.AIR)), 100L); }
private void timeShift(Player p) { TimeSnapshot snapshot = timeSnapshots.get(p.getUniqueId()); if (snapshot != null && System.currentTimeMillis() - snapshot.created < 10000) { p.teleport(snapshot.location); p.setHealth(Math.min(p.getMaxHealth(), snapshot.health)); p.setVelocity(snapshot.velocity); timeSnapshots.remove(p.getUniqueId()); tell(p, "time-shift-restored", "&bTime Shift restored your saved state."); } else { timeSnapshots.put(p.getUniqueId(), new TimeSnapshot(p.getLocation().clone(), p.getHealth(), p.getVelocity(), System.currentTimeMillis())); tell(p, "time-shift-saved", "&bTime Shift position saved. Activate again to return."); Bukkit.getScheduler().runTaskLater(this, () -> { TimeSnapshot current = timeSnapshots.get(p.getUniqueId()); if (current != null && current.created < System.currentTimeMillis() - 10000) { timeSnapshots.remove(p.getUniqueId()); tell(p, "time-shift-expired", "&cYour Time Shift state expired."); } }, 200L); } }
private void damageNearby(Player source, Location center, double radius, double damage, double knockback, boolean fire) { int count = 0; for (Entity entity : center.getWorld().getNearbyEntities(center, radius, radius, radius)) { if (count >= getConfig().getInt("settings.max-nearby-targets", 32) || !(entity instanceof LivingEntity target) || entity.equals(source)) continue; if (target instanceof Player && !getConfig().getBoolean("settings.allow-pvp-damage", true)) continue; target.damage(damage, source); if (fire) target.setFireTicks(80); if (knockback > 0) target.setVelocity(target.getLocation().toVector().subtract(center.toVector()).normalize().multiply(knockback).setY(.35)); count++; data.increment(source.getUniqueId(), "damage-dealt", damage); } }
private void effectNearby(Player source, Location center, double radius, PotionEffectType type, int duration, int amplifier) { for (Entity entity : center.getWorld().getNearbyEntities(center, radius, radius, radius)) if (entity instanceof LivingEntity target && !target.equals(source)) target.addPotionEffect(new PotionEffect(type, duration, amplifier)); }
private LivingEntity target(Player p, double range) { for (Entity entity : p.getWorld().getNearbyEntities(p.getEyeLocation().add(p.getLocation().getDirection().multiply(2)), range, range, range)) if (entity instanceof LivingEntity living && !living.equals(p)) return living; return null; }
private void heal(Player p, double amount) { p.setHealth(Math.min(p.getMaxHealth(), p.getHealth() + amount)); }
private void effect(LivingEntity entity, PotionEffectType type, int duration, int amplifier) { entity.addPotionEffect(new PotionEffect(type, duration, amplifier)); }
private void burst(Location l, Color color, int amount) { l.getWorld().spawnParticle(Particle.REDSTONE, l, amount, 1.5, 1.2, 1.5, new Particle.DustOptions(color, 1.5f)); l.getWorld().spawnParticle(Particle.CLOUD, l, amount / 2, 1, 1, 1, .08); }
private void soulParticles(Location l) { l.getWorld().spawnParticle(Particle.SOUL_FIRE_FLAME, l, 25, .5, .5, .5, .03); l.getWorld().spawnParticle(Particle.PORTAL, l, 25, .5, .5, .5, .2); }
public boolean domainActive(Player p, WeaponType type) { World.Environment environment = p.getWorld().getEnvironment(); if ((type == WeaponType.ENDERFALL) && environment == World.Environment.THE_END) return true; if ((type == WeaponType.SOULCLEAVER) && environment == World.Environment.NETHER) return true; if ((type == WeaponType.WARDENS_WRATH || type == WeaponType.SCULK_SLICER) && p.getLocation().getBlock().getBiome().name().equals("DEEP_DARK")) return true; return false; }
private void sendStatus(Player p) { if (!getConfig().getBoolean("settings.actionbar-enabled", true)) return; WeaponType type = weapon(p.getInventory().getItemInMainHand()); if (type == null) return; String text = type.color() + type.displayName() + ChatColor.GRAY + " | Energy: " + ChatColor.AQUA + String.format("%.0f", energy(p)); if (domainActive(p, type) && getConfig().getBoolean("settings.domain-actionbar", true)) text += " " + message("domain", "&dβ¦ DOMAIN POWER ACTIVE β¦"); p.sendActionBar(text); }
public void openMain(Player p) { Inventory inventory = Bukkit.createInventory(null, 54, ChatColor.DARK_RED + "Legendary Weapons"); for (int i = 0; i < WeaponType.values().length; i++) inventory.setItem(10 + i, icon(WeaponType.values()[i])); p.openInventory(inventory); }
public void openDetails(Player p, WeaponType type) { Inventory inventory = Bukkit.createInventory(null, 54, ChatColor.DARK_PURPLE + "DETAIL|" + type.id()); ItemStack icon = createWeapon(type, p); ItemMeta meta = icon.getItemMeta(); List<String> lore = new ArrayList<>(meta.getLore()); lore.add(""); lore.add(ChatColor.GOLD + "Damage: " + getConfig().getDouble("weapons." + type.id() + ".damage", 10)); lore.add(ChatColor.GOLD + "Passive: " + type.passive()); lore.add(ChatColor.GOLD + "Ability 1: " + type.abilityOne()); lore.add(ChatColor.GOLD + "Ability 2: " + type.abilityTwo()); lore.add(ChatColor.GOLD + "Ultimate: " + type.ultimate()); icon.setItemMeta(meta); inventory.setItem(13, icon); inventory.setItem(31, named(Material.REPEATER, ChatColor.AQUA + "Configure controls")); inventory.setItem(49, named(Material.ARROW, ChatColor.YELLOW + "Back")); p.openInventory(inventory); }
public void openControls(Player p, WeaponType type) { Inventory inventory = Bukkit.createInventory(null, 54, ChatColor.BLUE + "CONTROLS|" + type.id()); inventory.setItem(20, named(Material.IRON_SWORD, ChatColor.YELLOW + "Ability 1: " + binding(p, 1))); inventory.setItem(21, named(Material.DIAMOND_SWORD, ChatColor.YELLOW + "Ability 2: " + binding(p, 2))); inventory.setItem(22, named(Material.NETHER_STAR, ChatColor.YELLOW + "Ultimate: " + binding(p, 3))); inventory.setItem(49, named(Material.ARROW, ChatColor.YELLOW + "Back")); p.openInventory(inventory); }
public void openControlOptions(Player p, WeaponType type, int slot) { Inventory inventory = Bukkit.createInventory(null, 54, ChatColor.BLUE + "CONTROL|" + type.id() + "|" + slot); String[] keys = { "RIGHT_CLICK", "LEFT_CLICK", "SHIFT_RIGHT_CLICK", "SHIFT_LEFT_CLICK", "DROP", "SWAP_HANDS" }; for (int i = 0; i < keys.length; i++) inventory.setItem(10 + i, named(Material.PAPER, ChatColor.AQUA + keys[i])); inventory.setItem(31, named(Material.BARRIER, ChatColor.RED + "Reset to Defaults")); inventory.setItem(49, named(Material.ARROW, ChatColor.YELLOW + "Back")); p.openInventory(inventory); }
public void openAdmin(Player p) { Inventory inventory = Bukkit.createInventory(null, 27, ChatColor.DARK_RED + "ADMIN|Legendary Weapons"); inventory.setItem(11, named(Material.CHEST, ChatColor.GREEN + "Give weapon")); inventory.setItem(13, named(Material.ANVIL, ChatColor.YELLOW + "Reset cooldowns")); inventory.setItem(15, named(Material.BOOK, ChatColor.AQUA + "Reload config")); p.openInventory(inventory); }
private ItemStack icon(WeaponType type) { return named(type.material(), type.color() + type.displayName()); }
private ItemStack named(Material material, String name) { ItemStack stack = new ItemStack(material); ItemMeta meta = stack.getItemMeta(); meta.setDisplayName(name); stack.setItemMeta(meta); return stack; }
public void reloadResources() { reloadConfig(); messages = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml")); }