diff --git a/lib/MMOLib.jar b/lib/MMOLib.jar index 6b10fc2a..a7929d9a 100644 Binary files a/lib/MMOLib.jar and b/lib/MMOLib.jar differ diff --git a/src/main/java/net/Indyuce/mmocore/api/ConfigMessage.java b/src/main/java/net/Indyuce/mmocore/api/ConfigMessage.java index f97c6682..38093007 100644 --- a/src/main/java/net/Indyuce/mmocore/api/ConfigMessage.java +++ b/src/main/java/net/Indyuce/mmocore/api/ConfigMessage.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import net.Indyuce.mmocore.MMOCore; -import net.asangarin.hexcolors.ColorParse; import net.mmogroup.mmolib.MMOLib; public class ConfigMessage { @@ -31,14 +30,14 @@ public class ConfigMessage { } public void send(CommandSender sender) { - messages.forEach(line -> sender.sendMessage(new ColorParse('&', line).toChatColor())); + messages.forEach(line -> sender.sendMessage(MMOLib.plugin.parseColors(line))); } public void send(Collection players) { - players.forEach(player -> messages.forEach(line -> player.sendMessage(new ColorParse('&', MMOCore.plugin.placeholderParser.parse(player, line)).toChatColor()))); + players.forEach(player -> messages.forEach(line -> player.sendMessage(MMOCore.plugin.placeholderParser.parse(player, line)))); } public void sendAsJSon(Player player) { - messages.forEach(line -> MMOLib.plugin.getNMS().sendJson(player, new ColorParse('&', line).toChatColor())); + messages.forEach(line -> MMOLib.plugin.getVersion().getWrapper().sendJson(player, MMOLib.plugin.parseColors(line))); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/PlayerActionBar.java b/src/main/java/net/Indyuce/mmocore/api/PlayerActionBar.java index 7f21d210..75054cb9 100644 --- a/src/main/java/net/Indyuce/mmocore/api/PlayerActionBar.java +++ b/src/main/java/net/Indyuce/mmocore/api/PlayerActionBar.java @@ -9,9 +9,9 @@ import org.bukkit.scheduler.BukkitRunnable; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.stats.StatType; -import net.asangarin.hexcolors.ColorParse; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; +import net.mmogroup.mmolib.MMOLib; public class PlayerActionBar extends BukkitRunnable { private final int ticks; @@ -31,7 +31,7 @@ public class PlayerActionBar extends BukkitRunnable { for (PlayerData data : PlayerData.getAll()) if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && data.canSeeActionBar()) { data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(MMOCore.plugin.placeholderParser.parse(data.getPlayer(), - new ColorParse('&', new String(format) + MMOLib.plugin.parseColors(new String(format) .replace("{health}", digit.format(data.getPlayer().getHealth())) .replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())) .replace("{mana_icon}", data.getProfess().getManaDisplay().getIcon()) @@ -45,7 +45,7 @@ public class PlayerActionBar extends BukkitRunnable { .replace("{xp}", "" + data.getExperience()) .replace("{armor}", "" + StatType.ARMOR.format(data.getPlayer().getAttribute(Attribute.GENERIC_ARMOR).getValue())) .replace("{level}", "" + data.getLevel()) - .replace("{name}", data.getPlayer().getDisplayName())).toChatColor()))); + .replace("{name}", data.getPlayer().getDisplayName()))))); } } } diff --git a/src/main/java/net/Indyuce/mmocore/api/block/SkullBlockType.java b/src/main/java/net/Indyuce/mmocore/api/block/SkullBlockType.java index 11b42947..64cc03ba 100644 --- a/src/main/java/net/Indyuce/mmocore/api/block/SkullBlockType.java +++ b/src/main/java/net/Indyuce/mmocore/api/block/SkullBlockType.java @@ -19,7 +19,7 @@ public class SkullBlockType implements BlockType { } public SkullBlockType(Block block) { - value = MMOLib.plugin.getNMS().getSkullValue(block); + value = MMOLib.plugin.getVersion().getWrapper().getSkullValue(block); } public String getValue() { @@ -34,7 +34,7 @@ public class SkullBlockType implements BlockType { if (MMOCoreUtils.isPlayerHead(block.getBlockData().getMaterial()) && MMOLib.plugin.getVersion().isStrictlyHigher(1, 12)) loc.getBlock().setBlockData(block.getBlockData()); - MMOLib.plugin.getNMS().setSkullValue(loc.getBlock(), value); + MMOLib.plugin.getVersion().getWrapper().setSkullValue(loc.getBlock(), value); } @Override diff --git a/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttribute.java b/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttribute.java index 76da07ad..8465e394 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttribute.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttribute.java @@ -8,7 +8,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.configuration.ConfigurationSection; import net.Indyuce.mmocore.MMOCore; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.stat.modifier.StatModifier; public class PlayerAttribute { @@ -25,9 +25,7 @@ public class PlayerAttribute { Validate.notNull(config, "Could not load config"); id = config.getName().toLowerCase().replace("_", "-").replace(" ", "-"); - name = config.getString("name"); - Validate.isTrue(name != null && !name.isEmpty(), "Could not read name"); - + name = MMOLib.plugin.parseColors(config.getString("name", "Attribute")); max = config.contains("max-points") ? Math.max(1, config.getInt("max-points")) : 0; if (config.contains("buff")) @@ -45,7 +43,7 @@ public class PlayerAttribute { } public String getName() { - return new ColorParse('&', name).toChatColor(); + return name; } public boolean hasMax() { diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java index 2ba25795..f8898f31 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java @@ -37,8 +37,8 @@ import net.Indyuce.mmocore.api.skill.Skill.SkillInfo; import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.math.formula.LinearValue; import net.Indyuce.mmocore.api.util.math.particle.CastingParticle; -import net.asangarin.hexcolors.ColorParse; import net.md_5.bungee.api.ChatColor; +import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.MMOLineConfig; import net.mmogroup.mmolib.version.VersionMaterial; @@ -65,7 +65,7 @@ public class PlayerClass extends PostLoadObject { this.id = id.toUpperCase().replace("-", "_").replace(" ", "_"); - name = new ColorParse('&', config.getString("display.name")).toChatColor(); + name = MMOLib.plugin.parseColors(config.getString("display.name")); icon = MMOCoreUtils.readIcon(config.getString("display.item", "BARRIER")); if (config.contains("display.texture") && icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) @@ -83,9 +83,9 @@ public class PlayerClass extends PostLoadObject { } for (String string : config.getStringList("display.lore")) - description.add(ChatColor.GRAY + new ColorParse('&', string).toChatColor()); + description.add(ChatColor.GRAY + MMOLib.plugin.parseColors(string)); for (String string : config.getStringList("display.attribute-lore")) - attrDescription.add(ChatColor.GRAY + new ColorParse('&', string).toChatColor()); + attrDescription.add(ChatColor.GRAY + MMOLib.plugin.parseColors(string)); manaDisplay = config.contains("mana") ? new ManaDisplayOptions(config.getConfigurationSection("mana")) : ManaDisplayOptions.DEFAULT; maxLevel = config.getInt("max-level"); diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/resource/ManaDisplayOptions.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/resource/ManaDisplayOptions.java index bdab062a..616045be 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/resource/ManaDisplayOptions.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/resource/ManaDisplayOptions.java @@ -5,6 +5,7 @@ import org.bukkit.configuration.ConfigurationSection; import net.asangarin.hexcolors.ColorParse; import net.md_5.bungee.api.ChatColor; +import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.util.AltChar; public class ManaDisplayOptions { @@ -30,7 +31,7 @@ public class ManaDisplayOptions { Validate.notEmpty(format, "Could not load mana bar character"); barCharacter = format.charAt(0); - icon = new ColorParse('&', config.getString("icon", "")).toChatColor(); + icon = MMOLib.plugin.parseColors(config.getString("icon", "")); Validate.notEmpty(format, "Could not load mana action bar icon"); } diff --git a/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java b/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java index c73939aa..62ada386 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java @@ -1,6 +1,7 @@ package net.Indyuce.mmocore.api.player.stats; import net.Indyuce.mmocore.api.player.PlayerData; +import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.stat.StatInstance; import net.mmogroup.mmolib.api.stat.StatMap; import net.mmogroup.mmolib.api.stat.modifier.StatModifier; @@ -8,8 +9,10 @@ import net.mmogroup.mmolib.api.stat.modifier.StatModifier; public class PlayerStats { private final PlayerData data; - /* - * util class to manipulate more easily stat data from MMOLib + /** + * Utilclass to easily manipulate the MMOLib stat map + * + * @param data */ public PlayerStats(PlayerData data) { this.data = data; @@ -24,7 +27,7 @@ public class PlayerStats { } public StatInstance getInstance(StatType stat) { - return getInstance(stat.name()); + return getMap().getInstance(stat.name()); } public StatInstance getInstance(String stat) { @@ -47,17 +50,18 @@ public class PlayerStats { * used to update MMOCore stat modifiers due to class and send them over to * MMOLib. must be ran everytime the player levels up or changes class. */ + @SuppressWarnings("deprecation") public void updateStats() { getMap().getInstances().forEach(ins -> ins.removeIf(key -> key.equals("mmocoreClass"))); for (StatType stat : StatType.values()) { StatInstance instance = getMap().getInstance(stat.name()); - double total = getBase(stat) - instance.getVanilla(); + double total = getBase(stat) - instance.getBase(); if (total != 0) instance.addModifier("mmocoreClass", new StatModifier(total)); } - getMap().updateAll(); + MMOLib.plugin.getStats().runUpdates(getMap()); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java b/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java index e5bb6953..1ae950d9 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java @@ -2,7 +2,7 @@ package net.Indyuce.mmocore.api.quest; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.quest.objective.Objective; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; public class QuestProgress { private final Quest quest; @@ -60,6 +60,6 @@ public class QuestProgress { } public String getFormattedLore() { - return new ColorParse('&', objectiveProgress.formatLore(objectiveProgress.getObjective().getDefaultLore())).toChatColor(); + return MMOLib.plugin.parseColors(objectiveProgress.formatLore(objectiveProgress.getObjective().getDefaultLore())); } } \ No newline at end of file diff --git a/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java b/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java index a637ca6a..90af35ee 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java @@ -63,7 +63,7 @@ public class MMOCoreUtils { int t = 0; for (ItemStack item : items) if (item != null && item.getType() != Material.AIR) - t += MMOLib.plugin.getNMS().getNBTItem(item).getInteger("RpgWorth") * item.getAmount(); + t += MMOLib.plugin.getVersion().getWrapper().getNBTItem(item).getInteger("RpgWorth") * item.getAmount(); return t; } diff --git a/src/main/java/net/Indyuce/mmocore/api/util/input/AnvilGUI.java b/src/main/java/net/Indyuce/mmocore/api/util/input/AnvilGUI.java index a8e4bddb..2af41a61 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/input/AnvilGUI.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/input/AnvilGUI.java @@ -26,25 +26,25 @@ public class AnvilGUI extends PlayerInput { paperMeta.setDisplayName(MMOCore.plugin.configManager.getSimpleMessage("player-input.anvil." + type.getLowerCaseName()).message()); paper.setItemMeta(paperMeta); - MMOLib.plugin.getNMS().handleInventoryCloseEvent(player); - MMOLib.plugin.getNMS().setActiveContainerDefault(player); + MMOLib.plugin.getVersion().getWrapper().handleInventoryCloseEvent(player); + MMOLib.plugin.getVersion().getWrapper().setActiveContainerDefault(player); - final Object container = MMOLib.plugin.getNMS().newContainerAnvil(player); + final Object container = MMOLib.plugin.getVersion().getWrapper().newContainerAnvil(player); - inventory = MMOLib.plugin.getNMS().toBukkitInventory(container); + inventory = MMOLib.plugin.getVersion().getWrapper().toBukkitInventory(container); inventory.setItem(0, paper); - containerId = MMOLib.plugin.getNMS().getNextContainerId(player); - MMOLib.plugin.getNMS().sendPacketOpenWindow(player, containerId); - MMOLib.plugin.getNMS().setActiveContainer(player, container); - MMOLib.plugin.getNMS().setActiveContainerId(container, containerId); - MMOLib.plugin.getNMS().addActiveContainerSlotListener(container, player); + containerId = MMOLib.plugin.getVersion().getWrapper().getNextContainerId(player); + MMOLib.plugin.getVersion().getWrapper().sendPacketOpenWindow(player, containerId); + MMOLib.plugin.getVersion().getWrapper().setActiveContainer(player, container); + MMOLib.plugin.getVersion().getWrapper().setActiveContainerId(container, containerId); + MMOLib.plugin.getVersion().getWrapper().addActiveContainerSlotListener(container, player); } public void close() { - MMOLib.plugin.getNMS().handleInventoryCloseEvent(getPlayer()); - MMOLib.plugin.getNMS().setActiveContainerDefault(getPlayer()); - MMOLib.plugin.getNMS().sendPacketCloseWindow(getPlayer(), containerId); + MMOLib.plugin.getVersion().getWrapper().handleInventoryCloseEvent(getPlayer()); + MMOLib.plugin.getVersion().getWrapper().setActiveContainerDefault(getPlayer()); + MMOLib.plugin.getVersion().getWrapper().sendPacketCloseWindow(getPlayer(), containerId); InventoryClickEvent.getHandlerList().unregister(this); InventoryCloseEvent.getHandlerList().unregister(this); diff --git a/src/main/java/net/Indyuce/mmocore/api/util/item/ConfigItem.java b/src/main/java/net/Indyuce/mmocore/api/util/item/ConfigItem.java index fb6c018f..9a3fe6b7 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/item/ConfigItem.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/item/ConfigItem.java @@ -19,7 +19,6 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import net.Indyuce.mmocore.MMOCore; -import net.asangarin.hexcolors.ColorParse; import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.NBTItem; @@ -102,6 +101,7 @@ public class ConfigItem { return build(1); } + @SuppressWarnings("deprecation") public ItemStack build(int amount) { ItemStack item = getItem(amount); ItemMeta meta = item.getItemMeta(); @@ -138,6 +138,6 @@ public class ConfigItem { for (String placeholder : placeholders.keySet()) if (string.contains("{" + placeholder + "}")) string = string.replace("{" + placeholder + "}", "" + placeholders.get(placeholder)); - return new ColorParse('&', string).toChatColor(); + return MMOLib.plugin.parseColors(string); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/util/item/NamedItemStack.java b/src/main/java/net/Indyuce/mmocore/api/util/item/NamedItemStack.java index 6121bd97..f8db7dcd 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/item/NamedItemStack.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/item/NamedItemStack.java @@ -4,14 +4,14 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; public class NamedItemStack extends ItemStack { public NamedItemStack(Material material, String name) { super(material); ItemMeta meta = getItemMeta(); - meta.setDisplayName(new ColorParse('&', name).toChatColor()); + meta.setDisplayName(MMOLib.plugin.parseColors(name)); setItemMeta(meta); } } diff --git a/src/main/java/net/Indyuce/mmocore/command/rpg/booster/ListCommandMap.java b/src/main/java/net/Indyuce/mmocore/command/rpg/booster/ListCommandMap.java index 60cd055c..07b92b1d 100644 --- a/src/main/java/net/Indyuce/mmocore/command/rpg/booster/ListCommandMap.java +++ b/src/main/java/net/Indyuce/mmocore/command/rpg/booster/ListCommandMap.java @@ -24,7 +24,7 @@ public class ListCommandMap extends CommandEnd { sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------"); for (Booster booster : MMOCore.plugin.boosterManager.getBoosters()) if (!booster.isTimedOut()) - MMOLib.plugin.getNMS().sendJson((Player) sender, "{\"text\":\"" + ChatColor.YELLOW + "- " + ChatColor.GOLD + MMOCore.plugin.configManager.decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - " + ChatColor.GOLD + (!booster.hasProfession() ? "ExploreAttributesCommand" : booster.getProfession().getName()) + ChatColor.YELLOW + " - " + ChatColor.GOLD + new DelayFormat().format(booster.getCreationDate() + booster.getLength() - System.currentTimeMillis()) + "\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/mmocore booster remove " + booster.getUniqueId().toString() + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to remove.\"}}}"); + MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender, "{\"text\":\"" + ChatColor.YELLOW + "- " + ChatColor.GOLD + MMOCore.plugin.configManager.decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - " + ChatColor.GOLD + (!booster.hasProfession() ? "ExploreAttributesCommand" : booster.getProfession().getName()) + ChatColor.YELLOW + " - " + ChatColor.GOLD + new DelayFormat().format(booster.getCreationDate() + booster.getLength() - System.currentTimeMillis()) + "\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/mmocore booster remove " + booster.getUniqueId().toString() + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to remove.\"}}}"); sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------"); return CommandResult.SUCCESS; diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/Lootsplosion.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/Lootsplosion.java index a4bc7220..e9b3ca0a 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/Lootsplosion.java +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/Lootsplosion.java @@ -70,7 +70,7 @@ public class Lootsplosion implements Listener { if (colored) Bukkit.getScheduler().runTask(MMOCore.plugin, () -> { - NBTItem nbt = MMOLib.plugin.getNMS().getNBTItem(item.getItemStack()); + NBTItem nbt = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item.getItemStack()); if (nbt.hasTag("MMOITEMS_TIER")) { ItemTier tier = MMOItems.plugin.getTiers().get(nbt.getString("MMOITEMS_TIER")); if (tier.hasColor()) diff --git a/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java b/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java index a9b55887..ee82d3d4 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java +++ b/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java @@ -2,11 +2,12 @@ package net.Indyuce.mmocore.comp.placeholder; import org.bukkit.OfflinePlayer; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; public class DefaultParser implements PlaceholderParser { + @Override public String parse(OfflinePlayer player, String string) { - return new ColorParse('&', string.replace("%player%", player.getName())).toChatColor(); + return MMOLib.plugin.parseColors(string.replace("%player%", player.getName())); } } diff --git a/src/main/java/net/Indyuce/mmocore/comp/placeholder/PlaceholderAPIParser.java b/src/main/java/net/Indyuce/mmocore/comp/placeholder/PlaceholderAPIParser.java index 36a9172f..783e1698 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/placeholder/PlaceholderAPIParser.java +++ b/src/main/java/net/Indyuce/mmocore/comp/placeholder/PlaceholderAPIParser.java @@ -3,7 +3,7 @@ package net.Indyuce.mmocore.comp.placeholder; import org.bukkit.OfflinePlayer; import me.clip.placeholderapi.PlaceholderAPI; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; public class PlaceholderAPIParser implements PlaceholderParser { public PlaceholderAPIParser() { @@ -12,6 +12,6 @@ public class PlaceholderAPIParser implements PlaceholderParser { @Override public String parse(OfflinePlayer player, String string) { - return new ColorParse('&', PlaceholderAPI.setPlaceholders(player, string.replace("%player%", player.getName()))).toChatColor(); + return MMOLib.plugin.parseColors(PlaceholderAPI.setPlaceholders(player, string.replace("%player%", player.getName()))); } } diff --git a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java index eac3757a..38be11e2 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java +++ b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java @@ -23,7 +23,7 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem; import net.Indyuce.mmocore.manager.InventoryManager; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.NBTItem; @@ -68,7 +68,7 @@ public class ClassSelect extends EditableInventory { ItemMeta meta = item.getItemMeta(); if (hideFlags()) meta.addItemFlags(ItemFlag.values()); - meta.setDisplayName(new ColorParse('&', name).toChatColor().replace("{name}", profess.getName())); + meta.setDisplayName(MMOLib.plugin.parseColors(name).replace("{name}", profess.getName())); List lore = new ArrayList<>(this.lore); int index = lore.indexOf("{lore}"); diff --git a/src/main/java/net/Indyuce/mmocore/gui/SkillList.java b/src/main/java/net/Indyuce/mmocore/gui/SkillList.java index 211017a2..9e3e383b 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/SkillList.java +++ b/src/main/java/net/Indyuce/mmocore/gui/SkillList.java @@ -27,7 +27,7 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem; import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem; import net.Indyuce.mmocore.gui.api.item.Placeholders; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.NBTItem; @@ -71,7 +71,7 @@ public class SkillList extends EditableInventory { if (function.equals("slot")) return new InventoryPlaceholderItem(config) { - private final String none = new ColorParse('&', config.getString("no-skill")).toChatColor(); + private final String none = MMOLib.plugin.parseColors(config.getString("no-skill")); private final Material emptyMaterial = Material .valueOf(config.getString("empty-item").toUpperCase().replace("-", "_").replace(" ", "_")); @@ -170,12 +170,12 @@ public class SkillList extends EditableInventory { lore.add(index + j, skillLore.get(j)); for (int j = 0; j < lore.size(); j++) - lore.set(j, ChatColor.GRAY + new ColorParse('&', lore.get(j)).toChatColor()); + lore.set(j, ChatColor.GRAY + MMOLib.plugin.parseColors(lore.get(j))); ItemStack item = cloneItem(); ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(new ColorParse('&', getName().replace("{skill}", skill.getSkill().getName()) - .replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel)).toChatColor()); + meta.setDisplayName(MMOLib.plugin.parseColors(getName().replace("{skill}", skill.getSkill().getName()) + .replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel))); meta.addItemFlags(ItemFlag.values()); meta.setLore(lore); item.setItemMeta(meta); diff --git a/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java b/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java index ab867b50..a43db96c 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java +++ b/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java @@ -20,7 +20,7 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem; import net.Indyuce.mmocore.manager.InventoryManager; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.NBTItem; @@ -65,7 +65,7 @@ public class SubclassSelect extends EditableInventory { ItemStack item = profess.getIcon(); ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(new ColorParse('&', name).toChatColor().replace("{name}", profess.getName())); + meta.setDisplayName(MMOLib.plugin.parseColors(name).replace("{name}", profess.getName())); List lore = new ArrayList<>(this.lore); int index = lore.indexOf("{lore}"); diff --git a/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java b/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java index d1595869..24a2b29b 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java +++ b/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java @@ -10,7 +10,7 @@ import org.bukkit.inventory.Inventory; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.TriggerItem; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; public abstract class GeneratedInventory extends PluginInventory { private final EditableInventory editable; @@ -54,7 +54,7 @@ public abstract class GeneratedInventory extends PluginInventory { @Override public Inventory getInventory() { - Inventory inv = Bukkit.createInventory(this, editable.getSlots(), new ColorParse('&', calculateName()).toChatColor()); + Inventory inv = Bukkit.createInventory(this, editable.getSlots(), MMOLib.plugin.parseColors(calculateName())); for (InventoryItem item : editable.getItems()) if (item.canDisplay(this)) diff --git a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java index d018f919..4b663ddb 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java @@ -20,7 +20,7 @@ import net.Indyuce.mmocore.api.util.input.AnvilGUI; import net.Indyuce.mmocore.api.util.input.ChatInput; import net.Indyuce.mmocore.api.util.input.PlayerInput; import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType; -import net.asangarin.hexcolors.ColorParse; +import net.mmogroup.mmolib.MMOLib; public class ConfigManager { @@ -157,7 +157,7 @@ public class ConfigManager { String format = messages.getString(key, ""); for (int j = 0; j < placeholders.length - 1; j += 2) format = format.replace("{" + placeholders[j] + "}", placeholders[j + 1]); - return new SimpleMessage(new ColorParse('&', format).toChatColor()); + return new SimpleMessage(MMOLib.plugin.parseColors(format)); } public class SimpleMessage { diff --git a/src/main/java/net/Indyuce/mmocore/skill/Ambers.java b/src/main/java/net/Indyuce/mmocore/skill/Ambers.java index 4133ea06..e2eee1cb 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Ambers.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Ambers.java @@ -18,6 +18,7 @@ import net.Indyuce.mmocore.api.skill.SkillResult; import net.Indyuce.mmocore.api.util.math.formula.LinearValue; import net.Indyuce.mmocore.api.util.math.particle.ParabolicProjectile; import net.mmogroup.mmolib.MMOLib; +import net.mmogroup.mmolib.api.DamageType; import net.mmogroup.mmolib.api.event.PlayerAttackEvent; public class Ambers extends Skill implements Listener { @@ -38,7 +39,7 @@ public class Ambers extends Skill implements Listener { @EventHandler public void a(PlayerAttackEvent event) { PlayerData data = event.getData().getMMOCore(); - if (event.isWeapon() || !data.getProfess().hasSkill(this)) + if (!event.getAttack().hasType(DamageType.SKILL) || !data.getProfess().hasSkill(this)) return; SkillResult cast = data.cast(this); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Backstab.java b/src/main/java/net/Indyuce/mmocore/skill/Backstab.java index f4a20817..64a21411 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Backstab.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Backstab.java @@ -10,6 +10,7 @@ import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.skill.Skill; import net.Indyuce.mmocore.api.skill.SkillResult; import net.Indyuce.mmocore.api.util.math.formula.LinearValue; +import net.mmogroup.mmolib.api.DamageType; import net.mmogroup.mmolib.api.event.PlayerAttackEvent; public class Backstab extends Skill { @@ -28,7 +29,9 @@ public class Backstab extends Skill { public void a(PlayerAttackEvent event) { PlayerData data = event.getData().getMMOCore(); LivingEntity target = (LivingEntity) event.getEntity(); - if (!event.isWeapon() || data.isInCombat() || event.getPlayer().getEyeLocation().getDirection().angle(target.getEyeLocation().getDirection()) > Math.PI / 6 || !data.getProfess().hasSkill(this)) + if (data.isInCombat() || !event.getAttack().hasType(DamageType.WEAPON) + || event.getPlayer().getEyeLocation().getDirection().angle(target.getEyeLocation().getDirection()) > Math.PI / 6 + || !data.getProfess().hasSkill(this)) return; SkillResult cast = data.cast(this); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java b/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java index ebfeb35b..1f71898b 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java @@ -81,7 +81,7 @@ public class Empowered_Attack extends Skill { @EventHandler public void a(PlayerAttackEvent event) { - if (event.getPlayer().equals(player.getPlayer()) && event.isWeapon()) { + if (event.getPlayer().equals(player.getPlayer()) && event.getAttack().hasType(DamageType.WEAPON)) { close(); Entity target = event.getEntity(); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Evade.java b/src/main/java/net/Indyuce/mmocore/skill/Evade.java index 0d8e1a25..b74a929b 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Evade.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Evade.java @@ -15,6 +15,7 @@ import net.Indyuce.mmocore.api.skill.Skill; import net.Indyuce.mmocore.api.skill.SkillResult; import net.Indyuce.mmocore.api.util.math.formula.LinearValue; import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect; +import net.mmogroup.mmolib.api.DamageType; import net.mmogroup.mmolib.api.event.PlayerAttackEvent; import net.mmogroup.mmolib.version.VersionSound; @@ -22,7 +23,8 @@ public class Evade extends Skill { public Evade() { super(); setMaterial(Material.LEATHER_BOOTS); - setLore("You become imune to damage for &8{duration} &7seconds.", "Cancels when dealing weapon damage.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}"); + setLore("You become imune to damage for &8{duration} &7seconds.", "Cancels when dealing weapon damage.", "", "&e{cooldown}s Cooldown", + "&9Costs {mana} {mana_name}"); addModifier("cooldown", new LinearValue(20, 0)); addModifier("mana", new LinearValue(8, 3)); @@ -65,7 +67,7 @@ public class Evade extends Skill { @EventHandler(priority = EventPriority.HIGHEST) public void b(PlayerAttackEvent event) { - if (event.isWeapon() && !event.isCancelled() && event.getData().getMMOCore().equals(data)) + if (event.getAttack().hasType(DamageType.WEAPON) && !event.isCancelled() && event.getData().getMMOCore().equals(data)) close(); } diff --git a/src/main/java/net/Indyuce/mmocore/skill/Fire_Rage.java b/src/main/java/net/Indyuce/mmocore/skill/Fire_Rage.java index 20eee0db..355e0f88 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Fire_Rage.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Fire_Rage.java @@ -131,7 +131,7 @@ public class Fire_Rage extends Skill { loc.getWorld().spawnParticle(Particle.LAVA, loc, 0); for (Entity target : MMOCoreUtils.getNearbyChunkEntities(loc)) - if (MMOLib.plugin.getNMS().isInBoundingBox(target, loc) && MMOCoreUtils.canTarget(data, target)) { + if (MMOLib.plugin.getVersion().getWrapper().isInBoundingBox(target, loc) && MMOCoreUtils.canTarget(data, target)) { loc.getWorld().spawnParticle(Particle.LAVA, loc, 8); loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1); loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Fireball.java b/src/main/java/net/Indyuce/mmocore/skill/Fireball.java index 8e56c14a..ff5d59f3 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Fireball.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Fireball.java @@ -60,7 +60,7 @@ public class Fireball extends Skill { loc.getWorld().spawnParticle(Particle.LAVA, loc, 0); for (Entity target : MMOCoreUtils.getNearbyChunkEntities(loc)) - if (MMOLib.plugin.getNMS().isInBoundingBox(target, loc) && MMOCoreUtils.canTarget(data, target)) { + if (MMOLib.plugin.getVersion().getWrapper().isInBoundingBox(target, loc) && MMOCoreUtils.canTarget(data, target)) { loc.getWorld().spawnParticle(Particle.LAVA, loc, 8); loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1); loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java b/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java index bed7617b..553e4beb 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java @@ -47,7 +47,7 @@ public class Power_Mark extends Skill implements Listener { @EventHandler public void a(PlayerAttackEvent event) { PlayerData data = event.getData().getMMOCore(); - if (!event.isWeapon() || !data.getProfess().hasSkill(this)) + if (!event.getAttack().hasType(DamageType.WEAPON) || !data.getProfess().hasSkill(this)) return; SkillResult cast = data.cast(this); diff --git a/src/main/java/net/Indyuce/mmocore/skill/Sneaky_Picky.java b/src/main/java/net/Indyuce/mmocore/skill/Sneaky_Picky.java index 74a0774a..6014012b 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Sneaky_Picky.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Sneaky_Picky.java @@ -10,6 +10,7 @@ import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.skill.Skill; import net.Indyuce.mmocore.api.skill.SkillResult; import net.Indyuce.mmocore.api.util.math.formula.LinearValue; +import net.mmogroup.mmolib.api.DamageType; import net.mmogroup.mmolib.api.event.PlayerAttackEvent; public class Sneaky_Picky extends Skill { @@ -27,7 +28,7 @@ public class Sneaky_Picky extends Skill { @EventHandler public void a(PlayerAttackEvent event) { PlayerData data = event.getData().getMMOCore(); - if (!event.isWeapon() || data.isInCombat() || !data.getProfess().hasSkill(this)) + if (!event.getAttack().hasType(DamageType.WEAPON) || data.isInCombat() || !data.getProfess().hasSkill(this)) return; SkillResult cast = data.cast(this);