diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitOfflinePlayer.java b/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitOfflinePlayer.java index c0a96c7e..17003c4f 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitOfflinePlayer.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitOfflinePlayer.java @@ -19,8 +19,8 @@ package com.discordsrv.bukkit.player; import com.discordsrv.bukkit.BukkitDiscordSRV; +import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.player.IOfflinePlayer; -import com.discordsrv.common.profile.Profile; import net.kyori.adventure.identity.Identity; import org.bukkit.OfflinePlayer; import org.jetbrains.annotations.NotNull; @@ -37,17 +37,17 @@ public class BukkitOfflinePlayer implements IOfflinePlayer { this.identity = Identity.identity(offlinePlayer.getUniqueId()); } + @Override + public DiscordSRV discordSRV() { + return discordSRV; + } + @SuppressWarnings("NullabilityProblems") @Override public String username() { return offlinePlayer.getName(); } - @Override - public Profile profile() { - return discordSRV.profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new); - } - @Override public @NotNull Identity identity() { return identity; diff --git a/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayer.java b/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayer.java index 2c0657d4..7fb64c4a 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayer.java +++ b/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayer.java @@ -22,7 +22,6 @@ import com.discordsrv.bungee.BungeeDiscordSRV; import com.discordsrv.bungee.component.util.BungeeComponentUtil; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.player.IPlayer; -import com.discordsrv.common.profile.Profile; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; @@ -63,11 +62,6 @@ public class BungeePlayer implements IPlayer { return player.getName(); } - @Override - public Profile profile() { - return discordSRV.profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new); - } - @Override public @NotNull Identity identity() { return identity; diff --git a/common/src/main/java/com/discordsrv/common/player/IOfflinePlayer.java b/common/src/main/java/com/discordsrv/common/player/IOfflinePlayer.java index a6410e46..0831aeb6 100644 --- a/common/src/main/java/com/discordsrv/common/player/IOfflinePlayer.java +++ b/common/src/main/java/com/discordsrv/common/player/IOfflinePlayer.java @@ -19,6 +19,7 @@ package com.discordsrv.common.player; import com.discordsrv.api.placeholder.annotation.Placeholder; +import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.profile.Profile; import net.kyori.adventure.identity.Identified; import org.jetbrains.annotations.ApiStatus; @@ -26,9 +27,17 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.UUID; +import java.util.concurrent.CompletableFuture; public interface IOfflinePlayer extends Identified { + DiscordSRV discordSRV(); + + @ApiStatus.NonExtendable + default CompletableFuture lookupProfile() { + return discordSRV().profileManager().lookupProfile(uniqueId()); + } + @Placeholder("player_name") @Nullable String username(); @@ -39,6 +48,4 @@ public interface IOfflinePlayer extends Identified { default UUID uniqueId() { return identity().uuid(); } - - Profile profile(); } diff --git a/common/src/main/java/com/discordsrv/common/player/IPlayer.java b/common/src/main/java/com/discordsrv/common/player/IPlayer.java index ed92da9b..83d246f0 100644 --- a/common/src/main/java/com/discordsrv/common/player/IPlayer.java +++ b/common/src/main/java/com/discordsrv/common/player/IPlayer.java @@ -25,6 +25,7 @@ import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.command.game.sender.ICommandSender; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; import com.discordsrv.common.function.OrDefault; +import com.discordsrv.common.profile.Profile; import net.kyori.adventure.text.Component; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -36,6 +37,11 @@ public interface IPlayer extends DiscordSRVPlayer, IOfflinePlayer, ICommandSende DiscordSRV discordSRV(); + @ApiStatus.NonExtendable + default Profile profile() { + return discordSRV().profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new); + } + @NotNull String username(); diff --git a/sponge/src/main/java/com/discordsrv/sponge/player/SpongeOfflinePlayer.java b/sponge/src/main/java/com/discordsrv/sponge/player/SpongeOfflinePlayer.java index 1e201aa5..5cf718f2 100644 --- a/sponge/src/main/java/com/discordsrv/sponge/player/SpongeOfflinePlayer.java +++ b/sponge/src/main/java/com/discordsrv/sponge/player/SpongeOfflinePlayer.java @@ -18,8 +18,8 @@ package com.discordsrv.sponge.player; +import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.player.IOfflinePlayer; -import com.discordsrv.common.profile.Profile; import com.discordsrv.sponge.SpongeDiscordSRV; import net.kyori.adventure.identity.Identity; import org.jetbrains.annotations.NotNull; @@ -36,13 +36,13 @@ public class SpongeOfflinePlayer implements IOfflinePlayer { } @Override - public @NotNull String username() { - return user.name(); + public DiscordSRV discordSRV() { + return discordSRV; } @Override - public Profile profile() { - return discordSRV.profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new); + public @NotNull String username() { + return user.name(); } @Override diff --git a/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayer.java b/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayer.java index b40f21f8..8ae1b74c 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayer.java +++ b/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayer.java @@ -20,7 +20,6 @@ package com.discordsrv.velocity.player; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.player.IPlayer; -import com.discordsrv.common.profile.Profile; import com.discordsrv.velocity.VelocityDiscordSRV; import com.velocitypowered.api.proxy.Player; import net.kyori.adventure.audience.Audience; @@ -58,11 +57,6 @@ public class VelocityPlayer implements IPlayer { return player.getUsername(); } - @Override - public Profile profile() { - return discordSRV.profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new); - } - @Override public @NotNull Identity identity() { return player.identity();