mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Replace all usages of UserManager#carbonPlayer with UserManager#user
This commit is contained in:
20 files changed
+53
-105
No files matched your search
+13
-15
@@ -34,6 +34,7 @@ import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiFunction;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
@@ -93,7 +94,7 @@ public final class CarbonPlayerArgument extends CommandArgument<Commander, Carbo
|
||||
/**
|
||||
* Create a new required command component with a default value.
|
||||
*
|
||||
* @param name component name
|
||||
* @param name component name
|
||||
* @param defaultCarbonPlayer default player
|
||||
* @return created component
|
||||
*/
|
||||
@@ -151,7 +152,6 @@ public final class CarbonPlayerArgument extends CommandArgument<Commander, Carbo
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public @NonNull ArgumentParseResult<CarbonPlayer> parse(
|
||||
final @NonNull CommandContext<Commander> commandContext,
|
||||
final @NonNull Queue<@NonNull String> inputQueue
|
||||
@@ -165,21 +165,19 @@ public final class CarbonPlayerArgument extends CommandArgument<Commander, Carbo
|
||||
));
|
||||
}
|
||||
|
||||
return CarbonChatProvider.carbonChat().server().resolveUUID(input).thenApply(uuid -> {
|
||||
final @Nullable CarbonPlayer join = CarbonChatProvider.carbonChat().server().resolveUUID(input).thenCompose(uuid -> {
|
||||
if (uuid == null) {
|
||||
return ArgumentParseResult.<CarbonPlayer>failure(new CarbonPlayerParseException(input, commandContext, this.carbonMessages));
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
final var playerResult = CarbonChatProvider.carbonChat().server().userManager().carbonPlayer(uuid).join();
|
||||
|
||||
if (playerResult.player() == null) {
|
||||
return ArgumentParseResult.<CarbonPlayer>failure(new CarbonPlayerParseException(input, commandContext, this.carbonMessages));
|
||||
}
|
||||
|
||||
inputQueue.remove();
|
||||
|
||||
return ArgumentParseResult.<CarbonPlayer>success(playerResult.player());
|
||||
return CarbonChatProvider.carbonChat().server().userManager().user(uuid);
|
||||
}).join();
|
||||
|
||||
if (join == null) {
|
||||
return ArgumentParseResult.failure(new CarbonPlayerParseException(input, commandContext, this.carbonMessages));
|
||||
}
|
||||
|
||||
inputQueue.remove();
|
||||
return ArgumentParseResult.success(join);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,7 +201,7 @@ public final class CarbonPlayerArgument extends CommandArgument<Commander, Carbo
|
||||
/**
|
||||
* Construct a new CarbonPlayer parse exception.
|
||||
*
|
||||
* @param input string input
|
||||
* @param input string input
|
||||
* @param context command context
|
||||
*/
|
||||
public CarbonPlayerParseException(
|
||||
|
||||
+2
-4
@@ -27,7 +27,6 @@ import com.google.inject.Inject;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.draycia.carbon.common.command.CarbonCommand;
|
||||
import net.draycia.carbon.common.command.CommandSettings;
|
||||
@@ -100,9 +99,8 @@ public class ContinueCommand extends CarbonCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final ComponentPlayerResult<? extends CarbonPlayer> result = this.carbonChat.server()
|
||||
.userManager().carbonPlayer(whisperTarget).join();
|
||||
final @MonotonicNonNull CarbonPlayer recipient = result.player();
|
||||
final @MonotonicNonNull CarbonPlayer recipient = this.carbonChat.server()
|
||||
.userManager().user(whisperTarget).join();
|
||||
|
||||
if (sender.equals(recipient)) {
|
||||
this.carbonMessages.whisperSelfError(sender, CarbonPlayer.renderName(sender));
|
||||
|
||||
@@ -24,7 +24,6 @@ import cloud.commandframework.arguments.standard.UUIDArgument;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExtrasMetaKeys;
|
||||
import cloud.commandframework.minecraft.extras.RichDescription;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Objects;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.common.command.CarbonCommand;
|
||||
@@ -89,8 +88,7 @@ public class IgnoreCommand extends CarbonCommand {
|
||||
if (handler.contains("player")) {
|
||||
target = handler.get("player");
|
||||
} else if (handler.flags().contains("uuid")) {
|
||||
final var result = this.carbonChat.server().userManager().carbonPlayer(handler.get("uuid")).join();
|
||||
target = Objects.requireNonNull(result.player(), "No player found for UUID.");
|
||||
target = this.carbonChat.server().userManager().user(handler.get("uuid")).join();
|
||||
} else {
|
||||
this.carbonMessages.ignoreTargetInvalid(sender);
|
||||
return;
|
||||
|
||||
@@ -24,7 +24,6 @@ import cloud.commandframework.arguments.standard.UUIDArgument;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExtrasMetaKeys;
|
||||
import cloud.commandframework.minecraft.extras.RichDescription;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Objects;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.common.command.CarbonCommand;
|
||||
@@ -89,8 +88,7 @@ public class MuteCommand extends CarbonCommand {
|
||||
if (handler.contains("player")) {
|
||||
target = handler.get("player");
|
||||
} else if (handler.flags().contains("uuid")) {
|
||||
final var result = this.carbonChat.server().userManager().carbonPlayer(handler.get("uuid")).join();
|
||||
target = Objects.requireNonNull(result.player(), "No player found for UUID.");
|
||||
target = this.carbonChat.server().userManager().user(handler.get("uuid")).join();
|
||||
} else {
|
||||
this.carbonMessages.muteNoTarget(sender);
|
||||
// TODO: send command syntax
|
||||
|
||||
+1
-3
@@ -24,7 +24,6 @@ import cloud.commandframework.arguments.standard.UUIDArgument;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExtrasMetaKeys;
|
||||
import cloud.commandframework.minecraft.extras.RichDescription;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Objects;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.common.command.CarbonCommand;
|
||||
@@ -89,8 +88,7 @@ public class MuteInfoCommand extends CarbonCommand {
|
||||
if (handler.contains("player")) {
|
||||
target = handler.get("player");
|
||||
} else if (handler.flags().contains("uuid")) {
|
||||
final var result = this.carbonChat.server().userManager().carbonPlayer(handler.get("uuid")).join();
|
||||
target = Objects.requireNonNull(result.player(), "No player found for UUID.");
|
||||
target = this.carbonChat.server().userManager().user(handler.get("uuid")).join();
|
||||
} else {
|
||||
target = sender;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.google.inject.Inject;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.draycia.carbon.common.command.CarbonCommand;
|
||||
import net.draycia.carbon.common.command.CommandSettings;
|
||||
@@ -100,8 +99,7 @@ public class ReplyCommand extends CarbonCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final ComponentPlayerResult<? extends CarbonPlayer> result = this.carbonChat.server().userManager().carbonPlayer(replyTarget).join();
|
||||
final @MonotonicNonNull CarbonPlayer recipient = result.player();
|
||||
final @MonotonicNonNull CarbonPlayer recipient = this.carbonChat.server().userManager().user(replyTarget).join();
|
||||
|
||||
if (sender.equals(recipient)) {
|
||||
this.carbonMessages.whisperSelfError(sender, CarbonPlayer.renderName(sender));
|
||||
|
||||
+1
-3
@@ -24,7 +24,6 @@ import cloud.commandframework.arguments.standard.UUIDArgument;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExtrasMetaKeys;
|
||||
import cloud.commandframework.minecraft.extras.RichDescription;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Objects;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.common.command.CarbonCommand;
|
||||
@@ -90,8 +89,7 @@ public class UnignoreCommand extends CarbonCommand {
|
||||
if (handler.contains("player")) {
|
||||
target = handler.get("player");
|
||||
} else if (handler.flags().contains("uuid")) {
|
||||
final var result = this.carbonChat.server().userManager().carbonPlayer(handler.get("uuid")).join();
|
||||
target = Objects.requireNonNull(result.player(), "No player found for UUID.");
|
||||
target = this.carbonChat.server().userManager().user(handler.get("uuid")).join();
|
||||
} else {
|
||||
this.carbonMessages.ignoreTargetInvalid(sender);
|
||||
return;
|
||||
|
||||
@@ -24,7 +24,6 @@ import cloud.commandframework.arguments.standard.UUIDArgument;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExtrasMetaKeys;
|
||||
import cloud.commandframework.minecraft.extras.RichDescription;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Objects;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.common.command.CarbonCommand;
|
||||
@@ -89,8 +88,7 @@ public class UnmuteCommand extends CarbonCommand {
|
||||
if (handler.contains("player")) {
|
||||
target = handler.get("player");
|
||||
} else if (handler.flags().contains("uuid")) {
|
||||
final var result = this.carbonChat.server().userManager().carbonPlayer(handler.get("uuid")).join();
|
||||
target = Objects.requireNonNull(result.player(), "No player found for UUID.");
|
||||
target = this.carbonChat.server().userManager().user(handler.get("uuid")).join();
|
||||
} else {
|
||||
this.carbonMessages.unmuteNoTarget(sender);
|
||||
// TODO: send command syntax
|
||||
|
||||
+1
-2
@@ -91,8 +91,7 @@ public class UpdateUsernameCommand extends CarbonCommand {
|
||||
if (handler.contains("player")) {
|
||||
target = handler.get("player");
|
||||
} else if (handler.flags().contains("uuid")) {
|
||||
final var result = this.carbonChat.server().userManager().carbonPlayer(handler.get("uuid")).join();
|
||||
target = Objects.requireNonNull(result.player(), "No player found for UUID.");
|
||||
target = this.carbonChat.server().userManager().user(handler.get("uuid")).join();
|
||||
} else {
|
||||
target = sender;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.draycia.carbon.api.users.UserManager;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
// todo: need to unload transient users loaded via request for non-logged in players after some time
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public interface UserManagerInternal<C extends CarbonPlayer> extends UserManager<C> {
|
||||
|
||||
|
||||
@@ -21,13 +21,12 @@ package net.draycia.carbon.fabric;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import net.draycia.carbon.api.CarbonServer;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.fabric.users.CarbonPlayerFabric;
|
||||
@@ -65,17 +64,10 @@ public final class CarbonServerFabric implements CarbonServer, ForwardingAudienc
|
||||
|
||||
@Override
|
||||
public List<? extends CarbonPlayer> players() {
|
||||
final var players = new ArrayList<CarbonPlayer>();
|
||||
|
||||
for (final var player : this.carbonChatFabric.minecraftServer().getPlayerList().getPlayers()) {
|
||||
final ComponentPlayerResult<CarbonPlayerFabric> result = this.userManager.carbonPlayer(player.getUUID()).join();
|
||||
|
||||
if (result.player() != null) {
|
||||
players.add(result.player());
|
||||
}
|
||||
}
|
||||
|
||||
return players;
|
||||
return this.carbonChatFabric.minecraftServer().getPlayerList().getPlayers().stream()
|
||||
.map(serverPlayer -> this.userManager.user(serverPlayer.getUUID()).getNow(null))
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ package net.draycia.carbon.fabric.chat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -38,15 +38,9 @@ public class MessageRecipientFilter {
|
||||
}
|
||||
|
||||
public boolean shouldFilterMessageTo(final ServerPlayer serverPlayer) {
|
||||
final ComponentPlayerResult<? extends CarbonPlayer> authorResult = CarbonChatProvider.carbonChat().server().userManager().carbonPlayer(this.sender.getUUID()).join();
|
||||
final ComponentPlayerResult<? extends CarbonPlayer> recipientResult = CarbonChatProvider.carbonChat().server().userManager().carbonPlayer(serverPlayer.getUUID()).join();
|
||||
|
||||
final @MonotonicNonNull CarbonPlayer author = authorResult.player();
|
||||
final @MonotonicNonNull CarbonPlayer recipient = recipientResult.player();
|
||||
|
||||
if (author == null || recipient == null) {
|
||||
return true; // TODO: should we filter messages when this happens?
|
||||
}
|
||||
final UserManager<? extends CarbonPlayer> userManager = CarbonChatProvider.carbonChat().server().userManager();
|
||||
final CarbonPlayer author = userManager.user(this.sender.getUUID()).join();
|
||||
final CarbonPlayer recipient = userManager.user(serverPlayer.getUUID()).join();
|
||||
|
||||
if (author.muted()) {
|
||||
return true;
|
||||
|
||||
@@ -48,7 +48,7 @@ public record FabricPlayerCommander(
|
||||
@Override
|
||||
public CarbonPlayer carbonPlayer() {
|
||||
return requireNonNull(
|
||||
this.carbon.server().userManager().carbonPlayer(this.player().getUUID()).join().player(),
|
||||
this.carbon.server().userManager().user(this.player().getUUID()).join(),
|
||||
"No CarbonPlayer for logged in Player!"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.regex.Pattern;
|
||||
import net.draycia.carbon.api.channels.ChannelRegistry;
|
||||
import net.draycia.carbon.api.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.util.KeyedRenderer;
|
||||
import net.draycia.carbon.fabric.CarbonChatFabric;
|
||||
import net.draycia.carbon.fabric.callback.ChatCallback;
|
||||
@@ -60,12 +59,7 @@ public class FabricChatListener implements Consumer<ChatCallback.Chat> {
|
||||
|
||||
@Override
|
||||
public void accept(final ChatCallback.Chat chat) {
|
||||
final var playerResult = this.carbonChatFabric.server().userManager().carbonPlayer(chat.sender().getUUID()).join();
|
||||
final @Nullable CarbonPlayer sender = playerResult.player();
|
||||
|
||||
if (sender == null) {
|
||||
return;
|
||||
}
|
||||
final @Nullable CarbonPlayer sender = this.carbonChatFabric.server().userManager().user(chat.sender().getUUID()).join();
|
||||
|
||||
var channel = requireNonNullElse(sender.selectedChannel(), this.channelRegistry.defaultValue());
|
||||
final var originalMessage = chat.message();
|
||||
@@ -123,9 +117,9 @@ public class FabricChatListener implements Consumer<ChatCallback.Chat> {
|
||||
try {
|
||||
final Optional<UUID> uuid = viewer.get(Identity.UUID);
|
||||
if (uuid.isPresent()) {
|
||||
final ComponentPlayerResult<? extends CarbonPlayer> targetPlayer = this.carbonChatFabric.server().userManager().carbonPlayer(uuid.get()).join();
|
||||
final CarbonPlayer targetPlayer = this.carbonChatFabric.server().userManager().user(uuid.get()).join();
|
||||
|
||||
renderedMessage = renderer.render(sender, targetPlayer.player(), renderedMessage, chatEvent.message());
|
||||
renderedMessage = renderer.render(sender, targetPlayer, renderedMessage, chatEvent.message());
|
||||
} else {
|
||||
renderedMessage = renderer.render(sender, viewer, renderedMessage, chatEvent.message());
|
||||
}
|
||||
|
||||
+1
-6
@@ -70,12 +70,7 @@ public class FabricChatPreviewListener implements ChatDecorator {
|
||||
return CompletableFuture.completedFuture(component);
|
||||
}
|
||||
|
||||
final var playerResult = this.carbonChat.server().userManager().carbonPlayer(serverPlayer.getUUID()).join();
|
||||
final @Nullable CarbonPlayer sender = playerResult.player();
|
||||
|
||||
if (sender == null) {
|
||||
return CompletableFuture.completedFuture(component);
|
||||
}
|
||||
final @Nullable CarbonPlayer sender = this.carbonChat.server().userManager().user(serverPlayer.getUUID()).join();
|
||||
|
||||
var channel = requireNonNullElse(sender.selectedChannel(), this.channelRegistry.defaultValue());
|
||||
|
||||
|
||||
+2
-3
@@ -21,7 +21,6 @@ package net.draycia.carbon.fabric.mixin;
|
||||
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.fabric.CarbonChatFabric;
|
||||
import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
|
||||
import net.draycia.carbon.fabric.chat.MessageRecipientFilter;
|
||||
@@ -70,8 +69,8 @@ abstract class ServerGamePacketListenerImplMixin implements ServerGamePacketList
|
||||
@Redirect(method = "broadcastChatMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatType$Bound;)V"))
|
||||
private void broadcastChatMessage(final PlayerList instance, final PlayerChatMessage playerChatMessage, final ServerPlayer serverPlayer, final ChatType.Bound bound) {
|
||||
// TODO: Get the channel the message was sent in, when the player uses /channel <message>
|
||||
final ComponentPlayerResult<? extends CarbonPlayer> result = CarbonChatProvider.carbonChat().server().userManager().carbonPlayer(serverPlayer.getUUID()).join();
|
||||
final MessageRecipientFilter filter = new MessageRecipientFilter(serverPlayer, result.player().selectedChannel());
|
||||
final CarbonPlayer result = CarbonChatProvider.carbonChat().server().userManager().user(serverPlayer.getUUID()).join();
|
||||
final MessageRecipientFilter filter = new MessageRecipientFilter(serverPlayer, result.selectedChannel());
|
||||
|
||||
for (final ServerPlayer player : this.server.getPlayerList().getPlayers()) {
|
||||
if (filter.shouldFilterMessageTo(player)) {
|
||||
|
||||
@@ -48,7 +48,7 @@ public record PaperPlayerCommander(
|
||||
|
||||
@Override
|
||||
public CarbonPlayer carbonPlayer() {
|
||||
return requireNonNull(this.server.userManager().carbonPlayer(this.player.getUniqueId()).join().player(), "No CarbonPlayer for logged in Player!");
|
||||
return requireNonNull(this.server.userManager().user(this.player.getUniqueId()).join(), "No CarbonPlayer for logged in Player!");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -59,19 +59,17 @@ public class DiscordMessageListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
final var result = this.carbonChat.server().userManager().carbonPlayer(event.getUUID()).join();
|
||||
final var result = this.carbonChat.server().userManager().user(event.getUUID()).join();
|
||||
|
||||
if (result.player() != null) {
|
||||
var channel = result.player().selectedChannel();
|
||||
var channel = result.selectedChannel();
|
||||
|
||||
if (channel == null) {
|
||||
channel = this.carbonChat.channelRegistry().defaultValue();
|
||||
}
|
||||
|
||||
final var messageType = this.channelMessageTypes.get(channel.key());
|
||||
|
||||
event.setType(messageType);
|
||||
if (channel == null) {
|
||||
channel = this.carbonChat.channelRegistry().defaultValue();
|
||||
}
|
||||
|
||||
final var messageType = this.channelMessageTypes.get(channel.key());
|
||||
|
||||
event.setType(messageType);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -66,10 +66,9 @@ public final class PaperChatListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPaperChat(final @NonNull AsyncChatEvent event) {
|
||||
final var playerResult = this.carbonChat.server().userManager().carbonPlayer(event.getPlayer().getUniqueId()).join();
|
||||
final @Nullable CarbonPlayer sender = playerResult.player();
|
||||
final @Nullable CarbonPlayer sender = this.carbonChat.server().userManager().user(event.getPlayer().getUniqueId()).join();
|
||||
|
||||
if (sender == null || event.viewers().isEmpty()) {
|
||||
if (event.viewers().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,10 +125,7 @@ public final class PaperChatListener implements Listener {
|
||||
final Audience recipientViewer;
|
||||
|
||||
if (recipientUUID.isPresent()) {
|
||||
final var recipientResult = this.carbonChat.server().userManager().carbonPlayer(viewer.get(Identity.UUID).orElseThrow()).join();
|
||||
final @Nullable CarbonPlayer recipient = recipientResult.player();
|
||||
|
||||
recipientViewer = requireNonNullElse(recipient, viewer);
|
||||
recipientViewer = this.carbonChat.server().userManager().user(viewer.get(Identity.UUID).orElseThrow()).join();
|
||||
} else {
|
||||
recipientViewer = viewer;
|
||||
}
|
||||
|
||||
@@ -51,12 +51,8 @@ public class PaperPlayerJoinListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJoin(final PlayerJoinEvent event) {
|
||||
this.carbonChat.server().userManager().carbonPlayer(event.getPlayer().getUniqueId()).thenAccept(result -> {
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Optional.ofNullable(result.player().displayName()).ifPresent(displayName -> {
|
||||
this.carbonChat.server().userManager().user(event.getPlayer().getUniqueId()).thenAccept(result -> {
|
||||
Optional.ofNullable(result.displayName()).ifPresent(displayName -> {
|
||||
final Player player = event.getPlayer();
|
||||
player.displayName(displayName);
|
||||
player.playerListName(displayName);
|
||||
|
||||
Reference in new issue
Block a user