Merge pull request #3115 from i509VCB/fix/proxiedcommands

[Fabric] Make it so dynmap commands can be proxied via `/execute` without failing to parse.
This commit is contained in:
mikeprimm 2020-09-15 19:25:07 -05:00 committed by GitHub
commit 312f2e3c4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

2
.gitignore vendored
View File

@ -24,11 +24,13 @@
/bin
/dist
/manifest.mf
/run
# Mac filesystem dust
/.DS_Store
/dependency-reduced-pom.xml
*.log
/.gradle
/fabric-1.16.1_client.launch
/fabric-1.16.1_server.launch

View File

@ -45,7 +45,13 @@ public class DynmapCommandExecutor implements Command<ServerCommandSource> {
@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
String[] args = context.getInput().split("\\s+");
// Commands in brigadier may be proxied in Minecraft via a syntax like `/execute ... ... run dmap [args]`
// Dynmap will fail to parse this properly, so we find the starting position of the actual command being parsed after any forks or redirects.
// The start position of the range specifies where the actual command dynmap has registered starts
int start = context.getRange().getStart();
String dynmapInput = context.getInput().substring(start);
String[] args = dynmapInput.split("\\s+");
plugin.handleCommand(context.getSource(), cmd, Arrays.copyOfRange(args, 1, args.length));
return 1;
}

View File

@ -45,7 +45,13 @@ public class DynmapCommandExecutor implements Command<ServerCommandSource> {
@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
String[] args = context.getInput().split("\\s+");
// Commands in brigadier may be proxied in Minecraft via a syntax like `/execute ... ... run dmap [args]`
// Dynmap will fail to parse this properly, so we find the starting position of the actual command being parsed after any forks or redirects.
// The start position of the range specifies where the actual command dynmap has registered starts
int start = context.getRange().getStart();
String dynmapInput = context.getInput().substring(start);
String[] args = dynmapInput.split("\\s+");
plugin.handleCommand(context.getSource(), cmd, Arrays.copyOfRange(args, 1, args.length));
return 1;
}