diff --git a/src/main/kotlin/net/superricky/tpaplusplus/async/AsyncCommandData.kt b/src/main/kotlin/net/superricky/tpaplusplus/async/AsyncCommandData.kt index c82f18d..91acfe3 100644 --- a/src/main/kotlin/net/superricky/tpaplusplus/async/AsyncCommandData.kt +++ b/src/main/kotlin/net/superricky/tpaplusplus/async/AsyncCommandData.kt @@ -11,12 +11,39 @@ import net.superricky.tpaplusplus.utility.* class AsyncCommandData( private val asyncRequest: AsyncRequest, private var pos: LevelBoundVec3, - private val callback: Function2 + private val asyncCommandEventFactory: AsyncCommandEventFactory ) { private var canceled: AtomicBoolean = atomic(false) private var timeout = Config.getConfig()[CommonSpec.tpaTimeout].translateSecondToTick() private var checkTarget = asyncRequest.sender + init { + asyncCommandEventFactory + .addListener(AsyncCommandEvent.REQUEST_AFTER_DELAY) { + AsyncCommandHelper.addCooldown( + asyncRequest.sender.uuid, + asyncRequest.commandType + ) + } + .addListener(AsyncCommandEvent.REQUEST_OUT_DISTANCE) { + asyncRequest.sender.sendMessage( + Text.translatable( + "command.windup.error.out_distance", + asyncRequest.commandType.handler.getCommandName() + ).setStyle(TextColorPallet.error) + ) + } + .addListener(AsyncCommandEvent.REQUEST_UPDATE_MESSAGE) { + asyncRequest.sender.sendRemainTime(asyncRequest.delay) + } + .addListener(AsyncCommandEvent.REQUEST_UNDER_COOLDOWN) { + asyncRequest.sender.sendCooldownTime( + asyncRequest.commandType.handler.getCommandName(), + asyncRequest.cooldown.translateTickToSecond() + ) + } + } + fun needDelay(): Boolean = asyncRequest.delay != 0.0 fun getDelay(): Double = asyncRequest.delay @@ -54,34 +81,7 @@ class AsyncCommandData( if (isCanceled()) { return } - when (commandResult) { - AsyncCommandEvent.REQUEST_AFTER_DELAY -> { - AsyncCommandHelper.addCooldown(asyncRequest.sender.uuid, asyncRequest.commandType) - } - - AsyncCommandEvent.REQUEST_OUT_DISTANCE -> { - asyncRequest.sender.sendMessage( - Text.translatable( - "command.windup.error.out_distance", - asyncRequest.commandType.handler.getCommandName() - ).setStyle(TextColorPallet.error) - ) - } - - AsyncCommandEvent.REQUEST_UPDATE_MESSAGE -> { - asyncRequest.sender.sendRemainTime(asyncRequest.delay) - } - - AsyncCommandEvent.REQUEST_UNDER_COOLDOWN -> { - asyncRequest.sender.sendCooldownTime( - asyncRequest.commandType.handler.getCommandName(), - asyncRequest.cooldown.translateTickToSecond() - ) - } - - else -> {} - } - callback.invoke(commandResult, this) + asyncCommandEventFactory.invoke(commandResult, this) } fun cancel() { diff --git a/src/main/kotlin/net/superricky/tpaplusplus/async/AsyncCommandEventFactory.kt b/src/main/kotlin/net/superricky/tpaplusplus/async/AsyncCommandEventFactory.kt new file mode 100644 index 0000000..b2c554b --- /dev/null +++ b/src/main/kotlin/net/superricky/tpaplusplus/async/AsyncCommandEventFactory.kt @@ -0,0 +1,33 @@ +package net.superricky.tpaplusplus.async + +class AsyncCommandEventFactory { + private val listeners: MutableMap>> = mutableMapOf() + + fun addListener(event: AsyncCommandEvent, listener: Function1): AsyncCommandEventFactory { + if (!listeners.containsKey(event)) { + listeners[event] = HashSet() + } + listeners[event]!!.add(listener) + return this + } + + fun invoke(event: AsyncCommandEvent, asyncCommandData: AsyncCommandData): AsyncCommandEventFactory { + if (!listeners.containsKey(event)) { + listeners[event] = HashSet() + return this + } + for (listener in listeners[event]!!) { + listener.invoke(asyncCommandData) + } + return this + } + + companion object { + fun addListener( + event: AsyncCommandEvent, + listener: Function1 + ): AsyncCommandEventFactory { + return AsyncCommandEventFactory().addListener(event, listener) + } + } +} diff --git a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/AcceptCommand.kt b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/AcceptCommand.kt index 640f886..ab28e9e 100644 --- a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/AcceptCommand.kt +++ b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/AcceptCommand.kt @@ -59,23 +59,17 @@ object AcceptCommand : AsyncCommand(), BuildableCommand { AsyncCommandData( AsyncRequest(sender, receiver, AsyncCommandType.ACCEPT), LevelBoundVec3(sender.getDimension(), sender.pos), - ::asyncCommandCallback + AsyncCommandEventFactory.addListener(AsyncCommandEvent.REQUEST_AFTER_DELAY) { + if (AsyncCommandHelper.acceptRequest(sender, receiver) == AsyncCommandEvent.REQUEST_NOT_FOUND) { + CommandHelper.requestNotFound(sender, receiver) + } + } ) ) return CommandResult.NORMAL.status } private fun acceptCommand(context: Context): Int { - fun asyncCommandCallback(result: AsyncCommandEvent, asyncCommandData: AsyncCommandData) { - val asyncRequest = asyncCommandData.getRequest() - if (result == AsyncCommandEvent.REQUEST_AFTER_DELAY) { - val sender = asyncRequest.sender - if (AsyncCommandHelper.acceptRequest(sender) == AsyncCommandEvent.REQUEST_NOT_FOUND) { - CommandHelper.requestNotFound(sender) - } - } - } - val source = context.source val sender = source.player sender ?: return CommandResult.SENDER_NOT_EXIST.status @@ -83,7 +77,11 @@ object AcceptCommand : AsyncCommand(), BuildableCommand { AsyncCommandData( AsyncRequest(sender, null, AsyncCommandType.ACCEPT), LevelBoundVec3(sender.getDimension(), sender.pos), - ::asyncCommandCallback + AsyncCommandEventFactory.addListener(AsyncCommandEvent.REQUEST_AFTER_DELAY) { + if (AsyncCommandHelper.acceptRequest(sender) == AsyncCommandEvent.REQUEST_NOT_FOUND) { + CommandHelper.requestNotFound(sender) + } + } ) ) return CommandResult.NORMAL.status diff --git a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/CancelCommand.kt b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/CancelCommand.kt index 9a99041..4ee867d 100644 --- a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/CancelCommand.kt +++ b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/CancelCommand.kt @@ -38,17 +38,6 @@ object CancelCommand : AsyncCommand(), BuildableCommand { override fun getMinDistance(): Double = Config.getConfig()[CommandDistanceSpec.cancelDistance] private fun cancelRequestWithTarget(context: Context): Int { - fun asyncCommandCallback(result: AsyncCommandEvent, asyncCommandData: AsyncCommandData) { - val asyncRequest = asyncCommandData.getRequest() - if (result == AsyncCommandEvent.REQUEST_AFTER_DELAY) { - val sender = asyncRequest.sender - val receiver = asyncRequest.receiver!! - if (AsyncCommandHelper.cancelRequest(sender, receiver) == AsyncCommandEvent.REQUEST_NOT_FOUND) { - CommandHelper.requestNotFound(sender, receiver) - } - } - } - val source = context.source val (result, sender, receiver) = checkSenderReceiver(context) if (result != CommandResult.NORMAL) return result.status @@ -58,23 +47,17 @@ object CancelCommand : AsyncCommand(), BuildableCommand { AsyncCommandData( AsyncRequest(sender, receiver, AsyncCommandType.CANCEL), LevelBoundVec3(sender.getDimension(), sender.pos), - ::asyncCommandCallback + AsyncCommandEventFactory.addListener(AsyncCommandEvent.REQUEST_AFTER_DELAY) { + if (AsyncCommandHelper.cancelRequest(sender, receiver) == AsyncCommandEvent.REQUEST_NOT_FOUND) { + CommandHelper.requestNotFound(sender, receiver) + } + } ) ) return CommandResult.NORMAL.status } private fun cancelRequest(context: Context): Int { - fun asyncCommandCallback(result: AsyncCommandEvent, asyncCommandData: AsyncCommandData) { - val asyncRequest = asyncCommandData.getRequest() - if (result == AsyncCommandEvent.REQUEST_AFTER_DELAY) { - val sender = asyncRequest.sender - if (AsyncCommandHelper.cancelRequest(sender) == AsyncCommandEvent.REQUEST_NOT_FOUND) { - CommandHelper.requestNotFound(sender) - } - } - } - val source = context.source val sender = source.player sender ?: return CommandResult.SENDER_NOT_EXIST.status @@ -82,7 +65,11 @@ object CancelCommand : AsyncCommand(), BuildableCommand { AsyncCommandData( AsyncRequest(sender, null, AsyncCommandType.CANCEL), LevelBoundVec3(sender.getDimension(), sender.pos), - ::asyncCommandCallback + AsyncCommandEventFactory.addListener(AsyncCommandEvent.REQUEST_AFTER_DELAY) { + if (AsyncCommandHelper.cancelRequest(sender) == AsyncCommandEvent.REQUEST_NOT_FOUND) { + CommandHelper.requestNotFound(sender) + } + } ) ) return CommandResult.NORMAL.status diff --git a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/DenyCommand.kt b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/DenyCommand.kt index f98059f..a8bfa09 100644 --- a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/DenyCommand.kt +++ b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/DenyCommand.kt @@ -38,17 +38,6 @@ object DenyCommand : AsyncCommand(), BuildableCommand { override fun getMinDistance(): Double = Config.getConfig()[CommandDistanceSpec.denyDistance] private fun refuseRequestWithTarget(context: Context): Int { - fun asyncCommandCallback(result: AsyncCommandEvent, asyncCommandData: AsyncCommandData) { - val asyncRequest = asyncCommandData.getRequest() - if (result == AsyncCommandEvent.REQUEST_AFTER_DELAY) { - val sender = asyncRequest.sender - val receiver = asyncRequest.receiver!! - if (AsyncCommandHelper.refuseRequest(sender, receiver) == AsyncCommandEvent.REQUEST_NOT_FOUND) { - CommandHelper.requestNotFound(sender, receiver) - } - } - } - val source = context.source val (result, sender, receiver) = checkSenderReceiver(context) if (result != CommandResult.NORMAL) return result.status @@ -58,23 +47,17 @@ object DenyCommand : AsyncCommand(), BuildableCommand { AsyncCommandData( AsyncRequest(sender, receiver, AsyncCommandType.DENY), LevelBoundVec3(sender.getDimension(), sender.pos), - ::asyncCommandCallback + AsyncCommandEventFactory.addListener(AsyncCommandEvent.REQUEST_AFTER_DELAY) { + if (AsyncCommandHelper.refuseRequest(sender, receiver) == AsyncCommandEvent.REQUEST_NOT_FOUND) { + CommandHelper.requestNotFound(sender, receiver) + } + } ) ) return CommandResult.NORMAL.status } private fun refuseRequest(context: Context): Int { - fun asyncCommandCallback(result: AsyncCommandEvent, asyncCommandData: AsyncCommandData) { - val asyncRequest = asyncCommandData.getRequest() - if (result == AsyncCommandEvent.REQUEST_AFTER_DELAY) { - val sender = asyncRequest.sender - if (AsyncCommandHelper.refuseRequest(sender) == AsyncCommandEvent.REQUEST_NOT_FOUND) { - CommandHelper.requestNotFound(sender) - } - } - } - val source = context.source val sender = source.player sender ?: return CommandResult.SENDER_NOT_EXIST.status @@ -82,7 +65,11 @@ object DenyCommand : AsyncCommand(), BuildableCommand { AsyncCommandData( AsyncRequest(sender, null, AsyncCommandType.DENY), LevelBoundVec3(sender.getDimension(), sender.pos), - ::asyncCommandCallback + AsyncCommandEventFactory.addListener(AsyncCommandEvent.REQUEST_AFTER_DELAY) { + if (AsyncCommandHelper.refuseRequest(sender) == AsyncCommandEvent.REQUEST_NOT_FOUND) { + CommandHelper.requestNotFound(sender) + } + } ) ) return CommandResult.NORMAL.status diff --git a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaCommand.kt b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaCommand.kt index 06805e8..99e8b4e 100644 --- a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaCommand.kt +++ b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaCommand.kt @@ -35,91 +35,55 @@ object TpaCommand : AsyncCommand(), BuildableCommand { override fun getMinDistance(): Double = Config.getConfig()[CommandDistanceSpec.tpaDistance] - @Suppress("LongMethod") - private fun asyncCommandCallback(event: AsyncCommandEvent, asyncCommandData: AsyncCommandData) { - val asyncRequest = asyncCommandData.getRequest() - require(asyncRequest.receiver != null) { "Receiver cannot be null" } - when (event) { - AsyncCommandEvent.REQUEST_AFTER_DELAY -> { - asyncRequest.sender.sendMessageWithPlayerName("command.tpa.request.sender", asyncRequest.receiver) - asyncRequest.receiver.sendMessageWithPlayerName("command.tpa.request.receiver", asyncRequest.sender) - AsyncCommandHelper.addCooldown(asyncRequest.sender.uuid, AsyncCommandType.TPA) - } - - AsyncCommandEvent.REQUEST_TIMEOUT -> { - asyncRequest.sender.sendMessageWithPlayerName("command.tpa.timeout.sender", asyncRequest.receiver) - asyncRequest.receiver.sendMessageWithPlayerName("command.tpa.timeout.receiver", asyncRequest.sender) - } - - AsyncCommandEvent.REQUEST_ACCEPTED -> { - require(asyncRequest.canBeTeleported()) { "Request can't be teleported!" } - asyncRequest.sender.sendMessageWithPlayerName( - "command.tpa.request.accept.sender", - asyncRequest.receiver - ) - asyncRequest.receiver.sendMessageWithPlayerName( - "command.tpa.request.accept.receiver", - asyncRequest.sender - ) - AsyncCommandHelper.teleport(asyncCommandData) - } - - AsyncCommandEvent.REQUEST_CANCELED -> { - asyncRequest.sender.sendMessageWithPlayerName( - "command.tpa.request.cancel.sender", - asyncRequest.receiver - ) - asyncRequest.receiver.sendMessageWithPlayerName( - "command.tpa.request.cancel.receiver", - asyncRequest.sender - ) - } - - AsyncCommandEvent.REQUEST_REFUSED -> { - asyncRequest.sender.sendMessageWithPlayerName( - "command.tpa.request.refuse.sender", - asyncRequest.receiver - ) - asyncRequest.receiver.sendMessageWithPlayerName( - "command.tpa.request.refuse.receiver", - asyncRequest.sender - ) - } - - AsyncCommandEvent.TELEPORT_OUT_DISTANCE -> { - asyncRequest.from?.sendMessage( - Text.translatable("command.teleport.out_distance").setStyle(TextColorPallet.error) - ) - } - - AsyncCommandEvent.TELEPORT_UPDATE_MESSAGE -> { - asyncRequest.from?.sendTeleportTime(asyncRequest.delay) - } - - else -> {} - } - } - private fun tpaRequest(context: Context): Int { - val (result, sender, target) = checkSenderReceiver(context) + val (result, sender, receiver) = checkSenderReceiver(context) if (result != CommandResult.NORMAL) return result.status sender!! - target!! - if (CommandHelper.checkToggled(sender, target) || - CommandHelper.checkBlocked(sender, target) || - CommandHelper.checkRequestExist(sender, target, AsyncCommandType.TPA) + receiver!! + if (CommandHelper.checkToggled(sender, receiver) || + CommandHelper.checkBlocked(sender, receiver) || + CommandHelper.checkRequestExist(sender, receiver, AsyncCommandType.TPA) ) { return CommandResult.NORMAL.status } - LimitationHelper.checkLimitation(sender, target)?.let { + LimitationHelper.checkLimitation(sender, receiver)?.let { sender.sendMessage(it) return CommandResult.NORMAL.status } AsyncCommandHelper.schedule( AsyncCommandData( - AsyncRequest(sender, target, AsyncCommandType.TPA, sender, target), + AsyncRequest(sender, receiver, AsyncCommandType.TPA, sender, receiver), LevelBoundVec3(sender.getDimension(), sender.pos), - ::asyncCommandCallback + AsyncCommandEventFactory + .addListener(AsyncCommandEvent.REQUEST_AFTER_DELAY) { + sender.sendMessageWithPlayerName("command.tpa.request.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpa.request.receiver", sender) + } + .addListener(AsyncCommandEvent.REQUEST_TIMEOUT) { + sender.sendMessageWithPlayerName("command.tpa.timeout.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpa.timeout.receiver", sender) + } + .addListener(AsyncCommandEvent.REQUEST_ACCEPTED) { + sender.sendMessageWithPlayerName("command.tpa.request.accept.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpa.request.accept.receiver", sender) + AsyncCommandHelper.teleport(it) + } + .addListener(AsyncCommandEvent.REQUEST_CANCELED) { + sender.sendMessageWithPlayerName("command.tpa.request.cancel.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpa.request.cancel.receiver", sender) + } + .addListener(AsyncCommandEvent.REQUEST_REFUSED) { + sender.sendMessageWithPlayerName("command.tpa.request.refuse.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpa.request.refuse.receiver", sender) + } + .addListener(AsyncCommandEvent.TELEPORT_OUT_DISTANCE) { + sender.sendMessage( + Text.translatable("command.teleport.out_distance").setStyle(TextColorPallet.error) + ) + } + .addListener(AsyncCommandEvent.TELEPORT_UPDATE_MESSAGE) { + sender.sendTeleportTime(it.getRequest().delay) + } ) ) return CommandResult.NORMAL.status diff --git a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaHereCommand.kt b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaHereCommand.kt index 198e98e..f826e68 100644 --- a/src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaHereCommand.kt +++ b/src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaHereCommand.kt @@ -29,89 +29,54 @@ object TpaHereCommand : AsyncCommand(), BuildableCommand { override fun getMinDistance(): Double = Config.getConfig()[CommandDistanceSpec.tpahereDistance] - private fun asyncCommandCallback(event: AsyncCommandEvent, asyncCommandData: AsyncCommandData) { - val asyncRequest = asyncCommandData.getRequest() - asyncRequest.receiver!! - when (event) { - AsyncCommandEvent.REQUEST_AFTER_DELAY -> { - asyncRequest.sender.sendMessageWithPlayerName("command.tpahere.request.sender", asyncRequest.receiver) - asyncRequest.receiver.sendMessageWithPlayerName("command.tpahere.request.receiver", asyncRequest.sender) - } - - AsyncCommandEvent.REQUEST_TIMEOUT -> { - asyncRequest.sender.sendMessageWithPlayerName("command.tpahere.timeout.sender", asyncRequest.receiver) - asyncRequest.receiver.sendMessageWithPlayerName("command.tpahere.timeout.receiver", asyncRequest.sender) - } - - AsyncCommandEvent.REQUEST_ACCEPTED -> { - require(asyncRequest.canBeTeleported()) { "Request can't be teleported!" } - asyncRequest.sender.sendMessageWithPlayerName( - "command.tpahere.request.accept.sender", - asyncRequest.receiver - ) - asyncRequest.receiver.sendMessageWithPlayerName( - "command.tpahere.request.accept.receiver", - asyncRequest.sender - ) - AsyncCommandHelper.teleport(asyncCommandData) - } - - AsyncCommandEvent.REQUEST_CANCELED -> { - asyncRequest.sender.sendMessageWithPlayerName( - "command.tpahere.request.cancel.sender", - asyncRequest.receiver - ) - asyncRequest.receiver.sendMessageWithPlayerName( - "command.tpahere.request.cancel.receiver", - asyncRequest.sender - ) - } - - AsyncCommandEvent.REQUEST_REFUSED -> { - asyncRequest.sender.sendMessageWithPlayerName( - "command.tpahere.request.refuse.sender", - asyncRequest.receiver - ) - asyncRequest.receiver.sendMessageWithPlayerName( - "command.tpahere.request.refuse.receiver", - asyncRequest.sender - ) - } - - AsyncCommandEvent.TELEPORT_OUT_DISTANCE -> { - asyncRequest.from?.sendMessage( - Text.translatable("command.teleport.out_distance").setStyle(TextColorPallet.error) - ) - } - - AsyncCommandEvent.TELEPORT_UPDATE_MESSAGE -> { - asyncRequest.from?.sendTeleportTime(asyncRequest.delay) - } - - else -> {} - } - } - private fun tpaHereRequest(context: Context): Int { - val (result, sender, target) = checkSenderReceiver(context) + val (result, sender, receiver) = checkSenderReceiver(context) if (result != CommandResult.NORMAL) return result.status sender!! - target!! - if (CommandHelper.checkToggled(sender, target) || - CommandHelper.checkBlocked(sender, target) || - CommandHelper.checkRequestExist(sender, target, AsyncCommandType.TPAHERE) + receiver!! + if (CommandHelper.checkToggled(sender, receiver) || + CommandHelper.checkBlocked(sender, receiver) || + CommandHelper.checkRequestExist(sender, receiver, AsyncCommandType.TPAHERE) ) { return CommandResult.NORMAL.status } - LimitationHelper.checkLimitation(sender, target)?.let { + LimitationHelper.checkLimitation(sender, receiver)?.let { sender.sendMessage(it) return CommandResult.NORMAL.status } AsyncCommandHelper.schedule( AsyncCommandData( - AsyncRequest(sender, target, AsyncCommandType.TPAHERE, target, sender), + AsyncRequest(sender, receiver, AsyncCommandType.TPAHERE, receiver, sender), LevelBoundVec3(sender.getDimension(), sender.pos), - ::asyncCommandCallback + AsyncCommandEventFactory + .addListener(AsyncCommandEvent.REQUEST_AFTER_DELAY) { + sender.sendMessageWithPlayerName("command.tpahere.request.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpahere.request.receiver", sender) + } + .addListener(AsyncCommandEvent.REQUEST_TIMEOUT) { + sender.sendMessageWithPlayerName("command.tpahere.timeout.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpahere.timeout.receiver", sender) + } + .addListener(AsyncCommandEvent.REQUEST_ACCEPTED) { + sender.sendMessageWithPlayerName("command.tpahere.request.accept.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpahere.request.accept.receiver", sender) + AsyncCommandHelper.teleport(it) + }.addListener(AsyncCommandEvent.REQUEST_CANCELED) { + sender.sendMessageWithPlayerName("command.tpahere.request.cancel.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpahere.request.cancel.receiver", sender) + } + .addListener(AsyncCommandEvent.REQUEST_REFUSED) { + sender.sendMessageWithPlayerName("command.tpahere.request.refuse.sender", receiver) + receiver.sendMessageWithPlayerName("command.tpahere.request.refuse.receiver", sender) + } + .addListener(AsyncCommandEvent.TELEPORT_OUT_DISTANCE) { + receiver.sendMessage( + Text.translatable("command.teleport.out_distance").setStyle(TextColorPallet.error) + ) + } + .addListener(AsyncCommandEvent.TELEPORT_UPDATE_MESSAGE) { + receiver.sendTeleportTime(it.getRequest().delay) + } ) ) return CommandResult.NORMAL.status