SPIGOT-215: Implement infrastructure for Location tab completes

Dieser Commit ist enthalten in:
DemonWav 2016-08-25 09:48:52 +10:00 committet von md_5
Ursprung 4db0855e3e
Commit c74e2a7301
3 geänderte Dateien mit 14 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -568,7 +568,7 @@
return arraylist;
}
+ */
+ return server.tabComplete(icommandlistener, s); // PAIL : todo args
+ return server.tabComplete(icommandlistener, s, blockposition);
+ // CraftBukkit end
}

Datei anzeigen

@ -29,6 +29,7 @@ import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.UnsafeValues;
@ -1528,7 +1529,7 @@ public final class CraftServer implements Server {
return warningState;
}
public List<String> tabComplete(net.minecraft.server.ICommandListener sender, String message) {
public List<String> tabComplete(net.minecraft.server.ICommandListener sender, String message, BlockPosition pos) {
if (!(sender instanceof EntityPlayer)) {
return ImmutableList.of();
}
@ -1536,7 +1537,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, pos);
} else {
offers = tabCompleteChat(player, message);
}
@ -1547,10 +1548,14 @@ public final class CraftServer implements Server {
return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions();
}
public List<String> tabCompleteCommand(Player player, String message) {
public List<String> tabCompleteCommand(Player player, String message, BlockPosition pos) {
List<String> completions = null;
try {
completions = getCommandMap().tabComplete(player, message.substring(1));
if (pos == null) {
completions = getCommandMap().tabComplete(player, message.substring(1));
} else {
completions = getCommandMap().tabComplete(player, message.substring(1), new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
}
} 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);

Datei anzeigen

@ -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;
@ -38,11 +39,11 @@ public final class VanillaCommandWrapper extends VanillaCommand {
}
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
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));
return (List<String>) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, new BlockPosition(location.getX(), location.getY(), location.getZ()));
}
public static CommandSender lastSender = null; // Nasty :(
@ -72,7 +73,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
if (i > -1) {
List<Entity> list = ((List<Entity>)PlayerSelector.getPlayers(icommandlistener, as[i], Entity.class));
String s2 = as[i];
icommandlistener.a(CommandObjectiveExecutor.EnumCommandResult.AFFECTED_ENTITIES, list.size());
Iterator<Entity> iterator = list.iterator();