diff --git a/common/src/main/kotlin/com/bluedragonmc/server/api/OutgoingRPCHandler.kt b/common/src/main/kotlin/com/bluedragonmc/server/api/OutgoingRPCHandler.kt index 767df97..632c288 100644 --- a/common/src/main/kotlin/com/bluedragonmc/server/api/OutgoingRPCHandler.kt +++ b/common/src/main/kotlin/com/bluedragonmc/server/api/OutgoingRPCHandler.kt @@ -9,7 +9,6 @@ import com.bluedragonmc.server.Game import net.kyori.adventure.text.Component import net.minestom.server.command.CommandSender import net.minestom.server.entity.Player -import net.minestom.server.instance.Instance import java.util.* /** @@ -48,7 +47,7 @@ interface OutgoingRPCHandler { suspend fun kickFromParty(partyOwner: UUID, player: UUID) suspend fun leaveParty(player: UUID) suspend fun partyChat(message: String, sender: Player) - suspend fun warpParty(partyOwner: Player, instance: Instance) + suspend fun warpParty(partyOwner: Player, gameId: String) suspend fun transferParty(partyOwner: Player, newOwner: UUID) suspend fun listPartyMembers(member: UUID): PartyListResponse diff --git a/common/src/main/kotlin/com/bluedragonmc/server/api/OutgoingRPCHandlerStub.kt b/common/src/main/kotlin/com/bluedragonmc/server/api/OutgoingRPCHandlerStub.kt index 8821b39..70926f6 100644 --- a/common/src/main/kotlin/com/bluedragonmc/server/api/OutgoingRPCHandlerStub.kt +++ b/common/src/main/kotlin/com/bluedragonmc/server/api/OutgoingRPCHandlerStub.kt @@ -5,7 +5,6 @@ import com.bluedragonmc.server.Game import net.kyori.adventure.text.Component import net.minestom.server.command.CommandSender import net.minestom.server.entity.Player -import net.minestom.server.instance.Instance import java.util.* /** @@ -90,7 +89,7 @@ class OutgoingRPCHandlerStub : OutgoingRPCHandler { } - override suspend fun warpParty(partyOwner: Player, instance: Instance) { + override suspend fun warpParty(partyOwner: Player, gameId: String) { } diff --git a/src/main/kotlin/com/bluedragonmc/server/command/PartyCommand.kt b/src/main/kotlin/com/bluedragonmc/server/command/PartyCommand.kt index ea6ff4b..c6651f5 100644 --- a/src/main/kotlin/com/bluedragonmc/server/command/PartyCommand.kt +++ b/src/main/kotlin/com/bluedragonmc/server/command/PartyCommand.kt @@ -1,5 +1,6 @@ package com.bluedragonmc.server.command +import com.bluedragonmc.server.Game import com.bluedragonmc.server.service.Messaging import com.bluedragonmc.server.service.Permissions import com.bluedragonmc.server.utils.miniMessage @@ -63,7 +64,12 @@ class PartyCommand(name: String, usageString: String, vararg aliases: String) : subcommand("warp") { suspendSyntax { - Messaging.outgoing.warpParty(player, player.instance!!) + val gameId = Game.findGame(player)?.id + if (gameId == null) { + sender.sendMessage(Component.translatable("puffin.party.warp.invalid_destination", errorColor)) + return@suspendSyntax + } + Messaging.outgoing.warpParty(player, gameId) } } diff --git a/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt b/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt index 11dae00..05cec3c 100644 --- a/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt +++ b/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt @@ -25,7 +25,6 @@ import net.minestom.server.event.EventNode import net.minestom.server.event.instance.AddEntityToInstanceEvent import net.minestom.server.event.player.PlayerDisconnectEvent import net.minestom.server.event.player.PlayerSpawnEvent -import net.minestom.server.instance.Instance import java.time.Duration import java.util.* import java.util.concurrent.TimeUnit @@ -280,11 +279,11 @@ class OutgoingRPCHandlerImpl(serverAddress: String, serverPort: Int) : OutgoingR ) } - override suspend fun warpParty(partyOwner: Player, instance: Instance) { + override suspend fun warpParty(partyOwner: Player, gameId: String) { partyStub.withDeadlineAfter(5, TimeUnit.SECONDS).warpParty( PartySvc.PartyWarpRequest.newBuilder() .setPartyOwnerUuid(partyOwner.uuid.toString()) - .setInstanceUuid(instance.uniqueId.toString()) + .setInstanceUuid(gameId) .setServerName(serverName) .build() ) diff --git a/src/main/resources/lang_en.properties b/src/main/resources/lang_en.properties index a01146b..83e1b37 100644 --- a/src/main/resources/lang_en.properties +++ b/src/main/resources/lang_en.properties @@ -465,6 +465,7 @@ puffin.party.chat.not_found=You are not in a party. puffin.party.warp.not_enough_space=There is not enough space in this game for your entire party! puffin.party.warp.not_leader=You must be the leader of a party to do this. puffin.party.warp.success={0} members of the party have been warped to {1}'s server. +puffin.party.warp.invalid_destination=You must be in a game to use this command. puffin.party.transfer.success=The party has been transferred to {0}. puffin.party.transfer.not_leader=You must be the leader of a party to do this.