From e9c5dd0a2510c2e42c103cc1610781bdfc6977f1 Mon Sep 17 00:00:00 2001 From: Sentropic <60368610+Sentropic@users.noreply.github.com> Date: Sat, 19 Dec 2020 19:57:38 -0600 Subject: [PATCH] Updated PluginChecker Made more consistent with other listeners --- src/main/java/com/sucy/skill/SkillAPI.java | 3 ++- .../java/com/sucy/skill/hook/PluginChecker.java | 13 ++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/sucy/skill/SkillAPI.java b/src/main/java/com/sucy/skill/SkillAPI.java index c5b652fc..eef0f04e 100644 --- a/src/main/java/com/sucy/skill/SkillAPI.java +++ b/src/main/java/com/sucy/skill/SkillAPI.java @@ -167,7 +167,8 @@ public void onEnable() { listen(new DeathListener(), !VersionManager.isVersionAtLeast(11000)); listen(new LingeringPotionListener(), VersionManager.isVersionAtLeast(VersionManager.V1_9_0)); listen(new ExperienceListener(), settings.yieldsEnabled()); - new PluginChecker(this); + listen(new PluginChecker(), true); + // Set up tasks if (settings.isManaEnabled()) { diff --git a/src/main/java/com/sucy/skill/hook/PluginChecker.java b/src/main/java/com/sucy/skill/hook/PluginChecker.java index 72789b43..77d1ff2b 100644 --- a/src/main/java/com/sucy/skill/hook/PluginChecker.java +++ b/src/main/java/com/sucy/skill/hook/PluginChecker.java @@ -26,10 +26,9 @@ */ package com.sucy.skill.hook; -import com.sucy.skill.SkillAPI; +import com.sucy.skill.listener.SkillAPIListener; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.plugin.PluginManager; @@ -38,9 +37,7 @@ * Handler for checking whether or not hooked plugins are present * and active before using related code. */ -public class PluginChecker implements Listener { - private static PluginChecker singleton; - +public class PluginChecker extends SkillAPIListener { private static boolean vault; private static boolean libsDisguises; private static boolean noCheatPlus; @@ -51,11 +48,9 @@ public class PluginChecker implements Listener { private static boolean worldGuard; private static boolean parties; - public PluginChecker(SkillAPI plugin) { - if (singleton != null) return; - singleton = this; + @Override + public void init() { PluginManager pluginManager = Bukkit.getPluginManager(); - pluginManager.registerEvents(this, plugin); vault = pluginManager.isPluginEnabled("Vault") && VaultHook.isValid(); libsDisguises = pluginManager.isPluginEnabled("LibsDisguises");