diff --git a/Bukkit/pom.xml b/Bukkit/pom.xml index 77302cb..463a2cc 100644 --- a/Bukkit/pom.xml +++ b/Bukkit/pom.xml @@ -178,8 +178,8 @@ com.github.seeseemelk - MockBukkit-v1.20 - 3.39.0 + MockBukkit-v1.21 + 3.109.0 test @@ -210,7 +210,7 @@ org.spigotmc spigot-api - 1.20.2-R0.1-SNAPSHOT + 1.21-R0.1-SNAPSHOT provided diff --git a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/cache/CacheManager.java b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/cache/CacheManager.java index be159c7..5173b3e 100755 --- a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/cache/CacheManager.java +++ b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/cache/CacheManager.java @@ -116,7 +116,7 @@ public static void load(String dataDirectory) { List addonStorageManager = prAddon.getValue().getStorageManagerNames(); if (Objects.nonNull(addonStorageManager)) { for (String storageName : addonStorageManager) { - if (storageType.equals(storageName.toUpperCase())) { + if (storageType.equalsIgnoreCase(storageName)) { usedStorageManagerAddon = prAddon.getValue(); usedStorageManagerAddon.setupStorageManager(storageName); storageManager = usedStorageManagerAddon.getStorageManager(storageName); diff --git a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/cache/LanguageManager.java b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/cache/LanguageManager.java index ec576de..03c9915 100644 --- a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/cache/LanguageManager.java +++ b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/cache/LanguageManager.java @@ -34,11 +34,11 @@ public LanguageManager() { * @return List of found keys */ public List getKeys(String path) { - path = "lang." + this.language + "." + path; + String targetPath = "lang." + this.language + "." + path; List keys = new ArrayList(); - for (Entry entry : this.languageManager.getMap(path, new HashMap()).entrySet()) { + for (Entry entry : this.languageManager.getMap(targetPath, new HashMap()).entrySet()) { keys.add(String.valueOf(entry.getKey())); } @@ -78,9 +78,9 @@ public String getMessage(String path, boolean addPrefix) { * @return Unformatted message */ public String getUnformattedMessage(String path) { - path = "lang." + this.language + "." + path; - String output = this.languageManager.getString(path); - output = output == null ? path : output; + String targetPath = "lang." + this.language + "." + path; + String output = this.languageManager.getString(targetPath); + output = output == null ? targetPath : output; return output; } @@ -108,11 +108,10 @@ public String getFormattedMessage(String path, boolean addPrefix) { } public String getUsageMessage(String commandLabel, String commandName, String path, boolean isPlayer) { - path = "lang." + this.language + "." + path; - String output = this.languageManager.getString(path); - output = output == null ? path : output; - output = this.languageManager.getString("lang." + this.language + ".general.prefix") + " " - + (isPlayer ? "/" : "") + commandLabel + " " + commandName + " " + output; + String targetPath = "lang." + this.language + "." + path; + String output = this.languageManager.getString(targetPath); + output = output == null ? targetPath : output; + output = (isPlayer ? "/" : "") + commandLabel + " " + commandName + " " + output; return output; } @@ -144,7 +143,6 @@ public void setLanguage(String language) { public void save() { this.languageManager.save(); } - /** * Reload the language data */ diff --git a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/PowerCommandHandler.java b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/PowerCommandHandler.java index aac6e36..b9c28cd 100644 --- a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/PowerCommandHandler.java +++ b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/PowerCommandHandler.java @@ -37,6 +37,7 @@ import nl.svenar.powerranks.bukkit.commands.core.cmd_stats; import nl.svenar.powerranks.bukkit.commands.core.cmd_tablist; import nl.svenar.powerranks.bukkit.commands.core.cmd_verbose; +import nl.svenar.powerranks.bukkit.commands.core.cmd_permissionlookups; import nl.svenar.powerranks.bukkit.commands.player.cmd_addownrank; import nl.svenar.powerranks.bukkit.commands.player.cmd_addplayerperm; import nl.svenar.powerranks.bukkit.commands.player.cmd_addrank; @@ -66,7 +67,6 @@ import nl.svenar.powerranks.bukkit.commands.rank.cmd_setprefix; import nl.svenar.powerranks.bukkit.commands.rank.cmd_setsuffix; import nl.svenar.powerranks.bukkit.commands.rank.cmd_setweight; -import nl.svenar.powerranks.bukkit.commands.test.cmd_test; import nl.svenar.powerranks.bukkit.commands.usertags.cmd_addusertag; import nl.svenar.powerranks.bukkit.commands.usertags.cmd_clearusertag; import nl.svenar.powerranks.bukkit.commands.usertags.cmd_createusertag; @@ -98,6 +98,7 @@ public PowerCommandHandler(PowerRanks plugin) { new cmd_addonmanager(plugin, "addonmanager", COMMAND_EXECUTOR.ALL); new cmd_playerinfo(plugin, "playerinfo", COMMAND_EXECUTOR.ALL); new cmd_haspermission(plugin, "haspermission", COMMAND_EXECUTOR.ALL); + new cmd_permissionlookups(plugin, "permissionlookups", COMMAND_EXECUTOR.ALL); new cmd_dump(plugin, "dump", COMMAND_EXECUTOR.ALL); new cmd_setrank(plugin, "setrank", COMMAND_EXECUTOR.ALL); @@ -151,8 +152,6 @@ public PowerCommandHandler(PowerRanks plugin) { new cmd_webeditor(plugin, "webeditor", COMMAND_EXECUTOR.ALL); new cmd_webeditor(plugin, "we", COMMAND_EXECUTOR.ALL); - - new cmd_test(plugin, "test", COMMAND_EXECUTOR.ALL); } private static boolean canExecuteCommand(CommandSender sender, PowerCommand command_handler) { diff --git a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/core/cmd_permissionlookups.java b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/core/cmd_permissionlookups.java new file mode 100644 index 0000000..a8ffea3 --- /dev/null +++ b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/core/cmd_permissionlookups.java @@ -0,0 +1,215 @@ +package nl.svenar.powerranks.bukkit.commands.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.entity.Player; + +import com.google.common.collect.ImmutableMap; + +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.TextComponent; +import nl.svenar.powerranks.bukkit.PowerRanks; +import nl.svenar.powerranks.bukkit.commands.PowerCommand; +import nl.svenar.powerranks.bukkit.data.PowerPermissibleBase; +import nl.svenar.powerranks.bukkit.textcomponents.DefaultFontInfo; +import nl.svenar.powerranks.bukkit.textcomponents.PageNavigationManager; +import nl.svenar.powerranks.common.utils.PowerColor; + +public class cmd_permissionlookups extends PowerCommand { + + private final int maxResultsConsole = 20; + private final int maxResultsPlayer = 10; + + public cmd_permissionlookups(PowerRanks plugin, String command_name, COMMAND_EXECUTOR ce) { + super(plugin, command_name, ce); + this.setCommandPermission("powerranks.cmd." + command_name.toLowerCase()); + } + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String commandName, + String[] args) { + + int page = 1; + if (args.length > 0) { + try { + page = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + sender.sendMessage(ChatColor.RED + "Invalid page number."); + return false; + } + } + + Map permissionCallCount = PowerPermissibleBase.permissionCallCount; + // sort from high to low value + permissionCallCount = sortByValue(permissionCallCount, false); + + List callCounts = new ArrayList<>(); + for (Entry entry : permissionCallCount.entrySet()) { + callCounts.add(new PRCallCount(entry.getKey(), entry.getValue())); + } + + PageNavigationManager pageNavigationManager = new PageNavigationManager(); + pageNavigationManager.setItemsPerPage(sender instanceof Player ? maxResultsPlayer : maxResultsConsole); + pageNavigationManager.setMonospace(sender instanceof ConsoleCommandSender); + pageNavigationManager.setFancyPageControls(sender instanceof Player); + pageNavigationManager.setBaseCommand("pr permissionlookups"); + pageNavigationManager.setItems(formatPermissionCountList(callCounts, sender instanceof ConsoleCommandSender)); + + for (Object line : pageNavigationManager.getPage(page).generate()) { + if (line instanceof String) { + sender.sendMessage((String) line); + } else if (line instanceof TextComponent) { + sender.spigot().sendMessage((TextComponent) line); + } else { + sender.spigot().sendMessage((BaseComponent[]) line); + } + } + + sender.sendMessage(PowerRanks.chatColor("&7callcount &apermission&2.&anode", true)); + sender.sendMessage(PowerRanks.chatColor("&2Total called permissions: &a" + permissionCallCount.size(), true)); + + return false; + } + + private Map sortByValue(Map permissionCallCount, boolean asc) { + // sort from high to low value + List> list = new LinkedList<>(permissionCallCount.entrySet()); + java.util.Collections.sort(list, (Entry o1, Entry o2) -> { + if (asc) { + return (o1.getValue()).compareTo(o2.getValue()); + } else { + return (o2.getValue()).compareTo(o1.getValue()); + } + }); + // return + Map result = new LinkedHashMap<>(); + for (Entry entry : list) { + result.put(entry.getKey(), entry.getValue()); + } + + return result; + } + + @Override + public ArrayList tabCompleteEvent(CommandSender sender, String[] args) { + ArrayList tabcomplete = new ArrayList<>(); + + return tabcomplete; + } + + private List formatPermissionCountList(List prCallCounts, boolean hasMonospaceFont) { + List list = new ArrayList<>(); + + Map permissionNameBuffer = new HashMap<>(); + Map countBuffer = new HashMap<>(); + + for (PRCallCount prcc : prCallCounts) { + permissionNameBuffer.put(prcc.getName(), prcc.getName()); + countBuffer.put(prcc.getName(), String.valueOf(prcc.getCount())); + } + + if (!hasMonospaceFont) { + int longestName = permissionNameBuffer.values().stream().mapToInt( + name -> name.chars().map(c -> DefaultFontInfo.getDefaultFontInfo((char) c).getLength()).sum()).max() + .orElse(0); + int longestCount = countBuffer.values().stream().mapToInt( + name -> name.chars().map(c -> DefaultFontInfo.getDefaultFontInfo((char) c).getLength()).sum()).max() + .orElse(0); + + for (Entry entry : permissionNameBuffer.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + int currentLength = value.chars().map(c -> DefaultFontInfo.getDefaultFontInfo((char) c).getLength()) + .sum(); + while (currentLength < longestName) { + value += " "; + currentLength = value.chars().map(c -> DefaultFontInfo.getDefaultFontInfo((char) c).getLength()) + .sum(); + } + permissionNameBuffer.put(key, value); + } + + for (Entry entry : countBuffer.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + int currentLength = value.chars().map(c -> DefaultFontInfo.getDefaultFontInfo((char) c).getLength()) + .sum(); + while (currentLength < longestCount) { + value = " " + value; + currentLength = value.chars().map(c -> DefaultFontInfo.getDefaultFontInfo((char) c).getLength()) + .sum(); + } + countBuffer.put(key, value); + } + + } else { + int longestName = permissionNameBuffer.values().stream().mapToInt(name -> name.length()).max().orElse(0); + int longestCount = countBuffer.values().stream().mapToInt(name -> name.length()).max().orElse(0); + + for (Entry entry : permissionNameBuffer.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + int currentLength = value.length(); + while (currentLength < longestName) { + value += " "; + currentLength = value.length(); + } + permissionNameBuffer.put(key, value); + } + + for (Entry entry : countBuffer.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + int currentLength = value.length(); + while (currentLength < longestCount) { + value = " " + value; + currentLength = value.length(); + } + countBuffer.put(key, value); + } + } + + for (Iterator it = prCallCounts.iterator(); it.hasNext();) { + PRCallCount prcc = it.next(); + String line = prepareMessage("list.list-permissioncallcount-item", ImmutableMap.of( // + "permission", "&a" + permissionNameBuffer.get(prcc.getName()).replaceAll("\\.", "&2.&a"), // + "callcount", countBuffer.get(prcc.getName()) // + ), false); + while (line.endsWith(" ") || line.toLowerCase().endsWith(PowerColor.COLOR_CHAR + "") + || line.toLowerCase().endsWith(PowerColor.COLOR_CHAR + "r")) { + line = line.substring(0, line.length() - 1); + } + list.add(line); + } + return list; + } + + private class PRCallCount { + private final String name; + private final int count; + + public PRCallCount(String name, int count) { + this.name = name; + this.count = count; + } + + public String getName() { + return name; + } + + public int getCount() { + return count; + } + } +} diff --git a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/test/cmd_test.java b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/test/cmd_test.java deleted file mode 100644 index ba6a23b..0000000 --- a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/commands/test/cmd_test.java +++ /dev/null @@ -1,82 +0,0 @@ -package nl.svenar.powerranks.bukkit.commands.test; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import nl.svenar.powerranks.common.structure.PRPermission; -import nl.svenar.powerranks.bukkit.PowerRanks; -import nl.svenar.powerranks.bukkit.commands.PowerCommand; -import nl.svenar.powerranks.bukkit.data.PowerPermissibleBase; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class cmd_test extends PowerCommand { - - public cmd_test(PowerRanks plugin, String command_name, COMMAND_EXECUTOR ce) { - super(plugin, command_name, ce); - this.setCommandPermission("powerranks.cmd." + command_name.toLowerCase()); - } - - @Override - public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String commandName, - String[] args) { - - // Set permissions = Bukkit.getServer().getPluginManager().getPermissions(); - // for (Permission permission : permissions) { - // sender.sendMessage(permission.getName() + ": " + permission.getDefault().toString() + " (" + permission.getDescription() + ")"); - // } - - if (sender instanceof Player) { - List playerPermissions = PowerRanks.getInstance().getEffectivePlayerPermissions((Player) sender); - for (PRPermission permission : playerPermissions) { - sender.sendMessage(permission.getName() + ": " + permission.getValue()); - } - } else { - Map permissionCallCount = PowerPermissibleBase.permissionCallCount; - // sort from high to low value - permissionCallCount = sortByValue(permissionCallCount, false); - int index = 0; - for (Entry entry : permissionCallCount.entrySet()) { - if (index >= 20) - break; - sender.sendMessage(entry.getKey() + ": " + entry.getValue()); - index++; - } - } - - return false; - } - - private Map sortByValue(Map permissionCallCount, boolean asc) { - // sort from high to low value - List> list = new LinkedList>(permissionCallCount.entrySet()); - java.util.Collections.sort(list, new java.util.Comparator>() { - public int compare(Entry o1, Entry o2) { - if (asc) { - return (o1.getValue()).compareTo(o2.getValue()); - } else { - return (o2.getValue()).compareTo(o1.getValue()); - } - } - }); - // return - Map result = new LinkedHashMap(); - for (Entry entry : list) { - result.put(entry.getKey(), entry.getValue()); - } - - return result; - } - - public ArrayList tabCompleteEvent(CommandSender sender, String[] args) { - ArrayList tabcomplete = new ArrayList(); - - return tabcomplete; - } -} diff --git a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/data/TablistManager.java b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/data/TablistManager.java index 8ffa337..64386a0 100644 --- a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/data/TablistManager.java +++ b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/data/TablistManager.java @@ -217,6 +217,10 @@ private String getHeader(Player player) { output += line + "\n"; } + if (output.length() == 0) { + return output; + } + if (PowerRanks.placeholderapiExpansion != null) { output = PlaceholderAPI.setPlaceholders(player, output).replaceAll("" + ChatColor.COLOR_CHAR, "" + PowerColor.UNFORMATTED_COLOR_CHAR); @@ -236,6 +240,10 @@ private String getFooter(Player player) { output += line + "\n"; } + if (output.length() == 0) { + return output; + } + if (PowerRanks.placeholderapiExpansion != null) { output = PlaceholderAPI.setPlaceholders(player, output).replaceAll("" + ChatColor.COLOR_CHAR, "" + PowerColor.UNFORMATTED_COLOR_CHAR); diff --git a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/gui/GUIPage.java b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/gui/GUIPage.java index d1ddcc7..ac3459a 100644 --- a/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/gui/GUIPage.java +++ b/Bukkit/src/main/java/nl/svenar/powerranks/bukkit/gui/GUIPage.java @@ -434,7 +434,7 @@ Inventory setupGUI(GUI_PAGE_ID pageID) { "&n"), DyeColor.WHITE, PatternType.BASE), DyeColor.BLACK, - PatternType.HALF_HORIZONTAL_MIRROR), + PatternType.HALF_HORIZONTAL_BOTTOM), DyeColor.WHITE, PatternType.STRIPE_BOTTOM), DyeColor.WHITE, PatternType.STRIPE_MIDDLE)); new_gui.setItem(3, BannerItem.addPattern(BannerItem.addPattern(BannerItem.createEmpty("Itallic", "&o"), @@ -456,7 +456,7 @@ Inventory setupGUI(GUI_PAGE_ID pageID) { PatternType.STRIPE_DOWNLEFT), DyeColor.BLACK, PatternType.TRIANGLE_BOTTOM), DyeColor.BLACK, PatternType.TRIANGLE_TOP), - DyeColor.BLACK, PatternType.CIRCLE_MIDDLE)); + DyeColor.BLACK, PatternType.CIRCLE)); new_gui.setItem(5, BannerItem.addPattern( BannerItem.addPattern(BannerItem.createEmpty("Strike", "&m"), DyeColor.WHITE, PatternType.BASE), DyeColor.BLACK, PatternType.STRIPE_MIDDLE)); diff --git a/Bukkit/src/main/resources/lang.yml b/Bukkit/src/main/resources/lang.yml index 1765e27..afb2891 100644 --- a/Bukkit/src/main/resources/lang.yml +++ b/Bukkit/src/main/resources/lang.yml @@ -13,6 +13,7 @@ lang: list: list-rank-item: "&7[weight] &f[rank]&a &r[prefix]" list-permission-item: "&r[permission]" + list-permissioncallcount-item: "&7[callcount] &r[permission]" messages: signs: created: "&aNew sign command created" diff --git a/Bukkit/src/main/resources/plugin.yml b/Bukkit/src/main/resources/plugin.yml index d1eaab9..a350e5d 100644 --- a/Bukkit/src/main/resources/plugin.yml +++ b/Bukkit/src/main/resources/plugin.yml @@ -131,6 +131,8 @@ permissions: default: op powerranks.cmd.playerinfo: default: op + powerranks.cmd.permissionlookups: + default: op powerranks.cmd.verbose: default: op powerranks.cmd.pluginhook: diff --git a/Core/src/test/java/nl/svenar/powerranks/test/tests/TestPowerColor.java b/Core/src/test/java/nl/svenar/powerranks/test/tests/TestPowerColor.java index dd9082c..db3d3b1 100644 --- a/Core/src/test/java/nl/svenar/powerranks/test/tests/TestPowerColor.java +++ b/Core/src/test/java/nl/svenar/powerranks/test/tests/TestPowerColor.java @@ -1,7 +1,7 @@ package nl.svenar.powerranks.test.tests; import static org.junit.Assert.assertEquals; -import static org.junit.Assume.assumeTrue; +import static org.junit.Assert.assertTrue; import java.time.Instant; @@ -23,9 +23,9 @@ public void testOldColorFormat() { String expected = "§4§lHello §c§lWorld"; String actual = powerColor.formatColor(PowerColor.UNFORMATTED_COLOR_CHAR, input); - if (!expected.toLowerCase().equals(actual.toLowerCase())) { + if (!expected.equalsIgnoreCase(actual)) { TestDebugger.log(this, - "[testOldColorFormat] (" + (expected.toLowerCase().equals(actual.toLowerCase())) + "[testOldColorFormat] (" + (expected.equalsIgnoreCase(actual)) + "): " + expected.toLowerCase() + " == " + actual.toLowerCase()); } @@ -47,15 +47,15 @@ public void testHEXColorFormat() { String actual1 = powerColor.formatHEX(PowerColor.UNFORMATTED_COLOR_CHAR, input); String actual2 = powerColor.formatColor(PowerColor.UNFORMATTED_COLOR_CHAR, actual1); - if (!expected1.toLowerCase().equals(actual1.toLowerCase())) { + if (!expected1.equalsIgnoreCase(actual1)) { TestDebugger.log(this, "[testHEXColorFormat] (" - + (expected1.toLowerCase().equals(actual1.toLowerCase())) + + (expected1.equalsIgnoreCase(actual1)) + "): " + expected1.toLowerCase() + " == " + actual1.toLowerCase()); } assertEquals(expected1.toLowerCase(), actual1.toLowerCase()); - if (!expected2.toLowerCase().equals(actual2.toLowerCase())) { + if (!expected2.equalsIgnoreCase(actual2)) { TestDebugger.log(this, "[testHEXColorFormat] (" - + (expected2.toLowerCase().equals(actual2.toLowerCase())) + + (expected2.equalsIgnoreCase(actual2)) + "): " + expected2.toLowerCase() + " == " + actual2.toLowerCase()); } assertEquals(expected2.toLowerCase(), actual2.toLowerCase()); @@ -76,7 +76,7 @@ public void testSpecialColorFormat() { String interpolateOutput = powerColor.interpolateColor(interpolateColor1, interpolateColor2, 0.5); String interpolateExpected = "#c3d4e5"; - if (!interpolateExpected.toLowerCase().equals(interpolateOutput.toLowerCase())) { + if (!interpolateExpected.equalsIgnoreCase(interpolateOutput)) { TestDebugger.log(this, "[testSpecialColorFormat interpolation] (" + (interpolateExpected.toLowerCase() @@ -96,21 +96,19 @@ public void testSpecialColorFormat() { String actualRainbow2 = powerColor.formatColor(PowerColor.UNFORMATTED_COLOR_CHAR, powerColor.formatHEX(PowerColor.UNFORMATTED_COLOR_CHAR, actualRainbow1)); - if (!expectedRainbow1.toLowerCase().equals(actualRainbow1.toLowerCase())) { + if (!expectedRainbow1.equalsIgnoreCase(actualRainbow1)) { TestDebugger.log(this, "[testSpecialColorFormat rainbow #1] (" - + (expectedRainbow1.toLowerCase() - .equals(actualRainbow1.toLowerCase())) + + (expectedRainbow1.equalsIgnoreCase(actualRainbow1)) + "): " + expectedRainbow1.toLowerCase() + " == " + actualRainbow1.toLowerCase()); } assertEquals(expectedRainbow1.toLowerCase(), actualRainbow1.toLowerCase()); - if (!expectedRainbow2.toLowerCase().equals(actualRainbow2.toLowerCase())) { + if (!expectedRainbow2.equalsIgnoreCase(actualRainbow2)) { TestDebugger.log(this, "[testSpecialColorFormat rainbow #2] (" - + (expectedRainbow2.toLowerCase() - .equals(actualRainbow2.toLowerCase())) + + (expectedRainbow2.equalsIgnoreCase(actualRainbow2)) + "): " + expectedRainbow2.toLowerCase() + " == " + actualRainbow2.toLowerCase()); @@ -126,21 +124,19 @@ public void testSpecialColorFormat() { String actualGradient2 = powerColor.formatColor(PowerColor.UNFORMATTED_COLOR_CHAR, powerColor.formatHEX(PowerColor.UNFORMATTED_COLOR_CHAR, actualGradient1)); - if (!expectedGradient1.toLowerCase().equals(actualGradient1.toLowerCase())) { + if (!expectedGradient1.equalsIgnoreCase(actualGradient1)) { TestDebugger.log(this, "[testSpecialColorFormat gradient #1] (" - + (expectedGradient1.toLowerCase() - .equals(actualGradient1.toLowerCase())) + + (expectedGradient1.equalsIgnoreCase(actualGradient1)) + "): " + expectedGradient1.toLowerCase() + " == " + actualGradient1.toLowerCase()); } assertEquals(expectedGradient2.toLowerCase(), actualGradient2.toLowerCase()); - if (!expectedGradient2.toLowerCase().equals(actualGradient2.toLowerCase())) { + if (!expectedGradient2.equalsIgnoreCase(actualGradient2)) { TestDebugger.log(this, "[testSpecialColorFormat gradient #2] (" - + (expectedGradient2.toLowerCase() - .equals(actualGradient2.toLowerCase())) + + (expectedGradient2.equalsIgnoreCase(actualGradient2)) + "): " + expectedGradient2.toLowerCase() + " == " + actualGradient2.toLowerCase()); @@ -155,18 +151,18 @@ public void testSpecialColorFormat() { String actualAll2 = powerColor.formatColor(PowerColor.UNFORMATTED_COLOR_CHAR, powerColor.formatHEX(PowerColor.UNFORMATTED_COLOR_CHAR, actualAll1)); - if (!expectedAll1.toLowerCase().equals(actualAll1.toLowerCase())) { + if (!expectedAll1.equalsIgnoreCase(actualAll1)) { TestDebugger.log(this, "[testSpecialColorFormat all #1] (" - + (expectedAll1.toLowerCase().equals(actualAll1.toLowerCase())) + + (expectedAll1.equalsIgnoreCase(actualAll1)) + "): " + expectedAll1.toLowerCase() + " == " + actualAll1.toLowerCase()); } assertEquals(expectedAll1.toLowerCase(), actualAll1.toLowerCase()); - if (!expectedAll2.toLowerCase().equals(actualAll2.toLowerCase())) { + if (!expectedAll2.equalsIgnoreCase(actualAll2)) { TestDebugger.log(this, "[testSpecialColorFormat all #2] (" - + (expectedAll2.toLowerCase().equals(actualAll2.toLowerCase())) + + (expectedAll2.equalsIgnoreCase(actualAll2)) + "): " + expectedAll2.toLowerCase() + " == " + actualAll2.toLowerCase()); } @@ -180,22 +176,20 @@ public void testSpecialColorFormat() { String actualChat2 = powerColor.formatColor(PowerColor.UNFORMATTED_COLOR_CHAR, powerColor.formatHEX(PowerColor.UNFORMATTED_COLOR_CHAR, actualChat1)); - if (!expectedChat1.toLowerCase().equals(actualChat1.toLowerCase())) { + if (!expectedChat1.equalsIgnoreCase(actualChat1)) { TestDebugger.log(this, "[testSpecialColorFormat chat #1] (" - + (expectedChat1.toLowerCase() - .equals(actualChat1.toLowerCase())) + + (expectedChat1.equalsIgnoreCase(actualChat1)) + "): " + expectedChat1.toLowerCase() + " == " + actualChat1.toLowerCase()); } assertEquals(expectedChat2.toLowerCase(), actualChat2.toLowerCase()); - if (!expectedChat2.toLowerCase().equals(actualChat2.toLowerCase())) { + if (!expectedChat2.equalsIgnoreCase(actualChat2)) { TestDebugger.log(this, "[testSpecialColorFormat chat #2] (" - + (expectedChat2.toLowerCase() - .equals(actualChat2.toLowerCase())) + + (expectedChat2.equalsIgnoreCase(actualChat2)) + "): " + expectedChat2.toLowerCase() + " == " + actualChat2.toLowerCase()); @@ -222,7 +216,7 @@ public void testPerformance() { powerColor.formatSpecial(PowerColor.UNFORMATTED_COLOR_CHAR, inputString); } Instant end = Instant.now(); - assumeTrue(end.toEpochMilli() - start.toEpochMilli() < maxDurationEachItem * numItems); + assertTrue(end.toEpochMilli() - start.toEpochMilli() < maxDurationEachItem * numItems); TestDebugger.log(this, "[testPerformance] " + (end.toEpochMilli() - start.toEpochMilli()) + "ms (max: " + Math.round(maxDurationEachItem * numItems) + "ms)"); TestDebugger.log(this, "[testPerformance] Done!"); diff --git a/Nukkit/pom.xml b/Nukkit/pom.xml index 9f88a3d..2269180 100644 --- a/Nukkit/pom.xml +++ b/Nukkit/pom.xml @@ -1,29 +1,29 @@ - 4.0.0 - nl.svenar - powerranks.nukkit - ${revision} - PowerRanks Nukkit - Rank-based permission manager + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + nl.svenar + powerranks.nukkit + ${revision} + PowerRanks Nukkit + Rank-based permission manager - - 1.8 - UTF-8 - src/main/java - src/main/resources - nl.svenar.lib - false - + + 1.8 + UTF-8 + src/main/java + src/main/resources + nl.svenar.lib + false + - + nl.svenar powerranks ${revision} - + clean compile package ${output.name} ${src.dir} @@ -49,7 +49,7 @@ 2.3.1 - + org.apache.maven.plugins maven-shade-plugin 3.1.0 @@ -105,22 +105,22 @@ - + svenar https://svenar.nl/repo/ - - opencollab-repo-release - https://repo.opencollab.dev/maven-releases - - - opencollab-repo-snapshot - https://repo.opencollab.dev/maven-snapshots - - + + opencollab-repo-release + https://repo.opencollab.dev/maven-releases + + + opencollab-repo-snapshot + https://repo.opencollab.dev/maven-snapshots + + - + nl.svenar powerranks.core @@ -132,11 +132,10 @@ ${revision} - - cn.nukkit - nukkit - 1.0-SNAPSHOT - provided - - + + org.powernukkit + powernukkit + 1.6.0.1-PN + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 38db326..bac7836 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ pom - 1.10.9R2 + 1.10.10 PowerRanks