1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
From 47467b9ed89eb4761a409425af0d77d513e98c60 Mon Sep 17 00:00:00 2001
From: DemonWav <demonwav@gmail.com>
Date: Thu, 3 Mar 2016 01:44:39 -0600
Subject: [PATCH] Add Location support to tab completers (vanilla feature
missing in CraftBukkit)
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index b302cb7..75e7b78 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -249,4 +249,9 @@ public class PaperWorldConfig {
private void allChunksAreSlimeChunks() {
allChunksAreSlimeChunks = getBoolean("all-chunks-are-slime-chunks", false);
}
+
+ public boolean allowBlockLocationTabCompletion;
+ private void allowBlockLocationTabCompletion() {
+ allowBlockLocationTabCompletion = getBoolean("allow-block-location-tab-completion", true);
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index bbdb19a..3d2e0b6 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1156,7 +1156,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
return arraylist;
}
*/
- return server.tabComplete(icommandlistener, s); // PAIL : todo args
+ return server.tabComplete(icommandlistener, s, blockposition); // PAIL : todo args // Paper - add Location arg
// CraftBukkit end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2b49d69..bc48cf6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -25,17 +25,11 @@ import javax.imageio.ImageIO;
import net.minecraft.server.*;
-import org.bukkit.BanList;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.GameMode;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.Server;
-import org.bukkit.UnsafeValues;
+import net.minecraft.server.WorldType;
+import org.bukkit.*;
import org.bukkit.Warning.WarningState;
import org.bukkit.World;
import org.bukkit.World.Environment;
-import org.bukkit.WorldCreator;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
@@ -1607,6 +1601,14 @@ public final class CraftServer implements Server {
}
public List<String> tabComplete(net.minecraft.server.ICommandListener sender, String message) {
+ return tabComplete(sender, message, null); // Paper - location tab-completes. Original code here moved below
+ }
+
+ // Paper start - add BlockPosition support
+ /*
+ this code is copied, except for the noted change, from the original tabComplete(net.minecraft.server.ICommandListener sender, String message) method
+ */
+ public List<String> tabComplete(net.minecraft.server.ICommandListener sender, String message, BlockPosition blockPosition) {
if (!(sender instanceof EntityPlayer)) {
return ImmutableList.of();
}
@@ -1614,7 +1616,7 @@ public final class CraftServer implements Server {
List<String> offers;
Player player = ((EntityPlayer) sender).getBukkitEntity();
if (message.startsWith("/")) {
- offers = tabCompleteCommand(player, message);
+ offers = tabCompleteCommand(player, message, blockPosition);
} else {
offers = tabCompleteChat(player, message);
}
@@ -1623,11 +1625,20 @@ public final class CraftServer implements Server {
getPluginManager().callEvent(tabEvent);
return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions();
+ // Paper end
}
public List<String> tabCompleteCommand(Player player, String message) {
+ return tabCompleteCommand(player, message, null); // Paper - location tab-completes. Original code here moved below
+ }
+
+ // Paper start - add BlockPosition support
+ /*
+ this code is copied, except for the noted change, from the original tabComplete(net.minecraft.server.ICommandListener sender, String message) method
+ */
+ public List<String> tabCompleteCommand(Player player, String message, BlockPosition blockPosition) {
// Spigot Start
- if ( (org.spigotmc.SpigotConfig.tabComplete < 0 || message.length() <= org.spigotmc.SpigotConfig.tabComplete) && !message.contains( " " ) )
+ if ( (org.spigotmc.SpigotConfig.tabComplete < 0 || message.length() <= org.spigotmc.SpigotConfig.tabComplete) && !message.contains( " " ) )
{
return ImmutableList.of();
}
@@ -1635,7 +1646,14 @@ public final class CraftServer implements Server {
List<String> completions = null;
try {
- completions = getCommandMap().tabComplete(player, message.substring(1));
+ // send location info if presen
+ // completions = getCommandMap().tabComplete(player, message.substring(1));
+ if (blockPosition == null || !((CraftWorld) player.getWorld()).getHandle().paperConfig.allowBlockLocationTabCompletion) {
+ completions = getCommandMap().tabComplete(player, message.substring(1));
+ } else {
+ completions = getCommandMap().tabComplete(player, message.substring(1), new Location(player.getWorld(), blockPosition.getX(), blockPosition.getY(), blockPosition.getZ()));
+ }
+ // Paper end
} catch (CommandException ex) {
player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
index 100d84a..a40218c 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
@@ -7,6 +7,7 @@ import net.minecraft.server.*;
import org.apache.commons.lang.Validate;
import org.apache.logging.log4j.Level;
+import org.bukkit.Location;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@@ -46,10 +47,23 @@ public final class VanillaCommandWrapper extends VanillaCommand {
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
+ return tabComplete(sender, alias, args, null); // Paper - location tab-completes. Original code moved below
+ }
+
+ // Paper start - location tab-completes
+ /*
+ this code is copied, except for the noted change, from the original tabComplete(CommandSender sender, String alias, String[] args) method
+ */
+ @Override
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
- return (List<String>) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, new BlockPosition(0, 0, 0));
+ if (location == null) { // PaperSpigot use location information if available
+ return (List<String>) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, new BlockPosition(0, 0, 0));
+ } else {
+ return (List<String>) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
+ }
}
public static CommandSender lastSender = null; // Nasty :(
--
2.8.2
|