diff --git a/api/pom.xml b/api/pom.xml index 8ffa848ad..c5d10af0b 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -56,7 +56,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.4 + 3.0.0 attach-javadocs diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java index 92c339ca4..1851184db 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java @@ -113,8 +113,6 @@ public class BukkitConnectionListener extends AbstractLoginListener implements L this.plugin.getLog().severe("Player connection was re-allowed for " + e.getUniqueId()); e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, ""); } - - return; } } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/DummyPermissibleBase.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/DummyPermissibleBase.java index e434bc5aa..057b19268 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/DummyPermissibleBase.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/DummyPermissibleBase.java @@ -40,23 +40,15 @@ public class DummyPermissibleBase extends PermissibleBase { private static final Field PERMISSIONS_FIELD; static { - Field attachmentsField; try { - attachmentsField = PermissibleBase.class.getDeclaredField("attachments"); - attachmentsField.setAccessible(true); - } catch (NoSuchFieldException e) { - throw new ExceptionInInitializerError(e); - } - ATTACHMENTS_FIELD = attachmentsField; + ATTACHMENTS_FIELD = PermissibleBase.class.getDeclaredField("attachments"); + ATTACHMENTS_FIELD.setAccessible(true); - Field permissionsField; - try { - permissionsField = PermissibleBase.class.getDeclaredField("permissions"); - permissionsField.setAccessible(true); + PERMISSIONS_FIELD = PermissibleBase.class.getDeclaredField("permissions"); + PERMISSIONS_FIELD.setAccessible(true); } catch (NoSuchFieldException e) { throw new ExceptionInInitializerError(e); } - PERMISSIONS_FIELD = permissionsField; } public static void nullFields(PermissibleBase permissibleBase) { diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/LPPermissionAttachment.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/LPPermissionAttachment.java index 9c9cb4655..8b703962a 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/LPPermissionAttachment.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/LPPermissionAttachment.java @@ -59,14 +59,12 @@ public class LPPermissionAttachment extends PermissionAttachment { private static final Field PERMISSION_ATTACHMENT_PERMISSIONS_FIELD; static { - Field permissionAttachmentPermissionsField; try { - permissionAttachmentPermissionsField = PermissionAttachment.class.getDeclaredField("permissions"); - permissionAttachmentPermissionsField.setAccessible(true); + PERMISSION_ATTACHMENT_PERMISSIONS_FIELD = PermissionAttachment.class.getDeclaredField("permissions"); + PERMISSION_ATTACHMENT_PERMISSIONS_FIELD.setAccessible(true); } catch (NoSuchFieldException e) { throw new ExceptionInInitializerError(e); } - PERMISSION_ATTACHMENT_PERMISSIONS_FIELD = permissionAttachmentPermissionsField; } /** diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/PermissibleInjector.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/PermissibleInjector.java index aba91b4c0..6cc2f5328 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/PermissibleInjector.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/PermissibleInjector.java @@ -56,35 +56,26 @@ public final class PermissibleInjector { private static final Field PERMISSIBLE_BASE_ATTACHMENTS_FIELD; static { - Field humanEntityPermissibleField; - Field permissibleBaseAttachmentsField; - try { - // Catch all. If this setup doesn't fully complete without - // exceptions, then the Injector will not work. - // Try to load the permissible field. + Field humanEntityPermissibleField; try { // craftbukkit humanEntityPermissibleField = ReflectionUtil.obcClass("entity.CraftHumanEntity").getDeclaredField("perm"); humanEntityPermissibleField.setAccessible(true); - } catch (Exception e) { // glowstone humanEntityPermissibleField = Class.forName("net.glowstone.entity.GlowHumanEntity").getDeclaredField("permissions"); humanEntityPermissibleField.setAccessible(true); } + HUMAN_ENTITY_PERMISSIBLE_FIELD = humanEntityPermissibleField; // Try to load the attachments field. - permissibleBaseAttachmentsField = PermissibleBase.class.getDeclaredField("attachments"); - permissibleBaseAttachmentsField.setAccessible(true); - - } catch (Throwable t) { - throw new RuntimeException("Injector did not init successfully.", t); + PERMISSIBLE_BASE_ATTACHMENTS_FIELD = PermissibleBase.class.getDeclaredField("attachments"); + PERMISSIBLE_BASE_ATTACHMENTS_FIELD.setAccessible(true); + } catch (ClassNotFoundException | NoSuchFieldException e) { + throw new ExceptionInInitializerError(e); } - - HUMAN_ENTITY_PERMISSIBLE_FIELD = humanEntityPermissibleField; - PERMISSIBLE_BASE_ATTACHMENTS_FIELD = permissibleBaseAttachmentsField; } /** diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/SubscriptionMapInjector.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/SubscriptionMapInjector.java index 6dfa7879d..0d1dc387b 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/SubscriptionMapInjector.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/SubscriptionMapInjector.java @@ -39,14 +39,12 @@ public class SubscriptionMapInjector implements Runnable { private static final Field PERM_SUBS_FIELD; static { - Field permSubsField; try { - permSubsField = SimplePluginManager.class.getDeclaredField("permSubs"); - permSubsField.setAccessible(true); + PERM_SUBS_FIELD = SimplePluginManager.class.getDeclaredField("permSubs"); + PERM_SUBS_FIELD.setAccessible(true); } catch (NoSuchFieldException e) { throw new ExceptionInInitializerError(e); } - PERM_SUBS_FIELD = permSubsField; } private final LPBukkitPlugin plugin; diff --git a/common/pom.xml b/common/pom.xml index 40ea3b2eb..e95a627d3 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -89,7 +89,7 @@ com.github.ben-manes.caffeine caffeine - 2.6.0 + 2.6.1 provided @@ -144,7 +144,7 @@ com.zaxxer HikariCP - 2.7.3 + 2.7.6 provided @@ -158,7 +158,7 @@ org.mongodb mongo-java-driver - 3.5.0 + 3.6.1 provided diff --git a/common/src/main/java/me/lucko/luckperms/common/api/ApiRegistrationUtil.java b/common/src/main/java/me/lucko/luckperms/common/api/ApiRegistrationUtil.java index 41df7c8f8..74413ecb5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/ApiRegistrationUtil.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/ApiRegistrationUtil.java @@ -34,20 +34,15 @@ public class ApiRegistrationUtil { private static final Method REGISTER; private static final Method UNREGISTER; static { - Method register; - Method unregister; try { - register = LuckPerms.class.getDeclaredMethod("registerProvider", LuckPermsApi.class); - register.setAccessible(true); + REGISTER = LuckPerms.class.getDeclaredMethod("registerProvider", LuckPermsApi.class); + REGISTER.setAccessible(true); - unregister = LuckPerms.class.getDeclaredMethod("unregisterProvider"); - unregister.setAccessible(true); + UNREGISTER = LuckPerms.class.getDeclaredMethod("unregisterProvider"); + UNREGISTER.setAccessible(true); } catch (NoSuchMethodException e) { throw new ExceptionInInitializerError(e); } - - REGISTER = register; - UNREGISTER = unregister; } public static void registerProvider(LuckPermsApi luckPermsApi) { diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java index 83d566c6a..57c213497 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java @@ -61,22 +61,22 @@ public enum Dependency { CAFFEINE( "com{}github{}ben-manes{}caffeine", "caffeine", - "2.6.0", - "JmT16VQnCnVBAjRJCQkkkjmSVx2jajpzeBuKwpbzDA8=", + "2.6.1", + "5F55lb0PmSThBWkRJ9mwkvN+8xT6uDZKIwKk37QW0co=", Relocation.of("caffeine", "com{}github{}benmanes{}caffeine") ), MARIADB_DRIVER( "org{}mariadb{}jdbc", "mariadb-java-client", - "2.2.0", - "/q0LPGHrp3L9rvKr7TuA6urbtXBqvXis92mP4KhxzUw=", + "2.2.1", + "K/WUWx66IX2PpclGA6Eeczs5FyuzqBdcmS/IzNLzKW8=", Relocation.of("mariadb", "org{}mariadb{}jdbc") ), MYSQL_DRIVER( "mysql", "mysql-connector-java", - "5.1.44", - "d4RZVzTeWpoHBPB/tQP3mSafNy7L9MDUSOt4Ku9LGCc=", + "5.1.45", + "WbqXFalbltVXkMdH8kxUmr1kXNHpQdrlSxOMATMwDWQ=", Relocation.of("mysql", "com{}mysql") ), POSTGRESQL_DRIVER( @@ -105,8 +105,8 @@ public enum Dependency { HIKARI( "com{}zaxxer", "HikariCP", - "2.7.4", - "y9JE6/VmbydCqlV1z468+oqdkBswBk6aw+ECT178AT4=", + "2.7.6", + "gEhb0Z6eOIgGT5mG9NhyyEtbBxJx/Rks6aDiWUnmqK4=", Relocation.of("hikari", "com{}zaxxer{}hikari") ), SLF4J_SIMPLE( @@ -124,8 +124,8 @@ public enum Dependency { MONGODB_DRIVER( "org.mongodb", "mongo-java-driver", - "3.5.0", - "gxrbKVSI/xM6r+6uL7g7I0DzNV+hlNTtfw4UL13XdK8=", + "3.6.1", + "Po8eyOBWv8XjREKSFrQh/NKHvLabtOysxbEFiD35cEk=", Relocation.allOf( Relocation.of("mongodb", "com{}mongodb"), Relocation.of("bson", "org{}bson") diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/classloader/ReflectionClassLoader.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/classloader/ReflectionClassLoader.java index 44263de45..042c11731 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/classloader/ReflectionClassLoader.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/classloader/ReflectionClassLoader.java @@ -36,14 +36,12 @@ public class ReflectionClassLoader implements PluginClassLoader { private static final Method ADD_URL_METHOD; static { - Method addUrlMethod; try { - addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - addUrlMethod.setAccessible(true); + ADD_URL_METHOD = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); + ADD_URL_METHOD.setAccessible(true); } catch (NoSuchMethodException e) { throw new ExceptionInInitializerError(e); } - ADD_URL_METHOD = addUrlMethod; } private final URLClassLoader classLoader; diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/dao/mongodb/MongoDao.java b/common/src/main/java/me/lucko/luckperms/common/storage/dao/mongodb/MongoDao.java index 0f6ac5d86..b85b5ff2d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/dao/mongodb/MongoDao.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/dao/mongodb/MongoDao.java @@ -28,6 +28,7 @@ package me.lucko.luckperms.common.storage.dao.mongodb; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.mongodb.MongoClient; +import com.mongodb.MongoClientOptions; import com.mongodb.MongoCredential; import com.mongodb.ServerAddress; import com.mongodb.client.MongoCollection; @@ -61,7 +62,6 @@ import me.lucko.luckperms.common.storage.dao.AbstractDao; import org.bson.Document; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -102,9 +102,9 @@ public class MongoDao extends AbstractDao { ServerAddress address = new ServerAddress(host, port); if (credential == null) { - this.mongoClient = new MongoClient(address, Collections.emptyList()); + this.mongoClient = new MongoClient(address); } else { - this.mongoClient = new MongoClient(address, Collections.singletonList(credential)); + this.mongoClient = new MongoClient(address, credential, MongoClientOptions.builder().build()); } this.database = this.mongoClient.getDatabase(this.configuration.getDatabase()); diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/CollationKeyCache.java b/common/src/main/java/me/lucko/luckperms/common/utils/CollationKeyCache.java index d15555412..3d997a4bf 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/CollationKeyCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/CollationKeyCache.java @@ -37,9 +37,9 @@ import java.util.concurrent.TimeUnit; public final class CollationKeyCache implements Comparator { private static final CollationKeyCache INSTANCE = new CollationKeyCache(); - private static final Collator COLLATOR = Collator.getInstance(Locale.ENGLISH); - + private static final Collator COLLATOR; static { + COLLATOR = Collator.getInstance(Locale.ENGLISH); COLLATOR.setStrength(Collator.IDENTICAL); COLLATOR.setDecomposition(Collator.FULL_DECOMPOSITION); } @@ -78,14 +78,11 @@ public final class CollationKeyCache implements Comparator { return i; } } - - // fallback to standard string comparison - return o1.compareTo(o2); } catch (Exception e) { // ignored } - // shrug - return 0; + // fallback to standard string comparison + return o1.compareTo(o2); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/Cycle.java b/common/src/main/java/me/lucko/luckperms/common/utils/Cycle.java index d569b3d4f..48563f22d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/Cycle.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/Cycle.java @@ -50,7 +50,7 @@ public class Cycle { /** * The current position of the cursor */ - private AtomicInteger cursor = new AtomicInteger(0); + private final AtomicInteger cursor = new AtomicInteger(0); public Cycle(List objects) { if (objects == null || objects.isEmpty()) { diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java index b3c118a09..c2c7af268 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java @@ -71,7 +71,7 @@ public class VerboseListener { // the sender to notify each time the listener processes a check which passes the filter private final Sender notifiedSender; // the filter - private VerboseFilter filter; + private final VerboseFilter filter; // if we should notify the sender private final boolean notify; // the number of checks we have processed