From 1c9345ada5967d09b201920832e4af88cbe31e86 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Fri, 8 Feb 2019 18:18:25 -0200 Subject: [PATCH] fix message sending --- .../viafabric/VRViaVersionInitializer.java | 13 ------------- .../viafabric/commands/NMSCommandSender.java | 4 +++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/github/creeper123123321/viafabric/VRViaVersionInitializer.java b/src/main/java/com/github/creeper123123321/viafabric/VRViaVersionInitializer.java index b4a2c40..9d960ec 100644 --- a/src/main/java/com/github/creeper123123321/viafabric/VRViaVersionInitializer.java +++ b/src/main/java/com/github/creeper123123321/viafabric/VRViaVersionInitializer.java @@ -74,19 +74,6 @@ public class VRViaVersionInitializer { ); return 1; }) - .suggests((ctx, builder) -> { - String args = StringArgumentType.getString(ctx, "args"); - Via.getManager() - .getCommandHandler() - .onTabComplete( - new NMSCommandSender( - ctx.getSource() - ), - args.split(" ", -1) - ) - .forEach(builder::suggest); - return builder.buildFuture(); - }) ) ) ); diff --git a/src/main/java/com/github/creeper123123321/viafabric/commands/NMSCommandSender.java b/src/main/java/com/github/creeper123123321/viafabric/commands/NMSCommandSender.java index d9c3d4f..6bb4da7 100644 --- a/src/main/java/com/github/creeper123123321/viafabric/commands/NMSCommandSender.java +++ b/src/main/java/com/github/creeper123123321/viafabric/commands/NMSCommandSender.java @@ -28,7 +28,6 @@ import net.fabricmc.api.EnvType; import net.fabricmc.loader.FabricLoader; import net.minecraft.client.network.ClientCommandSource; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.CommandSource; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.TextComponent; @@ -54,6 +53,9 @@ public class NMSCommandSender implements ViaCommandSender { public void sendMessage(String s) { if (source instanceof ServerCommandSource) { ((ServerCommandSource) source).sendFeedback(TextComponent.Serializer.fromJsonString(ChatRewriter.legacyTextToJson(s)), false); + } else if (FabricLoader.INSTANCE.getEnvironmentType() == EnvType.CLIENT && source instanceof ClientCommandSource) { + FabricLoader.INSTANCE.getEnvironmentHandler().getClientPlayer() + .appendCommandFeedback(TextComponent.Serializer.fromJsonString(ChatRewriter.legacyTextToJson(s))); } }