From 7f14da427fdb910e9fef7fa27434dd78a9433b4b Mon Sep 17 00:00:00 2001 From: "Alex \"mcmonkey\" Goodwin" Date: Sat, 27 Aug 2022 05:23:47 -0700 Subject: [PATCH] tweaks to that PR --- lib | 2 +- .../commands/effectlib/EffectLibCommand.java | 30 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lib b/lib index 1d861c057..51dd0d112 160000 --- a/lib +++ b/lib @@ -1 +1 @@ -Subproject commit 1d861c0578a875a352d18507fd79e91c93a453fe +Subproject commit 51dd0d112dc1843cdddcf56f0138502bb884ba98 diff --git a/src/main/java/com/denizenscript/depenizen/bukkit/commands/effectlib/EffectLibCommand.java b/src/main/java/com/denizenscript/depenizen/bukkit/commands/effectlib/EffectLibCommand.java index d1e700972..85a054c9a 100644 --- a/src/main/java/com/denizenscript/depenizen/bukkit/commands/effectlib/EffectLibCommand.java +++ b/src/main/java/com/denizenscript/depenizen/bukkit/commands/effectlib/EffectLibCommand.java @@ -25,6 +25,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.MemoryConfiguration; +import java.util.HashMap; import java.util.Map; public class EffectLibCommand extends AbstractCommand implements Holdable { @@ -46,9 +47,12 @@ public EffectLibCommand() { // @Short Show custom effects using EffectLib // @Description // Displays EffectLib effects. + // // Specify which effect to display using the 'type:' argument, note that effect names are CASE-SENSITIVE. + // // The origin is the entity/location to play the effect at. If an entity is specified, the effect will follow it. // Defaults to the linked player if unspecified. + // // Some effects (such as the 'Line' effect) require an origin and a target, an effect's target can be a location or an entity. // If an entity is specified, the effect will follow it. // @@ -57,7 +61,7 @@ public EffectLibCommand() { // EffectLib effects can take additional data to change how the effect looks/works, you can specify that data in the form of a MapTag using the 'effect_data:' argument. // See EffectLib's docs for further information on the available options for each effect: <@link url https://reference.elmakers.com/#effectlib> // - // Note that this should only be used for displaying effects. for showing single particles, etc. use <@link command playeffect>. + // Note that this should only be used for displaying EffectLib's advanced effect shapes. For more general particle usage, use <@link command playeffect>. // // The effectlib command is ~waitable. Refer to <@link language ~waitable>. // When ~waited for, the command will wait until the effect is done playing. @@ -80,9 +84,20 @@ public EffectLibCommand() { // // --> - public static Warning durationArgument = new SlowWarning("effectlibCommandDuration", "The 'duration:' argument for the 'effectlib' command is deprecated in favour of the 'duration' key in the 'effect_data' map, refer to the meta docs for more information."); - public static Warning oldTargetArguments = new SlowWarning("effectlibCommandOldTarget", "The 'target:'/'location:' arguments for the 'effectlib' command are deprecated in favour of the 'origin:/' argument."); - public static Warning caseInsensitiveEffectName = new SlowWarning("effectlibCommandCaseInsensitiveType", "Case-Insensitive effect types in the 'effectlib' commands are deprecated. make sure you're using correct casing."); + public static Warning durationArgument = new SlowWarning("effectlibCommandDuration", "The 'duration:' argument for the 'effectlib' command is deprecated in favor of the 'duration' key in the 'effect_data' map, refer to the meta docs for more information."); + public static Warning oldTargetArguments = new SlowWarning("effectlibCommandOldTarget", "The 'target:'/'location:' arguments for the 'effectlib' command are deprecated in favor of the 'origin:/' argument."); + + public static HashMap nameCasings = new HashMap<>(); + public static void registerNameCasing(String s) { + nameCasings.put(CoreUtilities.toLowerCase(s), s); + } + static { // Effect names that have more than 1 capital letter + registerNameCasing("AnimatedBall"); + registerNameCasing("BigBang"); + registerNameCasing("ColoredImage"); + registerNameCasing("DiscoBall"); + registerNameCasing("SkyRocket"); + } public static void autoExecute(ScriptEntry scriptEntry, @ArgPrefixed @ArgName("type") String effectInput, @@ -109,10 +124,13 @@ public static void autoExecute(ScriptEntry scriptEntry, Debug.echoError(scriptEntry, "Must specify an origin location or entity!"); return; } - // EffectLib is case-sensitive, and the way the command used to handle effect names let you input 'atom', where now 'Atom' is required + // EffectLib is case-sensitive, so correct for casing as best as possible if (Character.isLowerCase(effectInput.charAt(0))) { - caseInsensitiveEffectName.warn(scriptEntry); effectInput = Character.toUpperCase(effectInput.charAt(0)) + effectInput.substring(1); + String fixed = nameCasings.get(CoreUtilities.toLowerCase(effectInput)); + if (fixed != null) { + effectInput = fixed; + } } Effect effect; if (effectData == null) {