|
10 | 10 | import org.mvplugins.multiverse.external.jakarta.inject.Provider; |
11 | 11 | import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull; |
12 | 12 | import org.mvplugins.multiverse.external.vavr.control.Option; |
| 13 | +import org.mvplugins.multiverse.external.vavr.control.Try; |
13 | 14 | import org.mvplugins.multiverse.inventories.MultiverseInventories; |
14 | 15 | import org.mvplugins.multiverse.inventories.profile.key.GlobalProfileKey; |
15 | 16 |
|
|
18 | 19 | import java.io.FileWriter; |
19 | 20 | import java.util.List; |
20 | 21 | import java.util.Map; |
21 | | -import java.util.Objects; |
22 | 22 | import java.util.UUID; |
23 | 23 | import java.util.concurrent.CompletableFuture; |
24 | 24 | import java.util.concurrent.ConcurrentHashMap; |
@@ -83,13 +83,17 @@ private void loadFromPlayerNamesFile() { |
83 | 83 | buildPlayerNamesMap(); |
84 | 84 | return; |
85 | 85 | } |
86 | | - playerNamesJson.forEach((String uuid, Object name) -> { |
87 | | - UUID playerUUID = UUID.fromString(uuid); |
88 | | - String playerName = String.valueOf(name); |
89 | | - GlobalProfileKey globalProfileKey = GlobalProfileKey.of(playerUUID, playerName); |
90 | | - playerNamesMap.put(playerName, globalProfileKey); |
91 | | - playerUUIDMap.put(playerUUID, globalProfileKey); |
92 | | - }); |
| 86 | + playerNamesJson.forEach((String uuidStr, Object name) -> Try.of(() -> UUID.fromString(uuidStr)) |
| 87 | + .onSuccess(uuid -> { |
| 88 | + String playerName = String.valueOf(name); |
| 89 | + GlobalProfileKey globalProfileKey = GlobalProfileKey.of(uuid, playerName); |
| 90 | + playerNamesMap.put(playerName, globalProfileKey); |
| 91 | + playerUUIDMap.put(uuid, globalProfileKey); |
| 92 | + }) |
| 93 | + .onFailure(throwable -> { |
| 94 | + Logging.warning("Not a valid UUID: %s", uuidStr); |
| 95 | + Logging.warning(throwable.getMessage()); |
| 96 | + })); |
93 | 97 | } catch (Exception e) { |
94 | 98 | e.printStackTrace(); |
95 | 99 | } |
|
0 commit comments