mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-21 07:13:49 -07:00
Fix tab completeion ignoring the old non-location tab complete
Closes GH-28
This commit is contained in:
@@ -18,21 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.minecart.CommandMinecart;
|
import org.bukkit.entity.minecart.CommandMinecart;
|
||||||
@@ -0,0 +0,0 @@ public abstract class Command {
|
@@ -0,0 +0,0 @@ public abstract class Command {
|
||||||
* @throws IllegalArgumentException if sender, alias, or args is null
|
return matchedPlayers;
|
||||||
*/
|
}
|
||||||
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);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // PaperSpigot start - location tab-completes
|
+ // PaperSpigot start - location tab-completes
|
||||||
+ /**
|
+ /**
|
||||||
+ * Executed on tab completion for this command, returning a list of options the player can tab through. This method
|
+ * 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 {
|
+ 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
|
+ // 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
|
+ // PaperSpigot end
|
||||||
|
+
|
||||||
/**
|
/**
|
||||||
* Returns the name of this command
|
* 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
|
diff --git a/src/main/java/org/bukkit/command/PluginCommand.java b/src/main/java/org/bukkit/command/PluginCommand.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/command/PluginCommand.java
|
--- a/src/main/java/org/bukkit/command/PluginCommand.java
|
||||||
+++ b/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;
|
@@ -0,0 +0,0 @@
|
||||||
import java.util.List;
|
package org.bukkit.command;
|
||||||
|
|
||||||
|
-import java.util.List;
|
||||||
|
-
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
+import org.bukkit.Location;
|
+import org.bukkit.Location;
|
||||||
import org.bukkit.plugin.Plugin;
|
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
|
@@ -0,0 +0,0 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -88,8 +75,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ // PaperSpigot start - location tab-completes
|
+ // 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
|
+ @Override
|
||||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws CommandException, IllegalArgumentException {
|
+ 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();
|
StringBuilder message = new StringBuilder();
|
||||||
@@ -0,0 +0,0 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
|
@@ -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;
|
return completions;
|
||||||
}
|
}
|
||||||
+ // PaperSpigot end
|
+ // PaperSpigot end
|
||||||
|
Reference in New Issue
Block a user