From db78c8d9c385b1fdf33260b505b95914556ab849 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Thu, 18 Aug 2022 23:15:39 +0200 Subject: [PATCH] Changed to ML placeholder parser --- MMOItems-API/src/main/java/net/Indyuce/mmoitems/MMOItems.java | 2 ++ .../Indyuce/mmoitems/api/crafting/trigger/MessageTrigger.java | 4 ++-- .../java/net/Indyuce/mmoitems/api/interaction/UseItem.java | 2 +- .../comp/parse/placeholders/DefaultPlaceholderParser.java | 2 ++ .../comp/parse/placeholders/PlaceholderAPIParser.java | 3 ++- .../mmoitems/comp/parse/placeholders/PlaceholderParser.java | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/MMOItems.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/MMOItems.java index 0f20a109..368e1f3a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/MMOItems.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/MMOItems.java @@ -88,6 +88,7 @@ public class MMOItems extends JavaPlugin { private TierManager tierManager; private SetManager setManager; + @Deprecated private PlaceholderParser placeholderParser = new DefaultPlaceholderParser(); private VaultSupport vaultSupport; private RPGHandler rpgPlugin; @@ -513,6 +514,7 @@ public class MMOItems extends JavaPlugin { return upgradeManager; } + @Deprecated public PlaceholderParser getPlaceholderParser() { return placeholderParser; } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/crafting/trigger/MessageTrigger.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/crafting/trigger/MessageTrigger.java index f2c4d550..c444d4e1 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/crafting/trigger/MessageTrigger.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/crafting/trigger/MessageTrigger.java @@ -1,6 +1,6 @@ package net.Indyuce.mmoitems.api.crafting.trigger; -import net.Indyuce.mmoitems.MMOItems; +import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmoitems.api.player.PlayerData; import io.lumine.mythic.lib.api.MMOLineConfig; @@ -17,6 +17,6 @@ public class MessageTrigger extends Trigger { @Override public void whenCrafting(PlayerData data) { if(!data.isOnline()) return; - data.getPlayer().sendMessage(MMOItems.plugin.getPlaceholderParser().parse(data.getPlayer(), message)); + data.getPlayer().sendMessage(MythicLib.plugin.getPlaceholderParser().parse(data.getPlayer(), message)); } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/UseItem.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/UseItem.java index d8160590..b00c0c52 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/UseItem.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/UseItem.java @@ -83,7 +83,7 @@ public class UseItem { * @param command Command to execute */ private void scheduleCommandExecution(CommandData command) { - String parsed = MMOItems.plugin.getPlaceholderParser().parse(player, command.getCommand()); + String parsed = MythicLib.plugin.getPlaceholderParser().parse(player, command.getCommand()); if (!command.hasDelay()) dispatchCommand(parsed, command.isConsoleCommand(), command.hasOpPerms()); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/DefaultPlaceholderParser.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/DefaultPlaceholderParser.java index b190876f..e0c193f9 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/DefaultPlaceholderParser.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/DefaultPlaceholderParser.java @@ -2,7 +2,9 @@ package net.Indyuce.mmoitems.comp.parse.placeholders; import org.bukkit.OfflinePlayer; +@Deprecated public class DefaultPlaceholderParser implements PlaceholderParser { + @Override public String parse(OfflinePlayer player, String string) { return string.replace("%player%", player.getName()); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/PlaceholderAPIParser.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/PlaceholderAPIParser.java index 62282701..03dc8580 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/PlaceholderAPIParser.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/PlaceholderAPIParser.java @@ -5,6 +5,7 @@ import org.bukkit.OfflinePlayer; import me.clip.placeholderapi.PlaceholderAPI; import io.lumine.mythic.lib.MythicLib; +@Deprecated public class PlaceholderAPIParser implements PlaceholderParser { public PlaceholderAPIParser() { new MMOItemsPlaceholders().register(); @@ -12,6 +13,6 @@ public class PlaceholderAPIParser implements PlaceholderParser { @Override public String parse(OfflinePlayer player, String string) { - return MythicLib.plugin.parseColors(PlaceholderAPI.setPlaceholders(player, string.replace("%player%", player.getName()))); + return MythicLib.plugin.parseColors(PlaceholderAPI.setPlaceholders(player, string)); } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/PlaceholderParser.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/PlaceholderParser.java index 301afe10..f08edfe6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/PlaceholderParser.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/parse/placeholders/PlaceholderParser.java @@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.comp.parse.placeholders; import org.bukkit.OfflinePlayer; +@Deprecated public interface PlaceholderParser { String parse(OfflinePlayer player, String string); }