From b150817964a0f5b9585222f8fc3019cfff9763b5 Mon Sep 17 00:00:00 2001 From: Jules Date: Fri, 24 May 2024 19:42:08 -0700 Subject: [PATCH] Default configs no longer use %player% --- .../net/Indyuce/mmocore/api/quest/trigger/CommandTrigger.java | 3 +++ .../mmocore/api/quest/trigger/LevelUpSkillTrigger.java | 4 +--- .../net/Indyuce/mmocore/api/quest/trigger/MessageTrigger.java | 3 +++ .../net/Indyuce/mmocore/comp/placeholder/DefaultParser.java | 3 +++ MMOCore-Dist/src/main/resources/default/exp-tables.yml | 2 +- .../src/main/resources/default/quests/fetch-mango.yml | 2 +- MMOCore-Dist/src/main/resources/default/quests/tutorial.yml | 2 +- 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/CommandTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/CommandTrigger.java index d08dd453..2df9e7e9 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/CommandTrigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/CommandTrigger.java @@ -1,5 +1,6 @@ package net.Indyuce.mmocore.api.quest.trigger; +import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import org.bukkit.Bukkit; @@ -23,7 +24,9 @@ public class CommandTrigger extends Trigger { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), format(player.getPlayer())); } + @BackwardsCompatibility(version = "1.12-SNAPSHOT") private String format(Player player) { + // TODO remove use of confusing non-PAPI %player% placeholder return MMOCore.plugin.placeholderParser.parse(player, command.replace("%player%", player.getName())); } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/LevelUpSkillTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/LevelUpSkillTrigger.java index db1ce9e9..0bf14b7e 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/LevelUpSkillTrigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/LevelUpSkillTrigger.java @@ -6,8 +6,6 @@ import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.quest.trigger.api.Removable; import net.Indyuce.mmocore.skill.RegisteredSkill; -import java.util.Objects; - public class LevelUpSkillTrigger extends Trigger implements Removable { private final RegisteredSkill skill; private final int amount; @@ -17,7 +15,7 @@ public class LevelUpSkillTrigger extends Trigger implements Removable { config.validateKeys("skill", "amount"); amount = config.getInt("amount"); - skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(config.getString("skill"))); + skill = MMOCore.plugin.skillManager.getSkillOrThrow(config.getString("skill")); } @Override diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/MessageTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/MessageTrigger.java index cad8f4c4..55f56fd1 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/MessageTrigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/MessageTrigger.java @@ -1,5 +1,6 @@ package net.Indyuce.mmocore.api.quest.trigger; +import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import org.bukkit.entity.Player; @@ -22,7 +23,9 @@ public class MessageTrigger extends Trigger { player.getPlayer().sendMessage(format(player.getPlayer())); } + @BackwardsCompatibility(version = "1.12-SNAPSHOT") private String format(Player player) { + // TODO remove use of confusing non-PAPI %player% placeholder return MMOCore.plugin.placeholderParser.parse(player, message.replace("%player%", player.getName())); } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java index a1529c1a..3ddd064a 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java @@ -1,5 +1,6 @@ package net.Indyuce.mmocore.comp.placeholder; +import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import org.bukkit.OfflinePlayer; import io.lumine.mythic.lib.MythicLib; @@ -7,7 +8,9 @@ import io.lumine.mythic.lib.MythicLib; public class DefaultParser implements PlaceholderParser { @Override + @BackwardsCompatibility(version = "1.12-SNAPSHOT") public String parse(OfflinePlayer player, String string) { + // TODO remove use of confusing non-PAPI %player% placeholder return MythicLib.plugin.parseColors(string.replace("%player%", player.getName())); } } diff --git a/MMOCore-Dist/src/main/resources/default/exp-tables.yml b/MMOCore-Dist/src/main/resources/default/exp-tables.yml index 965330cb..1fd7e355 100644 --- a/MMOCore-Dist/src/main/resources/default/exp-tables.yml +++ b/MMOCore-Dist/src/main/resources/default/exp-tables.yml @@ -47,7 +47,7 @@ class_exp_table: skill_point: period: 1 triggers: - - 'command{format="mmocore admin skill-points give %player% 1"}' + - 'command{format="mmocore admin skill-points give %player_name% 1"}' second_exp_table: diff --git a/MMOCore-Dist/src/main/resources/default/quests/fetch-mango.yml b/MMOCore-Dist/src/main/resources/default/quests/fetch-mango.yml index 530adab0..f71d4ef8 100644 --- a/MMOCore-Dist/src/main/resources/default/quests/fetch-mango.yml +++ b/MMOCore-Dist/src/main/resources/default/quests/fetch-mango.yml @@ -35,5 +35,5 @@ objectives: triggers: - message{format="&aThis looked like apple. But owell, thanks! Here are a a few coins'"} - sound{sound=ENTITY_EXPERIENCE_ORB_PICKUP;pitch=1;volume=1} - - command{format="mmocore coins %player% 10"} + - command{format="mmocore coins %player_name% 10"} - 'experience{amount=30}' diff --git a/MMOCore-Dist/src/main/resources/default/quests/tutorial.yml b/MMOCore-Dist/src/main/resources/default/quests/tutorial.yml index fd8994db..f3faaed5 100644 --- a/MMOCore-Dist/src/main/resources/default/quests/tutorial.yml +++ b/MMOCore-Dist/src/main/resources/default/quests/tutorial.yml @@ -35,7 +35,7 @@ objectives: type: 'goto{world="world";x=56;y=68;z=115;range=5}' lore: 'Head to the camp.' triggers: - - 'message{format="&aBlacksmith> &fHello, %player%! I am currently looking for some help."}' + - 'message{format="&aBlacksmith> &fHello, %player_name%! I am currently looking for some help."}' - 'message{format="&aBlacksmith> &fCould you please get me 3 oak logs?"}' - 'sound{sound=ENTITY_EXPERIENCE_ORB_PICKUP}' 2: