|
|
|
@ -84,9 +84,9 @@ public class PluginLoader {
|
|
|
|
|
|
|
|
|
|
public static GamePlugin discoverGamePlugins() {
|
|
|
|
|
LOGGER.info("Discovering game plugins...");
|
|
|
|
|
ServiceLoader<GamePlugin> loader = ServiceLoader.load(GamePlugin.class);
|
|
|
|
|
loader.stream().map(ServiceLoader.Provider::get).forEach(p -> LOGGER.info("Found game plugin: {}", p.getClass().getName()));
|
|
|
|
|
GamePlugin[] applicablePlugins = ServiceLoader.load(GamePlugin.class).stream().map(ServiceLoader.Provider::get).filter(GamePlugin::isApplicable).toArray(GamePlugin[]::new);
|
|
|
|
|
GamePlugin[] applicablePlugins = ServiceLoader.load(GamePlugin.class).stream().map(ServiceLoader.Provider::get)
|
|
|
|
|
.peek(p -> LOGGER.debug("Found game plugin: {}", p.getClass().getName()))
|
|
|
|
|
.filter(GamePlugin::isApplicable).toArray(GamePlugin[]::new);
|
|
|
|
|
if (applicablePlugins.length > 1) {
|
|
|
|
|
throw new IllegalStateException("Multiple applicable game plugins found!");
|
|
|
|
|
} else if (applicablePlugins.length == 0) {
|
|
|
|
|