diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/NullPacketListener.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/NullPacketListener.java index 70d9449b..4668b1df 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/NullPacketListener.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/NullPacketListener.java @@ -19,6 +19,7 @@ package com.comphenix.protocol.async; import org.bukkit.plugin.Plugin; +import com.comphenix.protocol.events.ListenerOptions; import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.ListeningWhitelist; import com.comphenix.protocol.events.PacketEvent; @@ -67,7 +68,8 @@ class NullPacketListener implements PacketListener { private ListeningWhitelist cloneWhitelist(ListenerPriority priority, ListeningWhitelist whitelist) { if (whitelist != null) - return ListeningWhitelist.newBuilder(whitelist).priority(priority).build(); + // We don't use the Bukkit API, so don't engage the ProtocolLib synchronization code + return ListeningWhitelist.newBuilder(whitelist).priority(priority).mergeOptions(ListenerOptions.ASYNC).build(); else return null; } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java index 0c3b2c5e..1c234aa4 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java @@ -420,7 +420,6 @@ public class ListeningWhitelist { public Builder gamePhaseBoth() { return gamePhase(GamePhase.BOTH); } - /** * Set the options to copy when constructing new whitelists. * @param options - the options. @@ -431,6 +430,16 @@ public class ListeningWhitelist { return this; } + /** + * Set the options to copy when constructing new whitelists. + * @param options - the options. + * @return This builder, for chaining. + */ + public Builder options(Collection options) { + this.options = safeSet(options); + return this; + } + /** * Set the options to copy when constructing new whitelists. * @param options - the options array. @@ -441,6 +450,29 @@ public class ListeningWhitelist { return this; } + /** + * Options to merge into the current set of options. + * @param options - the options array. + * @return This builder, for chaining. + */ + public Builder mergeOptions(ListenerOptions... serverOptions) { + return mergeOptions(Arrays.asList(serverOptions)); + } + + /** + * Options to merge into the current set of options. + * @param options - the options array. + * @return This builder, for chaining. + */ + public Builder mergeOptions(Collection serverOptions) { + if (options == null) + return options(serverOptions); + + // Merge the options + this.options.addAll(serverOptions); + return this; + } + /** * Construct a new whitelist from the values in this builder. * @return The new whitelist.