mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 23:13:48 +01:00
Centralizing event listener register to avoid issues
Fixing issue with chat entry no longer being recognized after plugin reload
This commit is contained in:
parent
f9ba65d56b
commit
f70027708e
@ -751,22 +751,8 @@ public final class Jobs extends JavaPlugin {
|
|||||||
new YmlMaker(getFolder(), "Signs.yml").saveDefaultConfig();
|
new YmlMaker(getFolder(), "Signs.yml").saveDefaultConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
// register the listeners
|
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
|
|
||||||
getServer().getPluginManager().registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), getInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new JobsListener(this), this);
|
|
||||||
getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this);
|
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
|
|
||||||
getServer().getPluginManager().registerEvents(new JobsPayment14Listener(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
HookManager.loadHooks();
|
HookManager.loadHooks();
|
||||||
|
registerListeners();
|
||||||
if (getGCManager().useBlockProtection) {
|
|
||||||
getServer().getPluginManager().registerEvents(new PistonProtectionListener(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_16_R3) && kyoriSupported) {
|
if (Version.isCurrentEqualOrHigher(Version.v1_16_R3) && kyoriSupported) {
|
||||||
complement = new Complement2();
|
complement = new Complement2();
|
||||||
@ -774,7 +760,6 @@ public final class Jobs extends JavaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
complement = new Complement1();
|
complement = new Complement1();
|
||||||
}
|
}
|
||||||
getServer().getPluginManager().registerEvents(new JobsChatEvent(this), this);
|
|
||||||
|
|
||||||
// register economy
|
// register economy
|
||||||
getServer().getScheduler().runTask(this, new HookEconomyTask(this));
|
getServer().getScheduler().runTask(this, new HookEconomyTask(this));
|
||||||
@ -794,6 +779,34 @@ public final class Jobs extends JavaPlugin {
|
|||||||
CMIMessages.consoleMessage(suffix);
|
CMIMessages.consoleMessage(suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void registerListeners() {
|
||||||
|
|
||||||
|
org.bukkit.plugin.PluginManager pm = getInstance().getServer().getPluginManager();
|
||||||
|
|
||||||
|
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
|
||||||
|
pm.registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
pm.registerEvents(new JobsListener(getInstance()), getInstance());
|
||||||
|
pm.registerEvents(new JobsPaymentListener(getInstance()), getInstance());
|
||||||
|
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
|
||||||
|
pm.registerEvents(new JobsPayment14Listener(), getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getGCManager().useBlockProtection) {
|
||||||
|
pm.registerEvents(new PistonProtectionListener(), getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
pm.registerEvents(new JobsChatEvent(getInstance()), getInstance());
|
||||||
|
|
||||||
|
if (HookManager.getMcMMOManager().CheckmcMMO()) {
|
||||||
|
HookManager.setMcMMOlistener();
|
||||||
|
}
|
||||||
|
if (HookManager.checkMythicMobs()) {
|
||||||
|
HookManager.getMythicManager().registerListener();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
reload(false);
|
reload(false);
|
||||||
}
|
}
|
||||||
@ -801,30 +814,8 @@ public final class Jobs extends JavaPlugin {
|
|||||||
public static void reload(boolean startup) {
|
public static void reload(boolean startup) {
|
||||||
// unregister all registered listeners by this plugin and register again
|
// unregister all registered listeners by this plugin and register again
|
||||||
if (!startup) {
|
if (!startup) {
|
||||||
org.bukkit.plugin.PluginManager pm = getInstance().getServer().getPluginManager();
|
|
||||||
|
|
||||||
HandlerList.unregisterAll(getInstance());
|
HandlerList.unregisterAll(getInstance());
|
||||||
|
registerListeners();
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
|
|
||||||
pm.registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), getInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
pm.registerEvents(new JobsListener(getInstance()), getInstance());
|
|
||||||
pm.registerEvents(new JobsPaymentListener(getInstance()), getInstance());
|
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
|
|
||||||
pm.registerEvents(new JobsPayment14Listener(), getInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getGCManager().useBlockProtection) {
|
|
||||||
pm.registerEvents(new PistonProtectionListener(), getInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HookManager.getMcMMOManager().CheckmcMMO()) {
|
|
||||||
HookManager.setMcMMOlistener();
|
|
||||||
}
|
|
||||||
if (HookManager.checkMythicMobs()) {
|
|
||||||
HookManager.getMythicManager().registerListener();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveTask != null) {
|
if (saveTask != null) {
|
||||||
|
@ -16,7 +16,6 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.commands.JobsCommands;
|
|
||||||
import com.gamingmesh.jobs.container.Boost;
|
import com.gamingmesh.jobs.container.Boost;
|
||||||
import com.gamingmesh.jobs.container.CurrencyType;
|
import com.gamingmesh.jobs.container.CurrencyType;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
@ -33,7 +32,6 @@ import com.gamingmesh.jobs.stuff.TimeManage;
|
|||||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||||
import net.Zrips.CMILib.Container.CMIList;
|
import net.Zrips.CMILib.Container.CMIList;
|
||||||
import net.Zrips.CMILib.Locale.LC;
|
import net.Zrips.CMILib.Locale.LC;
|
||||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
|
||||||
|
|
||||||
public class Placeholder {
|
public class Placeholder {
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@ import com.gamingmesh.jobs.hooks.WorldGuard.WorldGuardManager;
|
|||||||
import com.gamingmesh.jobs.hooks.stackMob.StackMobHandler;
|
import com.gamingmesh.jobs.hooks.stackMob.StackMobHandler;
|
||||||
import com.gamingmesh.jobs.hooks.wildStacker.WildStackerHandler;
|
import com.gamingmesh.jobs.hooks.wildStacker.WildStackerHandler;
|
||||||
|
|
||||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
|
||||||
|
|
||||||
public class HookManager {
|
public class HookManager {
|
||||||
|
|
||||||
private static McMMOManager McMMOManager;
|
private static McMMOManager McMMOManager;
|
||||||
@ -33,18 +31,11 @@ public class HookManager {
|
|||||||
public static void loadHooks() {
|
public static void loadHooks() {
|
||||||
pm = PLUGIN.getServer().getPluginManager();
|
pm = PLUGIN.getServer().getPluginManager();
|
||||||
|
|
||||||
if (getMcMMOManager().CheckmcMMO())
|
|
||||||
setMcMMOlistener();
|
|
||||||
|
|
||||||
setMyPetManager();
|
setMyPetManager();
|
||||||
setWorldGuard();
|
setWorldGuard();
|
||||||
setMythicManager();
|
setMythicManager();
|
||||||
setStackMobHandler();
|
setStackMobHandler();
|
||||||
setWildStackerHandler();
|
setWildStackerHandler();
|
||||||
|
|
||||||
if (checkMythicMobs()) {
|
|
||||||
MythicManager.registerListener();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StackMobHandler getStackMobHandler() {
|
public static StackMobHandler getStackMobHandler() {
|
||||||
|
@ -16,7 +16,6 @@ import com.gamingmesh.jobs.hooks.HookManager;
|
|||||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
||||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
|
||||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||||
|
|
||||||
public class McMMO1_X_listener implements Listener {
|
public class McMMO1_X_listener implements Listener {
|
||||||
|
@ -14,10 +14,8 @@ import com.gamingmesh.jobs.actions.ItemActionInfo;
|
|||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.hooks.HookManager;
|
import com.gamingmesh.jobs.hooks.HookManager;
|
||||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
|
||||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
||||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
|
||||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||||
|
|
||||||
public class McMMO2_X_listener implements Listener {
|
public class McMMO2_X_listener implements Listener {
|
||||||
|
Loading…
Reference in New Issue
Block a user