From 311a2ddc75f21012f46f418a4c0a969cc1b8dda9 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sun, 23 Aug 2020 21:28:08 +0200 Subject: [PATCH] Replace null checks with NullEconHandler --- .../core/generator/ClassicPlotWorld.java | 10 ++++------ .../core/generator/GridPlotWorld.java | 9 +++------ .../core/generator/HybridPlotWorld.java | 6 ++---- .../core/generator/SquarePlotWorld.java | 6 ++---- .../plotsquared/core/player/ConsolePlayer.java | 3 --- .../java/com/plotsquared/core/plot/PlotArea.java | 16 ++++++---------- .../core/plot/world/SinglePlotArea.java | 6 ++---- .../core/plot/world/SinglePlotAreaManager.java | 6 ++---- 8 files changed, 21 insertions(+), 41 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java index 5f30b424e..cffc9c4f7 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java @@ -33,7 +33,6 @@ import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.plot.BlockBucket; import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.queue.GlobalBlockQueue; -import com.plotsquared.core.util.EconHandler; import com.sk89q.worldedit.world.block.BlockTypes; import javax.annotation.Nonnull; @@ -63,12 +62,11 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { public ClassicPlotWorld(@Nonnull final String worldName, @Nullable final String id, @Nonnull final IndependentPlotGenerator generator, - @Nonnull final PlotId min, - @Nonnull final PlotId max, + @Nullable final PlotId min, + @Nullable final PlotId max, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration, - @Nonnull final GlobalBlockQueue blockQueue, - @Nonnull final EconHandler econHandler) { - super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler); + @Nonnull final GlobalBlockQueue blockQueue) { + super(worldName, id, generator, min, max, worldConfiguration, blockQueue); } /** diff --git a/Core/src/main/java/com/plotsquared/core/generator/GridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/GridPlotWorld.java index b26107000..8a0fda080 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/GridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/GridPlotWorld.java @@ -30,19 +30,16 @@ import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.queue.GlobalBlockQueue; -import com.plotsquared.core.util.EconHandler; import javax.annotation.Nonnull; -import javax.annotation.Nullable; public abstract class GridPlotWorld extends PlotArea { public short SIZE; public GridPlotWorld(String worldName, String id, @Nonnull IndependentPlotGenerator generator, - PlotId min, PlotId max, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration, - @Nonnull final GlobalBlockQueue blockQueue, - @Nullable final EconHandler econHandler) { - super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler); + PlotId min, PlotId max, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration, + @Nonnull final GlobalBlockQueue blockQueue) { + super(worldName, id, generator, min, max, worldConfiguration, blockQueue); } } diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java index f1673cc67..cff9f47d9 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java @@ -38,7 +38,6 @@ import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.schematic.Schematic; import com.plotsquared.core.queue.GlobalBlockQueue; -import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.FileUtils; import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.SchematicHandler; @@ -88,9 +87,8 @@ public class HybridPlotWorld extends ClassicPlotWorld { @Nullable @Assisted("min") final PlotId min, @Nullable @Assisted("max") final PlotId max, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration, - @Nonnull final GlobalBlockQueue blockQueue, - @Nullable final EconHandler econHandler) { - super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler); + @Nonnull final GlobalBlockQueue blockQueue) { + super(worldName, id, generator, min, max, worldConfiguration, blockQueue); PlotSquared.platform().getInjector().injectMembers(this); } diff --git a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java index e1b4546a7..cf44fc2d3 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java @@ -31,7 +31,6 @@ import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.queue.GlobalBlockQueue; -import com.plotsquared.core.util.EconHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,9 +52,8 @@ public abstract class SquarePlotWorld extends GridPlotWorld { @Nullable final PlotId min, @Nullable final PlotId max, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration, - @Nonnull final GlobalBlockQueue blockQueue, - @Nullable final EconHandler econHandler) { - super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler); + @Nonnull final GlobalBlockQueue blockQueue) { + super(worldName, id, generator, min, max, worldConfiguration, blockQueue); } @Override public void loadConfiguration(ConfigurationSection config) { diff --git a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java index a4a49a7fa..730127060 100644 --- a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java @@ -40,7 +40,6 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotWeather; import com.plotsquared.core.plot.world.PlotAreaManager; -import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EventDispatcher; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.regions.CuboidRegion; @@ -54,7 +53,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.UUID; public class ConsolePlayer extends PlotPlayer { @@ -68,7 +66,6 @@ public class ConsolePlayer extends PlotPlayer { @Inject private ConsolePlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher, @ConsoleActor @Nonnull final Actor actor, - @Nullable final EconHandler econHandler, @Nonnull final PermissionHandler permissionHandler) { super(plotAreaManager, eventDispatcher, permissionHandler); this.actor = actor; diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index 6f50b358b..93545c0b6 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -27,8 +27,8 @@ package com.plotsquared.core.plot; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.plotsquared.core.PlotSquared; import com.google.common.collect.Lists; +import com.plotsquared.core.PlotSquared; import com.plotsquared.core.collection.QuadMap; import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationSection; @@ -57,7 +57,6 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.types.DoubleFlag; import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.queue.QueueCoordinator; -import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.Expression; import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.RegionUtil; @@ -154,14 +153,12 @@ public abstract class PlotArea { private final YamlConfiguration worldConfiguration; private final GlobalBlockQueue globalBlockQueue; - private final EconHandler econHandler; public PlotArea(@Nonnull final String worldName, @Nullable final String id, - @Nonnull IndependentPlotGenerator generator, @Nullable final PlotId min, - @Nullable final PlotId max, - @WorldConfig @Nullable final YamlConfiguration worldConfiguration, - @Nonnull final GlobalBlockQueue blockQueue, - @Nullable final EconHandler econHandler) { + @Nonnull IndependentPlotGenerator generator, @Nullable final PlotId min, + @Nullable final PlotId max, + @WorldConfig @Nullable final YamlConfiguration worldConfiguration, + @Nonnull final GlobalBlockQueue blockQueue) { this.worldName = worldName; this.id = id; this.plotManager = createManager(); @@ -180,7 +177,6 @@ public abstract class PlotArea { } this.worldHash = worldName.hashCode(); this.worldConfiguration = worldConfiguration; - this.econHandler = econHandler; } @Nonnull protected abstract PlotManager createManager(); @@ -305,7 +301,7 @@ public abstract class PlotArea { this.schematicClaimSpecify = config.getBoolean("schematic.specify_on_claim"); this.schematics = new ArrayList<>(config.getStringList("schematic.schematics")); this.schematics.replaceAll(String::toLowerCase); - this.useEconomy = config.getBoolean("economy.use") && this.econHandler != null; + this.useEconomy = config.getBoolean("economy.use"); ConfigurationSection priceSection = config.getConfigurationSection("economy.prices"); if (this.useEconomy) { this.prices = new HashMap<>(); diff --git a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java index 13a9c7059..d2161fb43 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotArea.java @@ -45,7 +45,6 @@ import com.plotsquared.core.plot.flag.FlagContainer; import com.plotsquared.core.queue.GlobalBlockQueue; 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.task.TaskManager; @@ -66,10 +65,9 @@ public class SinglePlotArea extends GridPlotWorld { @Nonnull final EventDispatcher eventDispatcher, @Nonnull final PlotListener plotListener, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration, - @Nonnull final GlobalBlockQueue globalBlockQueue, - @Nonnull final EconHandler econHandler) { + @Nonnull final GlobalBlockQueue globalBlockQueue) { super("*", null, new SingleWorldGenerator(plotAreaManager), null, null, - worldConfiguration, globalBlockQueue, econHandler); + worldConfiguration, globalBlockQueue); this.eventDispatcher = eventDispatcher; this.plotListener = plotListener; this.setAllowSigns(false); diff --git a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotAreaManager.java b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotAreaManager.java index e909a894a..a18e13532 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotAreaManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/world/SinglePlotAreaManager.java @@ -34,7 +34,6 @@ import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.location.Location; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.queue.GlobalBlockQueue; -import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.SetupUtils; import com.sk89q.worldedit.regions.CuboidRegion; @@ -52,10 +51,9 @@ import javax.inject.Inject; @Inject public SinglePlotAreaManager(@Nonnull final EventDispatcher eventDispatcher, @Nonnull final PlotListener plotListener, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration, - @Nonnull final GlobalBlockQueue blockQueue, - @Nonnull final EconHandler econHandler) { + @Nonnull final GlobalBlockQueue blockQueue) { this.area = new SinglePlotArea(this, eventDispatcher, plotListener, - worldConfiguration, blockQueue, econHandler); + worldConfiguration, blockQueue); this.array = new SinglePlotArea[] {area}; this.all = new PlotArea[] {area}; SetupUtils.generators.put("PlotSquared:single",