diff options
author | DemonWav <[email protected]> | 2016-02-15 19:52:09 -0600 |
---|---|---|
committer | Zach Brown <[email protected]> | 2016-02-15 19:52:53 -0600 |
commit | 9c166f741dc7044e5e3097ba34acbf7b56c93078 (patch) | |
tree | fa4c999a93b6fcc9c8eafb9fc64a4867f67e5204 /Spigot-API-Patches/0015-Add-Location-support-to-tab-completers-vanilla-featu.patch | |
parent | 7bea05be5113fea600b253202208d82168adfbbb (diff) | |
download | Paper-9c166f741dc7044e5e3097ba34acbf7b56c93078.tar.gz Paper-9c166f741dc7044e5e3097ba34acbf7b56c93078.zip |
Fix tab completeion ignoring the old non-location tab complete
Closes GH-28
Diffstat (limited to 'Spigot-API-Patches/0015-Add-Location-support-to-tab-completers-vanilla-featu.patch')
-rw-r--r-- | Spigot-API-Patches/0015-Add-Location-support-to-tab-completers-vanilla-featu.patch | 64 |
1 files changed, 23 insertions, 41 deletions
diff --git a/Spigot-API-Patches/0015-Add-Location-support-to-tab-completers-vanilla-featu.patch b/Spigot-API-Patches/0015-Add-Location-support-to-tab-completers-vanilla-featu.patch index 5e6787ffe9..18cdb659eb 100644 --- a/Spigot-API-Patches/0015-Add-Location-support-to-tab-completers-vanilla-featu.patch +++ b/Spigot-API-Patches/0015-Add-Location-support-to-tab-completers-vanilla-featu.patch @@ -1,4 +1,4 @@ -From 2e148b75463f007fbfd5c9d19bb2c0dbf5658aa3 Mon Sep 17 00:00:00 2001 +From 5866613ee6d1fdcdf75c97983d6f28e6cf1e2342 Mon Sep 17 00:00:00 2001 From: DemonWav <[email protected]> Date: Sat, 30 Jan 2016 18:58:09 -0600 Subject: [PATCH] Add Location support to tab completers (vanilla feature @@ -6,7 +6,7 @@ Subject: [PATCH] Add Location support to tab completers (vanilla feature diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java -index 548d570..c5b2e34 100644 +index 548d570..3d0c5a5 100644 --- a/src/main/java/org/bukkit/command/Command.java +++ b/src/main/java/org/bukkit/command/Command.java @@ -8,6 +8,7 @@ import java.util.Set; @@ -17,22 +17,10 @@ index 548d570..c5b2e34 100644 import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.entity.minecart.CommandMinecart; -@@ -85,6 +86,42 @@ 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); -+ } -+ +@@ -109,6 +110,31 @@ public abstract class Command { + 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 548d570..c5b2e34 100644 + */ + 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"); -@@ -108,6 +145,7 @@ 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 3bfa31f..e3f8295 100644 +index 3bfa31f..597d7c2 100644 --- a/src/main/java/org/bukkit/command/PluginCommand.java +++ b/src/main/java/org/bukkit/command/PluginCommand.java -@@ -3,6 +3,7 @@ package org.bukkit.command; - import java.util.List; +@@ -1,10 +1,11 @@ + 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 + */ @@ -122,6 +123,15 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo */ @Override @@ -88,8 +75,8 @@ index 3bfa31f..e3f8295 100644 + } + + // 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 { @@ -109,12 +96,7 @@ index 3bfa31f..e3f8295 100644 } } catch (Throwable ex) { StringBuilder message = new StringBuilder(); -@@ -145,10 +155,11 @@ 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 +@@ -149,6 +159,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo } return completions; } @@ -189,5 +171,5 @@ index 6d61e3a..2cb971c 100644 + // PaperSpigot end } -- -2.7.0 +2.7.1 |