Skip to content

Commit 85e3763

Browse files
committed
Add enable/disable consumer invocation order guarantee
1 parent 812e4b8 commit 85e3763

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public abstract class BlueMapAPI {
7171

7272
private static BlueMapAPI instance;
7373

74-
private static final Collection<Consumer<BlueMapAPI>> onEnableConsumers = new HashSet<>(2);
75-
private static final Collection<Consumer<BlueMapAPI>> onDisableConsumers = new HashSet<>(2);
74+
private static final LinkedHashSet<Consumer<BlueMapAPI>> onEnableConsumers = new LinkedHashSet<>();
75+
private static final LinkedHashSet<Consumer<BlueMapAPI>> onDisableConsumers = new LinkedHashSet<>();
7676

7777
/**
7878
* Getter for the {@link RenderManager}.
@@ -163,6 +163,7 @@ public static synchronized Optional<BlueMapAPI> getInstance() {
163163
* <p><b>The {@link Consumer} can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!</b></p>
164164
* <p><i>(Note: The consumer will likely be called asynchronously, <b>not</b> on the server-thread!)</i></p>
165165
* <p>Remember to unregister the consumer when you no longer need it using {@link #unregisterListener(Consumer)}.</p>
166+
* <p>The {@link Consumer}s are guaranteed to be called in the order they were registered in.</p>
166167
* @param consumer the {@link Consumer}
167168
*/
168169
public static synchronized void onEnable(Consumer<BlueMapAPI> consumer) {
@@ -176,6 +177,7 @@ public static synchronized void onEnable(Consumer<BlueMapAPI> consumer) {
176177
* <p><b>The {@link Consumer} can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!</b></p>
177178
* <p><i>(Note: The consumer will likely be called asynchronously, <b>not</b> on the server-thread!)</i></p>
178179
* <p>Remember to unregister the consumer when you no longer need it using {@link #unregisterListener(Consumer)}.</p>
180+
* <p>The {@link Consumer}s are guaranteed to be called in the order they were registered in.</p>
179181
* @param consumer the {@link Consumer}
180182
*/
181183
public static synchronized void onDisable(Consumer<BlueMapAPI> consumer) {

0 commit comments

Comments
 (0)