Skip to content

Commit

Permalink
Add enable/disable consumer invocation order guarantee
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed May 2, 2023
1 parent 812e4b8 commit 85e3763
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/de/bluecolored/bluemap/api/BlueMapAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public abstract class BlueMapAPI {

private static BlueMapAPI instance;

private static final Collection<Consumer<BlueMapAPI>> onEnableConsumers = new HashSet<>(2);
private static final Collection<Consumer<BlueMapAPI>> onDisableConsumers = new HashSet<>(2);
private static final LinkedHashSet<Consumer<BlueMapAPI>> onEnableConsumers = new LinkedHashSet<>();
private static final LinkedHashSet<Consumer<BlueMapAPI>> onDisableConsumers = new LinkedHashSet<>();

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

0 comments on commit 85e3763

Please sign in to comment.