1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-08 07:03:47 +01:00

Fix tab completeion ignoring the old non-location tab complete

Closes GH-28
This commit is contained in:
DemonWav 2016-02-15 19:52:09 -06:00
parent b0092d1f74
commit 4e6b15d6bf

View file

@ -18,21 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.entity.Player;
import org.bukkit.entity.minecart.CommandMinecart;
@@ -0,0 +0,0 @@ public abstract class Command {
* @throws IllegalArgumentException if sender, alias, or args is null
*/
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
+ // PaperSpigot - location tab-completes
+ /*
+ To prevent infinite recursion, this implementation has been moved down to
+ tabCompleteImpl(CommandSender sender, String alias, String[] args). The infinite recursion happens when
+ a subclass calls super.tabComplete(CommandSender sender, String alias, String[] args, Location location),
+ which would end up calling tabComplete(CommandSender sender, String alias, String[] args), but rather than
+ this method, it would call the overridden method, which would call super.tabComplete again, etc. To prevent
+ this we move the actual main logic to a separate private method.
+ */
+ return tabCompleteImpl(sender, alias, args);
+ }
+
return matchedPlayers;
}
+ // PaperSpigot start - location tab-completes
+ /**
+ * Executed on tab completion for this command, returning a list of options the player can tab through. This method
@ -53,33 +41,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
+ // Simply default to the standard tab-complete, subclasses can override this if needed
+ return tabCompleteImpl(sender, alias, args);
+ System.out.println("wat");
+ return tabComplete(sender, alias, args);
+ }
+
+ private List<String> tabCompleteImpl(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
@@ -0,0 +0,0 @@ public abstract class Command {
Collections.sort(matchedPlayers, String.CASE_INSENSITIVE_ORDER);
return matchedPlayers;
}
+ // PaperSpigot end
+
/**
* Returns the name of this command
*
diff --git a/src/main/java/org/bukkit/command/PluginCommand.java b/src/main/java/org/bukkit/command/PluginCommand.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/command/PluginCommand.java
+++ b/src/main/java/org/bukkit/command/PluginCommand.java
@@ -0,0 +0,0 @@ package org.bukkit.command;
import java.util.List;
@@ -0,0 +0,0 @@
package org.bukkit.command;
-import java.util.List;
-
import org.apache.commons.lang.Validate;
+import org.bukkit.Location;
import org.bukkit.plugin.Plugin;
+import java.util.List;
+
/**
* Represents a {@link Command} belonging to a plugin
*/
@@ -0,0 +0,0 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
*/
@Override
@ -88,8 +75,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ // PaperSpigot start - location tab-completes
+ /*
+ this code was copied, except for the noted changes, from tabComplete(CommandSender sender, String alias, String[] args)
+ /**
+ * This code was copied from tabComplete(CommandSender sender, String alias, String[] args)
+ */
+ @Override
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws CommandException, IllegalArgumentException {
@ -111,11 +98,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
StringBuilder message = new StringBuilder();
@@ -0,0 +0,0 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
}
if (completions == null) {
- return super.tabComplete(sender, alias, args);
+ return super.tabComplete(sender, alias, args, location); // PaperSpigot - add location argument
}
return completions;
}
+ // PaperSpigot end