diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index 2a7a8db15..84b9e59c1 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -57,6 +57,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; @@ -665,24 +666,29 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, Class objectiveClass = c.asSubclass(CustomObjective.class); Constructor cstrctr = objectiveClass.getConstructor(); - CustomObjective objective = cstrctr.newInstance(); + final CustomObjective objective = cstrctr.newInstance(); customObjectives.add(objective); - String name = objective.getName() == null ? "[" + jar.getName() + "]" : objective.getName(); + final String name = objective.getName() == null ? "[" + jar.getName() + "]" : objective.getName(); String author = objective.getAuthor() == null ? "[Unknown]" : objective.getAuthor(); count++; getLogger().info("Loaded Module: " + name + " by " + author); + final Plugin plugin = this; - try { - getServer().getPluginManager().registerEvents(objective, this); - getLogger().info("Registered events for custom objective \"" + name + "\""); - } catch (Exception ex) { - getLogger().warning("Failed to register events for custom objective \"" + name + "\". Does the objective class listen for events?"); - if (debug) { - getLogger().warning("Error log:"); - ex.printStackTrace(); + getServer().getScheduler().runTaskLater(this, new Runnable() { + @Override + public void run() { + try { + getServer().getPluginManager().registerEvents(objective, plugin); + getLogger().info("Registered events for custom objective \"" + name + "\""); + } catch (Exception ex) { + getLogger().warning("Failed to register events for custom objective \"" + name + "\". Does the objective class listen for events?"); + if (debug) { + getLogger().warning("Error log:"); + ex.printStackTrace(); + } + } } - } - + }, 20); } }