diff --git a/src/main/java/org/mvplugins/multiverse/inventories/MultiverseInventories.java b/src/main/java/org/mvplugins/multiverse/inventories/MultiverseInventories.java index 8e5f5645..657c8033 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/MultiverseInventories.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/MultiverseInventories.java @@ -154,7 +154,7 @@ public void onDisable() { profileContainerStoreProvider.get().getStore(ContainerType.WORLD) .getContainer(world) .getPlayerData(player))); - profileDataSource.get().setLoadOnLogin(player.getName(), true); + profileDataSource.get().setLoadOnLogin(player.getUniqueId(), true); } } diff --git a/src/main/java/org/mvplugins/multiverse/inventories/listeners/InventoriesListener.java b/src/main/java/org/mvplugins/multiverse/inventories/listeners/InventoriesListener.java index 78a26eda..cb1bac53 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/listeners/InventoriesListener.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/listeners/InventoriesListener.java @@ -224,7 +224,7 @@ public void playerJoin(final PlayerJoinEvent event) { .getPlayerData(player) )); } - profileDataSource.setLoadOnLogin(player.getName(), false); + profileDataSource.setLoadOnLogin(player.getUniqueId(), false); verifyCorrectWorld(player, player.getWorld().getName(), globalProfile); } @@ -237,7 +237,7 @@ public void playerJoin(final PlayerJoinEvent event) { public void playerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); final String world = event.getPlayer().getWorld().getName(); - profileDataSource.updateLastWorld(player.getName(), world); + profileDataSource.updateLastWorld(player.getUniqueId(), world); if (config.usingLoggingSaveLoad()) { ShareHandlingUpdater.updateProfile(inventories, player, new PersistingProfile( Sharables.allOf(), @@ -245,20 +245,20 @@ public void playerQuit(final PlayerQuitEvent event) { .getContainer(world) .getPlayerData(player) )); - profileDataSource.setLoadOnLogin(player.getName(), true); + profileDataSource.setLoadOnLogin(player.getUniqueId(), true); } SingleShareWriter.of(this.inventories, player, Sharables.LAST_LOCATION).write(player.getLocation()); } private void verifyCorrectWorld(Player player, String world, GlobalProfile globalProfile) { if (globalProfile.getLastWorld() == null) { - profileDataSource.updateLastWorld(player.getName(), world); + profileDataSource.updateLastWorld(player.getUniqueId(), world); } else { if (!world.equals(globalProfile.getLastWorld())) { Logging.fine("Player did not spawn in the world they were last reported to be in!"); new WorldChangeShareHandler(this.inventories, player, globalProfile.getLastWorld(), world).handleSharing(); - profileDataSource.updateLastWorld(player.getName(), world); + profileDataSource.updateLastWorld(player.getUniqueId(), world); } } } @@ -300,7 +300,7 @@ public void playerChangedWorld(PlayerChangedWorldEvent event) { } new WorldChangeShareHandler(this.inventories, player, fromWorld.getName(), toWorld.getName()).handleSharing(); - profileDataSource.updateLastWorld(player.getName(), toWorld.getName()); + profileDataSource.updateLastWorld(player.getUniqueId(), toWorld.getName()); } /** diff --git a/src/main/java/org/mvplugins/multiverse/inventories/profile/FlatFileProfileDataSource.java b/src/main/java/org/mvplugins/multiverse/inventories/profile/FlatFileProfileDataSource.java index 666ee66b..e9b1b05f 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/profile/FlatFileProfileDataSource.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/profile/FlatFileProfileDataSource.java @@ -6,6 +6,7 @@ import com.google.common.cache.CacheBuilder; import net.minidev.json.parser.JSONParser; import net.minidev.json.parser.ParseException; +import org.bukkit.OfflinePlayer; import org.bukkit.configuration.InvalidConfigurationException; import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.external.jakarta.inject.Inject; @@ -423,9 +424,13 @@ private Map convertSection(ConfigurationSection section) { } @Override - @Deprecated - public GlobalProfile getGlobalProfile(String playerName) { - return getGlobalProfile(playerName, Bukkit.getOfflinePlayer(playerName).getUniqueId()); + public GlobalProfile getGlobalProfile(UUID playerUUID) { + return getGlobalProfile(Bukkit.getOfflinePlayer(playerUUID)); + } + + @Override + public GlobalProfile getGlobalProfile(OfflinePlayer player) { + return getGlobalProfile(player.getName(), player.getUniqueId()); } @Override @@ -442,7 +447,7 @@ public GlobalProfile getGlobalProfile(String playerName, UUID playerUUID) { } catch (IOException e) { // This won't ever happen e.printStackTrace(); - return GlobalProfile.createGlobalProfile(playerName); + return GlobalProfile.createGlobalProfile(playerName, playerUUID); } if (playerFile.exists()) { GlobalProfile profile = loadGlobalProfile(playerFile, playerName, playerUUID); @@ -529,19 +534,15 @@ private Map serializeGlobalProfile(GlobalProfile profile) { } @Override - @Deprecated - // TODO replace for UUID - public void updateLastWorld(String playerName, String worldName) { - GlobalProfile globalProfile = getGlobalProfile(playerName); + public void updateLastWorld(UUID playerUUID, String worldName) { + GlobalProfile globalProfile = getGlobalProfile(playerUUID); globalProfile.setLastWorld(worldName); updateGlobalProfile(globalProfile); } @Override - @Deprecated - // TODO replace for UUID - public void setLoadOnLogin(final String playerName, final boolean loadOnLogin) { - final GlobalProfile globalProfile = getGlobalProfile(playerName); + public void setLoadOnLogin(final UUID playerUUID, final boolean loadOnLogin) { + final GlobalProfile globalProfile = getGlobalProfile(playerUUID); globalProfile.setLoadOnLogin(loadOnLogin); updateGlobalProfile(globalProfile); } diff --git a/src/main/java/org/mvplugins/multiverse/inventories/profile/GlobalProfile.java b/src/main/java/org/mvplugins/multiverse/inventories/profile/GlobalProfile.java index c95f7ddf..4dac573b 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/profile/GlobalProfile.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/profile/GlobalProfile.java @@ -1,6 +1,6 @@ package org.mvplugins.multiverse.inventories.profile; -import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; import java.util.UUID; @@ -12,13 +12,11 @@ public final class GlobalProfile { /** * Creates a global profile object for the given player with default values. * - * @param playerName the player to create the profile object for. + * @param player the player to create the profile object for. * @return a new GlobalProfile for the given player. - * @deprecated Needs to use UUID. */ - @Deprecated - public static GlobalProfile createGlobalProfile(String playerName) { - return new GlobalProfile(playerName, Bukkit.getOfflinePlayer(playerName).getUniqueId()); + public static GlobalProfile createGlobalProfile(OfflinePlayer player) { + return new GlobalProfile(player.getName(), player.getUniqueId()); } /** diff --git a/src/main/java/org/mvplugins/multiverse/inventories/profile/PlayerProfile.java b/src/main/java/org/mvplugins/multiverse/inventories/profile/PlayerProfile.java index 8ddc54d1..88e82d5c 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/profile/PlayerProfile.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/profile/PlayerProfile.java @@ -3,7 +3,6 @@ import org.mvplugins.multiverse.inventories.share.Sharable; import org.mvplugins.multiverse.inventories.share.SharableEntry; import org.mvplugins.multiverse.inventories.profile.container.ContainerType; -import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import java.util.HashMap; @@ -20,15 +19,6 @@ public static PlayerProfile createPlayerProfile(ContainerType containerType, Str return new PlayerProfile(containerType, containerName, profileType, player); } - /** - * @deprecated Needs to use UUID for players - */ - @Deprecated - public static PlayerProfile createPlayerProfile(ContainerType containerType, String containerName, - ProfileType profileType, String playerName) { - return new PlayerProfile(containerType, containerName, profileType, Bukkit.getOfflinePlayer(playerName)); - } - private Map data = new HashMap(); private final OfflinePlayer player; diff --git a/src/main/java/org/mvplugins/multiverse/inventories/profile/ProfileDataSource.java b/src/main/java/org/mvplugins/multiverse/inventories/profile/ProfileDataSource.java index c9922395..ad9e3092 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/profile/ProfileDataSource.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/profile/ProfileDataSource.java @@ -1,5 +1,6 @@ package org.mvplugins.multiverse.inventories.profile; +import org.bukkit.OfflinePlayer; import org.jvnet.hk2.annotations.Contract; import org.mvplugins.multiverse.inventories.profile.container.ContainerType; @@ -47,19 +48,25 @@ public sealed interface ProfileDataSource permits FlatFileProfileDataSource { /** * Retrieves the global profile for a player which contains meta-data for the player. * - * @param playerName The name of player to retrieve for. + * @param playerUUID The UUID of the player. * @return The global profile for the specified player. - * @deprecated UUID must be supported now. */ - @Deprecated - GlobalProfile getGlobalProfile(String playerName); + GlobalProfile getGlobalProfile(UUID playerUUID); /** * Retrieves the global profile for a player which contains meta-data for the player. * - * @param playerName The name of the player to retrieve for. This is required for updating name last known as. - * @param playerUUID The UUID of the player. - * @return the global profile for the player with the given UUID. + * @param player The player. + * @return The global profile for the specified player. + */ + GlobalProfile getGlobalProfile(OfflinePlayer player); + + /** + * Retrieves the global profile for a player which contains meta-data for the player. + * + * @param playerName The name of the player. + * @param playerUUID The UUID of the player. + * @return The global profile for the specified player. */ GlobalProfile getGlobalProfile(String playerName, UUID playerUUID); @@ -74,18 +81,18 @@ public sealed interface ProfileDataSource permits FlatFileProfileDataSource { /** * A convenience method to update the GlobalProfile of a player with a specified world. * - * @param playerName The player whose global profile this will update. + * @param playerUUID The player whose global profile this will update. * @param worldName The world to update the global profile with. */ - void updateLastWorld(String playerName, String worldName); + void updateLastWorld(UUID playerUUID, String worldName); /** * A convenience method for setting whether player data should be loaded on login for the specified player. * - * @param playerName The player whose data should be loaded. + * @param playerUUID The player whose data should be loaded. * @param loadOnLogin Whether or not to load on login. */ - void setLoadOnLogin(String playerName, boolean loadOnLogin); + void setLoadOnLogin(UUID playerUUID, boolean loadOnLogin); /** * Copies all the data belonging to oldName to newName and removes the old data. diff --git a/src/main/java/org/mvplugins/multiverse/inventories/profile/group/AbstractWorldGroupManager.java b/src/main/java/org/mvplugins/multiverse/inventories/profile/group/AbstractWorldGroupManager.java index b8652ec6..1cf2d7ce 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/profile/group/AbstractWorldGroupManager.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/profile/group/AbstractWorldGroupManager.java @@ -99,15 +99,6 @@ protected Map getGroupNames() { return groupNamesMap; } - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public void addGroup(final WorldGroup worldGroup, final boolean persist) { - updateGroup(worldGroup); - } - @Override public void updateGroup(final WorldGroup worldGroup) { getGroupNames().put(worldGroup.getName().toLowerCase(), worldGroup); @@ -135,14 +126,6 @@ public WorldGroup newEmptyGroup(String name) { return new WorldGroup(this, profileContainerStoreProvider, name); } - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public void setGroups(List worldGroups) { - } - /** * {@inheritDoc} */ diff --git a/src/main/java/org/mvplugins/multiverse/inventories/profile/group/WorldGroupManager.java b/src/main/java/org/mvplugins/multiverse/inventories/profile/group/WorldGroupManager.java index 3cc7ede4..8527fe3b 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/profile/group/WorldGroupManager.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/profile/group/WorldGroupManager.java @@ -53,25 +53,6 @@ public sealed interface WorldGroupManager permits AbstractWorldGroupManager { */ boolean hasGroup(String worldName); - /** - * Sets up the World Groups in memory. - * - * @param worldGroups List of World Groups to store in memory. - * @deprecated This feature is now completely unused. - */ - @Deprecated - void setGroups(List worldGroups); - - /** - * Adds a World Group to the collection in memory, also writing it to the groups configuration. - * - * @param worldGroup World group to add. Casing is ignored. - * @param persist This parameter is unused due to deprecation of the method. - * @deprecated - */ - @Deprecated - void addGroup(WorldGroup worldGroup, boolean persist); - /** *

Adds or updates a world group in Multiverse-Inventories.

*