From 33b2b634accb643bef822cb1f6984b32e1cedd37 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 9 Jul 2020 22:14:24 +0100 Subject: [PATCH] Allow specific P2 queue hooks to be disabled --- .../plotsquared/FaweRegionManager.java | 19 +++++++++++---- .../plotsquared/PlotSquaredFeature.java | 2 +- .../plotsquaredv4/FaweChunkManager.java | 7 ++++++ .../plotsquaredv4/PlotSquaredFeature.java | 2 +- .../java/com/boydti/fawe/config/Settings.java | 24 +++++++++++++------ 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java index 1b9ca2608..6db889f5b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java @@ -16,7 +16,6 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; @@ -62,6 +61,9 @@ public class FaweRegionManager extends RegionManager { @Override public boolean setCuboids(final PlotArea area, final Set regions, final Pattern blocks, final int minY, final int maxY) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.CUBOIDS) { + return parent.setCuboids(area, regions, blocks, minY, maxY); + } TaskManager.IMP.async(() -> { synchronized (FaweRegionManager.class) { World world = BukkitAdapter.adapt(getWorld(area.getWorldName())); @@ -83,7 +85,7 @@ public class FaweRegionManager extends RegionManager { @Override public boolean notifyClear(PlotManager manager) { - if (!(manager instanceof HybridPlotManager)) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.CLEAR || !(manager instanceof HybridPlotManager)) { return false; } final HybridPlotWorld hpw = ((HybridPlotManager) manager).getHybridPlotWorld(); @@ -92,7 +94,7 @@ public class FaweRegionManager extends RegionManager { @Override public boolean handleClear(final Plot plot, final Runnable whenDone, final PlotManager manager) { - if (!(manager instanceof HybridPlotManager)) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.CLEAR || !(manager instanceof HybridPlotManager)) { return false; } TaskManager.IMP.async(() -> { @@ -123,7 +125,7 @@ public class FaweRegionManager extends RegionManager { Region airRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT + 1), pos2.withY(manager.getWorldHeight())); - Clipboard clipboard = new BlockArrayClipboard(new CuboidRegion(pos1, pos2)); + Clipboard clipboard = new BlockArrayClipboard(new CuboidRegion(pos1.withY(0), pos2.withY(255))); clipboard.setBlocks(bedrockRegion, bedrock); clipboard.setBlocks(fillingRegion, filling); @@ -162,6 +164,9 @@ public class FaweRegionManager extends RegionManager { @Override public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.COPY_AND_SWAP) { + parent.swap(pos1, pos2, pos3, pos4, whenDone); + } TaskManager.IMP.async(() -> { synchronized (FaweRegionManager.class) { //todo because of the following code this should proably be in the Bukkit module @@ -190,6 +195,9 @@ public class FaweRegionManager extends RegionManager { @Override public void setBiome(CuboidRegion region, int extendBiome, BiomeType biome, String world, Runnable whenDone) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.SET_BIOME) { + parent.setBiome(region, extendBiome, biome, world, whenDone); + } region.expand(BlockVector3.at(extendBiome, 0, extendBiome)); region.expand(BlockVector3.at(-extendBiome, 0, -extendBiome)); TaskManager.IMP.async(() -> { @@ -210,6 +218,9 @@ public class FaweRegionManager extends RegionManager { @Override public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.COPY_AND_SWAP) { + return parent.copyRegion(pos1, pos2, pos3, whenDone); + } TaskManager.IMP.async(() -> { synchronized (FaweRegionManager.class) { World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java index e51494aed..e54c68125 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java @@ -39,7 +39,7 @@ public class PlotSquaredFeature extends FaweMaskManager { public PlotSquaredFeature() { super("PlotSquared"); log.debug("Optimizing PlotSquared"); - if (com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_HOOK) { + if (com.boydti.fawe.config.Settings.IMP.ENABLED_COMPONENTS.PLOTSQUARED_HOOK) { Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS = false; try { setupBlockQueue(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java index b4b11f439..2d3e9b613 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java @@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.regions.plotsquaredv4; import static org.bukkit.Bukkit.getWorld; +import com.boydti.fawe.config.Settings; import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.object.Location; @@ -49,6 +50,9 @@ public class FaweChunkManager extends ChunkManager { @Override public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { + if (!Settings.IMP.PLOTSQUARED_INTEGRATION.COPY_AND_SWAP) { + parent.swap(pos1, pos2, pos3, pos4, whenDone); + } TaskManager.IMP.async(() -> { synchronized (FaweChunkManager.class) { //todo because of the following code this should proably be in the Bukkit module @@ -77,6 +81,9 @@ public class FaweChunkManager extends ChunkManager { @Override public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) { + if (!Settings.IMP.PLOTSQUARED_INTEGRATION.COPY_AND_SWAP) { + return parent.copyRegion(pos1, pos2, pos3, whenDone); + } TaskManager.IMP.async(() -> { synchronized (FaweChunkManager.class) { World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java index d1df6b58d..059fe87c8 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java @@ -41,7 +41,7 @@ public class PlotSquaredFeature extends FaweMaskManager { public PlotSquaredFeature() { super("PlotSquared"); log.debug("Optimizing PlotSquared"); - if (com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_HOOK) { + if (com.boydti.fawe.config.Settings.IMP.ENABLED_COMPONENTS.PLOTSQUARED_HOOK) { Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS = false; try { setupBlockQueue(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java index 2a74551d5..0e1309e9c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java @@ -14,8 +14,6 @@ public class Settings extends Config { @Ignore public boolean PROTOCOL_SUPPORT_FIX = false; - @Ignore - public boolean PLOTSQUARED_HOOK = true; @Comment("These first 6 aren't configurable") // This is a comment @Final // Indicates that this value isn't configurable @@ -46,6 +44,8 @@ public class Settings extends Config { }) public int MAX_MEMORY_PERCENT = 95; + @Create + public ENABLED_COMPONENTS ENABLED_COMPONENTS; @Create public CLIPBOARD CLIPBOARD; @Create @@ -55,6 +55,8 @@ public class Settings extends Config { @Create public WEB WEB; @Create + public PLOTSQUARED_INTEGRATION PLOTSQUARED_INTEGRATION; + @Create public EXTENT EXTENT; @Create public EXPERIMENTAL EXPERIMENTAL; @@ -67,11 +69,16 @@ public class Settings extends Config { @Create public REGION_RESTRICTIONS_OPTIONS REGION_RESTRICTIONS_OPTIONS; @Create - public ENABLED_COMPONENTS ENABLED_COMPONENTS; + public ConfigBlock LIMITS; @Comment("Enable or disable core components") public static final class ENABLED_COMPONENTS { public boolean COMMANDS = true; + @Comment({ + "Disable the FAWE-PlotSquared hook to take over most intense P2 queueing", + "Specific aspects can be turned on and off further below" + }) + public boolean PLOTSQUARED_HOOK = true; } @Comment("Paths for various directories") @@ -103,10 +110,6 @@ public class Settings extends Config { public String MODE = "MEMBER"; } - - @Create // This value will be generated automatically - public ConfigBlock LIMITS; - @Comment({ "The \"default\" limit group affects those without a specific limit permission.", "To grant someone different limits, copy the default limits group", @@ -388,6 +391,13 @@ public class Settings extends Config { public boolean ALLOW_TICK_EXISTING = true; } + public static class PLOTSQUARED_INTEGRATION { + public boolean CLEAR = true; + public boolean CUBOIDS = true; + public boolean COPY_AND_SWAP = true; + public boolean SET_BIOME = true; + } + public static class WEB { @Comment({ "Should download urls be shortened?",