diff --git a/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java b/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java index a8fe6d6d..13647535 100644 --- a/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java +++ b/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java @@ -202,8 +202,11 @@ public interface LuckPermsApi { * mapping system.

* * @return the uuid cache + * @deprecated this feature is now handled internally - and the API returns a + * No-op implementation of this class. */ @Nonnull + @Deprecated UuidCache getUuidCache(); /** diff --git a/api/src/main/java/me/lucko/luckperms/api/UuidCache.java b/api/src/main/java/me/lucko/luckperms/api/UuidCache.java index 5314001c..ac47e046 100644 --- a/api/src/main/java/me/lucko/luckperms/api/UuidCache.java +++ b/api/src/main/java/me/lucko/luckperms/api/UuidCache.java @@ -33,15 +33,10 @@ import javax.annotation.Nonnull; * A UUID cache for online users, between external Mojang UUIDs, and internal * LuckPerms UUIDs. * - *

A user's internal LuckPerms UUID is always the same as their Mojang one, - * unless use-server-uuids is disabled.

- * - *

When this setting is disabled, this cache becomes active, and allows you - * to convert between 'internal' and 'server provided' uuids.

- * - *

This is only effective for online players. - * Use {@link Storage#getUUID(String)} for offline players.

+ * @deprecated this feature is now handled internally - and the API returns a + * No-op implementation of this class. */ +@Deprecated public interface UuidCache { /** @@ -56,6 +51,7 @@ public interface UuidCache { * @return the corresponding internal UUID */ @Nonnull + @Deprecated UUID getUUID(@Nonnull UUID mojangUuid); /** @@ -67,6 +63,7 @@ public interface UuidCache { * @return the corresponding external UUID */ @Nonnull + @Deprecated UUID getExternalUUID(@Nonnull UUID internalUuid); } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java index 6abb8b20..c5a0abba 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java @@ -80,7 +80,6 @@ import me.lucko.luckperms.common.tasks.CacheHousekeepingTask; import me.lucko.luckperms.common.tasks.ExpireTemporaryTask; import me.lucko.luckperms.common.tasks.UpdateTask; import me.lucko.luckperms.common.treeview.PermissionVault; -import me.lucko.luckperms.common.utils.UuidCache; import me.lucko.luckperms.common.verbose.VerboseHandler; import org.bukkit.command.PluginCommand; @@ -120,7 +119,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { private Storage storage; private FileWatcher fileWatcher = null; private InternalMessagingService messagingService = null; - private UuidCache uuidCache; private LuckPermsApiProvider apiProvider; private EventFactory eventFactory; private Logger log; @@ -238,7 +236,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { // load internal managers getLog().info("Loading internal permission managers..."); - this.uuidCache = new UuidCache(this); this.userManager = new StandardUserManager(this); this.groupManager = new StandardGroupManager(this); this.trackManager = new StandardTrackManager(this); @@ -318,7 +315,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { this.scheduler.doAsync(() -> { try { connectionListener.loadUser(player.getUniqueId(), player.getName()); - User user = getUserManager().getIfLoaded(getUuidCache().getUUID(player.getUniqueId())); + User user = getUserManager().getIfLoaded(player.getUniqueId()); if (user != null) { this.scheduler.doSync(() -> { try { @@ -363,7 +360,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { player.setOp(false); } - final User user = getUserManager().getIfLoaded(getUuidCache().getUUID(player.getUniqueId())); + final User user = getUserManager().getIfLoaded(player.getUniqueId()); if (user != null) { user.getCachedData().invalidateCaches(); getUserManager().unload(user); @@ -496,7 +493,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { @Override public Player getPlayer(User user) { - return getServer().getPlayer(this.uuidCache.getExternalUUID(user.getUuid())); + return getServer().getPlayer(user.getUuid()); } @Override @@ -615,11 +612,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { return this.storage; } - @Override - public UuidCache getUuidCache() { - return this.uuidCache; - } - @Override public LuckPermsApiProvider getApiProvider() { return this.apiProvider; 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 b9cfecd9..710ae39e 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 @@ -129,7 +129,7 @@ public class BukkitConnectionListener extends AbstractLoginListener implements L this.plugin.getLog().info("Processing login for " + player.getUniqueId() + " - " + player.getName()); } - final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId())); + final User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId()); /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */ if (user == null) { diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultChatHook.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultChatHook.java index 12e2b437..ba6ab3d8 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultChatHook.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultChatHook.java @@ -246,7 +246,7 @@ public class VaultChatHook extends AbstractVaultChat { // utility methods for getting user and group instances private User getUser(UUID uuid) { - return this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(uuid)); + return this.plugin.getUserManager().getIfLoaded(uuid); } private Group getGroup(String name) { diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java index b4f3a97a..cb4017b5 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java @@ -287,7 +287,7 @@ public class VaultPermissionHook extends AbstractVaultPermission { // utility methods for getting user and group instances private User getUser(UUID uuid) { - return this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(uuid)); + return this.plugin.getUserManager().getIfLoaded(uuid); } private Group getGroup(String name) { diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index ffb0047c..74dc65bc 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -38,34 +38,6 @@ apply-global-groups: true # If users on this server should have global (non-world specific) groups applied apply-global-world-groups: true -# If UUIDs should be pulled from the server, or looked up by username based upon previous -# connections. -# -# This option should be set to true in most cases. When set to false, in order to get a player's -# UUID, LuckPerms will: -# -# 1. Check if a player with the given username has joined before, if they have, use the UUID they -# used on their previous login. -# 2. Save and return the players "current" uuid. -# -# For offline mode (cracked) servers, a players UUID is generated based upon their username. -# -# IMPORTANT: -# If you are using BungeeCord proxy running in online mode, it is important that "online-mode=false" -# is set in server.properties, but "bungeecord: true" is set in the spigot.yml. You also need to set -# "ip_forward: true" in BungeeCord's config.yml. -# -# If for whatever reason you are not able to do this, and do not have ip-forward enabled, then you -# may need to set "use-server-uuids" to false. -# -# If your proxy is running in offline mode, you should still be setting up ip-forwarding as -# described above, but may also find that you need to set "bungee-online-mode" to false in -# paper.yml, if you are using Paper. (https://ci.destroystokyo.com/job/PaperSpigot/) -# -# This option only really exists for networks who for whatever reason cannot setup proper ip -# forwarding. -use-server-uuids: true - # If the servers own UUID cache/lookup facility should be used when there is no record for a player # in the LuckPerms cache. use-server-uuid-cache: false diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java index e54035f7..a6b886a9 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java @@ -74,7 +74,6 @@ import me.lucko.luckperms.common.tasks.CacheHousekeepingTask; import me.lucko.luckperms.common.tasks.ExpireTemporaryTask; import me.lucko.luckperms.common.tasks.UpdateTask; import me.lucko.luckperms.common.treeview.PermissionVault; -import me.lucko.luckperms.common.utils.UuidCache; import me.lucko.luckperms.common.verbose.VerboseHandler; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -106,7 +105,6 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin { private Storage storage; private FileWatcher fileWatcher = null; private InternalMessagingService messagingService = null; - private UuidCache uuidCache; private LuckPermsApiProvider apiProvider; private EventFactory eventFactory; private Logger log; @@ -183,7 +181,6 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin { // load internal managers getLog().info("Loading internal permission managers..."); - this.uuidCache = new UuidCache(this); this.userManager = new StandardUserManager(this); this.groupManager = new StandardGroupManager(this); this.trackManager = new StandardTrackManager(this); @@ -322,7 +319,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin { @Override public ProxiedPlayer getPlayer(User user) { - return getProxy().getPlayer(this.uuidCache.getExternalUUID(user.getUuid())); + return getProxy().getPlayer(user.getUuid()); } @Override @@ -421,11 +418,6 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin { return this.storage; } - @Override - public UuidCache getUuidCache() { - return this.uuidCache; - } - @Override public LuckPermsApiProvider getApiProvider() { return this.apiProvider; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java b/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java index 2a3a4c3a..b8b161d3 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java @@ -105,7 +105,7 @@ public class BungeeConnectionListener extends AbstractLoginListener implements L @EventHandler public void onPlayerPostLogin(PostLoginEvent e) { final ProxiedPlayer player = e.getPlayer(); - final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(e.getPlayer().getUniqueId())); + final User user = this.plugin.getUserManager().getIfLoaded(e.getPlayer().getUniqueId()); if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) { this.plugin.getLog().info("Processing post-login for " + player.getUniqueId() + " - " + player.getName()); diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeePermissionCheckListener.java b/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeePermissionCheckListener.java index 1a82e2c1..3a91bfe4 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeePermissionCheckListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeePermissionCheckListener.java @@ -54,7 +54,7 @@ public class BungeePermissionCheckListener implements Listener { ProxiedPlayer player = ((ProxiedPlayer) e.getSender()); - User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId())); + User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId()); if (user == null) { e.setHasPermission(false); return; @@ -77,7 +77,7 @@ public class BungeePermissionCheckListener implements Listener { ProxiedPlayer player = ((ProxiedPlayer) e.getSender()); - User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId())); + User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId()); if (user == null) { e.setResult(Tristate.UNDEFINED); return; diff --git a/bungee/src/main/resources/config.yml b/bungee/src/main/resources/config.yml index 6178cbbc..2531f8a2 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -38,34 +38,6 @@ apply-global-groups: true # If users on this server should have global (non-world specific) groups applied apply-global-world-groups: true -# If UUIDs should be pulled from the server, or looked up by username based upon previous -# connections. -# -# This option should be set to true in most cases. When set to false, in order to get a player's -# UUID, LuckPerms will: -# -# 1. Check if a player with the given username has joined before, if they have, use the UUID they -# used on their previous login. -# 2. Save and return the players "current" uuid. -# -# For offline mode (cracked) servers, a players UUID is generated based upon their username. -# -# IMPORTANT: -# If you are using BungeeCord proxy running in online mode, it is important that "online-mode=false" -# is set in server.properties, but "bungeecord: true" is set in the spigot.yml. You also need to set -# "ip_forward: true" in BungeeCord's config.yml. -# -# If for whatever reason you are not able to do this, and do not have ip-forward enabled, then you -# may need to set "use-server-uuids" to false. -# -# If your proxy is running in offline mode, you should still be setting up ip-forwarding as -# described above, but may also find that you need to set "bungee-online-mode" to false in -# paper.yml, if you are using Paper. (https://ci.destroystokyo.com/job/PaperSpigot/) -# -# This option only really exists for networks who for whatever reason cannot setup proper ip -# forwarding. -use-server-uuids: true - # If the servers own UUID cache/lookup facility should be used when there is no record for a player # in the LuckPerms cache. # diff --git a/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java b/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java index 00dfda8d..4872a5f9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java @@ -49,6 +49,7 @@ import me.lucko.luckperms.common.api.delegates.misc.ApiMessagingService; import me.lucko.luckperms.common.api.delegates.misc.ApiMetaStackFactory; import me.lucko.luckperms.common.api.delegates.misc.ApiNodeFactory; import me.lucko.luckperms.common.api.delegates.misc.ApiPlatformInfo; +import me.lucko.luckperms.common.api.delegates.misc.NoopUuidCache; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.messaging.LuckPermsMessagingService; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -153,8 +154,9 @@ public class LuckPermsApiProvider implements LuckPermsApi { @Nonnull @Override + @Deprecated public UuidCache getUuidCache() { - return this.plugin.getUuidCache().getDelegate(); + return NoopUuidCache.INSTANCE; } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiUuidCache.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/NoopUuidCache.java similarity index 77% rename from common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiUuidCache.java rename to common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/NoopUuidCache.java index 42dff1c0..a00bfd1d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/ApiUuidCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/misc/NoopUuidCache.java @@ -27,29 +27,30 @@ package me.lucko.luckperms.common.api.delegates.misc; import me.lucko.luckperms.api.UuidCache; -import java.util.Objects; import java.util.UUID; import javax.annotation.Nonnull; -public class ApiUuidCache implements UuidCache { - private final me.lucko.luckperms.common.utils.UuidCache handle; +@Deprecated +@SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"}) +public class NoopUuidCache implements UuidCache { + public static final NoopUuidCache INSTANCE = new NoopUuidCache(); + + private NoopUuidCache() { - public ApiUuidCache(me.lucko.luckperms.common.utils.UuidCache handle) { - this.handle = handle; } @Nonnull @Override + @Deprecated public UUID getUUID(@Nonnull UUID external) { - Objects.requireNonNull(external, "external"); - return this.handle.getUUID(external); + return external; } @Nonnull @Override + @Deprecated public UUID getExternalUUID(@Nonnull UUID internal) { - Objects.requireNonNull(internal, "internal"); - return this.handle.getExternalUUID(internal); + return internal; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/ArgumentPermissions.java b/common/src/main/java/me/lucko/luckperms/common/commands/ArgumentPermissions.java index 214c34a4..fdba227d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/ArgumentPermissions.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/ArgumentPermissions.java @@ -77,7 +77,7 @@ public final class ArgumentPermissions { if (target instanceof User) { User targetUser = ((User) target); - if (plugin.getUuidCache().getExternalUUID(targetUser.getUuid()).equals(sender.getUuid())) { + if (targetUser.getUuid().equals(sender.getUuid())) { // the sender is trying to edit themselves Tristate ret = sender.getPermissionValue(base.getPermission() + ".modify.self"); if (ret != Tristate.UNDEFINED) { @@ -133,7 +133,7 @@ public final class ArgumentPermissions { if (target instanceof User) { User targetUser = ((User) target); - if (plugin.getUuidCache().getExternalUUID(targetUser.getUuid()).equals(sender.getUuid())) { + if (targetUser.getUuid().equals(sender.getUuid())) { // the sender is trying to view themselves Tristate ret = sender.getPermissionValue(base.getPermission() + ".view.self"); if (ret != Tristate.UNDEFINED) { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java index 219d54d7..8760e3ae 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java @@ -49,7 +49,7 @@ public class LogNotify extends SubCommand { } public static boolean isIgnoring(LuckPermsPlugin plugin, UUID uuid) { - User user = plugin.getUserManager().getIfLoaded(plugin.getUuidCache().getUUID(uuid)); + User user = plugin.getUserManager().getIfLoaded(uuid); if (user == null) { return false; } @@ -64,7 +64,7 @@ public class LogNotify extends SubCommand { } private static void setIgnoring(LuckPermsPlugin plugin, UUID uuid, boolean state) { - User user = plugin.getUserManager().getIfLoaded(plugin.getUuidCache().getUUID(uuid)); + User user = plugin.getUserManager().getIfLoaded(uuid); if (user == null) { return; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java index 79c86497..3a57ba50 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java @@ -59,7 +59,7 @@ public class UserInfo extends SubCommand { return CommandResult.NO_PERMISSION; } - Message status = plugin.isPlayerOnline(plugin.getUuidCache().getExternalUUID(user.getUuid())) ? Message.PLAYER_ONLINE : Message.PLAYER_OFFLINE; + Message status = plugin.isPlayerOnline(user.getUuid()) ? Message.PLAYER_ONLINE : Message.PLAYER_OFFLINE; Message.USER_INFO_GENERAL.send(sender, user.getName().orElse("Unknown"), 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 6790b7af..1bedd1be 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 @@ -118,14 +118,6 @@ public class ConfigKeys { */ public static final ConfigKey APPLYING_GLOBAL_WORLD_GROUPS = BooleanKey.of("apply-global-world-groups", true); - /** - * If the server provided uuids should be used. False if we should use the LP cache for existing users. - */ - public static final ConfigKey USE_SERVER_UUIDS = AbstractKey.of(c -> { - // backwards compatible with the old online-mode option - return c.contains("use-server-uuids") ? c.getBoolean("use-server-uuids", true) : c.getBoolean("online-mode", true); - }); - /** * # If the servers own UUID cache/lookup facility should be used when there is no record for a player in the LuckPerms cache. */ diff --git a/common/src/main/java/me/lucko/luckperms/common/managers/user/AbstractUserManager.java b/common/src/main/java/me/lucko/luckperms/common/managers/user/AbstractUserManager.java index ef1be8d2..643543a5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/managers/user/AbstractUserManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/managers/user/AbstractUserManager.java @@ -147,9 +147,7 @@ public abstract class AbstractUserManager extends AbstractManage @Override public CompletableFuture updateAllUsers() { return CompletableFuture.runAsync( - () -> this.plugin.getOnlinePlayers() - .map(u -> this.plugin.getUuidCache().getUUID(u)) - .forEach(u -> this.plugin.getStorage().loadUser(u, null).join()), + () -> this.plugin.getOnlinePlayers().forEach(u -> this.plugin.getStorage().loadUser(u, null).join()), this.plugin.getScheduler().async() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/managers/user/UserHousekeeper.java b/common/src/main/java/me/lucko/luckperms/common/managers/user/UserHousekeeper.java index 839c9036..627b5f45 100644 --- a/common/src/main/java/me/lucko/luckperms/common/managers/user/UserHousekeeper.java +++ b/common/src/main/java/me/lucko/luckperms/common/managers/user/UserHousekeeper.java @@ -76,7 +76,7 @@ public class UserHousekeeper implements Runnable { UUID uuid = identifier.getUuid(); // unload users which aren't online and who haven't been online (or tried to login) recently - if (this.recentlyUsed.contains(uuid) || this.recentlyUsedApi.contains(uuid) || this.plugin.isPlayerOnline(this.plugin.getUuidCache().getExternalUUID(uuid))) { + if (this.recentlyUsed.contains(uuid) || this.recentlyUsedApi.contains(uuid) || this.plugin.isPlayerOnline(uuid)) { return; } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/Group.java b/common/src/main/java/me/lucko/luckperms/common/model/Group.java index dce31b2a..7dac7fd5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/Group.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/Group.java @@ -63,7 +63,7 @@ public class Group extends PermissionHolder implements Identifiable { this.cachedData = new GroupCachedData(this); getPlugin().getEventFactory().handleGroupCacheLoad(this, this.cachedData); - // invalidate out caches when data is updated + // invalidate our caches when data is updated getStateListeners().add(this.refreshBuffer::request); } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java index 7c00bb1e..5a181195 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java @@ -191,7 +191,7 @@ public abstract class PermissionHolder { declareState(); } - protected void declareState() { + private void declareState() { /* only declare state of groups. the state manager isn't really being used now the caches in this class are gone, but it's useful for command output. */ if (this.getType().isGroup()) { @@ -255,20 +255,10 @@ public abstract class PermissionHolder { return this.transientNodes; } - /** - * Returns an immutable copy of this objects nodes - * - * @return an immutable copy of the multimap storing this objects nodes - */ public ImmutableSetMultimap getEnduringNodes() { return this.enduringNodes.immutable(); } - /** - * Returns an immutable copy of this objects transient nodes - * - * @return an immutable copy of the multimap storing this objects transient nodes - */ public ImmutableSetMultimap getTransientNodes() { return this.transientNodes.immutable(); } @@ -298,8 +288,8 @@ public abstract class PermissionHolder { * * @return a set containing the holders enduring and transient permissions */ - public LinkedHashSet getOwnNodesSet() { - LinkedHashSet ret = new LinkedHashSet<>(); + public Set getOwnNodesSet() { + Set ret = new LinkedHashSet<>(); this.transientNodes.copyTo(ret); this.enduringNodes.copyTo(ret); return ret; diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java index 988eb28e..bac2eef3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java @@ -51,7 +51,6 @@ import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.storage.Storage; import me.lucko.luckperms.common.storage.dao.file.FileWatcher; import me.lucko.luckperms.common.treeview.PermissionVault; -import me.lucko.luckperms.common.utils.UuidCache; import me.lucko.luckperms.common.verbose.VerboseHandler; import java.io.File; @@ -128,13 +127,6 @@ public interface LuckPermsPlugin { */ Logger getLog(); - /** - * Gets the UUID caching store for the platform - * - * @return the uuid cache - */ - UuidCache getUuidCache(); - /** * Gets the event factory * diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/AbstractLoginListener.java b/common/src/main/java/me/lucko/luckperms/common/utils/AbstractLoginListener.java index 4bd75957..f0b438dc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/AbstractLoginListener.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/AbstractLoginListener.java @@ -25,14 +25,12 @@ package me.lucko.luckperms.common.utils; -import me.lucko.luckperms.api.platform.PlatformType; import me.lucko.luckperms.common.assignments.AssignmentRule; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import java.util.UUID; -import java.util.concurrent.CompletableFuture; /** * Abstract listener utility for handling new player connections @@ -40,14 +38,8 @@ import java.util.concurrent.CompletableFuture; public abstract class AbstractLoginListener { private final LuckPermsPlugin plugin; - // if we should #join the uuid save future. - // this is only really necessary on BungeeCord, as the data may be needed - // on the backend, depending on uuid config options - private final boolean joinUuidSave; - protected AbstractLoginListener(LuckPermsPlugin plugin) { this.plugin = plugin; - this.joinUuidSave = plugin.getServerType() == PlatformType.BUNGEE; } public User loadUser(UUID u, String username) { @@ -56,34 +48,14 @@ public abstract class AbstractLoginListener { // register with the housekeeper to avoid accidental unloads this.plugin.getUserManager().getHouseKeeper().registerUsage(u); - final UuidCache cache = this.plugin.getUuidCache(); - if (!this.plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS)) { - UUID uuid = this.plugin.getStorage().noBuffer().getUUID(username).join(); - if (uuid != null) { - cache.addToCache(u, uuid); - } else { - // No previous data for this player - this.plugin.getEventFactory().handleUserFirstLogin(u, username); - cache.addToCache(u, u); - CompletableFuture future = this.plugin.getStorage().noBuffer().saveUUIDData(u, username); - if (this.joinUuidSave) { - future.join(); - } - } - } else { - String name = this.plugin.getStorage().noBuffer().getName(u).join(); - if (name == null) { - this.plugin.getEventFactory().handleUserFirstLogin(u, username); - } - - // Online mode, no cache needed. This is just for name -> uuid lookup. - CompletableFuture future = this.plugin.getStorage().noBuffer().saveUUIDData(u, username); - if (this.joinUuidSave) { - future.join(); - } + // save uuid data. + String name = this.plugin.getStorage().noBuffer().getName(u).join(); + if (name == null) { + this.plugin.getEventFactory().handleUserFirstLogin(u, username); } + this.plugin.getStorage().noBuffer().saveUUIDData(u, username); - User user = this.plugin.getStorage().noBuffer().loadUser(cache.getUUID(u), username).join(); + User user = this.plugin.getStorage().noBuffer().loadUser(u, username).join(); if (user == null) { throw new NullPointerException("User is null"); } else { diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/UuidCache.java b/common/src/main/java/me/lucko/luckperms/common/utils/UuidCache.java deleted file mode 100644 index 3f02ed35..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/utils/UuidCache.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.utils; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import com.google.common.collect.Maps; - -import me.lucko.luckperms.common.api.delegates.misc.ApiUuidCache; -import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.plugin.LuckPermsPlugin; - -import java.util.UUID; - -/** - * @see me.lucko.luckperms.api.UuidCache for docs - */ -public class UuidCache { - private final LuckPermsPlugin plugin; - - // External UUID --> Internal UUID - private final BiMap cache = Maps.synchronizedBiMap(HashBiMap.create()); - - private final ApiUuidCache delegate = new ApiUuidCache(this); - - public UuidCache(LuckPermsPlugin plugin) { - this.plugin = plugin; - } - - public UUID getUUID(UUID external) { - return inUse() ? external : this.cache.getOrDefault(external, external); - } - - public UUID getExternalUUID(UUID internal) { - return inUse() ? internal : this.cache.inverse().getOrDefault(internal, internal); - } - - public void addToCache(UUID external, UUID internal) { - if (inUse()) return; - this.cache.forcePut(external, internal); - } - - public void clearCache(UUID external) { - if (inUse()) return; - this.cache.remove(external); - } - - public int getSize() { - return inUse() ? 0 : this.cache.size(); - } - - private boolean inUse() { - return this.plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS); - } - - public ApiUuidCache getDelegate() { - return this.delegate; - } -} diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java index f099b7b7..d68c41bb 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -66,7 +66,6 @@ import me.lucko.luckperms.common.tasks.CacheHousekeepingTask; import me.lucko.luckperms.common.tasks.ExpireTemporaryTask; import me.lucko.luckperms.common.tasks.UpdateTask; import me.lucko.luckperms.common.treeview.PermissionVault; -import me.lucko.luckperms.common.utils.UuidCache; import me.lucko.luckperms.common.verbose.VerboseHandler; import me.lucko.luckperms.sponge.calculators.SpongeCalculatorFactory; import me.lucko.luckperms.sponge.commands.SpongeMainCommand; @@ -173,7 +172,6 @@ public class LPSpongePlugin implements LuckPermsSpongePlugin { private Storage storage; private FileWatcher fileWatcher = null; private InternalMessagingService messagingService = null; - private UuidCache uuidCache; private LuckPermsApiProvider apiProvider; private EventFactory eventFactory; private me.lucko.luckperms.common.logging.Logger log; @@ -243,7 +241,6 @@ public class LPSpongePlugin implements LuckPermsSpongePlugin { // load internal managers getLog().info("Loading internal permission managers..."); - this.uuidCache = new UuidCache(this); this.userManager = new SpongeUserManager(this); this.groupManager = new SpongeGroupManager(this); this.trackManager = new StandardTrackManager(this); @@ -410,7 +407,7 @@ public class LPSpongePlugin implements LuckPermsSpongePlugin { return null; } - return this.game.getServer().getPlayer(this.uuidCache.getExternalUUID(user.getUuid())).orElse(null); + return this.game.getServer().getPlayer(user.getUuid()).orElse(null); } @Override @@ -580,11 +577,6 @@ public class LPSpongePlugin implements LuckPermsSpongePlugin { return this.storage; } - @Override - public UuidCache getUuidCache() { - return this.uuidCache; - } - @Override public LuckPermsApiProvider getApiProvider() { return this.apiProvider; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java index a068178d..d768bc62 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java @@ -29,7 +29,6 @@ import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.utils.AbstractLoginListener; -import me.lucko.luckperms.common.utils.UuidCache; import me.lucko.luckperms.sponge.LPSpongePlugin; import org.spongepowered.api.event.Listener; @@ -126,7 +125,7 @@ public class SpongeConnectionListener extends AbstractLoginListener { this.plugin.getLog().info("Processing login event for " + player.getUniqueId() + " - " + player.getName()); } - final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId())); + final User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId()); /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */ if (user == null) { @@ -158,15 +157,6 @@ public class SpongeConnectionListener extends AbstractLoginListener { @Listener(order = Order.POST) public void onClientLeave(ClientConnectionEvent.Disconnect e) { - /* We don't actually remove the user instance here, as Sponge likes to keep performing checks - on players when they disconnect. The instance gets cleared up on a housekeeping task - after a period of inactivity. */ - - final UuidCache cache = this.plugin.getUuidCache(); - - // Unload the user from memory when they disconnect - cache.clearCache(e.getTargetEntity().getUniqueId()); - // Register with the housekeeper, so the User's instance will stick // around for a bit after they disconnect this.plugin.getUserManager().getHouseKeeper().registerUsage(e.getTargetEntity().getUniqueId()); diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/model/SpongeUser.java b/sponge/src/main/java/me/lucko/luckperms/sponge/model/SpongeUser.java index 8585d735..ad7f28c3 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/model/SpongeUser.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/model/SpongeUser.java @@ -87,7 +87,7 @@ public class SpongeUser extends User { @Override public String getIdentifier() { - return this.plugin.getUuidCache().getExternalUUID(this.parent.getUuid()).toString(); + return this.parent.getUuid().toString(); } @Override @@ -97,7 +97,7 @@ public class SpongeUser extends User { @Override public Optional getCommandSource() { - final UUID uuid = this.plugin.getUuidCache().getExternalUUID(this.parent.getUuid()); + final UUID uuid = this.parent.getUuid(); return Sponge.getServer().getPlayer(uuid).map(Function.identity()); } diff --git a/sponge/src/main/resources/luckperms.conf b/sponge/src/main/resources/luckperms.conf index 148c10e7..24695d4f 100644 --- a/sponge/src/main/resources/luckperms.conf +++ b/sponge/src/main/resources/luckperms.conf @@ -38,33 +38,6 @@ apply-global-groups=true # If users on this server should have global (non-world specific) groups applied apply-global-world-groups=true -# If UUIDs should be pulled from the server, or looked up by username based upon previous -# connections. -# -# This option should be set to true in most cases. When set to false, in order to get a player's -# UUID, LuckPerms will: -# -# 1. Check if a player with the given username has joined before, if they have, use the UUID they -# used on their previous login. -# 2. Save and return the players "current" uuid. -# -# For offline mode (cracked) servers, a players UUID is generated based upon their username. -# -# IMPORTANT: -# If you are using BungeeCord proxy running in online mode, it is important that "online-mode=false" -# is set in server.properties, but "bungeecord: true" is set in the spigot.yml. You also need to set -# "ip_forward: true" in BungeeCord's config.yml. -# -# If for whatever reason you are not able to do this, and do not have ip-forward enabled, then you -# may need to set "use-server-uuids" to false. -# -# If your proxy is running in offline mode, you should still be setting up ip-forwarding as -# described above. -# -# This option only really exists for networks who for whatever reason cannot setup proper ip -# forwarding. -use-server-uuids=true - # If the servers own UUID cache/lookup facility should be used when there is no record for a player # in the LuckPerms cache. use-server-uuid-cache=false