Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pw.neynq.plugin.Initializers;
- import org.bukkit.event.Listener;
- import pw.neynq.plugin.Plugin;
- import com.google.common.reflect.ClassPath;
- import com.google.common.reflect.ClassPath.ClassInfo;
- public class EventInit {
- public static void init() {
- try {
- ClassPath cp = ClassPath.from(CommandInit.class.getClassLoader());
- for (ClassInfo classInfo : cp.getTopLevelClassesRecursive("pw.neynq.plugin.Events")) {
- Class<?> clazz = Class.forName(classInfo.getName());
- try {
- if (Listener.class.isAssignableFrom(clazz)) {
- Listener event = (Listener) clazz.getDeclaredConstructor().newInstance();
- Plugin.plugin.getServer().getPluginManager().registerEvents(event, Plugin.plugin);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement