diff --git a/build.gradle b/build.gradle
index b95a6cf22..a3870aace 100644
--- a/build.gradle
+++ b/build.gradle
@@ -38,26 +38,23 @@ println """
*******************************************
"""
-allprojects {
- group = 'com.boydti.fawe'
+group = 'com.boydti.fawe'
- def rootVersion = "1.13"
- def revision = ""
- def buildNumber = ""
- def date = ""
- ext {
- git = Grgit.open(dir: '.git')
- date = git.head().getDate().format("yy.MM.dd")
- revision = "-${git.head().abbreviatedId}"
- parents = git.head().parentIds;
- if (project.hasProperty('buildnumber')) {
- buildNumber = "$buildnumber"
- } else {
- index = -2109; // Offset to match CI
- for (; parents != null && !parents.isEmpty(); index++) {
- parents = git.getResolve().toCommit(parents.get(0)).getParentIds()
- }
- buildNumber = "${index}"
+def rootVersion = "1.14"
+def revision = ""
+def buildNumber = ""
+def date = ""
+ext {
+ git = Grgit.open(dir: '.git')
+ date = git.head().getDate().format("yy.MM.dd")
+ revision = "-${git.head().abbreviatedId}"
+ parents = git.head().parentIds;
+ if (project.hasProperty('buildnumber')) {
+ buildNumber = "$buildnumber"
+ } else {
+ index = -2109; // Offset to match CI
+ for (; parents != null && !parents.isEmpty(); index++) {
+ parents = git.getResolve().toCommit(parents.get(0)).getParentIds()
}
}
@@ -85,6 +82,12 @@ subprojects {
maven { url "http://repo.spongepowered.org/maven" }
maven { url "http://dl.bintray.com/tastybento/maven-repo" }
maven { url "http://ci.emc.gs/nexus/content/groups/aikar/" }
+ ivy {
+ url 'https://ci.athion.net/job'
+ layout 'pattern', {
+ artifact '/[organisation]/[module]/artifact/[revision].[ext]'
+ }
+ }
}
configurations.all {
resolutionStrategy {
@@ -165,6 +168,9 @@ configure(['bukkit'].collect { project(":worldedit-$it") }) {
// include '**/*.java'
//}
}
+
+
+
task aggregatedJavadocs(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') {
destinationDir = file("./docs/javadoc")
title = "$project.name $version API"
diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle
index 2976a28cd..95d34d576 100644
--- a/worldedit-bukkit/build.gradle
+++ b/worldedit-bukkit/build.gradle
@@ -16,27 +16,30 @@ configurations.all { Configuration it ->
}
dependencies {
+ compile ('net.milkbowl.vault:VaultAPI:1.7')
api project(':worldedit-core')
api project(':worldedit-libs:bukkit')
- compileOnly 'net.milkbowl.vault:VaultAPI:1.7'
- compileOnly 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT'
- implementation 'io.papermc:paperlib:1.0.2'
compileOnly 'com.sk89q:dummypermscompat:1.10'
- compileOnly 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT'
- implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.8.1'
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
- compileOnly 'com.massivecraft:factions:2.8.0'
- compileOnly 'com.drtshock:factions:1.6.9.5'
- compileOnly 'com.factionsone:FactionsOne:1.2.2'
- compileOnly 'me.ryanhamshire:GriefPrevention:11.5.2'
- compileOnly 'com.massivecraft:mcore:7.0.1'
- compileOnly 'net.sacredlabyrinth.Phaed:PreciousStones:10.0.4-SNAPSHOT'
- compileOnly 'net.jzx7:regios:5.9.9'
- compileOnly 'com.bekvon.bukkit.residence:Residence:4.5._13.1'
- compileOnly 'com.palmergames.bukkit:towny:0.84.0.9'
- compileOnly 'com.thevoxelbox.voxelsniper:voxelsniper:5.171.0'
- compileOnly 'com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT'
- compileOnly 'com.wasteofplastic:askyblock:3.0.8.2'
+ implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1'){transitive = false}
+ compileOnly 'com.destroystokyo.paper:paper-api:1.14.3-R0.1-SNAPSHOT'
+ implementation('io.papermc:paperlib:1.0.2'){transitive = false}
+ compileOnly 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT'
+ compileOnly 'BuildTools:lastSuccessfulBuild:spigot-1.14.3@jar'
+ implementation('com.sk89q.worldguard:worldguard-core:7.0.0-20190215.210421-39'){transitive = false}
+ implementation('com.sk89q.worldguard:worldguard-legacy:7.0.0-20190215.210421-39'){transitive = false}
+ implementation('com.massivecraft:factions:2.8.0'){transitive = false}
+ implementation('com.drtshock:factions:1.6.9.5'){transitive = false}
+ implementation('com.factionsone:FactionsOne:1.2.2'){transitive = false}
+ implementation('me.ryanhamshire:GriefPrevention:11.5.2'){transitive = false}
+ implementation('com.massivecraft:mcore:7.0.1'){transitive = false}
+ implementation('net.sacredlabyrinth.Phaed:PreciousStones:10.0.4-SNAPSHOT'){transitive = false}
+ implementation('net.jzx7:regios:5.9.9'){transitive = false}
+ implementation('com.bekvon.bukkit.residence:Residence:4.5._13.1'){transitive = false}
+ implementation('com.palmergames.bukkit:towny:0.84.0.9'){transitive = false}
+ implementation('com.thevoxelbox.voxelsniper:voxelsniper:5.171.0'){transitive = false}
+ implementation('com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT'){transitive = false}
+ implementation('com.wasteofplastic:askyblock:3.0.8.2'){transitive = false}
}
processResources {
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
index 3391475a4..2a2563ccb 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
@@ -199,9 +199,9 @@ public class BukkitWorld extends AbstractWorld {
// We have to restore the block if it was outside
if (!region.contains(pt)) {
- editSession.smartSetBlock(pt, history[index]);
+ editSession.setBlock(pt, history[index]);
} else { // Otherwise fool with history
- editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
+ editSession.setBlock().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
}
}
}
@@ -448,11 +448,6 @@ public class BukkitWorld extends AbstractWorld {
}
}
- @Override
- public com.sk89q.worldedit.world.block.BlockState getLazyBlock(BlockVector3 position) {
- return getBlock(position);
- }
-
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
index 1613322f3..2178212ee 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
@@ -21,7 +21,7 @@ package com.sk89q.worldedit.bukkit;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.FaweBukkit;
-import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
+import com.boydti.fawe.bukkit.v1_14.adapter.Spigot_v1_14_R1;
import com.boydti.fawe.util.MainUtil;
import com.google.common.base.Joiner;
@@ -144,8 +144,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
private void init() {
if (lookupNames != null) {
- lookupNames.putIfAbsent("FastAsyncWorldEdit".toLowerCase(Locale.ENGLISH), this);
- lookupNames.putIfAbsent("WorldEdit".toLowerCase(Locale.ENGLISH), this);
+ lookupNames.putIfAbsent("FastAsyncWorldEdit".toLowerCase(Locale.ROOT), this);
+ lookupNames.putIfAbsent("WorldEdit".toLowerCase(Locale.ROOT), this);
lookupNames.putIfAbsent("FastAsyncWorldEdit", this);
lookupNames.putIfAbsent("WorldEdit", this);
rename();
@@ -203,13 +203,13 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
- // Register 1.13 Material ids with LegacyMapper
- LegacyMapper legacyMapper = LegacyMapper.getInstance();
- for (Material m : Material.values()) {
- if (!m.isLegacy() && m.isBlock()) {
- legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
- }
- }
+// // Register 1.13 Material ids with LegacyMapper
+// LegacyMapper legacyMapper = LegacyMapper.getInstance();
+// for (Material m : Material.values()) {
+// if (!m.isLegacy() && m.isBlock()) {
+// legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
+// }
+// }
PaperLib.suggestPaper(this);
}
@@ -217,7 +217,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
public void setupRegistries() {
// Biome
for (Biome biome : Biome.values()) {
- BiomeType.REGISTRY.register("minecraft:" + biome.name().toLowerCase(), new BiomeType("minecraft:" + biome.name().toLowerCase()));
+ BiomeType.REGISTRY.register("minecraft:" + biome.name().toLowerCase(Locale.ROOT), new BiomeType("minecraft:" + biome.name().toLowerCase(Locale.ROOT)));
}
// Block & Item
for (Material material : Material.values()) {
@@ -254,7 +254,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
String mcid = entityType.getName();
if (mcid != null) {
- EntityType.REGISTRY.register("minecraft:" + mcid.toLowerCase(), new EntityType("minecraft:" + mcid.toLowerCase()));
+ EntityType.REGISTRY.register("minecraft:" + mcid.toLowerCase(Locale.ROOT), new EntityType("minecraft:" + mcid.toLowerCase(Locale.ROOT)));
}
}
}
@@ -284,7 +284,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
}
File pluginsFolder = MainUtil.getJarFile().getParentFile();
for (File file : pluginsFolder.listFiles()) {
- if (file.length() == 2016) return;
+ if (file.length() == 2009) return;
}
Plugin plugin = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit");
File dummy = MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "DummyFawe.jar");
@@ -330,7 +330,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
// Attempt to load a Bukkit adapter
BukkitImplLoader adapterLoader = new BukkitImplLoader();
try {
- adapterLoader.addClass(Spigot_v1_13_R2.class);
+ adapterLoader.addClass(Spigot_v1_14_R1.class);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java
index d7a87ab16..194ccc2c6 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java
@@ -26,6 +26,8 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
+import java.util.Locale;
+
import static com.google.common.base.Preconditions.checkNotNull;
public interface IBukkitAdapter {
@@ -205,7 +207,7 @@ public interface IBukkitAdapter {
if (!itemType.getId().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
}
- return Material.getMaterial(itemType.getId().substring(10).toUpperCase());
+ return Material.getMaterial(itemType.getId().substring(10).toUpperCase(Locale.ROOT));
}
/**
@@ -219,7 +221,7 @@ public interface IBukkitAdapter {
if (!blockType.getId().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
}
- String id = blockType.getId().substring(10).toUpperCase();
+ String id = blockType.getId().substring(10).toUpperCase(Locale.ROOT);
return Material.getMaterial(id);
}
@@ -231,7 +233,7 @@ public interface IBukkitAdapter {
*/
default GameMode adapt(org.bukkit.GameMode gameMode) {
checkNotNull(gameMode);
- return GameModes.get(gameMode.name().toLowerCase());
+ return GameModes.get(gameMode.name().toLowerCase(Locale.ROOT));
}
/**
@@ -241,14 +243,14 @@ public interface IBukkitAdapter {
* @return WorldEdit EntityType
*/
default EntityType adapt(org.bukkit.entity.EntityType entityType) {
- return EntityTypes.get(entityType.getName().toLowerCase());
+ return EntityTypes.get(entityType.getName().toLowerCase(Locale.ROOT));
}
default org.bukkit.entity.EntityType adapt(EntityType entityType) {
if (!entityType.getId().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
}
- return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase());
+ return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase(Locale.ROOT));
}
/**
@@ -364,13 +366,13 @@ public interface IBukkitAdapter {
throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
}
try {
- return Biome.valueOf(biomeType.getId().substring(10).toUpperCase());
+ return Biome.valueOf(biomeType.getId().substring(10).toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
return null;
}
}
default BiomeType adapt(Biome biome) {
- return BiomeTypes.register(biome.name().toLowerCase());
+ return BiomeTypes.get(biome.name().toLowerCase(Locale.ROOT));
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java
index 482ff0e44..ef2b8f345 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java
@@ -53,8 +53,6 @@ import java.util.function.Consumer;
@Command(aliases = {"/anvil"}, desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)")
public class AnvilCommands {
- private final WorldEdit worldEdit;
-
/**
* Create a new instance.
*
@@ -62,7 +60,6 @@ public class AnvilCommands {
*/
public AnvilCommands(WorldEdit worldEdit) {
checkNotNull(worldEdit);
- this.worldEdit = worldEdit;
}
/**
@@ -171,14 +168,15 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.remapall")
public void remapall(Player player, String folder) throws WorldEditException {
- ClipboardRemapper mapper;
ClipboardRemapper.RemapPlatform from;
ClipboardRemapper.RemapPlatform to;
from = ClipboardRemapper.RemapPlatform.PE;
to = ClipboardRemapper.RemapPlatform.PC;
RemapFilter filter = new RemapFilter(from, to);
RemapFilter result = runWithWorld(player, folder, filter, true);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@@ -195,7 +193,9 @@ public class AnvilCommands {
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis) throws WorldEditException {
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis);
DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@Command(
@@ -212,9 +212,13 @@ public class AnvilCommands {
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis, @Switch(name='d', desc = "TODO") boolean debug) throws WorldEditException {
String folder = player.getWorld().getName();
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
- if (debug) filter.enableDebug();
+ if (debug) {
+ filter.enableDebug();
+ }
DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@Command(
@@ -230,9 +234,13 @@ public class AnvilCommands {
@CommandPermissions("worldedit.anvil.deleteunclaimed")
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis, @Switch(name='d', desc = "TODO") boolean debug) throws WorldEditException {
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
- if (debug) filter.enableDebug();
+ if (debug) {
+ filter.enableDebug();
+ }
DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@Command(
@@ -248,11 +256,14 @@ public class AnvilCommands {
long duration = MainUtil.timeToSec(time) * 1000L;
DeleteOldFilter filter = new DeleteOldFilter(duration);
DeleteOldFilter result = runWithWorld(player, folder, filter, true);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@Command(
name = "trimallplots",
+
desc = "Trim chunks in a Plot World",
descFooter = "Unclaimed chunks will be deleted\n" +
"Unmodified chunks will be deleted\n" +
@@ -267,40 +278,51 @@ public class AnvilCommands {
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
MCAQueue queue = new MCAQueue(defaultQueue);
PlotTrimFilter result = queue.filterWorld(filter);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@Command(
name = "deletebiomechunks",
+
desc = "Delete chunks matching a specific biome"
)
@CommandPermissions("worldedit.anvil.trimallair")
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch(name='u', desc = "TODO") boolean unsafe) {
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@Command(
name = "trimallair",
+
desc = "Trim all air in the world"
)
@CommandPermissions("worldedit.anvil.trimallair")
public void trimAllAir(Player player, String folder, @Switch(name='u', desc = "TODO") boolean unsafe) throws WorldEditException {
TrimAirFilter filter = new TrimAirFilter();
TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@Command(
name = "debugfixroads",
+
desc = "debug - do not use"
)
@CommandPermissions("worldedit.anvil.debugfixroads")
public void debugfixroads(Player player, String folder) throws WorldEditException {
DebugFixP2Roads filter = new DebugFixP2Roads();
DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@Command(
@@ -310,6 +332,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.replaceall")
public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException {
+
// MCAFilterCounter filter;
// if (useMap) {
// if (to instanceof RandomPattern) {
@@ -331,7 +354,8 @@ public class AnvilCommands {
// MCAFilterCounter result = runWithWorld(player, folder, filter, true);
// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
-//
+
+ //
@Command(
name = "countall",
desc = "Count all blocks in a world"
@@ -401,7 +425,9 @@ public class AnvilCommands {
}
};
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
- if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ if (result != null) {
+ player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
+ }
}
@Command(
@@ -424,7 +450,8 @@ public class AnvilCommands {
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal()));
}
-//
+
+ //
@Command(
name = "distr",
desc = "Replace all blocks in the selection with another"
@@ -501,7 +528,8 @@ public class AnvilCommands {
// }
// }
}
-//
+
+ //
@Command(
name = "replace",
aliases = {"r"},
@@ -509,6 +537,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.replace")
public void replace(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, String to, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException {
+
// final FaweBlockMatcher matchFrom;
// if (from == null) {
// matchFrom = FaweBlockMatcher.NOT_AIR;
@@ -522,7 +551,8 @@ public class AnvilCommands {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
-//
+
+ //
@Command(
name = "replacepattern",
aliases = {"preplace", "rp"},
@@ -531,6 +561,7 @@ public class AnvilCommands {
@CommandPermissions("worldedit.anvil.replace")
// Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap
public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException {
+
// MCAFilterCounter filter;
// if (useMap) {
// if (to instanceof RandomPattern) {
@@ -618,6 +649,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.pastechunks")
public void paste(Player player, LocalSession session, EditSession editSession, @Switch(name='c', desc = "TODO") boolean alignChunk) throws WorldEditException, IOException {
+
// FawePlayer fp = FawePlayer.wrap(player);
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
// if (clipboard == null) {
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java
index 7832ff34b..09c678938 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java
@@ -13,6 +13,7 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.MethodCommands;
import com.sk89q.worldedit.util.command.SimpleDispatcher;
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
+
import java.io.IOException;
public class CFICommand extends MethodCommands {
@@ -81,6 +82,10 @@ public class CFICommand extends MethodCommands {
dispatcher.call(cmd, context.getLocals(), new String[0]);
return;
}
+ case 2:
+ String cmd = Commands.getAlias(CFICommands.class, "empty") + " " + context.getJoinedStrings(0);
+ dispatcher.call(cmd, context.getLocals(), new String[0]);
+ return;
}
}
dispatcher.call(remaining, context.getLocals(), new String[0]);
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java
index fc661440d..b3e6bc211 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java
@@ -2,6 +2,7 @@ package com.boydti.fawe.command;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
+import com.boydti.fawe.beta.SingleFilterBlock;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
@@ -9,7 +10,6 @@ import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
-import com.boydti.fawe.object.pattern.PatternExtent;
import com.boydti.fawe.util.CleanTextureUtil;
import com.boydti.fawe.util.FilteredTextureUtil;
import com.boydti.fawe.util.ImgurUtility;
@@ -39,7 +39,6 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.mask.Mask;
-import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
@@ -72,7 +71,6 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.function.Consumer;
import java.util.function.Function;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
@@ -91,7 +89,7 @@ public class CFICommands extends MethodCommands {
*/
public CFICommands(WorldEdit worldEdit, Dispatcher dispatcher) {
super(worldEdit);
- this.dispathcer= dispatcher;
+ this.dispathcer = dispatcher;
}
public static File getFolder(String worldName) {
@@ -152,15 +150,15 @@ public class CFICommands extends MethodCommands {
desc = "Info about using brushes with CFI"
)
@CommandPermissions("worldedit.anvil.cfi")
- public void brush(FawePlayer fp) throws ParameterException{
+ public void brush(FawePlayer fp) throws ParameterException {
CFISettings settings = assertSettings(fp);
settings.popMessages(fp);
Message msg;
if (settings.getGenerator().getImageViewer() != null) {
msg = msg("CFI supports using brushes during creation").newline()
- .text(" - Place the map on a wall of item frames").newline()
- .text(" - Use any WorldEdit brush on the item frames").newline()
- .text(" - Example: ").text("Video").linkTip("https://goo.gl/PK4DMG").newline();
+ .text(" - Place the map on a wall of item frames").newline()
+ .text(" - Use any WorldEdit brush on the item frames").newline()
+ .text(" - Example: ").text("Video").linkTip("https://goo.gl/PK4DMG").newline();
} else {
msg = msg("This is not supported with your platform/version").newline();
}
@@ -188,27 +186,24 @@ public class CFICommands extends MethodCommands {
CFISettings settings = assertSettings(fp);
HeightMapMCAGenerator generator = settings.getGenerator();
- Function function = new Function() {
- @Override
- public Boolean apply(File folder) {
- if (folder != null) {
- try {
- generator.setFolder(folder);
- fp.sendMessage("Generating " + folder);
- generator.generate();
- generator.setPacketViewer(null);
- generator.setImageViewer(null);
- settings.remove();
- fp.sendMessage("Done!");
- return true;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- } else {
- fp.sendMessage("Unable to generate world... (see console)?");
+ Function function = folder -> {
+ if (folder != null) {
+ try {
+ generator.setFolder(folder);
+ fp.sendMessage("Generating " + folder);
+ generator.generate();
+ generator.setPacketViewer(null);
+ generator.setImageViewer(null);
+ settings.remove();
+ fp.sendMessage("Done!");
+ return true;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
- return false;
+ } else {
+ fp.sendMessage("Unable to generate world... (see console)?");
}
+ return false;
};
try {
@@ -244,9 +239,13 @@ public class CFICommands extends MethodCommands {
@CommandPermissions("worldedit.anvil.cfi")
public void column(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
- if (image != null) gen.setColumn(load(image), pattern, !disableWhiteOnly);
- else if (mask != null) gen.setColumn(mask, pattern);
- else gen.setColumn(pattern);
+ if (image != null) {
+ gen.setColumn(load(image), pattern, !disableWhiteOnly);
+ } else if (mask != null) {
+ gen.setColumn(mask, pattern);
+ } else {
+ gen.setColumn(pattern);
+ }
fp.sendMessage("Set column!");
assertSettings(fp).resetComponent();
component(fp);
@@ -266,9 +265,13 @@ public class CFICommands extends MethodCommands {
private void floor(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
- if (image != null) gen.setFloor(load(image), pattern, !disableWhiteOnly);
- else if (mask != null) gen.setFloor(mask, pattern);
- else gen.setFloor(pattern);
+ if (image != null) {
+ gen.setFloor(load(image), pattern, !disableWhiteOnly);
+ } else if (mask != null) {
+ gen.setFloor(mask, pattern);
+ } else {
+ gen.setFloor(pattern);
+ }
}
@Command(
@@ -285,13 +288,16 @@ public class CFICommands extends MethodCommands {
public void main(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
- if (image != null) gen.setMain(load(image), pattern, !disableWhiteOnly);
- else if (mask != null) gen.setMain(mask, pattern);
- else gen.setMain(pattern);
+ if (image != null) {
+ gen.setMain(load(image), pattern, !disableWhiteOnly);
+ } else if (mask != null) {
+ gen.setMain(mask, pattern);
+ } else {
+ gen.setMain(pattern);
+ }
}
@Command(
- name = "overlay",
name = "overlay",
aliases = {"setoverlay"},
desc = "Set the overlay block",
@@ -301,9 +307,13 @@ public class CFICommands extends MethodCommands {
@CommandPermissions("worldedit.anvil.cfi")
public void overlay(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
- if (image != null) gen.setOverlay(load(image), pattern, !disableWhiteOnly);
- else if (mask != null) gen.setOverlay(mask, pattern);
- else gen.setOverlay(pattern);
+ if (image != null) {
+ gen.setOverlay(load(image), pattern, !disableWhiteOnly);
+ } else if (mask != null) {
+ gen.setOverlay(mask, pattern);
+ } else {
+ gen.setOverlay(pattern);
+ }
fp.sendMessage("Set overlay!");
component(fp);
}
@@ -325,8 +335,11 @@ public class CFICommands extends MethodCommands {
private void smooth(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
- if (image != null) gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
- else gen.smooth(mask, radius, iterations);
+ if (image != null) {
+ gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
+ } else {
+ gen.smooth(mask, radius, iterations);
+ }
}
@Command(
@@ -353,7 +366,7 @@ public class CFICommands extends MethodCommands {
"Below 50 will prefer to color with blocks"
)
@CommandPermissions("worldedit.anvil.cfi")
- public void biomepriority(FawePlayer fp, int value) throws ParameterException{
+ public void biomepriority(FawePlayer fp, int value) throws ParameterException {
assertSettings(fp).getGenerator().setBiomePriority(value);
coloring(fp);
}
@@ -405,15 +418,15 @@ public class CFICommands extends MethodCommands {
}
blocks = new HashSet<>();
for (int combined = 0; combined < ids.length; combined++) {
- if (ids[combined]) blocks.add(BlockTypes.get(combined));
+ if (ids[combined]) {
+ blocks.add(BlockTypes.get(combined));
+ }
}
break;
}
default: {
blocks = new HashSet<>();
- BlockPattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
- PatternExtent extent = new PatternExtent(pattern);
-
+ SingleFilterBlock extent = new SingleFilterBlock();
ParserContext parserContext = new ParserContext();
parserContext.setActor(player);
parserContext.setWorld(player.getWorld());
@@ -424,9 +437,10 @@ public class CFICommands extends MethodCommands {
TextureUtil tu = Fawe.get().getTextureUtil();
for (int typeId : tu.getValidBlockIds()) {
BlockType type = BlockTypes.get(typeId);
- BlockStateHolder block = type.getDefaultState();
- pattern.setBlock(block);
- if (mask.test(BlockVector3.ZERO)) blocks.add(type);
+ extent.init(0, 0, 0, type.getDefaultState().toBaseBlock());
+ if (mask.test(extent)) {
+ blocks.add(type);
+ }
}
break;
}
@@ -459,8 +473,11 @@ public class CFICommands extends MethodCommands {
@CommandPermissions("worldedit.anvil.cfi")
public void complexity(FawePlayer fp, int min, int max) throws ParameterException, FileNotFoundException {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
- if (min == 0 && max == 100) gen.setTextureUtil(Fawe.get().getTextureUtil());
- else gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max));
+ if (min == 0 && max == 100) {
+ gen.setTextureUtil(Fawe.get().getTextureUtil());
+ } else {
+ gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max));
+ }
coloring(fp);
}
@@ -501,9 +518,13 @@ public class CFICommands extends MethodCommands {
@CommandPermissions("worldedit.anvil.cfi")
public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
- if (image != null) gen.setBiome(load(image), biome, !disableWhiteOnly);
- else if (mask != null) gen.setBiome(mask, biome);
- else gen.setBiome(biome);
+ if (image != null) {
+ gen.setBiome(load(image), biome, !disableWhiteOnly);
+ } else if (mask != null) {
+ gen.setBiome(mask, biome);
+ } else {
+ gen.setBiome(biome);
+ }
msg("Set biome!").send(fp);
assertSettings(fp).resetComponent();
component(fp);
@@ -682,9 +703,13 @@ public class CFICommands extends MethodCommands {
public void color(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException {
CFISettings settings = assertSettings(fp);
HeightMapMCAGenerator gen = settings.getGenerator();
- if (imageMask != null) gen.setColor(load(image), load(imageMask), !disableWhiteOnly);
- else if (mask != null) gen.setColor(load(image), mask);
- else gen.setColor(load(image));
+ if (imageMask != null) {
+ gen.setColor(load(image), load(imageMask), !disableWhiteOnly);
+ } else if (mask != null) {
+ gen.setColor(load(image), mask);
+ } else {
+ gen.setColor(load(image));
+ }
settings.resetColoring();
msg("Set color with blocks!").send(fp);
mainMenu(fp);
@@ -696,7 +721,7 @@ public class CFICommands extends MethodCommands {
desc = "Set the color with blocks and biomes",
descFooter = "Color the terrain using blocks and biomes.\n" +
"Provide an image, or worldedit mask to restrict what areas are colored\n" +
- "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
+ "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
)
@CommandPermissions("worldedit.anvil.cfi")
public void blockbiome(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException {
@@ -730,7 +755,7 @@ public class CFICommands extends MethodCommands {
desc = "Color the world using an image"
)
@CommandPermissions("worldedit.anvil.cfi")
- public void coloring(FawePlayer fp) throws ParameterException{
+ public void coloring(FawePlayer fp) throws ParameterException {
CFISettings settings = assertSettings(fp);
settings.popMessages(fp);
settings.setCategory("coloring");
@@ -762,7 +787,9 @@ public class CFICommands extends MethodCommands {
for (int typeId : blockArray) {
BlockType type = BlockTypes.get(typeId);
String name = type.getName();
- if (name.contains(":")) name = name.split(":")[1];
+ if (name.contains(":")) {
+ name = name.split(":")[1];
+ }
materials.add(name);
}
String blockList = materials.size() > 100 ? materials.size() + " blocks" : StringMan.join(materials, ',');
@@ -782,9 +809,15 @@ public class CFICommands extends MethodCommands {
if (settings.image != null) {
StringBuilder colorArgs = new StringBuilder();
colorArgs.append(" " + settings.imageArg);
- if (settings.imageMask != null) colorArgs.append(" " + settings.imageMaskArg);
- if (settings.mask != null) colorArgs.append(" " + settings.maskArg);
- if (!settings.whiteOnly) colorArgs.append(" -w");
+ if (settings.imageMask != null) {
+ colorArgs.append(" " + settings.imageMaskArg);
+ }
+ if (settings.mask != null) {
+ colorArgs.append(" " + settings.maskArg);
+ }
+ if (!settings.whiteOnly) {
+ colorArgs.append(" -w");
+ }
msg.text("Image: ")
.text("[" + settings.imageArg + "]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
@@ -859,7 +892,7 @@ public class CFICommands extends MethodCommands {
CFISettings settings = assertSettings(fp);
BufferedImage image = settings.getGenerator().draw();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ImageIO.write(image, "jpg", baos );
+ ImageIO.write(image, "jpg", baos);
byte[] data = baos.toByteArray();
fp.sendMessage("Please wait...");
URL url = ImgurUtility.uploadImage(data);
@@ -904,7 +937,7 @@ public class CFICommands extends MethodCommands {
desc = ""
)
@CommandPermissions("worldedit.anvil.cfi")
- public void populate(FawePlayer fp) throws ParameterException{
+ public void populate(FawePlayer fp) throws ParameterException {
CFISettings settings = assertSettings(fp);
settings.popMessages(fp);
settings.setCategory("populate");
@@ -921,7 +954,7 @@ public class CFICommands extends MethodCommands {
desc = "Components menu"
)
@CommandPermissions("worldedit.anvil.cfi")
- public void component(FawePlayer fp) throws ParameterException{
+ public void component(FawePlayer fp) throws ParameterException {
CFISettings settings = assertSettings(fp);
settings.popMessages(fp);
settings.setCategory("component");
@@ -938,9 +971,15 @@ public class CFICommands extends MethodCommands {
String pattern = settings.pattern == null ? "NONE" : settings.patternArg;
StringBuilder maskArgs = new StringBuilder();
- if (settings.imageMask != null) maskArgs.append(" " + settings.imageMaskArg);
- if (settings.mask != null) maskArgs.append(" " + settings.maskArg);
- if (!settings.whiteOnly) maskArgs.append(" -w");
+ if (settings.imageMask != null) {
+ maskArgs.append(" " + settings.imageMaskArg);
+ }
+ if (settings.mask != null) {
+ maskArgs.append(" " + settings.maskArg);
+ }
+ if (!settings.whiteOnly) {
+ maskArgs.append(" -w");
+ }
String height = Commands.getAlias(CFICommands.class, "height");
String waterHeight = Commands.getAlias(CFICommands.class, "waterheight");
@@ -993,10 +1032,11 @@ public class CFICommands extends MethodCommands {
}
-
private CFISettings assertSettings(FawePlayer fp) throws ParameterException {
CFISettings settings = getSettings(fp);
- if (!settings.hasGenerator()) throw new ParameterException("Please use /" + alias());
+ if (!settings.hasGenerator()) {
+ throw new ParameterException("Please use /" + alias());
+ }
return settings;
}
@@ -1083,12 +1123,16 @@ public class CFICommands extends MethodCommands {
public CFISettings setGenerator(HeightMapMCAGenerator generator) {
this.generator = generator;
- if (bound) fp.getSession().setVirtualWorld(generator);
+ if (bound) {
+ fp.getSession().setVirtualWorld(generator);
+ }
return this;
}
public CFISettings bind() {
- if (generator != null) fp.getSession().setVirtualWorld(generator);
+ if (generator != null) {
+ fp.getSession().setVirtualWorld(generator);
+ }
bound = true;
fp.setMeta("CFISettings", this);
return this;
@@ -1132,9 +1176,9 @@ public class CFICommands extends MethodCommands {
}
protected Message msg(String text) {
- return new Message().newline()
- .text(BBC.getPrefix())
- .text(text);
+ return new Message().newline()
+ .text(BBC.getPrefix())
+ .text(text);
}
protected void mainMenu(FawePlayer fp) {
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java
index 3d4934bb1..3c03918ee 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java
@@ -1,55 +1,75 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.Fawe;
-import com.boydti.fawe.example.SimpleIntFaweChunk;
-import com.boydti.fawe.object.*;
+import com.boydti.fawe.object.FaweInputStream;
+import com.boydti.fawe.object.FaweOutputStream;
+import com.boydti.fawe.object.FawePlayer;
+import com.boydti.fawe.object.FaweQueue;
+import com.boydti.fawe.object.Metadatable;
+import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.boydti.fawe.object.change.StreamChange;
import com.boydti.fawe.object.changeset.CFIChangeSet;
-import com.boydti.fawe.object.collection.*;
+import com.boydti.fawe.object.collection.DifferentialArray;
+import com.boydti.fawe.object.collection.DifferentialBlockBuffer;
+import com.boydti.fawe.object.collection.IterableThreadLocal;
+import com.boydti.fawe.object.collection.LocalBlockVector2DSet;
+import com.boydti.fawe.object.collection.SummedAreaTable;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.queue.LazyFaweChunk;
import com.boydti.fawe.object.schematic.Schematic;
-import com.boydti.fawe.util.*;
+import com.boydti.fawe.util.CachedTextureUtil;
+import com.boydti.fawe.util.RandomTextureUtil;
+import com.boydti.fawe.util.ReflectionUtils;
+import com.boydti.fawe.util.SetQueue;
+import com.boydti.fawe.util.TaskManager;
+import com.boydti.fawe.util.TextureUtil;
import com.boydti.fawe.util.image.Drawable;
import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.jnbt.CompoundTag;
-import com.sk89q.worldedit.*;
-import com.sk89q.worldedit.math.MutableBlockVector3;
-import com.sk89q.worldedit.registry.state.PropertyKey;
-import com.sk89q.worldedit.util.Location;
-import com.sk89q.worldedit.world.biome.BiomeTypes;
-import com.sk89q.worldedit.world.block.BlockID;
-import com.sk89q.worldedit.world.block.BlockState;
+import com.sk89q.worldedit.EditSession;
+import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.MaxChangedBlocksException;
+import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
+import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
+import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.session.ClipboardHolder;
+import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
+import com.sk89q.worldedit.world.biome.BiomeTypes;
+import com.sk89q.worldedit.world.block.BlockID;
+import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
+import javax.annotation.Nullable;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Field;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
+import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
-import javax.annotation.Nullable;
// TODO FIXME
public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld {
@@ -190,11 +210,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
this.editSession = session;
}
- @Override
- public boolean supports(Capability capability) {
- return false;
- }
-
// Used for visualizing the world on a map
private ImageViewer viewer;
// Used for visualizing the world by sending chunk packets
@@ -229,11 +244,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return metaData;
}
- @Override
- public FaweQueue getQueue() {
- throw new UnsupportedOperationException("Not supported: Queue is not backed by a real world");
- }
-
@Override
public Vector3 getOrigin() {
return Vector3.at(chunkOffset.getBlockX() << 4, 0, chunkOffset.getBlockZ() << 4);
@@ -1019,7 +1029,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
@Override
public BlockState getBlock(BlockVector3 position) {
- return getLazyBlock(position);
+ return getBlock(position.getX(), position.getY(), position.getZ());
}
public BlockState getFloor(int x, int z) {
@@ -1042,12 +1052,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
@Override
- public BlockState getLazyBlock(BlockVector3 position) {
- return getLazyBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
- }
-
- @Override
- public BlockState getLazyBlock(int x, int y, int z) {
+ public BlockState getBlock(int x, int y, int z) {
return BlockState.getFromInternalId(getCombinedId4Data(x, y, z));
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java
index 7e7c96c24..a5d3ab0b9 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java
@@ -49,7 +49,6 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
}
public Vector3 getTarget(Player player, boolean adjacent) {
- Location target = null;
int range = this.range > -1 ? getRange() : DEFAULT_RANGE;
if (adjacent) {
Location face = player.getBlockTraceFace(range, true);
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java
index c2ed40764..1d86aa11b 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java
@@ -46,9 +46,7 @@ import java.util.UUID;
*/
public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
- public static int COMPRESSION = 0;
- public static int MODE = 0;
- public static int HEADER_SIZE = 14;
+ private static int HEADER_SIZE = 14;
protected int length;
protected int height;
@@ -61,9 +59,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
private final File file;
private RandomAccessFile braf;
- private MappedByteBuffer mbb;
+ private MappedByteBuffer byteBuffer;
- private FileChannel fc;
+ private FileChannel fileChannel;
private boolean hasBiomes;
public DiskOptimizedClipboard(int width, int height, int length, UUID uuid) {
@@ -78,9 +76,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
this.braf = new RandomAccessFile(file, "rw");
braf.setLength(file.length());
init();
- width = mbb.getChar(2);
- height = mbb.getChar(4);
- length = mbb.getChar(6);
+ width = byteBuffer.getChar(2);
+ height = byteBuffer.getChar(4);
+ length = byteBuffer.getChar(6);
area = width * length;
this.volume = length * width * height;
@@ -98,9 +96,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
}
private void init() throws IOException {
- if (this.fc == null) {
- this.fc = braf.getChannel();
- this.mbb = fc.map(FileChannel.MapMode.READ_WRITE, 0, file.length());
+ if (this.fileChannel == null) {
+ this.fileChannel = braf.getChannel();
+ this.byteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, file.length());
}
}
@@ -134,7 +132,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@Override
public void setBiome(int index, BiomeType biome) {
if (initBiome()) {
- mbb.put(HEADER_SIZE + (volume << 2) + index, (byte) biome.getInternalId());
+ byteBuffer.put(HEADER_SIZE + (volume << 2) + index, (byte) biome.getInternalId());
}
}
@@ -143,8 +141,8 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
if (!hasBiomes()) {
return null;
}
- int biomeId = mbb.get(HEADER_SIZE + (volume << 2) + index) & 0xFF;
- return BiomeTypes.register(biomeId);
+ int biomeId = byteBuffer.get(HEADER_SIZE + (volume << 2) + index) & 0xFF;
+ return BiomeTypes.get(biomeId);
}
@Override
@@ -154,7 +152,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
int mbbIndex = HEADER_SIZE + (volume << 2);
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, index++, mbbIndex++) {
- int biome = mbb.get(mbbIndex) & 0xFF;
+ int biome = byteBuffer.get(mbbIndex) & 0xFF;
task.run(index, biome);
}
}
@@ -173,9 +171,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
public BlockArrayClipboard toClipboard() {
try {
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(width - 1, height - 1, length - 1));
- int ox = mbb.getShort(8);
- int oy = mbb.getShort(10);
- int oz = mbb.getShort(12);
+ int ox = byteBuffer.getShort(8);
+ int oy = byteBuffer.getShort(10);
+ int oz = byteBuffer.getShort(12);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, this);
clipboard.setOrigin(BlockVector3.at(ox, oy, oz));
return clipboard;
@@ -213,9 +211,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
if (width * height * length != 0) {
init();
// write length etc
- mbb.putChar(2, (char) width);
- mbb.putChar(4, (char) height);
- mbb.putChar(6, (char) length);
+ byteBuffer.putChar(2, (char) width);
+ byteBuffer.putChar(4, (char) height);
+ byteBuffer.putChar(6, (char) length);
}
} catch (IOException e) {
throw new RuntimeException(e);
@@ -225,9 +223,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@Override
public void setOrigin(BlockVector3 offset) {
try {
- mbb.putShort(8, (short) offset.getBlockX());
- mbb.putShort(10, (short) offset.getBlockY());
- mbb.putShort(12, (short) offset.getBlockZ());
+ byteBuffer.putShort(8, (short) offset.getBlockX());
+ byteBuffer.putShort(10, (short) offset.getBlockY());
+ byteBuffer.putShort(12, (short) offset.getBlockZ());
} catch (Throwable e) {
e.printStackTrace();
}
@@ -248,9 +246,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
braf.setLength(size);
init();
}
- mbb.putChar(2, (char) width);
- mbb.putChar(4, (char) height);
- mbb.putChar(6, (char) length);
+ byteBuffer.putChar(2, (char) width);
+ byteBuffer.putChar(4, (char) height);
+ byteBuffer.putChar(6, (char) length);
} catch (IOException e) {
e.printStackTrace();
}
@@ -258,7 +256,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@Override
public void flush() {
- mbb.force();
+ byteBuffer.force();
}
public DiskOptimizedClipboard(int width, int height, int length) {
@@ -267,7 +265,6 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
private void closeDirectBuffer(ByteBuffer cb) {
if (cb == null || !cb.isDirect()) return;
-
// we could use this type cast and call functions without reflection code,
// but static import from sun.* package is risky for non-SUN virtual machine.
//try { ((sun.nio.ch.DirectBuffer)cb).cleaner().clean(); } catch (Exception ex) { }
@@ -299,14 +296,15 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@Override
public void close() {
try {
- if (mbb != null) {
- mbb.force();
- fc.close();
+ if (byteBuffer != null) {
+ byteBuffer.force();
+ fileChannel.close();
braf.close();
+ //noinspection ResultOfMethodCallIgnored
file.setWritable(true);
- closeDirectBuffer(mbb);
- mbb = null;
- fc = null;
+ closeDirectBuffer(byteBuffer);
+ byteBuffer = null;
+ fileChannel = null;
braf = null;
}
} catch (IOException e) {
@@ -337,13 +335,13 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@Override
public void streamCombinedIds(NBTStreamer.ByteReader task) {
try {
- mbb.force();
+ byteBuffer.force();
int pos = HEADER_SIZE;
int index = 0;
for (int y = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, pos += 4) {
- int combinedId = mbb.getInt(pos);
+ int combinedId = byteBuffer.getInt(pos);
task.run(index++, combinedId);
}
}
@@ -360,7 +358,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@Override
public void forEach(final BlockReader task, boolean air) {
- mbb.force();
+ byteBuffer.force();
int pos = HEADER_SIZE;
IntegerTrio trio = new IntegerTrio();
final boolean hasTile = !nbtMap.isEmpty();
@@ -369,7 +367,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
for (int y = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, pos += 4) {
- int combinedId = mbb.getInt(pos);
+ int combinedId = byteBuffer.getInt(pos);
BlockType type = BlockTypes.getFromStateId(combinedId);
BlockState state = type.withStateId(combinedId);
if (type.getMaterial().hasContainer()) {
@@ -388,7 +386,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
for (int y = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, pos += 4) {
- int combinedId = mbb.getInt(pos);
+ int combinedId = byteBuffer.getInt(pos);
BlockState state = BlockState.getFromInternalId(combinedId);
task.run(x, y, z, state);
}
@@ -399,7 +397,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
for (int y = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, pos += 4) {
- int combinedId = mbb.getInt(pos);
+ int combinedId = byteBuffer.getInt(pos);
BlockType type = BlockTypes.getFromStateId(combinedId);
if (!type.getMaterial().isAir()) {
BlockState state = type.withStateId(combinedId);
@@ -427,7 +425,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
public BaseBlock getBlock(int x, int y, int z) {
try {
int index = HEADER_SIZE + (getIndex(x, y, z) << 2);
- int combinedId = mbb.getInt(index);
+ int combinedId = byteBuffer.getInt(index);
BlockType type = BlockTypes.getFromStateId(combinedId);
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
@@ -440,7 +438,6 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
} catch (IndexOutOfBoundsException ignore) {
} catch (Exception e) {
e.printStackTrace();
- e.printStackTrace();
}
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}
@@ -449,7 +446,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
public BaseBlock getBlock(int i) {
try {
int diskIndex = (HEADER_SIZE) + (i << 2);
- int combinedId = mbb.getInt(diskIndex);
+ int combinedId = byteBuffer.getInt(diskIndex);
BlockType type = BlockTypes.getFromStateId(combinedId);
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
@@ -499,7 +496,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
try {
int index = (HEADER_SIZE) + ((getIndex(x, y, z) << 2));
int combined = block.getInternalId();
- mbb.putInt(index, combined);
+ byteBuffer.putInt(index, combined);
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
if (hasNbt) {
setTile(x, y, z, block.getNbtData());
@@ -516,7 +513,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
try {
int combined = block.getInternalId();
int index = (HEADER_SIZE) + (i << 2);
- mbb.putInt(index, combined);
+ byteBuffer.putInt(index, combined);
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
if (hasNbt) {
int y = i / area;
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java
index c3115d1c4..bfe975708 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java
@@ -5,6 +5,7 @@ import com.boydti.fawe.jnbt.NBTStreamer;
import com.boydti.fawe.object.IntegerTrio;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.ReflectionUtils;
+
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.Tag;
@@ -28,9 +29,9 @@ import java.util.Map;
public class MemoryOptimizedClipboard extends FaweClipboard {
- public static final int BLOCK_SIZE = 1048576 * 4;
- public static final int BLOCK_MASK = 1048575;
- public static final int BLOCK_SHIFT = 20;
+ private static final int BLOCK_SIZE = 1048576 * 4;
+ private static final int BLOCK_MASK = 1048575;
+ private static final int BLOCK_SHIFT = 20;
private int length;
private int height;
@@ -338,9 +339,9 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
public > boolean setBlock(int index, B block) {
int combinedId = block.getInternalId();
setCombinedId(index, combinedId);
- boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
+ boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
if (hasNbt) {
- setTile(index, ((BaseBlock)block).getNbtData());
+ setTile(index, block.getNbtData());
}
return true;
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java
index ac52e3db5..952b6a661 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java
@@ -32,19 +32,14 @@ public class AverageColorPattern extends AbstractExtentPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
- BlockType blockType = extent.getBlock(getPosition).getBlockType();
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BlockType blockType = get.getBlock(extent).getBlockType();
TextureUtil util = holder.getTextureUtil();
int currentColor = util.getColor(blockType);
if (currentColor == 0) return false;
int newColor = util.averageColor(currentColor, color);
BlockType newBlock = util.getNearestBlock(newColor);
if (newBlock == blockType) return false;
- return extent.setBlock(setPosition, newBlock.getDefaultState());
- }
-
- private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
+ return set.setBlock(extent, newBlock.getDefaultState());
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java
index 8f6544940..fca405051 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java
@@ -13,7 +13,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
public class DesaturatePattern extends AbstractPattern {
- private transient TextureHolder holder;
+ private final TextureHolder holder;
private final Extent extent;
private final double value;
@@ -27,7 +27,11 @@ public class DesaturatePattern extends AbstractPattern {
public BaseBlock apply(BlockVector3 position) {
BlockType block = extent.getBlock(position).getBlockType();
TextureUtil util = holder.getTextureUtil();
- int color = util.getColor(block);
+ int color = getColor(util.getColor(block));
+ return util.getNearestBlock(color).getDefaultState().toBaseBlock();
+ }
+
+ public int getColor(int color) {
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 0) & 0xFF;
@@ -37,35 +41,22 @@ public class DesaturatePattern extends AbstractPattern {
int green = (int) (g + value * (l - g));
int blue = (int) (b + value * (l - b));
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
- return util.getNearestBlock(newColor).getDefaultState().toBaseBlock();
+ return newColor;
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
- BlockType block = extent.getBlock(getPosition).getBlockType();
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BlockType type = get.getBlock(extent).getBlockType();
TextureUtil util = holder.getTextureUtil();
- int color = util.getColor(block);
- int r = (color >> 16) & 0xFF;
- int g = (color >> 8) & 0xFF;
- int b = (color >> 0) & 0xFF;
- int alpha = (color >> 24) & 0xFF;
- double l = 0.3f * r + 0.6f * g + 0.1f * b;
- int red = (int) (r + value * (l - r));
- int green = (int) (g + value * (l - g));
- int blue = (int) (b + value * (l - b));
- int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
+ int color = util.getColor(type);
+ int newColor = getColor(color);
if (newColor == color) {
return false;
}
- BlockType newBlock = util.getNextNearestBlock(newColor);
- if (block.equals(newBlock)) {
+ BlockType newType = util.getNextNearestBlock(newColor);
+ if (type.equals(newType)) {
return false;
}
- return extent.setBlock(setPosition, newBlock.getDefaultState());
- }
-
- private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
+ return set.setBlock(extent, newType.getDefaultState());
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java
index ac29670fa..d9b4730b0 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java
@@ -1,6 +1,7 @@
package com.boydti.fawe.object.pattern;
import com.boydti.fawe.Fawe;
+import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.util.TextureHolder;
import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.WorldEditException;
@@ -14,7 +15,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
public class SaturatePattern extends AbstractPattern {
- private transient TextureHolder holder;
+ private final TextureHolder holder;
private final int color;
private final Extent extent;
@@ -35,19 +36,14 @@ public class SaturatePattern extends AbstractPattern {
}
@Override
- public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
- BlockType block = extent.getBlock(getPosition).getBlockType();
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BlockType block = get.getBlock(extent).getBlockType();
TextureUtil util = holder.getTextureUtil();
int currentColor = util.getColor(block);
if (currentColor == 0) return false;
int newColor = util.multiplyColor(currentColor, color);
BlockType newBlock = util.getNearestBlock(newColor);
if (newBlock.equals(block)) return false;
- return extent.setBlock(setPosition, newBlock.getDefaultState());
- }
-
- private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
+ return set.setBlock(extent, newBlock.getDefaultState());
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java
index 0fe10f849..43ba6bb83 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java
@@ -2,17 +2,16 @@ package com.boydti.fawe.object.pattern;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.TextureUtil;
+import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockType;
-import java.io.IOException;
public class ShadePattern extends AbstractPattern {
- private transient TextureUtil util;
+ private final TextureUtil util;
private final Extent extent;
private final boolean darken;
@@ -29,8 +28,13 @@ public class ShadePattern extends AbstractPattern {
return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState().toBaseBlock();
}
- private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- util = Fawe.get().getCachedTextureUtil(true, 0, 100);
+ @Override
+ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
+ BlockType type = get.getBlock(extent).getBlockType();
+ BlockType newType = (darken ? util.getDarkerBlock(type) : util.getLighterBlock(type));
+ if (type != newType) {
+ return set.setBlock(extent, newType.getDefaultState());
+ }
+ return false;
}
}
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java
index f198118d6..225960da1 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java
@@ -2,21 +2,24 @@ package com.boydti.fawe.util;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
+import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer;
-import com.boydti.fawe.object.FaweQueue;
+import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.object.NullChangeSet;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
-
-import static com.google.common.base.Preconditions.checkNotNull;
+import com.boydti.fawe.object.exception.FaweException;
+import com.boydti.fawe.object.extent.NullExtent;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.event.extent.EditSessionEvent;
+import com.sk89q.worldedit.extent.AbstractDelegateExtent;
+import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.eventbus.EventBus;
@@ -26,10 +29,12 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.UUID;
+import static com.google.common.base.Preconditions.checkNotNull;
+
public class EditSessionBuilder {
private World world;
private String worldName;
- private FaweQueue queue;
+ private Extent extent;
private FawePlayer player;
private FaweLimit limit;
private FaweChangeSet changeSet;
@@ -60,9 +65,17 @@ public class EditSessionBuilder {
public EditSessionBuilder(@Nonnull World world) {
checkNotNull(world);
this.world = world;
+ this.extent = world;
this.worldName = Fawe.imp().getWorldName(world);
}
+ public EditSessionBuilder(World world, String worldName) {
+ if (world == null && worldName == null) throw new NullPointerException("Both world and worldname cannot be null");
+ this.world = world;
+ this.extent = world;
+ this.worldName = worldName;
+ }
+
public EditSessionBuilder(@Nonnull String worldName) {
checkNotNull(worldName);
this.worldName = worldName;
@@ -176,8 +189,8 @@ public class EditSessionBuilder {
return this;
}
- public EditSessionBuilder queue(@Nullable FaweQueue queue) {
- this.queue = queue;
+ public EditSessionBuilder extent(@Nullable Extent extent) {
+ this.extent = extent;
return this;
}
@@ -191,10 +204,261 @@ public class EditSessionBuilder {
return this;
}
+ private boolean wrapped;
+
+ private AbstractDelegateExtent wrapExtent(final AbstractDelegateExtent extent, final EventBus eventBus, EditSessionEvent event, final EditSession.Stage stage) {
+ event = event.clone(stage);
+ event.setExtent(extent);
+ eventBus.post(event);
+ if (event.isCancelled()) {
+ return new NullExtent(extent, FaweException.MANUAL);
+ }
+ final Extent toReturn = event.getExtent();
+ if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) {
+ return new NullExtent(toReturn, FaweException.MANUAL);
+ }
+ if (!(toReturn instanceof AbstractDelegateExtent)) {
+ Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
+ return extent;
+ }
+ if (toReturn != extent) {
+ String className = toReturn.getClass().getName().toLowerCase();
+ for (String allowed : Settings.IMP.EXTENT.ALLOWED_PLUGINS) {
+ if (className.contains(allowed.toLowerCase())) {
+ this.wrapped = true;
+ return (AbstractDelegateExtent) toReturn;
+ }
+ }
+ if (Settings.IMP.EXTENT.DEBUG) {
+ Fawe.debug("&cPotentially unsafe extent blocked: " + toReturn.getClass().getName());
+ Fawe.debug("&8 - &7For area restrictions, it is recommended to use the FaweAPI");
+ Fawe.debug("&8 - &7For block logging, it is recommended to use use BlocksHub");
+ Fawe.debug("&8 - &7To allow this plugin add it to the FAWE `allowed-plugins` list");
+ Fawe.debug("&8 - &7To hide this message set `debug` to false in the FAWE config.yml");
+ if (toReturn.getClass().getName().contains("CoreProtect")) {
+ Fawe.debug("Note on CoreProtect: ");
+ Fawe.debug(" - If you disable CP's WE logger (CP config) and this still shows, please update CP");
+ Fawe.debug(" - Use BlocksHub and set `debug` false in the FAWE config");
+ }
+ }
+ }
+ return extent;
+ }
+
+ private FaweChangeSet changeTask;
+ private int maxY;
+ private HistoryExtent history;
+ private AbstractDelegateExtent bypassHistory;
+ private AbstractDelegateExtent bypassAll;
+
+ public EditSessionBuilder compile() {
+ if (extent != null) return this;
+
+ wrapped = false;
+ if (world == null && !this.worldName.isEmpty()) {
+ world = FaweAPI.getWorld(this.worldName);
+ }
+ if (eventBus == null) {
+ eventBus = WorldEdit.getInstance().getEventBus();
+ }
+ if (event == null) {
+ event = new EditSessionEvent(world, player == null ? null : (player.getPlayer()), -1, null);
+ }
+ if (player == null && event.getActor() != null) {
+ player = FawePlayer.wrap(event.getActor());
+ }
+ if (limit == null) {
+ if (player == null) {
+ limit = FaweLimit.MAX;
+ } else {
+ limit = player.getLimit();
+ }
+ }
+ if (autoQueue == null) {
+ autoQueue = true;
+ }
+ if (fastmode == null) {
+ if (player == null) {
+ fastmode = !Settings.IMP.HISTORY.ENABLE_FOR_CONSOLE;
+ } else {
+ fastmode = player.getSession().hasFastMode();
+ }
+ }
+ if (checkMemory == null) {
+ checkMemory = player != null && !this.fastmode;
+ }
+ if (checkMemory) {
+ if (MemUtil.isMemoryLimitedSlow()) {
+ if (Perm.hasPermission(player, "worldedit.fast")) {
+ BBC.WORLDEDIT_OOM_ADMIN.send(player);
+ }
+ throw FaweException.LOW_MEMORY;
+ }
+ }
+// this.originalLimit = limit;
+ this.blockBag = limit.INVENTORY_MODE != 0 ? blockBag : null;
+// this.limit = limit.copy();
+
+// if (queue == null) {
+// boolean placeChunks = this.fastmode || this.limit.FAST_PLACEMENT;
+// World unwrapped = WorldWrapper.unwrap(world);
+// if (unwrapped instanceof FaweQueue) {
+// queue = (FaweQueue) unwrapped;
+// } else if (unwrapped instanceof MCAWorld) {
+// queue = ((MCAWorld) unwrapped).getQueue();
+// } else if (player != null && world.equals(player.getWorld())) {
+// queue = player.getFaweQueue(placeChunks, autoQueue);
+// } else {
+// queue = SetQueue.IMP.getNewQueue(world, placeChunks, autoQueue);
+// }
+// }
+// if (combineStages == null) {
+// combineStages =
+// // If it's enabled in the settings
+// Settings.IMP.HISTORY.COMBINE_STAGES
+// // If fast placement is disabled, it's slower to perform a copy on each chunk
+// && this.limit.FAST_PLACEMENT
+// // If the specific queue doesn't support it
+// && queue.supports(FaweQueue.Capability.CHANGE_TASKS)
+// // If the edit uses items from the inventory we can't use a delayed task
+// && this.blockBag == null;
+// }
+// if (!Settings.IMP.QUEUE.PROGRESS.DISPLAY.equalsIgnoreCase("false") && player != null) {
+// switch (Settings.IMP.QUEUE.PROGRESS.DISPLAY.toLowerCase()) {
+// case "chat":
+// this.queue.setProgressTask(new ChatProgressTracker(player));
+// break;
+// case "title":
+// case "true":
+// default:
+// this.queue.setProgressTask(new DefaultProgressTracker(player));
+// }
+// }
+// this.bypassAll = wrapExtent(new FastWorldEditExtent(world, queue), eventBus, event, EditSession.Stage.BEFORE_CHANGE);
+// this.bypassHistory = (this.extent = wrapExtent(bypassAll, eventBus, event, EditSession.Stage.BEFORE_REORDER));
+// if (!this.fastmode || changeSet != null) {
+// if (changeSet == null) {
+// if (Settings.IMP.HISTORY.USE_DISK) {
+// UUID uuid = player == null ? EditSession.CONSOLE : player.getUUID();
+// if (Settings.IMP.HISTORY.USE_DATABASE) {
+// changeSet = new RollbackOptimizedHistory(world, uuid);
+// } else {
+// changeSet = new DiskStorageHistory(world, uuid);
+// }
+// } else if (combineStages && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0 && !(queue instanceof MCAQueue)) {
+// changeSet = new CPUOptimizedChangeSet(world);
+// } else {
+// changeSet = new MemoryOptimizedHistory(world);
+// }
+// }
+// if (this.limit.SPEED_REDUCTION > 0) {
+// this.bypassHistory = new SlowExtent(this.bypassHistory, this.limit.SPEED_REDUCTION);
+// }
+// if (changeSet instanceof NullChangeSet && Fawe.imp().getBlocksHubApi() != null && player != null) {
+// changeSet = LoggingChangeSet.wrap(player, changeSet);
+// }
+// if (!(changeSet instanceof NullChangeSet)) {
+// if (!(changeSet instanceof LoggingChangeSet) && player != null && Fawe.imp().getBlocksHubApi() != null) {
+// changeSet = LoggingChangeSet.wrap(player, changeSet);
+// }
+// if (this.blockBag != null) {
+// changeSet = new BlockBagChangeSet(changeSet, blockBag, limit.INVENTORY_MODE == 1);
+// }
+// if (combineStages) {
+// changeTask = changeSet;
+// changeSet.addChangeTask(queue);
+// } else {
+// this.extent = (history = new HistoryExtent(bypassHistory, changeSet, queue));
+//// if (this.blockBag != null) {
+//// this.extent = new BlockBagExtent(this.extent, blockBag, limit.INVENTORY_MODE == 1);
+//// }
+// }
+// }
+// }
+// if (allowedRegions == null) {
+// if (player != null && !player.hasPermission("fawe.bypass") && !player.hasPermission("fawe.bypass.regions") && !(queue instanceof VirtualWorld)) {
+// allowedRegions = player.getCurrentRegions();
+// }
+// }
+// this.maxY = world == null ? 255 : world.getMaxY();
+// if (allowedRegions != null) {
+// if (allowedRegions.length == 0) {
+// this.extent = new NullExtent(this.extent, FaweException.NO_REGION);
+// } else {
+// this.extent = new ProcessedWEExtent(this.extent, this.limit);
+// if (allowedRegions.length == 1) {
+// this.extent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
+// } else {
+// this.extent = new MultiRegionExtent(this.extent, this.limit, allowedRegions);
+// }
+// }
+// } else {
+// this.extent = new HeightBoundExtent(this.extent, this.limit, 0, maxY);
+// }
+// if (this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) {
+// this.extent = new StripNBTExtent(this.extent, this.limit.STRIP_NBT);
+// }
+// this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY);
+// return this;
+ return this;
+ }
+
public EditSession build() {
if (eventBus == null) {
eventBus = WorldEdit.getInstance().getEventBus();
}
- return new EditSession(worldName, world, queue, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, eventBus, event);
+ return new EditSession(this);
+ }
+
+ public Extent getExtent() {
+ return extent;
+ }
+
+ public World getWorld() {
+ return world;
+ }
+
+ public String getWorldName() {
+ return worldName;
+ }
+
+ public boolean isWrapped() {
+ return wrapped;
+ }
+
+ public boolean hasFastMode() {
+ return fastmode;
+ }
+
+ public HistoryExtent getHistory() {
+ return history;
+ }
+
+ public AbstractDelegateExtent getBypassHistory() {
+ return bypassHistory;
+ }
+
+ public AbstractDelegateExtent getBypassAll() {
+ return bypassAll;
+ }
+
+ public FaweLimit getLimit() {
+ return limit;
+ }
+
+ public FawePlayer getPlayer() {
+ return player;
+ }
+
+ public FaweChangeSet getChangeTask() {
+ return changeTask;
+ }
+
+ public BlockBag getBlockBag() {
+ return blockBag;
+ }
+
+ public int getMaxY() {
+ return maxY;
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java
index 6773d34e4..10c79cda0 100644
--- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java
+++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java
@@ -50,9 +50,8 @@ public final class NBTInputStream implements Closeable {
* from the specified input stream.
*
* @param is the input stream
- * @throws IOException if an I/O error occurs
*/
- public NBTInputStream(InputStream is) throws IOException {
+ public NBTInputStream(InputStream is) {
this.is = new DataInputStream(is);
}
@@ -364,7 +363,7 @@ public final class NBTInputStream implements Closeable {
int toRead = Math.min(length << 2, buf.length);
is.readFully(buf, 0, toRead);
for (int i = 0; i < toRead; i += 4, index++) {
- data[index] = ((buf[i + 0] & 0xFF) << 24) + ((buf[i + 1] & 0xFF) << 16) + ((buf[i + 2] & 0xFF) << 8) + (buf[i + 3] & 0xFF);
+ data[index] = ((buf[i] & 0xFF) << 24) + ((buf[i + 1] & 0xFF) << 16) + ((buf[i + 2] & 0xFF) << 8) + (buf[i + 3] & 0xFF);
}
length -= toRead;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
index b9a4c30b9..fd3697817 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
@@ -37,7 +37,6 @@ import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
-import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.object.NullChangeSet;
import com.boydti.fawe.object.RegionWrapper;
@@ -61,11 +60,17 @@ import com.boydti.fawe.object.extent.SingleRegionExtent;
import com.boydti.fawe.object.extent.SlowExtent;
import com.boydti.fawe.object.extent.SourceMaskExtent;
import com.boydti.fawe.object.extent.StripNBTExtent;
+import com.boydti.fawe.object.extent.FaweRegionExtent;
+import com.boydti.fawe.object.extent.NullExtent;
+import com.boydti.fawe.object.extent.ProcessedWEExtent;
+import com.boydti.fawe.object.extent.ResettableExtent;
+import com.boydti.fawe.object.extent.SourceMaskExtent;
import com.boydti.fawe.object.function.SurfaceRegionFunction;
import com.boydti.fawe.object.mask.ResettableMask;
import com.boydti.fawe.object.pattern.ExistingPattern;
import com.boydti.fawe.object.progress.ChatProgressTracker;
import com.boydti.fawe.object.progress.DefaultProgressTracker;
+import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.ExtentTraverser;
import com.boydti.fawe.util.MaskTraverser;
import com.boydti.fawe.util.MathMan;
@@ -80,6 +85,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.event.extent.EditSessionEvent;
+import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.ChangeSetExtent;
import com.sk89q.worldedit.extent.Extent;
@@ -104,6 +110,8 @@ import com.sk89q.worldedit.function.mask.MaskUnion;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
import com.sk89q.worldedit.function.mask.RegionMask;
+import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
+import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operation;
@@ -166,7 +174,10 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.weather.WeatherType;
import java.nio.file.Path;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -178,6 +189,12 @@ import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
+import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
+import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
+
/**
* An {@link Extent} that handles history, {@link BlockBag}s, change limits,
* block re-ordering, and much more. Most operations in WorldEdit use this class.
@@ -187,7 +204,7 @@ import org.slf4j.LoggerFactory;
* using the {@link ChangeSetExtent}.
*/
@SuppressWarnings({"FieldCanBeLocal"})
-public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, SimpleWorld, AutoCloseable {
+public class EditSession extends AbstractDelegateExtent SimpleWorld, AutoCloseable {
private static final Logger log = LoggerFactory.getLogger(EditSession.class);
@@ -224,194 +241,51 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return this.displayName;
}
}
-
- @SuppressWarnings("ProtectedField")
- protected final World world;
- private String worldName;
- private FaweQueue queue;
+ private final World world;
+ private final String worldName;
private boolean wrapped;
private boolean fastMode;
- private AbstractDelegateExtent extent;
- private HistoryExtent history;
+ private final HistoryExtent history;
private AbstractDelegateExtent bypassHistory;
private AbstractDelegateExtent bypassAll;
- private FaweLimit originalLimit;
- private FaweLimit limit;
- private FawePlayer player;
+ private final FaweLimit originalLimit;
+ private final FaweLimit limit;
+ private final FawePlayer player;
private FaweChangeSet changeTask;
- private MutableBlockVector3 mutablebv = new MutableBlockVector3();
+ private final MutableBlockVector3 mutablebv = new MutableBlockVector3();
private int changes = 0;
- private BlockBag blockBag;
+ private final BlockBag blockBag;
private final int maxY;
public static final UUID CONSOLE = UUID.fromString("1-1-3-3-7");
@Deprecated
- public EditSession(@Nonnull World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @NotNull EventBus bus, @Nullable EditSessionEvent event) {
- this(null, world, queue, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event);
+ public EditSession(@Nonnull World world, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
+ this(null, world, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event);
}
- public EditSession(@Nullable String worldName, @Nullable World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
- super(world);
- this.worldName = worldName == null ? world == null ? queue == null ? "" : queue.getWorldName() : world.getName() : worldName;
- if (world == null && this.worldName != null) world = FaweAPI.getWorld(this.worldName);
+ public EditSession(@Nullable String worldName, @Nullable World world, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
+ this(new EditSessionBuilder(world, worldName).player(player).limit(limit).changeSet(changeSet).allowedRegions(allowedRegions).autoQueue(autoQueue).fastmode(fastmode).checkMemory(checkMemory).combineStages(combineStages).blockBag(blockBag).eventBus(bus).event(event));
+ }
- this.world = world;
- if (bus == null) { // don't change
- bus = WorldEdit.getInstance().getEventBus();
- }
- if (event == null) {
- event = new EditSessionEvent(world, player == null ? null : (player.getPlayer()), -1, null);
- }
- event.setEditSession(this);
- if (player == null && event.getActor() != null) {
- player = FawePlayer.wrap(event.getActor());
- }
- this.player = player;
- if (limit == null) {
- if (player == null) {
- limit = FaweLimit.MAX;
- } else {
- limit = player.getLimit();
- }
- }
- if (autoQueue == null) {
- autoQueue = true;
- }
- if (fastmode == null) {
- if (player == null) {
- fastmode = !Settings.IMP.HISTORY.ENABLE_FOR_CONSOLE;
- } else {
- fastmode = player.getSession().hasFastMode();
- }
- }
- this.fastMode = fastmode;
- if (checkMemory == null) {
- checkMemory = player != null && !this.fastMode;
- }
- if (checkMemory) {
- if (MemUtil.isMemoryLimitedSlow()) {
- if (Perm.hasPermission(player, "worldedit.fast")) {
- BBC.WORLDEDIT_OOM_ADMIN.send(player);
- }
- throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY);
- }
- }
- this.originalLimit = limit;
- this.blockBag = limit.INVENTORY_MODE != 0 ? blockBag : null;
- this.limit = limit.copy();
-
- if (queue == null) {
- boolean placeChunks = this.fastMode || this.limit.FAST_PLACEMENT;
- World unwrapped = WorldWrapper.unwrap(world);
- if (unwrapped instanceof FaweQueue) {
- queue = (FaweQueue) unwrapped;
- } else if (unwrapped instanceof MCAWorld) {
- queue = ((MCAWorld) unwrapped).getQueue();
- } else if (player != null && world.equals(player.getWorld())) {
- queue = player.getFaweQueue(placeChunks, autoQueue);
- } else {
- queue = SetQueue.IMP.getNewQueue(world, placeChunks, autoQueue);
- }
- }
- if (combineStages == null) {
- combineStages =
- // If it's enabled in the settings
- Settings.IMP.HISTORY.COMBINE_STAGES
- // If fast placement is disabled, it's slower to perform a copy on each chunk
- && this.limit.FAST_PLACEMENT
- // If the specific queue doesn't support it
- && queue.supports(FaweQueue.Capability.CHANGE_TASKS)
- // If the edit uses items from the inventory we can't use a delayed task
- && this.blockBag == null;
- }
- if (Settings.IMP.EXPERIMENTAL.ANVIL_QUEUE_MODE && !(queue instanceof MCAQueue)) {
- queue = new MCAQueue(queue);
- }
- this.queue = queue;
- this.queue.addEditSession(this);
- if (!Settings.IMP.QUEUE.PROGRESS.DISPLAY.equalsIgnoreCase("false") && player != null) {
- switch (Settings.IMP.QUEUE.PROGRESS.DISPLAY.toLowerCase()) {
- case "chat":
- this.queue.setProgressTask(new ChatProgressTracker(player));
- break;
- case "title":
- case "true":
- default:
- this.queue.setProgressTask(new DefaultProgressTracker(player));
- }
- }
- this.bypassAll = wrapExtent(new FastWorldEditExtent(world, queue), bus, event, Stage.BEFORE_CHANGE);
- this.bypassHistory = (this.extent = wrapExtent(bypassAll, bus, event, Stage.BEFORE_REORDER));
- if (!this.fastMode || changeSet != null) {
- if (changeSet == null) {
- if (Settings.IMP.HISTORY.USE_DISK) {
- UUID uuid = player == null ? CONSOLE : player.getUUID();
- if (Settings.IMP.HISTORY.USE_DATABASE) {
- changeSet = new RollbackOptimizedHistory(world, uuid);
- } else {
- changeSet = new DiskStorageHistory(world, uuid);
- }
- } else if (combineStages && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0 && !(queue instanceof MCAQueue)) {
- changeSet = new CPUOptimizedChangeSet(world);
- } else {
- changeSet = new MemoryOptimizedHistory(world);
- }
- }
- if (this.limit.SPEED_REDUCTION > 0) {
- this.bypassHistory = new SlowExtent(this.bypassHistory, this.limit.SPEED_REDUCTION);
- }
- // don't delete
- if (changeSet instanceof NullChangeSet && Fawe.imp().getBlocksHubApi() != null && player != null) {
- changeSet = LoggingChangeSet.wrap(player, changeSet);
- }
- if (!(changeSet instanceof NullChangeSet)) {
- // don't delete
- if (!(changeSet instanceof LoggingChangeSet) && player != null && Fawe.imp().getBlocksHubApi() != null) {
- changeSet = LoggingChangeSet.wrap(player, changeSet);
- }
- if (this.blockBag != null) {
- changeSet = new BlockBagChangeSet(changeSet, blockBag, limit.INVENTORY_MODE == 1);
- }
- if (combineStages) {
- changeTask = changeSet;
- changeSet.addChangeTask(queue);
- } else {
- this.extent = (history = new HistoryExtent(this, bypassHistory, changeSet, queue));
-// if (this.blockBag != null) {
-// this.extent = new BlockBagExtent(this.extent, blockBag, limit.INVENTORY_MODE == 1);
-// }
- }
- }
- }
- if (allowedRegions == null) {
- if (player != null && !player.hasPermission("fawe.bypass") && !player.hasPermission("fawe.bypass.regions") && !(queue instanceof VirtualWorld)) {
- allowedRegions = player.getCurrentRegions();
- }
- }
- this.maxY = getWorld() == null ? 255 : world.getMaxY();
- if (allowedRegions != null) {
- if (allowedRegions.length == 0) {
- this.extent = new NullExtent(this.extent, BBC.WORLDEDIT_CANCEL_REASON_NO_REGION);
- } else {
- this.extent = new ProcessedWEExtent(this.extent, this.limit);
- if (allowedRegions.length == 1) {
- this.extent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
- } else {
- this.extent = new MultiRegionExtent(this.extent, this.limit, allowedRegions);
- }
- }
- } else {
- this.extent = new HeightBoundExtent(this.extent, this.limit, 0, maxY);
- }
- if (this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) {
- this.extent = new StripNBTExtent(this.extent, this.limit.STRIP_NBT);
- }
- this.extent = wrapExtent(this.extent, bus, event, Stage.BEFORE_HISTORY);
- setExtent(this.extent);
+ public EditSession(EditSessionBuilder builder) {
+ super(builder.compile().getExtent());
+ this.world = builder.getWorld();
+ this.worldName = builder.getWorldName();
+ this.wrapped = builder.isWrapped();
+ this.fastMode = builder.hasFastMode();
+ this.history = builder.getHistory();
+ this.bypassHistory = builder.getBypassHistory();
+ this.bypassAll = builder.getBypassAll();
+ this.originalLimit = builder.getLimit();
+ this.limit = builder.getLimit().copy();
+ this.player = builder.getPlayer();
+ this.changeTask = builder.getChangeTask();
+ this.maxY = builder.getMaxY();
+ this.blockBag = builder.getBlockBag();
}
/**
@@ -424,7 +298,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @param event the event to call with the extent
*/
public EditSession(EventBus eventBus, World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent event) {
- this(world, null, null, null, null, null, true, null, null, null, blockBag, eventBus, event);
+ this(world, null, null, null, null, true, null, null, null, blockBag, eventBus, event);
}
/**
@@ -438,7 +312,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public void resetLimit() {
this.limit.set(this.originalLimit);
- ExtentTraverser find = new ExtentTraverser<>(extent).find(ProcessedWEExtent.class);
+ ExtentTraverser find = new ExtentTraverser<>(getExtent()).find(ProcessedWEExtent.class);
if (find != null && find.get() != null) {
find.get().setLimit(this.limit);
}
@@ -477,7 +351,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return FaweRegionExtent (may be null)
*/
public FaweRegionExtent getRegionExtent() {
- ExtentTraverser traverser = new ExtentTraverser<>(this.extent).find(FaweRegionExtent.class);
+ ExtentTraverser traverser = new ExtentTraverser<>(getExtent()).find(FaweRegionExtent.class);
return traverser == null ? null : traverser.get();
}
@@ -489,14 +363,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return bypassHistory;
}
- @Override
- public Extent getExtent() {
- return extent;
- }
-
public void setExtent(AbstractDelegateExtent extent) {
- this.extent = extent;
- new ExtentTraverser(this).setNext(extent);
+ new ExtentTraverser<>(getExtent()).setNext(extent);
}
/**
@@ -510,99 +378,17 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
public boolean cancel() {
- ExtentTraverser traverser = new ExtentTraverser(this.extent);
- NullExtent nullExtent = new NullExtent(world, BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
+ ExtentTraverser traverser = new ExtentTraverser<>(getExtent());
+ NullExtent nullExtent = new NullExtent(world, FaweException.MANUAL);
while (traverser != null) {
- ExtentTraverser next = traverser.next();
Extent get = traverser.get();
+ ExtentTraverser next = traverser.next();
if (get instanceof AbstractDelegateExtent && !(get instanceof NullExtent)) {
traverser.setNext(nullExtent);
}
traverser = next;
}
- bypassHistory = nullExtent;
- this.extent = nullExtent;
- bypassAll = nullExtent;
- dequeue();
- if (!queue.isEmpty()) {
- if (Fawe.isMainThread()) {
- queue.clear();
- } else {
- SetQueue.IMP.addTask(() -> queue.clear());
- }
- }
- return true;
- }
-
- /**
- * Remove this EditSession from the queue
- * - This doesn't necessarily stop it from being queued again
- */
- public void dequeue() {
- if (queue != null) {
- SetQueue.IMP.dequeue(queue);
- }
- }
-
- /**
- * Add a task to run when this EditSession is done dispatching
- *
- * @param whenDone
- */
- public void addNotifyTask(Runnable whenDone) {
- if (queue != null) {
- queue.addNotifyTask(whenDone);
- }
- }
-
- /**
- * Get the FaweQueue this EditSession uses to queue the changes
- * - Note: All implementation queues for FAWE are instances of NMSMappedFaweQueue
- *
- * @return
- */
- @Override
- public FaweQueue getQueue() {
- return queue;
- }
-
- private AbstractDelegateExtent wrapExtent(Extent extent, EventBus eventBus, EditSessionEvent event, Stage stage) {
- event = event.clone(stage);
- event.setExtent(extent);
- eventBus.post(event);
- if (event.isCancelled()) {
- return new NullExtent(extent, BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
- }
- final Extent toReturn = event.getExtent();
- if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) {
- return new NullExtent(toReturn, null);
- }
- if (!(toReturn instanceof AbstractDelegateExtent)) {
- Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
- return (AbstractDelegateExtent) extent;
- }
- if (toReturn != extent) {
- String className = toReturn.getClass().getName().toLowerCase();
- for (String allowed : Settings.IMP.EXTENT.ALLOWED_PLUGINS) {
- if (className.contains(allowed.toLowerCase())) {
- this.wrapped = true;
- return (AbstractDelegateExtent) toReturn;
- }
- }
- if (Settings.IMP.EXTENT.DEBUG) {
- Fawe.debug("&cPotentially unsafe extent blocked: " + toReturn.getClass().getName());
- Fawe.debug("&8 - &7For area restrictions, it is recommended to use the FaweAPI");
- Fawe.debug("&8 - &7For block logging, it is recommended to use use BlocksHub");
- Fawe.debug("&8 - &7To allow this plugin add it to the FAWE `allowed-plugins` list");
- Fawe.debug("&8 - &7To hide this message set `debug` to false in the FAWE config.yml");
- if (toReturn.getClass().getName().contains("CoreProtect")) {
- Fawe.debug("Note on CoreProtect: ");
- Fawe.debug(" - If you disable CP's WE logger (CP config) and this still shows, please update CP");
- Fawe.debug(" - Use BlocksHub and set `debug` false in the FAWE config");
- }
- }
- }
- return (AbstractDelegateExtent) extent;
+ return super.cancel();
}
// pkg private for TracedEditSession only, may later become public API
@@ -674,26 +460,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
changes++;
}
- /**
- * Change the ChangeSet being used for this EditSession
- * - If history is disabled, no changeset can be set
- *
- * @param set (null = remove the changeset)
- */
- public void setChangeSet(@Nullable FaweChangeSet set) {
- if (set == null) {
- disableHistory(true);
- } else {
- if (history != null) {
- history.setChangeSet(set);
- } else {
- changeTask = set;
- set.addChangeTask(queue);
- }
- }
- changes++;
- }
-
/**
* Get the maximum number of blocks that can be changed. -1 will be returned
* if it the limit disabled.
@@ -752,7 +518,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return mask, may be null
*/
public Mask getMask() {
- ExtentTraverser maskingExtent = new ExtentTraverser<>(this.extent).find(MaskingExtent.class);
+ ExtentTraverser maskingExtent = new ExtentTraverser<>(getExtent()).find(MaskingExtent.class);
return maskingExtent != null ? maskingExtent.get().getMask() : null;
}
@@ -762,30 +528,21 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return mask, may be null
*/
public Mask getSourceMask() {
- ExtentTraverser maskingExtent = new ExtentTraverser<>(this.extent).find(SourceMaskExtent.class);
+ ExtentTraverser maskingExtent = new ExtentTraverser<>(getExtent()).find(SourceMaskExtent.class);
return maskingExtent != null ? maskingExtent.get().getMask() : null;
}
public void addTransform(ResettableExtent transform) {
+ checkNotNull(transform);
wrapped = true;
- if (transform == null) {
- ExtentTraverser traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
- AbstractDelegateExtent next = extent;
- while (traverser != null && traverser.get() instanceof ResettableExtent) {
- traverser = traverser.next();
- next = (AbstractDelegateExtent) traverser.get();
- }
- this.extent = next;
- return;
- } else {
- this.extent = transform.setExtent(extent);
- }
+ transform.setExtent(getExtent());
+ new ExtentTraverser<>(getExtent()).setNext(transform);
}
public @Nullable ResettableExtent getTransform() {
- ExtentTraverser traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
+ ExtentTraverser traverser = new ExtentTraverser<>(getExtent()).find(ResettableExtent.class);
if (traverser != null) {
- return (ResettableExtent) traverser.get();
+ return traverser.get();
}
return null;
}
@@ -801,7 +558,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} else {
new MaskTraverser(mask).reset(this);
}
- ExtentTraverser maskingExtent = new ExtentTraverser<>(this.extent).find(SourceMaskExtent.class);
+ ExtentTraverser maskingExtent = new ExtentTraverser<>(getExtent()).find(SourceMaskExtent.class);
+=======
+ ExtentTraverser maskingExtent = new ExtentTraverser<>(getExtent()).find(SourceMaskExtent.class);
+>>>>>>> filter-pipeline
if (maskingExtent != null && maskingExtent.get() != null) {
Mask oldMask = maskingExtent.get().getMask();
if (oldMask instanceof ResettableMask) {
@@ -809,7 +569,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
maskingExtent.get().setMask(mask);
} else if (mask != Masks.alwaysTrue()) {
- this.extent = new SourceMaskExtent(this.extent, mask);
+ SourceMaskExtent next = new SourceMaskExtent(getExtent(), mask);
+ new ExtentTraverser<>(getExtent()).setNext(next);
}
}
@@ -818,13 +579,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
Mask existing = getSourceMask();
if (existing != null) {
if (existing instanceof MaskIntersection) {
- ((MaskIntersection) existing).add(mask);
- return;
+ Collection masks = new HashSet<>(((MaskIntersection) existing).getMasks());
+ masks.add(mask);
+ mask = new MaskIntersection(masks);
} else {
- MaskIntersection intersection = new MaskIntersection(existing);
- intersection.add(mask);
- mask = intersection;
+ mask = new MaskIntersection(existing, mask);
}
+ mask = mask.optimize();
}
setSourceMask(mask);
}
@@ -840,7 +601,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} else {
new MaskTraverser(mask).reset(this);
}
- ExtentTraverser maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
+ ExtentTraverser maskingExtent = new ExtentTraverser<>(getExtent()).find(MaskingExtent.class);
if (maskingExtent != null && maskingExtent.get() != null) {
Mask oldMask = maskingExtent.get().getMask();
if (oldMask instanceof ResettableMask) {
@@ -848,7 +609,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
maskingExtent.get().setMask(mask);
} else if (mask != Masks.alwaysTrue()) {
- this.extent = new MaskingExtent(this.extent, mask);
+ MaskingExtent next = new MaskingExtent(getExtent(), mask);
+ new ExtentTraverser<>(getExtent()).setNext(next);
}
}
@@ -858,13 +620,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return the survival simulation extent
*/
public SurvivalModeExtent getSurvivalExtent() {
- ExtentTraverser survivalExtent = new ExtentTraverser<>(this.extent).find(SurvivalModeExtent.class);
+ ExtentTraverser survivalExtent = new ExtentTraverser<>(getExtent()).find(SurvivalModeExtent.class);
if (survivalExtent != null) {
return survivalExtent.get();
} else {
- AbstractDelegateExtent extent = this.extent;
- SurvivalModeExtent survival = new SurvivalModeExtent(extent.getExtent(), getWorld());
- new ExtentTraverser(extent).setNext(survival);
+ SurvivalModeExtent survival = new SurvivalModeExtent(bypassAll.getExtent(), getWorld());
+ new ExtentTraverser(bypassAll).setNext(survival);
return survival;
}
}
@@ -891,21 +652,21 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (history == null) {
return;
}
- ExtentTraverser traverseHistory = new ExtentTraverser<>(this.extent).find(HistoryExtent.class);
+ ExtentTraverser traverseHistory = new ExtentTraverser<>(getExtent()).find(HistoryExtent.class);
if (disableHistory) {
if (traverseHistory != null && traverseHistory.exists()) {
- ExtentTraverser beforeHistory = traverseHistory.previous();
- ExtentTraverser afterHistory = traverseHistory.next();
+ ExtentTraverser beforeHistory = traverseHistory.previous();
+ ExtentTraverser afterHistory = traverseHistory.next();
if (beforeHistory != null && beforeHistory.exists()) {
beforeHistory.setNext(afterHistory.get());
} else {
- extent = (AbstractDelegateExtent) afterHistory.get();
+ new ExtentTraverser<>(getExtent()).setNext(afterHistory.get());
}
}
} else if (traverseHistory == null || !traverseHistory.exists()) {
- ExtentTraverser traverseBypass = new ExtentTraverser<>(this.extent).find(bypassHistory);
+ ExtentTraverser traverseBypass = new ExtentTraverser<>(getExtent()).find(bypassHistory);
if (traverseBypass != null) {
- ExtentTraverser beforeHistory = traverseBypass.previous();
+ ExtentTraverser beforeHistory = traverseBypass.previous();
beforeHistory.setNext(history);
}
}
@@ -938,12 +699,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @param blockBag the block bag to set, or null to use none
*/
public void setBlockBag(BlockBag blockBag) {
- this.blockBag = blockBag;
+ throw new UnsupportedOperationException("TODO - this is never called anyway");
}
@Override
public String toString() {
- return super.toString() + ":" + extent;
+ return super.toString() + ":" + getExtent();
}
/**
@@ -964,7 +725,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (changeSet instanceof BlockBagChangeSet) {
missingBlocks = ((BlockBagChangeSet) changeSet).popMissing();
} else {
- ExtentTraverser find = new ExtentTraverser<>(extent).find(BlockBagExtent.class);
+ ExtentTraverser find = new ExtentTraverser<>(getExtent()).find(BlockBagExtent.class);
if (find != null && find.get() != null) {
missingBlocks = find.get().popMissing();
} else {
@@ -1032,69 +793,46 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
@Override
- public BiomeType getBiome(BlockVector2 position) {
- return this.extent.getBiome(position);
+ public BiomeType getBiome(final BlockVector2 position) {
+ return this.getExtent().getBiome(position);
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
this.changes++;
- return this.extent.setBiome(position, biome);
+ return this.getExtent().setBiome(position, biome);
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
this.changes++;
- return this.extent.setBiome(x, y, z, biome);
- }
-
- @Override
- public int getLight(int x, int y, int z) {
- return queue.getLight(x, y, z);
- }
-
- @Override
- public int getBlockLight(int x, int y, int z) {
- return queue.getEmmittedLight(x, y, z);
- }
-
- @Override
- public int getSkyLight(int x, int y, int z) {
- return queue.getSkyLight(x, y, z);
- }
-
- @Override
- public int getBrightness(int x, int y, int z) {
- return queue.getBrightness(x, y, z);
- }
-
- @Override
- public int getOpacity(int x, int y, int z) {
- return queue.getOpacity(x, y, z);
- }
-
- @Override
- public BlockState getLazyBlock(final BlockVector3 position) {
- return getLazyBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
- }
-
- @Override
- public BlockState getLazyBlock(int x, int y, int z) {
- return extent.getLazyBlock(x, y, z);
+ return this.getExtent().setBiome(x, y, z, biome);
}
public BlockState getBlock(int x, int y, int z) {
- return getLazyBlock(x, y, z);
+ return getExtent().getBlock(x, y, z);
}
@Override
public BlockState getBlock(BlockVector3 position) {
- return extent.getBlock(position);
+ return getExtent().getBlock(position);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
- return extent.getFullBlock(position);
+ return getExtent().getFullBlock(position);
+ }
+
+ /**
+ * Get a block type at the given position.
+ *
+ * @param position the position
+ * @return the block type
+ * @deprecated Use {@link #getBlock(BlockVector3)} or {@link #getBlock(BlockVector3)}
+ */
+ @Deprecated
+ public BlockType getBlockType(final BlockVector3 position) {
+ return getBlockType(position.getBlockX(), position.getBlockY(), position.getBlockZ());
}
/**
@@ -1133,16 +871,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return y;
}
}
-
return minY;
}
public BlockType getBlockType(int x, int y, int z) {
- if (!limit.MAX_CHECKS()) {
- throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
- }
- int combinedId4Data = queue.getCombinedId4DataDebug(x, y, z, BlockTypes.AIR.getInternalId(), this);
- return BlockTypes.getFromStateId(combinedId4Data);
+ return getBlock(x, y, z).getBlockType();
}
/**
@@ -1158,7 +891,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
this.changes++;
switch (stage) {
case BEFORE_HISTORY:
- return extent.setBlock(position, block);
+ return this.getExtent().setBlock(position, block);
case BEFORE_CHANGE:
return bypassHistory.setBlock(position, block);
case BEFORE_REORDER:
@@ -1204,7 +937,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public > boolean setBlock(BlockVector3 position, B block) throws MaxChangedBlocksException {
this.changes++;
try {
- return extent.setBlock(position, block);
+ return this.getExtent().setBlock(position, block);
} catch (MaxChangedBlocksException e) {
throw e;
} catch (WorldEditException e) {
@@ -1217,7 +950,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public > boolean setBlock(int x, int y, int z, B block) {
this.changes++;
try {
- return this.extent.setBlock(x, y, z, block);
+ return this.getExtent().setBlock(x, y, z, block);
} catch (WorldEditException e) {
throw new RuntimeException("Unexpected exception", e);
}
@@ -1237,7 +970,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
this.changes++;
try {
BlockVector3 bv = mutablebv.setComponents(x, y, z);
- return pattern.apply(extent, bv, bv);
+ return pattern.apply(getExtent(), bv, bv);
} catch (WorldEditException e) {
throw new RuntimeException("Unexpected exception", e);
}
@@ -1254,7 +987,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public boolean setBlock(BlockVector3 position, Pattern pattern) throws MaxChangedBlocksException {
this.changes++;
try {
- return pattern.apply(this.extent, position, position);
+ return pattern.apply(this.getExtent(), position, position);
} catch (WorldEditException e) {
throw new RuntimeException(e);
}
@@ -1270,7 +1003,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int setBlocks(Set vset, Pattern pattern) throws MaxChangedBlocksException {
- RegionVisitor visitor = new RegionVisitor(vset, new BlockReplace(extent, pattern), this);
+ RegionVisitor visitor = new RegionVisitor(vset, new BlockReplace(getExtent(), pattern));
Operations.completeBlindly(visitor);
changes += visitor.getAffected();
return changes;
@@ -1307,7 +1040,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
@Override
@Nullable
public Entity createEntity(Location location, final BaseEntity entity) {
- return this.extent.createEntity(location, entity);
+ return getExtent().createEntity(location, entity);
}
/**
@@ -1380,30 +1113,22 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
@Override
public BlockVector3 getMinimumPoint() {
- if (extent != null) {
- return this.extent.getMinimumPoint();
- } else {
- return BlockVector3.at(-30000000, 0, -30000000);
- }
+ return getExtent().getMinimumPoint();
}
@Override
public BlockVector3 getMaximumPoint() {
- if (extent != null) {
- return this.extent.getMaximumPoint();
- } else {
- return BlockVector3.at(30000000, 255, 30000000);
- }
+ return getExtent().getMaximumPoint();
}
@Override
public List extends Entity> getEntities(Region region) {
- return this.extent.getEntities(region);
+ return getExtent().getEntities(region);
}
@Override
public List extends Entity> getEntities() {
- return this.extent.getEntities();
+ return getExtent().getEntities();
}
/**
@@ -1424,7 +1149,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
@Override
public @Nullable Operation commit() {
- return extent.commit();
+ return getExtent().commit();
}
/**
@@ -1437,7 +1162,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (used.MAX_FAILS > 0) {
if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) {
BBC.WORLDEDIT_SOME_FAILS.send(player, used.MAX_FAILS);
- } else if (new ExtentTraverser(this).findAndGet(FaweRegionExtent.class) != null){
+ } else if (new ExtentTraverser<>(getExtent()).findAndGet(FaweRegionExtent.class) != null){
BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION.send(player);
} else {
BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_LEVEL.send(player);
@@ -1446,15 +1171,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
// Reset limit
limit.set(originalLimit);
// Enqueue it
- if (queue == null || queue.isEmpty()) {
- queue.dequeue();
- return;
- }
- if (Fawe.isMainThread()) {
- SetQueue.IMP.flush(queue);
- } else {
- queue.flush();
- }
+ super.commit();
if (getChangeSet() != null) {
if (Settings.IMP.HISTORY.COMBINE_STAGES) {
((FaweChangeSet) getChangeSet()).closeAsync();
@@ -1464,65 +1181,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
}
- /**
- * Count the number of blocks of a given list of types in a region.
- *
- * @param region the region
- * @param searchIDs a list of IDs to search
- * @return the number of found blocks
- */
- public int countBlock(final Region region, final Set searchIDs) {
- if (searchIDs.isEmpty()) {
- return 0;
- }
- if (searchIDs.size() == 1) {
- final BlockType id = searchIDs.iterator().next();
- RegionVisitor visitor = new RegionVisitor(region, position -> getBlock(position).getBlockType() == id, this);
- Operations.completeBlindly(visitor);
- return visitor.getAffected();
- }
- final boolean[] ids = new boolean[BlockTypes.size()];
- for (final BlockType id : searchIDs) {
- ids[id.getInternalId()] = true;
- }
- return this.countBlock(region, ids);
- }
-
- public int countBlock(final Region region, final boolean[] ids) {
- RegionVisitor visitor = new RegionVisitor(region,
- position -> ids[getBlock(position).getInternalId()], this);
- Operations.completeBlindly(visitor);
- return visitor.getAffected();
- }
-
- public int countBlock(final Region region, final Mask mask) {
- RegionVisitor visitor = new RegionVisitor(region, mask::test, this);
- Operations.completeBlindly(visitor);
- return visitor.getAffected();
- }
-
- /**
- * Count the number of blocks of a list of types in a region.
- *
- * @param region the region
- * @param searchBlocks the list of blocks to search
- * @return the number of blocks that matched the pattern
- */
- public int countBlocks(Region region, Set searchBlocks) {
- Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(extent);
- RegionVisitor visitor = new RegionVisitor(region, mask::test, this);
- Operations.completeBlindly(visitor);
- return visitor.getAffected();
- }
-
public int fall(final Region region, boolean fullHeight, final BlockStateHolder replace) {
FlatRegion flat = asFlatRegion(region);
final int startPerformY = region.getMinimumPoint().getBlockY();
final int startCheckY = fullHeight ? 0 : startPerformY;
final int endY = region.getMaximumPoint().getBlockY();
RegionVisitor visitor = new RegionVisitor(flat, pos -> {
- int x = pos.getBlockX();
- int z = pos.getBlockZ();
+ int x = pos.getX();
+ int z = pos.getZ();
int freeSpot = startCheckY;
for (int y = startCheckY; y <= endY; y++) {
if (y < startPerformY) {
@@ -1571,7 +1237,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
final BlockReplace replace = new BlockReplace(EditSession.this, pattern);
// Pick how we're going to visit blocks
- RecursiveVisitor visitor = new DirectionalVisitor(mask, replace, origin, direction, (int) (radius * 2 + 1), this);
+ RecursiveVisitor visitor = new DirectionalVisitor(mask, replace, origin, direction, (int) (radius * 2 + 1));
// Start at the origin
visitor.visit(origin);
@@ -1626,9 +1292,9 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
// Pick how we're going to visit blocks
RecursiveVisitor visitor;
if (recursive) {
- visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), this);
+ visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1));
} else {
- visitor = new DownwardVisitor(mask, replace, origin.getBlockY(), (int) (radius * 2 + 1), this);
+ visitor = new DownwardVisitor(mask, replace, origin.getBlockY(), (int) (radius * 2 + 1));
}
// Start at the origin
@@ -1747,7 +1413,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
checkNotNull(position);
checkArgument(apothem >= 1, "apothem >= 1");
- Mask mask = new BlockTypeMask(this, blockType);
+ Mask mask = new SingleBlockTypeMask(this, blockType);
BlockVector3 adjustment = BlockVector3.ONE.multiply(apothem - 1);
Region region = new CuboidRegion(
getWorld(), // Causes clamping of Y range
@@ -1757,138 +1423,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return replaceBlocks(region, mask, pattern);
}
- /**
- * Sets all the blocks inside a region to a given block type.
- *
- * @param region the region
- * @param block the block
- * @return number of blocks affected
- * @throws MaxChangedBlocksException thrown if too many blocks are changed
- */
- public > int setBlocks(Region region, B block) throws MaxChangedBlocksException {
- checkNotNull(region);
- checkNotNull(block);
- boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
-
- if (canBypassAll(region, false, true) && !hasNbt) {
- return changes = queue.setBlocks((CuboidRegion) region, block.getInternalId());
- }
- try {
- if (hasExtraExtents()) {
- RegionVisitor visitor = new RegionVisitor(region, new BlockReplace(extent, (block)), this);
- Operations.completeBlindly(visitor);
- this.changes += visitor.getAffected();
- } else {
- for (BlockVector3 blockVector3 : region) {
- if (this.extent.setBlock(blockVector3, block)) {
- changes++;
- }
- }
- }
- } catch (final WorldEditException e) {
- throw new RuntimeException("Unexpected exception", e);
- }
- return changes;
- }
-
- /**
- * Sets all the blocks inside a region to a given pattern.
- *
- * @param region the region
- * @param pattern the pattern that provides the replacement block
- * @return number of blocks affected
- * @throws MaxChangedBlocksException thrown if too many blocks are changed
- */
- public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
- checkNotNull(region);
- checkNotNull(pattern);
-
- if (pattern instanceof BlockPattern) {
- return setBlocks(region, ((BlockPattern) pattern).getBlock());
- }
- if (pattern instanceof BlockStateHolder) {
- return setBlocks(region, (BlockStateHolder) pattern);
- }
- BlockReplace replace = new BlockReplace(this, pattern);
- RegionVisitor visitor = new RegionVisitor(region, replace, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null);
- Operations.completeBlindly(visitor);
- return this.changes = visitor.getAffected();
- }
-
- /**
- * Replaces all the blocks matching a given filter, within a given region, to a block
- * returned by a given pattern.
- *
- * @param region the region to replace the blocks within
- * @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
- * @param replacement the replacement block
- * @return number of blocks affected
- * @throws MaxChangedBlocksException thrown if too many blocks are changed
- */
- public > int replaceBlocks(Region region, Set filter, B replacement) throws MaxChangedBlocksException {
- return replaceBlocks(region, filter, replacement);
- }
-
- /**
- * Replaces all the blocks matching a given filter, within a given region, to a block
- * returned by a given pattern.
- *
- * @param region the region to replace the blocks within
- * @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
- * @param pattern the pattern that provides the new blocks
- * @return number of blocks affected
- * @throws MaxChangedBlocksException thrown if too many blocks are changed
- */
- public int replaceBlocks(Region region, Set filter, Pattern pattern) throws MaxChangedBlocksException {
- Mask mask = filter == null ? new ExistingBlockMask(this) : new BlockMaskBuilder().addBlocks(filter).build(this);
- return replaceBlocks(region, mask, pattern);
- }
-
- /**
- * Replaces all the blocks matching a given mask, within a given region, to a block
- * returned by a given pattern.
- *
- * @param region the region to replace the blocks within
- * @param mask the mask that blocks must match
- * @param pattern the pattern that provides the new blocks
- * @return number of blocks affected
- * @throws MaxChangedBlocksException thrown if too many blocks are changed
- */
- public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
- checkNotNull(region);
- checkNotNull(mask);
- checkNotNull(pattern);
-
- BlockReplace replace = new BlockReplace(this, pattern);
- RegionMaskingFilter filter = new RegionMaskingFilter(mask, replace);
- RegionVisitor visitor = new RegionVisitor(region, filter, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null);
- Operations.completeBlindly(visitor);
- return this.changes = visitor.getAffected();
- }
-
- /**
- * Sets the blocks at the center of the given region to the given pattern.
- * If the center sits between two blocks on a certain axis, then two blocks
- * will be placed to mark the center.
- *
- * @param region the region to find the center of
- * @param pattern the replacement pattern
- * @return the number of blocks placed
- * @throws MaxChangedBlocksException thrown if too many blocks are changed
- */
- public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
- checkNotNull(region);
- checkNotNull(pattern);
-
- Vector3 center = region.getCenter();
- Region centerRegion = new CuboidRegion(
- getWorld(), // Causes clamping of Y range
- BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
- BlockVector3.at(MathUtils.roundHalfUp(center.getX()),
- center.getY(), MathUtils.roundHalfUp(center.getZ())));
- return setBlocks(centerRegion, pattern);
- }
-
/**
* Make the faces of the given region as if it was a {@link CuboidRegion}.
*
@@ -1988,14 +1522,18 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (region instanceof CuboidRegion) {
return makeCuboidWalls(region, pattern);
} else {
- for (BlockVector3 position : region) {
- int x = position.getBlockX();
- int y = position.getBlockY();
- int z = position.getBlockZ();
- if (!region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains(x - 1, z)) {
- setBlock(position, pattern);
+ replaceBlocks(region, new Mask() {
+ @Override
+ public boolean test(BlockVector3 position) {
+ int x = position.getBlockX();
+ int y = position.getBlockY();
+ int z = position.getBlockZ();
+ if (!region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains(x - 1, z)) {
+ return true;
+ }
+ return false;
}
- }
+ }, pattern);
}
return changes;
}
@@ -2011,7 +1549,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
*/
public > int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException {
checkNotNull(block);
-
return overlayCuboidBlocks(region, block);
}
@@ -2033,7 +1570,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
int minY = region.getMinimumPoint().getBlockY();
int maxY = Math.min(getMaximumPoint().getBlockY(), region.getMaximumPoint().getBlockY() + 1);
SurfaceRegionFunction surface = new SurfaceRegionFunction(this, offset, minY, maxY);
- FlatRegionVisitor visitor = new FlatRegionVisitor(asFlatRegion(region), surface, this);
+ FlatRegionVisitor visitor = new FlatRegionVisitor(asFlatRegion(region), surface);
Operations.completeBlindly(visitor);
return this.changes = visitor.getAffected();
}
@@ -2197,7 +1734,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} else {
replace = new BlockReplace(this, BlockTypes.AIR.getDefaultState());
}
- RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), this);
+ RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1));
// Around the origin in a 3x3 block
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
@@ -2510,8 +2047,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
- int affected = 0;
-
radiusX += 0.5;
radiusY += 0.5;
radiusZ += 0.5;
@@ -3108,7 +2643,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
throw new RuntimeException(e);
}
}
- }, this);
+ });
Operations.completeBlindly(visitor);
changes += visitor.getAffected();
return changes;
@@ -3125,6 +2660,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
+ return hollowOutRegion(region, thickness, pattern, new SolidBlockMask(this));
+ }
+
+ public int hollowOutRegion(final Region region, final int thickness, final Pattern pattern, Mask mask) {
+ try {
final Set outside = new LocalBlockVectorSet();
final BlockVector3 min = region.getMinimumPoint();
@@ -3139,22 +2679,22 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
- recurseHollow(region, BlockVector3.at(x, y, minZ), outside);
- recurseHollow(region, BlockVector3.at(x, y, maxZ), outside);
+ recurseHollow(region, BlockVector3.at(x, y, minZ), outside, mask);
+ recurseHollow(region, BlockVector3.at(x, y, maxZ), outside, mask);
}
}
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
- recurseHollow(region, BlockVector3.at(minX, y, z), outside);
- recurseHollow(region, BlockVector3.at(maxX, y, z), outside);
+ recurseHollow(region, BlockVector3.at(minX, y, z), outside, mask);
+ recurseHollow(region, BlockVector3.at(maxX, y, z), outside, mask);
}
}
for (int z = minZ; z <= maxZ; ++z) {
for (int x = minX; x <= maxX; ++x) {
- recurseHollow(region, BlockVector3.at(x, minY, z), outside);
- recurseHollow(region, BlockVector3.at(x, maxY, z), outside);
+ recurseHollow(region, BlockVector3.at(x, minY, z), outside, mask);
+ recurseHollow(region, BlockVector3.at(x, maxY, z), outside, mask);
}
}
@@ -3180,14 +2720,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (outside.contains(neighbor)) {
continue outer;
- }
}
- this.changes++;
- try {
- pattern.apply(this.extent, position, position);
- } catch (WorldEditException e) {
- e.printStackTrace();
}
+ this.changes++;
+ pattern.apply(getExtent(), position, position);
+ }
+ } catch (WorldEditException e) {
+ throw new RuntimeException(e);
}
return changes;
}
@@ -3400,29 +2939,29 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return returnset;
}
- private void recurseHollow(Region region, BlockVector3 origin, Set outside) {
+ private void recurseHollow(Region region, BlockVector3 origin, Set outside, Mask mask) {
final LocalBlockVectorSet queue = new LocalBlockVectorSet();
queue.add(origin);
while (!queue.isEmpty()) {
- final BlockVector3 current = queue.getIndex(0);
- queue.remove(current);
- final BlockState block = getBlock(current);
- if (block.getBlockType().getMaterial().isMovementBlocker()) {
- continue;
- }
+ Iterator iter = queue.iterator();
+ while (iter.hasNext()) {
+ final BlockVector3 current = iter.next();
+ iter.remove();
+ if (mask.test(current)) {
+ continue;
+ }
+ if (!outside.add(current)) {
+ continue;
+ }
+ if (!region.contains(current)) {
+ continue;
+ }
- if (!outside.add(current)) {
- continue;
- }
-
- if (!region.contains(current)) {
- continue;
- }
-
- for (BlockVector3 recurseDirection : recurseDirections) {
- queue.add(current.add(recurseDirection));
- }
+ for (BlockVector3 recurseDirection : recurseDirections) {
+ queue.add(current.add(recurseDirection));
+ }
+ }
}
}
@@ -3497,19 +3036,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return null;
}
- @Override
- public int getBlockLightLevel(BlockVector3 position) {
- return queue.getEmmittedLight(position.getBlockX(), position.getBlockY(), position.getBlockZ());
- }
-
@Override
public boolean clearContainerBlockContents(BlockVector3 pos) {
BaseBlock block = getFullBlock(pos);
CompoundTag nbt = block.getNbtData();
if (nbt != null) {
if (nbt.containsKey("items")) {
- block.setNbtData(null);
- return setBlock(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), block);
+ return setBlock(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), block.toBlockState().toBaseBlock());
}
}
return false;
@@ -3528,14 +3061,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
- int from = queue.getCombinedId4Data(x, y, z);
- queue.setBlock(x, y, z, from);
- if (BlockTypes.getFromStateId(from).getMaterial().hasContainer()) {
- CompoundTag tile = queue.getTileEntity(x, y, z);
- if (tile != null) {
- queue.setTile(x, y, z, tile);
- }
- }
+ setBlock(x, y, z, getFullBlock(x, y, z));
}
}
}
@@ -3552,7 +3078,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
BlockVector3 max = region.getMaximumPoint();
BlockVector3 min = region.getMinimumPoint();
if (!fe.contains(max.getBlockX(), max.getBlockY(), max.getBlockZ()) && !fe.contains(min.getBlockX(), min.getBlockY(), min.getBlockZ())) {
- throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
+ throw FaweException.OUTSIDE_REGION;
}
}
final Set chunks = region.getChunks();
@@ -3639,8 +3165,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (changes != 0) {
flushQueue();
return true;
- } else {
- this.queue.clear();
}
return false;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java
index df32908f4..6dc8df7b7 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java
@@ -38,6 +38,7 @@ import com.boydti.fawe.util.MaskTraverser;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.minecraft.util.commands.CommandContext;
+
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
@@ -91,6 +92,7 @@ import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
+
/**
* Clipboard commands.
*/
@@ -123,20 +125,24 @@ public class ClipboardCommands {
Mask mask, CommandContext context) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
+
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit();
if (volume >= limit.MAX_CHECKS) {
- throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
+ throw FaweException.MAX_CHECKS;
}
fp.checkConfirmationRegion(() -> {
session.setClipboard(null);
+
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
+
session.setClipboard(new ClipboardHolder(clipboard));
clipboard.setOrigin(session.getPlacementPosition(player));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setCopyingEntities(!skipEntities);
copy.setCopyingBiomes(copyBiomes);
+
Mask sourceMask = editSession.getSourceMask();
if (sourceMask != null) {
new MaskTraverser(sourceMask).reset(editSession);
@@ -204,12 +210,13 @@ public class ClipboardCommands {
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit();
if (volume >= limit.MAX_CHECKS) {
- throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
+ throw FaweException.MAX_CHECKS;
}
if (volume >= limit.MAX_CHANGES) {
- throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
+ throw FaweException.MAX_CHANGES;
}
session.setClipboard(null);
+
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
clipboard.setOrigin(session.getPlacementPosition(player));
@@ -221,6 +228,7 @@ public class ClipboardCommands {
name = "/cut",
desc = "Cut the selection to the clipboard",
descFooter = "WARNING: Cutting and pasting entities cannot be undone!"
+
)
@CommandPermissions("worldedit.clipboard.cut")
@Logging(REGION)
@@ -237,21 +245,24 @@ public class ClipboardCommands {
CommandContext context) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
+
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit();
if (volume >= limit.MAX_CHECKS) {
- throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
+ throw FaweException.MAX_CHECKS;
}
if (volume >= limit.MAX_CHANGES) {
- throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
+ throw FaweException.MAX_CHANGES;
}
fp.checkConfirmationRegion(() -> {
session.setClipboard(null);
+
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
clipboard.setOrigin(session.getPlacementPosition(player));
+
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
- copy.setCopyingEntities(!skipEntities);
+ copy.setCopyingEntities(copyEntities);
copy.setRemovingEntities(true);
copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask();
@@ -413,6 +424,7 @@ public class ClipboardCommands {
@Command(
name = "/paste",
desc = "Paste the clipboard's contents"
+
)
@CommandPermissions("worldedit.clipboard.paste")
@Logging(PLACEMENT)
@@ -481,6 +493,7 @@ public class ClipboardCommands {
name = "/place",
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
)
+
@CommandPermissions("worldedit.clipboard.place")
@Logging(PLACEMENT)
public void place(Player player, LocalSession session, final EditSession editSession,
@@ -551,6 +564,7 @@ public class ClipboardCommands {
public void flip(Player player, LocalSession session,
@Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM)
@Direction BlockVector3 direction) throws WorldEditException {
+
ClipboardHolder holder = session.getClipboard();
AffineTransform transform = new AffineTransform();
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
@@ -563,7 +577,7 @@ public class ClipboardCommands {
desc = "Clear your clipboard"
)
@CommandPermissions("worldedit.clipboard.clear")
- public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
+ public void clearClipboard(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
session.setClipboard(null);
BBC.CLIPBOARD_CLEARED.send(player);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java
index 6635883c0..6ad38305f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java
@@ -205,6 +205,7 @@ public class PatternCommands extends MethodCommands {
" - Use to replace slabs or where the data values needs to be shifted instead of set"
)
public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
+
return new IdDataMaskPattern(extent, pattern, bitmask);
}
@@ -213,6 +214,7 @@ public class PatternCommands extends MethodCommands {
desc = "Only change the block id"
)
public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+
return new IdPattern(extent, pattern);
}
@@ -221,6 +223,7 @@ public class PatternCommands extends MethodCommands {
desc = "Only change the block data"
)
public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+
return new DataPattern(extent, pattern);
}
@@ -230,6 +233,7 @@ public class PatternCommands extends MethodCommands {
desc = "Set the biome"
)
public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
+
return new BiomePattern(extent, biome);
}
@@ -239,6 +243,7 @@ public class PatternCommands extends MethodCommands {
desc = "Offset the pattern to where you click"
)
public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+
return new RelativePattern(pattern);
}
@@ -250,6 +255,7 @@ public class PatternCommands extends MethodCommands {
"Example: #!x[#!z[#~[#l3d[pattern]]]]"
)
public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+
return new NoXPattern(pattern);
}
@@ -259,6 +265,7 @@ public class PatternCommands extends MethodCommands {
desc = "The pattern will not be provided the y axis info"
)
public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+
return new NoYPattern(pattern);
}
@@ -268,6 +275,7 @@ public class PatternCommands extends MethodCommands {
desc = "The pattern will not be provided the z axis info"
)
public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
+
return new NoZPattern(pattern);
}
@@ -285,6 +293,7 @@ public class PatternCommands extends MethodCommands {
desc = "Offset a pattern"
)
public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
+
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@@ -293,6 +302,7 @@ public class PatternCommands extends MethodCommands {
desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given ranomized offset `[0, )`. e.g. Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard"
)
public Pattern surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
+
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
}
@@ -301,6 +311,7 @@ public class PatternCommands extends MethodCommands {
desc = "Randomly spread solid blocks"
)
public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
+
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@@ -310,6 +321,7 @@ public class PatternCommands extends MethodCommands {
desc = "Randomly spread blocks"
)
public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
+
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
}
@@ -319,6 +331,7 @@ public class PatternCommands extends MethodCommands {
desc = "Sequentially set blocks from a list of patterns"
)
public Pattern linear(Actor actor, LocalSession session, Pattern other) {
+
if (other instanceof RandomPattern) {
Set patterns = ((RandomPattern) other).getPatterns();
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
@@ -332,6 +345,7 @@ public class PatternCommands extends MethodCommands {
desc = "Use the x,y,z coordinate to pick a block from the list"
)
public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
+
if (other instanceof RandomPattern) {
Set patterns = ((RandomPattern) other).getPatterns();
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
@@ -345,6 +359,7 @@ public class PatternCommands extends MethodCommands {
desc = "Use the x,z coordinate to pick a block from the list"
)
public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
+
if (other instanceof RandomPattern) {
Set patterns = ((RandomPattern) other).getPatterns();
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
@@ -358,6 +373,7 @@ public class PatternCommands extends MethodCommands {
desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax"
)
public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
+
Expression exp = Expression.compile(input, "x", "y", "z");
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
exp.setEnvironment(env);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java
index f961fb9e7..430ee04a9 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java
@@ -29,7 +29,11 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
+
import com.boydti.fawe.FaweAPI;
+import com.boydti.fawe.beta.filters.SetFilter;
+import com.boydti.fawe.beta.implementation.QueueHandler;
+import com.boydti.fawe.beta.filters.DistrFilter;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.object.FaweLimit;
@@ -54,6 +58,7 @@ import com.sk89q.worldedit.function.generator.FloraGenerator;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
+import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.LayerVisitor;
@@ -76,9 +81,11 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.util.command.binding.Range;
import com.sk89q.worldedit.util.command.parametric.Optional;
+import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes;
+import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.ArrayList;
@@ -109,6 +116,43 @@ public class RegionCommands {
this.worldEdit = worldEdit;
}
+
+ @Command(
+ aliases = {"debugtest"},
+ usage = "",
+ desc = "debugtest",
+ help = "debugtest"
+ )
+ @CommandPermissions("fawe.admin.debug")
+ public void debugtest(Player player, @Selection Region region) throws WorldEditException {
+ QueueHandler queueHandler = Fawe.get().getQueueHandler();
+ World world = player.getWorld();
+ DistrFilter filter = new DistrFilter();
+ long start = System.currentTimeMillis();
+ queueHandler.apply(world, region, filter);
+ long diff = System.currentTimeMillis() - start;
+ System.out.println(diff);
+ }
+
+ @Command(
+ aliases = {"db2"},
+ usage = "",
+ desc = "db2",
+ help = "db2"
+ )
+ @CommandPermissions("fawe.admin.debug")
+ public void db2(Player player, @Selection Region region, String blockStr) throws WorldEditException {
+ QueueHandler queueHandler = Fawe.get().getQueueHandler();
+ World world = player.getWorld();
+ BlockState block = BlockState.get(blockStr);
+ SetFilter filter = new SetFilter(block);
+ long start = System.currentTimeMillis();
+ queueHandler.apply(world, region, filter);
+ long diff = System.currentTimeMillis() - start;
+ System.out.println(diff);
+ }
+
+
@Command(
name = "/fixlighting",
desc = "Get the light at a position"
@@ -417,7 +461,7 @@ public class RegionCommands {
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit();
if (volume >= limit.MAX_CHECKS) {
- throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
+ throw FaweException.MAX_CHECKS;
}
player.checkConfirmationRegion(() -> {
try {
@@ -673,6 +717,7 @@ public class RegionCommands {
descFooter = "Hollows out the object contained in this selection.\n" +
"Optionally fills the hollowed out part with the given block.\n" +
"Thickness is measured in manhattan distance."
+
)
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)
@@ -682,9 +727,11 @@ public class RegionCommands {
int thickness,
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
Pattern pattern,
+
CommandContext context) throws WorldEditException {
+ Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
player.checkConfirmationRegion(() -> {
- int affected = editSession.hollowOutRegion(region, thickness, pattern);
+ int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
BBC.VISITOR_BLOCK.send(player, affected);
}, getArguments(context), region, context);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
index 021b0c3ae..fd0768c86 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
@@ -31,6 +31,7 @@ import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
import com.boydti.fawe.object.schematic.StructureFormat;
+
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.chat.Message;
import com.sk89q.minecraft.util.commands.CommandContext;
@@ -80,6 +81,7 @@ import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Callable;
+
import java.util.regex.Pattern;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
@@ -403,8 +405,8 @@ public class SchematicCommands {
}
if (new PlayerSaveClipboardEvent(player, clipboard, uri, f.toURI()).call()) {
try (ClipboardWriter writer = format.getWriter(fos)) {
- if (writer instanceof StructureFormat) {
- ((StructureFormat) writer).write(target, player.getName());
+ if (writer instanceof MinecraftStructure) {
+ ((MinecraftStructure) writer).write(target, player.getName());
} else {
writer.write(target);
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
index 676dda1b0..5c2280bb6 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
@@ -27,6 +27,7 @@ import com.boydti.fawe.object.clipboard.URIClipboardHolder;
import com.boydti.fawe.object.mask.IdMask;
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
+
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@@ -490,7 +491,7 @@ public class SelectionCommands {
// TODO multi clipboard distribution
Clipboard clipboard = session.getClipboard().getClipboard(); // throws if missing
region = clipboard.getRegion();
- editSession.setExtent(new AbstractDelegateExtent(clipboard));
+ new ExtentTraverser(editSession).setNext(new AbstractDelegateExtent(clipboard));
} else {
region = session.getSelection(player.getWorld());
}
@@ -499,6 +500,7 @@ public class SelectionCommands {
else
distribution = (List) editSession.getBlockDistribution(region);
+
if (distribution.isEmpty()) { // *Should* always be false
player.printError("No blocks counted.");
return;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java
index 86c28e49a..23cc8d029 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java
@@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import com.boydti.fawe.Fawe;
+
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.DelegateConsumer;
@@ -60,6 +61,7 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.EntityVisitor;
+
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.math.BlockVector3;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java
index 3043bae7c..b8648f74b 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java
@@ -75,6 +75,7 @@ public class WorldEditCommands {
FaweVersion fVer = Fawe.get().getVersion();
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92");
+
if (fVer != null) {
actor.printDebug("----------- Platforms -----------");
FaweVersion version = Fawe.get().getVersion();
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java
index 87c69438c..b63b1f406 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java
@@ -48,6 +48,7 @@ import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
+import com.sk89q.worldedit.MaxBrushRadiusException;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
@@ -643,15 +644,16 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
Brush brush = current.getBrush();
if (brush == null) return;
FawePlayer