mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 11:45:19 +01:00
Properly handle economy initialization (fixes #3189)
This commit is contained in:
parent
8fc9e0b13f
commit
89e17bb468
@ -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);
|
||||
|
@ -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) {
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user