Add action and handler for gliding, equip, refactored PolicyParser and implementations to support world matching
Some checks are pending
Build / build (push) Waiting to run
Some checks are pending
Build / build (push) Waiting to run
This commit is contained in:
parent
96005d8c86
commit
f4a362c1c7
35 changed files with 651 additions and 177 deletions
|
|
@ -1,13 +1,10 @@
|
|||
package io.github.adrianvic.nemesiseye;
|
||||
|
||||
import io.github.adrianvic.nemesiseye.reflection.Glimmer;
|
||||
import io.github.adrianvic.nemesiseye.reflection.VersionMatcher;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public final class Nemesis extends JavaPlugin {
|
||||
private Glimmer glim;
|
||||
private static final String VERSION_PROP = "impl.version";
|
||||
|
|
@ -16,44 +13,11 @@ public final class Nemesis extends JavaPlugin {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
glim = loadGlim();
|
||||
glim = new VersionMatcher().loadGlim();
|
||||
glim.onLoad();
|
||||
Config.getInstance().load();
|
||||
}
|
||||
|
||||
private String readImplVersion() {
|
||||
Properties props = new Properties();
|
||||
try (InputStream is = getClass().getClassLoader()
|
||||
.getResourceAsStream("version.properties")) {
|
||||
if (is == null) {
|
||||
throw new IllegalStateException("version.properties not found on classpath.");
|
||||
}
|
||||
props.load(is);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Failed to load version.properties", e);
|
||||
}
|
||||
String version = props.getProperty(VERSION_PROP);
|
||||
if (version == null || version.isBlank()) {
|
||||
throw new IllegalStateException(VERSION_PROP + " property missing in version.properties.");
|
||||
}
|
||||
return version.trim();
|
||||
}
|
||||
|
||||
private Glimmer loadGlim() {
|
||||
String implVersion = readImplVersion();
|
||||
String className = "io.github.adrianvic.nemesiseye.impl." + implVersion;
|
||||
|
||||
try {
|
||||
Class<?> clazz = Class.forName(className, true, getClass().getClassLoader());
|
||||
if (!Glimmer.class.isAssignableFrom(clazz)) {
|
||||
throw new IllegalStateException(className + " does not implement Glimmer.");
|
||||
}
|
||||
return (Glimmer) clazz.getDeclaredConstructor().newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new IllegalStateException("Failed to instantiate " + className, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue