mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
Expand ParticleBuilder more with hasReceivers, fix empty receivers list
This commit is contained in:
parent
052479037b
commit
3f4bd3e8f7
1 changed files with 20 additions and 6 deletions
|
@ -10,7 +10,7 @@ This adds a new Builder API which is much friendlier to use.
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/ParticleBuilder.java b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
|
diff --git a/src/main/java/com/destroystokyo/paper/ParticleBuilder.java b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 00000000..a3d8caae
|
index 00000000..ef07ab3c
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
|
+++ b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +0,0 @@
|
||||||
|
@ -87,6 +87,19 @@ index 00000000..a3d8caae
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
|
+ * Example use:
|
||||||
|
+ *
|
||||||
|
+ * builder.receivers(16);
|
||||||
|
+ * if (builder.hasReceivers()) {
|
||||||
|
+ * sendParticleAsync(builder);
|
||||||
|
+ * }
|
||||||
|
+ * @return If this particle is going to be sent to someone
|
||||||
|
+ */
|
||||||
|
+ public boolean hasReceivers() {
|
||||||
|
+ return receivers == null || !receivers.isEmpty();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
+ * Sends this particle to all players in the world
|
+ * Sends this particle to all players in the world
|
||||||
+ */
|
+ */
|
||||||
+ public ParticleBuilder allPlayers() {
|
+ public ParticleBuilder allPlayers() {
|
||||||
|
@ -95,16 +108,17 @@ index 00000000..a3d8caae
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * @param receivers List of players to receive this particle, or null
|
+ * @param receivers List of players to receive this particle, or null for all players in the world
|
||||||
+ */
|
+ */
|
||||||
+ public ParticleBuilder receivers(@Nullable List<Player> receivers) {
|
+ public ParticleBuilder receivers(@Nullable List<Player> receivers) {
|
||||||
+ // Had to keep this as we first made API List<> and not Collection, but removing this may break plugins compiled on older jars
|
+ // Had to keep this as we first made API List<> and not Collection, but removing this may break plugins compiled on older jars
|
||||||
+ // TODO: deprecate?
|
+ // TODO: deprecate?
|
||||||
+ return receivers((Collection<Player>) receivers);
|
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
|
||||||
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * @param receivers List of players to receive this particle, or null
|
+ * @param receivers List of players to receive this particle, or null for all players in the world
|
||||||
+ */
|
+ */
|
||||||
+ public ParticleBuilder receivers(@Nullable Collection<Player> receivers) {
|
+ public ParticleBuilder receivers(@Nullable Collection<Player> receivers) {
|
||||||
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
|
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
|
||||||
|
@ -112,10 +126,10 @@ index 00000000..a3d8caae
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * @param receivers List of players to be receive this particle, or null
|
+ * @param receivers List of players to be receive this particle, or null for all players in the world
|
||||||
+ */
|
+ */
|
||||||
+ public ParticleBuilder receivers(Player... receivers) {
|
+ public ParticleBuilder receivers(Player... receivers) {
|
||||||
+ this.receivers = receivers != null && receivers.length > 0 ? Lists.newArrayList(receivers) : null;
|
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
|
Loading…
Reference in a new issue