Skip to content

Commit f274e29

Browse files
authored
Merge pull request #563 from Multiverse/ben/mv5/remove-deprecated
Ben/mv5/remove deprecated
2 parents 189d975 + 422a678 commit f274e29

File tree

8 files changed

+42
-82
lines changed

8 files changed

+42
-82
lines changed

src/main/java/org/mvplugins/multiverse/inventories/MultiverseInventories.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void onDisable() {
155155
profileContainerStoreProvider.get().getStore(ContainerType.WORLD)
156156
.getContainer(world)
157157
.getPlayerData(player)));
158-
profileDataSource.get().setLoadOnLogin(player.getName(), true);
158+
profileDataSource.get().setLoadOnLogin(player.getUniqueId(), true);
159159
}
160160
}
161161

src/main/java/org/mvplugins/multiverse/inventories/listeners/InventoriesListener.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void playerJoin(final PlayerJoinEvent event) {
210210
.getPlayerData(player)
211211
));
212212
}
213-
profileDataSource.setLoadOnLogin(player.getName(), false);
213+
profileDataSource.setLoadOnLogin(player.getUniqueId(), false);
214214
verifyCorrectWorld(player, player.getWorld().getName(), globalProfile);
215215
}
216216

@@ -243,28 +243,28 @@ private void verifyCorrectPlayerName(UUID uuid, String name) {
243243
public void playerQuit(final PlayerQuitEvent event) {
244244
final Player player = event.getPlayer();
245245
final String world = event.getPlayer().getWorld().getName();
246-
profileDataSource.updateLastWorld(player.getName(), world);
246+
profileDataSource.updateLastWorld(player.getUniqueId(), world);
247247
if (config.usingLoggingSaveLoad()) {
248248
ShareHandlingUpdater.updateProfile(inventories, player, new PersistingProfile(
249249
Sharables.allOf(),
250250
profileContainerStoreProvider.getStore(ContainerType.WORLD)
251251
.getContainer(world)
252252
.getPlayerData(player)
253253
));
254-
profileDataSource.setLoadOnLogin(player.getName(), true);
254+
profileDataSource.setLoadOnLogin(player.getUniqueId(), true);
255255
}
256256
SingleShareWriter.of(this.inventories, player, Sharables.LAST_LOCATION).write(player.getLocation());
257257
}
258258

259259
private void verifyCorrectWorld(Player player, String world, GlobalProfile globalProfile) {
260260
if (globalProfile.getLastWorld() == null) {
261-
profileDataSource.updateLastWorld(player.getName(), world);
261+
profileDataSource.updateLastWorld(player.getUniqueId(), world);
262262
} else {
263263
if (!world.equals(globalProfile.getLastWorld())) {
264264
Logging.fine("Player did not spawn in the world they were last reported to be in!");
265265
new WorldChangeShareHandler(this.inventories, player,
266266
globalProfile.getLastWorld(), world).handleSharing();
267-
profileDataSource.updateLastWorld(player.getName(), world);
267+
profileDataSource.updateLastWorld(player.getUniqueId(), world);
268268
}
269269
}
270270
}
@@ -306,7 +306,7 @@ public void playerChangedWorld(PlayerChangedWorldEvent event) {
306306
}
307307

308308
new WorldChangeShareHandler(this.inventories, player, fromWorld.getName(), toWorld.getName()).handleSharing();
309-
profileDataSource.updateLastWorld(player.getName(), toWorld.getName());
309+
profileDataSource.updateLastWorld(player.getUniqueId(), toWorld.getName());
310310
}
311311

312312
/**

src/main/java/org/mvplugins/multiverse/inventories/profile/FlatFileProfileDataSource.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.google.common.collect.Sets;
88
import net.minidev.json.parser.JSONParser;
99
import net.minidev.json.parser.ParseException;
10+
import org.bukkit.OfflinePlayer;
1011
import org.bukkit.configuration.InvalidConfigurationException;
1112
import org.jvnet.hk2.annotations.Service;
1213
import org.mvplugins.multiverse.external.jakarta.inject.Inject;
@@ -439,9 +440,13 @@ private Map<String, Object> convertSection(ConfigurationSection section) {
439440
}
440441

441442
@Override
442-
@Deprecated
443-
public GlobalProfile getGlobalProfile(String playerName) {
444-
return getGlobalProfile(playerName, Bukkit.getOfflinePlayer(playerName).getUniqueId());
443+
public GlobalProfile getGlobalProfile(UUID playerUUID) {
444+
return getGlobalProfile(Bukkit.getOfflinePlayer(playerUUID));
445+
}
446+
447+
@Override
448+
public GlobalProfile getGlobalProfile(OfflinePlayer player) {
449+
return getGlobalProfile(player.getName(), player.getUniqueId());
445450
}
446451

447452
@Override
@@ -458,7 +463,7 @@ public GlobalProfile getGlobalProfile(String playerName, UUID playerUUID) {
458463
} catch (IOException e) {
459464
// This won't ever happen
460465
e.printStackTrace();
461-
return GlobalProfile.createGlobalProfile(playerName);
466+
return GlobalProfile.createGlobalProfile(playerName, playerUUID);
462467
}
463468
if (playerFile.exists()) {
464469
GlobalProfile profile = loadGlobalProfile(playerFile, playerName, playerUUID);
@@ -545,19 +550,15 @@ private Map<String, Object> serializeGlobalProfile(GlobalProfile profile) {
545550
}
546551

547552
@Override
548-
@Deprecated
549-
// TODO replace for UUID
550-
public void updateLastWorld(String playerName, String worldName) {
551-
GlobalProfile globalProfile = getGlobalProfile(playerName);
553+
public void updateLastWorld(UUID playerUUID, String worldName) {
554+
GlobalProfile globalProfile = getGlobalProfile(playerUUID);
552555
globalProfile.setLastWorld(worldName);
553556
updateGlobalProfile(globalProfile);
554557
}
555558

556559
@Override
557-
@Deprecated
558-
// TODO replace for UUID
559-
public void setLoadOnLogin(final String playerName, final boolean loadOnLogin) {
560-
final GlobalProfile globalProfile = getGlobalProfile(playerName);
560+
public void setLoadOnLogin(final UUID playerUUID, final boolean loadOnLogin) {
561+
final GlobalProfile globalProfile = getGlobalProfile(playerUUID);
561562
globalProfile.setLoadOnLogin(loadOnLogin);
562563
updateGlobalProfile(globalProfile);
563564
}

src/main/java/org/mvplugins/multiverse/inventories/profile/GlobalProfile.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.mvplugins.multiverse.inventories.profile;
22

3-
import org.bukkit.Bukkit;
3+
import org.bukkit.OfflinePlayer;
44

55
import java.util.UUID;
66

@@ -12,13 +12,11 @@ public final class GlobalProfile {
1212
/**
1313
* Creates a global profile object for the given player with default values.
1414
*
15-
* @param playerName the player to create the profile object for.
15+
* @param player the player to create the profile object for.
1616
* @return a new GlobalProfile for the given player.
17-
* @deprecated Needs to use UUID.
1817
*/
19-
@Deprecated
20-
public static GlobalProfile createGlobalProfile(String playerName) {
21-
return new GlobalProfile(playerName, Bukkit.getOfflinePlayer(playerName).getUniqueId());
18+
public static GlobalProfile createGlobalProfile(OfflinePlayer player) {
19+
return new GlobalProfile(player.getName(), player.getUniqueId());
2220
}
2321

2422
/**

src/main/java/org/mvplugins/multiverse/inventories/profile/PlayerProfile.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.mvplugins.multiverse.inventories.share.Sharable;
44
import org.mvplugins.multiverse.inventories.share.SharableEntry;
55
import org.mvplugins.multiverse.inventories.profile.container.ContainerType;
6-
import org.bukkit.Bukkit;
76
import org.bukkit.OfflinePlayer;
87

98
import java.util.HashMap;
@@ -20,15 +19,6 @@ public static PlayerProfile createPlayerProfile(ContainerType containerType, Str
2019
return new PlayerProfile(containerType, containerName, profileType, player);
2120
}
2221

23-
/**
24-
* @deprecated Needs to use UUID for players
25-
*/
26-
@Deprecated
27-
public static PlayerProfile createPlayerProfile(ContainerType containerType, String containerName,
28-
ProfileType profileType, String playerName) {
29-
return new PlayerProfile(containerType, containerName, profileType, Bukkit.getOfflinePlayer(playerName));
30-
}
31-
3222
private Map<Sharable, SharableEntry> data = new HashMap<Sharable, SharableEntry>();
3323

3424
private final OfflinePlayer player;

src/main/java/org/mvplugins/multiverse/inventories/profile/ProfileDataSource.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.mvplugins.multiverse.inventories.profile;
22

3+
import org.bukkit.OfflinePlayer;
34
import org.jvnet.hk2.annotations.Contract;
45
import org.mvplugins.multiverse.inventories.profile.container.ContainerType;
56

@@ -47,19 +48,25 @@ public sealed interface ProfileDataSource permits FlatFileProfileDataSource {
4748
/**
4849
* Retrieves the global profile for a player which contains meta-data for the player.
4950
*
50-
* @param playerName The name of player to retrieve for.
51+
* @param playerUUID The UUID of the player.
5152
* @return The global profile for the specified player.
52-
* @deprecated UUID must be supported now.
5353
*/
54-
@Deprecated
55-
GlobalProfile getGlobalProfile(String playerName);
54+
GlobalProfile getGlobalProfile(UUID playerUUID);
5655

5756
/**
5857
* Retrieves the global profile for a player which contains meta-data for the player.
5958
*
60-
* @param playerName The name of the player to retrieve for. This is required for updating name last known as.
61-
* @param playerUUID The UUID of the player.
62-
* @return the global profile for the player with the given UUID.
59+
* @param player The player.
60+
* @return The global profile for the specified player.
61+
*/
62+
GlobalProfile getGlobalProfile(OfflinePlayer player);
63+
64+
/**
65+
* Retrieves the global profile for a player which contains meta-data for the player.
66+
*
67+
* @param playerName The name of the player.
68+
* @param playerUUID The UUID of the player.
69+
* @return The global profile for the specified player.
6370
*/
6471
GlobalProfile getGlobalProfile(String playerName, UUID playerUUID);
6572

@@ -74,18 +81,18 @@ public sealed interface ProfileDataSource permits FlatFileProfileDataSource {
7481
/**
7582
* A convenience method to update the GlobalProfile of a player with a specified world.
7683
*
77-
* @param playerName The player whose global profile this will update.
84+
* @param playerUUID The player whose global profile this will update.
7885
* @param worldName The world to update the global profile with.
7986
*/
80-
void updateLastWorld(String playerName, String worldName);
87+
void updateLastWorld(UUID playerUUID, String worldName);
8188

8289
/**
8390
* A convenience method for setting whether player data should be loaded on login for the specified player.
8491
*
85-
* @param playerName The player whose data should be loaded.
92+
* @param playerUUID The player whose data should be loaded.
8693
* @param loadOnLogin Whether or not to load on login.
8794
*/
88-
void setLoadOnLogin(String playerName, boolean loadOnLogin);
95+
void setLoadOnLogin(UUID playerUUID, boolean loadOnLogin);
8996

9097
/**
9198
* Copies all the data belonging to oldName to newName and removes the old data.

src/main/java/org/mvplugins/multiverse/inventories/profile/group/AbstractWorldGroupManager.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,6 @@ protected Map<String, WorldGroup> getGroupNames() {
9999
return groupNamesMap;
100100
}
101101

102-
/**
103-
* {@inheritDoc}
104-
*/
105-
@Override
106-
@Deprecated
107-
public void addGroup(final WorldGroup worldGroup, final boolean persist) {
108-
updateGroup(worldGroup);
109-
}
110-
111102
@Override
112103
public void updateGroup(final WorldGroup worldGroup) {
113104
getGroupNames().put(worldGroup.getName().toLowerCase(), worldGroup);
@@ -135,14 +126,6 @@ public WorldGroup newEmptyGroup(String name) {
135126
return new WorldGroup(this, profileContainerStoreProvider, name);
136127
}
137128

138-
/**
139-
* {@inheritDoc}
140-
*/
141-
@Override
142-
@Deprecated
143-
public void setGroups(List<WorldGroup> worldGroups) {
144-
}
145-
146129
/**
147130
* {@inheritDoc}
148131
*/

src/main/java/org/mvplugins/multiverse/inventories/profile/group/WorldGroupManager.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,6 @@ public sealed interface WorldGroupManager permits AbstractWorldGroupManager {
5353
*/
5454
boolean hasGroup(String worldName);
5555

56-
/**
57-
* Sets up the World Groups in memory.
58-
*
59-
* @param worldGroups List of World Groups to store in memory.
60-
* @deprecated This feature is now completely unused.
61-
*/
62-
@Deprecated
63-
void setGroups(List<WorldGroup> worldGroups);
64-
65-
/**
66-
* Adds a World Group to the collection in memory, also writing it to the groups configuration.
67-
*
68-
* @param worldGroup World group to add. Casing is ignored.
69-
* @param persist This parameter is unused due to deprecation of the method.
70-
* @deprecated
71-
*/
72-
@Deprecated
73-
void addGroup(WorldGroup worldGroup, boolean persist);
74-
7556
/**
7657
* <p>Adds or updates a world group in Multiverse-Inventories.</p>
7758
*

0 commit comments

Comments
 (0)