From 85e3763d7aa69e0b1796a5dd8123f19cc6d25244 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Tue, 2 May 2023 21:29:10 +0200 Subject: [PATCH] Add enable/disable consumer invocation order guarantee --- src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java b/src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java index d715ffe..d25376a 100644 --- a/src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java +++ b/src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java @@ -71,8 +71,8 @@ public abstract class BlueMapAPI { private static BlueMapAPI instance; - private static final Collection> onEnableConsumers = new HashSet<>(2); - private static final Collection> onDisableConsumers = new HashSet<>(2); + private static final LinkedHashSet> onEnableConsumers = new LinkedHashSet<>(); + private static final LinkedHashSet> onDisableConsumers = new LinkedHashSet<>(); /** * Getter for the {@link RenderManager}. @@ -163,6 +163,7 @@ public static synchronized Optional getInstance() { *

The {@link Consumer} can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!

*

(Note: The consumer will likely be called asynchronously, not on the server-thread!)

*

Remember to unregister the consumer when you no longer need it using {@link #unregisterListener(Consumer)}.

+ *

The {@link Consumer}s are guaranteed to be called in the order they were registered in.

* @param consumer the {@link Consumer} */ public static synchronized void onEnable(Consumer consumer) { @@ -176,6 +177,7 @@ public static synchronized void onEnable(Consumer consumer) { *

The {@link Consumer} can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!

*

(Note: The consumer will likely be called asynchronously, not on the server-thread!)

*

Remember to unregister the consumer when you no longer need it using {@link #unregisterListener(Consumer)}.

+ *

The {@link Consumer}s are guaranteed to be called in the order they were registered in.

* @param consumer the {@link Consumer} */ public static synchronized void onDisable(Consumer consumer) {