diff --git a/README.md b/README.md index 6730c85..669e0c5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Conditions should always have a valid operator on the left side and the limit nu Any type operators: `empty, !empty` (check if a placeholder returns empty value)\ Valid string operators: `=, !=`\ -Valid number operators: `=, !=, <, >, <=, >=`\ +Valid number operators: `=, !=, <, >, <=, >=, %`\ Valid time operators: `=, !=, <, >, <=, >=` When no condition is specified, it's automatically condidered true -- passing. \ @@ -65,7 +65,7 @@ rules: - '&7On your way to a million huh.' ``` -Since 1.1.2 you can also use placeholders in conditions. +You can also use other placeholders in conditions. ``- '<%some_placeholder%;&7Some text.'`` With strings: @@ -99,12 +99,12 @@ But first, load the new settings in with a quick `/ct reload`. Then just use the placeholder ``%conditionaltext_%`` whereever you desire. (And where PlaceholderAPI is supported) -### Extra feature - custom arguments +### Arguments in placeholders It's a useful feature when you want to use one setting for more variations of the same placeholder, for example displaying the amount of keys on multiple crates. -It would be a pain to create a setting for each of the crate types. +It would be painful to create a setting for each of the crate types. -And that's why this is a thing: +That's when arguments come in handy: ```yaml custom-arg-setting: placeholder: '%specializedcrates_virtual_keys_$0%' @@ -116,11 +116,12 @@ custom-arg-setting: ``` *Example with [Specialized crates](https://www.spigotmc.org/resources/specialized-crates-1-8-1-16.9047/)* -To provide the `$0` argument, add another param to our placeholder: ``%conditionaltext__(args)%``\ -You can add as many of them as you want! Just make sure you're **counting from 0**, because that's the right and only way to count, and seperating each one with an underscore. +To provide the `$0` argument, add another param to the placeholder: ``%conditionaltext__(args)%``\ +You can add as many of them as you want. Just make sure you're **counting from 0** and seperating each one with an underscore. For the above example with a crate named Epic to display, you'd use ``%conditionaltext_custom-arg-setting_Epic%`` +Then with a different type of crate,.. let's say Mythic: ``%conditionaltext_custom-arg-setting_Mythic%`` ### Help -For help, join [this empty discord server](https://discord.gg/5Suw58j) +For help, join [this discord server](https://discord.gg/5Suw58j) diff --git a/pom.xml b/pom.xml index 61df639..b599db2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ space.devport.wertik.conditionaltext ConditionalTextPlaceholders - 1.3.8 + 1.4.0 ConditionalTextPlaceholders @@ -44,8 +44,8 @@ true - space.devport.utils - ${project.groupId}.utils + space.devport.dock + ${project.groupId}.dock @@ -68,7 +68,7 @@ devport - https://nexus.pvpcraft.cz/repository/devport/ + https://nexus.devport.space/repository/devport-public/ placeholderapi @@ -80,31 +80,31 @@ org.spigotmc spigot-api - 1.16.5-R0.1-SNAPSHOT + 1.17.1-R0.1-SNAPSHOT provided org.jetbrains annotations - 20.1.0 + 21.0.1 compile org.projectlombok lombok - 1.18.16 + 1.18.20 provided - space.devport.utils - devportutils + space.devport.dock + dock 4.0.0-SNAPSHOT compile me.clip placeholderapi - 2.10.9 + 2.10.10 provided diff --git a/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextExpansion.java b/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextExpansion.java index 81b6540..315f94b 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextExpansion.java +++ b/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextExpansion.java @@ -40,14 +40,16 @@ public String onPlaceholderRequest(Player player, @NotNull String params) { if (Strings.isNullOrEmpty(params)) return "invalid-params"; + String[] args = params.split("_"); + Setting setting = plugin.getSettingManager().getSetting(params.split("_")[0]); if (setting == null) return "invalid-setting"; - String[] args = Arrays.copyOfRange(params.split("_"), 1, params.split("_").length); + String[] placeholderArguments = Arrays.copyOfRange(args, 1, args.length); - String output = setting.process(player, args); + String output = setting.process(player, placeholderArguments); return output == null ? plugin.getConfig().getString("empty-output", "no-match") : output; } diff --git a/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextLanguage.java b/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextLanguage.java index 73fa006..8885ff9 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextLanguage.java +++ b/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextLanguage.java @@ -1,11 +1,12 @@ package space.devport.wertik.conditionaltext; -import space.devport.utils.DevportPlugin; -import space.devport.utils.text.language.LanguageDefaults; + +import space.devport.dock.api.IDockedPlugin; +import space.devport.dock.text.language.LanguageDefaults; public class ConditionalTextLanguage extends LanguageDefaults { - public ConditionalTextLanguage(DevportPlugin plugin) { + public ConditionalTextLanguage(IDockedPlugin plugin) { super(plugin); } @@ -15,5 +16,10 @@ public void setDefaults() { addDefault("Commands.Invalid-Target", "&cPlayer &f%param% &cis invalid."); addDefault("Commands.Try.Output", "&7Parsed, result: '&r%result%&7'"); + + addDefault("Commands.List.Empty", "&7No settings yet."); + + addDefault("Commands.List.Header", "&8&m &f Loaded Settings &8&m "); + addDefault("Commands.List.Format", "&8 - &f%name% &7( &f%rules% rule(s) &7)"); } } diff --git a/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextPlugin.java b/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextPlugin.java index 10846be..e2a07e3 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextPlugin.java +++ b/src/main/java/space/devport/wertik/conditionaltext/ConditionalTextPlugin.java @@ -4,17 +4,17 @@ import lombok.extern.java.Log; import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.expansion.PlaceholderExpansion; -import space.devport.utils.DevportPlugin; -import space.devport.utils.UsageFlag; -import space.devport.utils.utility.DependencyUtil; -import space.devport.utils.utility.VersionUtil; +import space.devport.dock.DockedPlugin; +import space.devport.dock.UsageFlag; +import space.devport.dock.util.DependencyUtil; +import space.devport.dock.util.VersionUtil; import space.devport.wertik.conditionaltext.commands.ConditionalTextCommand; import space.devport.wertik.conditionaltext.system.SettingManager; import java.time.format.DateTimeFormatter; @Log -public class ConditionalTextPlugin extends DevportPlugin { +public class ConditionalTextPlugin extends DockedPlugin { @Getter private static ConditionalTextPlugin instance; diff --git a/src/main/java/space/devport/wertik/conditionaltext/commands/ConditionalTextCommand.java b/src/main/java/space/devport/wertik/conditionaltext/commands/ConditionalTextCommand.java index cf80d85..876797c 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/commands/ConditionalTextCommand.java +++ b/src/main/java/space/devport/wertik/conditionaltext/commands/ConditionalTextCommand.java @@ -1,8 +1,9 @@ package space.devport.wertik.conditionaltext.commands; -import space.devport.utils.commands.MainCommand; -import space.devport.utils.commands.struct.CommandResult; +import space.devport.dock.commands.MainCommand; +import space.devport.dock.commands.struct.CommandResult; import space.devport.wertik.conditionaltext.ConditionalTextPlugin; +import space.devport.wertik.conditionaltext.commands.subcommands.ListSubCommand; import space.devport.wertik.conditionaltext.commands.subcommands.TrySubCommand; public class ConditionalTextCommand extends MainCommand { @@ -19,6 +20,7 @@ public ConditionalTextCommand(ConditionalTextPlugin plugin) { return CommandResult.SUCCESS; })); withSubCommand(new TrySubCommand(plugin)); + withSubCommand(new ListSubCommand(plugin)); } @Override diff --git a/src/main/java/space/devport/wertik/conditionaltext/commands/ConditionalTextSubCommand.java b/src/main/java/space/devport/wertik/conditionaltext/commands/ConditionalTextSubCommand.java index 893f412..e6ab4b2 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/commands/ConditionalTextSubCommand.java +++ b/src/main/java/space/devport/wertik/conditionaltext/commands/ConditionalTextSubCommand.java @@ -2,8 +2,8 @@ import lombok.Getter; import org.jetbrains.annotations.Nullable; -import space.devport.utils.commands.SubCommand; -import space.devport.utils.commands.struct.ArgumentRange; +import space.devport.dock.commands.SubCommand; +import space.devport.dock.commands.struct.ArgumentRange; import space.devport.wertik.conditionaltext.ConditionalTextPlugin; public abstract class ConditionalTextSubCommand extends SubCommand { diff --git a/src/main/java/space/devport/wertik/conditionaltext/commands/subcommands/ListSubCommand.java b/src/main/java/space/devport/wertik/conditionaltext/commands/subcommands/ListSubCommand.java new file mode 100644 index 0000000..d2eb95f --- /dev/null +++ b/src/main/java/space/devport/wertik/conditionaltext/commands/subcommands/ListSubCommand.java @@ -0,0 +1,56 @@ +package space.devport.wertik.conditionaltext.commands.subcommands; + +import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import space.devport.dock.commands.struct.ArgumentRange; +import space.devport.dock.commands.struct.CommandResult; +import space.devport.dock.text.message.Message; +import space.devport.wertik.conditionaltext.ConditionalTextPlugin; +import space.devport.wertik.conditionaltext.commands.ConditionalTextSubCommand; +import space.devport.wertik.conditionaltext.system.struct.Setting; + +import java.util.Map; + +public class ListSubCommand extends ConditionalTextSubCommand { + + public ListSubCommand(ConditionalTextPlugin plugin) { + super(plugin, "list"); + } + + @Override + protected @NotNull CommandResult perform(@NotNull CommandSender sender, @NotNull String label, String[] args) { + + Map settings = getPlugin().getSettingManager().getSettings(); + + if (settings.isEmpty()) { + language.sendPrefixed(sender, "Commands.List.Empty"); + return CommandResult.SUCCESS; + } + + Message header = language.get("Commands.List.Header"); + String format = language.get("Commands.List.Format").toString(); + + for (Map.Entry entry : settings.entrySet()) { + header.append(format.replace("%name%", entry.getKey()).replace("%rules%", String.valueOf(entry.getValue().getRules().size()))); + } + + header.send(sender); + return CommandResult.SUCCESS; + } + + @Override + public @Nullable String getDefaultUsage() { + return "/%label% list"; + } + + @Override + public @Nullable String getDefaultDescription() { + return "List loaded settings."; + } + + @Override + public @Nullable ArgumentRange getRange() { + return new ArgumentRange(0); + } +} diff --git a/src/main/java/space/devport/wertik/conditionaltext/commands/subcommands/TrySubCommand.java b/src/main/java/space/devport/wertik/conditionaltext/commands/subcommands/TrySubCommand.java index 644dfd9..4f8ae0a 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/commands/subcommands/TrySubCommand.java +++ b/src/main/java/space/devport/wertik/conditionaltext/commands/subcommands/TrySubCommand.java @@ -6,8 +6,8 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import space.devport.utils.commands.struct.ArgumentRange; -import space.devport.utils.commands.struct.CommandResult; +import space.devport.dock.commands.struct.ArgumentRange; +import space.devport.dock.commands.struct.CommandResult; import space.devport.wertik.conditionaltext.ConditionalTextPlugin; import space.devport.wertik.conditionaltext.commands.ConditionalTextSubCommand; import space.devport.wertik.conditionaltext.system.struct.Setting; diff --git a/src/main/java/space/devport/wertik/conditionaltext/system/SettingManager.java b/src/main/java/space/devport/wertik/conditionaltext/system/SettingManager.java index 627cbb7..bd9f0ce 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/system/SettingManager.java +++ b/src/main/java/space/devport/wertik/conditionaltext/system/SettingManager.java @@ -3,8 +3,7 @@ import lombok.Getter; import lombok.extern.java.Log; import org.jetbrains.annotations.Nullable; -import space.devport.utils.configuration.Configuration; -import space.devport.utils.logging.DebugLevel; +import space.devport.dock.configuration.Configuration; import space.devport.wertik.conditionaltext.ConditionalTextPlugin; import space.devport.wertik.conditionaltext.system.struct.Setting; @@ -38,7 +37,7 @@ public void load() { continue; loadedSettings.put(settingName, setting); - log.log(DebugLevel.DEBUG, String.format("Loaded setting %s", settingName)); + log.fine(String.format("Loaded setting %s", settingName)); } log.info(String.format("Loaded %d setting(s)...", loadedSettings.size())); diff --git a/src/main/java/space/devport/wertik/conditionaltext/system/struct/Condition.java b/src/main/java/space/devport/wertik/conditionaltext/system/struct/Condition.java index 83108b9..d1a510a 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/system/struct/Condition.java +++ b/src/main/java/space/devport/wertik/conditionaltext/system/struct/Condition.java @@ -2,13 +2,15 @@ import com.google.common.base.Strings; import lombok.Getter; +import lombok.extern.java.Log; import org.bukkit.OfflinePlayer; import org.jetbrains.annotations.Nullable; import space.devport.wertik.conditionaltext.system.struct.operator.Operators; import space.devport.wertik.conditionaltext.system.struct.operator.impl.OperatorWrapper; -import space.devport.wertik.conditionaltext.system.utils.ParserUtil; +import space.devport.wertik.conditionaltext.system.utils.ParseUtil; import space.devport.wertik.conditionaltext.system.utils.PlaceholderUtil; +@Log public class Condition { @Getter @@ -31,22 +33,27 @@ public static Condition fromString(String input) { for (String sign : Operators.operatorFunctions.keySet()) { if (input.startsWith(sign)) { - input = input.replace(sign, ""); + input = input.replaceFirst(sign, ""); operator = new OperatorWrapper(sign, Operators.getFunction(sign)); break; } } - return operator == null ? null : new Condition(ParserUtil.parseObject(input), operator); + return operator == null ? null : new Condition(ParseUtil.parseObject(input), operator); } public boolean check(Object value, @Nullable OfflinePlayer player) { Object required = this.required; - // Parse placeholders in String requirements + // Parse placeholders in String requirements. if (required instanceof String) - required = ParserUtil.parseObject(PlaceholderUtil.parsePlaceholders(player, (String) required)); + required = ParseUtil.parseObject(PlaceholderUtil.parsePlaceholders(player, (String) required)); - return operator.apply(value, required); + boolean out = operator.apply(value, required); + + log.fine(String.format("'%s' (%s) %s '%s' (%s) -> %b", + value, value.getClass().getSimpleName(), operator.getSign(), required, required.getClass().getSimpleName(), out)); + + return out; } } \ No newline at end of file diff --git a/src/main/java/space/devport/wertik/conditionaltext/system/struct/Setting.java b/src/main/java/space/devport/wertik/conditionaltext/system/struct/Setting.java index 3ecdc97..84096db 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/system/struct/Setting.java +++ b/src/main/java/space/devport/wertik/conditionaltext/system/struct/Setting.java @@ -6,11 +6,12 @@ import org.bukkit.OfflinePlayer; import org.bukkit.configuration.ConfigurationSection; import org.jetbrains.annotations.Nullable; -import space.devport.utils.configuration.Configuration; -import space.devport.utils.logging.DebugLevel; -import space.devport.utils.text.StringUtil; +import space.devport.dock.configuration.Configuration; +import space.devport.dock.util.StringUtil; import space.devport.wertik.conditionaltext.system.utils.PlaceholderUtil; +import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -53,51 +54,67 @@ public static Setting load(Configuration config, String path) { } setting.addRule(rule); - log.log(DebugLevel.DEBUG, String.format("Loaded rule %s", rule.toString())); + log.fine(String.format("Loaded rule %s", rule)); } return setting; } + public Collection getRules() { + return Collections.unmodifiableList(this.rules); + } + public void addRule(Rule rule) { rules.add(rule); } + // Run rules for given Object value. + @Nullable + public String process(@Nullable OfflinePlayer player, Object value) { + for (Rule rule : rules) { + if (rule.check(value, player)) + return rule.getOutput(); + } + return null; + } + // Process the given value and output the formatted text based on rules. @Nullable public String process(@Nullable OfflinePlayer player, Object value, String... arguments) { + + // Actually process the value into an output String output = process(player, value); + // Parse arguments again (in case there were some in the output) output = parseArguments(output, arguments); + // Parse PAPI again and color the output. return StringUtil.color(output != null ? PlaceholderAPI.setPlaceholders(player, output) : null); } @Nullable public String process(@Nullable OfflinePlayer player, String valueString, String... arguments) { Object value = PlaceholderUtil.parsePlaceholderIntoObject(player, valueString); + + log.fine(String.format("Parsed: '%s' -> (%s)", placeholder, value.getClass().getSimpleName())); + return process(player, value, arguments); } // Process the Setting placeholder and output the formatted text based on rules. @Nullable public String process(@Nullable OfflinePlayer player, String... arguments) { + + // Replace $n String placeholder = parseArguments(this.placeholder, arguments); + + // Parse the placeholder into a comparable object. Object value = PlaceholderUtil.parsePlaceholderIntoObject(player, placeholder); - return process(player, value, arguments); - } - // Run rules for given Object value. - // Return the raw output. - @Nullable - public String process(@Nullable OfflinePlayer player, Object value) { - for (Rule rule : rules) { - if (rule.check(value, player)) - return rule.getOutput(); - } - return null; + return process(player, value, arguments); } + // Replace $n with arguments from the placeholder. private String parseArguments(String string, String[] arguments) { for (int n = 0; n < arguments.length; n++) { String argument = arguments[n]; diff --git a/src/main/java/space/devport/wertik/conditionaltext/system/struct/operator/Operators.java b/src/main/java/space/devport/wertik/conditionaltext/system/struct/operator/Operators.java index 0861b9d..2db8c80 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/system/struct/operator/Operators.java +++ b/src/main/java/space/devport/wertik/conditionaltext/system/struct/operator/Operators.java @@ -68,6 +68,15 @@ public class Operators { return false; }); + operatorFunctions.put("%", (input, required) -> { + + if (input instanceof Number && required instanceof Number) { + return ((Number) input).floatValue() % ((Number) required).floatValue() == 0; + } + + return false; + }); + operatorFunctions.put("==", Objects::equals); operatorFunctions.put("!==", (a, b) -> !Objects.equals(a, b)); diff --git a/src/main/java/space/devport/wertik/conditionaltext/system/struct/operator/impl/OperatorWrapper.java b/src/main/java/space/devport/wertik/conditionaltext/system/struct/operator/impl/OperatorWrapper.java index b275e53..0a7390f 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/system/struct/operator/impl/OperatorWrapper.java +++ b/src/main/java/space/devport/wertik/conditionaltext/system/struct/operator/impl/OperatorWrapper.java @@ -3,7 +3,6 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.java.Log; -import space.devport.utils.logging.DebugLevel; @Log @RequiredArgsConstructor @@ -15,9 +14,6 @@ public class OperatorWrapper { private final ObjectOperator function; public boolean apply(Object input, Object required) { - boolean bool = function.apply(input, required); - log.log(DebugLevel.DEBUG, String.format("'%s' (%s) %s '%s' (%s) -> %b", - input, input.getClass().getSimpleName(), sign, required, required.getClass().getSimpleName(), bool)); - return bool; + return function.apply(input, required); } } \ No newline at end of file diff --git a/src/main/java/space/devport/wertik/conditionaltext/system/utils/ParseUtil.java b/src/main/java/space/devport/wertik/conditionaltext/system/utils/ParseUtil.java new file mode 100644 index 0000000..42c50de --- /dev/null +++ b/src/main/java/space/devport/wertik/conditionaltext/system/utils/ParseUtil.java @@ -0,0 +1,37 @@ +package space.devport.wertik.conditionaltext.system.utils; + +import lombok.experimental.UtilityClass; +import lombok.extern.java.Log; +import org.jetbrains.annotations.NotNull; +import space.devport.wertik.conditionaltext.ConditionalTextPlugin; + +import java.time.LocalTime; +import java.time.format.DateTimeParseException; + +@Log +@UtilityClass +public class ParseUtil { + + @NotNull + public Object parseObject(@NotNull String input) { + + try { + return Integer.parseInt(input); + } catch (NumberFormatException ignored) { + // Not an integer + } + + try { + return Double.parseDouble(input); + } catch (NumberFormatException ignored) { + // Not a double + } + try { + return LocalTime.parse(input, ConditionalTextPlugin.getInstance().getTimeFormatter()); + } catch (DateTimeParseException ignored) { + // Not a date + } + + return input; + } +} \ No newline at end of file diff --git a/src/main/java/space/devport/wertik/conditionaltext/system/utils/ParserUtil.java b/src/main/java/space/devport/wertik/conditionaltext/system/utils/ParserUtil.java deleted file mode 100644 index 3a915a9..0000000 --- a/src/main/java/space/devport/wertik/conditionaltext/system/utils/ParserUtil.java +++ /dev/null @@ -1,47 +0,0 @@ -package space.devport.wertik.conditionaltext.system.utils; - -import lombok.experimental.UtilityClass; -import lombok.extern.java.Log; -import org.jetbrains.annotations.NotNull; -import space.devport.utils.logging.DebugLevel; -import space.devport.wertik.conditionaltext.ConditionalTextPlugin; - -import java.time.LocalTime; -import java.time.format.DateTimeParseException; - -@Log -@UtilityClass -public class ParserUtil { - - @NotNull - public Object parseObject(String input) { - - Object out = null; - - try { - out = Integer.parseInt(input); - } catch (NumberFormatException ignored) { - // Not an integer - } - - if (out == null) - try { - return Double.parseDouble(input); - } catch (NumberFormatException ignored) { - // Not a double - } - - if (out == null) - try { - return LocalTime.parse(input, ConditionalTextPlugin.getInstance().getTimeFormatter()); - } catch (DateTimeParseException ignored) { - // Not a date - } - - if (out == null) - out = input; - - log.log(DebugLevel.DEBUG, String.format("Parsed: '%s' -> (%s)", input, out.getClass().getSimpleName())); - return out; - } -} \ No newline at end of file diff --git a/src/main/java/space/devport/wertik/conditionaltext/system/utils/PlaceholderUtil.java b/src/main/java/space/devport/wertik/conditionaltext/system/utils/PlaceholderUtil.java index 3f89be3..b3ca353 100644 --- a/src/main/java/space/devport/wertik/conditionaltext/system/utils/PlaceholderUtil.java +++ b/src/main/java/space/devport/wertik/conditionaltext/system/utils/PlaceholderUtil.java @@ -1,19 +1,26 @@ package space.devport.wertik.conditionaltext.system.utils; import lombok.experimental.UtilityClass; +import lombok.extern.java.Log; import me.clip.placeholderapi.PlaceholderAPI; import org.bukkit.OfflinePlayer; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import space.devport.utils.text.StringUtil; +import space.devport.dock.util.StringUtil; +@Log @UtilityClass public class PlaceholderUtil { - public String parsePlaceholders(@Nullable OfflinePlayer player, String placeholder) { - return StringUtil.stripColor(PlaceholderAPI.setPlaceholders(player, placeholder)); + // Parse PlaceholderAPI placeholders. + @NotNull + public String parsePlaceholders(@Nullable OfflinePlayer player, @NotNull String placeholder) { + return StringUtil.stripColor(PlaceholderAPI.setPlaceholders(player, placeholder)); // Strip colors from the result } - public Object parsePlaceholderIntoObject(@Nullable OfflinePlayer player, String placeholder) { - return ParserUtil.parseObject(parsePlaceholders(player, placeholder)); + // Parse PlaceholderAPI placeholders and then into a comparable object. + @NotNull + public Object parsePlaceholderIntoObject(@Nullable OfflinePlayer player, @NotNull String placeholder) { + return ParseUtil.parseObject(parsePlaceholders(player, placeholder)); } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2e0e172..1bbfdd8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,7 +3,13 @@ # Version: ${project.version} plugin-prefix: '&eConditionalText &8| ' -debug-enabled: false + +## Plugin log level +# ERROR - Errors +# WARN - Warnings +# INFO - Normal user information +# FINE - Debug messages +log-level: INFO # Configure the placeholder identifier. # PAPI format: %_(params)% diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 88618ee..282a307 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,8 +1,9 @@ name: ${project.name} main: ${project.groupId}.ConditionalTextPlugin version: ${project.version} -authors: [ Wertik1206 ] +authors: [ qwz ] softdepend: [ PlaceholderAPI ] +api-version: 1.13 commands: conditionaltext: description: Main plugin command.