Skip to content

Commit

Permalink
use new equalsIgnoreCase
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 14, 2020
1 parent c1b66cb commit 0b5ed25
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 31 deletions.
Expand Up @@ -76,7 +76,7 @@ public String getName() {
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
if (determinationObj instanceof ElementTag) {
String determination = determinationObj.toString();
if (CoreUtilities.toLowerCase(determination).equals("none")) {
if (CoreUtilities.equalsIgnoreCase(determination, "none")) {
event.setMessage(null);
}
else {
Expand Down
Expand Up @@ -36,12 +36,12 @@ public boolean couldMatchInArea(String lower) {
}

String in = CoreUtilities.getXthArg(index + 1, lower);
if (InventoryTag.matches(in) || in.equalsIgnoreCase("inventory") || isRegexMatchable(in)) {
if (InventoryTag.matches(in) || CoreUtilities.equalsIgnoreCase(in, "inventory") || isRegexMatchable(in)) {
return false;
}
if (in.equalsIgnoreCase("notable")) {
if (CoreUtilities.equalsIgnoreCase(in, "notable")) {
String next = CoreUtilities.getXthArg(index + 2, lower);
if (!next.equalsIgnoreCase("cuboid") && !next.equalsIgnoreCase("ellipsoid")) {
if (!CoreUtilities.equalsIgnoreCase(next, "cuboid") && !CoreUtilities.equalsIgnoreCase(next, "ellipsoid")) {
return false;
}
}
Expand All @@ -50,7 +50,7 @@ public boolean couldMatchInArea(String lower) {

public boolean couldMatchEnum(String text, final Enum<?>[] enumVals) {
for (Enum<?> val : enumVals) {
if (val.name().equalsIgnoreCase(text)) {
if (CoreUtilities.equalsIgnoreCase(val.name(), text)) {
return true;
}
}
Expand Down Expand Up @@ -401,7 +401,7 @@ else if (lower.equals("ellipsoid")) {
return EllipsoidTag.getNotableEllipsoidsContaining(location).size() > 0;
}
else if (WorldTag.matches(it)) {
return CoreUtilities.toLowerCase(location.getWorld().getName()).equals(lower);
return CoreUtilities.equalsIgnoreCase(location.getWorld().getName(), lower);
}
else if (CuboidTag.matches(it)) {
CuboidTag cuboid = CuboidTag.valueOf(it, getTagContext(path));
Expand All @@ -428,7 +428,7 @@ else if (EllipsoidTag.matches(it)) {
public boolean runWithCheck(ScriptPath path, ItemTag held) {
String with = path.switches.get("with");
if (with != null) {
if (with.equalsIgnoreCase("item")) {
if (CoreUtilities.equalsIgnoreCase(with, "item")) {
return true;
}
if (held == null || !tryItem(held, with)) {
Expand Down
Expand Up @@ -7,6 +7,7 @@
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -73,7 +74,7 @@ public boolean matches(ScriptPath path) {
}

if (path.eventArgLowerAt(2).equals("because")
&& !path.eventArgLowerAt(3).equalsIgnoreCase(reason.toString())) {
&& !CoreUtilities.equalsIgnoreCase(path.eventArgLowerAt(3), reason.toString())) {
return false;
}

Expand Down
Expand Up @@ -53,7 +53,7 @@ public boolean couldMatch(ScriptPath path) {
public boolean matches(ScriptPath path) {
String mode = path.eventArgLowerAt(4);
if (mode.length() > 0) {
if (!CoreUtilities.toLowerCase(gamemode.asString()).equals(mode)) {
if (!CoreUtilities.equalsIgnoreCase(gamemode.asString(), mode)) {
return false;
}
}
Expand Down
Expand Up @@ -7,6 +7,7 @@
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.Material;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -80,7 +81,7 @@ private boolean runUsingCheck(ScriptPath path) {
Debug.echoError("Invalid USING hand in " + getName() + " for '" + path.event + "' in " + path.container.getName());
return false;
}
if (!using.equals("either_hand") && !using.equalsIgnoreCase(hand.identify())) {
if (!using.equals("either_hand") && !CoreUtilities.equalsIgnoreCase(using, hand.identify())) {
return false;
}
return true;
Expand Down
Expand Up @@ -86,7 +86,7 @@ public String getName() {
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
if (determinationObj instanceof ElementTag) {
if (CoreUtilities.toLowerCase(determinationObj.toString()).equals("instabreak")) {
if (CoreUtilities.equalsIgnoreCase(determinationObj.toString(), "instabreak")) {
event.setInstaBreak(true);
return true;
}
Expand Down
Expand Up @@ -57,7 +57,7 @@ public String getName() {
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
if (determinationObj instanceof ElementTag) {
String determination = determinationObj.toString();
if (CoreUtilities.toLowerCase(determination).equals("none")) {
if (CoreUtilities.equalsIgnoreCase(determination, "none")) {
event.setJoinMessage(null);
return true;
}
Expand Down
Expand Up @@ -57,7 +57,7 @@ public String getName() {
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
if (determinationObj instanceof ElementTag) {
String determination = determinationObj.toString();
if (CoreUtilities.toLowerCase(determination).equals("none")) {
if (CoreUtilities.equalsIgnoreCase(determination, "none")) {
event.setQuitMessage(null);
return true;
}
Expand Down
Expand Up @@ -68,7 +68,7 @@ public String getName() {
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
String determination = determinationObj.toString();
if (!CoreUtilities.toLowerCase(determination).equals("none")) {
if (!CoreUtilities.equalsIgnoreCase(determination, "none")) {
LocationTag loc = LocationTag.valueOf(determination, getTagContext(path));
if (loc != null) {
event.setRespawnLocation(loc);
Expand Down
Expand Up @@ -701,7 +701,7 @@ public boolean equals(Object o) {
if ((other.getWorldName() == null && getWorldName() != null)
|| (getWorldName() == null && other.getWorldName() != null)
|| (getWorldName() != null && other.getWorldName() != null
&& !getWorldName().equalsIgnoreCase(other.getWorldName()))) {
&& !CoreUtilities.equalsIgnoreCase(getWorldName(), other.getWorldName()))) {
return false;
}
return Math.floor(getX()) == Math.floor(other.getX())
Expand Down
Expand Up @@ -883,7 +883,7 @@ public static void registerTags() {
if (obj instanceof EntityTag) {
filterEntity = (EntityTag) obj;
}
else if (CoreUtilities.toLowerCase(obj.toString()).equals("npc")) {
else if (CoreUtilities.equalsIgnoreCase(obj.toString(), "npc")) {
valid = EntityTag.isCitizensNPC(entity);
}
else {
Expand Down
Expand Up @@ -499,8 +499,8 @@ public void adjust(Mechanism mechanism) {
else {
try {
PotionType type = PotionType.valueOf(data.get(0));
boolean extended = type.isExtendable() && CoreUtilities.toLowerCase(data.get(1)).equals("true");
boolean upgraded = type.isUpgradeable() && CoreUtilities.toLowerCase(data.get(2)).equals("true");
boolean extended = type.isExtendable() && CoreUtilities.equalsIgnoreCase(data.get(1), "true");
boolean upgraded = type.isUpgradeable() && CoreUtilities.equalsIgnoreCase(data.get(2), "true");
if (extended && upgraded) {
Debug.echoError("Potion cannot be both upgraded and extended");
}
Expand Down
Expand Up @@ -385,8 +385,8 @@ public void adjust(Mechanism mechanism) {
String[] d1 = data.get(0).split(",");
PotionMeta meta = (PotionMeta) item.getItemStack().getItemMeta();
meta.setBasePotionData(new PotionData(PotionType.valueOf(d1[0].toUpperCase()),
CoreUtilities.toLowerCase(d1[2]).equals("true"),
CoreUtilities.toLowerCase(d1[1]).equals("true")));
CoreUtilities.equalsIgnoreCase(d1[2], "true"),
CoreUtilities.equalsIgnoreCase(d1[1], "true")));
if (d1.length > 3) {
meta.setColor(ColorTag.valueOf(d1[3].replace("&comma", ","), mechanism.context).getColor());
}
Expand Down
Expand Up @@ -165,7 +165,7 @@ public void execute(ScriptEntry scriptEntry) {
break;

case AS_OP:
if (CoreUtilities.toLowerCase(command).equals("stop")) {
if (CoreUtilities.equalsIgnoreCase(command, "stop")) {
Debug.echoError("Please use as_server to execute 'stop'.");
return;
}
Expand Down
Expand Up @@ -333,10 +333,10 @@ public boolean createPlayerAccount(String s, String s1) {
}

public ServicePriority getPriority() {
String prioString = CoreUtilities.toLowerCase(getString("priority", "normal"));
String prioString = getString("priority", "normal");
// Enumeration name casing is weird for ServicePriority.
for (ServicePriority prio : ServicePriority.values()) {
if (CoreUtilities.toLowerCase(prio.name()).equals(prioString)) {
if (CoreUtilities.equalsIgnoreCase(prio.name(), prioString)) {
return prio;
}
}
Expand Down
Expand Up @@ -1253,8 +1253,9 @@ else if (recipe instanceof CookingRecipe<?>) {
if ((attribute.startsWith("npcs_named") || attribute.startsWith("list_npcs_named")) && Depends.citizens != null && attribute.hasContext(1)) {
listDeprecateWarn(attribute);
ListTag npcs = new ListTag();
String name = attribute.getContext(1);
for (NPC npc : CitizensAPI.getNPCRegistry()) {
if (npc.getName().equalsIgnoreCase(attribute.getContext(1))) {
if (CoreUtilities.equalsIgnoreCase(npc.getName(), name)) {
npcs.addObject(NPCTag.mirrorCitizensNPC(npc));
}
}
Expand Down Expand Up @@ -1566,7 +1567,7 @@ else if (recipe instanceof CookingRecipe<?>) {
Player matchPlayer = null;
String matchInput = CoreUtilities.toLowerCase(attribute.getContext(1));
for (Player player : Bukkit.getOnlinePlayers()) {
if (CoreUtilities.toLowerCase(player.getName()).equals(matchInput)) {
if (CoreUtilities.equalsIgnoreCase(player.getName(), matchInput)) {
matchPlayer = player;
break;
}
Expand Down Expand Up @@ -1594,7 +1595,7 @@ else if (CoreUtilities.toLowerCase(player.getName()).contains(matchInput) && mat
UUID matchPlayer = null;
String matchInput = CoreUtilities.toLowerCase(attribute.getContext(1));
for (Map.Entry<String, UUID> entry : PlayerTag.getAllPlayers().entrySet()) {
if (CoreUtilities.toLowerCase(entry.getKey()).equals(matchInput)) {
if (CoreUtilities.equalsIgnoreCase(entry.getKey(), matchInput)) {
matchPlayer = entry.getValue();
break;
}
Expand Down Expand Up @@ -1627,7 +1628,7 @@ else if (CoreUtilities.toLowerCase(entry.getKey()).contains(matchInput) && match
ListTag npcs = new ListTag();
for (NPC npc : CitizensAPI.getNPCRegistry()) {
if (npc.hasTrait(AssignmentTrait.class) && npc.getTrait(AssignmentTrait.class).hasAssignment()
&& npc.getTrait(AssignmentTrait.class).getAssignment().getName().equalsIgnoreCase(script.getName())) {
&& CoreUtilities.equalsIgnoreCase(npc.getTrait(AssignmentTrait.class).getAssignment().getName(), script.getName())) {
npcs.addObject(NPCTag.mirrorCitizensNPC(npc));
}
}
Expand Down
Expand Up @@ -96,7 +96,7 @@ public static boolean canReadFile(File f) {
!f.getCanonicalPath().startsWith(new File(".").getCanonicalPath())) {
return false;
}
if (!CoreUtilities.toLowerCase(Settings.fileLimitPath()).equals("none")
if (!CoreUtilities.equalsIgnoreCase(Settings.fileLimitPath(), "none")
&& !f.getCanonicalPath().startsWith(new File("./" + Settings.fileLimitPath()).getCanonicalPath())) {
return false;
}
Expand Down Expand Up @@ -357,7 +357,7 @@ public static void extractFile(File jarFile, String fileName, String destDir) {
java.util.Enumeration myEnum = jar.entries();
while (myEnum.hasMoreElements()) {
java.util.jar.JarEntry file = (java.util.jar.JarEntry) myEnum.nextElement();
if (file.getName().equalsIgnoreCase(fileName)) {
if (CoreUtilities.equalsIgnoreCase(file.getName(), fileName)) {
java.io.File f = new java.io.File(destDir + "/" + file.getName());
if (file.isDirectory()) {
continue;
Expand Down
Expand Up @@ -238,7 +238,7 @@ public int length() {
}

public boolean matches(String command) {
return args[0].equalsIgnoreCase(command);
return CoreUtilities.equalsIgnoreCase(args[0], command);
}

public static Location parseLocation(Location currentLocation, String flag) throws CommandException {
Expand Down
Expand Up @@ -85,7 +85,7 @@ private void executeHelp(String[] args, CommandSender sender) throws CommandExce
private void executeMethod(String[] args, CommandSender sender, Object[] methodArgs) throws CommandException {
String cmdName = CoreUtilities.toLowerCase(args[0]);
String modifier = args.length > 1 ? args[1] : "";
boolean help = CoreUtilities.toLowerCase(modifier).equals("help");
boolean help = CoreUtilities.equalsIgnoreCase(modifier, "help");

Method method = commands.get(cmdName + " " + CoreUtilities.toLowerCase(modifier));
if (method == null && !help) {
Expand Down

0 comments on commit 0b5ed25

Please sign in to comment.