diff --git a/7mi-TCT-API/pom.xml b/7mi-TCT-API/pom.xml index 379cb8c..5a929c5 100644 --- a/7mi-TCT-API/pom.xml +++ b/7mi-TCT-API/pom.xml @@ -10,7 +10,7 @@ 4.0.0 7mi-TCT-API - 2.1-MC1.12.2 + 2.2-MC1.12.2 jar 7mi TCT API diff --git a/7mi-TCT-API/src/main/java/me/clockclap/tct/api/TctMain.java b/7mi-TCT-API/src/main/java/me/clockclap/tct/api/TctMain.java new file mode 100644 index 0000000..f269ffa --- /dev/null +++ b/7mi-TCT-API/src/main/java/me/clockclap/tct/api/TctMain.java @@ -0,0 +1,11 @@ +package me.clockclap.tct.api; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface TctMain { +} diff --git a/7miTCT/pom.xml b/7miTCT/pom.xml index a59e9cd..b98bb69 100644 --- a/7miTCT/pom.xml +++ b/7miTCT/pom.xml @@ -11,7 +11,7 @@ 4.0.0 7mi-TCT - 4.0.7 + 4.0.8 jar 7miTct @@ -175,10 +175,16 @@ 16.0.1 compile + + org.reflections + reflections + 0.9.9-RC1 + compile + me.clockclap 7mi-TCT-API - 2.1-MC1.12.2 + 2.2-MC1.12.2 compile diff --git a/7miTCT/src/main/java/me/clockclap/tct/NanamiTct.java b/7miTCT/src/main/java/me/clockclap/tct/NanamiTct.java index 39f8930..227704a 100644 --- a/7miTCT/src/main/java/me/clockclap/tct/NanamiTct.java +++ b/7miTCT/src/main/java/me/clockclap/tct/NanamiTct.java @@ -31,11 +31,18 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; +import org.reflections.Reflections; +import org.reflections.scanners.MethodAnnotationsScanner; +import org.reflections.util.ClasspathHelper; +import org.reflections.util.ConfigurationBuilder; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.sql.SQLException; +import java.util.Set; public final class NanamiTct extends JavaPlugin { @@ -235,6 +242,18 @@ private void reload() { } } isLoaded = true; + Reflections reflections = new Reflections(new ConfigurationBuilder() + .setUrls(ClasspathHelper.forJavaClassPath()).setScanners( + new MethodAnnotationsScanner())); + Set methods = reflections.getMethodsAnnotatedWith(TctMain.class); + + for (Method m : methods) { + try { + m.invoke(null); // for simplicity, invoking static methods without parameters + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } } @Override