Skip to content

Commit

Permalink
server mech default_colors
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 19, 2022
1 parent c6a13f8 commit 3e545c2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Expand Up @@ -29,6 +29,7 @@
import com.denizenscript.denizencore.tags.TagManager;
import com.denizenscript.denizencore.tags.TagRunnable;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.text.StringHolder;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.citizensnpcs.Citizens;
import net.citizensnpcs.api.CitizensAPI;
Expand Down Expand Up @@ -2641,5 +2642,31 @@ public static void adjustServer(Mechanism mechanism) {
DefaultPermissions.registerPermission(name.toString(), description == null ? null : description.toString(), actualDef, actualParent);
}
}

// <--[mechanism]
// @object server
// @name default_colors
// @input MapTag
// @description
// Sets a default value of a custom color, to be used if the config.yml does not specify a value for that color name.
// Input must be a map with the keys as custom color names, and the values as the default color.
// This mechanism should probably be executed during <@link event scripts loaded>.
// @tags
// <&>
// <ElementTag.custom_color>
// @Example
// on scripts loaded:
// - adjust server default_colors:[mymagenta=<&color[#ff00ff]>;myred=<&c>]
// - debug log "The custom red is <&[myred]>"
// -->
if (mechanism.matches("default_colors") && mechanism.requireObject(MapTag.class)) {
MapTag map = mechanism.valueAsType(MapTag.class);
for (Map.Entry<StringHolder, ObjectTag> pair : map.map.entrySet()) {
String name = pair.getKey().low;
if (!CustomColorTagBase.customColors.containsKey(name)) {
CustomColorTagBase.customColors.put(name, pair.getValue().toString().replace("<", "<&lt>"));
}
}
}
}
}
Expand Up @@ -125,7 +125,6 @@ public static void refillCache() {
RemoveCommand.alwaysWarnOnMassRemove = config.getBoolean("Commands.Remove.Always warn on mass delete", false);
ConfigurationSection colorSection = config.getConfigurationSection("Colors");
if (colorSection != null) {
CustomColorTagBase.customColorsRaw.clear();
CustomColorTagBase.customColors.clear();
CustomColorTagBase.defaultColor = null;
for (String key : colorSection.getKeys(false)) {
Expand Down

0 comments on commit 3e545c2

Please sign in to comment.