diff options
3 files changed, 7 insertions, 13 deletions
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/CommandMapUtil.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/CommandMapUtil.java index 28b7475..058ef55 100644 --- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/CommandMapUtil.java +++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/CommandMapUtil.java @@ -72,9 +72,9 @@ enum CommandMapUtil { } } + @SuppressWarnings("unchecked") private static Map<String, Command> getKnownCommandMap() { try { - //noinspection unchecked return (Map<String, Command>) KNOWN_COMMANDS_FIELD.get(getCommandMap()); } catch (Exception e) { throw new RuntimeException("Could not get known commands map", e); @@ -87,10 +87,8 @@ enum CommandMapUtil { * @param plugin the plugin instance * @param command the command instance * @param aliases the command aliases - * @param <T> the command executor class type - * @return the command executor */ - public static <T extends CommandExecutor> T registerCommand(Plugin plugin, T command, String... aliases) { + public static void registerCommand(Plugin plugin, CommandExecutor command, String... aliases) { Preconditions.checkArgument(aliases.length != 0, "No aliases"); for (String alias : aliases) { try { @@ -112,17 +110,14 @@ enum CommandMapUtil { e.printStackTrace(); } } - return command; } /** * Unregisters a CommandExecutor with the server * * @param command the command instance - * @param <T> the command executor class type - * @return the command executor */ - public static <T extends CommandExecutor> T unregisterCommand(T command) { + public static void unregisterCommand(CommandExecutor command) { CommandMap map = getCommandMap(); try { //noinspection unchecked @@ -142,8 +137,6 @@ enum CommandMapUtil { } catch (Exception e) { throw new RuntimeException("Could not unregister command", e); } - - return command; } }
\ No newline at end of file diff --git a/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java b/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java index c91ceae..a6265c8 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java +++ b/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java @@ -141,7 +141,7 @@ public class TickStatistics implements TickHook.Callback, TickReporter.Callback /** - * Rolling average calculator taken. + * Rolling average calculator. * * <p>This code is taken from PaperMC/Paper, licensed under MIT.</p> * diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java b/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java index 8713678..492d4ea 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java +++ b/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java @@ -23,6 +23,8 @@ package me.lucko.spark.common.util; public enum FormatUtil { ; + private static final String[] SIZE_UNITS = {"bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; + public static String percent(double value, double max) { double percent = (value * 100d) / max; return (int) percent + "%"; @@ -32,8 +34,7 @@ public enum FormatUtil { if (bytes == 0) { return "0 bytes"; } - String[] sizes = new String[]{"bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; int sizeIndex = (int) (Math.log(bytes) / Math.log(1024)); - return String.format("%.1f", bytes / Math.pow(1024, sizeIndex)) + " " + sizes[sizeIndex]; + return String.format("%.1f", bytes / Math.pow(1024, sizeIndex)) + " " + SIZE_UNITS[sizeIndex]; } } |