From 5ce9677cb424df68e39fd6c93810e0f252ce54fc Mon Sep 17 00:00:00 2001 From: jmp Date: Sun, 18 Oct 2020 14:58:18 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Register=20new=20Velocity=20argumen?= =?UTF-8?q?ts=20with=20the=20parser=20registry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../velocity/VelocityCommandManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cloud-minecraft/cloud-velocity/src/main/java/cloud/commandframework/velocity/VelocityCommandManager.java b/cloud-minecraft/cloud-velocity/src/main/java/cloud/commandframework/velocity/VelocityCommandManager.java index 83292c7b..0ff8ec21 100644 --- a/cloud-minecraft/cloud-velocity/src/main/java/cloud/commandframework/velocity/VelocityCommandManager.java +++ b/cloud-minecraft/cloud-velocity/src/main/java/cloud/commandframework/velocity/VelocityCommandManager.java @@ -29,11 +29,16 @@ import cloud.commandframework.captions.FactoryDelegatingCaptionRegistry; import cloud.commandframework.execution.CommandExecutionCoordinator; import cloud.commandframework.meta.CommandMeta; import cloud.commandframework.meta.SimpleCommandMeta; +import cloud.commandframework.velocity.arguments.PlayerArgument; +import cloud.commandframework.velocity.arguments.ServerArgument; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.Singleton; import com.velocitypowered.api.command.CommandSource; +import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; +import com.velocitypowered.api.proxy.server.RegisteredServer; +import io.leangen.geantyref.TypeToken; import org.checkerframework.checker.nullness.qual.NonNull; import java.util.function.Function; @@ -83,6 +88,13 @@ public class VelocityCommandManager extends CommandManager { this.proxyServer = proxyServer; this.commandSenderMapper = commandSenderMapper; this.backwardsCommandSenderMapper = backwardsCommandSenderMapper; + + /* Register Velocity Parsers */ + this.getParserRegistry().registerParserSupplier(TypeToken.get(Player.class), parserParameters -> + new PlayerArgument.PlayerParser<>(proxyServer)); + this.getParserRegistry().registerParserSupplier(TypeToken.get(RegisteredServer.class), parserParameters -> + new ServerArgument.ServerParser<>(proxyServer)); + /* Register default captions */ if (this.getCaptionRegistry() instanceof FactoryDelegatingCaptionRegistry) { final FactoryDelegatingCaptionRegistry factoryDelegatingCaptionRegistry = (FactoryDelegatingCaptionRegistry)