3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 04:20:06 +01:00

Lighting and Database changes

Dieser Commit ist enthalten in:
MattBDev 2020-02-18 17:21:09 -05:00
Ursprung 175b3a93ce
Commit 39dfc2444b
22 geänderte Dateien mit 93 neuen und 285 gelöschten Zeilen

Datei anzeigen

@ -7,7 +7,6 @@ import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.object.changeset.SimpleChangeSetSummary; import com.boydti.fawe.object.changeset.SimpleChangeSetSummary;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.LightingExtent;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
@ -114,27 +113,6 @@ public class FaweAPI {
// return parser != null; // return parser != null;
// } // }
public static <T> T getParser(Class<T> parserClass) {
try {
Field field = AbstractFactory.class.getDeclaredField("parsers");
field.setAccessible(true);
ArrayList<InputParser> parsers = new ArrayList<>();
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getMaskFactory()));
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getBlockFactory()));
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getItemFactory()));
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getPatternFactory()));
for (InputParser parser : parsers) {
if (parserClass.isAssignableFrom(parser.getClass())) {
return (T) parser;
}
}
return null;
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
/** /**
* You can either use a IQueueExtent or an EditSession to change blocks<br> * You can either use a IQueueExtent or an EditSession to change blocks<br>
* - The IQueueExtent skips a bit of overhead so it's marginally faster<br> * - The IQueueExtent skips a bit of overhead so it's marginally faster<br>
@ -399,30 +377,30 @@ public class FaweAPI {
* @return * @return
*/ */
public static int fixLighting(World world, Region selection, @Nullable IQueueExtent queue) { public static int fixLighting(World world, Region selection, @Nullable IQueueExtent queue) {
final BlockVector3 bot = selection.getMinimumPoint(); // final BlockVector3 bot = selection.getMinimumPoint();
final BlockVector3 top = selection.getMaximumPoint(); // final BlockVector3 top = selection.getMaximumPoint();
//
final int minX = bot.getBlockX() >> 4; // final int minX = bot.getBlockX() >> 4;
final int minZ = bot.getBlockZ() >> 4; // final int minZ = bot.getBlockZ() >> 4;
//
final int maxX = top.getBlockX() >> 4; // final int maxX = top.getBlockX() >> 4;
final int maxZ = top.getBlockZ() >> 4; // final int maxZ = top.getBlockZ() >> 4;
//
int count = 0; // int count = 0;
if (queue == null) queue = createQueue(world, false); // if (queue == null) queue = createQueue(world, false);
// Remove existing lighting first // // Remove existing lighting first
if (queue instanceof LightingExtent) { // if (queue instanceof LightingExtent) {
LightingExtent relighter = (LightingExtent) queue; // LightingExtent relighter = (LightingExtent) queue;
for (int x = minX; x <= maxX; x++) { // for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) { // for (int z = minZ; z <= maxZ; z++) {
relighter.relightChunk(x, z); // relighter.relightChunk(x, z);
count++; // count++;
} // }
} // }
} else { // } else {
throw new UnsupportedOperationException("Queue is not " + LightingExtent.class); // throw new UnsupportedOperationException("Queue is not " + LightingExtent.class);
} // }
return count; return 0;
} }
/** /**

Datei anzeigen

@ -1,48 +1,25 @@
package com.boydti.fawe.database; package com.boydti.fawe.database
import com.boydti.fawe.config.Config; import com.boydti.fawe.config.Config
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World
import java.util.Map; import org.slf4j.LoggerFactory
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DBHandler { object DBHandler {
private val log = LoggerFactory.getLogger(Config::class.java)
private final Logger log = LoggerFactory.getLogger(Config.class); private val databases: MutableMap<String, RollbackDatabase> = ConcurrentHashMap(8, 0.9f, 1)
fun getDatabase(world: World): RollbackDatabase? {
public final static DBHandler IMP = new DBHandler(); val worldName = world.name
var database = databases[worldName]
private Map<String, RollbackDatabase> databases = new ConcurrentHashMap<>(8, 0.9f, 1); return database
?: try {
public RollbackDatabase getDatabase(World world) { database = RollbackDatabase(world)
String worldName = world.getName(); databases[worldName] = database
RollbackDatabase database = databases.get(worldName); database
if (database != null) { } catch (e: Throwable) {
return database; log.error("No JDBC driver found!\n TODO: Bundle driver with FAWE (or disable database)", e)
} null
try { }
database = new RollbackDatabase(world);
databases.put(worldName, database);
return database;
} catch (Throwable e) {
log.error("No JDBC driver found!\n TODO: Bundle driver with FAWE (or disable database)", e);
return null;
}
} }
public RollbackDatabase getDatabase(String world) {
RollbackDatabase database = databases.get(world);
if (database != null) {
return database;
}
try {
database = new RollbackDatabase(world);
databases.put(world, database);
return database;
} catch (Throwable e) {
e.printStackTrace();
return null;
}
}
} }

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.database; package com.boydti.fawe.database;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.collection.YieldIterable; import com.boydti.fawe.object.collection.YieldIterable;
@ -40,26 +39,22 @@ public class RollbackDatabase extends AsyncNotifyQueue {
private final World world; private final World world;
private Connection connection; private Connection connection;
private @Language("sql") String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `{0}edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL, `time` INT NOT NULL,`x1` INT NOT NULL,`x2` INT NOT NULL,`z1` INT NOT NULL,`z2` INT NOT NULL,`y1` INT NOT NULL, `y2` INT NOT NULL, `size` INT NOT NULL, `command` VARCHAR, PRIMARY KEY (player, id))"; private @Language("SQLite") String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `{0}edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL, `time` INT NOT NULL,`x1` INT NOT NULL,`x2` INT NOT NULL,`z1` INT NOT NULL,`z2` INT NOT NULL,`y1` INT NOT NULL, `y2` INT NOT NULL, `size` INT NOT NULL, `command` VARCHAR, PRIMARY KEY (player, id))";
private @Language("sql") String UPDATE_TABLE1 = "ALTER TABLE `{0}edits` ADD COLUMN `command` VARCHAR"; private @Language("SQLite") String UPDATE_TABLE1 = "ALTER TABLE `{0}edits` ADD COLUMN `command` VARCHAR";
private @Language("sql") String UPDATE_TABLE2 = "alter table `{0}edits` add size int default 0 not null"; private @Language("SQLite") String UPDATE_TABLE2 = "alter table `{0}edits` add size int default 0 not null";
private @Language("sql") String INSERT_EDIT = "INSERT OR REPLACE INTO `{0}edits` (`player`,`id`,`time`,`x1`,`x2`,`z1`,`z2`,`y1`,`y2`,`command`,`size`) VALUES(?,?,?,?,?,?,?,?,?,?,?)"; private @Language("SQLite") String INSERT_EDIT = "INSERT OR REPLACE INTO `{0}edits` (`player`,`id`,`time`,`x1`,`x2`,`z1`,`z2`,`y1`,`y2`,`command`,`size`) VALUES(?,?,?,?,?,?,?,?,?,?,?)";
private @Language("sql") String PURGE = "DELETE FROM `{0}edits` WHERE `time`<?"; private @Language("SQLite") String PURGE = "DELETE FROM `{0}edits` WHERE `time`<?";
private @Language("sql") String GET_EDITS_USER = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC"; private @Language("SQLite") String GET_EDITS_USER = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC";
private @Language("sql") String GET_EDITS_USER_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC"; private @Language("SQLite") String GET_EDITS_USER_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC";
private @Language("sql") String GET_EDITS = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` DESC, `id` DESC"; private @Language("SQLite") String GET_EDITS = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` DESC, `id` DESC";
private @Language("sql") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` , `id` "; private @Language("SQLite") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` , `id` ";
private @Language("sql") String GET_EDIT_USER = "SELECT * FROM `{0}edits` WHERE `player`=? AND `id`=?"; private @Language("SQLite") String GET_EDIT_USER = "SELECT * FROM `{0}edits` WHERE `player`=? AND `id`=?";
private @Language("sql") String DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?"; private @Language("SQLite") String DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?";
private @Language("sql") String DELETE_EDIT_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `id`=?"; private @Language("SQLite") String DELETE_EDIT_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `id`=?";
private ConcurrentLinkedQueue<RollbackOptimizedHistory> historyChanges = new ConcurrentLinkedQueue<>(); private ConcurrentLinkedQueue<RollbackOptimizedHistory> historyChanges = new ConcurrentLinkedQueue<>();
public RollbackDatabase(String world) throws SQLException, ClassNotFoundException {
this(FaweAPI.getWorld(world));
}
public RollbackDatabase(World world) throws SQLException, ClassNotFoundException { public RollbackDatabase(World world) throws SQLException, ClassNotFoundException {
super((t, e) -> e.printStackTrace()); super((t, e) -> e.printStackTrace());
this.prefix = ""; this.prefix = "";

Datei anzeigen

@ -96,7 +96,7 @@ public class RollbackOptimizedHistory extends DiskStorageHistory {
public void close() throws IOException { public void close() throws IOException {
super.close(); super.close();
// Save to DB // Save to DB
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld()); RollbackDatabase db = DBHandler.INSTANCE.getDatabase(getWorld());
if (db != null) { if (db != null) {
db.logEdit(this); db.logEdit(this);
} }

Datei anzeigen

@ -77,7 +77,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
final int y = target.getBlockY(); final int y = target.getBlockY();
final int z = target.getBlockZ(); final int z = target.getBlockZ();
World world = player.getWorld(); World world = player.getWorld();
RollbackDatabase db = DBHandler.IMP.getDatabase(world); RollbackDatabase db = DBHandler.INSTANCE.getDatabase(world);
System.out.println("World " + world.getName()); System.out.println("World " + world.getName());
int count = 0; int count = 0;
for (Supplier<RollbackOptimizedHistory> supplier : db.getEdits(target, false)) { for (Supplier<RollbackOptimizedHistory> supplier : db.getEdits(target, false)) {

Datei anzeigen

@ -121,10 +121,9 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
@Override @Override
public void delete() { public void delete() {
// Fawe.debug("Deleting history: " + getWorld().getName() + "/" + uuid + "/" + index);
deleteFiles(); deleteFiles();
if (Settings.IMP.HISTORY.USE_DATABASE) { if (Settings.IMP.HISTORY.USE_DATABASE) {
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld()); RollbackDatabase db = DBHandler.INSTANCE.getDatabase(getWorld());
db.delete(uuid, index); db.delete(uuid, index);
} }
} }

Datei anzeigen

@ -133,61 +133,6 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
return super.getBlock(position); return super.getBlock(position);
} }
@Override
public int getBlockLight(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getBlockLight(x, y, z);
}
@Override
public int getBrightness(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getBrightness(x, y, z);
}
@Override
public int getLight(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getLight(x, y, z);
}
@Override
public int getOpacity(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getOpacity(x, y, z);
}
@Override
public int getSkyLight(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getSkyLight(x, y, z);
}
@Nullable @Nullable
@Override @Override
public Entity createEntity(Location location, BaseEntity entity) { public Entity createEntity(Location location, BaseEntity entity) {

Datei anzeigen

@ -1,17 +0,0 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.extent.Extent;
public interface LightingExtent extends Extent {
int getLight(int x, int y, int z);
int getSkyLight(int x, int y, int z);
int getBlockLight(int x, int y, int z);
int getOpacity(int x, int y, int z);
int getBrightness(int x, int y, int z);
public void relightChunk(int chunkX, int chunkZ);
}

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -17,10 +16,10 @@ public class BlockLightMask extends AbstractExtentMask {
@Override @Override
public boolean test(Extent extent, BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) { // if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getBlockLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); // int light = ((LightingExtent) extent).getBlockLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; // return light >= min && light <= max;
} // }
return false; return false;
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -17,10 +16,10 @@ public class BrightnessMask extends AbstractExtentMask {
@Override @Override
public boolean test(Extent extent, BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) { // if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getBrightness(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); // int light = ((LightingExtent) extent).getBrightness(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; // return light >= min && light <= max;
} // }
return false; return false;
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -17,10 +16,10 @@ public class LightMask extends AbstractExtentMask {
@Override @Override
public boolean test(Extent extent, BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) { // if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); // int light = ((LightingExtent) extent).getLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; // return light >= min && light <= max;
} // }
return false; return false;
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -17,10 +16,10 @@ public class OpacityMask extends AbstractExtentMask {
@Override @Override
public boolean test(Extent extent, BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) { // if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getOpacity(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); // int light = ((LightingExtent) extent).getOpacity(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; // return light >= min && light <= max;
} // }
return false; return false;
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -18,11 +17,11 @@ public class SkyLightMask extends AbstractExtentMask {
@Override @Override
public boolean test(Extent extent, BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) { // if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent) // int light = ((LightingExtent) extent)
.getSkyLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); // .getSkyLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max; // return light >= min && light <= max;
} // }
return false; return false;
} }

Datei anzeigen

@ -4,9 +4,6 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
/**
* Restricts the
*/
public class XAxisMask extends AbstractMask implements ResettableMask { public class XAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1; private transient int layer = -1;

Datei anzeigen

@ -4,9 +4,6 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
/**
* Restricts the
*/
public class YAxisMask extends AbstractMask implements ResettableMask { public class YAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1; private transient int layer = -1;

Datei anzeigen

@ -4,9 +4,6 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
/**
* Restricts the
*/
public class ZAxisMask extends AbstractMask implements ResettableMask { public class ZAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1; private transient int layer = -1;

Datei anzeigen

@ -12,6 +12,6 @@ public class ChatProgressTracker extends DefaultProgressTracker {
@Override @Override
public void sendTile(Component title, Component sub) { public void sendTile(Component title, Component sub) {
getPlayer().print(TextComponent.builder().append(title).append("\n").append(sub).build()); getPlayer().print(TextComponent.builder().append(title).append(TextComponent.newline()).append(sub).build());
} }
} }

Datei anzeigen

@ -15,11 +15,12 @@ import com.sk89q.worldedit.regions.AbstractRegion;
import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.Iterator; import java.util.Iterator;
import org.jetbrains.annotations.NotNull;
public class FuzzyRegion extends AbstractRegion { public class FuzzyRegion extends AbstractRegion {
private final Mask mask; private final Mask mask;
private BlockVectorSet set = new BlockVectorSet(); private final BlockVectorSet set = new BlockVectorSet();
private int minX, minY, minZ, maxX, maxY, maxZ; private int minX, minY, minZ, maxX, maxY, maxZ;
private Extent extent; private Extent extent;
@ -44,24 +45,22 @@ public class FuzzyRegion extends AbstractRegion {
} }
public void select(int x, int y, int z) { public void select(int x, int y, int z) {
RecursiveVisitor search = new RecursiveVisitor(mask.withExtent(extent), new RegionFunction() { RecursiveVisitor search = new RecursiveVisitor(mask.withExtent(extent), p -> {
@Override setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
public boolean apply(BlockVector3 p) throws WorldEditException { return true;
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
return true;
}
}, 256); }, 256);
search.setVisited(set); search.setVisited(set);
search.visit(BlockVector3.at(x, y, z)); search.visit(BlockVector3.at(x, y, z));
Operations.completeBlindly(search); Operations.completeBlindly(search);
} }
@NotNull
@Override @Override
public Iterator<BlockVector3> iterator() { public Iterator<BlockVector3> iterator() {
return set.iterator(); return set.iterator();
} }
private final void setMinMax(int x, int y, int z) { private void setMinMax(int x, int y, int z) {
if (x > maxX) { if (x > maxX) {
maxX = x; maxX = x;
} }

Datei anzeigen

@ -179,7 +179,7 @@ public class HistorySubCommands {
BlockVector3 BlockVector3
.at(summary.maxX, 255, summary.maxZ)); .at(summary.maxX, 255, summary.maxZ));
rollback.setTime(historyFile.lastModified()); rollback.setTime(historyFile.lastModified());
RollbackDatabase db = DBHandler.IMP RollbackDatabase db = DBHandler.INSTANCE
.getDatabase(world); .getDatabase(world);
db.logEdit(rollback); db.logEdit(rollback);
actor.print("Logging: " + historyFile); actor.print("Logging: " + historyFile);

Datei anzeigen

@ -81,7 +81,7 @@ public class ProvideBindings extends Bindings {
@Binding @Binding
public RollbackDatabase database(World world) { public RollbackDatabase database(World world) {
return DBHandler.IMP.getDatabase(world); return DBHandler.INSTANCE.getDatabase(world);
} }
@AllowedRegion(FaweMaskManager.MaskType.OWNER) @AllowedRegion(FaweMaskManager.MaskType.OWNER)

Datei anzeigen

@ -26,7 +26,6 @@ import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.object.HistoryExtent; import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.object.changeset.AbstractChangeSet; import com.boydti.fawe.object.changeset.AbstractChangeSet;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.LightingExtent;
import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -52,7 +51,7 @@ import org.jetbrains.annotations.Range;
/** /**
* A base class for {@link Extent}s that merely passes extents onto another. * A base class for {@link Extent}s that merely passes extents onto another.
*/ */
public class AbstractDelegateExtent implements Extent, LightingExtent { public class AbstractDelegateExtent implements Extent {
private final Extent extent; private final Extent extent;
@ -201,54 +200,6 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
return extent.setBiome(position.getX(), 0, position.getZ(), biome); return extent.setBiome(position.getX(), 0, position.getZ(), biome);
} }
@Override
public int getSkyLight(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getSkyLight(x, y, z);
}
return 0;
}
@Override
public int getBlockLight(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getBlockLight(x, y, z);
}
return getBrightness(x, y, z);
}
@Override
public int getOpacity(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getOpacity(x, y, z);
}
return getBlock(x, y, z).getBlockType().getMaterial().getLightOpacity();
}
@Override
public int getLight(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getLight(x, y, z);
}
return 0;
}
@Override
public int getBrightness(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getBrightness(x, y, z);
}
return getBlock(x, y, z).getBlockType().getMaterial().getLightValue();
}
@Override
public void relightChunk(int chunkX, int chunkZ) {
if (extent instanceof LightingExtent) {
((LightingExtent) extent).relightChunk(chunkX, chunkZ);
} else {
throw new UnsupportedOperationException("Cannot relight");
}
}
@Override @Override
public String toString() { public String toString() {
return super.toString() + ":" + (extent == this ? "" : extent.toString()); return super.toString() + ":" + (extent == this ? "" : extent.toString());

Datei anzeigen

@ -22,7 +22,6 @@ package com.sk89q.worldedit.world;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.beta.IChunkCache; import com.boydti.fawe.beta.IChunkCache;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -134,10 +133,6 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
* @return the light level (0-15) * @return the light level (0-15)
*/ */
default int getBlockLightLevel(BlockVector3 position) { default int getBlockLightLevel(BlockVector3 position) {
if (this instanceof LightingExtent) {
LightingExtent extent = (LightingExtent) this;
return extent.getBlockLight(position.getX(), position.getY(), position.getZ());
}
return getBlock(position).getMaterial().getLightValue(); return getBlock(position).getMaterial().getLightValue();
} }