mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
SPIGOT-215: Implement infrastructure for Location tab completes
This commit is contained in:
parent
4db0855e3e
commit
c74e2a7301
@ -568,7 +568,7 @@
|
|||||||
return arraylist;
|
return arraylist;
|
||||||
}
|
}
|
||||||
+ */
|
+ */
|
||||||
+ return server.tabComplete(icommandlistener, s); // PAIL : todo args
|
+ return server.tabComplete(icommandlistener, s, blockposition);
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import org.bukkit.BanList;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.UnsafeValues;
|
import org.bukkit.UnsafeValues;
|
||||||
@ -1528,7 +1529,7 @@ public final class CraftServer implements Server {
|
|||||||
return warningState;
|
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)) {
|
if (!(sender instanceof EntityPlayer)) {
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
@ -1536,7 +1537,7 @@ public final class CraftServer implements Server {
|
|||||||
List<String> offers;
|
List<String> offers;
|
||||||
Player player = ((EntityPlayer) sender).getBukkitEntity();
|
Player player = ((EntityPlayer) sender).getBukkitEntity();
|
||||||
if (message.startsWith("/")) {
|
if (message.startsWith("/")) {
|
||||||
offers = tabCompleteCommand(player, message);
|
offers = tabCompleteCommand(player, message, pos);
|
||||||
} else {
|
} else {
|
||||||
offers = tabCompleteChat(player, message);
|
offers = tabCompleteChat(player, message);
|
||||||
}
|
}
|
||||||
@ -1547,10 +1548,14 @@ public final class CraftServer implements Server {
|
|||||||
return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions();
|
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;
|
List<String> completions = null;
|
||||||
try {
|
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) {
|
} catch (CommandException ex) {
|
||||||
player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
|
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);
|
getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
|
||||||
|
@ -7,6 +7,7 @@ import net.minecraft.server.*;
|
|||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.BlockCommandSender;
|
import org.bukkit.command.BlockCommandSender;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
@ -38,11 +39,11 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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(sender, "Sender cannot be null");
|
||||||
Validate.notNull(args, "Arguments cannot be null");
|
Validate.notNull(args, "Arguments cannot be null");
|
||||||
Validate.notNull(alias, "Alias 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 :(
|
public static CommandSender lastSender = null; // Nasty :(
|
||||||
@ -72,7 +73,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
|||||||
if (i > -1) {
|
if (i > -1) {
|
||||||
List<Entity> list = ((List<Entity>)PlayerSelector.getPlayers(icommandlistener, as[i], Entity.class));
|
List<Entity> list = ((List<Entity>)PlayerSelector.getPlayers(icommandlistener, as[i], Entity.class));
|
||||||
String s2 = as[i];
|
String s2 = as[i];
|
||||||
|
|
||||||
icommandlistener.a(CommandObjectiveExecutor.EnumCommandResult.AFFECTED_ENTITIES, list.size());
|
icommandlistener.a(CommandObjectiveExecutor.EnumCommandResult.AFFECTED_ENTITIES, list.size());
|
||||||
Iterator<Entity> iterator = list.iterator();
|
Iterator<Entity> iterator = list.iterator();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user