From af2613202d05d1069d4416b53c50018dce2a6752 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 22 Dec 2021 02:06:07 +0100 Subject: [PATCH] refactor: Satisfy Semgrep --- .../plotsquared/bukkit/listener/EntitySpawnListener.java | 2 +- Core/src/main/java/com/plotsquared/core/util/StringMan.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java index 151c2f40a..783622e63 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java @@ -75,7 +75,7 @@ public class EntitySpawnListener implements Listener { public static void testCreate(final Entity entity) { @NonNull World world = entity.getWorld(); - if (areaName == world.getName()) { + if (areaName.equals(world.getName())) { } else { areaName = world.getName(); hasPlotArea = PlotSquared.get().getPlotAreaManager().hasPlotArea(areaName); diff --git a/Core/src/main/java/com/plotsquared/core/util/StringMan.java b/Core/src/main/java/com/plotsquared/core/util/StringMan.java index ee7a614b8..388e46135 100644 --- a/Core/src/main/java/com/plotsquared/core/util/StringMan.java +++ b/Core/src/main/java/com/plotsquared/core/util/StringMan.java @@ -286,15 +286,13 @@ public class StringMan { } public static boolean isEqualIgnoreCase(String a, String b) { - return (a == b) || ((a != null) && (b != null) && (a.length() == b.length()) && a + return (a.equals(b)) || ((a != null) && (b != null) && (a.length() == b.length()) && a .equalsIgnoreCase(b)); } public static String repeat(String s, int n) { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < n; i++) { - sb.append(s); - } + sb.append(String.valueOf(s).repeat(Math.max(0, n))); return sb.toString(); }