plugin manager: register plugins with immediate event bus
This commit is contained in:
@@ -52,6 +52,7 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -81,6 +82,10 @@ public class PluginManager
|
|||||||
@Inject
|
@Inject
|
||||||
EventBus eventBus;
|
EventBus eventBus;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("Immediate EventBus")
|
||||||
|
EventBus immediateEventBus;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Scheduler scheduler;
|
Scheduler scheduler;
|
||||||
|
|
||||||
@@ -316,6 +321,7 @@ public class PluginManager
|
|||||||
log.debug("Plugin {} is now running", plugin.getClass().getSimpleName());
|
log.debug("Plugin {} is now running", plugin.getClass().getSimpleName());
|
||||||
regionTileManager.simulateObjectSpawns(plugin);
|
regionTileManager.simulateObjectSpawns(plugin);
|
||||||
eventBus.register(plugin);
|
eventBus.register(plugin);
|
||||||
|
immediateEventBus.register(plugin);
|
||||||
schedule(plugin);
|
schedule(plugin);
|
||||||
eventBus.post(new PluginChanged(plugin, true));
|
eventBus.post(new PluginChanged(plugin, true));
|
||||||
}
|
}
|
||||||
@@ -340,6 +346,7 @@ public class PluginManager
|
|||||||
{
|
{
|
||||||
unschedule(plugin);
|
unschedule(plugin);
|
||||||
eventBus.unregister(plugin);
|
eventBus.unregister(plugin);
|
||||||
|
immediateEventBus.unregister(plugin);
|
||||||
|
|
||||||
// plugins always stop in the event thread
|
// plugins always stop in the event thread
|
||||||
SwingUtilities.invokeAndWait(() ->
|
SwingUtilities.invokeAndWait(() ->
|
||||||
|
|||||||
Reference in New Issue
Block a user