mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 17:37:45 +01:00
SPIGOT-4026: Clicking on command error suggestion should return verbatim input
This commit is contained in:
parent
fa1340f7a6
commit
b4bff6fc3d
@ -33,7 +33,7 @@
|
||||
this.b.setConsumer((commandcontext, flag, i) -> {
|
||||
((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i);
|
||||
});
|
||||
@@ -114,7 +126,58 @@
|
||||
@@ -114,8 +126,63 @@
|
||||
|
||||
}
|
||||
|
||||
@ -73,6 +73,11 @@
|
||||
+ }
|
||||
+
|
||||
public int a(CommandListenerWrapper commandlistenerwrapper, String s) {
|
||||
- String s1 = s;
|
||||
+ return this.a(commandlistenerwrapper, s, s);
|
||||
+ }
|
||||
+
|
||||
+ public int a(CommandListenerWrapper commandlistenerwrapper, String s, String label) {
|
||||
+ // Some commands use the worldserver variable but we leave it full of null values,
|
||||
+ // so we must temporarily populate it with the world of the commandsender
|
||||
+ WorldServer[] prev = MinecraftServer.getServer().worldServer;
|
||||
@ -88,11 +93,12 @@
|
||||
+ }
|
||||
+ server.worldServer[pos] = world;
|
||||
+ }
|
||||
+ String s1 = label;
|
||||
+ // CraftBukkit end
|
||||
String s1 = s;
|
||||
|
||||
if (s.startsWith("/")) {
|
||||
@@ -126,7 +189,6 @@
|
||||
s = s.substring(1);
|
||||
@@ -126,7 +193,6 @@
|
||||
byte b0;
|
||||
|
||||
try {
|
||||
@ -100,7 +106,7 @@
|
||||
ChatComponentText chatcomponenttext;
|
||||
|
||||
try {
|
||||
@@ -135,54 +197,59 @@
|
||||
@@ -135,54 +201,59 @@
|
||||
return i;
|
||||
} catch (CommandException commandexception) {
|
||||
commandlistenerwrapper.sendFailureMessage(commandexception.a());
|
||||
@ -152,17 +158,17 @@
|
||||
} catch (Exception exception) {
|
||||
- chatcomponenttext = new ChatComponentText;
|
||||
- }
|
||||
+ ChatMessage chatmessage1 = new ChatMessage("command.failed", new Object[0]);
|
||||
|
||||
-
|
||||
- chatcomponenttext.<init>(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
|
||||
- ChatComponentText chatcomponenttext1 = chatcomponenttext;
|
||||
+ ChatMessage chatmessage1 = new ChatMessage("command.failed", new Object[0]);
|
||||
|
||||
- if (CommandDispatcher.a.isDebugEnabled()) {
|
||||
- StackTraceElement[] astacktraceelement = exception.getStackTrace();
|
||||
+ chatcomponenttext = new ChatComponentText(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
|
||||
+ if (CommandDispatcher.a.isDebugEnabled()) {
|
||||
+ StackTraceElement[] astacktraceelement = exception.getStackTrace();
|
||||
|
||||
- if (CommandDispatcher.a.isDebugEnabled()) {
|
||||
- StackTraceElement[] astacktraceelement = exception.getStackTrace();
|
||||
-
|
||||
- for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) {
|
||||
- chatcomponenttext1.a("\n\n").a(astacktraceelement[k].getMethodName()).a("\n ").a(astacktraceelement[k].getFileName()).a(":").a(String.valueOf(astacktraceelement[k].getLineNumber()));
|
||||
+ for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) {
|
||||
|
@ -43,7 +43,7 @@ public final class VanillaCommandWrapper extends BukkitCommand {
|
||||
if (!testPermission(sender)) return true;
|
||||
|
||||
CommandListenerWrapper icommandlistener = getListener(sender);
|
||||
dispatcher.a(icommandlistener, toDispatcher(args));
|
||||
dispatcher.a(icommandlistener, toDispatcher(args, getName()), toDispatcher(args, commandLabel));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public final class VanillaCommandWrapper extends BukkitCommand {
|
||||
Validate.notNull(alias, "Alias cannot be null");
|
||||
|
||||
CommandListenerWrapper icommandlistener = getListener(sender);
|
||||
ParseResults<CommandListenerWrapper> parsed = dispatcher.a().parse(toDispatcher(args), icommandlistener);
|
||||
ParseResults<CommandListenerWrapper> parsed = dispatcher.a().parse(toDispatcher(args, getName()), icommandlistener);
|
||||
|
||||
List<String> results = new ArrayList<>();
|
||||
dispatcher.a().getCompletionSuggestions(parsed).thenAccept((suggestions) -> {
|
||||
@ -91,7 +91,7 @@ public final class VanillaCommandWrapper extends BukkitCommand {
|
||||
return "minecraft.command." + ((vanillaCommand.getRedirect() == null) ? vanillaCommand.getName() : vanillaCommand.getRedirect().getName());
|
||||
}
|
||||
|
||||
private String toDispatcher(String[] args) {
|
||||
return getName() + ((args.length > 0) ? " " + Joiner.on(' ').join(args) : "");
|
||||
private String toDispatcher(String[] args, String name) {
|
||||
return "/" + name + ((args.length > 0) ? " " + Joiner.on(' ').join(args) : "");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user