Skip to content

Commit

Permalink
Fix /p warp command
Browse files Browse the repository at this point in the history
  • Loading branch information
FluxCapacitor2 committed Dec 24, 2024
1 parent e4ed0e1 commit fb48500
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*

/**
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*

/**
Expand Down Expand Up @@ -90,7 +89,7 @@ class OutgoingRPCHandlerStub : OutgoingRPCHandler {

}

override suspend fun warpParty(partyOwner: Player, instance: Instance) {
override suspend fun warpParty(partyOwner: Player, gameId: String) {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
)
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit fb48500

Please sign in to comment.