2016-03-28 01:48:50 +00:00
|
|
|
From fcf90d0153ab06175704b06e7e439750b96d2869 Mon Sep 17 00:00:00 2001
|
2016-01-31 01:20:18 +00:00
|
|
|
From: DemonWav <demonwav@gmail.com>
|
2016-02-29 23:09:49 +00:00
|
|
|
Date: Thu, 3 Mar 2016 01:44:39 -0600
|
2016-01-31 01:20:18 +00:00
|
|
|
Subject: [PATCH] Add Location support to tab completers (vanilla feature
|
|
|
|
missing in CraftBukkit)
|
|
|
|
|
|
|
|
|
2016-02-29 23:09:49 +00:00
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2016-03-25 06:38:38 +00:00
|
|
|
index 1f97e59..ca11cd7 100644
|
2016-02-29 23:09:49 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2016-03-19 02:10:20 +00:00
|
|
|
@@ -262,4 +262,9 @@ public class PaperWorldConfig {
|
2016-02-29 23:09:49 +00:00
|
|
|
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);
|
|
|
|
+ }
|
|
|
|
}
|
2016-01-31 01:20:18 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2016-03-28 01:48:50 +00:00
|
|
|
index 5076aa3..d628a32 100644
|
2016-01-31 01:20:18 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2016-03-25 06:38:38 +00:00
|
|
|
@@ -1186,7 +1186,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
2016-01-31 01:20:18 +00:00
|
|
|
return arraylist;
|
|
|
|
}
|
|
|
|
*/
|
2016-02-29 23:09:49 +00:00
|
|
|
- return server.tabComplete(icommandlistener, s); // PAIL : todo args
|
|
|
|
+ return server.tabComplete(icommandlistener, s, blockposition); // PAIL : todo args // Paper - add Location arg
|
2016-01-31 01:20:18 +00:00
|
|
|
// CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2016-03-28 01:48:50 +00:00
|
|
|
index c6cee80..3a288bd 100644
|
2016-01-31 01:20:18 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2016-02-29 23:09:49 +00:00
|
|
|
@@ -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;
|
2016-03-28 01:48:50 +00:00
|
|
|
@@ -1606,21 +1600,38 @@ public final class CraftServer implements Server {
|
2016-01-31 01:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<String> tabComplete(net.minecraft.server.ICommandListener sender, String message) {
|
2016-02-29 23:09:49 +00:00
|
|
|
+ return tabComplete(sender, message, null); // Paper - location tab-completes. Original code here moved below
|
2016-01-31 01:20:18 +00:00
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // Paper start - add BlockPosition support
|
2016-01-31 01:20:18 +00:00
|
|
|
+ /*
|
2016-02-29 23:09:49 +00:00
|
|
|
+ this code is copied, except for the noted change, from the original tabComplete(net.minecraft.server.ICommandListener sender, String message) method
|
2016-01-31 01:20:18 +00:00
|
|
|
+ */
|
|
|
|
+ public List<String> tabComplete(net.minecraft.server.ICommandListener sender, String message, BlockPosition blockPosition) {
|
|
|
|
if (!(sender instanceof EntityPlayer)) {
|
|
|
|
return ImmutableList.of();
|
|
|
|
}
|
|
|
|
|
|
|
|
Player player = ((EntityPlayer) sender).getBukkitEntity();
|
|
|
|
if (message.startsWith("/")) {
|
|
|
|
- return tabCompleteCommand(player, message);
|
|
|
|
+ return tabCompleteCommand(player, message, blockPosition);
|
|
|
|
} else {
|
|
|
|
return tabCompleteChat(player, message);
|
|
|
|
}
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // Paper end
|
2016-01-31 01:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<String> tabCompleteCommand(Player player, String message) {
|
2016-02-29 23:09:49 +00:00
|
|
|
+ return tabCompleteCommand(player, message, null); // Paper - location tab-completes. Original code here moved below
|
2016-01-31 01:20:18 +00:00
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // Paper start - add BlockPosition support
|
2016-01-31 01:20:18 +00:00
|
|
|
+ /*
|
2016-02-29 23:09:49 +00:00
|
|
|
+ this code is copied, except for the noted change, from the original tabComplete(net.minecraft.server.ICommandListener sender, String message) method
|
2016-01-31 01:20:18 +00:00
|
|
|
+ */
|
|
|
|
+ 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();
|
|
|
|
}
|
2016-03-28 01:48:50 +00:00
|
|
|
@@ -1628,7 +1639,14 @@ public final class CraftServer implements Server {
|
2016-01-31 01:20:18 +00:00
|
|
|
|
|
|
|
List<String> completions = null;
|
|
|
|
try {
|
|
|
|
- completions = getCommandMap().tabComplete(player, message.substring(1));
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // send location info if presen
|
2016-01-31 01:20:18 +00:00
|
|
|
+ // completions = getCommandMap().tabComplete(player, message.substring(1));
|
2016-02-29 23:09:49 +00:00
|
|
|
+ if (blockPosition == null || !((CraftWorld) player.getWorld()).getHandle().paperConfig.allowBlockLocationTabCompletion) {
|
2016-01-31 01:20:18 +00:00
|
|
|
+ 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()));
|
|
|
|
+ }
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // Paper end
|
2016-01-31 01:20:18 +00:00
|
|
|
} 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
|
2016-02-29 23:09:49 +00:00
|
|
|
index 100d84a..a40218c 100644
|
2016-01-31 01:20:18 +00:00
|
|
|
--- 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;
|
2016-02-29 23:09:49 +00:00
|
|
|
@@ -46,10 +47,23 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
2016-01-31 01:20:18 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
2016-02-29 23:09:49 +00:00
|
|
|
+ return tabComplete(sender, alias, args, null); // Paper - location tab-completes. Original code moved below
|
2016-01-31 01:20:18 +00:00
|
|
|
+ }
|
|
|
|
+
|
2016-02-29 23:09:49 +00:00
|
|
|
+ // Paper start - location tab-completes
|
2016-01-31 01:20:18 +00:00
|
|
|
+ /*
|
2016-02-29 23:09:49 +00:00
|
|
|
+ this code is copied, except for the noted change, from the original tabComplete(CommandSender sender, String alias, String[] args) method
|
2016-01-31 01:20:18 +00:00
|
|
|
+ */
|
|
|
|
+ @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");
|
2016-02-29 23:09:49 +00:00
|
|
|
- return (List<String>) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, new BlockPosition(0, 0, 0));
|
2016-01-31 01:20:18 +00:00
|
|
|
+ if (location == null) { // PaperSpigot use location information if available
|
2016-02-29 23:09:49 +00:00
|
|
|
+ return (List<String>) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, new BlockPosition(0, 0, 0));
|
2016-01-31 01:20:18 +00:00
|
|
|
+ } else {
|
2016-02-29 23:09:49 +00:00
|
|
|
+ return (List<String>) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
2016-01-31 01:20:18 +00:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
public static CommandSender lastSender = null; // Nasty :(
|
|
|
|
--
|
2016-03-28 01:48:50 +00:00
|
|
|
2.7.4
|
2016-01-31 01:20:18 +00:00
|
|
|
|