diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 3d52c8d6a..b4d5ebc19 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -102,7 +102,6 @@ import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.plot.world.SinglePlotAreaManager; import com.plotsquared.core.setup.PlotAreaBuilder; import com.plotsquared.core.setup.SettingsNodesWrapper; -import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.FileUtils; import com.plotsquared.core.util.PlatformWorldManager; @@ -188,7 +187,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl private boolean methodUnloadSetup = false; private boolean metricsStarted; private boolean faweHook = false; - private EconHandler econ; private Injector injector; @@ -375,14 +373,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl // Permissions this.permissionHandler().initialize(); - // Economy - if (Settings.Enabled_Components.ECONOMY) { - TaskManager.runTaskAsync(() -> { - final EconHandler econHandler = injector().getInstance(EconHandler.class); - econHandler.init(); - }); - } - if (Settings.Enabled_Components.COMPONENT_PRESETS) { try { injector().getInstance(ComponentPresetManager.class); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BukkitModule.java b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BukkitModule.java index eec8a47dd..de734c1a1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BukkitModule.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/inject/BukkitModule.java @@ -72,6 +72,8 @@ import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.WorldUtil; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extension.platform.Actor; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.plugin.java.JavaPlugin; @@ -79,6 +81,8 @@ import org.checkerframework.checker.nullness.qual.NonNull; public class BukkitModule extends AbstractModule { + private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + BukkitModule.class.getSimpleName()); + private final BukkitPlatform bukkitPlatform; public BukkitModule(final @NonNull BukkitPlatform bukkitPlatform) { @@ -131,9 +135,17 @@ public class BukkitModule extends AbstractModule { @Provides @Singleton @NonNull EconHandler provideEconHandler() { + if (!Settings.Enabled_Components.ECONOMY) { + return EconHandler.nullEconHandler(); + } if (Bukkit.getPluginManager().isPluginEnabled("Vault")) { try { - return new BukkitEconHandler(); + BukkitEconHandler econHandler = new BukkitEconHandler(); + if (!econHandler.init()) { + LOGGER.warn("Economy is enabled but no plugin is providing an economy service. Falling back..."); + return EconHandler.nullEconHandler(); + } + return econHandler; } catch (final Exception ignored) { } }