diff --git a/build.gradle.kts b/build.gradle.kts index 052a512..8e54a0c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,9 +20,8 @@ repositories { dependencies { // Minestom - api("net.minestom:minestom-snapshots:17fd82a5c1") -// api("net.minestom:minestom-snapshots:0c9527118a") // todo update to this minestom - lots of breaking changes - api("net.kyori:adventure-text-minimessage:4.15.0") // Version that Minestom uses (https://github.com/Minestom/Minestom/blob/17fd82a5c1dc845d417ab2c60ae1248369e4fdff/gradle/libs.versions.toml#L7) + api("net.minestom:minestom-snapshots:789befee31") + api("net.kyori:adventure-text-minimessage:4.15.0") implementation("io.pyroscope:agent:0.12.2") // Logger @@ -31,8 +30,8 @@ dependencies { // APIs api("dev.emortal.api:module-system:1.0.0") - api("dev.emortal.api:agones-sdk:1.0.7") - api("dev.emortal.api:common-proto-sdk:6a9ad1a") + api("dev.emortal.api:agones-sdk:1.1.0") + api("dev.emortal.api:common-proto-sdk:fee482e") api("dev.emortal.api:live-config-parser:f0728b0") api("io.kubernetes:client-java:18.0.1") @@ -47,6 +46,8 @@ java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } + + withSourcesJar() } tasks { diff --git a/src/main/java/dev/emortal/minestom/core/module/core/badge/BadgeGui.java b/src/main/java/dev/emortal/minestom/core/module/core/badge/BadgeGui.java index 0ebb1b9..0b87b84 100644 --- a/src/main/java/dev/emortal/minestom/core/module/core/badge/BadgeGui.java +++ b/src/main/java/dev/emortal/minestom/core/module/core/badge/BadgeGui.java @@ -12,9 +12,10 @@ import net.minestom.server.inventory.InventoryType; import net.minestom.server.inventory.click.ClickType; import net.minestom.server.inventory.condition.InventoryConditionResult; -import net.minestom.server.item.ItemHideFlag; +import net.minestom.server.item.ItemComponent; import net.minestom.server.item.ItemStack; import net.minestom.server.item.Material; +import net.minestom.server.item.component.AttributeList; import net.minestom.server.tag.Tag; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -120,11 +121,12 @@ private void onClick(@NotNull Player clicker, int slot, @NotNull ClickType click return; } - boolean isUnlocked = clickedItem.meta().getTag(BADGE_UNLOCKED_TAG); - boolean isActive = clickedItem.meta().getTag(BADGE_ACTIVE_TAG); + + boolean isUnlocked = clickedItem.getTag(BADGE_UNLOCKED_TAG); + boolean isActive = clickedItem.getTag(BADGE_ACTIVE_TAG); if (!isUnlocked || isActive) return; - String badgeId = clickedItem.meta().getTag(BADGE_ID_TAG); + String badgeId = clickedItem.getTag(BADGE_ID_TAG); try { this.badgeService.setActiveBadge(clicker.getUuid(), badgeId); } catch (StatusRuntimeException exception) { @@ -133,7 +135,7 @@ private void onClick(@NotNull Player clicker, int slot, @NotNull ClickType click return; } - String badgeName = clickedItem.meta().getTag(BADGE_NAME_TAG); + String badgeName = clickedItem.getTag(BADGE_NAME_TAG); clicker.sendMessage(Component.text("Set active badge to " + badgeName, NamedTextColor.GREEN)); new BadgeGui(this.badgeService, clicker); // Reopen the gui } @@ -163,14 +165,13 @@ private void onClick(@NotNull Player clicker, int slot, @NotNull ClickType click } return ItemStack.builder(Material.fromNamespaceId(guiItem.getMaterial())) - .displayName(MINI_MESSAGE.deserialize(guiItem.getDisplayName())) - .lore(lore) - .meta(builder -> builder.hideFlag(ItemHideFlag.HIDE_ATTRIBUTES) - .set(BADGE_ID_TAG, badge.getId()) - .set(BADGE_NAME_TAG, badge.getFriendlyName()) - .set(BADGE_ACTIVE_TAG, isActive) - .set(BADGE_UNLOCKED_TAG, isOwned) - ) - .build(); + .set(ItemComponent.ITEM_NAME, MINI_MESSAGE.deserialize(guiItem.getDisplayName())) + .set(ItemComponent.LORE, lore) + .set(BADGE_ID_TAG, badge.getId()) + .set(BADGE_NAME_TAG, badge.getFriendlyName()) + .set(BADGE_ACTIVE_TAG, isActive) + .set(BADGE_UNLOCKED_TAG, isOwned) + .set(ItemComponent.ATTRIBUTE_MODIFIERS, new AttributeList(List.of(), false) + ).build(); } } diff --git a/src/main/java/dev/emortal/minestom/core/module/kubernetes/KubernetesModule.java b/src/main/java/dev/emortal/minestom/core/module/kubernetes/KubernetesModule.java index abfad41..b5ec133 100644 --- a/src/main/java/dev/emortal/minestom/core/module/kubernetes/KubernetesModule.java +++ b/src/main/java/dev/emortal/minestom/core/module/kubernetes/KubernetesModule.java @@ -2,6 +2,7 @@ import dev.agones.sdk.AgonesSDKProto; import dev.agones.sdk.SDKGrpc; +import dev.agones.sdk.beta.BetaAgonesSDKProto; import dev.emortal.api.agonessdk.AgonesUtils; import dev.emortal.api.agonessdk.IgnoredStreamObserver; import dev.emortal.api.modules.Module; @@ -11,12 +12,15 @@ import dev.emortal.minestom.core.Environment; import dev.emortal.minestom.core.module.kubernetes.command.agones.AgonesCommand; import dev.emortal.minestom.core.module.kubernetes.command.currentserver.CurrentServerCommand; +import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import io.kubernetes.client.ProtoClient; import io.kubernetes.client.openapi.ApiClient; import io.kubernetes.client.openapi.Configuration; import io.kubernetes.client.util.Config; import net.minestom.server.MinecraftServer; +import net.minestom.server.event.player.AsyncPlayerConfigurationEvent; +import net.minestom.server.event.player.PlayerDisconnectEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; @@ -48,6 +52,7 @@ public final class KubernetesModule extends Module { private ProtoClient protoClient; private SDKGrpc.SDKStub sdk; + private dev.agones.sdk.beta.SDKGrpc.SDKStub betaSdk; public KubernetesModule(@NotNull ModuleEnvironment environment, @NotNull AgonesSDKProto.KeyValue... additionalLabels) { super(environment); @@ -80,9 +85,11 @@ public boolean onLoad() { } private void loadAgones() { - this.sdk = SDKGrpc.newStub(ManagedChannelBuilder.forAddress(AGONES_ADDRESS, AGONES_GRPC_PORT).usePlaintext().build()); + ManagedChannel channel = ManagedChannelBuilder.forAddress(AGONES_ADDRESS, AGONES_GRPC_PORT).usePlaintext().build(); + this.sdk = SDKGrpc.newStub(channel); + this.betaSdk = dev.agones.sdk.beta.SDKGrpc.newStub(channel); - MinecraftServer.getCommandManager().register(new AgonesCommand(this.sdk)); + MinecraftServer.getCommandManager().register(new AgonesCommand(this.sdk, this.betaSdk)); for (AgonesSDKProto.KeyValue label : this.additionalLabels) { this.sdk.setLabel(label, new IgnoredStreamObserver<>()); @@ -103,6 +110,40 @@ private void loadAgones() { this.sdk.setAnnotation(protocolVersion, new IgnoredStreamObserver<>()); this.sdk.setAnnotation(versionName, new IgnoredStreamObserver<>()); + + this.loadAgonesCountsAndLists(); + } + + private void loadAgonesCountsAndLists() { + MinecraftServer.getGlobalEventHandler().addListener(AsyncPlayerConfigurationEvent.class, event -> { + this.updateAgonesCounter("players", 1); + this.addToAgonesList("players", event.getPlayer().getUuid().toString()); + }).addListener(PlayerDisconnectEvent.class, event -> { + this.updateAgonesCounter("players", -1); + this.removeFromAgonesList("players", event.getPlayer().getUuid().toString()); + }); + } + + public void updateAgonesCounter(String name, long diff) { + this.betaSdk.updateCounter(BetaAgonesSDKProto.UpdateCounterRequest.newBuilder() + .setCounterUpdateRequest(BetaAgonesSDKProto.CounterUpdateRequest.newBuilder() + .setName(name) + .setCountDiff(diff)) + .build(), new IgnoredStreamObserver<>()); + } + + public void addToAgonesList(String listName, String value) { + this.betaSdk.addListValue(BetaAgonesSDKProto.AddListValueRequest.newBuilder() + .setName(listName) + .setValue(value) + .build(), new IgnoredStreamObserver<>()); + } + + public void removeFromAgonesList(String listName, String value) { + this.betaSdk.removeListValue(BetaAgonesSDKProto.RemoveListValueRequest.newBuilder() + .setName(listName) + .setValue(value) + .build(), new IgnoredStreamObserver<>()); } @Override @@ -137,7 +178,11 @@ private void readyAgones() { return this.protoClient; } - public @Nullable SDKGrpc.SDKStub getSdk() { + public @Nullable SDKGrpc.SDKStub getAgonesSdk() { return this.sdk; } + + public @Nullable dev.agones.sdk.beta.SDKGrpc.SDKStub getAgonesBetaSdk() { + return this.betaSdk; + } } diff --git a/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/agones/AgonesCommand.java b/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/agones/AgonesCommand.java index 88719f2..02a99a9 100644 --- a/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/agones/AgonesCommand.java +++ b/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/agones/AgonesCommand.java @@ -11,18 +11,21 @@ public final class AgonesCommand extends Command { - public AgonesCommand(@NotNull SDKGrpc.SDKStub sdk) { + public AgonesCommand(@NotNull SDKGrpc.SDKStub sdk, dev.agones.sdk.beta.SDKGrpc.SDKStub betaSdk) { super("magones"); this.setCondition(ExtraConditions.hasPermission("command.agones")); - var sdkSubs = new SdkSubCommands(sdk); + var sdkSubs = new SdkSubCommands(sdk, betaSdk); // /magones get gameserver this.addSyntax(sdkSubs::executeGetGameServer, new ArgumentLiteral("get"), new ArgumentLiteral("gameserver")); - // /magones reserve - this.addSyntax(sdkSubs::executeReserve, new ArgumentLiteral("reserve"), new ArgumentTime("duration")); - // /magones allocate - this.addSyntax(sdkSubs::executeAllocate, new ArgumentLiteral("allocate")); + + // /magones get count [id] + this.addSyntax(sdkSubs::executeListCounters, new ArgumentLiteral("get"), new ArgumentLiteral("counters")); + + // /magones get list [id] + this.addSyntax(sdkSubs::executeListLists, new ArgumentLiteral("get"), new ArgumentLiteral("list")); + this.addSyntax(sdkSubs::executeGetList, new ArgumentLiteral("get"), new ArgumentLiteral("list"), new ArgumentString("id")); var set = new ArgumentLiteral("set"); var key = new ArgumentString("key"); diff --git a/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/agones/SdkSubCommands.java b/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/agones/SdkSubCommands.java index e244770..d30aa16 100644 --- a/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/agones/SdkSubCommands.java +++ b/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/agones/SdkSubCommands.java @@ -1,8 +1,13 @@ package dev.emortal.minestom.core.module.kubernetes.command.agones; +import allocation.Allocation; import dev.agones.sdk.AgonesSDKProto; import dev.agones.sdk.SDKGrpc; +import dev.agones.sdk.beta.BetaAgonesSDKProto; import io.grpc.stub.StreamObserver; + +import java.util.Map; +import java.util.StringJoiner; import java.util.function.Function; import net.kyori.adventure.text.Component; import net.minestom.server.command.CommandSender; @@ -15,14 +20,20 @@ public final class SdkSubCommands { private static @NotNull Component generateMessage(@NotNull String sdk, @NotNull String method, @NotNull AgonesCommand.RequestStatus status, @NotNull String message) { - String text = "Agones >> [%s.%s] (%s) %s".formatted(sdk, method, status.name(), message); + String text = "Agones >> [%s.%s] (%s)".formatted(sdk, method, status.name()); + if (!message.isEmpty()) { + text += "\n" + message; + } + return Component.text(text, status.getColor()); } private final @NotNull SDKGrpc.SDKStub sdk; + private final @NotNull dev.agones.sdk.beta.SDKGrpc.SDKStub betaSdk; - public SdkSubCommands(@NotNull SDKGrpc.SDKStub sdk) { + public SdkSubCommands(@NotNull SDKGrpc.SDKStub sdk, dev.agones.sdk.beta.SDKGrpc.@NotNull SDKStub betaSdk) { this.sdk = sdk; + this.betaSdk = betaSdk; } private @NotNull StreamObserver createCallback(@NotNull CommandSender sender, @NotNull String sdkMethod, @@ -54,15 +65,40 @@ public void executeGetGameServer(@NotNull CommandSender sender, @NotNull Command this.sdk.getGameServer(AgonesSDKProto.Empty.getDefaultInstance(), this.createCallback(sender, "GetGameServer", Object::toString)); } - public void executeReserve(@NotNull CommandSender sender, @NotNull CommandContext context) { - Duration duration = context.get("duration"); - AgonesSDKProto.Duration agonesDuration = AgonesSDKProto.Duration.newBuilder().setSeconds(duration.getSeconds()).build(); + public void executeListCounters(@NotNull CommandSender sender, @NotNull CommandContext context) { + this.sdk.getGameServer(AgonesSDKProto.Empty.getDefaultInstance(), this.createCallback(sender, "GetGameServer [Counters]", gameServer -> { + Map counters = gameServer.getStatus().getCountersMap(); + StringJoiner joiner = new StringJoiner(", ", "Counters: \n", ""); + for (Map.Entry entry : counters.entrySet()) { + String key = entry.getKey(); + AgonesSDKProto.GameServer.Status.CounterStatus value = entry.getValue(); + joiner.add(" - %s (%s/%s)".formatted(key, value.getCount(), value.getCapacity())); + } + + return joiner.toString(); + })); + } + + public void executeListLists(@NotNull CommandSender sender, @NotNull CommandContext context) { + this.sdk.getGameServer(AgonesSDKProto.Empty.getDefaultInstance(), this.createCallback(sender, "GetGameServer [Lists]", gameServer -> { + Map lists = gameServer.getStatus().getListsMap(); + + StringJoiner joiner = new StringJoiner(", ", "Lists: \n", ""); + for (Map.Entry entry : lists.entrySet()) { + String key = entry.getKey(); + AgonesSDKProto.GameServer.Status.ListStatus value = entry.getValue(); + joiner.add(" - %s (%s/%s)".formatted(key, value.getValuesCount(), value.getCapacity())); + } - this.sdk.reserve(agonesDuration, this.createCallback(sender, "Reserve", v -> "Reserved for %s seconds".formatted(duration.getSeconds()))); + return joiner.toString(); + })); } - public void executeAllocate(@NotNull CommandSender sender, @NotNull CommandContext context) { - this.sdk.allocate(AgonesSDKProto.Empty.getDefaultInstance(), this.createCallback(sender, "Allocate", v -> "Allocated")); + public void executeGetList(@NotNull CommandSender sender, @NotNull CommandContext context) { + String id = context.get("id"); + AgonesSDKProto.KeyValue keyValue = AgonesSDKProto.KeyValue.newBuilder().setKey(id).build(); + this.betaSdk.getList(BetaAgonesSDKProto.GetListRequest.newBuilder().setName(id).build(), + this.createCallback(sender, "GetList", Object::toString)); } public void executeSetAnnotation(@NotNull CommandSender sender, @NotNull CommandContext context) { diff --git a/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/currentserver/CurrentServerCommand.java b/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/currentserver/CurrentServerCommand.java index d516a09..c70f3ea 100644 --- a/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/currentserver/CurrentServerCommand.java +++ b/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/currentserver/CurrentServerCommand.java @@ -22,14 +22,9 @@ public final class CurrentServerCommand extends Command { private static final Logger LOGGER = LoggerFactory.getLogger(CurrentServerCommand.class); - private static final String MESSAGE = """ - Proxy: - Server: - Fleet: """; private static final String COPY_MESSAGE = """ Proxy: %s Server: %s - Instance: %s Position: %s"""; private final @NotNull PlayerTrackerService playerTracker; @@ -59,13 +54,30 @@ private void onExecute(@NotNull CommandSender sender, @NotNull CommandContext co return; } - var serverId = Placeholder.unparsed("server_id", currentServer.getServerId()); - var proxyId = Placeholder.unparsed("proxy_id", currentServer.getProxyId()); - var fleetId = Placeholder.unparsed("fleet_id", currentServer.getFleetName()); + Component message = Component.text().append( + Component.text("Proxy: ", NamedTextColor.DARK_PURPLE) + .append(Component.text(currentServer.getProxyId(), NamedTextColor.LIGHT_PURPLE)) + .hoverEvent(HoverEvent.showText(Component.text("Click to copy Proxy ID", NamedTextColor.GREEN))) + .clickEvent(ClickEvent.copyToClipboard(currentServer.getProxyId())) + ).append( + Component.newline() + .append(Component.text("Server: ", NamedTextColor.DARK_PURPLE)) + .append(Component.text(currentServer.getServerId(), NamedTextColor.LIGHT_PURPLE)) + .hoverEvent(HoverEvent.showText(Component.text("Click to copy Server ID", NamedTextColor.GREEN))) + .clickEvent(ClickEvent.copyToClipboard(currentServer.getServerId())) + ).append( + Component.newline() + .append(Component.text("Fleet: ", NamedTextColor.DARK_PURPLE)) + .append(Component.text(currentServer.getFleetName(), NamedTextColor.LIGHT_PURPLE)) + .hoverEvent(HoverEvent.showText(Component.text("Click to copy Fleet Name", NamedTextColor.GREEN))) + .clickEvent(ClickEvent.copyToClipboard(currentServer.getFleetName())) + ).append( + Component.newline() + .append(Component.text("⎘ Click to copy", NamedTextColor.GREEN)) + .clickEvent(ClickEvent.copyToClipboard(this.createCopyableData(currentServer, player))) + .hoverEvent(HoverEvent.showText(Component.text("Click to copy all data", NamedTextColor.GREEN))) + ).build(); - var message = MiniMessage.miniMessage().deserialize(MESSAGE, serverId, proxyId, fleetId) - .clickEvent(ClickEvent.copyToClipboard(this.createCopyableData(currentServer, player))) - .hoverEvent(HoverEvent.showText(Component.text("Click to copy", NamedTextColor.GREEN))); sender.sendMessage(message); } @@ -73,7 +85,6 @@ private void onExecute(@NotNull CommandSender sender, @NotNull CommandContext co return COPY_MESSAGE.formatted( server.getProxyId(), server.getServerId(), - player.getInstance().getUniqueId(), this.formatPos(player.getPosition()) ); } diff --git a/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/DefaultMatchmakingSessionImpl.java b/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/DefaultMatchmakingSessionImpl.java index 4afc6e5..e153593 100644 --- a/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/DefaultMatchmakingSessionImpl.java +++ b/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/DefaultMatchmakingSessionImpl.java @@ -11,6 +11,7 @@ import net.minestom.server.entity.Player; import net.minestom.server.timer.TaskSchedule; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.time.Instant; import java.util.concurrent.Executors; @@ -33,7 +34,7 @@ public final class DefaultMatchmakingSessionImpl extends MatchmakingSession { private final @NotNull ScheduledFuture notificationTask; private final @NotNull GameModeConfig gameMode; - public DefaultMatchmakingSessionImpl(@NotNull Player player, @NotNull GameModeConfig gameMode, @NotNull Ticket ticket) { + public DefaultMatchmakingSessionImpl(@NotNull Player player, @NotNull GameModeConfig gameMode, @NotNull Ticket ticket, @Nullable PendingMatch pendingMatch) { super(player, ticket); this.notificationTask = SCHEDULER.scheduleAtFixedRate(this::notifyPlayer, 30, 30, TimeUnit.SECONDS); diff --git a/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/MatchmakingSession.java b/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/MatchmakingSession.java index a8107cb..d4b52a4 100644 --- a/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/MatchmakingSession.java +++ b/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/MatchmakingSession.java @@ -5,6 +5,7 @@ import dev.emortal.api.model.matchmaker.Ticket; import net.minestom.server.entity.Player; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public abstract class MatchmakingSession { @@ -54,6 +55,6 @@ public void setTicket(@NotNull Ticket ticket) { @FunctionalInterface public interface Creator { - @NotNull MatchmakingSession create(@NotNull Player player, @NotNull GameModeConfig gameMode, @NotNull Ticket ticket); + @NotNull MatchmakingSession create(@NotNull Player player, @NotNull GameModeConfig gameMode, @NotNull Ticket ticket, @Nullable PendingMatch pendingMatch); } } diff --git a/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/MatchmakingSessionManager.java b/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/MatchmakingSessionManager.java index 1fd1903..3679a70 100644 --- a/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/MatchmakingSessionManager.java +++ b/src/main/java/dev/emortal/minestom/core/module/matchmaker/session/MatchmakingSessionManager.java @@ -25,6 +25,7 @@ import net.minestom.server.event.EventNode; import net.minestom.server.event.player.AsyncPlayerConfigurationEvent; import net.minestom.server.event.player.PlayerDisconnectEvent; +import net.minestom.server.event.player.PlayerSpawnEvent; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +55,7 @@ public MatchmakingSessionManager(@NotNull EventNode eventNode, @NotNull M this.sessionCreator = sessionCreator; this.gameModes = gameModes; - eventNode.addListener(AsyncPlayerConfigurationEvent.class, this::handlePlayerLogin); + eventNode.addListener(PlayerSpawnEvent.class, this::handlePlayerLogin); eventNode.addListener(PlayerDisconnectEvent.class, event -> { UUID playerId = event.getPlayer().getUuid(); @@ -104,7 +105,7 @@ private void onTicketCreate(@NotNull Ticket ticket) { if (player == null) continue; GameModeConfig gameMode = this.gameModes.getConfig(ticket.getGameModeId()); - MatchmakingSession session = this.sessionCreator.create(player, gameMode, ticket); + MatchmakingSession session = this.sessionCreator.create(player, gameMode, ticket, null); this.sessions.put(uuid, session); shouldCache = true; } @@ -146,7 +147,7 @@ private void onTicketUpdated(@NotNull Ticket newTicket) { Player player = MinecraftServer.getConnectionManager().getOnlinePlayerByUuid(uuid); if (player == null) continue; - session = this.sessionCreator.create(player, gameMode, newTicket); + session = this.sessionCreator.create(player, gameMode, newTicket, null); this.sessions.put(uuid, session); } @@ -197,7 +198,7 @@ private void destroySession(@NotNull MatchmakingSession session) { session.destroy(); } - private void handlePlayerLogin(@NotNull AsyncPlayerConfigurationEvent event) { + private void handlePlayerLogin(@NotNull PlayerSpawnEvent event) { Player player = event.getPlayer(); UUID playerId = player.getUuid(); @@ -206,7 +207,7 @@ private void handlePlayerLogin(@NotNull AsyncPlayerConfigurationEvent event) { queueInfo = this.matchmaker.getPlayerQueueInfo(playerId); } catch (StatusRuntimeException exception) { LOGGER.error("Failed to get queue info for '{}'", player.getUsername(), exception); - player.sendMessage(Component.text("An unknown error occurred", NamedTextColor.RED)); + player.sendMessage(Component.text("An unknown error occurred retrieving queue info", NamedTextColor.RED)); return; } @@ -223,7 +224,7 @@ private void handlePlayerLogin(@NotNull AsyncPlayerConfigurationEvent event) { return; } - MatchmakingSession session = this.sessionCreator.create(player, mode, ticket); + MatchmakingSession session = this.sessionCreator.create(player, mode, ticket, queueInfo.getPendingMatch()); this.sessions.put(playerId, session); this.ticketCache.put(ticket.getId(), ticket);