Skip to content

Commit

Permalink
use CoreUtilities.toUpperCase
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 6, 2022
1 parent 0a1249e commit 3a2ec38
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 17 deletions.
Expand Up @@ -595,7 +595,7 @@ public void initListener(Listener listener) {
String bukkitPriority = path.switches.get("bukkit_priority");
if (bukkitPriority != null) {
try {
EventPriority priority = EventPriority.valueOf(bukkitPriority.toUpperCase());
EventPriority priority = EventPriority.valueOf(CoreUtilities.toUpperCase(bukkitPriority));
BukkitScriptEvent handler = priorityHandlers.get(priority);
if (handler == null) {
handler = (BukkitScriptEvent) clone();
Expand Down
@@ -1,6 +1,7 @@
package com.denizenscript.denizen.nms.abstracts;

import com.denizenscript.denizen.nms.interfaces.EntityAnimation;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.entity.Villager;

import java.util.HashMap;
Expand All @@ -11,22 +12,22 @@ public abstract class AnimationHelper {
public static final Map<String, EntityAnimation> entityAnimations = new HashMap<>();

static {
entityAnimations.put("VILLAGER_SHAKE_HEAD", entity -> {
entityAnimations.put("villager_shake_head", entity -> {
if (entity instanceof Villager) {
((Villager) entity).shakeHead();
}
});
}

protected void register(String name, EntityAnimation animation) {
entityAnimations.put(name.toUpperCase(), animation);
entityAnimations.put(CoreUtilities.toLowerCase(name), animation);
}

public boolean hasEntityAnimation(String name) {
return entityAnimations.containsKey(name.toUpperCase());
return entityAnimations.containsKey(CoreUtilities.toLowerCase(name));
}

public EntityAnimation getEntityAnimation(String name) {
return entityAnimations.get(name.toUpperCase());
return entityAnimations.get(CoreUtilities.toLowerCase(name));
}
}
Expand Up @@ -3,6 +3,7 @@
import com.denizenscript.denizen.objects.NPCTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizen.scripts.containers.core.AssignmentScriptContainer;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizencore.objects.core.ElementTag;
Expand Down Expand Up @@ -34,13 +35,18 @@ public ListTag doAction(String actionName, NPCTag npc, PlayerTag player, Assignm
if (!assignment.containsScriptSection("actions.on " + actionName)) {
return null;
}
Debug.report(assignment, "Action", ArgumentHelper.debugObj("Type", "On " + actionName), npc, assignment.getAsScriptArg(), player);
boolean shouldDebug = Debug.shouldDebug(assignment);
if (shouldDebug) {
Debug.report(assignment, "Action", ArgumentHelper.debugObj("Type", "On " + actionName), npc, assignment.getAsScriptArg(), player);
}
// Fetch script from Actions
List<ScriptEntry> script = assignment.getEntries(new BukkitScriptEntryData(player, npc), "actions.on " + actionName);
if (script.isEmpty()) {
return null;
}
Debug.echoDebug(assignment, DebugElement.Header, "Building action 'On " + actionName.toUpperCase() + "' for " + npc.toString());
if (shouldDebug) {
Debug.echoDebug(assignment, DebugElement.Header, "Building action 'On " + CoreUtilities.toUpperCase(actionName) + "' for " + npc.toString());
}
// Add entries and context to the queue
ScriptQueue queue = new InstantQueue(assignment.getName());
queue.addEntries(script);
Expand Down
Expand Up @@ -352,7 +352,7 @@ public static boolean matches(String arg) {
return true;
}
// No longer picky about e@.. let's remove it from the arg
arg = arg.replace("e@", "").toUpperCase();
arg = CoreUtilities.toUpperCase(arg.replace("e@", ""));
// Allow 'random'
if (arg.equals("RANDOM")) {
return true;
Expand Down
Expand Up @@ -149,7 +149,7 @@ else if (ScriptRegistry.containsScript(string, BookScriptContainer.class)) {
}
}
try {
MaterialTag mat = MaterialTag.valueOf(string.toUpperCase(), context);
MaterialTag mat = MaterialTag.valueOf(string, context);
if (mat != null) {
stack = new ItemTag(mat.getMaterial());
}
Expand Down Expand Up @@ -313,7 +313,7 @@ public int comparesTo(ItemStack compared_to) {
if (!thisMeta.hasDisplayName()) {
return -1;
}
if (comparedItemMeta.getDisplayName().toUpperCase().startsWith(thisMeta.getDisplayName().toUpperCase())) {
if (CoreUtilities.toLowerCase(comparedItemMeta.getDisplayName()).startsWith(CoreUtilities.toLowerCase(thisMeta.getDisplayName()))) {
if (thisMeta.getDisplayName().length() > comparedItemMeta.getDisplayName().length()) {
determination++;
}
Expand Down
Expand Up @@ -78,7 +78,7 @@ public static MaterialTag valueOf(String string, TagContext context) {
if (ObjectFetcher.isObjectWithProperties(string)) {
return ObjectFetcher.getObjectFromWithProperties(MaterialTag.class, string, context);
}
string = string.toUpperCase();
string = CoreUtilities.toUpperCase(string);
if (string.startsWith("M@")) {
string = string.substring("M@".length());
}
Expand Down Expand Up @@ -750,7 +750,7 @@ else if (matcherLow.startsWith("material_flagged:")) {
}
}
if (allowByMaterialName) {
Material quickOf = Material.getMaterial(comparedto.toUpperCase());
Material quickOf = Material.getMaterial(CoreUtilities.toUpperCase(comparedto));
if (quickOf != null) {
return quickOf == mat;
}
Expand Down
Expand Up @@ -487,7 +487,7 @@ else if (colorName.startsWith("co@") || colorName.lastIndexOf(',') > colorName.i
}
if (colorOut == null) {
try {
ChatColor color = ChatColor.valueOf(colorName.toUpperCase());
ChatColor color = ChatColor.valueOf(CoreUtilities.toUpperCase(colorName));
colorOut = color.toString();
}
catch (IllegalArgumentException ex) {
Expand Down
Expand Up @@ -511,7 +511,7 @@ else if (innardType.equals("click") && innardParts.size() == 1) {
continue;
}
TextComponent clickableText = new TextComponent();
clickableText.setClickEvent(new ClickEvent(ClickEvent.Action.valueOf(innardBase.get(1).toUpperCase()), unescape(innardParts.get(0))));
clickableText.setClickEvent(new ClickEvent(ClickEvent.Action.valueOf(CoreUtilities.toUpperCase(innardBase.get(1))), unescape(innardParts.get(0))));
for (BaseComponent subComponent : parse(str.substring(endBracket + 1, endIndex), baseColor, false)) {
clickableText.addExtra(subComponent);
}
Expand All @@ -524,7 +524,7 @@ else if (innardType.equals("hover")) {
continue;
}
TextComponent hoverableText = new TextComponent();
HoverEvent.Action action = HoverEvent.Action.valueOf(innardBase.get(1).toUpperCase());
HoverEvent.Action action = HoverEvent.Action.valueOf(CoreUtilities.toUpperCase(innardBase.get(1)));
if (HoverFormatHelper.processHoverInput(action, hoverableText, innardParts.get(0))) {
continue;
}
Expand Down
Expand Up @@ -5,6 +5,7 @@
import com.denizenscript.denizen.nms.v1_19.ReflectionMappingsInfo;
import com.denizenscript.denizen.scripts.containers.core.EnchantmentScriptContainer;
import com.denizenscript.denizen.utilities.FormattedTextHelper;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import com.denizenscript.denizencore.utilities.ReflectionHelper;
import net.md_5.bungee.api.ChatColor;
Expand Down Expand Up @@ -40,7 +41,7 @@ public org.bukkit.enchantments.Enchantment registerFakeEnchantment(EnchantmentSc
try {
EquipmentSlot[] slots = new EquipmentSlot[script.script.slots.size()];
for (int i = 0; i < slots.length; i++) {
slots[i] = EquipmentSlot.valueOf(script.script.slots.get(i).toUpperCase());
slots[i] = EquipmentSlot.valueOf(CoreUtilities.toUpperCase(script.script.slots.get(i)));
}
net.minecraft.world.item.enchantment.Enchantment nmsEnchant = new net.minecraft.world.item.enchantment.Enchantment(net.minecraft.world.item.enchantment.Enchantment.Rarity.valueOf(script.script.rarity), EnchantmentCategory.valueOf(script.script.category), slots) {
@Override
Expand Down Expand Up @@ -128,7 +129,7 @@ public boolean isDiscoverable() {
return script.script.isDiscoverable;
}
};
String enchName = script.script.id.toUpperCase();
String enchName = CoreUtilities.toUpperCase(script.script.id);
boolean wasFrozen = REGISTRY_FROZEN.getBoolean(Registry.ENCHANTMENT);
REGISTRY_FROZEN.setBoolean(Registry.ENCHANTMENT, false);
Registry.register(Registry.ENCHANTMENT, "denizen:" + script.script.id, nmsEnchant);
Expand Down

0 comments on commit 3a2ec38

Please sign in to comment.