mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-17 13:51:23 +01:00
Always copy completions for #setCompletions in Tab Complete Events
Per feedback on 6364cb2
This commit is contained in:
parent
8665021cdb
commit
4f6b49e007
@ -13,7 +13,7 @@ completion, such as offline players.
|
|||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java
|
diff --git a/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 00000000..2fa4cb1c
|
index 00000000..3071320e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java
|
+++ b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +0,0 @@
|
||||||
@ -43,6 +43,7 @@ index 00000000..2fa4cb1c
|
|||||||
+package com.destroystokyo.paper.event.server;
|
+package com.destroystokyo.paper.event.server;
|
||||||
+
|
+
|
||||||
+import com.google.common.collect.ImmutableList;
|
+import com.google.common.collect.ImmutableList;
|
||||||
|
+import org.apache.commons.lang.Validate;
|
||||||
+import org.bukkit.Location;
|
+import org.bukkit.Location;
|
||||||
+import org.bukkit.command.Command;
|
+import org.bukkit.command.Command;
|
||||||
+import org.bukkit.command.CommandSender;
|
+import org.bukkit.command.CommandSender;
|
||||||
@ -106,13 +107,13 @@ index 00000000..2fa4cb1c
|
|||||||
+ * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])}
|
+ * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])}
|
||||||
+ * or current player names will not be called.
|
+ * or current player names will not be called.
|
||||||
+ *
|
+ *
|
||||||
|
+ * The passed collection will be cloned to a new List. You must call {{@link #getCompletions()}} to mutate from here
|
||||||
|
+ *
|
||||||
+ * @param completions the new completions
|
+ * @param completions the new completions
|
||||||
+ */
|
+ */
|
||||||
+ public void setCompletions(List<String> completions) {
|
+ public void setCompletions(List<String> completions) {
|
||||||
+ if (completions instanceof ImmutableList) {
|
+ Validate.notNull(completions);
|
||||||
+ completions = new ArrayList<>(completions);
|
+ this.completions = new ArrayList<>(completions);
|
||||||
+ }
|
|
||||||
+ this.completions = completions;
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
@ -185,9 +186,16 @@ index 00000000..2fa4cb1c
|
|||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java
|
diff --git a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java
|
||||||
index 6ac437d5..fef57f5f 100644
|
index 6ac437d5..df6eb53d 100644
|
||||||
--- a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java
|
--- a/src/main/java/org/bukkit/event/server/TabCompleteEvent.java
|
||||||
+++ b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java
|
+++ b/src/main/java/org/bukkit/event/server/TabCompleteEvent.java
|
||||||
|
@@ -0,0 +0,0 @@
|
||||||
|
package org.bukkit.event.server;
|
||||||
|
|
||||||
|
+import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -0,0 +0,0 @@ public class TabCompleteEvent extends Event implements Cancellable {
|
@@ -0,0 +0,0 @@ public class TabCompleteEvent extends Event implements Cancellable {
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
@ -227,4 +235,15 @@ index 6ac437d5..fef57f5f 100644
|
|||||||
/**
|
/**
|
||||||
* Set the completions offered, overriding any already set.
|
* Set the completions offered, overriding any already set.
|
||||||
*
|
*
|
||||||
|
+ * The passed collection will be cloned to a new List. You must call {{@link #getCompletions()}} to mutate from here
|
||||||
|
+ *
|
||||||
|
* @param completions the new completions
|
||||||
|
*/
|
||||||
|
public void setCompletions(List<String> completions) {
|
||||||
|
Validate.notNull(completions);
|
||||||
|
- this.completions = completions;
|
||||||
|
+ this.completions = new ArrayList<>(completions); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
--
|
--
|
Loading…
Reference in New Issue
Block a user