enchantment manager
This commit is contained in:
parent
c89d48910c
commit
0f39c1bc73
11 changed files with 263 additions and 229 deletions
|
@ -6,7 +6,7 @@ import me.night.nullvalkyrie.tasks.AlwaysDayTask;
|
||||||
import me.night.nullvalkyrie.ui.inventory.InventoryListener;
|
import me.night.nullvalkyrie.ui.inventory.InventoryListener;
|
||||||
import me.night.nullvalkyrie.database.NPCDataManager;
|
import me.night.nullvalkyrie.database.NPCDataManager;
|
||||||
import me.night.nullvalkyrie.discord.DiscordClientManager;
|
import me.night.nullvalkyrie.discord.DiscordClientManager;
|
||||||
import me.night.nullvalkyrie.enchantments.EnchantmentManager;
|
import me.night.nullvalkyrie.util.enchantments.EnchantmentManager;
|
||||||
import me.night.nullvalkyrie.ui.player.ScoreboardListener;
|
import me.night.nullvalkyrie.ui.player.ScoreboardListener;
|
||||||
import me.night.nullvalkyrie.util.*;
|
import me.night.nullvalkyrie.util.*;
|
||||||
import me.night.nullvalkyrie.commands.*;
|
import me.night.nullvalkyrie.commands.*;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package me.night.nullvalkyrie.commands;
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.database.CustomWeaponsDataManager;
|
import me.night.nullvalkyrie.database.CustomWeaponsDataManager;
|
||||||
import me.night.nullvalkyrie.items.CustomItemManager;
|
import me.night.nullvalkyrie.entities.items.CustomItemManager;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package me.night.nullvalkyrie.commands;
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.database.CustomWeaponsDataManager;
|
import me.night.nullvalkyrie.database.CustomWeaponsDataManager;
|
||||||
import me.night.nullvalkyrie.items.CustomItemManager;
|
import me.night.nullvalkyrie.entities.items.CustomItemManager;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.items;
|
package me.night.nullvalkyrie.entities.items;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
import me.night.nullvalkyrie.enums.Rarity;
|
import me.night.nullvalkyrie.enums.Rarity;
|
||||||
|
@ -38,11 +38,13 @@ public class CustomItemManager {
|
||||||
for (String p : properties.keySet())
|
for (String p : properties.keySet())
|
||||||
if ((int) properties.get(p) > 0)
|
if ((int) properties.get(p) > 0)
|
||||||
propertiesList.add(ChatColor.GRAY + Util.capitalize(p) + ": " + ChatColor.RED + "+" + properties.get(p));
|
propertiesList.add(ChatColor.GRAY + Util.capitalize(p) + ": " + ChatColor.RED + "+" + properties.get(p));
|
||||||
itemAbility.add(ChatColor.GOLD + "Item Ability: " + ability.get("Name"));
|
if (ability.get("Name") != null) {
|
||||||
for (String line : (List<String>) ability.get("Details"))
|
itemAbility.add(ChatColor.GOLD + "Item Ability: " + ability.get("Name"));
|
||||||
itemAbility.add(ChatColor.GRAY + line);
|
for (String line : (List<String>) ability.get("Details"))
|
||||||
|
itemAbility.add(ChatColor.GRAY + line);
|
||||||
|
}
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta == null) return item;
|
||||||
itemMeta.setDisplayName(Rarity.getRarity((String) weapon.get("Rarity")).getColor() + weapon.get("Name"));
|
itemMeta.setDisplayName(Rarity.getRarity((String) weapon.get("Rarity")).getColor() + weapon.get("Name"));
|
||||||
itemMeta.setUnbreakable(true);
|
itemMeta.setUnbreakable(true);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.items;
|
package me.night.nullvalkyrie.entities.items;
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
34
src/main/java/me/night/nullvalkyrie/enums/Enchantments.java
Normal file
34
src/main/java/me/night/nullvalkyrie/enums/Enchantments.java
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package me.night.nullvalkyrie.enums;
|
||||||
|
|
||||||
|
import me.night.nullvalkyrie.util.enchantments.EnchantmentManager;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
|
||||||
|
public enum Enchantments {
|
||||||
|
THUNDERBOLT("thunderbolt", "ThunderBolt", 5),
|
||||||
|
SMELTING_TOUCH("smelting-touch", "Smelting Touch", 1);
|
||||||
|
public final String namespacekey;
|
||||||
|
public final String name;
|
||||||
|
public final int maxLevel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Enchantments(String namespacekey, String name, int maxLevel) {
|
||||||
|
this.namespacekey = namespacekey;
|
||||||
|
this.name = name;
|
||||||
|
this.maxLevel = maxLevel;
|
||||||
|
}
|
||||||
|
public String getNamespacekey() {
|
||||||
|
return namespacekey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxLevel() {
|
||||||
|
return maxLevel;
|
||||||
|
}
|
||||||
|
public Enchantment getEnchant() {
|
||||||
|
return EnchantmentManager.enchants.get(this.ordinal());
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,8 +5,8 @@ import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
import me.night.nullvalkyrie.items.CustomItemManager;
|
import me.night.nullvalkyrie.entities.items.CustomItemManager;
|
||||||
import me.night.nullvalkyrie.items.Pickaxe;
|
import me.night.nullvalkyrie.entities.items.Pickaxe;
|
||||||
import me.night.nullvalkyrie.enums.Rarity;
|
import me.night.nullvalkyrie.enums.Rarity;
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package me.night.nullvalkyrie.ui.inventory;
|
package me.night.nullvalkyrie.ui.inventory;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.database.ShopDataManager;
|
import me.night.nullvalkyrie.database.ShopDataManager;
|
||||||
import me.night.nullvalkyrie.items.CustomItemManager;
|
import me.night.nullvalkyrie.entities.items.CustomItemManager;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package me.night.nullvalkyrie.util;
|
package me.night.nullvalkyrie.util;
|
||||||
|
|
||||||
import static me.night.nullvalkyrie.items.CustomItemManager.updateYamlFilesToPlugin;
|
import static me.night.nullvalkyrie.entities.items.CustomItemManager.updateYamlFilesToPlugin;
|
||||||
|
|
||||||
public class FileManager {
|
public class FileManager {
|
||||||
public FileManager() {
|
public FileManager() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.enchantments;
|
package me.night.nullvalkyrie.util.enchantments;
|
||||||
|
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
|
@ -1,5 +1,6 @@
|
||||||
package me.night.nullvalkyrie.enchantments;
|
package me.night.nullvalkyrie.util.enchantments;
|
||||||
|
|
||||||
|
import me.night.nullvalkyrie.enums.Enchantments;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
@ -8,16 +9,13 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EnchantmentManager {
|
public class EnchantmentManager {
|
||||||
public static final Enchantment ThunderBolt = new CustomEnchantment("thunderbolt", "ThunderBolt", 5);
|
public static List<Enchantment> enchants = new ArrayList<>();
|
||||||
public static final Enchantment SmeltingTouch = new CustomEnchantment("smelting-touch", "Smelting Touch", 1);
|
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
List<Enchantment> enchants = new ArrayList<>();
|
|
||||||
enchants.add(ThunderBolt);
|
|
||||||
enchants.add(SmeltingTouch);
|
|
||||||
List<Boolean> registeredList = new ArrayList<>();
|
List<Boolean> registeredList = new ArrayList<>();
|
||||||
for (Enchantment enchant : enchants) {
|
for (Enchantments enchantment : Enchantments.values()) {
|
||||||
registeredList.add(Arrays.stream(Enchantment.values()).toList().contains(enchant));
|
Enchantment en = new CustomEnchantment(enchantment.getNamespacekey(), enchantment.getName(), enchantment.getMaxLevel());
|
||||||
|
enchants.add(en);
|
||||||
|
registeredList.add(Arrays.stream(Enchantment.values()).toList().contains(en));
|
||||||
}
|
}
|
||||||
for (int counter = 0; counter < registeredList.size(); counter++) {
|
for (int counter = 0; counter < registeredList.size(); counter++) {
|
||||||
if (!registeredList.get(counter)) registerEnchantment(enchants.get(counter));
|
if (!registeredList.get(counter)) registerEnchantment(enchants.get(counter));
|
Loading…
Reference in a new issue