diff --git a/Core/src/main/java/fr/pandacube/lib/core/permissions/PermissionsBackendWriter.java b/Core/src/main/java/fr/pandacube/lib/core/permissions/PermissionsBackendWriter.java index 6029063..6a35e9a 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/permissions/PermissionsBackendWriter.java +++ b/Core/src/main/java/fr/pandacube/lib/core/permissions/PermissionsBackendWriter.java @@ -1,5 +1,7 @@ package fr.pandacube.lib.core.permissions; +import java.util.Objects; + import com.google.common.base.Preconditions; import fr.pandacube.lib.core.db.DB; @@ -10,9 +12,9 @@ import fr.pandacube.lib.core.permissions.SQLPermissions.EntityType; /* package */ void addSelfPermission(String name, EntityType type, String permission, String server, String world) { - Preconditions.checkNotNull(name, "name cannot be null"); - Preconditions.checkNotNull(type, "type cannot be null"); - Preconditions.checkNotNull(permission, "permission cannot be null"); + Objects.requireNonNull(name, "name cannot be null"); + Objects.requireNonNull(type, "type cannot be null"); + Objects.requireNonNull(permission, "permission cannot be null"); Preconditions.checkArgument(world == null || server != null, "world not null but server is null"); name = name.toLowerCase(); permission = permission.toLowerCase(); @@ -25,9 +27,9 @@ import fr.pandacube.lib.core.permissions.SQLPermissions.EntityType; } /* package */ void removeSelfPermission(String name, EntityType type, String permission, String server, String world) { - Preconditions.checkNotNull(name, "name cannot be null"); - Preconditions.checkNotNull(type, "type cannot be null"); - Preconditions.checkNotNull(permission, "permission cannot be null"); + Objects.requireNonNull(name, "name cannot be null"); + Objects.requireNonNull(type, "type cannot be null"); + Objects.requireNonNull(permission, "permission cannot be null"); Preconditions.checkArgument(world == null || server != null, "world not null but server is null"); name = name.toLowerCase(); permission = permission.toLowerCase(); @@ -47,7 +49,7 @@ import fr.pandacube.lib.core.permissions.SQLPermissions.EntityType; /* package */ void setGroupDefault(String name, boolean deflt) { - Preconditions.checkNotNull(name, "name cannot be null"); + Objects.requireNonNull(name, "name cannot be null"); name = name.toLowerCase(); try { SQLPermissions entry = DB.getFirst(SQLPermissions.class, @@ -85,8 +87,8 @@ import fr.pandacube.lib.core.permissions.SQLPermissions.EntityType; /* package */ void setSelfPrefix(String name, EntityType type, String prefix) { - Preconditions.checkNotNull(name, "name cannot be null"); - Preconditions.checkNotNull(type, "type cannot be null"); + Objects.requireNonNull(name, "name cannot be null"); + Objects.requireNonNull(type, "type cannot be null"); name = name.toLowerCase(); try { @@ -118,8 +120,8 @@ import fr.pandacube.lib.core.permissions.SQLPermissions.EntityType; } /* package */ void setSelfSuffix(String name, EntityType type, String suffix) { - Preconditions.checkNotNull(name, "name cannot be null"); - Preconditions.checkNotNull(type, "type cannot be null"); + Objects.requireNonNull(name, "name cannot be null"); + Objects.requireNonNull(type, "type cannot be null"); name = name.toLowerCase(); try { @@ -155,9 +157,9 @@ import fr.pandacube.lib.core.permissions.SQLPermissions.EntityType; /* package */ void addInheritance(String name, EntityType type, String inheritance) { - Preconditions.checkNotNull(name, "name cannot be null"); - Preconditions.checkNotNull(type, "type cannot be null"); - Preconditions.checkNotNull(inheritance, "inheritance cannot be null"); + Objects.requireNonNull(name, "name cannot be null"); + Objects.requireNonNull(type, "type cannot be null"); + Objects.requireNonNull(inheritance, "inheritance cannot be null"); name = name.toLowerCase(); inheritance = inheritance.toLowerCase(); String key = type == EntityType.Group ? "inheritances" : "groups"; @@ -179,9 +181,9 @@ import fr.pandacube.lib.core.permissions.SQLPermissions.EntityType; } /* package */ void removeInheritance(String name, EntityType type, String inheritance) { - Preconditions.checkNotNull(name, "name cannot be null"); - Preconditions.checkNotNull(type, "type cannot be null"); - Preconditions.checkNotNull(inheritance, "inheritance cannot be null"); + Objects.requireNonNull(name, "name cannot be null"); + Objects.requireNonNull(type, "type cannot be null"); + Objects.requireNonNull(inheritance, "inheritance cannot be null"); name = name.toLowerCase(); inheritance = inheritance.toLowerCase(); String key = type == EntityType.Group ? "inheritances" : "groups"; @@ -201,9 +203,9 @@ import fr.pandacube.lib.core.permissions.SQLPermissions.EntityType; } /* package */ void setInheritance(String name, EntityType type, String inheritance) { - Preconditions.checkNotNull(name, "name cannot be null"); - Preconditions.checkNotNull(type, "type cannot be null"); - Preconditions.checkNotNull(inheritance, "inheritance cannot be null"); + Objects.requireNonNull(name, "name cannot be null"); + Objects.requireNonNull(type, "type cannot be null"); + Objects.requireNonNull(inheritance, "inheritance cannot be null"); name = name.toLowerCase(); inheritance = inheritance.toLowerCase(); String key = type == EntityType.Group ? "inheritances" : "groups"; diff --git a/Core/src/main/java/fr/pandacube/lib/core/permissions/PermissionsResolver.java b/Core/src/main/java/fr/pandacube/lib/core/permissions/PermissionsResolver.java index cdf2b91..e583c51 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/permissions/PermissionsResolver.java +++ b/Core/src/main/java/fr/pandacube/lib/core/permissions/PermissionsResolver.java @@ -80,8 +80,8 @@ public class PermissionsResolver { .build(); private String getEffectiveData(String name, EntityType type, DataType dataType) { - Preconditions.checkNotNull(name, "name can’t be null"); - Preconditions.checkNotNull(type, "type can’t be null"); + Objects.requireNonNull(name, "name can’t be null"); + Objects.requireNonNull(type, "type can’t be null"); try { return effectiveDataCache.get(new DataCacheKey(name, type, dataType), () -> { @@ -239,8 +239,8 @@ public class PermissionsResolver { .build(); /* package */ Map getEffectivePermissionList(String name, EntityType type, String server, String world) { - Preconditions.checkNotNull(name, "name can’t be null"); - Preconditions.checkNotNull(type, "type can’t be null"); + Objects.requireNonNull(name, "name can’t be null"); + Objects.requireNonNull(type, "type can’t be null"); Preconditions.checkArgument(world == null || server != null, "world not null but server is null"); String fServer = server == null ? null : server.toLowerCase(); @@ -271,9 +271,9 @@ public class PermissionsResolver { .build(); /* package */ Boolean getEffectivePermission(String name, EntityType type, String permission, String server, String world) { - Preconditions.checkNotNull(name, "name can’t be null"); - Preconditions.checkNotNull(type, "type can’t be null"); - Preconditions.checkNotNull(permission, "permission can’t be null"); + Objects.requireNonNull(name, "name can’t be null"); + Objects.requireNonNull(type, "type can’t be null"); + Objects.requireNonNull(permission, "permission can’t be null"); Preconditions.checkArgument(world == null || server != null, "world not null but server is null"); boolean reversed = false; diff --git a/Core/src/main/java/fr/pandacube/lib/core/players/IPlayerManager.java b/Core/src/main/java/fr/pandacube/lib/core/players/IPlayerManager.java index 6c0fc5b..761ea8f 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/players/IPlayerManager.java +++ b/Core/src/main/java/fr/pandacube/lib/core/players/IPlayerManager.java @@ -5,10 +5,10 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.TimeUnit; -import com.google.common.base.Preconditions; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -151,7 +151,7 @@ public abstract class IPlayerManager { Set searchKw; try { searchKw = result.getSearchKeywords(); - Preconditions.checkNotNull(searchKw, "SearchResult instance must provide a non null set of search keywords"); + Objects.requireNonNull(searchKw, "SearchResult instance must provide a non null set of search keywords"); searchKw = searchKw.stream() .filter(e -> e != null) .map(String::toLowerCase) @@ -61,7 +61,7 @@ public class SearchEngine { Set suggestsKw; try { suggestsKw = result.getSuggestionKeywords(); - Preconditions.checkNotNull(suggestsKw, "SearchResult instance must provide a non null set of suggestions keywords"); + Objects.requireNonNull(suggestsKw, "SearchResult instance must provide a non null set of suggestions keywords"); suggestsKw = new HashSet<>(suggestsKw); suggestsKw.removeIf(e -> e == null); } catch (Exception e) {