diff --git a/build.gradle b/build.gradle index aa1b70aa..edb6e5f7 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ allprojects { compileJava.options.encoding = 'UTF-8' javadoc.options.encoding = 'UTF-8' - compileJava.options.release.set 17 + compileJava.options.release.set 16 repositories { mavenLocal() diff --git a/common/src/main/java/net/william278/huskhomes/Cache.java b/common/src/main/java/net/william278/huskhomes/Cache.java index 9a85e5f3..2981b880 100644 --- a/common/src/main/java/net/william278/huskhomes/Cache.java +++ b/common/src/main/java/net/william278/huskhomes/Cache.java @@ -146,9 +146,11 @@ public class Cache { } @NotNull - public MineDown getCommandList(@NotNull Locales locales, @NotNull List commands, - final int itemsPerPage, final int page) { - return PaginatedList.of(commands.stream().map(command -> locales.getRawLocale("command_list_item", + public MineDown getCommandList(@NotNull OnlineUser onlineUser, @NotNull Locales locales, + @NotNull List commands, final int itemsPerPage, final int page) { + return PaginatedList.of(commands.stream() + .filter(command -> onlineUser.hasPermission(command.permission)) + .map(command -> locales.getRawLocale("command_list_item", Locales.escapeMineDown(command.command), Locales.escapeMineDown(command.getDescription().length() > 50 ? command.getDescription().substring(0, 49).trim() + "…" diff --git a/common/src/main/java/net/william278/huskhomes/command/CommandBase.java b/common/src/main/java/net/william278/huskhomes/command/CommandBase.java index 24dc4ec9..88a55c87 100644 --- a/common/src/main/java/net/william278/huskhomes/command/CommandBase.java +++ b/common/src/main/java/net/william278/huskhomes/command/CommandBase.java @@ -26,7 +26,7 @@ public abstract class CommandBase { * The permission node required to use this command */ @NotNull - protected final String permission; + public final String permission; /** * Instance of the implementing plugin diff --git a/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java b/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java index a69cbd52..faf58454 100644 --- a/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java @@ -66,8 +66,8 @@ public class HuskHomesCommand extends CommandBase implements ConsoleExecutable, return; } } - onlineUser.sendMessage(plugin.getCache().getCommandList(plugin.getLocales(), plugin.getCommands(), - plugin.getSettings().listItemsPerPage, page)); + onlineUser.sendMessage(plugin.getCache().getCommandList(onlineUser, + plugin.getLocales(), plugin.getCommands(), plugin.getSettings().listItemsPerPage, page)); } case "reload" -> { diff --git a/common/src/main/java/net/william278/huskhomes/config/Locales.java b/common/src/main/java/net/william278/huskhomes/config/Locales.java index 697e7abb..9774153f 100644 --- a/common/src/main/java/net/william278/huskhomes/config/Locales.java +++ b/common/src/main/java/net/william278/huskhomes/config/Locales.java @@ -122,9 +122,7 @@ public class Locales { } /** - * Formats a description string, applying space-delimited line breaks after 35 characters. - *

- * If there is no space after 35 characters, the string will be split regardless at 45 characters. + * Formats a description string, wrapping text on whitespace after 40 characters * * @param string The string to format * @return The line-break formatted string, or a String literal {@code "N/A"} if the input string is empty @@ -134,7 +132,7 @@ public class Locales { if (string.isBlank()) { return this.getRawLocale("item_no_description").orElse("N/A"); } - return WordUtils.wrap(string, 35); + return WordUtils.wrap(string, 40, "\n", true); } @SuppressWarnings("unused") diff --git a/common/src/main/java/net/william278/huskhomes/random/NormalDistributionEngine.java b/common/src/main/java/net/william278/huskhomes/random/NormalDistributionEngine.java index 8e73f804..f2536ce2 100644 --- a/common/src/main/java/net/william278/huskhomes/random/NormalDistributionEngine.java +++ b/common/src/main/java/net/william278/huskhomes/random/NormalDistributionEngine.java @@ -59,7 +59,7 @@ public class NormalDistributionEngine extends RtpEngine { */ private static float generateNormallyDistributedRadius(float mean, float standardDeviation, float spawnRadius, float maxRadius) { - double value = new Random().nextGaussian(mean, standardDeviation) * maxRadius; + double value = (new Random().nextGaussian() * mean + standardDeviation) * maxRadius; if (value < spawnRadius || value > maxRadius) { return generateNormallyDistributedRadius(mean, standardDeviation, spawnRadius, maxRadius); } diff --git a/gradle.properties b/gradle.properties index 4e0bbcff..d5577736 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs='-Dfile.encoding=UTF-8' org.gradle.daemon=true -javaVersion=17 +javaVersion=16 plugin_version=3.0 plugin_archive=huskhomes