summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-05-16 16:59:23 +1000
committermd_5 <git@md-5.net>2016-05-16 16:59:23 +1000
commite217da5747089094acffd0b65b03eb095f465930 (patch)
treeaadbcabacc0e756e5a7900a3195d48e164172d5a
parent329ef57aea4529ce36b9d59b22d2ce00d1c64cb0 (diff)
downloadbukkit-e217da5747089094acffd0b65b03eb095f465930.tar
bukkit-e217da5747089094acffd0b65b03eb095f465930.tar.gz
bukkit-e217da5747089094acffd0b65b03eb095f465930.tar.lz
bukkit-e217da5747089094acffd0b65b03eb095f465930.tar.xz
bukkit-e217da5747089094acffd0b65b03eb095f465930.zip
Implement TabCompleteEvent
-rw-r--r--src/main/java/org/bukkit/event/server/TabCompleteEvent.java89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java
new file mode 100644
index 00000000..6ac437d5
--- /dev/null
+++ b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java
@@ -0,0 +1,89 @@
+package org.bukkit.event.server;
+
+import java.util.List;
+import org.apache.commons.lang.Validate;
+import org.bukkit.command.CommandSender;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Called when a {@link CommandSender} of any description (ie: player or
+ * console) attempts to tab complete.
+ */
+public class TabCompleteEvent extends Event implements Cancellable {
+
+ private static final HandlerList handlers = new HandlerList();
+ //
+ private final CommandSender sender;
+ private final String buffer;
+ private List<String> completions;
+ private boolean cancelled;
+
+ public TabCompleteEvent(CommandSender sender, String buffer, List<String> completions) {
+ Validate.notNull(sender, "sender");
+ Validate.notNull(buffer, "buffer");
+ Validate.notNull(completions, "completions");
+
+ this.sender = sender;
+ this.buffer = buffer;
+ this.completions = completions;
+ }
+
+ /**
+ * Get the sender completing this command.
+ *
+ * @return the {@link CommandSender} instance
+ */
+ public CommandSender getSender() {
+ return sender;
+ }
+
+ /**
+ * Return the entire buffer which formed the basis of this completion.
+ *
+ * @return command buffer, as entered
+ */
+ public String getBuffer() {
+ return buffer;
+ }
+
+ /**
+ * The list of completions which will be offered to the sender, in order.
+ * This list is mutable and reflects what will be offered.
+ *
+ * @return a list of offered completions
+ */
+ public List<String> getCompletions() {
+ return completions;
+ }
+
+ /**
+ * Set the completions offered, overriding any already set.
+ *
+ * @param completions the new completions
+ */
+ public void setCompletions(List<String> completions) {
+ Validate.notNull(completions);
+ this.completions = completions;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}