From 0a50df6557d0e3639e351f9f2fda2fb0b8fb55ae Mon Sep 17 00:00:00 2001 From: Luck Date: Tue, 5 Mar 2019 12:36:09 +0000 Subject: [PATCH] Code style: move private constructors for singleton classes to the top of the file --- .../bukkit/inject/permissible/PermissibleInjector.java | 3 +-- .../me/lucko/luckperms/bukkit/migration/BukkitUuids.java | 3 +-- .../java/me/lucko/luckperms/bungee/util/RedisBungeeUtil.java | 3 +-- .../luckperms/common/actionlog/LogEntryJsonSerializer.java | 2 +- .../main/java/me/lucko/luckperms/common/api/ApiUtils.java | 3 +-- .../luckperms/common/command/access/ArgumentPermissions.java | 4 ++-- .../lucko/luckperms/common/command/utils/MessageUtils.java | 3 +-- .../luckperms/common/command/utils/StorageAssistant.java | 2 +- .../luckperms/common/commands/migration/MigrationUtils.java | 3 +-- .../java/me/lucko/luckperms/common/config/ConfigKeys.java | 3 +-- .../common/context/ContextSetConfigurateSerializer.java | 3 +-- .../luckperms/common/context/ContextSetJsonSerializer.java | 3 +-- .../me/lucko/luckperms/common/graph/GraphTraversers.java | 3 +-- .../luckperms/common/metastacking/StandardStackElements.java | 3 +-- .../me/lucko/luckperms/common/model/DemotionResults.java | 4 +--- .../me/lucko/luckperms/common/model/PromotionResults.java | 4 +--- .../common/node/comparator/NodeWithContextComparator.java | 3 +-- .../luckperms/common/node/factory/LegacyNodeFactory.java | 3 +-- .../me/lucko/luckperms/common/node/factory/NodeFactory.java | 4 ++-- .../java/me/lucko/luckperms/common/node/model/NodeTypes.java | 3 +-- .../java/me/lucko/luckperms/common/node/utils/NodeTools.java | 2 +- .../lucko/luckperms/common/node/utils/ShorthandParser.java | 4 ++-- .../implementation/custom/CustomStorageProviders.java | 4 ++-- .../lucko/luckperms/common/storage/misc/DataConstraints.java | 3 +-- .../main/java/me/lucko/luckperms/common/util/DateParser.java | 4 ++-- .../java/me/lucko/luckperms/common/util/ExpiringSet.java | 3 +-- .../me/lucko/luckperms/common/util/ImmutableCollectors.java | 3 +-- .../main/java/me/lucko/luckperms/common/util/Iterators.java | 3 +-- .../main/java/me/lucko/luckperms/common/util/MoreFiles.java | 2 +- .../java/me/lucko/luckperms/common/util/PatternCache.java | 3 +-- .../main/java/me/lucko/luckperms/common/util/Predicates.java | 3 ++- .../me/lucko/luckperms/common/util/PrivateMethodHandles.java | 1 - .../main/java/me/lucko/luckperms/common/util/Scripting.java | 4 ++-- .../main/java/me/lucko/luckperms/common/util/TextUtils.java | 3 +-- .../src/main/java/me/lucko/luckperms/common/util/Uuids.java | 4 ++-- .../main/java/me/lucko/luckperms/common/web/HttpClient.java | 1 - .../main/java/me/lucko/luckperms/common/web/WebEditor.java | 4 ++-- .../nukkit/inject/permissible/PermissibleInjector.java | 3 +-- .../me/lucko/luckperms/sponge/service/CompatibilityUtil.java | 4 ++-- .../lucko/luckperms/sponge/commands/SpongeCommandUtils.java | 3 +-- .../java/me/lucko/luckperms/sponge/service/ProxyFactory.java | 4 ++-- .../sponge/service/inheritance/SubjectInheritanceGraphs.java | 5 ++--- .../lucko/luckperms/velocity/service/CompatibilityUtil.java | 3 +-- 43 files changed, 53 insertions(+), 82 deletions(-) diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/PermissibleInjector.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/PermissibleInjector.java index d1b920ca9..b31b38c9c 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/PermissibleInjector.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/PermissibleInjector.java @@ -42,6 +42,7 @@ import java.util.List; * checks made by plugins. */ public final class PermissibleInjector { + private PermissibleInjector() {} /** * All permission checks made on standard Bukkit objects are effectively proxied to a @@ -151,6 +152,4 @@ public final class PermissibleInjector { } } - private PermissibleInjector() {} - } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/BukkitUuids.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/BukkitUuids.java index f39f327d9..82d7086c1 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/BukkitUuids.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/BukkitUuids.java @@ -33,6 +33,7 @@ import org.bukkit.Bukkit; import java.util.UUID; public final class BukkitUuids { + private BukkitUuids() {} public static UUID lookupUuid(ProgressLogger log, String s) { UUID uuid = Uuids.parse(s); @@ -50,6 +51,4 @@ public final class BukkitUuids { return uuid; } - private BukkitUuids() {} - } diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/util/RedisBungeeUtil.java b/bungee/src/main/java/me/lucko/luckperms/bungee/util/RedisBungeeUtil.java index fb9514cd5..6326d4edb 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/util/RedisBungeeUtil.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/util/RedisBungeeUtil.java @@ -31,6 +31,7 @@ import java.util.Optional; import java.util.UUID; public final class RedisBungeeUtil { + private RedisBungeeUtil() {} /** * Looks up a UUID from username via RedisBungee's uuid cache. @@ -46,6 +47,4 @@ public final class RedisBungeeUtil { return Optional.ofNullable(RedisBungee.getApi()).map(a -> a.getNameFromUuid(uuid, true)); } - private RedisBungeeUtil() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/LogEntryJsonSerializer.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogEntryJsonSerializer.java index cc9949ff4..fdf4fccf9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/LogEntryJsonSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogEntryJsonSerializer.java @@ -35,6 +35,7 @@ import me.lucko.luckperms.api.LogEntry; import java.util.UUID; public final class LogEntryJsonSerializer { + private LogEntryJsonSerializer() {} public static JsonObject serialize(LogEntry logEntry) { JsonObject data = new JsonObject(); @@ -68,5 +69,4 @@ public final class LogEntryJsonSerializer { return builder.build(); } - private LogEntryJsonSerializer() {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/ApiUtils.java b/common/src/main/java/me/lucko/luckperms/common/api/ApiUtils.java index b8d849e7e..049606c79 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/ApiUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/ApiUtils.java @@ -34,6 +34,7 @@ import me.lucko.luckperms.common.storage.misc.DataConstraints; import java.util.function.Predicate; public final class ApiUtils { + private ApiUtils() {} public static String checkUsername(String s, LuckPermsPlugin plugin) { if (s == null) { @@ -57,6 +58,4 @@ public final class ApiUtils { return s.toLowerCase(); } - private ApiUtils() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java b/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java index 68d949da1..198d00f35 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java @@ -47,6 +47,8 @@ import java.util.function.Function; * Implements argument based permission checks for use in command implementations. */ public final class ArgumentPermissions { + private ArgumentPermissions() {} + private static final String USER_MODIFY_SELF = CommandPermission.ROOT + "modify.user.self"; private static final String USER_MODIFY_OTHERS = CommandPermission.ROOT + "modify.user.others"; private static final Function GROUP_MODIFY = s -> CommandPermission.ROOT + "modify.group." + s; @@ -301,7 +303,5 @@ public final class ArgumentPermissions { PermissionCache permissionData = user.getCachedData().getPermissionData(Contexts.global().setContexts(contextSet)); return !permissionData.getPermissionValue(NodeFactory.groupNode(targetGroupName), PermissionCheckEvent.Origin.INTERNAL).result().asBoolean(); } - - private ArgumentPermissions() {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java index 970932d3b..45157899d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java @@ -38,6 +38,7 @@ import java.util.List; import java.util.Map; public final class MessageUtils { + private MessageUtils() {} /** * Sends a message to the sender, formatted with the plugin prefix and color scheme @@ -177,6 +178,4 @@ public final class MessageUtils { return sb.delete(sb.length() - Message.CONTEXT_PAIR_SEP.asString(localeManager).length(), sb.length()).toString(); } - private MessageUtils() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java index 294cafc57..5a5ef9acb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java @@ -41,6 +41,7 @@ import java.util.Optional; * Utility methods for saving users, groups and tracks. */ public final class StorageAssistant { + private StorageAssistant() {} public static Group loadGroup(String target, Sender sender, LuckPermsPlugin plugin, boolean auditTemporary) { // special handling for the importer @@ -176,5 +177,4 @@ public final class StorageAssistant { } } - private StorageAssistant() {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java index 75f3368fa..210d529c5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java @@ -31,6 +31,7 @@ import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.node.factory.NodeFactory; public final class MigrationUtils { + private MigrationUtils() {} public static Node.Builder parseNode(String permission, boolean value) { if (permission.startsWith("-") || permission.startsWith("!")) { @@ -61,6 +62,4 @@ public final class MigrationUtils { return string.trim().replace(':', '-').replace(' ', '-').replace('.', '-').toLowerCase(); } - private MigrationUtils() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java index fea3a7740..d8fac5c37 100644 --- a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java +++ b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java @@ -70,6 +70,7 @@ import static me.lucko.luckperms.common.config.ConfigKeyTypes.stringKey; * to function a bit like an enum, but with generics.

*/ public final class ConfigKeys { + private ConfigKeys() {} /** * The name of the server @@ -593,6 +594,4 @@ public final class ConfigKeys { return SIZE; } - private ConfigKeys() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java index 58c2ad437..d510aa152 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Map; public final class ContextSetConfigurateSerializer { + private ContextSetConfigurateSerializer() {} public static ConfigurationNode serializeContextSet(ContextSet contextSet) { ConfigurationNode data = SimpleConfigurationNode.root(); @@ -84,6 +85,4 @@ public final class ContextSetConfigurateSerializer { return map; } - private ContextSetConfigurateSerializer() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java index 0ffe89182..9c6b312e2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java @@ -42,6 +42,7 @@ import java.util.Map; import java.util.Objects; public final class ContextSetJsonSerializer { + private ContextSetJsonSerializer() {} public static JsonObject serializeContextSet(ContextSet contextSet) { JsonObject data = new JsonObject(); @@ -104,6 +105,4 @@ public final class ContextSetJsonSerializer { return map; } - private ContextSetJsonSerializer() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/graph/GraphTraversers.java b/common/src/main/java/me/lucko/luckperms/common/graph/GraphTraversers.java index 3d4aa5e6f..0484efb17 100644 --- a/common/src/main/java/me/lucko/luckperms/common/graph/GraphTraversers.java +++ b/common/src/main/java/me/lucko/luckperms/common/graph/GraphTraversers.java @@ -57,6 +57,7 @@ import java.util.Set; * @author Jens Nyman */ public final class GraphTraversers { + private GraphTraversers() {} /** * Returns an unmodifiable {@code Iterable} over the nodes reachable from @@ -210,6 +211,4 @@ public final class GraphTraversers { POST_ORDER } - private GraphTraversers() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/metastacking/StandardStackElements.java b/common/src/main/java/me/lucko/luckperms/common/metastacking/StandardStackElements.java index 0782ea59a..b99a01fb5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/metastacking/StandardStackElements.java +++ b/common/src/main/java/me/lucko/luckperms/common/metastacking/StandardStackElements.java @@ -44,6 +44,7 @@ import java.util.Objects; * Contains the standard {@link MetaStackElement}s provided by LuckPerms. */ public final class StandardStackElements { + private StandardStackElements() {} public static MetaStackElement parseFromString(LuckPermsPlugin plugin, String s) { s = s.toLowerCase(); @@ -317,6 +318,4 @@ public final class StandardStackElements { } } - private StandardStackElements() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/DemotionResults.java b/common/src/main/java/me/lucko/luckperms/common/model/DemotionResults.java index 1de198f48..0440e3084 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/DemotionResults.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/DemotionResults.java @@ -36,6 +36,7 @@ import java.util.Optional; * Utility class for creating instances of {@link DemotionResult}. */ public final class DemotionResults { + private DemotionResults() {} public static DemotionResult success(String groupFrom, String groupTo) { return new Impl(DemotionResult.Status.SUCCESS, groupFrom, groupTo); @@ -115,7 +116,4 @@ public final class DemotionResults { } } - - private DemotionResults() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/PromotionResults.java b/common/src/main/java/me/lucko/luckperms/common/model/PromotionResults.java index 7a2ecd633..10b96253c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/PromotionResults.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/PromotionResults.java @@ -36,6 +36,7 @@ import java.util.Optional; * Utility class for creating instances of {@link PromotionResult}. */ public final class PromotionResults { + private PromotionResults() {} public static PromotionResult success(String groupFrom, String groupTo) { return new Impl(PromotionResult.Status.SUCCESS, groupFrom, groupTo); @@ -115,7 +116,4 @@ public final class PromotionResults { } } - - private PromotionResults() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/comparator/NodeWithContextComparator.java b/common/src/main/java/me/lucko/luckperms/common/node/comparator/NodeWithContextComparator.java index f3e9a0965..29b3c3ba4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/comparator/NodeWithContextComparator.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/comparator/NodeWithContextComparator.java @@ -34,6 +34,7 @@ import java.util.Comparator; * Compares permission nodes based upon their supposed "priority". */ public class NodeWithContextComparator implements Comparator { + private NodeWithContextComparator() {} private static final Comparator INSTANCE = new NodeWithContextComparator(); private static final Comparator REVERSE = INSTANCE.reversed(); @@ -46,8 +47,6 @@ public class NodeWithContextComparator implements Comparator { return REVERSE; } - private NodeWithContextComparator() {} - @Override public int compare(Node o1, Node o2) { if (o1.equals(o2)) { diff --git a/common/src/main/java/me/lucko/luckperms/common/node/factory/LegacyNodeFactory.java b/common/src/main/java/me/lucko/luckperms/common/node/factory/LegacyNodeFactory.java index 865eaae2b..1b9c36319 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/factory/LegacyNodeFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/factory/LegacyNodeFactory.java @@ -36,6 +36,7 @@ import java.util.Map; import java.util.regex.Pattern; public final class LegacyNodeFactory { + private LegacyNodeFactory() {} /** * The characters which are delimited when serializing a context set @@ -201,6 +202,4 @@ public final class LegacyNodeFactory { } } - private LegacyNodeFactory() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeFactory.java b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeFactory.java index 9b948e3a1..28db72d14 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeFactory.java @@ -38,6 +38,8 @@ import java.util.Map; * Utility class to make Node(Builder) instances from strings or existing Nodes */ public final class NodeFactory { + private NodeFactory() {} + public static final String DEFAULT_GROUP_NAME = "default"; public static Node.Builder builder(String s) { @@ -344,6 +346,4 @@ public final class NodeFactory { return sb; } - private NodeFactory() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/model/NodeTypes.java b/common/src/main/java/me/lucko/luckperms/common/node/model/NodeTypes.java index 9fc6476f8..dc5b5c6d5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/model/NodeTypes.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/model/NodeTypes.java @@ -52,6 +52,7 @@ import java.util.Optional; import java.util.regex.Pattern; public final class NodeTypes { + private NodeTypes() {} public static final String PREFIX_KEY = "prefix"; public static final String SUFFIX_KEY = "suffix"; @@ -509,6 +510,4 @@ public final class NodeTypes { } } - private NodeTypes() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/utils/NodeTools.java b/common/src/main/java/me/lucko/luckperms/common/node/utils/NodeTools.java index d892a4805..df194b7a3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/utils/NodeTools.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/utils/NodeTools.java @@ -37,6 +37,7 @@ import java.util.Set; import java.util.function.Predicate; public final class NodeTools { + private NodeTools() {} public static void removeEqual(Iterator it, NodeEqualityPredicate equalityPredicate) { List alreadyIn = new ArrayList<>(); @@ -78,5 +79,4 @@ public final class NodeTools { return localizedNode -> delegate.test(localizedNode.getNode()); } - private NodeTools() {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/utils/ShorthandParser.java b/common/src/main/java/me/lucko/luckperms/common/node/utils/ShorthandParser.java index b327515eb..78b80ce2d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/utils/ShorthandParser.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/utils/ShorthandParser.java @@ -38,6 +38,8 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; public final class ShorthandParser { + private ShorthandParser() {} + private static final List>> PARSERS = ImmutableList.>>builder() .add(new ListParser()) .add(new CharacterRangeParser()) @@ -169,6 +171,4 @@ public final class ShorthandParser { } } - private ShorthandParser() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/custom/CustomStorageProviders.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/custom/CustomStorageProviders.java index 77fa438a9..2377c3f04 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/custom/CustomStorageProviders.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/custom/CustomStorageProviders.java @@ -29,6 +29,8 @@ package me.lucko.luckperms.common.storage.implementation.custom; * Hook to allow external code to provide a storage dao */ public final class CustomStorageProviders { + private CustomStorageProviders() {} + private static CustomStorageProvider provider = null; public static void register(CustomStorageProvider provider) { @@ -43,6 +45,4 @@ public final class CustomStorageProviders { return provider; } - private CustomStorageProviders() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/misc/DataConstraints.java b/common/src/main/java/me/lucko/luckperms/common/storage/misc/DataConstraints.java index 8032beff7..de0d215bb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/misc/DataConstraints.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/misc/DataConstraints.java @@ -29,6 +29,7 @@ import java.util.function.Predicate; import java.util.regex.Pattern; public final class DataConstraints { + private DataConstraints() {} public static final int MAX_PERMISSION_LENGTH = 200; @@ -59,6 +60,4 @@ public final class DataConstraints { public static final Predicate WORLD_NAME_TEST = s -> !s.isEmpty() && s.length() <= MAX_WORLD_LENGTH; - private DataConstraints() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/DateParser.java b/common/src/main/java/me/lucko/luckperms/common/util/DateParser.java index a3a72bfec..c05ab48df 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/DateParser.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/DateParser.java @@ -39,6 +39,8 @@ import java.util.stream.Stream; * see: https://github.com/drtshock/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/utils/DateUtil.java */ public final class DateParser { + private DateParser() {} + private static final Pattern TIME_PATTERN = Pattern.compile(Stream.of("y", "mo", "w", "d", "h", "m").map(i -> "(?:([0-9]+)\\s*" + i + "[a-z]*[,\\s]*)?").collect(Collectors.joining()) + "(?:([0-9]+)\\s*(?:s[a-z]*)?)?", Pattern.CASE_INSENSITIVE); private static final int MAX_YEARS = 100000; @@ -130,6 +132,4 @@ public final class DateParser { return (c.getTimeInMillis() / 1000) + 1; } - private DateParser() {} - } \ No newline at end of file diff --git a/common/src/main/java/me/lucko/luckperms/common/util/ExpiringSet.java b/common/src/main/java/me/lucko/luckperms/common/util/ExpiringSet.java index 8c8401030..3ff953fc1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/ExpiringSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/ExpiringSet.java @@ -26,7 +26,6 @@ package me.lucko.luckperms.common.util; import com.github.benmanes.caffeine.cache.Cache; -import com.github.benmanes.caffeine.cache.Caffeine; import com.google.common.collect.ForwardingSet; import org.checkerframework.checker.nullness.qual.NonNull; @@ -45,7 +44,7 @@ public class ExpiringSet extends ForwardingSet { private final Set setView; public ExpiringSet(long duration, TimeUnit unit) { - this.cache = Caffeine.newBuilder().expireAfterAccess(duration, unit).build(); + this.cache = CaffeineFactory.newBuilder().expireAfterAccess(duration, unit).build(); this.setView = this.cache.asMap().keySet(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/ImmutableCollectors.java b/common/src/main/java/me/lucko/luckperms/common/util/ImmutableCollectors.java index 420834244..99c0b6627 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/ImmutableCollectors.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/ImmutableCollectors.java @@ -37,6 +37,7 @@ import java.util.function.Function; import java.util.stream.Collector; public final class ImmutableCollectors { + private ImmutableCollectors() {} private static final Collector, ImmutableList> LIST = Collector.of( ImmutableList.Builder::new, @@ -98,6 +99,4 @@ public final class ImmutableCollectors { ); } - private ImmutableCollectors() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/Iterators.java b/common/src/main/java/me/lucko/luckperms/common/util/Iterators.java index 83576bbc1..81cd5b1f0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/Iterators.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/Iterators.java @@ -32,6 +32,7 @@ import java.util.function.Consumer; import java.util.function.Function; public final class Iterators { + private Iterators() {} public static void iterate(Iterable iterable, Consumer action) { for (I i : iterable) { @@ -86,6 +87,4 @@ public final class Iterators { return lists; } - private Iterators() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/MoreFiles.java b/common/src/main/java/me/lucko/luckperms/common/util/MoreFiles.java index b964a5acd..37ee3326c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/MoreFiles.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/MoreFiles.java @@ -30,6 +30,7 @@ import java.nio.file.Files; import java.nio.file.Path; public final class MoreFiles { + private MoreFiles() {} public static Path createFileIfNotExists(Path path) throws IOException { if (!Files.exists(path)) { @@ -56,5 +57,4 @@ public final class MoreFiles { return path; } - private MoreFiles() {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/PatternCache.java b/common/src/main/java/me/lucko/luckperms/common/util/PatternCache.java index 94d1ee9f5..303a58918 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/PatternCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/PatternCache.java @@ -33,6 +33,7 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; public final class PatternCache { + private PatternCache() {} private static final Map CACHE = LoadingMap.of(s -> { try { @@ -92,6 +93,4 @@ public final class PatternCache { } } - private PatternCache() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/Predicates.java b/common/src/main/java/me/lucko/luckperms/common/util/Predicates.java index c6b9290c6..3c4bc1041 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/Predicates.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/Predicates.java @@ -33,6 +33,8 @@ import java.util.function.Predicate; * A collection of predicate utilities used mostly in command classes */ public final class Predicates { + private Predicates() {} + private static final Predicate FALSE = new Predicate() { @Override public boolean test(Object o) { return false; } @Override public Predicate and(Predicate other) { return this; } @@ -74,5 +76,4 @@ public final class Predicates { return t::equals; } - private Predicates() {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/PrivateMethodHandles.java b/common/src/main/java/me/lucko/luckperms/common/util/PrivateMethodHandles.java index 571b01587..1588cfa3d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/PrivateMethodHandles.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/PrivateMethodHandles.java @@ -30,7 +30,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; public final class PrivateMethodHandles { - private PrivateMethodHandles() {} private static final Constructor LOOKUP_CONSTRUCTOR; diff --git a/common/src/main/java/me/lucko/luckperms/common/util/Scripting.java b/common/src/main/java/me/lucko/luckperms/common/util/Scripting.java index bdefaf3e4..bcc1880e6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/Scripting.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/Scripting.java @@ -32,6 +32,8 @@ import javax.script.ScriptEngineManager; * Provides a nashorn script engine (lazily) */ public final class Scripting { + private Scripting() {} + private static ScriptEngine engine = null; // Lazily load @@ -42,6 +44,4 @@ public final class Scripting { return engine; } - private Scripting() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/TextUtils.java b/common/src/main/java/me/lucko/luckperms/common/util/TextUtils.java index f7e7b6fba..d1ff05154 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/TextUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/TextUtils.java @@ -35,6 +35,7 @@ import java.util.stream.Stream; @SuppressWarnings("deprecation") public final class TextUtils { + private TextUtils() {} public static String joinNewline(String... strings) { return joinNewline(Arrays.stream(strings)); @@ -68,6 +69,4 @@ public final class TextUtils { return input; } - private TextUtils() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/Uuids.java b/common/src/main/java/me/lucko/luckperms/common/util/Uuids.java index 216365df5..9f398a83f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/Uuids.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/Uuids.java @@ -34,6 +34,8 @@ import java.util.function.Predicate; * Utilities for working with {@link UUID}s. */ public final class Uuids { + private Uuids() {} + public static final Predicate PREDICATE = s -> parse(s) != null; public static @Nullable UUID fromString(String s) { @@ -59,6 +61,4 @@ public final class Uuids { return uuid; } - private Uuids() {} - } diff --git a/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java b/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java index 3d58fc4f2..1eaf929c3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java @@ -37,7 +37,6 @@ import java.io.IOException; * Utilities for the OkHttp client */ public final class HttpClient { - private HttpClient() {} private static final OkHttpClient CLIENT = new OkHttpClient.Builder() diff --git a/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java b/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java index 5977a6b64..2f34b4b1b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java @@ -63,6 +63,8 @@ import java.util.stream.Stream; * Utility methods for interacting with the LuckPerms web permission editor. */ public final class WebEditor { + private WebEditor() {} + private static final String USER_ID_PATTERN = "user/"; private static final String GROUP_ID_PATTERN = "group/"; @@ -235,6 +237,4 @@ public final class WebEditor { return nodes; } - private WebEditor() {} - } diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/PermissibleInjector.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/PermissibleInjector.java index 9607f568b..75a2b4a88 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/PermissibleInjector.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/PermissibleInjector.java @@ -41,6 +41,7 @@ import java.util.Set; * checks made by plugins. */ public final class PermissibleInjector { + private PermissibleInjector() {} /** * All permission checks made on standard Nukkit objects are effectively proxied to a @@ -141,6 +142,4 @@ public final class PermissibleInjector { } } - private PermissibleInjector() {} - } diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java index 1a272a9b2..71dcdac4e 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java @@ -42,6 +42,8 @@ import java.util.Set; * Utility class for converting between Sponge and LuckPerms context and tristate classes */ public final class CompatibilityUtil { + private CompatibilityUtil() {} + private static final Set EMPTY = ImmutableSet.of(); public static ImmutableContextSet convertContexts(Set contexts) { @@ -92,6 +94,4 @@ public final class CompatibilityUtil { } } - private CompatibilityUtil() {} - } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeCommandUtils.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeCommandUtils.java index 38626e588..1d7ea5849 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeCommandUtils.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeCommandUtils.java @@ -36,6 +36,7 @@ import java.util.List; import java.util.Map; public final class SpongeCommandUtils { + private SpongeCommandUtils() {} public static Tristate parseTristate(int index, List args) throws ArgumentParser.ArgumentException { String s = args.get(index).toLowerCase(); @@ -90,6 +91,4 @@ public final class SpongeCommandUtils { return MessageUtils.contextSetToString(localeManager, set); } - private SpongeCommandUtils() {} - } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/ProxyFactory.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/ProxyFactory.java index c0c3b756f..727dda56c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/ProxyFactory.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/ProxyFactory.java @@ -42,6 +42,8 @@ import org.spongepowered.api.service.permission.SubjectData; * Provides proxy instances which implement the SpongeAPI using the LuckPerms model. */ public final class ProxyFactory { + private ProxyFactory() {} + private static final boolean IS_API_7 = isApi7(); private static boolean isApi7() { try { @@ -89,6 +91,4 @@ public final class ProxyFactory { me.lucko.luckperms.sponge.service.proxy.api6.DescriptionBuilder.registerDescription(service, description); } - private ProxyFactory() {} - } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraphs.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraphs.java index 984e2f628..c20322a46 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraphs.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraphs.java @@ -31,8 +31,9 @@ import me.lucko.luckperms.sponge.service.model.calculated.CalculatedSubject; import java.util.stream.Collectors; public final class SubjectInheritanceGraphs { - private static final SubjectInheritanceGraph NON_CONTEXTUAL = new NonContextual(); + private SubjectInheritanceGraphs() {} + private static final SubjectInheritanceGraph NON_CONTEXTUAL = new NonContextual(); public static SubjectInheritanceGraph getGraph() { return NON_CONTEXTUAL; @@ -73,6 +74,4 @@ public final class SubjectInheritanceGraphs { .collect(Collectors.toList()); } } - - private SubjectInheritanceGraphs() {} } diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/service/CompatibilityUtil.java b/velocity/src/main/java/me/lucko/luckperms/velocity/service/CompatibilityUtil.java index 7370e0fa8..3dfe7d762 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/service/CompatibilityUtil.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/service/CompatibilityUtil.java @@ -33,6 +33,7 @@ import java.util.Objects; * Utility class for converting between Velocity and LuckPerms tristate classes */ public final class CompatibilityUtil { + private CompatibilityUtil() {} public static com.velocitypowered.api.permission.Tristate convertTristate(Tristate tristate) { Objects.requireNonNull(tristate, "tristate"); @@ -58,6 +59,4 @@ public final class CompatibilityUtil { } } - private CompatibilityUtil() {} - }