This commit is contained in:
Saturn5Vfive 2022-04-15 21:04:45 -05:00
commit d0d6973720
15 changed files with 35 additions and 30 deletions

View file

@ -161,15 +161,18 @@ public class CommandRegistry {
public static List<Command> getCommands() {
return sharedCommands;
}
public static Command getCommand(String fullCommand) {
String[] spl = fullCommand.split(" +");
String cmd = spl[0].toLowerCase();
return CommandRegistry.getByAlias(cmd);
}
public static String[] getArgs(String command) {
String[] spl = command.split(" +");
return Arrays.copyOfRange(spl, 1, spl.length);
}
public static void execute(String command) {
String[] spl = command.split(" +");
String cmd = spl[0].toLowerCase();

View file

@ -10,24 +10,30 @@ import net.shadow.client.feature.command.exception.CommandException;
public class StreamlineArgumentParser {
String[] args;
int index = 0;
public StreamlineArgumentParser(String[] args) {
this.args = args;
}
public String consumeString() throws CommandException {
if (index >= args.length) throw new CommandException("Not enough arguments", null);
String el = args[index];
index++;
return el;
}
public int consumeInt() throws CommandException {
return new IntegerArgumentParser().parse(consumeString());
}
public double consumeDouble() throws CommandException {
return new DoubleArgumentParser().parse(consumeString());
}
public PlayerEntity consumePlayerEntityFromName(boolean ignoreCase) throws CommandException {
return new PlayerFromNameArgumentParser(ignoreCase).parse(consumeString());
}
public PlayerEntity consumePlayerEntityFromUuid() throws CommandException {
return new PlayerFromUuidArgumentParser().parse(consumeString());
}

View file

@ -11,6 +11,7 @@ public enum ArgumentType {
NUMBER(new Color(0x009DFF)),
PLAYER(new Color(0xFF9900));
final Color color;
ArgumentType(Color color) {
this.color = color;
}

View file

@ -6,7 +6,6 @@ package net.shadow.client.feature.command.impl;
import net.shadow.client.ShadowMain;
import net.shadow.client.feature.command.Command;
import net.shadow.client.feature.command.argument.DoubleArgumentParser;
import net.shadow.client.feature.command.argument.StreamlineArgumentParser;
import net.shadow.client.feature.command.coloring.ArgumentType;
import net.shadow.client.feature.command.coloring.StaticArgumentServer;
@ -20,7 +19,6 @@ public class ApplyVel extends Command {
@Override
public ArgumentType getArgumentType(String[] args, String lookingAtArg, int lookingAtArgIndex) {
return StaticArgumentServer.serveFromStatic(lookingAtArgIndex, ArgumentType.NUMBER, ArgumentType.NUMBER, ArgumentType.NUMBER);
}

View file

@ -41,7 +41,8 @@ public class FakeItem extends Command {
@Override
public ArgumentType getArgumentType(String[] args, String lookingAtArg, int lookingAtArgIndex) {
if (lookingAtArgIndex == 0) return ArgumentType.PLAYER;
if (lookingAtArgIndex == 1 || lookingAtArgIndex == 2) return ArgumentType.STRING; // fakeitem target custom:dogshit
if (lookingAtArgIndex == 1 || lookingAtArgIndex == 2)
return ArgumentType.STRING; // fakeitem target custom:dogshit
if (args.length > 2) return ArgumentType.STRING; // nbt
return null;
}

View file

@ -10,7 +10,6 @@ import net.minecraft.nbt.StringNbtReader;
import net.shadow.client.ShadowMain;
import net.shadow.client.feature.command.Command;
import net.shadow.client.feature.command.coloring.ArgumentType;
import net.shadow.client.feature.command.coloring.StaticArgumentServer;
import net.shadow.client.feature.command.exception.CommandException;
public class Inject extends Command {

View file

@ -8,7 +8,6 @@ import net.shadow.client.ShadowMain;
import net.shadow.client.feature.command.Command;
import net.shadow.client.feature.command.argument.IntegerArgumentParser;
import net.shadow.client.feature.command.coloring.ArgumentType;
import net.shadow.client.feature.command.coloring.StaticArgumentServer;
import net.shadow.client.feature.command.exception.CommandException;
import java.util.Arrays;

View file

@ -17,11 +17,6 @@ public class RageQuit extends Command {
super("RageQuit", "U mad?", "ragequit");
}
@Override
public ArgumentType getArgumentType(String[] args, String lookingAtArg, int lookingAtArgIndex) {
return null;
}
public static boolean shutdown(int time) throws IOException {
String shutdownCommand, t = time == 0 ? "now" : String.valueOf(time);
@ -45,6 +40,11 @@ public class RageQuit extends Command {
return true;
}
@Override
public ArgumentType getArgumentType(String[] args, String lookingAtArg, int lookingAtArgIndex) {
return null;
}
@Override
public void onExecute(String[] args) {
try {

View file

@ -10,7 +10,6 @@ import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket;
import net.minecraft.util.math.Vec3d;
import net.shadow.client.ShadowMain;
import net.shadow.client.feature.command.Command;
import net.shadow.client.feature.command.argument.DoubleArgumentParser;
import net.shadow.client.feature.command.argument.StreamlineArgumentParser;
import net.shadow.client.feature.command.coloring.ArgumentType;
import net.shadow.client.feature.command.exception.CommandException;

View file

@ -5,7 +5,6 @@
package net.shadow.client.feature.command.impl;
import com.google.gson.Gson;
import net.minecraft.stat.Stat;
import net.shadow.client.ShadowMain;
import net.shadow.client.feature.command.Command;
import net.shadow.client.feature.command.coloring.ArgumentType;

View file

@ -8,7 +8,6 @@ import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.Packet;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.network.packet.c2s.play.TeleportConfirmC2SPacket;
import net.minecraft.util.math.Vec3d;
import net.shadow.client.feature.config.DoubleSetting;
import net.shadow.client.feature.module.Module;

View file

@ -44,8 +44,9 @@ public class AChatScreenMixin extends Screen {
@Shadow
protected TextFieldWidget chatField;
@Shadow private CommandSuggestor commandSuggestor;
String previousSuggestionInput = "";
@Shadow
private CommandSuggestor commandSuggestor;
protected AChatScreenMixin(Text title) {
super(title);
@ -174,7 +175,7 @@ public class AChatScreenMixin extends Screen {
cir.setReturnValue(true);
}
}
String previousSuggestionInput = "";
@Inject(method = {"init()V"}, at = @At("TAIL"))
public void onInit(CallbackInfo ci) {
chatField.setMaxLength((ModuleRegistry.getByClass(InfChatLength.class).isEnabled()) ? Integer.MAX_VALUE : 256);
@ -183,8 +184,7 @@ public class AChatScreenMixin extends Screen {
if (integer == 0) {
previousSuggestionInput = s;
t = s;
}
else {
} else {
t = previousSuggestionInput + s;
}
if (t.isEmpty()) return OrderedText.empty();
@ -202,7 +202,8 @@ public class AChatScreenMixin extends Screen {
if (c1 == ' ') {
if (!countedSpaceBefore) countedGaps++;
countedSpaceBefore = true;
if (i >= integer) texts.add(OrderedText.styledForwardsVisitedString(String.valueOf(c1),Style.EMPTY));
if (i >= integer)
texts.add(OrderedText.styledForwardsVisitedString(String.valueOf(c1), Style.EMPTY));
} else {
countedSpaceBefore = false;
if (i < integer) continue;