mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-10-31 08:32:18 +01:00
Change around profile methods on players
This commit is contained in:
parent
da882301bc
commit
54db798e9a
@ -19,8 +19,8 @@
|
|||||||
package com.discordsrv.bukkit.player;
|
package com.discordsrv.bukkit.player;
|
||||||
|
|
||||||
import com.discordsrv.bukkit.BukkitDiscordSRV;
|
import com.discordsrv.bukkit.BukkitDiscordSRV;
|
||||||
|
import com.discordsrv.common.DiscordSRV;
|
||||||
import com.discordsrv.common.player.IOfflinePlayer;
|
import com.discordsrv.common.player.IOfflinePlayer;
|
||||||
import com.discordsrv.common.profile.Profile;
|
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -37,17 +37,17 @@ public class BukkitOfflinePlayer implements IOfflinePlayer {
|
|||||||
this.identity = Identity.identity(offlinePlayer.getUniqueId());
|
this.identity = Identity.identity(offlinePlayer.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DiscordSRV discordSRV() {
|
||||||
|
return discordSRV;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("NullabilityProblems")
|
@SuppressWarnings("NullabilityProblems")
|
||||||
@Override
|
@Override
|
||||||
public String username() {
|
public String username() {
|
||||||
return offlinePlayer.getName();
|
return offlinePlayer.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Profile profile() {
|
|
||||||
return discordSRV.profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Identity identity() {
|
public @NotNull Identity identity() {
|
||||||
return identity;
|
return identity;
|
||||||
|
@ -22,7 +22,6 @@ import com.discordsrv.bungee.BungeeDiscordSRV;
|
|||||||
import com.discordsrv.bungee.component.util.BungeeComponentUtil;
|
import com.discordsrv.bungee.component.util.BungeeComponentUtil;
|
||||||
import com.discordsrv.common.DiscordSRV;
|
import com.discordsrv.common.DiscordSRV;
|
||||||
import com.discordsrv.common.player.IPlayer;
|
import com.discordsrv.common.player.IPlayer;
|
||||||
import com.discordsrv.common.profile.Profile;
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -63,11 +62,6 @@ public class BungeePlayer implements IPlayer {
|
|||||||
return player.getName();
|
return player.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Profile profile() {
|
|
||||||
return discordSRV.profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Identity identity() {
|
public @NotNull Identity identity() {
|
||||||
return identity;
|
return identity;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package com.discordsrv.common.player;
|
package com.discordsrv.common.player;
|
||||||
|
|
||||||
import com.discordsrv.api.placeholder.annotation.Placeholder;
|
import com.discordsrv.api.placeholder.annotation.Placeholder;
|
||||||
|
import com.discordsrv.common.DiscordSRV;
|
||||||
import com.discordsrv.common.profile.Profile;
|
import com.discordsrv.common.profile.Profile;
|
||||||
import net.kyori.adventure.identity.Identified;
|
import net.kyori.adventure.identity.Identified;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
@ -26,9 +27,17 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public interface IOfflinePlayer extends Identified {
|
public interface IOfflinePlayer extends Identified {
|
||||||
|
|
||||||
|
DiscordSRV discordSRV();
|
||||||
|
|
||||||
|
@ApiStatus.NonExtendable
|
||||||
|
default CompletableFuture<Profile> lookupProfile() {
|
||||||
|
return discordSRV().profileManager().lookupProfile(uniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
@Placeholder("player_name")
|
@Placeholder("player_name")
|
||||||
@Nullable
|
@Nullable
|
||||||
String username();
|
String username();
|
||||||
@ -39,6 +48,4 @@ public interface IOfflinePlayer extends Identified {
|
|||||||
default UUID uniqueId() {
|
default UUID uniqueId() {
|
||||||
return identity().uuid();
|
return identity().uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
Profile profile();
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.discordsrv.common.DiscordSRV;
|
|||||||
import com.discordsrv.common.command.game.sender.ICommandSender;
|
import com.discordsrv.common.command.game.sender.ICommandSender;
|
||||||
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
|
||||||
import com.discordsrv.common.function.OrDefault;
|
import com.discordsrv.common.function.OrDefault;
|
||||||
|
import com.discordsrv.common.profile.Profile;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -36,6 +37,11 @@ public interface IPlayer extends DiscordSRVPlayer, IOfflinePlayer, ICommandSende
|
|||||||
|
|
||||||
DiscordSRV discordSRV();
|
DiscordSRV discordSRV();
|
||||||
|
|
||||||
|
@ApiStatus.NonExtendable
|
||||||
|
default Profile profile() {
|
||||||
|
return discordSRV().profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
String username();
|
String username();
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
package com.discordsrv.sponge.player;
|
package com.discordsrv.sponge.player;
|
||||||
|
|
||||||
|
import com.discordsrv.common.DiscordSRV;
|
||||||
import com.discordsrv.common.player.IOfflinePlayer;
|
import com.discordsrv.common.player.IOfflinePlayer;
|
||||||
import com.discordsrv.common.profile.Profile;
|
|
||||||
import com.discordsrv.sponge.SpongeDiscordSRV;
|
import com.discordsrv.sponge.SpongeDiscordSRV;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -36,13 +36,13 @@ public class SpongeOfflinePlayer implements IOfflinePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String username() {
|
public DiscordSRV discordSRV() {
|
||||||
return user.name();
|
return discordSRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Profile profile() {
|
public @NotNull String username() {
|
||||||
return discordSRV.profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new);
|
return user.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,6 @@ package com.discordsrv.velocity.player;
|
|||||||
|
|
||||||
import com.discordsrv.common.DiscordSRV;
|
import com.discordsrv.common.DiscordSRV;
|
||||||
import com.discordsrv.common.player.IPlayer;
|
import com.discordsrv.common.player.IPlayer;
|
||||||
import com.discordsrv.common.profile.Profile;
|
|
||||||
import com.discordsrv.velocity.VelocityDiscordSRV;
|
import com.discordsrv.velocity.VelocityDiscordSRV;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
@ -58,11 +57,6 @@ public class VelocityPlayer implements IPlayer {
|
|||||||
return player.getUsername();
|
return player.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Profile profile() {
|
|
||||||
return discordSRV.profileManager().getProfile(uniqueId()).orElseThrow(IllegalStateException::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Identity identity() {
|
public @NotNull Identity identity() {
|
||||||
return player.identity();
|
return player.identity();
|
||||||
|
Loading…
Reference in New Issue
Block a user