moved listener registration to onEnable to fix bug w/ multiple events

This commit is contained in:
Indyuce 2019-09-01 17:24:06 +02:00
parent dbf3ee981a
commit 23e702bb2d
2 changed files with 12 additions and 13 deletions

View File

@ -58,6 +58,9 @@ import net.Indyuce.mmocore.listener.PlayerListener;
import net.Indyuce.mmocore.listener.SpellCast; import net.Indyuce.mmocore.listener.SpellCast;
import net.Indyuce.mmocore.listener.WaypointsListener; import net.Indyuce.mmocore.listener.WaypointsListener;
import net.Indyuce.mmocore.listener.event.PlayerAttackEventListener; import net.Indyuce.mmocore.listener.event.PlayerAttackEventListener;
import net.Indyuce.mmocore.listener.option.DeathExperienceLoss;
import net.Indyuce.mmocore.listener.option.HealthScale;
import net.Indyuce.mmocore.listener.option.VanillaExperienceOverride;
import net.Indyuce.mmocore.listener.profession.FishingListener; import net.Indyuce.mmocore.listener.profession.FishingListener;
import net.Indyuce.mmocore.listener.profession.PlayerCollectStats; import net.Indyuce.mmocore.listener.profession.PlayerCollectStats;
import net.Indyuce.mmocore.manager.AttributeManager; import net.Indyuce.mmocore.manager.AttributeManager;
@ -247,6 +250,15 @@ public class MMOCore extends JavaPlugin {
if (getConfig().getBoolean("debug")) if (getConfig().getBoolean("debug"))
new DebugMode(); new DebugMode();
if (configManager.overrideVanillaExp = getConfig().getBoolean("override-vanilla-exp"))
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), this);
if (getConfig().getBoolean("health-scale.enabled"))
Bukkit.getPluginManager().registerEvents(new HealthScale(), this);
if (getConfig().getBoolean("death-exp-loss.enabled"))
Bukkit.getPluginManager().registerEvents(new DeathExperienceLoss(), this);
Bukkit.getPluginManager().registerEvents(new PlayerAttackEventListener(), this); Bukkit.getPluginManager().registerEvents(new PlayerAttackEventListener(), this);
Bukkit.getPluginManager().registerEvents(new DamageManager(), this); Bukkit.getPluginManager().registerEvents(new DamageManager(), this);

View File

@ -9,7 +9,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,9 +20,6 @@ import net.Indyuce.mmocore.api.input.AnvilGUI;
import net.Indyuce.mmocore.api.input.ChatInput; import net.Indyuce.mmocore.api.input.ChatInput;
import net.Indyuce.mmocore.api.input.PlayerInput; import net.Indyuce.mmocore.api.input.PlayerInput;
import net.Indyuce.mmocore.api.input.PlayerInput.InputType; import net.Indyuce.mmocore.api.input.PlayerInput.InputType;
import net.Indyuce.mmocore.listener.option.DeathExperienceLoss;
import net.Indyuce.mmocore.listener.option.HealthScale;
import net.Indyuce.mmocore.listener.option.VanillaExperienceOverride;
public class ConfigManager { public class ConfigManager {
@ -97,15 +93,6 @@ public class ConfigManager {
regenPartyBuff = MMOCore.plugin.getConfig().getDouble("party.buff.health-regen"); regenPartyBuff = MMOCore.plugin.getConfig().getDouble("party.buff.health-regen");
partyChatPrefix = MMOCore.plugin.getConfig().getString("party.chat-prefix"); partyChatPrefix = MMOCore.plugin.getConfig().getString("party.chat-prefix");
if (overrideVanillaExp = MMOCore.plugin.getConfig().getBoolean("override-vanilla-exp"))
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), MMOCore.plugin);
if (MMOCore.plugin.getConfig().getBoolean("health-scale.enabled"))
Bukkit.getPluginManager().registerEvents(new HealthScale(), MMOCore.plugin);
if (MMOCore.plugin.getConfig().getBoolean("death-exp-loss.enabled"))
Bukkit.getPluginManager().registerEvents(new DeathExperienceLoss(), MMOCore.plugin);
neededExp.clear(); neededExp.clear();
int line = 0; int line = 0;
try { try {