From 529138be864bf822b3d370222c87b252af6a343e Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Sat, 25 Nov 2023 11:18:44 +0800 Subject: [PATCH] chore(provider): implemented suggestion --- .../slimefun4/api/researches/Research.java | 11 ++++++++++- .../guide/unlockprovider/CurrencyUnlockProvider.java | 2 +- .../unlockprovider/ExperienceUnlockProvider.java | 2 +- src/main/resources/config.yml | 1 + src/main/resources/languages/en/messages.yml | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java index 585bc710d4..3273550b83 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java @@ -198,6 +198,15 @@ public void setCost(int cost) { this.cost = cost; } + /** + * Set the custom {@link SlimefunGuideUnlockProvider} of this {@link Research} + * + * @param unlockProvider custom unlock provider {@link SlimefunGuideUnlockProvider} + */ + public void setUnlockProvider(Optional unlockProvider) { + this.unlockProvider = unlockProvider; + } + /** * Bind the specified {@link SlimefunItem SlimefunItems} to this {@link Research}. * @@ -274,7 +283,7 @@ public void unlockFromGuide(SlimefunGuideImplementation guide, Player player, Pl if (this.canUnlock(player)) { guide.unlockItem(player, sfItem, pl -> guide.openItemGroup(profile, itemGroup, page)); } else { - Slimefun.getLocalization().sendMessage(player, "messages.not-meet-requirement", true); + Slimefun.getLocalization().sendMessage(player, "messages.requirement-unfulfilled", true); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/unlockprovider/CurrencyUnlockProvider.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/unlockprovider/CurrencyUnlockProvider.java index 1b06dc04f5..feaff24f81 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/unlockprovider/CurrencyUnlockProvider.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/unlockprovider/CurrencyUnlockProvider.java @@ -14,7 +14,7 @@ * * @see SlimefunGuideUnlockProvider */ -public final class CurrencyUnlockProvider implements SlimefunGuideUnlockProvider { +public class CurrencyUnlockProvider implements SlimefunGuideUnlockProvider { @Override public boolean canUnlock(@Nonnull Research research, @Nonnull Player p) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/unlockprovider/ExperienceUnlockProvider.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/unlockprovider/ExperienceUnlockProvider.java index 57cde5b870..a3fecedd4d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/unlockprovider/ExperienceUnlockProvider.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/unlockprovider/ExperienceUnlockProvider.java @@ -14,7 +14,7 @@ * * @see SlimefunGuideUnlockProvider */ -public final class ExperienceUnlockProvider implements SlimefunGuideUnlockProvider { +public class ExperienceUnlockProvider implements SlimefunGuideUnlockProvider { @Override public boolean canUnlock(@Nonnull Research research, @Nonnull Player p) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5652a1e995..027a9a2096 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -31,6 +31,7 @@ researches: free-in-creative-mode: true enable-fireworks: true disable-learning-animation: false + # Currently we have those research mode: EXPERIENCE, CURRENCY unlock-research-mode: EXPERIENCE URID: diff --git a/src/main/resources/languages/en/messages.yml b/src/main/resources/languages/en/messages.yml index 711e965ed7..9e11b21d20 100644 --- a/src/main/resources/languages/en/messages.yml +++ b/src/main/resources/languages/en/messages.yml @@ -154,7 +154,7 @@ actionbar: messages: not-researched: '&4You do not have enough knowledge to understand this. &cYou will need to unlock &f"%item%&f"' - not-meet-requirement: '&4You do not meet the requirement to unlock this' + requirement-unfulfilled: '&4You do not meet the requirement to unlock this' unlocked: '&bYou have unlocked &7"%research%"' only-players: '&4This command is only for Players' unknown-player: '&4Unknown Player: &c%player%'