Skip to content

Commit 2d438a8

Browse files
committed
avoid redundant caching of username lookups
1 parent 89c38ae commit 2d438a8

1 file changed

Lines changed: 1 addition & 13 deletions

File tree

src/main/java/pro/cloudnode/smp/smpcore/CachedProfile.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,11 @@ public record CachedProfile(@NotNull UUID uuid, @NotNull String name, @NotNull D
189189
* @param name Username of the player to look up.
190190
*/
191191
public static @NotNull OfflinePlayer get(final @NotNull String name) {
192-
final OfflinePlayer player = Optional.<@NotNull OfflinePlayer>ofNullable(getOffline(name))
192+
return Optional.<@NotNull OfflinePlayer>ofNullable(getOffline(name))
193193
.orElseGet(() -> {
194194
logger.fine("Miss for name " + name);
195195
return Bukkit.getOfflinePlayer(name);
196196
});
197-
198-
CachedProfile.from(player);
199-
200-
return player;
201197
}
202198

203199
/**
@@ -267,14 +263,6 @@ public static void cleanUp() {
267263
return profile;
268264
}
269265

270-
private static @Nullable CachedProfile from(final @NotNull OfflinePlayer player) {
271-
if (player.getName() == null)
272-
return null;
273-
274-
return new CachedProfile(player.getUniqueId(), player.getName(), new Date())
275-
.save();
276-
}
277-
278266
private boolean stale() {
279267
return fetched.before(expirationThreshold());
280268
}

0 commit comments

Comments
 (0)