diff --git a/eco-api/src/main/java/com/willfp/eco/core/integrations/IntegrationLoader.java b/eco-api/src/main/java/com/willfp/eco/core/integrations/IntegrationLoader.java
index b4fd37e5..c6abd989 100644
--- a/eco-api/src/main/java/com/willfp/eco/core/integrations/IntegrationLoader.java
+++ b/eco-api/src/main/java/com/willfp/eco/core/integrations/IntegrationLoader.java
@@ -1,13 +1,27 @@
package com.willfp.eco.core.integrations;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Collectors;
+
/**
* An integration loader runs a runnable only if a specific plugin is present on the server.
*
* Used by {@link com.willfp.eco.core.EcoPlugin} to load integrations.
*/
public class IntegrationLoader {
+ /**
+ * All loaded plugins on the server.
+ */
+ private static final Set LOADED_PLUGINS = Arrays.stream(Bukkit.getPluginManager().getPlugins())
+ .map(Plugin::getName)
+ .map(String::toLowerCase)
+ .collect(Collectors.toSet());
+
/**
* The lambda to be run if the plugin is present.
*/
@@ -30,6 +44,15 @@ public class IntegrationLoader {
this.pluginName = pluginName;
}
+ /**
+ * Load the integration if the specified plugin is present on the server.
+ */
+ public void loadIfPresent() {
+ if (LOADED_PLUGINS.contains(this.pluginName.toLowerCase())) {
+ this.load();
+ }
+ }
+
/**
* Load the integration.
*/
diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/DataListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/DataListener.kt
index 615d7f9a..d1f774cd 100644
--- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/DataListener.kt
+++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/DataListener.kt
@@ -4,6 +4,7 @@ import com.willfp.eco.core.Eco
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.util.PlayerUtils
import org.bukkit.event.EventHandler
+import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.event.player.PlayerLoginEvent
@@ -12,19 +13,19 @@ import org.bukkit.event.player.PlayerQuitEvent
class DataListener(
private val plugin: EcoPlugin
) : Listener {
- @EventHandler
+ @EventHandler(priority = EventPriority.HIGHEST)
fun onLeave(event: PlayerQuitEvent) {
Eco.getHandler().playerProfileHandler.unloadPlayer(event.player.uniqueId)
}
@EventHandler
fun onJoin(event: PlayerJoinEvent) {
- plugin.scheduler.runLater({
+ plugin.scheduler.runLater(5) {
PlayerUtils.updateSavedDisplayName(event.player)
- }, 5)
+ }
}
- @EventHandler
+ @EventHandler(priority = EventPriority.LOWEST)
fun onLogin(event: PlayerLoginEvent) {
Eco.getHandler().playerProfileHandler.unloadPlayer(event.player.uniqueId)
}
diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/eventlisteners/EntityDeathByEntityListeners.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/eventlisteners/EntityDeathByEntityListeners.kt
index 5d674a38..409188bf 100644
--- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/eventlisteners/EntityDeathByEntityListeners.kt
+++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/eventlisteners/EntityDeathByEntityListeners.kt
@@ -30,9 +30,9 @@ class EntityDeathByEntityListeners(
builtEvent.victim = victim
builtEvent.damager = event.damager
events.add(builtEvent)
- this.plugin.scheduler.runLater({
+ this.plugin.scheduler.run {
events.remove(builtEvent)
- }, 1)
+ }
}
@EventHandler