Separate plugin types #10

Merged
owlsys merged 14 commits from ecorous/plugin-types into main 2024-06-16 17:13:54 -04:00
3 changed files with 5 additions and 5 deletions
Showing only changes of commit a3960b933f - Show all commits

View file

@ -1,6 +1,6 @@
[versions] [versions]
thyroxine = "0.0.1-alpha.2" thyroxine = "0.0.1-alpha.3"
nightconfig = "3.7.2" nightconfig = "3.7.2"
mixin = "0.14.0+mixin.0.8.6" mixin = "0.14.0+mixin.0.8.6"
annotations = "24.1.0" annotations = "24.1.0"

View file

@ -1,6 +1,6 @@
plugins { plugins {
java java
id("dev.frogmc.phytotelma") version "0.0.1-alpha.9" id("dev.frogmc.phytotelma") version "0.0.1-alpha.10"
} }
repositories { repositories {

View file

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