From 8e8bd810b5e822a43bb6fc7a368e3b44344e4030 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 18 Sep 2020 12:38:17 +0100 Subject: [PATCH] Relight after completing P2 operations teporarily fix #629 --- .../plotsquared/FaweRegionManager.java | 19 ++++++++++-- .../com/boydti/fawe/object/RelightMode.java | 31 +++++++++++++++++-- 2 files changed, 45 insertions(+), 5 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 d127afca2..d8f922ef0 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 @@ -1,5 +1,7 @@ package com.boydti.fawe.bukkit.regions.plotsquared; +import com.boydti.fawe.FaweAPI; +import com.boydti.fawe.object.RelightMode; import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.TaskManager; import com.plotsquared.core.configuration.Settings; @@ -75,6 +77,10 @@ public class FaweRegionManager extends RegionManager { } try { session.flushQueue(); + for (CuboidRegion region : regions) { + FaweAPI.fixLighting(world, region, null, + RelightMode.valueOf(com.boydti.fawe.config.Settings.IMP.LIGHTING.MODE)); + } } catch (MaxChangedBlocksException e) { e.printStackTrace(); } @@ -100,7 +106,8 @@ public class FaweRegionManager extends RegionManager { TaskManager.IMP.async(() -> { synchronized (FaweRegionManager.class) { final HybridPlotWorld hybridPlotWorld = ((HybridPlotManager) manager).getHybridPlotWorld(); - EditSession editSession = new EditSessionBuilder(BukkitAdapter.adapt(getWorld(hybridPlotWorld.getWorldName()))).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); + World world = BukkitAdapter.adapt(getWorld(hybridPlotWorld.getWorldName())); + EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); if (!hybridPlotWorld.PLOT_SCHEMATIC || !Settings.Schematics.PASTE_ON_TOP) { final BlockType bedrock; @@ -153,7 +160,8 @@ public class FaweRegionManager extends RegionManager { } editSession.flushQueue(); - + FaweAPI.fixLighting(world, new CuboidRegion(plot.getBottomAbs().getBlockVector3(), plot.getTopAbs().getBlockVector3()), null, + RelightMode.valueOf(com.boydti.fawe.config.Settings.IMP.LIGHTING.MODE)); TaskManager.IMP.task(whenDone); } }); @@ -185,6 +193,10 @@ public class FaweRegionManager extends RegionManager { } catch (MaxChangedBlocksException e) { e.printStackTrace(); } + FaweAPI.fixLighting(pos1World, new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()), null, + RelightMode.valueOf(com.boydti.fawe.config.Settings.IMP.LIGHTING.MODE)); + FaweAPI.fixLighting(pos1World, new CuboidRegion(pos3.getBlockVector3(), pos4.getBlockVector3()), null, + RelightMode.valueOf(com.boydti.fawe.config.Settings.IMP.LIGHTING.MODE)); TaskManager.IMP.task(whenDone); } }); @@ -229,6 +241,9 @@ public class FaweRegionManager extends RegionManager { try { Operations.completeLegacy(copy); to.flushQueue(); + FaweAPI.fixLighting(pos1World, + new CuboidRegion(pos3.getBlockVector3(), pos3.getBlockVector3().add(pos2.getBlockVector3().subtract(pos1.getBlockVector3()))), + null, RelightMode.valueOf(com.boydti.fawe.config.Settings.IMP.LIGHTING.MODE)); } catch (MaxChangedBlocksException e) { e.printStackTrace(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/RelightMode.java b/worldedit-core/src/main/java/com/boydti/fawe/object/RelightMode.java index 23b84c15e..a8d448e5a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/RelightMode.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/RelightMode.java @@ -1,7 +1,32 @@ package com.boydti.fawe.object; +import java.util.HashMap; +import java.util.Map; + public enum RelightMode { - NONE, // no relighting - OPTIMAL, // relight changed light sources and changed blocks - ALL // relight every single block + NONE(0), // no relighting + OPTIMAL(1), // relight changed light sources and changed blocks + ALL(2); // relight every single block + + private static final Map map = new HashMap<>(); + + static { + for (RelightMode mode : RelightMode.values()) { + map.put(mode.mode, mode); + } + } + + private final int mode; + + RelightMode(int mode) { + this.mode = mode; + } + + public static RelightMode valueOf(int mode) { + return map.get(mode); + } + + public int getMode() { + return mode; + } }