diff --git a/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md b/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md index 47f004ca3..261b049fb 100644 --- a/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md +++ b/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md @@ -1,5 +1,5 @@ --- -name: Bug / Issue report for FastAsyncWorldEdit v1.15.2 +name: Bug / Issue report for FastAsyncWorldEdit v1.16.1 about: Bug / Issue report about this plugin title: '' labels: Requires Testing @@ -7,9 +7,9 @@ assignees: '' --- -# Bug report for FastAsyncWorldEdit 1.15.2 - - +# Bug report for FastAsyncWorldEdit 1.16.1 + + @@ -41,5 +41,5 @@ assignees: '' - [] I included all information required in the sections above - [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/IntellectualSites/FastAsyncWorldEdit/issues?q=is%3Aissue) -- [] I made sure I am using an up-to-date version of [FastAsyncWorldEdit for 1.15.2](https://ci.athion.net/job/FastAsyncWorldEdit-1.15/) +- [] I made sure I am using an up-to-date version of [FastAsyncWorldEdit for 1.16.1](https://ci.athion.net/job/FastAsyncWorldEdit-1.16/) - [] I made sure the bug/error is not caused by any other plugin diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ac23f5a75..58e192ab0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -16,4 +16,4 @@ You can do so here: https://github.com/IntellectualSites/FastAsyncWorldEdit/issu - [] I included all information required in the sections above - [] I tested my changes and approved their functionality - [] I ensured my changes do not break other parts of the code -- [] I read and followed the [contribution guidelines](https://github.com/IntellectualSites/FastAsyncWorldEdit/blob/1.15/CONTRIBUTING.md) +- [] I read and followed the [contribution guidelines](https://github.com/IntellectualSites/FastAsyncWorldEdit/blob/1.16/CONTRIBUTING.md) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 96e52b293..016f67f78 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -3,10 +3,10 @@ name: Java CI on: push: branches: - - '1.15' + - '1.16' pull_request: branches: - - '1.15' + - '1.16' jobs: test: diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 000000000..f6ad72628 --- /dev/null +++ b/NOTICE.txt @@ -0,0 +1,18 @@ +This project uses code from the following projects. In some cases the code used may be modified. + +SnakeYAML + +Copyright (c) 2008, http://www.snakeyaml.org + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + diff --git a/README.md b/README.md index 09b28f24b..8c90a3c07 100644 --- a/README.md +++ b/README.md @@ -11,20 +11,15 @@ FAWE is a fork of WorldEdit that has huge speed and memory improvements and cons * [Spigot Page](https://www.spigotmc.org/threads/fast-async-worldedit.100104/) * [Discord](https://discord.gg/KxkjDVg) * [Wiki](https://wiki.intellectualsites.com/FastAsyncWorldEdit/index) -* [Report Issue](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues) +* [Report Issue](https://github.com/IntellectualSites/FastAsyncWorldEdit/issues) * [Crowdin](https://intellectualsites.crowdin.com/fastasyncworldedit) +* [JavaDocs](https://ci.athion.net/job/FastAsyncWorldEdit-1.16/javadoc/) ## Downloads -### 1.13+ +### 1.14+ * [Download](https://intellectualsites.github.io/download/fawe.html) * [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-1.16/) -### < 1.12.2 -* [Download](https://intellectualsites.github.io/download/fawe.html) -* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit/) -* [Repository](https://github.com/boy0001/FastAsyncWorldedit) -* [JavaDoc](https://ci.athion.net/job/FastAsyncWorldEdit/javadoc/) - ## Building FAWE uses gradle to build @@ -32,7 +27,7 @@ You can safely ignore `gradlew setupDecompWorkspace` if you are not planning to ``` $ gradlew setupDecompWorkspace -$ gradlew build +$ gradlew clean build -x test ``` The jar is located in `worldedit-bukkit/build/libs/FastAsyncWorldEdit-1.16-###.jar` diff --git a/build.gradle.kts b/build.gradle.kts index 84e6e066f..1c05b06ab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,10 +51,10 @@ version = String.format("%s-%s", rootVersion, buildNumber) if (!project.hasProperty("gitCommitHash")) { apply(plugin = "org.ajoberstar.grgit") ext["gitCommitHash"] = try { - (ext["grgit"] as Grgit?)?.head()?.abbreviatedId + extensions.getByName("grgit").head()?.abbreviatedId } catch (e: Exception) { logger.warn("Error getting commit hash", e) - "no_git_id" + "no.git.id" } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 138c405f0..60f5ff779 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -30,9 +30,9 @@ configurations.all { resolutionStrategy { // Fabric needs this. force( - "commons-io:commons-io:2.5", - "org.ow2.asm:asm:7.1", - "org.ow2.asm:asm-commons:7.1" + "commons-io:commons-io:2.6", + "org.ow2.asm:asm:8.0.1", + "org.ow2.asm:asm-commons:8.0.1" ) } } @@ -48,13 +48,13 @@ val mixinVersion: String = properties.getProperty("mixin.version") dependencies { implementation(gradleApi()) implementation("gradle.plugin.net.minecrell:licenser:0.4.1") - implementation("org.ajoberstar.grgit:grgit-gradle:3.1.1") - implementation("com.github.jengelman.gradle.plugins:shadow:5.1.0") + implementation("org.ajoberstar.grgit:grgit-gradle:4.0.2") + implementation("com.github.jengelman.gradle.plugins:shadow:5.2.0") implementation("net.ltgt.apt-eclipse:net.ltgt.apt-eclipse.gradle.plugin:0.21") implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21") - implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7") + implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.16.0") implementation("gradle.plugin.org.spongepowered:spongegradle:0.9.0") - implementation("net.minecraftforge.gradle:ForgeGradle:3.0.168") + implementation("net.minecraftforge.gradle:ForgeGradle:3.0.179") implementation("net.fabricmc:fabric-loom:$loomVersion") implementation("net.fabricmc:sponge-mixin:$mixinVersion") implementation("gradle.plugin.com.mendhak.gradlecrowdin:plugin:0.1.0") diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt index 197e4bcde..f8fd2f797 100644 --- a/buildSrc/src/main/kotlin/CommonConfig.kt +++ b/buildSrc/src/main/kotlin/CommonConfig.kt @@ -10,7 +10,7 @@ fun Project.applyCommonConfiguration() { mavenLocal() maven { url = uri("https://mvn.intellectualsites.com/content/groups/public/") } maven { url = uri("https://plotsquared.com/mvn/") } - maven { url = uri("https://maven.sk89q.com/repo/") } + maven { url = uri("https://maven.enginehub.org/repo/") } maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") } maven { url = uri("https://ci.athion.net/plugin/repository/tools/") } maven { url = uri("https://repo.destroystokyo.com/repository/maven-public") } @@ -21,7 +21,7 @@ fun Project.applyCommonConfiguration() { } configurations.all { resolutionStrategy { - cacheChangingModulesFor(5, "minutes") + cacheChangingModulesFor(5, "MINUTES") } } } diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index 0c573871c..da14d923c 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -22,7 +22,7 @@ fun Project.applyPlatformAndCoreConfiguration() { apply(plugin = "java") apply(plugin = "idea") apply(plugin = "maven") - //apply(plugin = "checkstyle") +// apply(plugin = "checkstyle") apply(plugin = "com.github.johnrengelman.shadow") ext["internalVersion"] = "$version;${rootProject.ext["gitCommitHash"]}" @@ -34,7 +34,7 @@ fun Project.applyPlatformAndCoreConfiguration() { // configure { // configFile = rootProject.file("config/checkstyle/checkstyle.xml") -// toolVersion = "7.6.1" +// toolVersion = "8.34" // } tasks.withType().configureEach { diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 4b3bb46e9..3985105db 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -3,7 +3,7 @@ import org.gradle.api.Project object Versions { const val TEXT = "3.0.4" const val TEXT_EXTRAS = "3.0.5" - const val PISTON = "0.5.5" + const val PISTON = "0.5.6" const val AUTO_VALUE = "1.7" const val JUNIT = "5.6.1" const val MOCKITO = "3.3.3" diff --git a/config/checkstyle/checkstyle-suppression.xml b/config/checkstyle/checkstyle-suppression.xml new file mode 100644 index 000000000..a48ff1f81 --- /dev/null +++ b/config/checkstyle/checkstyle-suppression.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 8dbf07f8f..760dab104 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -1,73 +1,201 @@ - + - - - - - - - - - + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> - +Checks based on Google Checks, modified for EngineHub. + --> - - - - - - - - + + - - - - - - + - - - + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + - - + + - - - - - - - - - - - - - - - - - - diff --git a/config/checkstyle/import-control.xml b/config/checkstyle/import-control.xml deleted file mode 100644 index d15b7ac92..000000000 --- a/config/checkstyle/import-control.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 6a5327618..259486a00 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -29,12 +29,6 @@ import com.boydti.fawe.util.image.ImageViewer; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitPlayer; import io.papermc.lib.PaperLib; -import java.io.File; -import java.io.FileOutputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.UUID; -import java.util.function.Supplier; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -47,6 +41,13 @@ import org.bukkit.plugin.PluginManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.UUID; +import java.util.function.Supplier; + public class FaweBukkit implements IFawe, Listener { private static final Logger log = LoggerFactory.getLogger(FaweBukkit.class); @@ -83,18 +84,20 @@ public class FaweBukkit implements IFawe, Listener { Bukkit.getServer().shutdown(); } - chunksStretched = Integer.parseInt(Bukkit.getBukkitVersion().split("-")[0].split("\\.")[1]) >= 16; - + chunksStretched = + Integer.parseInt(Bukkit.getBukkitVersion().split("-")[0].split("\\.")[1]) >= 16; + //Vault is Spigot/Paper only so this needs to be done in the Bukkit module setupVault(); - + //PlotSquared support is limited to Spigot/Paper as of 02/20/2020 TaskManager.IMP.later(this::setupPlotSquared, 0); - + // Registered delayed Event Listeners TaskManager.IMP.task(() -> { // Fix for ProtocolSupport - Settings.IMP.PROTOCOL_SUPPORT_FIX = Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport"); + Settings.IMP.PROTOCOL_SUPPORT_FIX = + Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport"); // This class Bukkit.getPluginManager().registerEvents(FaweBukkit.this, FaweBukkit.this.plugin); @@ -112,28 +115,31 @@ public class FaweBukkit implements IFawe, Listener { } } - @Override - public QueueHandler getQueueHandler() { + @Override public QueueHandler getQueueHandler() { return new BukkitQueueHandler(); } @Override public synchronized ImageViewer getImageViewer(com.sk89q.worldedit.entity.Player player) { - if (listeningImages && imageListener == null) return null; + if (listeningImages && imageListener == null) { + return null; + } try { listeningImages = true; registerPacketListener(); PluginManager manager = Bukkit.getPluginManager(); if (manager.getPlugin("PacketListenerApi") == null) { - File output = new File(plugin.getDataFolder().getParentFile(), "PacketListenerAPI_v3.7.6-SNAPSHOT.jar"); + File output = new File(plugin.getDataFolder().getParentFile(), + "PacketListenerAPI_v3.7.6-SNAPSHOT.jar"); byte[] jarData = Jars.PL_v3_7_6.download(); try (FileOutputStream fos = new FileOutputStream(output)) { fos.write(jarData); } } if (manager.getPlugin("MapManager") == null) { - File output = new File(plugin.getDataFolder().getParentFile(), "MapManager_v1.7.8-SNAPSHOT.jar"); + File output = new File(plugin.getDataFolder().getParentFile(), + "MapManager_v1.7.8-SNAPSHOT.jar"); byte[] jarData = Jars.MM_v1_7_8.download(); try (FileOutputStream fos = new FileOutputStream(output)) { fos.write(jarData); @@ -144,17 +150,16 @@ public class FaweBukkit implements IFawe, Listener { this.imageListener = new BukkitImageListener(plugin); } return viewer; - } catch (Throwable ignore) {} + } catch (Throwable ignore) { + } return null; } - @Override - public void debug(final String message) { + @Override public void debug(final String message) { Bukkit.getConsoleSender().sendMessage(message); } - @Override - public File getDirectory() { + @Override public File getDirectory() { return plugin.getDataFolder(); } @@ -172,9 +177,6 @@ public class FaweBukkit implements IFawe, Listener { return tmp; } - /** - * Vault isn't required, but used for setting player permissions (WorldEdit bypass) - */ private void setupVault() { try { this.vault = new VaultUtil(); @@ -182,8 +184,7 @@ public class FaweBukkit implements IFawe, Listener { } } - @Override - public String getDebugInfo() { + @Override public String getDebugInfo() { StringBuilder msg = new StringBuilder(); msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n"); msg.append("Plugins: \n"); @@ -195,10 +196,9 @@ public class FaweBukkit implements IFawe, Listener { } /** - * The task manager handles sync/async tasks + * The task manager handles sync/async tasks. */ - @Override - public TaskManager getTaskManager() { + @Override public TaskManager getTaskManager() { return new BukkitTaskMan(plugin); } @@ -209,9 +209,9 @@ public class FaweBukkit implements IFawe, Listener { /** * A mask manager handles region restrictions e.g., PlotSquared plots / WorldGuard regions */ - @Override - public Collection getMaskManagers() { - final Plugin worldguardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"); + @Override public Collection getMaskManagers() { + final Plugin worldguardPlugin = + Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"); final ArrayList managers = new ArrayList<>(); if (worldguardPlugin != null && worldguardPlugin.isEnabled()) { try { @@ -236,7 +236,8 @@ public class FaweBukkit implements IFawe, Listener { } catch (Throwable ignored) { } } - final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention"); + final Plugin griefpreventionPlugin = + Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention"); if (griefpreventionPlugin != null && griefpreventionPlugin.isEnabled()) { try { managers.add(new GriefPreventionFeature(griefpreventionPlugin)); @@ -258,8 +259,7 @@ public class FaweBukkit implements IFawe, Listener { private volatile boolean keepUnloaded; - @EventHandler(priority = EventPriority.MONITOR) - public void onWorldLoad(WorldLoadEvent event) { + @EventHandler(priority = EventPriority.MONITOR) public void onWorldLoad(WorldLoadEvent event) { if (keepUnloaded) { org.bukkit.World world = event.getWorld(); world.setKeepSpawnInMemory(false); @@ -282,38 +282,34 @@ public class FaweBukkit implements IFawe, Listener { wePlayer.unregister(); } - @Override - public String getPlatform() { + @Override public String getPlatform() { return "Bukkit"; } - @Override - public UUID getUUID(String name) { + @Override public UUID getUUID(String name) { return Bukkit.getOfflinePlayer(name).getUniqueId(); } - @Override - public String getName(UUID uuid) { + @Override public String getName(UUID uuid) { return Bukkit.getOfflinePlayer(uuid).getName(); } - @Override - public Preloader getPreloader() { + @Override public Preloader getPreloader() { if (PaperLib.isPaper()) { return new AsyncPreloader(); } return null; } - @Override - public boolean isChunksStretched() { + @Override public boolean isChunksStretched() { return chunksStretched; } private void setupPlotSquared() { Plugin plotSquared = this.plugin.getServer().getPluginManager().getPlugin("PlotSquared"); - if (plotSquared == null) + if (plotSquared == null) { return; + } if (plotSquared.getClass().getPackage().toString().contains("intellectualsites")) { WEManager.IMP.managers .add(new com.boydti.fawe.bukkit.regions.plotsquaredv4.PlotSquaredFeature()); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java index fd5902df1..4df159b0b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java @@ -1,7 +1,5 @@ package com.boydti.fawe.bukkit.adapter.mc1_14; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IChunkSet; @@ -28,21 +26,6 @@ import com.sk89q.worldedit.internal.Constants; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; -import java.util.AbstractSet; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.HashMap; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.concurrent.Future; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; import net.minecraft.server.v1_14_R1.BiomeBase; import net.minecraft.server.v1_14_R1.BlockPosition; import net.minecraft.server.v1_14_R1.Chunk; @@ -72,6 +55,25 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.AbstractSet; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import static org.slf4j.LoggerFactory.getLogger; + +@SuppressWarnings("checkstyle:TypeName") public class BukkitGetBlocks_1_14 extends CharGetBlocks { private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_14.class); @@ -79,26 +81,27 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { public ChunkSection[] sections; public Chunk nmsChunk; public WorldServer world; - public int X, Z; + public int chunkX; + public int chunkZ; public NibbleArray[] blockLight = new NibbleArray[16]; public NibbleArray[] skyLight = new NibbleArray[16]; - public BukkitGetBlocks_1_14(World world, int X, int Z) { - this(((CraftWorld) world).getHandle(), X, Z); + public BukkitGetBlocks_1_14(World world, int chunkX, int chunkZ) { + this(((CraftWorld) world).getHandle(), chunkX, chunkZ); } - public BukkitGetBlocks_1_14(WorldServer world, int X, int Z) { + public BukkitGetBlocks_1_14(WorldServer world, int chunkX, int chunkZ) { this.world = world; - this.X = X; - this.Z = Z; + this.chunkX = chunkX; + this.chunkZ = chunkZ; } public int getX() { - return X; + return chunkX; } public int getZ() { - return Z; + return chunkZ; } @Override @@ -109,16 +112,21 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { @Override public CompoundTag getTile(int x, int y, int z) { - TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4))); + TileEntity tileEntity = getChunk().getTileEntity( + new BlockPosition((x & 15) + (chunkX << 4), y, (z & 15) + (chunkZ << 4))); if (tileEntity == null) { return null; } - return new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); + return new LazyCompoundTag_1_14( + Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); } - private static final Function posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ()); + private static final Function posNms2We = + v -> BlockVector3.at(v.getX(), v.getY(), v.getZ()); - private final static Function nmsTile2We = tileEntity -> new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); + private static final Function nmsTile2We = + tileEntity -> new LazyCompoundTag_1_14( + Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); @Override public Map getTiles() { @@ -135,19 +143,23 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { if (skyLight[layer] == null) { //getDataLayerData SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); - NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition); + NibbleArray nibbleArray = + world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { - byte[] a = new byte[2048]; - // Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway. - Arrays.fill(a, (byte) 15); - nibbleArray = new NibbleArray(a); - ((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.SKY, sectionPosition, nibbleArray); + byte[] a = new byte[2048]; + // Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway. + Arrays.fill(a, (byte) 15); + nibbleArray = new NibbleArray(a); + ((LightEngine) world.getChunkProvider().getLightEngine()) + .a(EnumSkyBlock.SKY, sectionPosition, nibbleArray); } skyLight[layer] = nibbleArray; } long l = BlockPosition.a(x, y, z); - return skyLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l))); + return skyLight[layer] + .a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), + SectionPosition.b(BlockPosition.d(l))); } @Override @@ -156,19 +168,23 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { if (blockLight[layer] == null) { //getDataLayerData SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); - NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); + NibbleArray nibbleArray = + world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { byte[] a = new byte[2048]; // Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway. Arrays.fill(a, (byte) 15); nibbleArray = new NibbleArray(a); - ((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.BLOCK, sectionPosition, nibbleArray); + ((LightEngine) world.getChunkProvider().getLightEngine()) + .a(EnumSkyBlock.BLOCK, sectionPosition, nibbleArray); } blockLight[layer] = nibbleArray; } long l = BlockPosition.a(x, y, z); - return blockLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l))); + return blockLight[layer] + .a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), + SectionPosition.b(BlockPosition.d(l))); } @Override @@ -196,7 +212,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { List[] slices = getChunk().getEntitySlices(); int size = 0; for (List slice : slices) { - if (slice != null) size += slice.size(); + if (slice != null) { + size += slice.size(); + } } if (slices.length == 0) { return Collections.emptySet(); @@ -238,19 +256,21 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { @NotNull @Override public Iterator iterator() { - Iterable result = StreamSupport - .stream(Iterables.concat(slices).spliterator(), false).map(input -> { - BukkitImplAdapter adapter = WorldEditPlugin.getInstance() - .getBukkitImplAdapter(); - NBTTagCompound tag = new NBTTagCompound(); - return (CompoundTag) adapter.toNative(input.save(tag)); - }).collect(Collectors.toList()); + Iterable result = + StreamSupport.stream(Iterables.concat(slices).spliterator(), false) + .map(input -> { + BukkitImplAdapter adapter = + WorldEditPlugin.getInstance().getBukkitImplAdapter(); + NBTTagCompound tag = new NBTTagCompound(); + return (CompoundTag) adapter.toNative(input.save(tag)); + }).collect(Collectors.toList()); return result.iterator(); } }; } - private void updateGet(BukkitGetBlocks_1_14 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) { + private void updateGet(BukkitGetBlocks_1_14 get, Chunk nmsChunk, ChunkSection[] sections, + ChunkSection section, char[] arr, int layer) { synchronized (get) { if (this.nmsChunk != nmsChunk) { this.nmsChunk = nmsChunk; @@ -271,15 +291,16 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { entity.die(); } - public Chunk ensureLoaded(net.minecraft.server.v1_14_R1.World nmsWorld, int X, int Z) { - return BukkitAdapter_1_14.ensureLoaded(nmsWorld, X, Z); + public Chunk ensureLoaded(net.minecraft.server.v1_14_R1.World nmsWorld, int chunkX, + int chunkZ) { + return BukkitAdapter_1_14.ensureLoaded(nmsWorld, chunkX, chunkZ); } @Override public > T call(IChunkSet set, Runnable finalizer) { try { WorldServer nmsWorld = world; - Chunk nmsChunk = ensureLoaded(nmsWorld, X, Z); + Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ); boolean fastmode = set.isFastMode() && Settings.IMP.QUEUE.NO_TICK_FASTMODE; // Remove existing tiles @@ -308,7 +329,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { ChunkSection[] sections = nmsChunk.getSections(); for (int layer = 0; layer < 16; layer++) { - if (!set.hasSection(layer)) continue; + if (!set.hasSection(layer)) { + continue; + } bitMask |= 1 << layer; @@ -317,13 +340,16 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { ChunkSection existingSection = sections[layer]; if (existingSection == null) { newSection = BukkitAdapter_1_14.newChunkSection(layer, setArr, fastmode); - if (BukkitAdapter_1_14.setSectionAtomic(sections, null, newSection, layer)) { + if (BukkitAdapter_1_14 + .setSectionAtomic(sections, null, newSection, layer)) { updateGet(this, nmsChunk, sections, newSection, setArr, layer); continue; } else { existingSection = sections[layer]; if (existingSection == null) { - log.error("Skipping invalid null section. chunk:" + X + "," + Z + " layer: " + layer); + log.error( + "Skipping invalid null section. chunk:" + chunkX + "," + chunkZ + + " layer: " + layer); continue; } } @@ -348,9 +374,12 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { } else if (lock.isModified()) { this.reset(layer); } - newSection = BukkitAdapter_1_14.newChunkSection(layer, this::load, setArr, fastmode); - if (!BukkitAdapter_1_14.setSectionAtomic(sections, existingSection, newSection, layer)) { - log.error("Failed to set chunk section:" + X + "," + Z + " layer: " + layer); + newSection = BukkitAdapter_1_14 + .newChunkSection(layer, this::load, setArr, fastmode); + if (!BukkitAdapter_1_14 + .setSectionAtomic(sections, existingSection, newSection, layer)) { + log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + + " layer: " + layer); continue; } else { updateGet(this, nmsChunk, sections, newSection, setArr, layer); @@ -398,12 +427,14 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { Runnable[] syncTasks = null; - int bx = X << 4; - int bz = Z << 4; + int bx = chunkX << 4; + int bz = chunkZ << 4; Set entityRemoves = set.getEntityRemoves(); if (entityRemoves != null && !entityRemoves.isEmpty()) { - if (syncTasks == null) syncTasks = new Runnable[3]; + if (syncTasks == null) { + syncTasks = new Runnable[3]; + } syncTasks[2] = () -> { final List[] entities = nmsChunk.getEntitySlices(); @@ -425,7 +456,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { Set entities = set.getEntities(); if (entities != null && !entities.isEmpty()) { - if (syncTasks == null) syncTasks = new Runnable[2]; + if (syncTasks == null) { + syncTasks = new Runnable[2]; + } syncTasks[1] = () -> { for (final CompoundTag nativeTag : entities) { @@ -434,7 +467,8 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { final ListTag posTag = (ListTag) entityTagMap.get("Pos"); final ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); if (idTag == null || posTag == null || rotTag == null) { - getLogger(BukkitGetBlocks_1_14.class).debug("Unknown entity tag: " + nativeTag); + getLogger(BukkitGetBlocks_1_14.class) + .debug("Unknown entity tag: " + nativeTag); continue; } final double x = posTag.getDouble(0); @@ -455,7 +489,8 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { } entity.f(tag); entity.setLocation(x, y, z, yaw, pitch); - nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM); + nmsWorld + .addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM); } } } @@ -466,7 +501,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { // set tiles Map tiles = set.getTiles(); if (tiles != null && !tiles.isEmpty()) { - if (syncTasks == null) syncTasks = new Runnable[1]; + if (syncTasks == null) { + syncTasks = new Runnable[1]; + } syncTasks[0] = () -> { for (final Map.Entry entry : tiles.entrySet()) { @@ -484,8 +521,10 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { tileEntity = nmsWorld.getTileEntity(pos); } if (tileEntity != null) { - BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); - final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag); + BukkitImplAdapter adapter = + WorldEditPlugin.getInstance().getBukkitImplAdapter(); + final NBTTagCompound tag = + (NBTTagCompound) adapter.fromNative(nativeTag); tag.set("x", new NBTTagInt(x)); tag.set("y", new NBTTagInt(y)); tag.set("z", new NBTTagInt(z)); @@ -508,8 +547,11 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { nmsChunk.mustNotSave = false; nmsChunk.markDirty(); // send to player - BukkitAdapter_1_14.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate); - if (finalizer != null) finalizer.run(); + BukkitAdapter_1_14 + .sendChunk(nmsWorld, chunkX, chunkZ, finalMask, finalLightUpdate); + if (finalizer != null) { + finalizer.run(); + } }; } if (syncTasks != null) { @@ -526,7 +568,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { } } if (callback == null) { - if (finalizer != null) finalizer.run(); + if (finalizer != null) { + finalizer.run(); + } return null; } else { return queueHandler.async(callback, null); @@ -539,7 +583,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { return (T) (Future) queueHandler.sync(chain); } else { if (callback == null) { - if (finalizer != null) finalizer.run(); + if (finalizer != null) { + finalizer.run(); + } } else { callback.run(); } @@ -571,11 +617,13 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { lock.setModified(false); // Efficiently convert ChunkSection to raw data try { - FAWE_Spigot_v1_14_R4 adapter = ((FAWE_Spigot_v1_14_R4) WorldEditPlugin.getInstance().getBukkitImplAdapter()); + FAWE_Spigot_v1_14_R4 adapter = + ((FAWE_Spigot_v1_14_R4) WorldEditPlugin.getInstance().getBukkitImplAdapter()); final DataPaletteBlock blocks = section.getBlocks(); final DataBits bits = (DataBits) BukkitAdapter_1_14.fieldBits.get(blocks); - final DataPalette palette = (DataPalette) BukkitAdapter_1_14.fieldPalette.get(blocks); + final DataPalette palette = + (DataPalette) BukkitAdapter_1_14.fieldPalette.get(blocks); final int bitsPerEntry = bits.c(); final long[] blockStates = bits.a(); @@ -689,7 +737,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { synchronized (this) { tmp = nmsChunk; if (tmp == null) { - nmsChunk = tmp = ensureLoaded(this.world, X, Z); + nmsChunk = tmp = ensureLoaded(this.world, chunkX, chunkZ); } } } @@ -702,12 +750,14 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { continue; } SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), Y); - NibbleArray nibble = world.getChunkProvider().getLightEngine().a(skyBlock).a(sectionPosition); + NibbleArray nibble = + world.getChunkProvider().getLightEngine().a(skyBlock).a(sectionPosition); if (nibble == null) { byte[] a = new byte[2048]; Arrays.fill(a, skyBlock == EnumSkyBlock.SKY ? (byte) 15 : (byte) 0); nibble = new NibbleArray(a); - ((LightEngine) world.getChunkProvider().getLightEngine()).a(skyBlock, sectionPosition, nibble); + ((LightEngine) world.getChunkProvider().getLightEngine()) + .a(skyBlock, sectionPosition, nibble); } synchronized (nibble) { for (int i = 0; i < 4096; i++) { @@ -739,7 +789,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks { try { final DataPaletteBlock blocksExisting = existing.getBlocks(); - final DataPalette palette = (DataPalette) BukkitAdapter_1_14.fieldPalette.get(blocksExisting); + final DataPalette palette = + (DataPalette) BukkitAdapter_1_14.fieldPalette + .get(blocksExisting); int paletteSize; if (palette instanceof DataPaletteLinear) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java index 9433308c2..515f5e07b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java @@ -105,19 +105,18 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { return AdaptedMap.immutable(nmsTiles, posNms2We, nmsTile2We); } - @Override - public int getSkyLight(int x, int y, int z) { + @Override public int getSkyLight(int x, int y, int z) { int layer = y >> 4; if (skyLight[layer] == null) { SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { - byte[] a = new byte[2048]; - // Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway. - Arrays.fill(a, (byte) 15); - nibbleArray = new NibbleArray(a); - ((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.SKY, sectionPosition, nibbleArray, true); + byte[] a = new byte[2048]; + // Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway. + Arrays.fill(a, (byte) 15); + nibbleArray = new NibbleArray(a); + ((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.SKY, sectionPosition, nibbleArray, true); } skyLight[layer] = nibbleArray; } @@ -125,21 +124,20 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { return skyLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l))); } - @Override - public int getEmmittedLight(int x, int y, int z) { + @Override public int getEmmittedLight(int x, int y, int z) { int layer = y >> 4; - if (skyLight[layer] == null) { + if (blockLight[layer] == null) { SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer); NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition); // If the server hasn't generated the section's NibbleArray yet, it will be null if (nibbleArray == null) { - byte[] a = new byte[2048]; - // Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway. - Arrays.fill(a, (byte) 15); - nibbleArray = new NibbleArray(a); - ((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.BLOCK, sectionPosition, nibbleArray, true); + byte[] a = new byte[2048]; + // Safe enough to assume if it's not created, it's under the sky. Unlikely to be created before lighting is fixed anyway. + Arrays.fill(a, (byte) 15); + nibbleArray = new NibbleArray(a); + ((LightEngine) world.getChunkProvider().getLightEngine()).a(EnumSkyBlock.BLOCK, sectionPosition, nibbleArray, true); } - skyLight[layer] = nibbleArray; + blockLight[layer] = nibbleArray; } long l = BlockPosition.a(x, y, z); return blockLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l))); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java index 4660c20e4..d127afca2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java @@ -16,6 +16,7 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.FlatRegionFunction; @@ -24,6 +25,7 @@ import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.FlatRegionVisitor; +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; @@ -41,7 +43,7 @@ import static org.bukkit.Bukkit.getWorld; public class FaweRegionManager extends RegionManager { - private RegionManager parent; + private final RegionManager parent; public FaweRegionManager(RegionManager parent) { this.parent = parent; @@ -59,6 +61,9 @@ public class FaweRegionManager extends RegionManager { @Override public boolean setCuboids(final PlotArea area, final Set regions, final Pattern blocks, final int minY, final int maxY) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.CUBOIDS) { + return parent.setCuboids(area, regions, blocks, minY, maxY); + } TaskManager.IMP.async(() -> { synchronized (FaweRegionManager.class) { World world = BukkitAdapter.adapt(getWorld(area.getWorldName())); @@ -80,7 +85,7 @@ public class FaweRegionManager extends RegionManager { @Override public boolean notifyClear(PlotManager manager) { - if (!(manager instanceof HybridPlotManager)) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.CLEAR || !(manager instanceof HybridPlotManager)) { return false; } final HybridPlotWorld hpw = ((HybridPlotManager) manager).getHybridPlotWorld(); @@ -89,7 +94,7 @@ public class FaweRegionManager extends RegionManager { @Override public boolean handleClear(final Plot plot, final Runnable whenDone, final PlotManager manager) { - if (!(manager instanceof HybridPlotManager)) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.CLEAR || !(manager instanceof HybridPlotManager)) { return false; } TaskManager.IMP.async(() -> { @@ -108,21 +113,29 @@ public class FaweRegionManager extends RegionManager { final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern(); final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern(); + final BiomeType biome = hybridPlotWorld.getPlotBiome(); - BlockVector3 pos1 = plot.getBottomAbs().getBlockVector3(); - BlockVector3 pos2 = plot.getExtendedTopAbs().getBlockVector3(); + BlockVector3 pos1 = BlockVector3.ZERO; + BlockVector3 pos2 = BlockVector3.at(hybridPlotWorld.PLOT_WIDTH - 1, 255, hybridPlotWorld.PLOT_WIDTH - 1); - Region bedrockRegion = new CuboidRegion(pos1.withY(0), pos2.withY(0)); + Region bedrockRegion = new CuboidRegion(pos1, pos2.withY(0)); Region fillingRegion = new CuboidRegion(pos1.withY(1), pos2.withY(hybridPlotWorld.PLOT_HEIGHT - 1)); - Region floorRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT), - pos2.withY(hybridPlotWorld.PLOT_HEIGHT)); - Region airRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT + 1), - pos2.withY(manager.getWorldHeight())); + Region floorRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT), pos2.withY(hybridPlotWorld.PLOT_HEIGHT)); + Region airRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT + 1), pos2.withY(manager.getWorldHeight())); - editSession.setBlocks(bedrockRegion, bedrock); - editSession.setBlocks(fillingRegion, filling); - editSession.setBlocks(floorRegion, plotfloor); - editSession.setBlocks(airRegion, air); + Clipboard clipboard = new BlockArrayClipboard(new CuboidRegion(pos1, pos2)); + + clipboard.setBlocks(bedrockRegion, bedrock); + clipboard.setBlocks(fillingRegion, filling); + clipboard.setBlocks(floorRegion, plotfloor); + clipboard.setBlocks(airRegion, air); + for (int x = pos1.getX(); x <= pos2.getX(); x ++) { + for (int z = pos1.getZ(); z <= pos2.getZ(); z ++) { + clipboard.setBiome(BlockVector2.at(x, z), biome); + } + } + + clipboard.paste(editSession, plot.getBottomAbs().getBlockVector3().withY(0), true, false, true); } if (hybridPlotWorld.PLOT_SCHEMATIC) { @@ -149,13 +162,15 @@ public class FaweRegionManager extends RegionManager { @Override public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.COPY_AND_SWAP) { + parent.swap(pos1, pos2, pos3, pos4, whenDone); + } TaskManager.IMP.async(() -> { synchronized (FaweRegionManager.class) { //todo because of the following code this should proably be in the Bukkit module World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld())); - WorldEdit.getInstance().getEditSessionFactory().getEditSession( - pos1World,-1); + WorldEdit.getInstance().getEditSessionFactory().getEditSession(pos1World,-1); EditSession sessionA = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); EditSession sessionB = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); @@ -177,6 +192,9 @@ public class FaweRegionManager extends RegionManager { @Override public void setBiome(CuboidRegion region, int extendBiome, BiomeType biome, String world, Runnable whenDone) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.SET_BIOME) { + parent.setBiome(region, extendBiome, biome, world, whenDone); + } region.expand(BlockVector3.at(extendBiome, 0, extendBiome)); region.expand(BlockVector3.at(-extendBiome, 0, -extendBiome)); TaskManager.IMP.async(() -> { @@ -197,6 +215,9 @@ public class FaweRegionManager extends RegionManager { @Override public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) { + if (!com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_INTEGRATION.COPY_AND_SWAP) { + return parent.copyRegion(pos1, pos2, pos3, whenDone); + } TaskManager.IMP.async(() -> { synchronized (FaweRegionManager.class) { World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); @@ -222,11 +243,8 @@ public class FaweRegionManager extends RegionManager { TaskManager.IMP.async(() -> { synchronized (FaweRegionManager.class) { World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); - try (EditSession editSession = new EditSessionBuilder(pos1World).checkMemory(false) - .fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) { - CuboidRegion region = new CuboidRegion( - BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), - BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); + try (EditSession editSession = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) { + CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); editSession.regenerate(region); editSession.flushQueue(); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java index e51494aed..e54c68125 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java @@ -39,7 +39,7 @@ public class PlotSquaredFeature extends FaweMaskManager { public PlotSquaredFeature() { super("PlotSquared"); log.debug("Optimizing PlotSquared"); - if (com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_HOOK) { + if (com.boydti.fawe.config.Settings.IMP.ENABLED_COMPONENTS.PLOTSQUARED_HOOK) { Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS = false; try { setupBlockQueue(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java index b4b11f439..2d3e9b613 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/FaweChunkManager.java @@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.regions.plotsquaredv4; import static org.bukkit.Bukkit.getWorld; +import com.boydti.fawe.config.Settings; import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.object.Location; @@ -49,6 +50,9 @@ public class FaweChunkManager extends ChunkManager { @Override public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { + if (!Settings.IMP.PLOTSQUARED_INTEGRATION.COPY_AND_SWAP) { + parent.swap(pos1, pos2, pos3, pos4, whenDone); + } TaskManager.IMP.async(() -> { synchronized (FaweChunkManager.class) { //todo because of the following code this should proably be in the Bukkit module @@ -77,6 +81,9 @@ public class FaweChunkManager extends ChunkManager { @Override public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) { + if (!Settings.IMP.PLOTSQUARED_INTEGRATION.COPY_AND_SWAP) { + return parent.copyRegion(pos1, pos2, pos3, whenDone); + } TaskManager.IMP.async(() -> { synchronized (FaweChunkManager.class) { World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java index d1df6b58d..059fe87c8 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java @@ -41,7 +41,7 @@ public class PlotSquaredFeature extends FaweMaskManager { public PlotSquaredFeature() { super("PlotSquared"); log.debug("Optimizing PlotSquared"); - if (com.boydti.fawe.config.Settings.IMP.PLOTSQUARED_HOOK) { + if (com.boydti.fawe.config.Settings.IMP.ENABLED_COMPONENTS.PLOTSQUARED_HOOK) { Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS = false; try { setupBlockQueue(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java index d62e54853..aa91f4a60 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitReflectionUtils.java @@ -8,16 +8,16 @@ import java.lang.reflect.Method; public class BukkitReflectionUtils { /** - * prefix of bukkit classes + * Prefix of Bukkit classes. */ private static volatile String preClassB = null; /** - * prefix of minecraft classes + * Prefix of Minecraft classes. */ private static volatile String preClassM = null; /** - * check server version and class names + * Check server version and class names. */ public static void init() { final Server server = Bukkit.getServer(); @@ -50,18 +50,22 @@ public class BukkitReflectionUtils { * @return RefClass object * @throws RuntimeException if no class found */ - public static ReflectionUtils.RefClass getRefClass(final String... classes) throws RuntimeException { + public static ReflectionUtils.RefClass getRefClass(final String... classes) + throws RuntimeException { if (preClassM == null) { init(); } for (String className : classes) { try { - className = className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft"); + className = className.replace("{cb}", preClassB).replace("{nms}", preClassM) + .replace("{nm}", "net.minecraft"); return ReflectionUtils.getRefClass(Class.forName(className)); } catch (final ClassNotFoundException ignored) { } } - throw new RuntimeException("no class found: " + classes[0].replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft")); + throw new RuntimeException( + "no class found: " + classes[0].replace("{cb}", preClassB).replace("{nms}", preClassM) + .replace("{nm}", "net.minecraft")); } public static Class getNmsClass(final String name) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java index 5211c618a..dc7bfd742 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java @@ -9,10 +9,8 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; -import java.util.Collections; import org.bukkit.FluidCollisionMode; import org.bukkit.Location; import org.bukkit.Material; @@ -31,8 +29,8 @@ import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import java.util.Collection; +import java.util.Collections; import java.util.List; -import org.jetbrains.annotations.Nullable; public class AsyncBlock implements Block { @@ -72,27 +70,33 @@ public class AsyncBlock implements Block { return world.getBlock(x, y, z).getBlockType().getInternalId(); } - @NotNull @Override + @NotNull + @Override public AsyncBlock getRelative(int modX, int modY, int modZ) { return new AsyncBlock(world, x + modX, y + modY, z + modZ); } - @NotNull @Override + @NotNull + @Override public AsyncBlock getRelative(BlockFace face) { return this.getRelative(face.getModX(), face.getModY(), face.getModZ()); } - @NotNull @Override + @NotNull + @Override public AsyncBlock getRelative(BlockFace face, int distance) { - return this.getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance); + return this.getRelative(face.getModX() * distance, face.getModY() * distance, + face.getModZ() * distance); } - @NotNull @Override + @NotNull + @Override public Material getType() { return getBlockData().getMaterial(); } - @NotNull @Override + @NotNull + @Override public BlockData getBlockData() { return BukkitAdapter.adapt(world.getBlock(x, y, z)); } @@ -137,7 +141,8 @@ public class AsyncBlock implements Block { return (byte) 15; } - @NotNull @Override + @NotNull + @Override public AsyncWorld getWorld() { return world; } @@ -157,14 +162,15 @@ public class AsyncBlock implements Block { return z; } - @NotNull @Override + @NotNull + @Override public Location getLocation() { return new Location(world, x, y, z); } @Override public Location getLocation(Location loc) { - if(loc != null) { + if (loc != null) { loc.setWorld(this.getWorld()); loc.setX(this.x); loc.setY(this.y); @@ -173,7 +179,8 @@ public class AsyncBlock implements Block { return loc; } - @NotNull @Override + @NotNull + @Override public AsyncChunk getChunk() { return world.getChunkAt(x >> 4, z >> 4); } @@ -219,7 +226,8 @@ public class AsyncBlock implements Block { return null; } - @NotNull @Override + @NotNull + @Override public AsyncBlockState getState() { BaseBlock state = world.getFullBlock(x, y, z); switch (state.getBlockType().getInternalId()) { @@ -247,7 +255,8 @@ public class AsyncBlock implements Block { return getState(); } - @NotNull @Override + @NotNull + @Override public Biome getBiome() { return world.getAdapter().adapt(world.getBiomeType(x, y, z)); } @@ -339,13 +348,15 @@ public class AsyncBlock implements Block { public boolean breakNaturally(@NotNull ItemStack tool, boolean value) { return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool)); } - - @NotNull @Override + + @NotNull + @Override public Collection getDrops() { return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops()); } - @NotNull @Override + @NotNull + @Override public Collection getDrops(@NotNull ItemStack tool) { return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops(tool)); } @@ -355,7 +366,8 @@ public class AsyncBlock implements Block { this.getUnsafeBlock().setMetadata(metadataKey, newMetadataValue); } - @NotNull @Override + @NotNull + @Override public List getMetadata(@NotNull String metadataKey) { return this.getUnsafeBlock().getMetadata(metadataKey); } @@ -376,11 +388,13 @@ public class AsyncBlock implements Block { } @Override - public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2, @NotNull FluidCollisionMode arg3) { + public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2, + @NotNull FluidCollisionMode arg3) { return this.getUnsafeBlock().rayTrace(arg0, arg1, arg2, arg3); } - @NotNull @Override + @NotNull + @Override public BoundingBox getBoundingBox() { return this.getUnsafeBlock().getBoundingBox(); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlockState.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlockState.java index 8b171a9a6..c8ab44cfe 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlockState.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlockState.java @@ -1,19 +1,14 @@ package com.boydti.fawe.bukkit.wrapper; -import com.boydti.fawe.FaweCache; import com.sk89q.jnbt.CompoundTag; -import java.util.List; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; @@ -22,6 +17,8 @@ import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; +import java.util.List; + public class AsyncBlockState implements BlockState { private BaseBlock state; @@ -165,7 +162,8 @@ public class AsyncBlockState implements BlockState { @Override public void setRawData(byte data) { int combinedId = getTypeId() + (data << BlockTypesCache.BIT_OFFSET); - state = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combinedId).toBaseBlock(state.getNbtData()); + state = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combinedId) + .toBaseBlock(state.getNbtData()); this.blockData = BukkitAdapter.adapt(state); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java index 2256cec7f..d2e3cb30b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncChunk.java @@ -1,10 +1,8 @@ package com.boydti.fawe.bukkit.wrapper; import com.boydti.fawe.Fawe; -import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TaskManager; -import java.util.function.Supplier; import org.bukkit.Chunk; import org.bukkit.ChunkSnapshot; import org.bukkit.World; @@ -15,6 +13,7 @@ import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import java.util.Collection; +import java.util.function.Supplier; public class AsyncChunk implements Chunk { @@ -68,11 +67,14 @@ public class AsyncChunk implements Chunk { } @Override - public ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain) { + public ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome, + boolean includeBiomeTempRain) { if (Fawe.isMainThread()) { - return world.getChunkAt(x, z).getChunkSnapshot(includeMaxblocky, includeBiome, includeBiomeTempRain); + return world.getChunkAt(x, z) + .getChunkSnapshot(includeMaxblocky, includeBiome, includeBiomeTempRain); } - return whenLoaded(() -> world.getChunkAt(x, z).getChunkSnapshot(includeBiome, includeBiome, includeBiomeTempRain)); + return whenLoaded(() -> world.getChunkAt(x, z) + .getChunkSnapshot(includeBiome, includeBiome, includeBiomeTempRain)); } private T whenLoaded(Supplier task) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java index 847b17a62..63b98efb8 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java @@ -13,14 +13,6 @@ import com.sk89q.worldedit.extent.PassthroughExtent; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; -import java.io.File; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.function.Predicate; import org.bukkit.BlockChangeDelegate; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -69,14 +61,24 @@ import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.File; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.function.Predicate; + /** * Modify the world from an async thread
- * - Use world.commit() to execute all the changes
- * - Any Chunk/Block/BlockState objects returned should also be safe to use from the same async thread
- * - Only block read,write and biome write are fast, other methods will perform slower async
- * - - * @see #wrap(World) - * @see #create(WorldCreator) + * - Use world.commit() to execute all the changes
+ * - Any Chunk/Block/BlockState objects returned should also be safe to use from the same async thread
+ * - Only block read,write and biome write are fast, other methods will perform slower async
+ * - + * + * @see #wrap(World) + * @see #create(WorldCreator) */ public class AsyncWorld extends PassthroughExtent implements World { @@ -84,14 +86,15 @@ public class AsyncWorld extends PassthroughExtent implements World { private BukkitImplAdapter adapter; @Override - public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t) { + public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, + double v3, double v4, double v5, double v6, T t) { parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5, v6, t); } /** - * @deprecated use {@link #wrap(World)} instead - * @param parent Parent world + * @param parent Parent world * @param autoQueue + * @deprecated use {@link #wrap(World)} instead */ @Deprecated public AsyncWorld(World parent, boolean autoQueue) { @@ -103,9 +106,9 @@ public class AsyncWorld extends PassthroughExtent implements World { } /** - * @deprecated use {@link #wrap(World)} instead * @param parent * @param extent + * @deprecated use {@link #wrap(World)} instead */ @Deprecated public AsyncWorld(World parent, Extent extent) { @@ -115,7 +118,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } /** - * Wrap a world for async usage + * Wrap a world for async usage. + * * @param world * @return */ @@ -137,7 +141,8 @@ public class AsyncWorld extends PassthroughExtent implements World { /** * Create a world async (untested) - * - Only optimized for 1.10 + * - Only optimized for 1.10 + * * @param creator * @return */ @@ -173,47 +178,56 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, T t) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, + T t) { parent.spawnParticle(particle, location, i, t); } @Override - public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, T data) { + public void spawnParticle(@NotNull Particle particle, double x, double y, double z, + int count, T data) { parent.spawnParticle(particle, x, y, z, count, data); } @Override - public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, + double offsetX, double offsetY, double offsetZ) { parent.spawnParticle(particle, location, count, offsetX, offsetY, offsetZ); } @Override - public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5) { + public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, + double v3, double v4, double v5) { parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5); } @Override - public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, double v, double v1, double v2, T t) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, + double v, double v1, double v2, T t) { parent.spawnParticle(particle, location, i, v, v1, v2, t); } @Override - public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, T t) { + public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, + double v3, double v4, double v5, T t) { parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5, t); } @Override - public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, double v, double v1, double v2, double v3) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, + double v, double v1, double v2, double v3) { parent.spawnParticle(particle, location, i, v, v1, v2, v3); } @Override - public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6) { + public void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, + double v3, double v4, double v5, double v6) { parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5, v6); } @Override - public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, double v, double v1, double v2, double v3, T t) { + public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, + double v, double v1, double v2, double v3, T t) { parent.spawnParticle(particle, location, i, v, v1, v2, v3, t); } @@ -236,7 +250,9 @@ public class AsyncWorld extends PassthroughExtent implements World { public int getHighestBlockYAt(int x, int z) { for (int y = getMaxHeight() - 1; y >= 0; y--) { BlockState state = this.getBlock(x, y, z); - if (!state.getMaterial().isAir()) return y; + if (!state.getMaterial().isAir()) { + return y; + } } return 0; } @@ -259,7 +275,7 @@ public class AsyncWorld extends PassthroughExtent implements World { @Override public int getHighestBlockYAt(int i, int i1, @NotNull HeightMap heightMap) { - return parent.getHighestBlockYAt(i,i1, heightMap); + return parent.getHighestBlockYAt(i, i1, heightMap); } @Override @@ -410,17 +426,20 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public @NotNull Item dropItemNaturally(final @NotNull Location location, final @NotNull ItemStack item) { + public @NotNull Item dropItemNaturally(final @NotNull Location location, + final @NotNull ItemStack item) { return TaskManager.IMP.sync(() -> parent.dropItemNaturally(location, item)); } @Override - public @NotNull Arrow spawnArrow(final @NotNull Location location, final @NotNull Vector direction, final float speed, final float spread) { + public @NotNull Arrow spawnArrow(final @NotNull Location location, + final @NotNull Vector direction, final float speed, final float spread) { return TaskManager.IMP.sync(() -> parent.spawnArrow(location, direction, speed, spread)); } @Override - public @NotNull T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class clazz) { + public @NotNull T spawnArrow(@NotNull Location location, + @NotNull Vector direction, float speed, float spread, @NotNull Class clazz) { return parent.spawnArrow(location, direction, speed, spread, clazz); } @@ -430,7 +449,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public boolean generateTree(final @NotNull Location loc, final @NotNull TreeType type, final @NotNull BlockChangeDelegate delegate) { + public boolean generateTree(final @NotNull Location loc, final @NotNull TreeType type, + final @NotNull BlockChangeDelegate delegate) { return TaskManager.IMP.sync(() -> parent.generateTree(loc, type, delegate)); } @@ -466,7 +486,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public @NotNull Collection getEntitiesByClass(final @NotNull Class cls) { + public @NotNull Collection getEntitiesByClass( + final @NotNull Class cls) { return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(cls)); } @@ -481,7 +502,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public @NotNull Collection getNearbyEntities(final @NotNull Location location, final double x, final double y, final double z) { + public @NotNull Collection getNearbyEntities(final @NotNull Location location, + final double x, final double y, final double z) { return TaskManager.IMP.sync(() -> parent.getNearbyEntities(location, x, y, z)); } @@ -576,17 +598,17 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public boolean createExplosion(final double x, final double y, final double z, final float power, final boolean setFire, final boolean breakBlocks) { - return TaskManager.IMP.sync( - () -> - parent.createExplosion(x, y, z, power, setFire, breakBlocks)); + public boolean createExplosion(final double x, final double y, final double z, + final float power, final boolean setFire, final boolean breakBlocks) { + return TaskManager.IMP + .sync(() -> parent.createExplosion(x, y, z, power, setFire, breakBlocks)); } @Override public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, @Nullable Entity source) { - return TaskManager.IMP.sync( - () -> parent.createExplosion(x, y, z, power, setFire, breakBlocks, source)); + return TaskManager.IMP + .sync(() -> parent.createExplosion(x, y, z, power, setFire, breakBlocks, source)); } @Override @@ -641,33 +663,40 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public @NotNull T spawn(final @NotNull Location location, final @NotNull Class clazz) throws IllegalArgumentException { + public @NotNull T spawn(final @NotNull Location location, + final @NotNull Class clazz) throws IllegalArgumentException { return TaskManager.IMP.sync(() -> parent.spawn(location, clazz)); } @Override - public @NotNull T spawn(@NotNull Location location, @NotNull Class clazz, Consumer function) throws IllegalArgumentException { + public @NotNull T spawn(@NotNull Location location, @NotNull Class clazz, + Consumer function) throws IllegalArgumentException { return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function)); } @Override - public @NotNull T spawn(@NotNull Location location, @NotNull Class clazz, @Nullable Consumer function, CreatureSpawnEvent.@NotNull SpawnReason reason) throws IllegalArgumentException { + public @NotNull T spawn(@NotNull Location location, @NotNull Class clazz, + @Nullable Consumer function, CreatureSpawnEvent.@NotNull SpawnReason reason) + throws IllegalArgumentException { return null; } @Override - public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException { + public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location, + @NotNull MaterialData data) throws IllegalArgumentException { return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, data)); } @Override @Deprecated - public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull Material material, byte data) throws IllegalArgumentException { + public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location, + @NotNull Material material, byte data) throws IllegalArgumentException { return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, material, data)); } @Override - public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull BlockData blockData) throws IllegalArgumentException { + public @NotNull FallingBlock spawnFallingBlock(@NotNull Location location, + @NotNull BlockData blockData) throws IllegalArgumentException { return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, blockData)); } @@ -677,7 +706,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public void playEffect(final @NotNull Location location, final @NotNull Effect effect, final int data, final int radius) { + public void playEffect(final @NotNull Location location, final @NotNull Effect effect, + final int data, final int radius) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { @@ -692,7 +722,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public void playEffect(final @NotNull Location location, final @NotNull Effect effect, final T data, final int radius) { + public void playEffect(final @NotNull Location location, final @NotNull Effect effect, + final T data, final int radius) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { @@ -702,9 +733,10 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public @NotNull ChunkSnapshot getEmptyChunkSnapshot(final int x, final int z, final boolean includeBiome, final boolean includeBiomeTempRain) { - return TaskManager.IMP.sync( - () -> parent.getEmptyChunkSnapshot(x, z, includeBiome, includeBiomeTempRain)); + public @NotNull ChunkSnapshot getEmptyChunkSnapshot(final int x, final int z, + final boolean includeBiome, final boolean includeBiomeTempRain) { + return TaskManager.IMP + .sync(() -> parent.getEmptyChunkSnapshot(x, z, includeBiome, includeBiomeTempRain)); } @Override @@ -729,7 +761,7 @@ public class AsyncWorld extends PassthroughExtent implements World { @Override public @NotNull Biome getBiome(int x, int y, int z) { - return adapter.adapt(getExtent().getBiomeType(x,y,z)); + return adapter.adapt(getExtent().getBiomeType(x, y, z)); } @Override @@ -884,11 +916,13 @@ public class AsyncWorld extends PassthroughExtent implements World { parent.setWaterAnimalSpawnLimit(limit); } - @Override public int getWaterAmbientSpawnLimit() { + @Override + public int getWaterAmbientSpawnLimit() { return parent.getWaterAmbientSpawnLimit(); } - @Override public void setWaterAmbientSpawnLimit(int limit) { + @Override + public void setWaterAmbientSpawnLimit(int limit) { parent.setWaterAmbientSpawnLimit(limit); } @@ -903,7 +937,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public void playSound(final @NotNull Location location, final @NotNull Sound sound, final float volume, final float pitch) { + public void playSound(final @NotNull Location location, final @NotNull Sound sound, + final float volume, final float pitch) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { @@ -913,7 +948,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public void playSound(final @NotNull Location location, final @NotNull String sound, final float volume, final float pitch) { + public void playSound(final @NotNull Location location, final @NotNull String sound, + final float volume, final float pitch) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { @@ -923,7 +959,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull Sound sound, + @NotNull SoundCategory category, float volume, float pitch) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { @@ -933,7 +970,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) { + public void playSound(@NotNull Location location, @NotNull String sound, + @NotNull SoundCategory category, float volume, float pitch) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { @@ -1042,13 +1080,14 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public @NotNull Collection getNearbyEntities(@NotNull BoundingBox arg0, Predicate arg1) { + public @NotNull Collection getNearbyEntities(@NotNull BoundingBox arg0, + Predicate arg1) { return parent.getNearbyEntities(arg0, arg1); } @Override - public @NotNull Collection getNearbyEntities(@NotNull Location arg0, double arg1, double arg2, double arg3, - Predicate arg4) { + public @NotNull Collection getNearbyEntities(@NotNull Location arg0, double arg1, + double arg2, double arg3, Predicate arg4) { return parent.getNearbyEntities(arg0, arg1, arg2, arg3, arg4); } @@ -1058,7 +1097,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public Location locateNearestStructure(@NotNull Location arg0, @NotNull StructureType arg1, int arg2, boolean arg3) { + public Location locateNearestStructure(@NotNull Location arg0, @NotNull StructureType arg1, + int arg2, boolean arg3) { return parent.locateNearestStructure(arg0, arg1, arg2, arg3); } @@ -1083,46 +1123,51 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public RayTraceResult rayTrace( - @NotNull Location arg0, @NotNull Vector arg1, double arg2, @NotNull FluidCollisionMode arg3, boolean arg4, - double arg5, Predicate arg6) { + public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2, + @NotNull FluidCollisionMode arg3, boolean arg4, double arg5, Predicate arg6) { return parent.rayTrace(arg0, arg1, arg2, arg3, arg4, arg5, arg6); } @Override - public RayTraceResult rayTraceBlocks(@NotNull Location arg0, @NotNull Vector arg1, double arg2) { + public RayTraceResult rayTraceBlocks(@NotNull Location arg0, @NotNull Vector arg1, + double arg2) { return parent.rayTraceBlocks(arg0, arg1, arg2); } @Override - public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) { + public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, + double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) { return parent.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode); } @Override - public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double arg2, @NotNull FluidCollisionMode fluidCollisionMode, - boolean ignorePassableBlocks) { - return parent.rayTraceBlocks(start, direction, arg2, fluidCollisionMode, ignorePassableBlocks); + public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, + double arg2, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) { + return parent + .rayTraceBlocks(start, direction, arg2, fluidCollisionMode, ignorePassableBlocks); } @Override - public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance) { + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, + double maxDistance) { return parent.rayTraceEntities(start, direction, maxDistance); } @Override - public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, double arg2, double arg3) { + public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, + double arg2, double arg3) { return parent.rayTraceEntities(arg0, arg1, arg2, arg3); } @Override - public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, double arg2, Predicate arg3) { + public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, + double arg2, Predicate arg3) { return parent.rayTraceEntities(arg0, arg1, arg2, arg3); } @Override - public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, double arg2, double arg3, - Predicate arg4) { + public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, + double arg2, double arg3, Predicate arg4) { return parent.rayTraceEntities(arg0, arg1, arg2, arg3, arg4); } @@ -1170,7 +1215,9 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public int getHighestBlockYAt(int x, int z, com.destroystokyo.paper.@NotNull HeightmapType heightmap) throws UnsupportedOperationException { + public int getHighestBlockYAt(int x, int z, + com.destroystokyo.paper.@NotNull HeightmapType heightmap) + throws UnsupportedOperationException { return TaskManager.IMP.sync(() -> parent.getHighestBlockYAt(x, z, heightmap)); } @@ -1205,7 +1252,8 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public @NotNull CompletableFuture getChunkAtAsync(int x, int z, boolean gen, boolean urgent) { + public @NotNull CompletableFuture getChunkAtAsync(int x, int z, boolean gen, + boolean urgent) { return null; } @@ -1241,8 +1289,10 @@ public class AsyncWorld extends PassthroughExtent implements World { } @Override - public boolean createExplosion(Entity source, @NotNull Location loc, float power, boolean setFire, boolean breakBlocks) { - return TaskManager.IMP.sync(() -> parent.createExplosion(source, loc, power, setFire, breakBlocks)); + public boolean createExplosion(Entity source, @NotNull Location loc, float power, + boolean setFire, boolean breakBlocks) { + return TaskManager.IMP + .sync(() -> parent.createExplosion(source, loc, power, setFire, breakBlocks)); } @Override @@ -1259,13 +1309,17 @@ public class AsyncWorld extends PassthroughExtent implements World { @Override - public void spawnParticle( - @NotNull Particle particle, List receivers, @NotNull Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { - parent.spawnParticle(particle, receivers, source, x, y, z, count, offsetX, offsetY, offsetZ, extra, data); + public void spawnParticle(@NotNull Particle particle, List receivers, + @NotNull Player source, double x, double y, double z, int count, double offsetX, + double offsetY, double offsetZ, double extra, T data) { + parent.spawnParticle(particle, receivers, source, x, y, z, count, offsetX, offsetY, offsetZ, + extra, data); } @Override - public void spawnParticle(@NotNull Particle particle, List list, Player player, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t, boolean b) { + public void spawnParticle(@NotNull Particle particle, List list, Player player, + double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t, + boolean b) { parent.spawnParticle(particle, list, player, v, v1, v2, i, v3, v4, v5, v6, t, b); } @@ -1273,7 +1327,8 @@ public class AsyncWorld extends PassthroughExtent implements World { public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data, boolean force) { - parent.spawnParticle(particle, location, count, offsetX, offsetY, offsetZ, extra, data, force); + parent.spawnParticle(particle, location, count, offsetX, offsetY, offsetZ, extra, data, + force); } @Override diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandInfo.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandInfo.java index 5fad6c1b2..008cd4cd7 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandInfo.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandInfo.java @@ -23,7 +23,8 @@ public class CommandInfo { private final String[] aliases; private final Object registeredWith; - private final String usage, desc; + private final String usage; + private final String desc; private final String[] permissions; public CommandInfo(String usage, String desc, String[] aliases, Object registeredWith) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java index f5daf2fc9..f0b6d7c89 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java @@ -37,7 +37,8 @@ import java.util.Set; public class CommandRegistration { static { - Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class, new DynamicPluginCommandHelpTopic.Factory()); + Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class, + new DynamicPluginCommandHelpTopic.Factory()); } protected final Plugin plugin; @@ -55,7 +56,9 @@ public class CommandRegistration { } public Plugin getCommandOwner(String label) { - if (serverCommandMap == null) return null; + if (serverCommandMap == null) { + return null; + } Command command = serverCommandMap.getCommand(label); if (command instanceof PluginIdentifiableCommand) { return ((PluginIdentifiableCommand) command).getPlugin(); @@ -87,8 +90,8 @@ public class CommandRegistration { CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap"); if (commandMap == null) { - Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() + - ": Could not retrieve server CommandMap, using fallback instead!"); + Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() + + ": Could not retrieve server CommandMap, using fallback instead!"); fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer()); Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin); } else { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/DynamicPluginCommand.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/DynamicPluginCommand.java index 77d95d2f5..c1ecb4e32 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/DynamicPluginCommand.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/DynamicPluginCommand.java @@ -22,8 +22,6 @@ package com.sk89q.bukkit.util; import com.sk89q.minecraft.util.commands.CommandsManager; import com.sk89q.util.StringUtil; import com.sk89q.wepif.PermissionsResolverManager; -import java.util.Arrays; -import java.util.List; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -31,8 +29,11 @@ import org.bukkit.command.PluginIdentifiableCommand; import org.bukkit.command.TabCompleter; import org.bukkit.plugin.Plugin; +import java.util.Arrays; +import java.util.List; + /** -* An implementation of a dynamically registered {@link org.bukkit.command.Command} attached to a plugin +* An implementation of a dynamically registered {@link org.bukkit.command.Command} attached to a plugin. */ @SuppressWarnings("deprecation") public class DynamicPluginCommand extends org.bukkit.command.Command implements PluginIdentifiableCommand { @@ -105,7 +106,7 @@ public class DynamicPluginCommand extends org.bukkit.command.Command implements } } return false; - } catch (Throwable ignore) { + } catch (Throwable ignored) { } } else if (PermissionsResolverManager.isInitialized() && sender instanceof OfflinePlayer) { for (String permission : permissions) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java index 763e4f88d..a83e075aa 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java @@ -31,10 +31,10 @@ import java.util.Map; import java.util.Set; public class ConfigurationPermissionsResolver implements PermissionsResolver { - private YAMLProcessor config; - private Map> userPermissionsCache; - private Set defaultPermissionsCache; - private Map> userGroups; + private final YAMLProcessor config; + private final Map> userPermissionsCache = new HashMap<>(); + private final Set defaultPermissionsCache = new HashSet<>(); + private final Map> userGroups = new HashMap<>(); public ConfigurationPermissionsResolver(YAMLProcessor config) { this.config = config; @@ -42,9 +42,10 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { public static YAMLNode generateDefaultPerms(YAMLNode section) { section.setProperty("groups.default.permissions", new String[] { - "worldedit.reload", - "worldedit.selection", - "worlds.creative.worldedit.region"}); + "worldedit.reload", + "worldedit.selection", + "worlds.creative.worldedit.region" + }); section.setProperty("groups.admins.permissions", new String[] { "*" }); section.setProperty("users.sk89q.permissions", new String[] { "worldedit" }); section.setProperty("users.sk89q.groups", new String[] { "admins" }); @@ -53,9 +54,9 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { @Override public void load() { - userGroups = new HashMap<>(); - userPermissionsCache = new HashMap<>(); - defaultPermissionsCache = new HashSet<>(); + userGroups.clear(); + userPermissionsCache.clear(); + defaultPermissionsCache.clear(); Map> userGroupPermissions = new HashMap<>(); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java index d5f9c7fc6..8fdc5f4a6 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java @@ -78,6 +78,8 @@ public class DinnerPermsResolver implements PermissionsResolver { return false; case 1: return true; + default: + break; } int dotPos = permission.lastIndexOf("."); while (dotPos > -1) { @@ -86,6 +88,8 @@ public class DinnerPermsResolver implements PermissionsResolver { return false; case 1: return true; + default: + break; } dotPos = permission.lastIndexOf(".", dotPos - 1); } @@ -126,19 +130,23 @@ public class DinnerPermsResolver implements PermissionsResolver { } public Permissible getPermissible(OfflinePlayer offline) { - if (offline == null) return null; + if (offline == null) { + return null; + } Permissible perm = null; if (offline instanceof Permissible) { perm = (Permissible) offline; } else { Player player = offline.getPlayer(); - if (player != null) perm = player; + if (player != null) { + perm = player; + } } return perm; } /** - * Checks the permission from dinnerperms + * Checks the permission from dinnerperms. * * @param perms Permissible to check for * @param permission The permission to check diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java index ef12e2ff4..675e8e184 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java @@ -35,8 +35,8 @@ public class NijiPermissionsResolver implements PermissionsResolver { private static final Logger log = LoggerFactory.getLogger(NijiPermissionsResolver.class); - private Server server; - private Permissions api; + private final Server server; + private final Permissions api; public static PermissionsResolver factory(Server server, YAMLProcessor config) { PluginManager pluginManager = server.getPluginManager(); @@ -76,7 +76,9 @@ public class NijiPermissionsResolver implements PermissionsResolver { public boolean hasPermission(String name, String permission) { try { Player player = server.getPlayerExact(name); - if (player == null) return false; + if (player == null) { + return false; + } try { return api.getHandler().has(player, permission); } catch (Throwable t) { @@ -107,7 +109,9 @@ public class NijiPermissionsResolver implements PermissionsResolver { public boolean inGroup(String name, String group) { try { Player player = server.getPlayerExact(name); - if (player == null) return false; + if (player == null) { + return false; + } try { return api.getHandler().inGroup(player.getWorld().getName(), name, group); } catch (Throwable t) { @@ -124,13 +128,17 @@ public class NijiPermissionsResolver implements PermissionsResolver { public String[] getGroups(String name) { try { Player player = server.getPlayerExact(name); - if (player == null) return new String[0]; + if (player == null) { + return new String[0]; + } String[] groups = null; try { groups = api.getHandler().getGroups(player.getWorld().getName(), player.getName()); } catch (Throwable t) { String group = api.Security.getGroup(player.getWorld().getName(), player.getName()); - if (group != null) groups = new String[] { group }; + if (group != null) { + groups = new String[] { group }; + } } if (groups == null) { return new String[0]; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java index 68903f9c3..c3382a9e2 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java @@ -40,24 +40,24 @@ import java.util.List; public class PermissionsResolverManager implements PermissionsResolver { - private static final String CONFIG_HEADER = "#\r\n" + - "# WEPIF Configuration File\r\n" + - "#\r\n" + - "# This file handles permissions configuration for every plugin using WEPIF\r\n" + - "#\r\n" + - "# About editing this file:\r\n" + - "# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If\r\n" + - "# you use an editor like Notepad++ (recommended for Windows users), you\r\n" + - "# must configure it to \"replace tabs with spaces.\" In Notepad++, this can\r\n" + - "# be changed in Settings > Preferences > Language Menu.\r\n" + - "# - Don't get rid of the indents. They are indented so some entries are\r\n" + - "# in categories (like \"enforce-single-session\" is in the \"protection\"\r\n" + - "# category.\r\n" + - "# - If you want to check the format of this file before putting it\r\n" + - "# into WEPIF, paste it into http://yaml-online-parser.appspot.com/\r\n" + - "# and see if it gives \"ERROR:\".\r\n" + - "# - Lines starting with # are comments and so they are ignored.\r\n" + - "\r\n"; + private static final String CONFIG_HEADER = "#\r\n" + + "# WEPIF Configuration File\r\n" + + "#\r\n" + + "# This file handles permissions configuration for every plugin using WEPIF\r\n" + + "#\r\n" + + "# About editing this file:\r\n" + + "# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If\r\n" + + "# you use an editor like Notepad++ (recommended for Windows users), you\r\n" + + "# must configure it to \"replace tabs with spaces.\" In Notepad++, this can\r\n" + + "# be changed in Settings > Preferences > Language Menu.\r\n" + + "# - Don't get rid of the indents. They are indented so some entries are\r\n" + + "# in categories (like \"enforce-single-session\" is in the \"protection\"\r\n" + + "# category.\r\n" + + "# - If you want to check the format of this file before putting it\r\n" + + "# into WEPIF, paste it into https://yaml-online-parser.appspot.com/\r\n" + + "# and see if it gives \"ERROR:\".\r\n" + + "# - Lines starting with # are comments and so they are ignored.\r\n" + + "\r\n"; private static PermissionsResolverManager instance; @@ -78,22 +78,22 @@ public class PermissionsResolverManager implements PermissionsResolver { return instance; } - private Server server; + private final Server server; private PermissionsResolver permissionResolver; private YAMLProcessor config; - private Logger logger = LoggerFactory.getLogger(getClass()); - private List> enabledResolvers = new ArrayList<>(); + private final Logger logger = LoggerFactory.getLogger(getClass()); + private final List> enabledResolvers = new ArrayList<>(); @SuppressWarnings("unchecked") protected Class[] availableResolvers = new Class[] { - PluginPermissionsResolver.class, - PermissionsExResolver.class, - bPermissionsResolver.class, - GroupManagerResolver.class, - NijiPermissionsResolver.class, - VaultResolver.class, - DinnerPermsResolver.class, - FlatFilePermissionsResolver.class + PluginPermissionsResolver.class, + PermissionsExResolver.class, + bPermissionsResolver.class, + GroupManagerResolver.class, + NijiPermissionsResolver.class, + VaultResolver.class, + DinnerPermsResolver.class, + FlatFilePermissionsResolver.class }; protected PermissionsResolverManager(Plugin plugin) { @@ -225,7 +225,8 @@ public class PermissionsResolverManager implements PermissionsResolver { Class next = null; try { next = Class.forName(getClass().getPackage().getName() + "." + nextName); - } catch (ClassNotFoundException e) {} + } catch (ClassNotFoundException ignored) { + } if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) { logger.warn("WEPIF: Invalid or unknown class found in enabled resolvers: " @@ -239,12 +240,12 @@ public class PermissionsResolverManager implements PermissionsResolver { } for (Class clazz : availableResolvers) { - if (!stagedEnabled.contains(clazz.getSimpleName()) && - !disabledResolvers.contains(clazz.getSimpleName())) { + if (!stagedEnabled.contains(clazz.getSimpleName()) + && !disabledResolvers.contains(clazz.getSimpleName())) { disabledResolvers.add(clazz.getSimpleName()); logger.info("New permissions resolver: " - + clazz.getSimpleName() + " detected. " + - "Added to disabled resolvers list."); + + clazz.getSimpleName() + " detected. " + + "Added to disabled resolvers list."); isUpdated = true; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/bPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/bPermissionsResolver.java index dacc0be0f..083b91fe7 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/bPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/bPermissionsResolver.java @@ -37,7 +37,7 @@ public class bPermissionsResolver implements PermissionsResolver { return new bPermissionsResolver(server); } - + private final Server server; public bPermissionsResolver(Server server) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java index ee975b837..8e7a6d1bc 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java @@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory; import java.io.File; /** - * YAMLConfiguration but with setting for no op permissions and plugin root data folder + * YAMLConfiguration but with setting for no op permissions and plugin root data folder. */ public class BukkitConfiguration extends YAMLConfiguration { @@ -59,8 +59,8 @@ public class BukkitConfiguration extends YAMLConfiguration { File toDir = new File(getWorkingDirectory(), file); if (fromDir.exists() & !toDir.exists()) { if (fromDir.renameTo(toDir)) { - plugin.getLogger().info("Migrated " + name + " folder '" + file + - "' from server root to plugin data folder."); + plugin.getLogger().info("Migrated " + name + " folder '" + file + + "' from server root to plugin data folder."); } else { plugin.getLogger().warning("Error while migrating " + name + " folder!"); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntity.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntity.java index be50815f3..23e414ab5 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntity.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntity.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.bukkit; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -35,9 +32,10 @@ import org.bukkit.entity.EntityType; import java.lang.ref.WeakReference; import java.util.Locale; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * An adapter to adapt a Bukkit entity into a WorldEdit one. */ diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 201a542db..64dbce76b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -194,7 +194,7 @@ public class BukkitPlayer extends AbstractPlayerActor { } @Override - public void setPosition(Vector3 pos, float pitch, float yaw) { + public boolean trySetPosition(Vector3 pos, float pitch, float yaw) { org.bukkit.World world = player.getWorld(); if (pos instanceof com.sk89q.worldedit.util.Location) { com.sk89q.worldedit.util.Location loc = (com.sk89q.worldedit.util.Location) pos; @@ -203,7 +203,8 @@ public class BukkitPlayer extends AbstractPlayerActor { world = Bukkit.getWorld(((World) extent).getName()); } } - player.teleport(new Location(world, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch)); + org.bukkit.World finalWorld = world; + return TaskManager.IMP.sync(() -> player.teleport(new Location(finalWorld, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch))); } @Override diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java index 09aa43ca3..35778d1fd 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_14_R4.java @@ -406,10 +406,11 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I SingleThreadQueueExtent extent = new SingleThreadQueueExtent(); extent.init(null, (x, z) -> new BukkitGetBlocks_1_14(freshWorld, x, z) { @Override - public Chunk ensureLoaded(World nmsWorld, int X, int Z) { - Chunk cached = nmsWorld.getChunkIfLoaded(X, Z); + public Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) { + Chunk cached = nmsWorld.getChunkIfLoaded(chunkX, chunkZ); if (cached != null) return cached; - Future future = Fawe.get().getQueueHandler().sync((Supplier) () -> freshWorld.getChunkAt(X, Z)); + Future future = Fawe.get().getQueueHandler().sync((Supplier) () -> freshWorld.getChunkAt( + chunkX, chunkZ)); while (!future.isDone()) { // this feels so dirty freshWorld.getChunkProvider().runTasks(); diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 41dac87ff..5c6242641 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -1,7 +1,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import org.gradle.plugins.ide.idea.model.IdeaModel import com.mendhak.gradlecrowdin.DownloadTranslationsTask import com.mendhak.gradlecrowdin.UploadSourceFileTask +import org.gradle.plugins.ide.idea.model.IdeaModel import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -94,15 +94,13 @@ plugins.withId("idea") { } } -sourceSets { - main { - java { - srcDir("src/main/java") - srcDir("src/legacy/java") - } - resources { - srcDir("src/main/resources") - } +sourceSets.named("main") { + java { + srcDir("src/main/java") + srcDir("src/legacy/java") + } + resources { + srcDir("src/main/resources") } } @@ -147,7 +145,7 @@ if (project.hasProperty(crowdinApiKey) && !gradle.startParameter.isOffline) { } } - tasks.named("classes").configure { + tasks.named("classes") { dependsOn("crowdinDownload") } } diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java index 944b4ab42..f394de876 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java @@ -63,8 +63,11 @@ public class SkullBlock extends BaseBlock { if (owner == null) { this.owner = ""; } else { - if (owner.length() > 16 || owner.isEmpty()) this.owner = ""; - else this.owner = owner; + if (owner.length() > 16 || owner.isEmpty()) { + this.owner = ""; + } else { + this.owner = owner; + } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index 6675390eb..440b98efa 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -18,6 +18,9 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; @@ -28,17 +31,12 @@ import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.MemoryPoolMXBean; import java.lang.management.MemoryUsage; -import java.util.Calendar; import java.util.Date; import java.util.List; -import java.util.Locale; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import javax.management.InstanceAlreadyExistsException; import javax.management.NotificationEmitter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * [ WorldEdit action] diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java index 66c0f0978..c42b26872 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -29,18 +29,14 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; -import com.sk89q.worldedit.internal.registry.AbstractFactory; -import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.world.World; -import javax.annotation.Nullable; import java.io.File; import java.io.IOException; -import java.lang.reflect.Field; import java.net.URL; import java.util.ArrayList; import java.util.HashSet; @@ -49,6 +45,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.UUID; +import javax.annotation.Nullable; /** * The FaweAPI class offers a few useful functions.
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java index 859503291..3e83b3fd1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -1,7 +1,5 @@ package com.boydti.fawe; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.beta.implementation.queue.Pool; @@ -36,6 +34,8 @@ import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.block.BlockTypesCache; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -54,7 +54,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import java.util.function.Supplier; -import org.jetbrains.annotations.NotNull; + +import static com.google.common.base.Preconditions.checkNotNull; public enum FaweCache implements Trimable { IMP diff --git a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java index 6941fb728..2d65517cf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java @@ -1,12 +1,12 @@ package com.boydti.fawe; -import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.cache.preloader.Preloader; +import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.image.ImageViewer; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.world.World; + import java.io.File; import java.util.Collection; import java.util.UUID; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java index b5ae0014e..b2bcaa9dc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/CombinedBlocks.java @@ -1,13 +1,10 @@ package com.boydti.fawe.beta; import com.boydti.fawe.FaweCache; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.util.HashMap; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java index 97870cc2a..3ab1008cb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java @@ -1,11 +1,11 @@ package com.boydti.fawe.beta; -import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.regions.Region; -import javax.annotation.Nullable; import org.jetbrains.annotations.Range; +import javax.annotation.Nullable; + /** * A filter is an interface used for setting blocks. */ diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java index f4798db91..cb5ea99a0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java @@ -6,6 +6,7 @@ import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.World; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; + import java.util.concurrent.ConcurrentLinkedQueue; public class Flood { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java index face13146..1cd27670f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java @@ -7,10 +7,11 @@ import com.boydti.fawe.beta.implementation.processors.MultiBatchProcessor; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; +import org.jetbrains.annotations.Nullable; + import java.util.Map; import java.util.Set; import java.util.function.Function; -import org.jetbrains.annotations.Nullable; public interface IBatchProcessor { /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java index 42fbac580..c89c71adb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBlocks.java @@ -11,11 +11,12 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.registry.BlockRegistry; +import org.jetbrains.annotations.Range; + import java.io.IOException; import java.util.Map; import java.util.Set; import java.util.stream.IntStream; -import org.jetbrains.annotations.Range; /** * A shared interface for IGetBlocks and ISetBlocks diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java index dcd4df154..c9660456f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java @@ -1,11 +1,11 @@ package com.boydti.fawe.beta; import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; -import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.regions.Region; -import javax.annotation.Nullable; import org.jetbrains.annotations.Range; +import javax.annotation.Nullable; + /** * Represents a chunk in the queue {@link IQueueExtent} Used for getting and setting blocks / biomes * / entities diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java index c0eb29a35..43d60af11 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkGet.java @@ -2,13 +2,10 @@ package com.boydti.fawe.beta; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.extent.InputExtent; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -import java.util.Map; -import java.util.Set; import java.util.UUID; import java.util.concurrent.Future; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java index 843922f45..46ee3e69b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java @@ -6,9 +6,9 @@ import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; -import javax.annotation.Nullable; import java.util.Set; import java.util.UUID; +import javax.annotation.Nullable; /** * Interface for setting blocks diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java index 862da2a56..8655ab5dc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java @@ -2,6 +2,7 @@ package com.boydti.fawe.beta; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.regions.Region; + import javax.annotation.Nullable; public interface IDelegateFilter extends Filter { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java index eed76600e..c79eef5fb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java @@ -9,11 +9,12 @@ import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; +import org.jetbrains.annotations.Range; + import java.io.Flushable; import java.util.Set; import java.util.concurrent.Future; import javax.annotation.Nullable; -import org.jetbrains.annotations.Range; /** * TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java index 34af72698..b143c744e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/BitSetBlocks.java @@ -8,6 +8,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; + import java.util.Arrays; import java.util.Collections; import java.util.Map; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java index 9da99934d..b70c5a0a2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java @@ -14,7 +14,12 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -import java.util.*; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.Future; public class FallbackChunkGet implements IChunkGet { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt index cd43cb7c1..3d938ea06 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.kt @@ -11,8 +11,7 @@ import com.sk89q.worldedit.world.biome.BiomeTypes import com.sk89q.worldedit.world.block.BaseBlock import com.sk89q.worldedit.world.block.BlockState import com.sk89q.worldedit.world.block.BlockTypes - -import java.util.UUID +import java.util.* import java.util.concurrent.Future object NullChunkGet : IChunkGet { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java index 4be438efc..fb7e8b989 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java @@ -19,11 +19,11 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import org.jetbrains.annotations.Range; -import javax.annotation.Nullable; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.Future; +import javax.annotation.Nullable; /** * An abstract {@link IChunk} class that implements basic get/set blocks diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.kt b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.kt index 740b178ce..78f82cb5b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.kt +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.kt @@ -12,7 +12,7 @@ import com.sk89q.worldedit.world.block.BaseBlock import com.sk89q.worldedit.world.block.BlockState import com.sk89q.worldedit.world.block.BlockStateHolder import com.sk89q.worldedit.world.block.BlockTypes -import java.util.UUID +import java.util.* import java.util.concurrent.Future object NullChunk : IQueueChunk { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ArrayImageMask.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ArrayImageMask.java index e47b25a27..802f8ba62 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ArrayImageMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ArrayImageMask.java @@ -1,7 +1,8 @@ package com.boydti.fawe.beta.implementation.filter; -import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.boydti.fawe.beta.FilterBlockMask; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; + import java.awt.image.BufferedImage; import java.util.concurrent.ThreadLocalRandom; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java index 645e23cd9..38494b82e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java @@ -7,7 +7,6 @@ import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; import java.util.ArrayList; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ForkedFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ForkedFilter.java index dc2e33f7c..08577b63c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ForkedFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ForkedFilter.java @@ -1,6 +1,7 @@ package com.boydti.fawe.beta.implementation.filter; import com.boydti.fawe.beta.Filter; + import java.util.Map; import java.util.concurrent.ConcurrentHashMap; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java index 9aca5764f..c911bb1eb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java @@ -1,7 +1,7 @@ package com.boydti.fawe.beta.implementation.filter; -import com.boydti.fawe.beta.implementation.filter.block.DelegateFilter; import com.boydti.fawe.beta.Filter; +import com.boydti.fawe.beta.implementation.filter.block.DelegateFilter; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.function.mask.Mask; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractExtentFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractExtentFilterBlock.java index 7f1b74873..fb066b3b2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractExtentFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractExtentFilterBlock.java @@ -3,7 +3,7 @@ package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.worldedit.extent.Extent; /** - * Filter block with an extent + * Filter block with an extent. */ public abstract class AbstractExtentFilterBlock extends FilterBlock { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractFilterBlock.java index e3abe3dbf..f56b1018c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractFilterBlock.java @@ -8,6 +8,7 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; + import javax.annotation.Nullable; public abstract class AbstractFilterBlock extends FilterBlock { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractSingleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractSingleFilterBlock.java index 45c972b6b..f7e473897 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractSingleFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractSingleFilterBlock.java @@ -82,11 +82,11 @@ public abstract class AbstractSingleFilterBlock extends FilterBlock { setFullBlock(block.toBaseBlock()); return true; } - return getExtent().setBlock(x,y, z, block); + return getExtent().setBlock(x, y, z, block); } @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { - return getExtent().setBiome(x, y, z,biome); + return getExtent().setBiome(x, y, z, biome); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java index d1179563c..ca4594151 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java @@ -8,6 +8,7 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypesCache; + import javax.annotation.Nullable; public class ArrayFilterBlock extends AbstractExtentFilterBlock { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java index f2957f901..c4056c2b5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java @@ -1,7 +1,5 @@ package com.boydti.fawe.beta.implementation.filter.block; -import static com.sk89q.worldedit.world.block.BlockTypesCache.states; - import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.FilterBlockMask; @@ -22,9 +20,12 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.registry.BlockMaterial; -import javax.annotation.Nullable; import org.jetbrains.annotations.NotNull; +import javax.annotation.Nullable; + +import static com.sk89q.worldedit.world.block.BlockTypesCache.states; + public class CharFilterBlock extends ChunkFilterBlock { private static final SetDelegate FULL = (block, value) -> block.setArr[block.index] = value; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java index 157d04491..4933b6f17 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java @@ -1,8 +1,6 @@ package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.TileEntityBlock; import com.sk89q.worldedit.extent.Extent; @@ -10,6 +8,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; + import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java index 5638c962e..d10eb55cc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java @@ -6,7 +6,6 @@ import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.io.FastByteArrayOutputStream; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.WorldEdit; import java.util.HashMap; import java.util.function.Function; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java index 6e3b13281..e5fea0164 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java @@ -30,12 +30,12 @@ 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.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.UUID; +import javax.annotation.Nullable; public class LimitExtent extends PassthroughExtent { private final FaweLimit limit; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/PersistentChunkSendProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/PersistentChunkSendProcessor.java index f639c1cb5..b9715c515 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/PersistentChunkSendProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/PersistentChunkSendProcessor.java @@ -1,12 +1,10 @@ package com.boydti.fawe.beta.implementation.processors; -import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.CombinedBlocks; import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; -import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.implementation.IChunkExtent; import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.util.MathMan; @@ -19,7 +17,6 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.function.Supplier; -import java.util.stream.Stream; public class PersistentChunkSendProcessor extends ChunkSendProcessor { private final Long2ObjectLinkedOpenHashMap current; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java index f5b1bc600..aaa5ca89d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java @@ -3,13 +3,13 @@ package com.boydti.fawe.beta.implementation.queue; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IBatchProcessor; +import com.boydti.fawe.beta.IChunkCache; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IQueueChunk; import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.beta.implementation.cache.ChunkCache; -import com.boydti.fawe.beta.IChunkCache; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.collection.CleanableThreadLocal; import com.boydti.fawe.util.MemUtil; @@ -17,6 +17,7 @@ import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.wrappers.WorldWrapper; import com.google.common.util.concurrent.Futures; import com.sk89q.worldedit.world.World; + import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.Iterator; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java index d079d2c81..7e73f8c8d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java @@ -20,6 +20,7 @@ import com.boydti.fawe.util.MemUtil; import com.google.common.util.concurrent.Futures; import com.sk89q.worldedit.extent.Extent; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; + import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; 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 106ed9daf..0530ecb3d 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 @@ -1,7 +1,5 @@ package com.boydti.fawe.command; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -13,12 +11,15 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.annotation.Selection; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.biome.BiomeType; -import java.io.IOException; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Switch; +import java.io.IOException; + +import static com.google.common.base.Preconditions.checkNotNull; + @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class AnvilCommands { @@ -31,87 +32,87 @@ public class AnvilCommands { checkNotNull(worldEdit); } -// /** -// * Run safely on an unloaded world (no selection) -// * -// * @param player -// * @param folder -// * @param filter -// * @param -// * @param -// * @return -// */ -// @Deprecated -// public static > T runWithWorld(Player player, String folder, T filter, boolean force) { -// return runWithWorld(player, folder, filter, force, false); -// } -// -// -// @Deprecated -// public static > T runWithWorld(Player player, String folder, T filter, boolean force, boolean unsafe) { -// boolean copy = false; -// if (FaweAPI.getWorld(folder) != null) { -// if (!force) { -// player.print(TranslatableComponent.of("fawe.worldedit.anvil.world.is.loaded")) -// return null; -// } -// copy = true; -// } -// IQueueExtent defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false); -// MCAQueue queue = new MCAQueue(defaultQueue); -// if (copy && !unsafe) { -// return queue.filterCopy(filter, RegionWrapper.GLOBAL()); -// } else { -// return queue.filterWorld(filter); -// } -// } -// -// /** -// * Run safely on an existing world within a selection -// * -// * @param player -// * @param editSession -// * @param selection -// * @param filter -// * @param -// * @param -// * @return -// */ -// @Deprecated -// public static > T runWithSelection(Player player, EditSession editSession, Region selection, T filter) { -// if (!(selection instanceof CuboidRegion)) { -// player.print(TranslatableComponent.of("fawe.error.no.region")) -// return null; -// } -// CuboidRegion cuboid = (CuboidRegion) selection; -// RegionWrapper wrappedRegion = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint()); -// String worldName = editSession.getWorld().getName(); -// IQueueExtent tmp = SetQueue.IMP.getNewQueue(worldName, true, false); -// MCAQueue queue = new MCAQueue(tmp); -// FawePlayer fp = FawePlayer.wrap(player); -// fp.checkAllowedRegion(selection); -// recordHistory(fp, editSession.getWorld(), iAnvilHistory -> { -// queue.filterCopy(filter, wrappedRegion, iAnvilHistory); -// }); -// return filter; -// } -// -// public static void recordHistory(FawePlayer fp, World world, Consumer run) { -// LocalSession session = fp.getSession(); -// if (session == null || session.hasFastMode()) { -// run.accept(new NullAnvilHistory()); -// } else { -// AnvilHistory history = new AnvilHistory(world.getName(), fp.getUUID()); -// run.accept(history); -// session.remember(fp.getPlayer(), world, history, fp.getLimit()); -// } -// } + // /** + // * Run safely on an unloaded world (no selection) + // * + // * @param player + // * @param folder + // * @param filter + // * @param + // * @param + // * @return + // */ + // @Deprecated + // public static > T runWithWorld(Player player, String folder, T filter, boolean force) { + // return runWithWorld(player, folder, filter, force, false); + // } + // + // + // @Deprecated + // public static > T runWithWorld(Player player, String folder, T filter, boolean force, boolean unsafe) { + // boolean copy = false; + // if (FaweAPI.getWorld(folder) != null) { + // if (!force) { + // player.print(TranslatableComponent.of("fawe.worldedit.anvil.world.is.loaded")) + // return null; + // } + // copy = true; + // } + // IQueueExtent defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false); + // MCAQueue queue = new MCAQueue(defaultQueue); + // if (copy && !unsafe) { + // return queue.filterCopy(filter, RegionWrapper.GLOBAL()); + // } else { + // return queue.filterWorld(filter); + // } + // } + // + // /** + // * Run safely on an existing world within a selection + // * + // * @param player + // * @param editSession + // * @param selection + // * @param filter + // * @param + // * @param + // * @return + // */ + // @Deprecated + // public static > T runWithSelection(Player player, EditSession editSession, Region selection, T filter) { + // if (!(selection instanceof CuboidRegion)) { + // player.print(TranslatableComponent.of("fawe.error.no.region")) + // return null; + // } + // CuboidRegion cuboid = (CuboidRegion) selection; + // RegionWrapper wrappedRegion = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint()); + // String worldName = editSession.getWorld().getName(); + // IQueueExtent tmp = SetQueue.IMP.getNewQueue(worldName, true, false); + // MCAQueue queue = new MCAQueue(tmp); + // FawePlayer fp = FawePlayer.wrap(player); + // fp.checkAllowedRegion(selection); + // recordHistory(fp, editSession.getWorld(), iAnvilHistory -> { + // queue.filterCopy(filter, wrappedRegion, iAnvilHistory); + // }); + // return filter; + // } + // + // public static void recordHistory(FawePlayer fp, World world, Consumer run) { + // LocalSession session = fp.getSession(); + // if (session == null || session.hasFastMode()) { + // run.accept(new NullAnvilHistory()); + // } else { + // AnvilHistory history = new AnvilHistory(world.getName(), fp.getUUID()); + // run.accept(history); + // session.remember(fp.getPlayer(), world, history, fp.getLimit()); + // } + // } @Command( - name = "replaceall", - aliases = {"rea", "repall"}, - desc = "Replace all blocks in the selection with another" -) + name = "replaceall", + aliases = {"rea", "repall"}, + desc = "Replace all blocks in the selection with another" + ) @CommandPermissions("worldedit.anvil.replaceall") public void replaceAll(Player player, String folder, @Arg(name = "from", desc = "String", def = "") @@ -119,525 +120,525 @@ public class AnvilCommands { String toPatternStr, @Switch(name = 'd', desc = "Disable wildcard data matching") boolean useData) throws WorldEditException { -// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED -// if (from == null) { -// matchFrom = FaweBlockMatcher.NOT_AIR; -// } else { -// if (from.contains(":")) { -// useData = true; //override d flag, if they specified data they want it -// } -// matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData); -// } -// final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true)); -// ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); -// ReplaceSimpleFilter result = runWithWorld(player, folder, filter, true); -// if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED + // if (from == null) { + // matchFrom = FaweBlockMatcher.NOT_AIR; + // } else { + // if (from.contains(":")) { + // useData = true; //override d flag, if they specified data they want it + // } + // matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData); + // } + // final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true)); + // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); + // ReplaceSimpleFilter result = runWithWorld(player, folder, filter, true); + // if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); } @Command( - name = "remapall", - descFooter = "Remap the world between MCPE/PC values", - desc = "Remap the world between MCPE/PC values" + name = "remapall", + descFooter = "Remap the world between MCPE/PC values", + desc = "Remap the world between MCPE/PC values" ) @CommandPermissions("worldedit.anvil.remapall") public void remapall(Player player, String folder) throws WorldEditException { -// ClipboardRemapper.RemapPlatform from; TODO NOT IMPLEMENTED -// 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(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // ClipboardRemapper.RemapPlatform from; TODO NOT IMPLEMENTED + // 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(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "deleteallunvisited", - aliases = {"delunvisited" }, - desc = "Delete all chunks which haven't been occupied", - descFooter = "occupied for `age-ticks` (20t = 1s) and \n" + - "Have not been accessed since `file-duration` (ms) after creation and\n" + - "Have not been used in the past `chunk-inactivity` (ms)" + - "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`" + name = "deleteallunvisited", + aliases = {"delunvisited" }, + desc = "Delete all chunks which haven't been occupied", + descFooter = "occupied for `age-ticks` (20t = 1s) and \n" + + "Have not been accessed since `file-duration` (ms) after creation and\n" + + "Have not been used in the past `chunk-inactivity` (ms)" + + "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`" ) @CommandPermissions("worldedit.anvil.deleteallunvisited") public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Arg(desc = "int", def = "60000") int fileDurationMillis) throws WorldEditException { -// DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED -// DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED + // DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "deleteallunclaimed", - aliases = {"delallunclaimed" }, - desc = "Delete all chunks which haven't been occupied", - descFooter = "Supports: WG, P2, GP:\n" + - "Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n" + - "Have not been accessed since `file-duration` (ms) after creation and\n" + - "Have not been used in the past `chunk-inactivity` (ms)" + - "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`" -) + name = "deleteallunclaimed", + aliases = {"delallunclaimed" }, + desc = "Delete all chunks which haven't been occupied", + descFooter = "Supports: WG, P2, GP:\n" + + "Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n" + + "Have not been accessed since `file-duration` (ms) after creation and\n" + + "Have not been used in the past `chunk-inactivity` (ms)" + + "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`" + ) @CommandPermissions("worldedit.anvil.deleteallunclaimed") public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Arg(desc = "int", def = "60000") int fileDurationMillis, @Switch(name = 'd', desc = "TODO") boolean debug) throws WorldEditException { -// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED -// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); -// if (debug) { -// filter.enableDebug(); -// } -// DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED + // DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); + // if (debug) { + // filter.enableDebug(); + // } + // DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "deleteunclaimed", - desc = "Delete all chunks which haven't been occupied", - descFooter = "(Supports: WG, P2, GP):\n" + - "Is not claimed\n" + - "Has not been occupied for `age-ticks` (20t = 1s) and \n" + - "Have not been accessed since `file-duration` (ms) after creation and\n" + - "Have not been used in the past `chunk-inactivity` (ms)" + - "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`" -) + name = "deleteunclaimed", + desc = "Delete all chunks which haven't been occupied", + descFooter = "(Supports: WG, P2, GP):\n" + + "Is not claimed\n" + + "Has not been occupied for `age-ticks` (20t = 1s) and \n" + + "Have not been accessed since `file-duration` (ms) after creation and\n" + + "Have not been used in the past `chunk-inactivity` (ms)" + + "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`" + ) @CommandPermissions("worldedit.anvil.deleteunclaimed") public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Arg(desc = "int", def = "60000") int fileDurationMillis, @Switch(name = 'd', desc = "TODO") boolean debug) throws WorldEditException { -// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED -// if (debug) { -// filter.enableDebug(); -// } -// DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED + // if (debug) { + // filter.enableDebug(); + // } + // DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "deletealloldregions", - aliases = {"deloldreg" }, - desc = "Delete regions which haven't been accessed in a certain amount of time", - descFooter = "You can use seconds (s), minutes (m), hours (h), days (d), weeks (w), years (y)\n" + - "(months are not a unit of time) e.g., 8h5m12s\n" + name = "deletealloldregions", + aliases = {"deloldreg" }, + desc = "Delete regions which haven't been accessed in a certain amount of time", + descFooter = "You can use seconds (s), minutes (m), hours (h), days (d), weeks (w), years (y)\n" + + "(months are not a unit of time) e.g., 8h5m12s\n" ) @CommandPermissions("worldedit.anvil.deletealloldregions") public void deleteAllOldRegions(Player player, String folder, String time) throws WorldEditException { -// long duration = MainUtil.timeToSec(time) * 1000L; TODO NOT IMPLEMENTED -// DeleteOldFilter filter = new DeleteOldFilter(duration); -// DeleteOldFilter result = runWithWorld(player, folder, filter, true); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // long duration = MainUtil.timeToSec(time) * 1000L; TODO NOT IMPLEMENTED + // DeleteOldFilter filter = new DeleteOldFilter(duration); + // DeleteOldFilter result = runWithWorld(player, folder, filter, true); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "trimallplots", + name = "trimallplots", - desc = "Trim chunks in a Plot World", - descFooter = "Unclaimed chunks will be deleted\nUnmodified chunks will be deleted\n" + desc = "Trim chunks in a Plot World", + descFooter = "Unclaimed chunks will be deleted\nUnmodified chunks will be deleted\n" ) @CommandPermissions("worldedit.anvil.trimallplots") public void trimAllPlots(Player player, @Switch(name = 'v', desc = "Delete unvisited chunks") boolean deleteUnvisited) throws WorldEditException { -// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED -// int visitTime = deleteUnvisited ? 1 : -1; -// PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000); -//// PlotTrimFilter result = runWithWorld(player, folder, filter, true); -// IQueueExtent defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false); -// MCAQueue queue = new MCAQueue(defaultQueue); -// PlotTrimFilter result = queue.filterWorld(filter); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED + // int visitTime = deleteUnvisited ? 1 : -1; + // PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000); + //// PlotTrimFilter result = runWithWorld(player, folder, filter, true); + // IQueueExtent defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false); + // MCAQueue queue = new MCAQueue(defaultQueue); + // PlotTrimFilter result = queue.filterWorld(filter); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "deletebiomechunks", - desc = "Delete chunks matching a specific biome" + 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); TODO NOT IMPLEMENTED -// DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); TODO NOT IMPLEMENTED + // DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "trimallair", - desc = "Trim all air in the world" + 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(); TODO NOT IMPLEMENTED -// TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // TrimAirFilter filter = new TrimAirFilter(); TODO NOT IMPLEMENTED + // TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "debugfixroads", + name = "debugfixroads", - desc = "debug - do not use" + desc = "debug - do not use" ) @CommandPermissions("worldedit.anvil.debugfixroads") public void debugfixroads(Player player, String folder) throws WorldEditException { -// DebugFixP2Roads filter = new DebugFixP2Roads(); TODO NOT IMPLEMENTED -// DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // DebugFixP2Roads filter = new DebugFixP2Roads(); TODO NOT IMPLEMENTED + // DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "replaceallpattern", - aliases = {"reap", "repallpat"}, - desc = "Replace all blocks in the selection with another" + name = "replaceallpattern", + aliases = {"reap", "repallpat"}, + desc = "Replace all blocks in the selection with another" ) @CommandPermissions("worldedit.anvil.replaceall") public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, Pattern toPattern, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap) throws WorldEditException { -// MCAFilterCounter filter; TODO NOT IMPLEMENTED -// if (useMap) { -// if (to instanceof RandomPattern) { -// List split = StringMan.split(from, ','); -// filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData); -// } else { -// player.print("Must be a pattern list!"); -// return; -// } -// } else { -// final FaweBlockMatcher matchFrom; -// if (from == null) { -// matchFrom = FaweBlockMatcher.NOT_AIR; -// } else { -// matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData || from.contains(":")); -// } -// filter = new ReplacePatternFilter(matchFrom, to); -// } -// MCAFilterCounter result = runWithWorld(player, folder, filter, true); -// if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // MCAFilterCounter filter; TODO NOT IMPLEMENTED + // if (useMap) { + // if (to instanceof RandomPattern) { + // List split = StringMan.split(from, ','); + // filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData); + // } else { + // player.print("Must be a pattern list!"); + // return; + // } + // } else { + // final FaweBlockMatcher matchFrom; + // if (from == null) { + // matchFrom = FaweBlockMatcher.NOT_AIR; + // } else { + // matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData || from.contains(":")); + // } + // filter = new ReplacePatternFilter(matchFrom, to); + // } + // MCAFilterCounter result = runWithWorld(player, folder, filter, true); + // if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); } // @Command( - name = "countall", - desc = "Count all blocks in a world" + name = "countall", + desc = "Count all blocks in a world" ) @CommandPermissions("worldedit.anvil.countall") public void countAll(Player player, EditSession editSession, String folder, String argStr, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { -// Set searchBlocks = worldEdit.getBlocks(player, arg, true); -// MCAFilterCounter filter; -// if (useData || arg.contains(":")) { // Optimize for both cases -// CountFilter counter = new CountFilter(); -// searchBlocks.forEach(counter::addBlock); -// filter = counter; -// } else { -// CountIdFilter counter = new CountIdFilter(); -// searchBlocks.forEach(counter::addBlock); -// filter = counter; -// } -// MCAFilterCounter result = runWithWorld(player, folder, filter, true); -// if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.selection.selection.count", (result.getTotal()))); + // Set searchBlocks = worldEdit.getBlocks(player, arg, true); + // MCAFilterCounter filter; + // if (useData || arg.contains(":")) { // Optimize for both cases + // CountFilter counter = new CountFilter(); + // searchBlocks.forEach(counter::addBlock); + // filter = counter; + // } else { + // CountIdFilter counter = new CountIdFilter(); + // searchBlocks.forEach(counter::addBlock); + // filter = counter; + // } + // MCAFilterCounter result = runWithWorld(player, folder, filter, true); + // if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.selection.selection.count", (result.getTotal()))); } @Command( - name = "clear", - aliases = {"unset"}, - desc = "Clear the chunks in a selection (delete without defrag)" + name = "clear", + aliases = {"unset"}, + desc = "Clear the chunks in a selection (delete without defrag)" ) @CommandPermissions("worldedit.anvil.clear") public void unset(Player player, EditSession editSession, @Selection Region selection) throws WorldEditException { -// BlockVector3 bot = selection.getMinimumPoint(); TODO NOT IMPLEMENTED -// BlockVector3 top = selection.getMaximumPoint(); -// RegionWrapper region = new RegionWrapper(bot, top); -// -// MCAFilterCounter filter = new MCAFilterCounter() { -// @Override -// public MCAFile applyFile(MCAFile file) { -// int X = file.getX(); -// int Z = file.getZ(); -// int bcx = X << 5; -// int bcz = Z << 5; -// int bx = X << 9; -// int bz = Z << 9; -// if (region.isIn(bx, bz) && region.isIn(bx + 511, bz + 511)) { -// file.setDeleted(true); -// get().add(512 * 512 * 256); -// } else if (region.isInMCA(X, Z)) { -// file.init(); -// final byte[] empty = new byte[4]; -// RandomAccessFile raf = file.getRandomAccessFile(); -// file.forEachChunk(new RunnableVal4() { -// @Override -// public void run(Integer cx, Integer cz, Integer offset, Integer size) { -// if (region.isInChunk(bcx + cx, bcz + cz)) { -// int index = ((cx & 31) << 2) + ((cz & 31) << 7); -// try { -// raf.seek(index); -// raf.write(empty); -// get().add(16 * 16 * 256); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// } -// }); -// file.clear(); -// } -// return null; -// } -// }; -// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // BlockVector3 bot = selection.getMinimumPoint(); TODO NOT IMPLEMENTED + // BlockVector3 top = selection.getMaximumPoint(); + // RegionWrapper region = new RegionWrapper(bot, top); + // + // MCAFilterCounter filter = new MCAFilterCounter() { + // @Override + // public MCAFile applyFile(MCAFile file) { + // int X = file.getX(); + // int Z = file.getZ(); + // int bcx = X << 5; + // int bcz = Z << 5; + // int bx = X << 9; + // int bz = Z << 9; + // if (region.isIn(bx, bz) && region.isIn(bx + 511, bz + 511)) { + // file.setDeleted(true); + // get().add(512 * 512 * 256); + // } else if (region.isInMCA(X, Z)) { + // file.init(); + // final byte[] empty = new byte[4]; + // RandomAccessFile raf = file.getRandomAccessFile(); + // file.forEachChunk(new RunnableVal4() { + // @Override + // public void run(Integer cx, Integer cz, Integer offset, Integer size) { + // if (region.isInChunk(bcx + cx, bcz + cz)) { + // int index = ((cx & 31) << 2) + ((cz & 31) << 7); + // try { + // raf.seek(index); + // raf.write(empty); + // get().add(16 * 16 * 256); + // } catch (IOException e) { + // e.printStackTrace(); + // } + // } + // } + // }); + // file.clear(); + // } + // return null; + // } + // }; + // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "count", - desc = "Count blocks in a selection" + name = "count", + desc = "Count blocks in a selection" ) @CommandPermissions("worldedit.anvil.count") public void count(Player player, EditSession editSession, @Selection Region selection, String argStr, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { -// Set searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED -// MCAFilterCounter filter; -// if (useData || arg.contains(":")) { // Optimize for both cases -// CountFilter counter = new CountFilter(); -// searchBlocks.forEach(counter::addBlock); -// filter = counter; -// } else { -// CountIdFilter counter = new CountIdFilter(); -// searchBlocks.forEach(counter::addBlock); -// filter = counter; -// } -// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); -// if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.selection.selection.count", (result.getTotal()))); + // Set searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED + // MCAFilterCounter filter; + // if (useData || arg.contains(":")) { // Optimize for both cases + // CountFilter counter = new CountFilter(); + // searchBlocks.forEach(counter::addBlock); + // filter = counter; + // } else { + // CountIdFilter counter = new CountIdFilter(); + // searchBlocks.forEach(counter::addBlock); + // filter = counter; + // } + // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); + // if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.selection.selection.count", (result.getTotal()))); } // @Command( - name = "distr", - desc = "Replace all blocks in the selection with another" + name = "distr", + desc = "Replace all blocks in the selection with another" ) @CommandPermissions("worldedit.anvil.distr") public void distr(Player player, EditSession editSession, @Selection Region selection, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { -// long total = 0; TODO NOT IMPLEMENTED -// long[] count; -// MCAFilter counts; -// if (useData) { -// counts = runWithSelection(player, editSession, selection, new MCAFilter() { -// @Override -// public void applyBlock(int x, int y, int z, BaseBlock block, long[] counts) { -// counts[block.getCombined()]++; -// } -// -// @Override -// public long[] init() { -// return new long[Character.MAX_VALUE + 1]; -// } -// }); -// count = new long[Character.MAX_VALUE + 1]; -// } else { -// counts = runWithSelection(player, editSession, selection, new MCAFilter() { -// @Override -// public void applyBlock(int x, int y, int z, BaseBlock block, long[] counts) { -// counts[block.getId()]++; -// } -// -// @Override -// public long[] init() { -// return new long[4096]; -// } -// }); -// count = new long[4096]; -// } -// for (long[] value : counts) { -// for (int i = 0; i < value.length; i++) { -// count[i] += value[i]; -// total += value[i]; -// } -// } -// ArrayList map = new ArrayList<>(); -// for (int i = 0; i < count.length; i++) { -// if (count[i] != 0) map.add(new long[]{i, count[i]}); -// } -// Collections.sort(map, new Comparator() { -// @Override -// public int compare(long[] a, long[] b) { -// long vA = a[1]; -// long vB = b[1]; -// return (vA < vB) ? -1 : ((vA == vB) ? 0 : 1); -// } -// }); -// if (useData) { -// for (long[] c : map) { -// BaseBlock block = FaweCache.IMP.CACHE_BLOCK[(int) c[0]]; -// String name = BlockType.fromID(block.getId()).getName(); -// String str = String.format("%-7s (%.3f%%) %s #%d:%d", -// String.valueOf(c[1]), -// ((c[1] * 10000) / total) / 100d, -// name == null ? "Unknown" : name, -// block.getType(), block.getData()); -// player.print(str); -// } -// } else { -// for (long[] c : map) { -// BlockType block = BlockType.fromID((int) c[0]); -// String str = String.format("%-7s (%.3f%%) %s #%d", -// String.valueOf(c[1]), -// ((c[1] * 10000) / total) / 100d, -// block == null ? "Unknown" : block.getName(), c[0]); -// player.print(str); -// } -// } + // long total = 0; TODO NOT IMPLEMENTED + // long[] count; + // MCAFilter counts; + // if (useData) { + // counts = runWithSelection(player, editSession, selection, new MCAFilter() { + // @Override + // public void applyBlock(int x, int y, int z, BaseBlock block, long[] counts) { + // counts[block.getCombined()]++; + // } + // + // @Override + // public long[] init() { + // return new long[Character.MAX_VALUE + 1]; + // } + // }); + // count = new long[Character.MAX_VALUE + 1]; + // } else { + // counts = runWithSelection(player, editSession, selection, new MCAFilter() { + // @Override + // public void applyBlock(int x, int y, int z, BaseBlock block, long[] counts) { + // counts[block.getId()]++; + // } + // + // @Override + // public long[] init() { + // return new long[4096]; + // } + // }); + // count = new long[4096]; + // } + // for (long[] value : counts) { + // for (int i = 0; i < value.length; i++) { + // count[i] += value[i]; + // total += value[i]; + // } + // } + // ArrayList map = new ArrayList<>(); + // for (int i = 0; i < count.length; i++) { + // if (count[i] != 0) map.add(new long[]{i, count[i]}); + // } + // Collections.sort(map, new Comparator() { + // @Override + // public int compare(long[] a, long[] b) { + // long vA = a[1]; + // long vB = b[1]; + // return (vA < vB) ? -1 : ((vA == vB) ? 0 : 1); + // } + // }); + // if (useData) { + // for (long[] c : map) { + // BaseBlock block = FaweCache.IMP.CACHE_BLOCK[(int) c[0]]; + // String name = BlockType.fromID(block.getId()).getName(); + // String str = String.format("%-7s (%.3f%%) %s #%d:%d", + // String.valueOf(c[1]), + // ((c[1] * 10000) / total) / 100d, + // name == null ? "Unknown" : name, + // block.getType(), block.getData()); + // player.print(str); + // } + // } else { + // for (long[] c : map) { + // BlockType block = BlockType.fromID((int) c[0]); + // String str = String.format("%-7s (%.3f%%) %s #%d", + // String.valueOf(c[1]), + // ((c[1] * 10000) / total) / 100d, + // block == null ? "Unknown" : block.getName(), c[0]); + // player.print(str); + // } + // } } // @Command( - name = "replace", - aliases = {"r"}, - desc = "Replace all blocks in the selection with another" + name = "replace", + aliases = {"r"}, + desc = "Replace all blocks in the selection with another" ) @CommandPermissions("worldedit.anvil.replace") public void replace(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, String toStr, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException { -// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED -// if (from == null) { -// matchFrom = FaweBlockMatcher.NOT_AIR; -// } else { -// matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData || from.contains(":")); -// } -// final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true)); -// ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); -// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED + // if (from == null) { + // matchFrom = FaweBlockMatcher.NOT_AIR; + // } else { + // matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData || from.contains(":")); + // } + // final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true)); + // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); + // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } // @Command( - name = "replacepattern", - aliases = {"preplace", "rp"}, - desc = "Replace all blocks in the selection with a pattern" + name = "replacepattern", + aliases = {"preplace", "rp"}, + desc = "Replace all blocks in the selection with a pattern" ) @CommandPermissions("worldedit.anvil.replace") public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, final Pattern toPattern, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap) throws WorldEditException { -// MCAFilterCounter filter; TODO NOT IMPLEMENTED -// if (useMap) { -// if (to instanceof RandomPattern) { -// List split = StringMan.split(from, ','); -// filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData); -// } else { -// player.print("Must be a pattern list!"); -// return; -// } -// } else { -// final FaweBlockMatcher matchFrom; -// if (from == null) { -// matchFrom = FaweBlockMatcher.NOT_AIR; -// } else { -// matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData || from.contains(":")); -// } -// filter = new ReplacePatternFilter(matchFrom, to); -// } -// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // MCAFilterCounter filter; TODO NOT IMPLEMENTED + // if (useMap) { + // if (to instanceof RandomPattern) { + // List split = StringMan.split(from, ','); + // filter = new MappedReplacePatternFilter(from, (RandomPattern) to, useData); + // } else { + // player.print("Must be a pattern list!"); + // return; + // } + // } else { + // final FaweBlockMatcher matchFrom; + // if (from == null) { + // matchFrom = FaweBlockMatcher.NOT_AIR; + // } else { + // matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData || from.contains(":")); + // } + // filter = new ReplacePatternFilter(matchFrom, to); + // } + // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "set", - desc = "Set all blocks in the selection with a pattern" + name = "set", + desc = "Set all blocks in the selection with a pattern" ) @CommandPermissions("worldedit.anvil.set") // Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern toPattern, @Switch(name = 'd', desc = "TODO") boolean useData, @Switch(name = 'm', desc = "TODO") boolean useMap public void set(Player player, EditSession editSession, @Selection Region selection, final Pattern toPattern) throws WorldEditException { -// MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED -// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED + // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "removelayers", - desc = "Removes matching chunk layers", - descFooter = "Only if a chunk matches the provided id" + name = "removelayers", + desc = "Removes matching chunk layers", + descFooter = "Only if a chunk matches the provided id" ) @CommandPermissions("worldedit.anvil.removelayer") public void removeLayers(Player player, EditSession editSession, @Selection Region selection, int id) throws WorldEditException { -// BlockVector3 min = selection.getMinimumPoint(); TODO NOT IMPLEMENTED -// BlockVector3 max = selection.getMaximumPoint(); -// int minY = min.getBlockY(); -// int maxY = max.getBlockY(); -// RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id); -// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); -// if (result != null) { -// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); -// } + // BlockVector3 min = selection.getMinimumPoint(); TODO NOT IMPLEMENTED + // BlockVector3 max = selection.getMaximumPoint(); + // int minY = min.getBlockY(); + // int maxY = max.getBlockY(); + // RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id); + // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); + // if (result != null) { + // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); + // } } @Command( - name = "copy", - desc = "Lazily copy chunks to your anvil clipboard" + name = "copy", + desc = "Lazily copy chunks to your anvil clipboard" ) @CommandPermissions("worldedit.anvil.copychunks") public void copy(Player player, LocalSession session, EditSession editSession, @Selection Region selection) throws WorldEditException { -// if (!(selection instanceof CuboidRegion)) { TODO NOT IMPLEMENTED -// player.print(TranslatableComponent.of("fawe.error.no.region")) -// return; -// } -// CuboidRegion cuboid = (CuboidRegion) selection; -// String worldName = editSession.getWorld().getName(); -// IQueueExtent tmp = SetQueue.IMP.getNewQueue(worldName, true, false); -// MCAQueue queue = new MCAQueue(tmp); -// BlockVector3 origin = session.getPlacementPosition(player); -// MCAClipboard clipboard = new MCAClipboard(queue, cuboid, origin); -// FawePlayer fp = FawePlayer.wrap(player); -// fp.setMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD, clipboard); -// player.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy" , selection.getArea())); + // if (!(selection instanceof CuboidRegion)) { TODO NOT IMPLEMENTED + // player.print(TranslatableComponent.of("fawe.error.no.region")) + // return; + // } + // CuboidRegion cuboid = (CuboidRegion) selection; + // String worldName = editSession.getWorld().getName(); + // IQueueExtent tmp = SetQueue.IMP.getNewQueue(worldName, true, false); + // MCAQueue queue = new MCAQueue(tmp); + // BlockVector3 origin = session.getPlacementPosition(player); + // MCAClipboard clipboard = new MCAClipboard(queue, cuboid, origin); + // FawePlayer fp = FawePlayer.wrap(player); + // fp.setMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD, clipboard); + // player.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy" , selection.getArea())); } @Command( - name = "paste", - desc = "Paste chunks from your anvil clipboard", - descFooter = "Paste the chunks from your anvil clipboard.\n" + - "The -c flag will align the paste to the chunks." + name = "paste", + desc = "Paste chunks from your anvil clipboard", + descFooter = "Paste the chunks from your anvil clipboard.\n" + + "The -c flag will align the paste to the chunks." ) @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); TODO NOT IMPLEMENTED -// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD); -// if (clipboard == null) { -// fp.sendMessage("You must first use `//anvil copy`"); -// return; -// } -// CuboidRegion cuboid = clipboard.getRegion(); -// RegionWrapper copyRegion = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint()); -// final Vector offset = player.getPosition().subtract(clipboard.getOrigin()); -// if (alignChunk) { -// offset.setComponents((offset.getBlockX() >> 4) << 4, offset.getBlockY(), (offset.getBlockZ() >> 4) << 4); -// } -// int oX = offset.getBlockX(); -// int oZ = offset.getBlockZ(); -// RegionWrapper pasteRegion = new RegionWrapper(copyRegion.minX + oX, copyRegion.maxX + oX, copyRegion.minZ + oZ, copyRegion.maxZ + oZ); -// String pasteWorldName = editSession.getWorld().getName(); -// IQueueExtent tmpTo = SetQueue.IMP.getNewQueue(pasteWorldName, true, false); -// MCAQueue copyQueue = clipboard.getQueue(); -// MCAQueue pasteQueue = new MCAQueue(tmpTo); -// -// fp.checkAllowedRegion(pasteRegion); -// recordHistory(fp, editSession.getWorld(), iAnvilHistory -> { -// try { -// pasteQueue.pasteRegion(copyQueue, copyRegion, offset, iAnvilHistory); -// } catch (IOException e) { throw new RuntimeException(e); } -// }); -// player.print(TranslatableComponent.of("fawe.worldedit.paste.command.paste" , player.getPosition().toBlockVector())); + // FawePlayer fp = FawePlayer.wrap(player); TODO NOT IMPLEMENTED + // MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD); + // if (clipboard == null) { + // fp.sendMessage("You must first use `//anvil copy`"); + // return; + // } + // CuboidRegion cuboid = clipboard.getRegion(); + // RegionWrapper copyRegion = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint()); + // final Vector offset = player.getPosition().subtract(clipboard.getOrigin()); + // if (alignChunk) { + // offset.setComponents((offset.getBlockX() >> 4) << 4, offset.getBlockY(), (offset.getBlockZ() >> 4) << 4); + // } + // int oX = offset.getBlockX(); + // int oZ = offset.getBlockZ(); + // RegionWrapper pasteRegion = new RegionWrapper(copyRegion.minX + oX, copyRegion.maxX + oX, copyRegion.minZ + oZ, copyRegion.maxZ + oZ); + // String pasteWorldName = editSession.getWorld().getName(); + // IQueueExtent tmpTo = SetQueue.IMP.getNewQueue(pasteWorldName, true, false); + // MCAQueue copyQueue = clipboard.getQueue(); + // MCAQueue pasteQueue = new MCAQueue(tmpTo); + // + // fp.checkAllowedRegion(pasteRegion); + // recordHistory(fp, editSession.getWorld(), iAnvilHistory -> { + // try { + // pasteQueue.pasteRegion(copyQueue, copyRegion, offset, iAnvilHistory); + // } catch (IOException e) { throw new RuntimeException(e); } + // }); + // player.print(TranslatableComponent.of("fawe.worldedit.paste.command.paste" , player.getPosition().toBlockVector())); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/SuggestInputParseException.java b/worldedit-core/src/main/java/com/boydti/fawe/command/SuggestInputParseException.java index 7af1cd09b..55ca58c38 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/SuggestInputParseException.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/SuggestInputParseException.java @@ -1,13 +1,14 @@ package com.boydti.fawe.command; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extension.input.InputParseException; + import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.function.Supplier; import java.util.stream.Collectors; +import static com.google.common.base.Preconditions.checkNotNull; + public class SuggestInputParseException extends InputParseException { private final InputParseException cause; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Caption.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Caption.java index 2f7308040..8f0d39830 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Caption.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Caption.java @@ -5,20 +5,25 @@ import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; +import com.sk89q.worldedit.util.formatting.text.format.Style; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer; import org.jetbrains.annotations.Nullable; -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.Objects; +import java.util.regex.Pattern; import java.util.stream.Collectors; +import javax.annotation.Nonnull; public class Caption { + + private static final Pattern colorCodes = Pattern.compile("&([0-9a-o])"); + public static String toString(Component component) { return toString(component, WorldEdit.getInstance().getTranslationManager().getDefaultLocale()); } @@ -39,9 +44,9 @@ public class Caption { private static Component color(TextComponent text) { String content = text.content(); - if (content.indexOf('&') != -1) { + if (colorCodes.matcher(content).find()) { TextComponent legacy = LegacyComponentSerializer.INSTANCE.deserialize(content, '&'); - legacy = (TextComponent) legacy.style(text.style()); + legacy.style().merge(text.style(), Style.Merge.Strategy.IF_ABSENT_ON_TARGET); if (!text.children().isEmpty()) { text = TextComponent.builder().append(legacy).append(text.children()).build(); } else { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java index 7ac5196cb..f6533209d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java @@ -1,9 +1,11 @@ package com.boydti.fawe.config; -import com.boydti.fawe.Fawe; import com.boydti.fawe.configuration.MemorySection; import com.boydti.fawe.configuration.file.YamlConfiguration; import com.boydti.fawe.util.StringMan; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.PrintWriter; @@ -20,8 +22,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class Config { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java index 2a74551d5..5586fc000 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java @@ -2,6 +2,7 @@ package com.boydti.fawe.config; import com.boydti.fawe.object.FaweLimit; import com.sk89q.worldedit.extension.platform.Actor; + import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -14,8 +15,6 @@ public class Settings extends Config { @Ignore public boolean PROTOCOL_SUPPORT_FIX = false; - @Ignore - public boolean PLOTSQUARED_HOOK = true; @Comment("These first 6 aren't configurable") // This is a comment @Final // Indicates that this value isn't configurable @@ -46,6 +45,8 @@ public class Settings extends Config { }) public int MAX_MEMORY_PERCENT = 95; + @Create + public ENABLED_COMPONENTS ENABLED_COMPONENTS; @Create public CLIPBOARD CLIPBOARD; @Create @@ -55,6 +56,8 @@ public class Settings extends Config { @Create public WEB WEB; @Create + public PLOTSQUARED_INTEGRATION PLOTSQUARED_INTEGRATION; + @Create public EXTENT EXTENT; @Create public EXPERIMENTAL EXPERIMENTAL; @@ -67,11 +70,16 @@ public class Settings extends Config { @Create public REGION_RESTRICTIONS_OPTIONS REGION_RESTRICTIONS_OPTIONS; @Create - public ENABLED_COMPONENTS ENABLED_COMPONENTS; + public ConfigBlock LIMITS; @Comment("Enable or disable core components") public static final class ENABLED_COMPONENTS { public boolean COMMANDS = true; + @Comment({ + "Disable the FAWE-PlotSquared hook to take over most intense P2 queueing", + "Specific aspects can be turned on and off further below" + }) + public boolean PLOTSQUARED_HOOK = true; } @Comment("Paths for various directories") @@ -103,10 +111,6 @@ public class Settings extends Config { public String MODE = "MEMBER"; } - - @Create // This value will be generated automatically - public ConfigBlock LIMITS; - @Comment({ "The \"default\" limit group affects those without a specific limit permission.", "To grant someone different limits, copy the default limits group", @@ -388,6 +392,13 @@ public class Settings extends Config { public boolean ALLOW_TICK_EXISTING = true; } + public static class PLOTSQUARED_INTEGRATION { + public boolean CLEAR = true; + public boolean CUBOIDS = true; + public boolean COPY_AND_SWAP = true; + public boolean SET_BIOME = true; + } + public static class WEB { @Comment({ "Should download urls be shortened?", diff --git a/worldedit-core/src/main/java/com/boydti/fawe/configuration/TypeDescription.java b/worldedit-core/src/main/java/com/boydti/fawe/configuration/TypeDescription.java index 1f0b1474c..087cc7929 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/configuration/TypeDescription.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/configuration/TypeDescription.java @@ -15,9 +15,10 @@ */ package org.yaml.snakeyaml; +import org.yaml.snakeyaml.nodes.Tag; + import java.util.HashMap; import java.util.Map; -import org.yaml.snakeyaml.nodes.Tag; /** * Provides additional runtime information necessary to create a custom Java diff --git a/worldedit-core/src/main/java/com/boydti/fawe/configuration/Yaml.java b/worldedit-core/src/main/java/com/boydti/fawe/configuration/Yaml.java index 400d19c24..01dee77db 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/configuration/Yaml.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/configuration/Yaml.java @@ -1,30 +1,5 @@ -/** - * Copyright (c) 2008, http://www.snakeyaml.org - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.yaml.snakeyaml; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.regex.Pattern; import org.yaml.snakeyaml.DumperOptions.FlowStyle; import org.yaml.snakeyaml.composer.Composer; import org.yaml.snakeyaml.constructor.BaseConstructor; @@ -44,6 +19,17 @@ import org.yaml.snakeyaml.representer.Representer; import org.yaml.snakeyaml.resolver.Resolver; import org.yaml.snakeyaml.serializer.Serializer; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Pattern; + /** * Public YAML interface. Each Thread must have its own instance. */ @@ -65,8 +51,7 @@ public class Yaml { /** * Create Yaml instance. * - * @param dumperOptions - * DumperOptions to configure outgoing objects + * @param dumperOptions DumperOptions to configure outgoing objects */ public Yaml(DumperOptions dumperOptions) { this(new Constructor(), new Representer(), dumperOptions); @@ -76,8 +61,7 @@ public class Yaml { * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. * - * @param representer - * Representer to emit outgoing objects + * @param representer Representer to emit outgoing objects */ public Yaml(Representer representer) { this(new Constructor(), representer); @@ -87,8 +71,7 @@ public class Yaml { * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. * - * @param constructor - * BaseConstructor to construct incoming documents + * @param constructor BaseConstructor to construct incoming documents */ public Yaml(BaseConstructor constructor) { this(constructor, new Representer()); @@ -98,10 +81,8 @@ public class Yaml { * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. * - * @param constructor - * BaseConstructor to construct incoming documents - * @param representer - * Representer to emit outgoing objects + * @param constructor BaseConstructor to construct incoming documents + * @param representer Representer to emit outgoing objects */ public Yaml(BaseConstructor constructor, Representer representer) { this(constructor, representer, new DumperOptions()); @@ -111,10 +92,8 @@ public class Yaml { * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. * - * @param representer - * Representer to emit outgoing objects - * @param dumperOptions - * DumperOptions to configure outgoing objects + * @param representer Representer to emit outgoing objects + * @param dumperOptions DumperOptions to configure outgoing objects */ public Yaml(Representer representer, DumperOptions dumperOptions) { this(new Constructor(), representer, dumperOptions, new Resolver()); @@ -124,12 +103,9 @@ public class Yaml { * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. * - * @param constructor - * BaseConstructor to construct incoming documents - * @param representer - * Representer to emit outgoing objects - * @param dumperOptions - * DumperOptions to configure outgoing objects + * @param constructor BaseConstructor to construct incoming documents + * @param representer Representer to emit outgoing objects + * @param dumperOptions DumperOptions to configure outgoing objects */ public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions) { this(constructor, representer, dumperOptions, new Resolver()); @@ -139,17 +115,12 @@ public class Yaml { * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. * - * @param constructor - * BaseConstructor to construct incoming documents - * @param representer - * Representer to emit outgoing objects - * @param dumperOptions - * DumperOptions to configure outgoing objects - * @param resolver - * Resolver to detect implicit type + * @param constructor BaseConstructor to construct incoming documents + * @param representer Representer to emit outgoing objects + * @param dumperOptions DumperOptions to configure outgoing objects + * @param resolver Resolver to detect implicit type */ - public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions, - Resolver resolver) { + public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions, Resolver resolver) { if (!constructor.isExplicitPropertyUtils()) { constructor.setPropertyUtils(representer.getPropertyUtils()); } else if (!representer.isExplicitPropertyUtils()) { @@ -158,8 +129,7 @@ public class Yaml { this.constructor = constructor; representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle()); representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle()); - representer.getPropertyUtils().setAllowReadOnlyProperties( - dumperOptions.isAllowReadOnlyProperties()); + representer.getPropertyUtils().setAllowReadOnlyProperties(dumperOptions.isAllowReadOnlyProperties()); representer.setTimeZone(dumperOptions.getTimeZone()); this.representer = representer; this.dumperOptions = dumperOptions; @@ -170,8 +140,7 @@ public class Yaml { /** * Serialize a Java object into a YAML String. * - * @param data - * Java object to be Serialized to YAML + * @param data Java object to be Serialized to YAML * @return YAML String */ public String dump(Object data) { @@ -183,11 +152,10 @@ public class Yaml { /** * Produce the corresponding representation tree for a given Object. * - * @see Figure 3.1. Processing - * Overview - * @param data - * instance to build the representation tree for + * @param data instance to build the representation tree for * @return representation tree + * @see Figure 3.1. Processing + * Overview */ public Node represent(Object data) { return representer.represent(data); @@ -196,8 +164,7 @@ public class Yaml { /** * Serialize a sequence of Java objects into a YAML String. * - * @param data - * Iterator with Objects + * @param data Iterator with Objects * @return YAML String with all the objects in proper sequence */ public String dumpAll(Iterator data) { @@ -209,10 +176,8 @@ public class Yaml { /** * Serialize a Java object into a YAML stream. * - * @param data - * Java object to be serialized to YAML - * @param output - * stream to write to + * @param data Java object to be serialized to YAML + * @param output stream to write to */ public void dump(Object data, Writer output) { List list = new ArrayList<>(1); @@ -223,18 +188,15 @@ public class Yaml { /** * Serialize a sequence of Java objects into a YAML stream. * - * @param data - * Iterator with Objects - * @param output - * stream to write to + * @param data Iterator with Objects + * @param output stream to write to */ public void dumpAll(Iterator data, Writer output) { dumpAll(data, output, null); } private void dumpAll(Iterator data, Writer output, Tag rootTag) { - Serializer serializer = new Serializer(new Emitter(output, dumperOptions), resolver, - dumperOptions, rootTag); + Serializer serializer = new Serializer(new Emitter(output, dumperOptions), resolver, dumperOptions, rootTag); try { serializer.open(); while (data.hasNext()) { @@ -272,19 +234,15 @@ public class Yaml { * handled as an instance of YourClass when loaded. *

* - * @param data - * Java object to be serialized to YAML - * @param rootTag - * the tag for the whole YAML document. The tag should be Tag.MAP - * for a JavaBean to make the tag disappear (to use implicit tag - * !!map). If null is provided then the standard tag - * with the full class name is used. - * @param flowStyle - * flow style for the whole document. See Chapter 10. Collection - * Styles http://yaml.org/spec/1.1/#id930798. If - * null is provided then the flow style from - * DumperOptions is used. - * + * @param data Java object to be serialized to YAML + * @param rootTag the tag for the whole YAML document. The tag should be Tag.MAP + * for a JavaBean to make the tag disappear (to use implicit tag + * !!map). If null is provided then the standard tag + * with the full class name is used. + * @param flowStyle flow style for the whole document. See Chapter 10. Collection + * Styles http://yaml.org/spec/1.1/#id930798. If + * null is provided then the flow style from + * DumperOptions is used. * @return YAML String */ public String dumpAs(Object data, Tag rootTag, FlowStyle flowStyle) { @@ -315,8 +273,7 @@ public class Yaml { * (http://yaml.org/spec/1.1/#id934537) *

* - * @param data - * Java object to be serialized to YAML + * @param data Java object to be serialized to YAML * @return YAML String */ public String dumpAsMap(Object data) { @@ -326,10 +283,9 @@ public class Yaml { /** * Serialize the representation tree into Events. * - * @see Processing Overview - * @param data - * representation tree + * @param data representation tree * @return Event list + * @see Processing Overview */ public List serialize(Node data) { SilentEmitter emitter = new SilentEmitter(); @@ -360,8 +316,7 @@ public class Yaml { * Parse the only YAML document in a String and produce the corresponding * Java object. (Because the encoding in known BOM is not respected.) * - * @param yaml - * YAML data to load from (BOM must not be present) + * @param yaml YAML data to load from (BOM must not be present) * @return parsed object */ public Object load(String yaml) { @@ -372,8 +327,7 @@ public class Yaml { * Parse the only YAML document in a stream and produce the corresponding * Java object. * - * @param io - * data to load from (BOM is respected and removed) + * @param io data to load from (BOM is respected and removed) * @return parsed object */ public Object load(InputStream io) { @@ -384,8 +338,7 @@ public class Yaml { * Parse the only YAML document in a stream and produce the corresponding * Java object. * - * @param io - * data to load from (BOM must not be present) + * @param io data to load from (BOM must not be present) * @return parsed object */ public Object load(Reader io) { @@ -396,12 +349,9 @@ public class Yaml { * Parse the only YAML document in a stream and produce the corresponding * Java object. * - * @param - * Class is defined by the second argument - * @param io - * data to load from (BOM must not be present) - * @param type - * Class of the object to be created + * @param Class is defined by the second argument + * @param io data to load from (BOM must not be present) + * @param type Class of the object to be created * @return parsed object */ @SuppressWarnings("unchecked") @@ -413,12 +363,9 @@ public class Yaml { * Parse the only YAML document in a String and produce the corresponding * Java object. (Because the encoding in known BOM is not respected.) * - * @param - * Class is defined by the second argument - * @param yaml - * YAML data to load from (BOM must not be present) - * @param type - * Class of the object to be created + * @param Class is defined by the second argument + * @param yaml YAML data to load from (BOM must not be present) + * @param type Class of the object to be created * @return parsed object */ @SuppressWarnings("unchecked") @@ -430,12 +377,9 @@ public class Yaml { * Parse the only YAML document in a stream and produce the corresponding * Java object. * - * @param - * Class is defined by the second argument - * @param input - * data to load from (BOM is respected and removed) - * @param type - * Class of the object to be created + * @param Class is defined by the second argument + * @param input data to load from (BOM is respected and removed) + * @param type Class of the object to be created * @return parsed object */ @SuppressWarnings("unchecked") @@ -453,10 +397,9 @@ public class Yaml { * Parse all YAML documents in a String and produce corresponding Java * objects. The documents are parsed only when the iterator is invoked. * - * @param yaml - * YAML data to load from (BOM must not be present) + * @param yaml YAML data to load from (BOM must not be present) * @return an iterator over the parsed Java objects in this String in proper - * sequence + * sequence */ public Iterable loadAll(Reader yaml) { Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver); @@ -494,10 +437,9 @@ public class Yaml { * objects. (Because the encoding in known BOM is not respected.) The * documents are parsed only when the iterator is invoked. * - * @param yaml - * YAML data to load from (BOM must not be present) + * @param yaml YAML data to load from (BOM must not be present) * @return an iterator over the parsed Java objects in this String in proper - * sequence + * sequence */ public Iterable loadAll(String yaml) { return loadAll(new StringReader(yaml)); @@ -507,10 +449,9 @@ public class Yaml { * Parse all YAML documents in a stream and produce corresponding Java * objects. The documents are parsed only when the iterator is invoked. * - * @param yaml - * YAML data to load from (BOM is respected and ignored) + * @param yaml YAML data to load from (BOM is respected and ignored) * @return an iterator over the parsed Java objects in this stream in proper - * sequence + * sequence */ public Iterable loadAll(InputStream yaml) { return loadAll(new UnicodeReader(yaml)); @@ -520,11 +461,10 @@ public class Yaml { * Parse the first YAML document in a stream and produce the corresponding * representation tree. (This is the opposite of the represent() method) * - * @see Figure 3.1. Processing - * Overview - * @param yaml - * YAML document + * @param yaml YAML document * @return parsed root Node for the specified YAML document + * @see Figure 3.1. Processing + * Overview */ public Node compose(Reader yaml) { Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver); @@ -536,10 +476,9 @@ public class Yaml { * Parse all YAML documents in a stream and produce corresponding * representation trees. * - * @see Processing Overview - * @param yaml - * stream of YAML documents + * @param yaml stream of YAML documents * @return parsed root Nodes for all the specified YAML documents + * @see Processing Overview */ public Iterable composeAll(Reader yaml) { final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver); @@ -576,13 +515,10 @@ public class Yaml { * Add an implicit scalar detector. If an implicit scalar value matches the * given regexp, the corresponding tag is assigned to the scalar. * - * @param tag - * tag to assign to the node - * @param regexp - * regular expression to match against - * @param first - * a sequence of possible initial characters or null (which means - * any). + * @param tag tag to assign to the node + * @param regexp regular expression to match against + * @param first a sequence of possible initial characters or null (which means + * any). */ public void addImplicitResolver(Tag tag, Pattern regexp, String first) { resolver.addImplicitResolver(tag, regexp, first); @@ -607,8 +543,7 @@ public class Yaml { /** * Set a meaningful name to be shown in toString() * - * @param name - * human readable name + * @param name human readable name */ public void setName(String name) { this.name = name; @@ -617,10 +552,9 @@ public class Yaml { /** * Parse a YAML stream and produce parsing events. * - * @see Processing Overview - * @param yaml - * YAML document(s) + * @param yaml YAML document(s) * @return parsed events + * @see Processing Overview */ public Iterable parse(Reader yaml) { final Parser parser = new ParserImpl(new StreamReader(yaml)); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/FileConfiguration.java b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/FileConfiguration.java index 3f3c8ec1b..79a915b67 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/FileConfiguration.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/FileConfiguration.java @@ -3,6 +3,7 @@ package com.boydti.fawe.configuration.file; import com.boydti.fawe.configuration.Configuration; import com.boydti.fawe.configuration.InvalidConfigurationException; import com.boydti.fawe.configuration.MemoryConfiguration; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfiguration.java b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfiguration.java index a3b6647d7..e42b2ebcd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfiguration.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfiguration.java @@ -3,16 +3,20 @@ package com.boydti.fawe.configuration.file; import com.boydti.fawe.configuration.Configuration; import com.boydti.fawe.configuration.ConfigurationSection; import com.boydti.fawe.configuration.InvalidConfigurationException; +import com.sk89q.worldedit.util.YAMLConfiguration; +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.error.YAMLException; +import org.yaml.snakeyaml.representer.Representer; + import java.io.File; import java.io.IOException; import java.io.Reader; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.Map; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.error.YAMLException; -import org.yaml.snakeyaml.representer.Representer; + +import static org.slf4j.LoggerFactory.getLogger; /** * An implementation of {@link com.boydti.fawe.configuration.Configuration} which saves all files in Yaml. @@ -27,12 +31,16 @@ public class YamlConfiguration extends FileConfiguration { /** * Creates a new {@link com.boydti.fawe.configuration.file.YamlConfiguration}, loading from the given file. + * *

* Any errors loading the Configuration will be logged and then ignored. * If the specified input is not a valid config, a blank config will be * returned. + *

+ * *

* The encoding used may follow the system dependent default. + *

* * @param file Input file * @return Resulting configuration @@ -71,10 +79,12 @@ public class YamlConfiguration extends FileConfiguration { /** * Creates a new {@link com.boydti.fawe.configuration.file.YamlConfiguration}, loading from the given reader. + * *

* Any errors loading the Configuration will be logged and then ignored. * If the specified input is not a valid config, a blank config will be * returned. + *

* * @param reader input * @return resulting configuration @@ -90,8 +100,7 @@ public class YamlConfiguration extends FileConfiguration { try { config.load(reader); } catch (final IOException | InvalidConfigurationException ex) { - System.out.println("Cannot load configuration from stream"); - ex.printStackTrace(); + getLogger(YAMLConfiguration.class).error("Cannot load configuration from stream", ex); } return config; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfigurationOptions.java b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfigurationOptions.java index f1351a8fa..f84d30310 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfigurationOptions.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfigurationOptions.java @@ -1,8 +1,7 @@ package com.boydti.fawe.configuration.file; /** - * Various settings for controlling the input and output of a {@link - * com.boydti.fawe.configuration.file.YamlConfiguration} + * Various settings for controlling the input and output of a {@link YamlConfiguration}. */ public class YamlConfigurationOptions extends FileConfigurationOptions { private int indent = 2; @@ -42,8 +41,10 @@ public class YamlConfigurationOptions extends FileConfigurationOptions { /** * Gets how much spaces should be used to indent each line. + * *

* The minimum value this may be is 2, and the maximum is 9. + *

* * @return How much to indent by */ diff --git a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConstructor.java b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConstructor.java index 12fa6a616..5d48addfb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConstructor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConstructor.java @@ -1,13 +1,14 @@ package com.boydti.fawe.configuration.file; import com.boydti.fawe.configuration.serialization.ConfigurationSerialization; -import java.util.LinkedHashMap; -import java.util.Map; import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.nodes.Tag; +import java.util.LinkedHashMap; +import java.util.Map; + public class YamlConstructor extends SafeConstructor { public YamlConstructor() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlRepresenter.java b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlRepresenter.java index 8811e8519..a891d5e29 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlRepresenter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlRepresenter.java @@ -3,11 +3,12 @@ package com.boydti.fawe.configuration.file; import com.boydti.fawe.configuration.ConfigurationSection; import com.boydti.fawe.configuration.serialization.ConfigurationSerializable; import com.boydti.fawe.configuration.serialization.ConfigurationSerialization; -import java.util.LinkedHashMap; -import java.util.Map; import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.representer.Representer; +import java.util.LinkedHashMap; +import java.util.Map; + public class YamlRepresenter extends Representer { public YamlRepresenter() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/database/DBHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/database/DBHandler.java index 32202bc70..720fd671f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/database/DBHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/database/DBHandler.java @@ -2,11 +2,12 @@ package com.boydti.fawe.database; import com.boydti.fawe.config.Config; import com.sk89q.worldedit.world.World; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + public class DBHandler { private final Logger log = LoggerFactory.getLogger(Config.class); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/database/RollbackDatabase.java b/worldedit-core/src/main/java/com/boydti/fawe/database/RollbackDatabase.java index fa8aefd59..a0219955c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/database/RollbackDatabase.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/database/RollbackDatabase.java @@ -9,6 +9,11 @@ import com.boydti.fawe.util.MainUtil; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; +import org.intellij.lang.annotations.Language; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; @@ -24,10 +29,6 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import java.util.stream.IntStream; -import org.intellij.lang.annotations.Language; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class RollbackDatabase extends AsyncNotifyQueue { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/JSON2NBT.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/JSON2NBT.java index edd082307..e5ff43e6e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/JSON2NBT.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/JSON2NBT.java @@ -14,6 +14,7 @@ import com.sk89q.jnbt.LongTag; import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; + import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/LevelDat.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/LevelDat.java index d4cd3329d..4ee85f8ae 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/LevelDat.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/LevelDat.java @@ -1,6 +1,5 @@ package com.boydti.fawe.jnbt.anvil; -import com.boydti.fawe.object.io.PGZIPOutputStream; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTOutputStream; @@ -9,7 +8,6 @@ import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.GZIPInputStream; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java index 57f16950a..c8666c2fe 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java @@ -31,7 +31,6 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream; -import javax.annotation.Nullable; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -42,6 +41,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.Future; +import javax.annotation.Nullable; public class MCAChunk implements IChunk { public final boolean[] hasSections = new boolean[16]; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java index f8ceb5f10..b496ce375 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java @@ -1,7 +1,5 @@ package com.boydti.fawe.jnbt.anvil; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.beta.implementation.IChunkExtent; @@ -19,6 +17,7 @@ import com.sk89q.worldedit.world.World; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream; + import java.io.BufferedInputStream; import java.io.File; import java.io.FileNotFoundException; @@ -39,6 +38,8 @@ import java.util.zip.Deflater; import java.util.zip.Inflater; import java.util.zip.InflaterInputStream; +import static org.slf4j.LoggerFactory.getLogger; + /** * Chunk format: http://minecraft.gamepedia.com/Chunk_format#Entity_format * e.g., `.Level.Entities.#` (Starts with a . as the root tag is unnamed) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java index 6046c5928..2ad54e577 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAWorld.java @@ -2,14 +2,12 @@ package com.boydti.fawe.jnbt.anvil; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.implementation.packet.ChunkPacket; -import com.google.common.base.Preconditions; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; @@ -20,9 +18,9 @@ import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import javax.annotation.Nullable; import java.io.File; import java.util.Set; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkArgument; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java b/worldedit-core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java index b8839d7f4..36e657ba1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java @@ -7,6 +7,7 @@ import com.boydti.fawe.object.changeset.SimpleChangeSetSummary; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; + import java.io.IOException; import java.io.OutputStream; import java.util.UUID; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweInputStream.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweInputStream.java index 5f9c2d11f..004370113 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweInputStream.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweInputStream.java @@ -3,6 +3,7 @@ package com.boydti.fawe.object; import com.boydti.fawe.util.IOUtil; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NamedTag; + import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweOutputStream.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweOutputStream.java index 12a1cd619..53f8f229d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweOutputStream.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweOutputStream.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object; import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.Tag; + import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java index 4ae2da1aa..cc7d1c3ed 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java @@ -1,7 +1,5 @@ package com.boydti.fawe.object; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.object.changeset.AbstractChangeSet; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; @@ -16,10 +14,13 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; + import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Stores changes to a {@link ChangeSet}. */ diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java index 07bffb59e..5d63474c3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java @@ -6,6 +6,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; + import java.util.Collections; import java.util.Iterator; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlendBall.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlendBall.java index 76460548d..cef6d9271 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlendBall.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlendBall.java @@ -7,6 +7,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; + import java.util.Arrays; public class BlendBall implements Brush { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java index ec7f995d6..5856d922b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java @@ -10,6 +10,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; + import java.util.concurrent.ThreadLocalRandom; public class BlobBrush implements Brush { @@ -74,10 +75,12 @@ public class BlobBrush implements Brush { MutableVector3 mutable = new MutableVector3(); double roughness = 1 - sphericity; for (int xr = -sizeInt; xr <= sizeInt; xr++) { - mutable.mutX(xr); for (int yr = -sizeInt; yr <= sizeInt; yr++) { - mutable.mutY(yr); for (int zr = -sizeInt; zr <= sizeInt; zr++) { + // pt == mutable as it's a MutableVector3 + // so it must be set each time + mutable.mutX(xr); + mutable.mutY(yr); mutable.mutZ(zr); Vector3 pt = transform.apply(mutable); int x = MathMan.roundInt(pt.getX()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BrushSettings.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BrushSettings.java index 7121d395f..c200a2cf3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BrushSettings.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/BrushSettings.java @@ -1,8 +1,5 @@ package com.boydti.fawe.object.brush; -import static com.boydti.fawe.object.brush.BrushSettings.SettingType.BRUSH; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.object.brush.scroll.Scroll; import com.boydti.fawe.object.extent.ResettableExtent; import com.sk89q.worldedit.command.tool.brush.Brush; @@ -11,12 +8,16 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.internal.expression.Expression; + import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import static com.boydti.fawe.object.brush.BrushSettings.SettingType.BRUSH; +import static com.google.common.base.Preconditions.checkNotNull; + public class BrushSettings { public enum SettingType { BRUSH, @@ -29,6 +30,7 @@ public class BrushSettings { SCROLL_ACTION, } + private static final Expression DEFAULT_SIZE = Expression.compile("1"); private final Map constructor = new ConcurrentHashMap<>(); @@ -48,65 +50,65 @@ public class BrushSettings { } // TODO: Ping @MattBDev to reimplement 2020-02-04 -// public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map settings) throws InputParseException { -// PlatformCommandManager manager = PlatformCommandManager.getInstance(); -// String constructor = (String) settings.get(SettingType.BRUSH.name()); -// if (constructor == null) { -// return new BrushSettings(); -// } -// BrushSettings bs = manager.parseCommand(constructor, player); -// bs.constructor.put(SettingType.BRUSH, constructor); -// if (settings.containsKey(SettingType.PERMISSIONS.name())) { -// bs.permissions.addAll((Collection) settings.get(SettingType.PERMISSIONS.name())); -// } -// if (settings.containsKey(SettingType.SIZE.name())) { -// try { -// bs.size = Expression.compile((String) settings.getOrDefault(SettingType.SIZE.name(), -1)); -// bs.size.optimize(); -// } catch (ExpressionException e) { -// throw new RuntimeException(e); -// } -// } -// -// ParserContext parserContext = new ParserContext(); -// parserContext.setActor(player); -// parserContext.setWorld(player.getWorld()); -// parserContext.setSession(session); -// -// if (settings.containsKey(SettingType.MASK.name())) { -// String maskArgs = (String) settings.get(SettingType.MASK.name()); -// Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext); -// bs.setMask(mask); -// bs.constructor.put(SettingType.MASK, maskArgs); -// } -// if (settings.containsKey(SettingType.SOURCE_MASK.name())) { -// String maskArgs = (String) settings.get(SettingType.SOURCE_MASK.name()); -// Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext); -// bs.setSourceMask(mask); -// bs.constructor.put(SettingType.SOURCE_MASK, maskArgs); -// } -// if (settings.containsKey(SettingType.TRANSFORM.name())) { -// String transformArgs = (String) settings.get(SettingType.TRANSFORM.name()); -// ResettableExtent extent = Fawe.get().getTransformParser().parseFromInput(transformArgs, parserContext); -// bs.setTransform(extent); -// bs.constructor.put(SettingType.TRANSFORM, transformArgs); -// } -// if (settings.containsKey(SettingType.FILL.name())) { -// String fillArgs = (String) settings.get(SettingType.FILL.name()); -// Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(fillArgs, parserContext); -// bs.setFill(pattern); -// bs.constructor.put(SettingType.FILL, fillArgs); -// } -// if (settings.containsKey(SettingType.SCROLL_ACTION.name())) { -// String actionArgs = (String) settings.get(SettingType.SCROLL_ACTION.name()); -// Scroll action = Scroll.fromArguments(tool, player, session, actionArgs, false); -// if (action != null) { -// bs.setScrollAction(action); -// bs.constructor.put(SettingType.SCROLL_ACTION, actionArgs); -// } -// } -// return bs; -// } + // public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map settings) throws InputParseException { + // PlatformCommandManager manager = PlatformCommandManager.getInstance(); + // String constructor = (String) settings.get(SettingType.BRUSH.name()); + // if (constructor == null) { + // return new BrushSettings(); + // } + // BrushSettings bs = manager.parseCommand(constructor, player); + // bs.constructor.put(SettingType.BRUSH, constructor); + // if (settings.containsKey(SettingType.PERMISSIONS.name())) { + // bs.permissions.addAll((Collection) settings.get(SettingType.PERMISSIONS.name())); + // } + // if (settings.containsKey(SettingType.SIZE.name())) { + // try { + // bs.size = Expression.compile((String) settings.getOrDefault(SettingType.SIZE.name(), -1)); + // bs.size.optimize(); + // } catch (ExpressionException e) { + // throw new RuntimeException(e); + // } + // } + // + // ParserContext parserContext = new ParserContext(); + // parserContext.setActor(player); + // parserContext.setWorld(player.getWorld()); + // parserContext.setSession(session); + // + // if (settings.containsKey(SettingType.MASK.name())) { + // String maskArgs = (String) settings.get(SettingType.MASK.name()); + // Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext); + // bs.setMask(mask); + // bs.constructor.put(SettingType.MASK, maskArgs); + // } + // if (settings.containsKey(SettingType.SOURCE_MASK.name())) { + // String maskArgs = (String) settings.get(SettingType.SOURCE_MASK.name()); + // Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext); + // bs.setSourceMask(mask); + // bs.constructor.put(SettingType.SOURCE_MASK, maskArgs); + // } + // if (settings.containsKey(SettingType.TRANSFORM.name())) { + // String transformArgs = (String) settings.get(SettingType.TRANSFORM.name()); + // ResettableExtent extent = Fawe.get().getTransformParser().parseFromInput(transformArgs, parserContext); + // bs.setTransform(extent); + // bs.constructor.put(SettingType.TRANSFORM, transformArgs); + // } + // if (settings.containsKey(SettingType.FILL.name())) { + // String fillArgs = (String) settings.get(SettingType.FILL.name()); + // Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(fillArgs, parserContext); + // bs.setFill(pattern); + // bs.constructor.put(SettingType.FILL, fillArgs); + // } + // if (settings.containsKey(SettingType.SCROLL_ACTION.name())) { + // String actionArgs = (String) settings.get(SettingType.SCROLL_ACTION.name()); + // Scroll action = Scroll.fromArguments(tool, player, session, actionArgs, false); + // if (action != null) { + // bs.setScrollAction(action); + // bs.constructor.put(SettingType.SCROLL_ACTION, actionArgs); + // } + // } + // return bs; + // } public BrushSettings setBrush(Brush brush) { Brush tmp = this.brush; @@ -148,25 +150,33 @@ public class BrushSettings { } public BrushSettings setMask(Mask mask) { - if (mask == null) constructor.remove(SettingType.MASK); + if (mask == null) { + constructor.remove(SettingType.MASK); + } this.mask = mask; return this; } public BrushSettings setSourceMask(Mask mask) { - if (mask == null) constructor.remove(SettingType.SOURCE_MASK); + if (mask == null) { + constructor.remove(SettingType.SOURCE_MASK); + } this.sourceMask = mask; return this; } public BrushSettings setTransform(ResettableExtent transform) { - if (transform == null) constructor.remove(SettingType.TRANSFORM); + if (transform == null) { + constructor.remove(SettingType.TRANSFORM); + } this.transform = transform; return this; } public BrushSettings setFill(Pattern pattern) { - if (pattern == null) constructor.remove(SettingType.FILL); + if (pattern == null) { + constructor.remove(SettingType.FILL); + } this.material = pattern; return this; } @@ -187,7 +197,9 @@ public class BrushSettings { } public BrushSettings setScrollAction(Scroll scrollAction) { - if (scrollAction == null) constructor.remove(SettingType.SCROLL_ACTION); + if (scrollAction == null) { + constructor.remove(SettingType.SCROLL_ACTION); + } this.scrollAction = scrollAction; return this; } @@ -245,7 +257,9 @@ public class BrushSettings { public boolean canUse(Actor actor) { Set perms = getPermissions(); for (String perm : perms) { - if (actor.hasPermission(perm)) return true; + if (actor.hasPermission(perm)) { + return true; + } } return perms.isEmpty(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CatenaryBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CatenaryBrush.java index 94247f503..85fc928e6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CatenaryBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CatenaryBrush.java @@ -11,6 +11,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; + import java.util.Arrays; import java.util.List; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CommandBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CommandBrush.java index 6ce0bf1b2..68908dc4b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CommandBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CommandBrush.java @@ -14,6 +14,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.util.Location; + import java.util.List; public class CommandBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java index 8a74f5f3d..97e59b4f6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/CopyPastaBrush.java @@ -25,6 +25,7 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; + import java.util.concurrent.ThreadLocalRandom; public class CopyPastaBrush implements Brush, ResettableTool { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ErodeBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ErodeBrush.java index bb1e932e2..05929172a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ErodeBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ErodeBrush.java @@ -14,6 +14,7 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; + import java.util.Arrays; public class ErodeBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/FlattenBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/FlattenBrush.java index 368f9ac30..de2cbc45a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/FlattenBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/FlattenBrush.java @@ -9,6 +9,7 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; + import java.io.InputStream; public class FlattenBrush extends HeightBrush { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java index 6aa41c3e6..8ac75c973 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/HeightBrush.java @@ -17,6 +17,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; + import java.io.IOException; import java.io.InputStream; import java.util.concurrent.ThreadLocalRandom; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java index d1c037745..78100c955 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java @@ -20,6 +20,7 @@ import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; + import java.awt.image.BufferedImage; import java.io.IOException; import java.util.Arrays; 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 d5165a0ad..48cb92e72 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 @@ -24,6 +24,7 @@ import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; + import java.io.IOException; import java.util.Iterator; import java.util.UUID; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java index 0701b305c..284be6fd6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java @@ -19,6 +19,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; + import java.util.Arrays; public class LayerBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/PopulateSchem.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/PopulateSchem.java index af49de9b4..a3a337aac 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/PopulateSchem.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/PopulateSchem.java @@ -11,6 +11,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.session.ClipboardHolder; + import java.util.List; public class PopulateSchem implements Brush { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RockBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RockBrush.java index 267fb66e4..32cf5ba18 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RockBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/RockBrush.java @@ -7,6 +7,7 @@ import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; + import java.util.concurrent.ThreadLocalRandom; public class RockBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterBrush.java index 89832d0c1..f8d33e8a7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterBrush.java @@ -10,13 +10,14 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.MaskUnion; +import com.sk89q.worldedit.function.mask.MaskIntersection; import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.BreadthFirstSearch; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; + import java.util.Arrays; import java.util.concurrent.ThreadLocalRandom; @@ -51,7 +52,7 @@ public class ScatterBrush implements Brush { final int distance = Math.min((int) size, this.distance); - RecursiveVisitor visitor = new RecursiveVisitor(new MaskUnion(radius, surface).withExtent(editSession), function -> true); + RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(radius, surface).withExtent(editSession), function -> true); visitor.visit(position); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); Operations.completeBlindly(visitor); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterCommand.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterCommand.java index 678b3fe13..ee45169ab 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterCommand.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ScatterCommand.java @@ -10,6 +10,7 @@ import com.sk89q.worldedit.extension.platform.PlatformCommandManager; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; + import java.util.List; public class ScatterCommand extends ScatterBrush { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java index fbd400de0..903d4f80e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ShatterBrush.java @@ -10,6 +10,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.BreadthFirstSearch; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; + import java.util.concurrent.ThreadLocalRandom; public class ShatterBrush extends ScatterBrush { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java index c95dd7d9e..16927212d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java @@ -11,6 +11,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.BreadthFirstSearch; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; + import java.util.Arrays; import java.util.concurrent.ThreadLocalRandom; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java index 77a77a2af..aa1151639 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplineBrush.java @@ -17,6 +17,7 @@ import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.interpolation.Node; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; + import java.util.ArrayList; import java.util.Collection; import java.util.List; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java index 5f215c4f1..281cada71 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java @@ -17,6 +17,7 @@ import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.util.Location; + import java.io.InputStream; import java.util.Arrays; import java.util.concurrent.ThreadLocalRandom; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSphereBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSphereBrush.java index ac4064d06..6a32c5d92 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSphereBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSphereBrush.java @@ -5,13 +5,14 @@ import com.boydti.fawe.object.mask.SurfaceMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.command.tool.brush.Brush; -import com.sk89q.worldedit.function.mask.MaskUnion; +import com.sk89q.worldedit.function.mask.MaskIntersection; 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.BreadthFirstSearch; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; + import java.util.Arrays; public class SurfaceSphereBrush implements Brush { @@ -20,7 +21,7 @@ public class SurfaceSphereBrush implements Brush { SurfaceMask surface = new SurfaceMask(editSession); final SolidBlockMask solid = new SolidBlockMask(editSession); final RadiusMask radius = new RadiusMask(0, (int) size); - RecursiveVisitor visitor = new RecursiveVisitor(new MaskUnion(surface, radius).withExtent(editSession), vector -> editSession.setBlock(vector, pattern)); + RecursiveVisitor visitor = new RecursiveVisitor(new MaskIntersection(surface, radius).withExtent(editSession), vector -> editSession.setBlock(vector, pattern)); visitor.visit(position); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); Operations.completeBlindly(visitor); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java index 621e2b80f..ddfb6cbf6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SurfaceSpline.java @@ -14,6 +14,7 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation; import com.sk89q.worldedit.math.interpolation.Node; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; + import java.util.ArrayList; import java.util.List; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java index 77bad8505..8e64eb64e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/HeightMap.java @@ -9,6 +9,7 @@ import com.sk89q.worldedit.math.convolution.HeightMapFilter; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; + import java.util.concurrent.ThreadLocalRandom; public interface HeightMap { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java index 7b2c2f4cd..81ac51f4c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/ScalableHeightMap.java @@ -7,6 +7,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockState; + import java.awt.image.BufferedImage; import java.awt.image.Raster; import java.io.IOException; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/Scroll.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/Scroll.java index 2d4eb14ad..17584f04f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/Scroll.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/Scroll.java @@ -11,6 +11,7 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; + import java.io.IOException; import java.util.Arrays; import java.util.List; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/ScrollClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/ScrollClipboard.java index 229a932f4..c048abac4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/ScrollClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/ScrollClipboard.java @@ -5,6 +5,7 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.command.tool.BrushTool; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.session.ClipboardHolder; + import java.util.List; public class ScrollClipboard extends Scroll { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/Spline.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/Spline.java index a43e4dfca..b7f2eafe4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/Spline.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/Spline.java @@ -8,6 +8,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.interpolation.Interpolation; + import java.util.ArrayList; import java.util.List; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/SweepBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/SweepBrush.java index 9e5c264e6..e2d05508f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/SweepBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/sweep/SweepBrush.java @@ -20,6 +20,7 @@ import com.sk89q.worldedit.math.interpolation.Node; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; + import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/ImmutableVirtualWorld.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/ImmutableVirtualWorld.java index 2344a118e..107b64212 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/ImmutableVirtualWorld.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/ImmutableVirtualWorld.java @@ -13,6 +13,7 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.weather.WeatherType; + import javax.annotation.Nullable; public abstract class ImmutableVirtualWorld implements VirtualWorld { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VirtualWorld.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VirtualWorld.java index 5e7fd3238..884afea68 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VirtualWorld.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VirtualWorld.java @@ -9,6 +9,7 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.SimpleWorld; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; + import java.io.Closeable; import java.io.IOException; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java index d6f32fb43..b3edc1cc4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java @@ -12,6 +12,7 @@ import com.sk89q.worldedit.world.biome.BiomeType; 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; public class VisualExtent extends AbstractDelegateExtent { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/CFIDrawer.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/CFIDrawer.java index 1078d838a..57715ea79 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/CFIDrawer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/CFIDrawer.java @@ -5,6 +5,7 @@ import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TextureUtil; import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockTypes; + import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.util.concurrent.ForkJoinPool; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java index b50bce169..2541698ee 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java @@ -1,7 +1,5 @@ package com.boydti.fawe.object.brush.visualization.cfi; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IBlocks; @@ -29,7 +27,10 @@ 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.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.entity.Player; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -45,7 +46,11 @@ import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.util.*; +import com.sk89q.worldedit.util.Identifiable; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.SideEffect; +import com.sk89q.worldedit.util.SideEffectSet; +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; @@ -55,6 +60,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; + import java.awt.image.BufferedImage; import java.io.File; import java.io.FileNotFoundException; @@ -69,6 +75,8 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.function.Supplier; import javax.annotation.Nullable; +import static org.slf4j.LoggerFactory.getLogger; + public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/MCAWriter.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/MCAWriter.java index 7cfb83bf6..ce5c98868 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/MCAWriter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/MCAWriter.java @@ -7,6 +7,7 @@ import com.boydti.fawe.util.MainUtil; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.world.block.BlockID; import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream; + import java.io.File; import java.io.IOException; import java.util.Arrays; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/CFIChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/CFIChange.java index 7b263ef50..9c791fffa 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/CFIChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/CFIChange.java @@ -1,16 +1,17 @@ package com.boydti.fawe.object.change; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.util.ExtentTraverser; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.change.Change; + import java.io.File; import java.io.IOException; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; + public class CFIChange implements Change { private final File file; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java index 49f1a48f5..9df641143 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java @@ -1,7 +1,5 @@ package com.boydti.fawe.object.change; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.util.MathMan; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.DoubleTag; @@ -15,10 +13,13 @@ import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; + import java.util.List; import java.util.Map; import java.util.UUID; +import static org.slf4j.LoggerFactory.getLogger; + public class MutableEntityChange implements Change { public CompoundTag tag; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/StreamChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/StreamChange.java index 9a760cac0..015bab727 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/StreamChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/StreamChange.java @@ -2,14 +2,15 @@ package com.boydti.fawe.object.change; import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweOutputStream; +import net.jpountz.lz4.LZ4BlockInputStream; +import net.jpountz.lz4.LZ4BlockOutputStream; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import net.jpountz.lz4.LZ4BlockInputStream; -import net.jpountz.lz4.LZ4BlockOutputStream; public interface StreamChange { public void flushChanges(FaweOutputStream out) throws IOException; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java index ad5f0ca79..89827082f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java @@ -1,9 +1,6 @@ package com.boydti.fawe.object.changeset; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.Fawe; -import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; @@ -32,7 +29,6 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockState; -import java.io.Closeable; import java.io.IOException; import java.util.Iterator; import java.util.Map; @@ -41,6 +37,8 @@ import java.util.UUID; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicInteger; +import static org.slf4j.LoggerFactory.getLogger; + public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { private final World world; @@ -48,7 +46,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { protected AtomicInteger waitingAsync = new AtomicInteger(0); protected boolean closed; - + public AbstractChangeSet(World world) { this.world = world; } @@ -58,7 +56,9 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { } public void closeAsync() { - if (closed) return; + if (closed) { + return; + } closed = true; waitingAsync.incrementAndGet(); TaskManager.IMP.async(() -> { @@ -157,7 +157,9 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { } } for (int layer = 0; layer < 16; layer++) { - if (!set.hasSection(layer)) continue; + if (!set.hasSection(layer)) { + continue; + } // add each block and tile char[] blocksGet = get.load(layer); if (blocksGet == null) { @@ -223,7 +225,9 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { } public EditSession toEditSession(Player player, Region[] regions) { - EditSessionBuilder builder = new EditSessionBuilder(getWorld()).player(player).autoQueue(false).fastmode(false).checkMemory(false).changeSet(this).limitUnlimited(); + EditSessionBuilder builder = + new EditSessionBuilder(getWorld()).player(player).autoQueue(false).fastmode(false) + .checkMemory(false).changeSet(this).limitUnlimited(); if (regions != null) { builder.allowedRegions(regions); } else { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java index 4a24e600b..39220f70e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java @@ -7,16 +7,12 @@ import com.boydti.fawe.object.change.CFIChange; import com.boydti.fawe.util.MainUtil; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.history.change.Change; -import com.sk89q.worldedit.history.changeset.ChangeSetSummary; -import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.biome.BiomeType; -import com.sk89q.worldedit.world.block.BlockState; import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.Iterator; -import java.util.Map; import java.util.UUID; public class CFIChangeSet extends AbstractChangeSet { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java index 2a3385e17..4da062af4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java @@ -19,11 +19,11 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; + import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.NoSuchElementException; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java index 592285128..bc5e52823 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java @@ -15,13 +15,13 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import javax.annotation.Nullable; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; public class CPUOptimizedClipboard extends LinearClipboard { 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 fbfcb24ae..923fa2056 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 @@ -21,6 +21,9 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.Closeable; import java.io.DataInputStream; import java.io.File; @@ -42,8 +45,6 @@ import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * A clipboard with disk backed storage. (lower memory + loads on crash) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LazyClipboardHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LazyClipboardHolder.java index e7b9522c7..9542f5fc3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LazyClipboardHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LazyClipboardHolder.java @@ -5,6 +5,7 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; + import java.io.InputStream; import java.net.URI; import java.util.UUID; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LinearClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LinearClipboard.java index ae421e139..962a73695 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LinearClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LinearClipboard.java @@ -14,11 +14,12 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.UUID; -import org.jetbrains.annotations.NotNull; /** * Best used when clipboard selections are small, or using legacy formats 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 f169e3fe4..72a34748d 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 @@ -20,6 +20,7 @@ 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 java.io.IOException; import java.util.ArrayList; import java.util.Collection; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MultiClipboardHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MultiClipboardHolder.java index 6a1345c50..c0d0a3ef9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MultiClipboardHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MultiClipboardHolder.java @@ -1,10 +1,8 @@ package com.boydti.fawe.object.clipboard; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.session.ClipboardHolder; + import java.net.URI; import java.util.ArrayList; import java.util.HashSet; @@ -13,6 +11,8 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; +import static com.google.common.base.Preconditions.checkNotNull; + public class MultiClipboardHolder extends URIClipboardHolder { private final List holders; private Clipboard[] cached; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java index b5bbaba4c..e7886a8f5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java @@ -12,6 +12,7 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; + import java.util.List; import java.util.function.Supplier; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java index 3f9480f72..1806ebced 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ResizableClipboardBuilder.java @@ -11,6 +11,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; + import java.util.Iterator; public class ResizableClipboardBuilder extends MemoryOptimizedHistory { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/URIClipboardHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/URIClipboardHolder.java index c583565b1..5b324a52b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/URIClipboardHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/URIClipboardHolder.java @@ -1,13 +1,14 @@ package com.boydti.fawe.object.clipboard; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.session.ClipboardHolder; + import java.net.URI; import java.util.Collections; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + public class URIClipboardHolder extends ClipboardHolder { private final URI uri; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java index 7f6912b10..4770b3af8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/WorldCopyClipboard.java @@ -6,6 +6,7 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; + import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedMap.java index 87c9a247a..c0d6d56af 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedMap.java @@ -67,7 +67,9 @@ public class AdaptedMap implements IAdaptedMap { @NotNull @Override public Set> entrySet() { - if (isEmpty()) return Collections.emptySet(); + if (isEmpty()) { + return Collections.emptySet(); + } return new AdaptedSetCollection<>(getParent().entrySet(), new com.google.common.base.Function, Entry>() { private AdaptedPair entry = new AdaptedPair(); @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedSetCollection.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedSetCollection.java index d51dbd921..f055d5a0d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedSetCollection.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/AdaptedSetCollection.java @@ -2,6 +2,8 @@ package com.boydti.fawe.object.collection; import com.google.common.base.Function; import com.google.common.collect.Collections2; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.Iterator; import java.util.Set; @@ -9,13 +11,10 @@ import java.util.Spliterator; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Stream; -import org.jetbrains.annotations.NotNull; /** - * Adapt a collection to a set - * (It's assumed that the collection is set like, otherwise behavior will be weird) - * - * @param + * Adapt a collection to a set. + * @apiNote It's assumed that the collection is set like, otherwise behavior will be weird */ public class AdaptedSetCollection implements Set { private final Collection adapted; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockSet.java index 42c3e1588..53c2f7ea6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockSet.java @@ -4,6 +4,7 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.RegionOperationException; + import java.util.Iterator; import java.util.Set; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVector3ChunkMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVector3ChunkMap.java index b3bca51d4..eac9ebbff 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVector3ChunkMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVector3ChunkMap.java @@ -4,6 +4,7 @@ import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap; + import java.util.Map; public class BlockVector3ChunkMap implements IAdaptedMap { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java index 74dc46802..60c82b697 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/BlockVectorSet.java @@ -3,13 +3,18 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; - import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectIterator; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.AbstractCollection; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; /** * The BlockVectorSet is a Memory optimized Set for storing BlockVectors diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialArray.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialArray.java index 47ea5c752..0010823f9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialArray.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialArray.java @@ -1,16 +1,17 @@ package com.boydti.fawe.object.collection; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.io.serialize.Serialize; import com.boydti.fawe.util.MainUtil; + import java.io.IOException; import java.lang.reflect.Array; import java.util.Arrays; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Records changes made through the {@link #setByte(int, byte)} or {@link #setInt(int, int)} method
* If you are editing the raw data, use {@link #record(Runnable)} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialBlockBuffer.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialBlockBuffer.java index ce6efa400..59b1d8a50 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialBlockBuffer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/DifferentialBlockBuffer.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweOutputStream; + import java.io.IOException; import java.lang.reflect.Array; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/FastRandomCollection.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/FastRandomCollection.java index 3ca33a53a..41ac563cf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/FastRandomCollection.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/FastRandomCollection.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.object.random.SimpleRandom; import com.boydti.fawe.util.MathMan; + import java.util.ArrayList; import java.util.Map; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/IAdaptedMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/IAdaptedMap.java index 73646b6c8..18aa4d1c9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/IAdaptedMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/IAdaptedMap.java @@ -4,7 +4,6 @@ import com.google.common.base.Function; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.AbstractMap; import java.util.Collection; import java.util.Collections; import java.util.Map; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java index dddf6d5d4..3d7994ef9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/MemBlockSet.java @@ -5,11 +5,12 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector3; +import org.jetbrains.annotations.NotNull; + import java.util.AbstractSet; import java.util.Arrays; import java.util.Iterator; import java.util.Set; -import org.jetbrains.annotations.NotNull; /** * Memory optimized BlockVector3 Set using a sparsely populated bitset and grouped by chunk section diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/ObjObjMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/ObjObjMap.java index ac9c085c3..21a3f8d87 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/ObjObjMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/ObjObjMap.java @@ -1,10 +1,10 @@ package com.boydti.fawe.object.collection; -import static it.unimi.dsi.fastutil.HashCommon.arraySize; - import java.util.Arrays; import javax.annotation.Nonnull; +import static it.unimi.dsi.fastutil.HashCommon.arraySize; + public class ObjObjMap { private static final Object FREE_KEY = new Object(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/RandomCollection.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/RandomCollection.java index 550c82c24..fc12c1ac6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/RandomCollection.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/RandomCollection.java @@ -1,8 +1,8 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.object.random.SimpleRandom; -import java.util.Map; +import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SimpleRandomCollection.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SimpleRandomCollection.java index aaa450f49..e99593c0f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SimpleRandomCollection.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SimpleRandomCollection.java @@ -1,6 +1,7 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.object.random.SimpleRandom; + import java.util.Map; import java.util.NavigableMap; import java.util.TreeMap; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SoftHashMap.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SoftHashMap.java index 7a17bb076..1ac228a98 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SoftHashMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SoftHashMap.java @@ -1,5 +1,7 @@ package com.boydti.fawe.object.collection; +import org.jetbrains.annotations.NotNull; + import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.util.ArrayList; @@ -13,7 +15,6 @@ import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.locks.ReentrantLock; -import org.jetbrains.annotations.NotNull; /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SummedColorTable.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SummedColorTable.java index f5664998a..95b51dd4e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SummedColorTable.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SummedColorTable.java @@ -1,6 +1,7 @@ package com.boydti.fawe.object.collection; import com.boydti.fawe.util.MathMan; + import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; @@ -222,4 +223,4 @@ public class SummedColorTable { return curr + leftSum + topSum - topLeftSum; } } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/exception/FaweException.java b/worldedit-core/src/main/java/com/boydti/fawe/object/exception/FaweException.java index 2c9b2d728..930862283 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/exception/FaweException.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/exception/FaweException.java @@ -3,7 +3,6 @@ package com.boydti.fawe.object.exception; import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; -import com.sk89q.worldedit.extent.Extent; import java.util.Locale; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ExtentHeightCacher.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ExtentHeightCacher.java index f4d871c68..560e9f841 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ExtentHeightCacher.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ExtentHeightCacher.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.PassthroughExtent; + import java.util.Arrays; public class ExtentHeightCacher extends PassthroughExtent { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java index a6b494cde..bc391e957 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FaweRegionExtent.java @@ -18,6 +18,7 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; + import java.util.Collection; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/HeightBoundExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/HeightBoundExtent.java index 888b7a923..624113cdd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/HeightBoundExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/HeightBoundExtent.java @@ -7,6 +7,7 @@ import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.RegionWrapper; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.regions.Region; + import java.util.Collection; import java.util.Collections; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiRegionExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiRegionExtent.java index a36cea3f9..21851ff8b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiRegionExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiRegionExtent.java @@ -7,6 +7,7 @@ import com.boydti.fawe.object.FaweLimit; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionIntersection; + import java.util.Arrays; import java.util.Collection; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiTransform.java index f09c895ae..1f6a36ff2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiTransform.java @@ -9,6 +9,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; + import java.util.Collection; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java index 0f5fa61f6..d74238c0b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java @@ -5,10 +5,9 @@ import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.util.formatting.text.Component; import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.exception.FaweException; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; @@ -26,6 +25,7 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.BaseBlock; @@ -33,6 +33,7 @@ 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 java.util.Collection; import java.util.Collections; import java.util.List; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java index 4a4963adb..79b5ec745 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/PositionTransformExtent.java @@ -1,8 +1,6 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; @@ -10,6 +8,8 @@ import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; public class PositionTransformExtent extends ResettableExtent { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java index e9c578664..ce11bb8da 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java @@ -7,6 +7,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; + import java.util.SplittableRandom; public class RandomOffsetTransform extends ResettableExtent { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomTransform.java index 08e7d4950..35823f090 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomTransform.java @@ -1,17 +1,18 @@ package com.boydti.fawe.object.extent; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.object.collection.RandomCollection; import com.boydti.fawe.object.random.SimpleRandom; import com.boydti.fawe.object.random.TrueRandom; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; + import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Uses a random pattern of a weighted list of patterns. */ diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ResettableExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ResettableExtent.java index c5275ea80..86056b88f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ResettableExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ResettableExtent.java @@ -1,18 +1,19 @@ package com.boydti.fawe.object.extent; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; + import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Field; +import static com.google.common.base.Preconditions.checkNotNull; + public class ResettableExtent extends AbstractDelegateExtent implements Serializable { public ResettableExtent(Extent parent) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java index 76129bc48..2512f3b55 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java @@ -10,6 +10,7 @@ import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; + import javax.annotation.Nullable; public class ScaleTransform extends ResettableExtent { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SelectTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SelectTransform.java index 108083a1f..0a7f0937a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SelectTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SelectTransform.java @@ -11,6 +11,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; + import javax.annotation.Nullable; public abstract class SelectTransform extends ResettableExtent { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SlowExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SlowExtent.java index 8defb4884..a09051f2f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SlowExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SlowExtent.java @@ -2,12 +2,8 @@ package com.boydti.fawe.object.extent; import com.boydti.fawe.Fawe; import com.sk89q.worldedit.WorldEditException; - -import com.sk89q.worldedit.extent.PassthroughExtent; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; public class SlowExtent extends AbstractDelegateExtent { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java index bd953778c..0e2558247 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SourceMaskExtent.java @@ -1,7 +1,5 @@ package com.boydti.fawe.object.extent; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; @@ -9,6 +7,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; +import static com.google.common.base.Preconditions.checkNotNull; + public class SourceMaskExtent extends TemporalExtent { private Mask mask; private Extent get; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/StripNBTExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/StripNBTExtent.java index 7d112d666..c46e663e0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/StripNBTExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/StripNBTExtent.java @@ -12,6 +12,7 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.NbtValued; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; + import java.util.Map; import java.util.Set; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/SimpleBlockCopy.java b/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/SimpleBlockCopy.java index 261303402..9f3e40af5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/SimpleBlockCopy.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/function/block/SimpleBlockCopy.java @@ -4,7 +4,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BaseBlock; public class SimpleBlockCopy implements RegionFunction { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/io/LittleEndianOutputStream.java b/worldedit-core/src/main/java/com/boydti/fawe/object/io/LittleEndianOutputStream.java index 7c46fdbf4..4f2115e5e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/io/LittleEndianOutputStream.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/io/LittleEndianOutputStream.java @@ -1,11 +1,12 @@ package com.boydti.fawe.object.io; +import org.jetbrains.annotations.NotNull; + import java.io.DataOutput; import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.UTFDataFormatException; -import org.jetbrains.annotations.NotNull; public class LittleEndianOutputStream extends FilterOutputStream implements DataOutput { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/io/zstd/ZstdInputStream.java b/worldedit-core/src/main/java/com/boydti/fawe/object/io/zstd/ZstdInputStream.java index 18a9d9aac..777fb730d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/io/zstd/ZstdInputStream.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/io/zstd/ZstdInputStream.java @@ -1,6 +1,7 @@ package com.github.luben.zstd; import com.github.luben.zstd.util.Native; + import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; @@ -9,8 +10,9 @@ import java.io.InputStream; * InputStream filter that decompresses the data provided * by the underlying InputStream using Zstd compression. * + *

* It does not support mark/reset methods - * + *

*/ public class ZstdInputStream extends FilterInputStream { @@ -33,11 +35,16 @@ public class ZstdInputStream extends FilterInputStream { /* JNI methods */ private static native long recommendedDInSize(); + private static native long recommendedDOutSize(); + private static native long createDStream(); - private static native int freeDStream(long stream); - private native int initDStream(long stream); - private native int decompressStream(long stream, byte[] dst, int dst_size, byte[] src, int src_size); + + private static native int freeDStream(long stream); + + private native int initDStream(long stream); + + private native int decompressStream(long stream, byte[] dst, int dst_size, byte[] src, int src_size); // The main constructor / legacy version dispatcher public ZstdInputStream(InputStream inStream) throws IOException { @@ -54,10 +61,11 @@ public class ZstdInputStream extends FilterInputStream { } /** - * Don't break on unfinished frames + * Don't break on unfinished frames. * - * Use case: decompressing files that are not - * yet finished writing and compressing + *

+ * Use case: decompressing files that are not yet finished writing and compressing. + *

*/ public ZstdInputStream setContinuous(boolean b) { isContinuous = b; @@ -76,8 +84,9 @@ public class ZstdInputStream extends FilterInputStream { // guard against buffer overflows if (offset < 0 || len > dst.length - offset) { - throw new IndexOutOfBoundsException("Requested length " + len - + " from offset " + offset + " in buffer of size " + dst.length); + throw new IndexOutOfBoundsException( + "Requested length " + len + " from offset " + offset + " in buffer of size " + + dst.length); } int dstSize = offset + len; dstPos = offset; @@ -91,7 +100,7 @@ public class ZstdInputStream extends FilterInputStream { if (frameFinished) { return -1; } else if (isContinuous) { - return (int)(dstPos - offset); + return (int) (dstPos - offset); } else { throw new IOException("Read error or truncated source"); } @@ -113,7 +122,7 @@ public class ZstdInputStream extends FilterInputStream { if (Zstd.isError(size)) { throw new IOException("Decompression error: " + Zstd.getErrorName(size)); } - return (int)(dstPos - offset); + return (int) (dstPos - offset); } } return len; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java index 0f0ea9698..8669fd33f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentAnyMask.java @@ -3,12 +3,11 @@ package com.boydti.fawe.object.mask; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractMask; -import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; /** - * Just an optimized version of the Adjacent Mask for single adjacency + * Just an optimized version of the Adjacent Mask for single adjacency. */ public class AdjacentAnyMask extends AbstractMask implements ResettableMask { @@ -40,15 +39,15 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask { int z = v.getBlockZ(); if (mask.test(extent, x + 1, y, z)) { return mutable.setComponents(1, 0, 0); - }else if (mask.test(extent, x - 1, y, z)) { + } else if (mask.test(extent, x - 1, y, z)) { return mutable.setComponents(-1, 0, 0); - }else if (mask.test(extent, x, y, z + 1)) { + } else if (mask.test(extent, x, y, z + 1)) { return mutable.setComponents(0, 0, 1); - }else if (mask.test(extent, x, y, z - 1)) { + } else if (mask.test(extent, x, y, z - 1)) { return mutable.setComponents(0, 0, -1); - }else if (y < 256 && mask.test(extent, x, y + 1, z)) { + } else if (y < 256 && mask.test(extent, x, y + 1, z)) { return mutable.setComponents(0, 1, 0); - }else if (y > 0 && mask.test(extent, x, y - 1, z)) { + } else if (y > 0 && mask.test(extent, x, y - 1, z)) { return mutable.setComponents(0, -1, 0); } else { return null; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java index c3a21bb38..bc7c70c4d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AdjacentMask.java @@ -7,57 +7,58 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; public class AdjacentMask extends AbstractMask { - private final int min, max; + private final int min; + private final int max; private final Mask mask; - private MutableBlockVector3 v; + private MutableBlockVector3 vector; public AdjacentMask(Mask mask, int requiredMin, int requiredMax) { this.mask = mask; this.min = requiredMin; this.max = requiredMax; - this.v = new MutableBlockVector3(); + this.vector = new MutableBlockVector3(); } @Override public boolean test(Extent extent, BlockVector3 bv) { - v.setComponents(bv); - int count = 0; + vector.setComponents(bv); double x = bv.getX(); double y = bv.getY(); double z = bv.getZ(); - v.mutX(x + 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { - v.mutX(x); + vector.mutX(x + 1); + int count = 0; + if (mask.test(extent, vector) && ++count == min && max >= 8) { + vector.mutX(x); return true; } - v.mutX(x - 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { - v.mutX(x); + vector.mutX(x - 1); + if (mask.test(extent, vector) && ++count == min && max >= 8) { + vector.mutX(x); return true; } - v.mutX(x); - v.mutY(y + 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { - v.mutY(y); + vector.mutX(x); + vector.mutY(y + 1); + if (mask.test(extent, vector) && ++count == min && max >= 8) { + vector.mutY(y); return true; } - v.mutY(y - 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { - v.mutY(y); + vector.mutY(y - 1); + if (mask.test(extent, vector) && ++count == min && max >= 8) { + vector.mutY(y); return true; } - v.mutY(y); - v.mutZ(z + 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { - v.mutZ(z); + vector.mutY(y); + vector.mutZ(z + 1); + if (mask.test(extent, vector) && ++count == min && max >= 8) { + vector.mutZ(z); return true; } - v.mutZ(z - 1); - if (mask.test(extent, v) && ++count == min && max >= 8) { - v.mutZ(z); + vector.mutZ(z - 1); + if (mask.test(extent, vector) && ++count == min && max >= 8) { + vector.mutZ(z); return true; } - v.mutZ(z); + vector.mutZ(z); return count >= min && count <= max; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java index 8d619c092..5789190a8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/AngleMask.java @@ -4,6 +4,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; + import java.util.Arrays; public class AngleMask extends SolidBlockMask implements ResettableMask { @@ -58,7 +59,7 @@ public class AngleMask extends SolidBlockMask implements ResettableMask { protected transient boolean lastValue; public int getHeight(Extent extent, int x, int y, int z) { -// return extent.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY); + // return extent.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY); try { int rx = x - cacheBotX + 16; int rz = z - cacheBotZ + 16; @@ -92,19 +93,33 @@ public class AngleMask extends SolidBlockMask implements ResettableMask { double slope; boolean aboveMin; lastY = y; - slope = Math.abs(getHeight(extent, x + distance, y, z) - getHeight(extent, x -distance, y, z)) * ADJACENT_MOD; + slope = + Math.abs(getHeight(extent, x + distance, y, z) - getHeight(extent, x - distance, y, z)) + * ADJACENT_MOD; if (checkFirst) { if (slope >= min) { return lastValue = true; } - slope = Math.max(slope, Math.abs(getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance)) * ADJACENT_MOD); - slope = Math.max(slope, Math.abs(getHeight(extent, x + distance, y, z + distance) - getHeight(extent, x - distance, y, z - distance)) * DIAGONAL_MOD); - slope = Math.max(slope, Math.abs(getHeight(extent, x - distance, y, z + distance) - getHeight(extent, x + distance, y, z - distance)) * DIAGONAL_MOD); + slope = Math.max(slope, Math.abs( + getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance)) + * ADJACENT_MOD); + slope = Math.max(slope, Math.abs( + getHeight(extent, x + distance, y, z + distance) - getHeight(extent, + x - distance, y, z - distance)) * DIAGONAL_MOD); + slope = Math.max(slope, Math.abs( + getHeight(extent, x - distance, y, z + distance) - getHeight(extent, + x + distance, y, z - distance)) * DIAGONAL_MOD); return lastValue = (slope >= min); } else { - slope = Math.max(slope, Math.abs(getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance)) * ADJACENT_MOD); - slope = Math.max(slope, Math.abs(getHeight(extent, x + distance, y, z + distance) - getHeight(extent, x - distance, y, z - distance)) * DIAGONAL_MOD); - slope = Math.max(slope, Math.abs(getHeight(extent, x - distance, y, z + distance) - getHeight(extent, x + distance, y, z - distance)) * DIAGONAL_MOD); + slope = Math.max(slope, Math.abs( + getHeight(extent, x, y, z + distance) - getHeight(extent, x, y, z - distance)) + * ADJACENT_MOD); + slope = Math.max(slope, Math.abs( + getHeight(extent, x + distance, y, z + distance) - getHeight(extent, + x - distance, y, z - distance)) * DIAGONAL_MOD); + slope = Math.max(slope, Math.abs( + getHeight(extent, x - distance, y, z + distance) - getHeight(extent, + x + distance, y, z - distance)) * DIAGONAL_MOD); return lastValue = (slope >= min && slope <= max); } } @@ -142,14 +157,18 @@ public class AngleMask extends SolidBlockMask implements ResettableMask { if ((lastX == (lastX = x) & lastZ == (lastZ = z))) { int height = getHeight(extent, x, y, z); - if (y <= height) return overlay ? (lastValue && y == height) : lastValue; + if (y <= height) { + return overlay ? (lastValue && y == height) : lastValue; + } } if (!mask.test(extent, x, y, z)) { return false; } if (overlay) { - if (y < 255 && !mask.test(extent, x, y + 1, z)) return lastValue = false; + if (y < 255 && !mask.test(extent, x, y + 1, z)) { + return lastValue = false; + } } else if (!adjacentAir(extent, vector)) { return false; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RandomMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RandomMask.java index fa0992a30..2b835700d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RandomMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/RandomMask.java @@ -3,6 +3,7 @@ package com.boydti.fawe.object.mask; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.math.BlockVector3; + import java.util.SplittableRandom; public class RandomMask extends AbstractMask implements ResettableMask { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SurfaceMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SurfaceMask.java index de5e901c5..3413e6878 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SurfaceMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/SurfaceMask.java @@ -3,7 +3,6 @@ package com.boydti.fawe.object.mask; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.BlockMaskBuilder; -import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockTypes; @@ -23,4 +22,4 @@ public class SurfaceMask extends AdjacentAnyMask { public boolean test(Extent extent, BlockVector3 v) { return !getParentMask().test(extent, v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(extent, v); } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AbstractExtentPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AbstractExtentPattern.java index 1990bb18d..5b6007783 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AbstractExtentPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AbstractExtentPattern.java @@ -1,10 +1,10 @@ package com.boydti.fawe.object.pattern; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; +import static com.google.common.base.Preconditions.checkNotNull; + public abstract class AbstractExtentPattern extends AbstractPattern { private final transient Extent extent; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java index 485f18845..223a683f7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java @@ -19,7 +19,9 @@ public class AngleColorPattern extends DataAnglePattern { } public int getColor(int color, int slope) { - if (slope == 0) return color; + if (slope == 0) { + return color; + } double newFactor = (1 - Math.min(1, slope * factor)); int newRed = (int) (((color >> 16) & 0xFF) * newFactor); int newGreen = (int) (((color >> 8) & 0xFF) * newFactor); @@ -31,9 +33,13 @@ public class AngleColorPattern extends DataAnglePattern { public BaseBlock apply(BlockVector3 position) { BaseBlock block = extent.getFullBlock(position); int slope = getSlope(block, position, extent); - if (slope == -1) return block; + if (slope == -1) { + return block; + } int color = holder.getTextureUtil().getColor(block.getBlockType()); - if (color == 0) return block; + if (color == 0) { + return block; + } int newColor = getColor(color, slope); return holder.getTextureUtil().getNearestBlock(newColor).getDefaultState().toBaseBlock(); } @@ -60,12 +66,18 @@ public class AngleColorPattern extends DataAnglePattern { public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { BlockState block = get.getBlock(extent); int slope = getSlope(block, get, extent); - if (slope == -1) return false; + if (slope == -1) { + return false; + } int color = holder.getTextureUtil().getColor(block.getBlockType()); - if (color == 0) return false; + if (color == 0) { + return false; + } int newColor = getColor(color, slope); BlockType newBlock = holder.getTextureUtil().getNearestBlock(newColor); - if (newBlock == null) return false; + if (newBlock == null) { + return false; + } return set.setBlock(extent, newBlock.getDefaultState()); } } 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 c6ef74ef2..6ef3b1a7f 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 @@ -7,6 +7,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockType; + import java.awt.Color; public class AverageColorPattern extends AbstractExtentPattern { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java index ff9353d48..0c5d72078 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java @@ -10,6 +10,7 @@ import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; + import java.util.UUID; public class BufferedPattern extends AbstractPattern implements ResettablePattern { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java index 01f2d2b34..7eb167c29 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java @@ -1,7 +1,5 @@ package com.boydti.fawe.object.pattern; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.Pattern; @@ -9,6 +7,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; +import static com.google.common.base.Preconditions.checkNotNull; + public class DataPattern extends AbstractExtentPattern { private final Pattern pattern; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java index ee1e054ce..d8e967ad7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java @@ -1,7 +1,5 @@ package com.boydti.fawe.object.pattern; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.internal.expression.Expression; @@ -12,6 +10,8 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A mask that evaluates an expression. *

diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdPattern.java index 1ccac933b..969d3f097 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdPattern.java @@ -1,12 +1,12 @@ package com.boydti.fawe.object.pattern; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; +import static com.google.common.base.Preconditions.checkNotNull; + public class IdPattern extends AbstractExtentPattern { private final Pattern pattern; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternTraverser.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternTraverser.java index 833829536..ed0235ac7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternTraverser.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternTraverser.java @@ -1,9 +1,9 @@ package com.boydti.fawe.object.pattern; import com.boydti.fawe.Resettable; -import com.boydti.fawe.object.mask.ResettableMask; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.Pattern; + import java.lang.reflect.Field; import java.util.Collection; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java index 049311906..0c79b8d1f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java @@ -1,7 +1,5 @@ package com.boydti.fawe.object.pattern; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -13,9 +11,12 @@ import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.block.BaseBlock; + import java.util.List; import java.util.concurrent.ThreadLocalRandom; +import static com.google.common.base.Preconditions.checkNotNull; + public class RandomFullClipboardPattern extends AbstractPattern { private final Extent extent; private final MutableBlockVector3 mutable = new MutableBlockVector3(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java index 862a4cf02..29081cf48 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java @@ -7,6 +7,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; + import java.util.SplittableRandom; public class RandomOffsetPattern extends AbstractPattern { 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 19975c2fd..244c1b46b 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 @@ -8,6 +8,7 @@ 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.awt.Color; public class SaturatePattern extends AbstractPattern { 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 43ba6bb83..32bdb748e 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 @@ -1,7 +1,5 @@ package com.boydti.fawe.object.pattern; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.util.TextureUtil; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; @@ -10,6 +8,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockType; +import static com.google.common.base.Preconditions.checkNotNull; + public class ShadePattern extends AbstractPattern { private final TextureUtil util; private final Extent extent; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java index f9f357a64..58da0899f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java @@ -6,6 +6,7 @@ import com.sk89q.worldedit.function.visitor.BreadthFirstSearch; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; + import java.util.concurrent.ThreadLocalRandom; public class SurfaceRandomOffsetPattern extends AbstractPattern { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/progress/DefaultProgressTracker.java b/worldedit-core/src/main/java/com/boydti/fawe/object/progress/DefaultProgressTracker.java index 37618e599..90e605c30 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/progress/DefaultProgressTracker.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/progress/DefaultProgressTracker.java @@ -1,14 +1,14 @@ package com.boydti.fawe.object.progress; import com.boydti.fawe.config.Caption; -import com.sk89q.worldedit.util.formatting.text.Component; -import com.sk89q.worldedit.util.formatting.text.TextComponent; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.TaskManager; - import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; + import java.util.function.BiConsumer; /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java index ff1ad748a..1d0bd4d6b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/FuzzyRegion.java @@ -10,9 +10,10 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.world.World; -import java.util.Iterator; import org.jetbrains.annotations.NotNull; +import java.util.Iterator; + public class FuzzyRegion extends AbstractRegion { private final Mask mask; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java index 714d37b1c..c3cf62ce4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/PolyhedralRegion.java @@ -19,14 +19,13 @@ package com.boydti.fawe.object.regions; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.regions.polyhedron.Edge; import com.sk89q.worldedit.world.World; + import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -35,6 +34,8 @@ import java.util.List; import java.util.Set; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + public class PolyhedralRegion extends AbstractRegion { /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java index b9a348126..eeb42bd9d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/FuzzyRegionSelector.java @@ -17,6 +17,7 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; import com.sk89q.worldedit.world.World; + import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java index 6c94049c3..7b154726f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/regions/selector/PolyhedralRegionSelector.java @@ -19,8 +19,6 @@ package com.boydti.fawe.object.regions.selector; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.object.regions.PolyhedralRegion; import com.boydti.fawe.object.regions.Triangle; import com.sk89q.worldedit.IncompleteRegionException; @@ -35,6 +33,7 @@ import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.World; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -43,6 +42,8 @@ import java.util.Map; import java.util.Optional; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Creates a {@code PolyhedralRegion} from a user's selections. */ diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java index 065c653ef..bfe0acb6a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java @@ -1,7 +1,5 @@ package com.boydti.fawe.object.schematic; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.FaweCache; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; @@ -31,6 +29,8 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.storage.NBTConversions; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; +import org.jetbrains.annotations.NotNull; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -38,7 +38,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; -import org.jetbrains.annotations.NotNull; + +import static org.slf4j.LoggerFactory.getLogger; public class MinecraftStructure implements ClipboardReader, ClipboardWriter { private static final int WARN_SIZE = 32; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java index 0e1f2f95e..2a1b6c2b3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/PNGWriter.java @@ -8,6 +8,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.block.BlockState; + import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java index 20555819e..33ffc9696 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java @@ -5,7 +5,6 @@ //import com.boydti.fawe.beta.IChunk; //import com.boydti.fawe.beta.IQueueExtent; //import com.boydti.fawe.config.BBC; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; //import com.boydti.fawe.object.*; //import com.boydti.fawe.object.brush.visualization.ImmutableVirtualWorld; //import com.boydti.fawe.object.clipboard.LazyClipboardHolder; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/task/AsyncNotifyQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/object/task/AsyncNotifyQueue.java index f79906fb4..9dccb56d7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/task/AsyncNotifyQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/task/AsyncNotifyQueue.java @@ -1,6 +1,7 @@ package com.boydti.fawe.object.task; import com.boydti.fawe.Fawe; + import java.io.Closeable; import java.util.concurrent.Callable; import java.util.concurrent.Future; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/task/SingleThreadIntervalQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/object/task/SingleThreadIntervalQueue.java index 7fd063afd..5271a7e32 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/task/SingleThreadIntervalQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/task/SingleThreadIntervalQueue.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.task; import com.boydti.fawe.Fawe; import com.boydti.fawe.util.TaskManager; + import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/AboveVisitor.java b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/AboveVisitor.java index d5a69f048..e15661df4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/AboveVisitor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/AboveVisitor.java @@ -1,16 +1,15 @@ package com.boydti.fawe.object.visitor; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Visits adjacent points on the same X-Z plane as long as the points pass the given mask, and then * executes the provided region function on the entire column. - *

*

This is used by {@code //fill}.

*/ public class AboveVisitor extends RecursiveVisitor { @@ -20,9 +19,9 @@ public class AboveVisitor extends RecursiveVisitor { /** * Create a new visitor. * - * @param mask the mask + * @param mask the mask * @param function the function - * @param baseY the base Y + * @param baseY the base Y */ public AboveVisitor(Mask mask, RegionFunction function, int baseY) { this(mask, function, baseY, Integer.MAX_VALUE); @@ -34,14 +33,9 @@ public class AboveVisitor extends RecursiveVisitor { this.baseY = baseY; - setDirections( - BlockVector3.UNIT_MINUS_X, - BlockVector3.UNIT_MINUS_Y, - BlockVector3.UNIT_MINUS_Z, - BlockVector3.UNIT_X, - BlockVector3.UNIT_Y, - BlockVector3.UNIT_Z - ); + setDirections(BlockVector3.UNIT_MINUS_X, BlockVector3.UNIT_MINUS_Y, + BlockVector3.UNIT_MINUS_Z, BlockVector3.UNIT_X, BlockVector3.UNIT_Y, + BlockVector3.UNIT_Z); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSRecursiveVisitor.java b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSRecursiveVisitor.java index 6b9506184..6d294437e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSRecursiveVisitor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSRecursiveVisitor.java @@ -1,11 +1,11 @@ package com.boydti.fawe.object.visitor; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; +import static com.google.common.base.Preconditions.checkNotNull; + /** * An implementation of an {@link com.sk89q.worldedit.function.visitor.BreadthFirstSearch} that uses * a mask to determine where a block should be visited. diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java index 32edff280..152e0ef4e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/visitor/DFSVisitor.java @@ -11,6 +11,7 @@ import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; + import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashSet; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/FaweMask.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/FaweMask.java index ed3f9d99d..e8f7ee586 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/FaweMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/FaweMask.java @@ -1,8 +1,6 @@ package com.boydti.fawe.regions; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.IDelegateRegion; import com.sk89q.worldedit.regions.Region; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java index f484c043c..550c722e9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java @@ -1,7 +1,5 @@ package com.boydti.fawe.util; -import static org.slf4j.LoggerFactory.getLogger; - import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.sk89q.jnbt.CompoundTag; @@ -11,6 +9,7 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.command.tool.BrushTool; import com.sk89q.worldedit.entity.Player; + import java.util.HashMap; import java.util.Map; import java.util.WeakHashMap; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/CachedTextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/CachedTextureUtil.java index 8913e4c11..252a927ea 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/CachedTextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/CachedTextureUtil.java @@ -2,6 +2,7 @@ package com.boydti.fawe.util; import com.sk89q.worldedit.world.block.BlockType; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + import java.io.FileNotFoundException; public class CachedTextureUtil extends DelegateTextureUtil { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java index 2fca05f4e..c84aa83cf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java @@ -2,6 +2,7 @@ package com.boydti.fawe.util; import com.sk89q.worldedit.world.block.BlockType; + import java.awt.image.BufferedImage; import java.io.File; import java.io.FileNotFoundException; 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 153ae6442..152ec2475 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 @@ -9,13 +9,22 @@ import com.boydti.fawe.beta.implementation.processors.LimitProcessor; import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; -import com.boydti.fawe.object.*; +import com.boydti.fawe.object.FaweLimit; +import com.boydti.fawe.object.HistoryExtent; +import com.boydti.fawe.object.NullChangeSet; +import com.boydti.fawe.object.RegionWrapper; +import com.boydti.fawe.object.RelightMode; import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.changeset.AbstractChangeSet; import com.boydti.fawe.object.changeset.BlockBagChangeSet; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.MemoryOptimizedHistory; -import com.boydti.fawe.object.extent.*; +import com.boydti.fawe.object.extent.FaweRegionExtent; +import com.boydti.fawe.object.extent.MultiRegionExtent; +import com.boydti.fawe.object.extent.NullExtent; +import com.boydti.fawe.object.extent.SingleRegionExtent; +import com.boydti.fawe.object.extent.SlowExtent; +import com.boydti.fawe.object.extent.StripNBTExtent; import com.boydti.fawe.wrappers.WorldWrapper; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; @@ -30,8 +39,8 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; import java.util.UUID; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/ExtentTraverser.java b/worldedit-core/src/main/java/com/boydti/fawe/util/ExtentTraverser.java index 80eb91bdb..9e4676782 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/ExtentTraverser.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/ExtentTraverser.java @@ -2,11 +2,10 @@ package com.boydti.fawe.util; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; +import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; -import org.jetbrains.annotations.NotNull; - public class ExtentTraverser { private final T root; private final ExtentTraverser parent; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/ImgurUtility.java b/worldedit-core/src/main/java/com/boydti/fawe/util/ImgurUtility.java index fd79082e9..08fd7333f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/ImgurUtility.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/ImgurUtility.java @@ -4,7 +4,14 @@ import com.boydti.fawe.object.io.FastByteArrayOutputStream; import com.google.gson.Gson; import com.google.gson.JsonObject; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java b/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java index 1d4cae98f..d843a0efd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java @@ -6,14 +6,25 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.sk89q.worldedit.util.paste.Paster; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; @@ -230,7 +241,7 @@ public final class IncendoPaster implements Paster { b.append("OS Arch: ").append(System.getProperty("os.arch")).append('\n'); b.append("# Okay :D Great. You are now ready to create your bug report!"); b.append("\n# You can do so at https://github.com/IntellectualSites/FastAsyncWorldEdit/issues"); - b.append("\n# or via our Discord at https://discord.gg/ngZCzbU"); + b.append("\n# or via our Discord at https://discord.gg/KxkjDVg"); incendoPaster.addFile(new IncendoPaster.PasteFile("information", b.toString())); try { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/Jars.java b/worldedit-core/src/main/java/com/boydti/fawe/util/Jars.java index 837e99ea4..260245178 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/Jars.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/Jars.java @@ -1,7 +1,5 @@ package com.boydti.fawe.util; -import static org.slf4j.LoggerFactory.getLogger; - import java.io.DataInputStream; import java.io.IOException; import java.net.URL; @@ -9,6 +7,8 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Base64; +import static org.slf4j.LoggerFactory.getLogger; + public enum Jars { MM_v1_7_8( diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java index fb2a8af58..90e36a915 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java @@ -2,12 +2,21 @@ package com.boydti.fawe.util; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.*; +import com.boydti.fawe.object.FaweInputStream; +import com.boydti.fawe.object.FaweOutputStream; +import com.boydti.fawe.object.RegionWrapper; +import com.boydti.fawe.object.RunnableVal; +import com.boydti.fawe.object.RunnableVal2; import com.boydti.fawe.object.changeset.FaweStreamChangeSet; import com.boydti.fawe.object.io.AbstractDelegateOutputStream; import com.github.luben.zstd.ZstdInputStream; import com.github.luben.zstd.ZstdOutputStream; -import com.sk89q.jnbt.*; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.DoubleTag; +import com.sk89q.jnbt.IntTag; +import com.sk89q.jnbt.ListTag; +import com.sk89q.jnbt.StringTag; +import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; @@ -16,31 +25,65 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import it.unimi.dsi.fastutil.io.FastBufferedInputStream; -import net.jpountz.lz4.*; +import net.jpountz.lz4.LZ4BlockInputStream; +import net.jpountz.lz4.LZ4BlockOutputStream; +import net.jpountz.lz4.LZ4Compressor; +import net.jpountz.lz4.LZ4Factory; +import net.jpountz.lz4.LZ4FastDecompressor; +import net.jpountz.lz4.LZ4InputStream; +import net.jpountz.lz4.LZ4Utils; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; -import javax.imageio.ImageIO; -import java.awt.*; +import java.awt.Graphics2D; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; import java.lang.reflect.Array; -import java.net.*; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLConnection; import java.nio.channels.Channels; import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; import java.nio.charset.StandardCharsets; -import java.nio.file.*; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardCopyOption; import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; import java.util.List; -import java.util.*; +import java.util.Map; +import java.util.Scanner; +import java.util.UUID; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.regex.Pattern; -import java.util.zip.*; +import java.util.zip.DataFormatException; +import java.util.zip.Deflater; +import java.util.zip.GZIPInputStream; +import java.util.zip.Inflater; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import javax.annotation.Nullable; +import javax.imageio.ImageIO; import static java.lang.System.arraycopy; import static org.slf4j.LoggerFactory.getLogger; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/MemUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/MemUtil.java index 285572885..7cb9a5aa7 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/MemUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/MemUtil.java @@ -1,6 +1,7 @@ package com.boydti.fawe.util; import com.boydti.fawe.config.Settings; + import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/RandomTextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/RandomTextureUtil.java index c8d2ae500..d87f00310 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/RandomTextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/RandomTextureUtil.java @@ -1,7 +1,6 @@ package com.boydti.fawe.util; import com.sk89q.worldedit.world.block.BlockType; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.io.FileNotFoundException; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java b/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java index dfd78f0aa..71572dbcb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java @@ -1,6 +1,7 @@ package com.boydti.fawe.util; -import com.boydti.fawe.Fawe; +import org.jetbrains.annotations.NotNull; + import java.lang.invoke.MethodHandles; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Constructor; @@ -13,8 +14,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; -import java.util.Map; -import org.jetbrains.annotations.NotNull; public class ReflectionUtils { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java index 3c7d1703a..9ab14751c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java @@ -1,15 +1,11 @@ package com.boydti.fawe.util; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.RunnableVal; - import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; import java.util.Collection; import java.util.Iterator; import java.util.concurrent.ExecutionException; @@ -17,6 +13,9 @@ import java.util.concurrent.ForkJoinPool; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; +import javax.annotation.Nullable; + +import static org.slf4j.LoggerFactory.getLogger; public abstract class TaskManager { @@ -25,16 +24,15 @@ public abstract class TaskManager { private final ForkJoinPool pool = new ForkJoinPool(); /** - * Run a repeating task on the main thread + * Run a repeating task on the main thread. * - * @param runnable + * @param runnable the task to run * @param interval in ticks - * @return */ public abstract int repeat(@NotNull final Runnable runnable, final int interval); /** - * Run a repeating task asynchronously + * Run a repeating task asynchronously. * * @param runnable the task to run * @param interval in ticks @@ -43,34 +41,31 @@ public abstract class TaskManager { public abstract int repeatAsync(@NotNull final Runnable runnable, final int interval); /** - * Run a task asynchronously + * Run a task asynchronously. * * @param runnable the task to run */ public abstract void async(@NotNull final Runnable runnable); /** - * Run a task on the main thread + * Run a task on the main thread. * * @param runnable the task to run */ public abstract void task(@NotNull final Runnable runnable); /** - * Get the public ForkJoinPool
+ * Get the public ForkJoinPool. * - ONLY SUBMIT SHORT LIVED TASKS
* - DO NOT USE SLEEP/WAIT/LOCKS IN ANY SUBMITTED TASKS
* - * @return */ public ForkJoinPool getPublicForkJoinPool() { return pool; } /** - * Run a bunch of tasks in parallel using the shared thread pool - * - * @param runnables + * Run a bunch of tasks in parallel using the shared thread pool. */ public void parallel(Collection runnables) { for (Runnable run : runnables) { @@ -80,7 +75,7 @@ public abstract class TaskManager { } /** - * Run a bunch of tasks in parallel + * Run a bunch of tasks in parallel. * * @param runnables the tasks to run * @param numThreads number of threads (null = config.yml parallel threads) @@ -136,9 +131,7 @@ public abstract class TaskManager { } /** - * Disable async catching for a specific task - * - * @param run + * Disable async catching for a specific task. */ public void runUnsafe(Runnable run) { QueueHandler queue = Fawe.get().getQueueHandler(); @@ -152,7 +145,7 @@ public abstract class TaskManager { } /** - * Run a task on the current thread or asynchronously + * Run a task on the current thread or asynchronously. * - If it's already the main thread, it will just call run() * * @param runnable the task to run @@ -167,7 +160,7 @@ public abstract class TaskManager { } /** - * Run a task as soon as possible on the main thread + * Run a task as soon as possible on the main thread. * - Non blocking if not calling from the main thread * * @param runnable the task to run @@ -181,7 +174,7 @@ public abstract class TaskManager { } /** - * Run a task as soon as possible not on the main thread + * Run a task as soon as possible not on the main thread. * * @param runnable the task to run * @see Fawe#isMainThread() @@ -191,9 +184,9 @@ public abstract class TaskManager { } /** - * Run a task on the main thread at the next tick or now async + * Run a task on the main thread at the next tick or now async. * - * @param runnable the task to run. + * @param runnable the task to run. * @param async whether the task should run on the main thread */ public void taskSoonMain(@NotNull final Runnable runnable, boolean async) { @@ -206,7 +199,7 @@ public abstract class TaskManager { /** - * Run a task later on the main thread + * Run a task later on the main thread. * * @param runnable the task to run * @param delay in ticks @@ -214,7 +207,7 @@ public abstract class TaskManager { public abstract void later(@NotNull final Runnable runnable, final int delay); /** - * Run a task later asynchronously + * Run a task later asynchronously. * * @param runnable the task to run * @param delay in ticks @@ -222,7 +215,7 @@ public abstract class TaskManager { public abstract void laterAsync(@NotNull final Runnable runnable, final int delay); /** - * Cancel a task + * Cancel a task. * * @param task the id of the task to cancel */ @@ -289,12 +282,9 @@ public abstract class TaskManager { } /** - * Run a task on the main thread when the TPS is high enough, and wait for execution to finish:
+ * Run a task on the main thread when the TPS is high enough, and wait for execution to finish. * - Useful if you need to access something from the Bukkit API from another thread
* - Usually wait time is around 25ms
- * - * @param function - * @return */ public T syncWhenFree(@NotNull final RunnableVal function) { if (Fawe.isMainThread()) { @@ -309,7 +299,7 @@ public abstract class TaskManager { } /** - * Run a task on the main thread when the TPS is high enough, and wait for execution to finish:
+ * Run a task on the main thread when the TPS is high enough, and wait for execution to finish. * - Useful if you need to access something from the Bukkit API from another thread
* - Usually wait time is around 25ms
*/ @@ -325,24 +315,18 @@ public abstract class TaskManager { } /** - * Quickly run a task on the main thread, and wait for execution to finish:
+ * Quickly run a task on the main thread, and wait for execution to finish. * - Useful if you need to access something from the Bukkit API from another thread
- * - Usually wait time is around 25ms
- * - * @param function - * @return + * - Usually wait time is around 25ms */ public T sync(@NotNull final RunnableVal function) { return sync((Supplier) function); } /** - * Quickly run a task on the main thread, and wait for execution to finish:
+ * Quickly run a task on the main thread, and wait for execution to finish. * - Useful if you need to access something from the Bukkit API from another thread
* - Usually wait time is around 25ms
- * - * @param function - * @return */ public T sync(final Supplier function) { if (Fawe.isMainThread()) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java index c92afc2f8..877bc3a43 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java @@ -1,7 +1,5 @@ package com.boydti.fawe.util; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock; import com.boydti.fawe.config.Settings; @@ -9,7 +7,6 @@ import com.boydti.fawe.util.image.ImageUtil; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; @@ -21,6 +18,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.IntArraySet; import it.unimi.dsi.fastutil.longs.LongArrayList; + import java.awt.image.BufferedImage; import java.io.File; import java.io.FileNotFoundException; @@ -45,6 +43,8 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import javax.imageio.ImageIO; +import static org.slf4j.LoggerFactory.getLogger; + // TODO FIXME public class TextureUtil implements TextureHolder { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java index 3512829bc..10f821331 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java @@ -8,20 +8,19 @@ import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMaskManager; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extension.platform.PlatformCommandManager; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.TextComponent; -import java.lang.reflect.Field; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayDeque; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class WEManager { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/image/ImageUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/image/ImageUtil.java index 2a07dff0b..0a67f42cf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/image/ImageUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/image/ImageUtil.java @@ -7,7 +7,6 @@ import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.platform.binding.ProvideBindings; -import javax.annotation.Nullable; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.Transparency; @@ -20,6 +19,7 @@ import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import javax.annotation.Nullable; public class ImageUtil { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java b/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java index b721ee2b3..e4e35b203 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/web/SchemSync.java @@ -8,6 +8,7 @@ import com.boydti.fawe.util.MainUtil; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.command.UtilityCommands; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/LocationMaskedPlayerWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/LocationMaskedPlayerWrapper.java index b33f4558a..5b3a2e41a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/LocationMaskedPlayerWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/LocationMaskedPlayerWrapper.java @@ -1,17 +1,8 @@ package com.boydti.fawe.wrappers; -import com.boydti.fawe.Fawe; -import com.boydti.fawe.object.RunnableVal; -import com.boydti.fawe.util.EditSessionBuilder; -import com.boydti.fawe.util.TaskManager; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.block.BlockTypes; public class LocationMaskedPlayerWrapper extends AsyncPlayer { private final boolean allowTeleport; @@ -129,4 +120,4 @@ public class LocationMaskedPlayerWrapper extends AsyncPlayer { update(); } } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java index 812b440dc..bd10a23f6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java @@ -5,7 +5,6 @@ import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.TaskManager; - import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; @@ -24,7 +23,11 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.util.*; +import com.sk89q.worldedit.util.Direction; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.SideEffect; +import com.sk89q.worldedit.util.SideEffectSet; +import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; @@ -34,9 +37,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.weather.WeatherType; -import javax.annotation.Nullable; import java.util.List; import java.util.Set; +import javax.annotation.Nullable; public class WorldWrapper extends AbstractWorld { diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java index faa23c1df..8e81e8862 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java @@ -22,6 +22,7 @@ package com.sk89q.jnbt; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; + import java.util.Collections; import java.util.HashMap; import java.util.List; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java index 6b5776619..7a8e95b7d 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java @@ -19,11 +19,11 @@ package com.sk89q.jnbt; -import static com.google.common.base.Preconditions.checkNotNull; - import java.util.HashMap; import java.util.Map; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Helps create compound tags. */ diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/CompressedCompoundTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/CompressedCompoundTag.java index 0ef0aa680..3a661b437 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompressedCompoundTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompressedCompoundTag.java @@ -1,9 +1,10 @@ package com.sk89q.jnbt; +import net.jpountz.lz4.LZ4BlockInputStream; + import java.io.IOException; import java.util.HashMap; import java.util.Map; -import net.jpountz.lz4.LZ4BlockInputStream; public abstract class CompressedCompoundTag extends CompoundTag { private T in; diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java index f18d648b7..1a4bd9399 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java @@ -21,7 +21,6 @@ package com.sk89q.jnbt; /** * The {@code TAG_Double} tag. - * */ public final class DoubleTag extends NumberTag { @Override diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java index ed309870a..17c471ade 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java @@ -19,14 +19,13 @@ package com.sk89q.jnbt; -import static com.google.common.base.Preconditions.checkNotNull; - import java.util.ArrayList; import java.util.Collections; import java.util.List; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * The {@code TAG_List} tag. */ @@ -79,7 +78,7 @@ public final class ListTag extends Tag { /** * Get the tag if it exists at the given index. - * + * * @param index the index * @return the tag or null */ @@ -424,7 +423,7 @@ public final class ListTag extends Tag { @Override public ArrayList toRaw() { - ArrayList raw = new ArrayList<>(); + ArrayList raw = new ArrayList<>(); if (this.value.isEmpty()) { return raw; } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTagBuilder.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTagBuilder.java index ab2b41399..42dfa5017 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTagBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTagBuilder.java @@ -19,13 +19,13 @@ package com.sk89q.jnbt; -import static com.google.common.base.Preconditions.checkNotNull; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Helps create list tags. */ diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java index bf4911a9c..4525cd719 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java @@ -21,7 +21,6 @@ package com.sk89q.jnbt; /** * The {@code TAG_Long} tag. - * */ public final class LongTag extends NumberTag { @Override diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java index c73ab5184..50b4d6263 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java @@ -29,10 +29,19 @@ public final class NBTConstants { public static final Charset CHARSET = StandardCharsets.UTF_8; - public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, - TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, - TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9, - TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11, TYPE_LONG_ARRAY = 12; + public static final int TYPE_END = 0; + public static final int TYPE_BYTE = 1; + public static final int TYPE_SHORT = 2; + public static final int TYPE_INT = 3; + public static final int TYPE_LONG = 4; + public static final int TYPE_FLOAT = 5; + public static final int TYPE_DOUBLE = 6; + public static final int TYPE_BYTE_ARRAY = 7; + public static final int TYPE_STRING = 8; + public static final int TYPE_LIST = 9; + public static final int TYPE_COMPOUND = 10; + public static final int TYPE_INT_ARRAY = 11; + public static final int TYPE_LONG_ARRAY = 12; /** * Default private constructor. @@ -40,44 +49,44 @@ public final class NBTConstants { private NBTConstants() { } - + /** * Convert a type ID to its corresponding {@link Tag} class. - * + * * @param id type ID * @return tag class * @throws IllegalArgumentException thrown if the tag ID is not valid */ public static Class getClassFromType(int id) { switch (id) { - case TYPE_END: - return EndTag.class; - case TYPE_BYTE: - return ByteTag.class; - case TYPE_SHORT: - return ShortTag.class; - case TYPE_INT: - return IntTag.class; - case TYPE_LONG: - return LongTag.class; - case TYPE_FLOAT: - return FloatTag.class; - case TYPE_DOUBLE: - return DoubleTag.class; - case TYPE_BYTE_ARRAY: - return ByteArrayTag.class; - case TYPE_STRING: - return StringTag.class; - case TYPE_LIST: - return ListTag.class; - case TYPE_COMPOUND: - return CompoundTag.class; - case TYPE_INT_ARRAY: - return IntArrayTag.class; - case TYPE_LONG_ARRAY: - return LongArrayTag.class; - default: - throw new IllegalArgumentException("Unknown tag type ID of " + id); + case TYPE_END: + return EndTag.class; + case TYPE_BYTE: + return ByteTag.class; + case TYPE_SHORT: + return ShortTag.class; + case TYPE_INT: + return IntTag.class; + case TYPE_LONG: + return LongTag.class; + case TYPE_FLOAT: + return FloatTag.class; + case TYPE_DOUBLE: + return DoubleTag.class; + case TYPE_BYTE_ARRAY: + return ByteArrayTag.class; + case TYPE_STRING: + return StringTag.class; + case TYPE_LIST: + return ListTag.class; + case TYPE_COMPOUND: + return CompoundTag.class; + case TYPE_INT_ARRAY: + return IntArrayTag.class; + case TYPE_LONG_ARRAY: + return LongArrayTag.class; + default: + throw new IllegalArgumentException("Unknown tag type ID of " + id); } } 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 5418eca52..94334259f 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java @@ -36,10 +36,12 @@ import java.util.Map; * This class reads NBT, or Named Binary Tag * streams, and produces an object graph of subclasses of the {@code Tag} * object. - * - *

The NBT format was created by Markus Persson, and the specification may be - * found at - * http://www.minecraft.net/docs/NBT.txt.

+ * + *

+ * The NBT format was created by Markus Persson, and the specification may be + * found at + * https://minecraft.gamepedia.com/NBT_format. + *

*/ public final class NBTInputStream implements Closeable { @@ -48,7 +50,7 @@ public final class NBTInputStream implements Closeable { /** * Creates a new {@code NBTInputStream}, which will source its data * from the specified input stream. - * + * * @param is the input stream */ public NBTInputStream(InputStream is) { @@ -61,7 +63,7 @@ public final class NBTInputStream implements Closeable { /** * Reads an NBT tag from the stream. - * + * * @return The tag that was read. * @throws IOException if an I/O error occurs. */ @@ -89,7 +91,9 @@ public final class NBTInputStream implements Closeable { public void readNamedTagLazy(StreamDelegate scope) throws IOException { try { int type = is.readByte(); - if (type == NBTConstants.TYPE_END) return; + if (type == NBTConstants.TYPE_END) { + return; + } StreamDelegate child = scope.get(is); if (child != null) { @@ -540,7 +544,7 @@ public final class NBTInputStream implements Closeable { case NBTConstants.TYPE_END: if (depth == 0) { throw new IOException( - "TAG_End found without a TAG_Compound/TAG_List tag preceding it."); + "TAG_End found without a TAG_Compound/TAG_List tag preceding it."); } else { return new EndTag(); } @@ -569,6 +573,7 @@ public final class NBTInputStream implements Closeable { case NBTConstants.TYPE_LIST: int childType = is.readByte(); length = is.readInt(); + List tagList = new ArrayList<>(); for (int i = 0; i < length; ++i) { Tag tag = readTagPayload(childType, depth + 1); @@ -590,6 +595,7 @@ public final class NBTInputStream implements Closeable { tagMap.put(namedTag.getName(), tag); } } + return new CompoundTag(tagMap); case NBTConstants.TYPE_INT_ARRAY: length = is.readInt(); diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java index 99b0acdf0..9a79de34c 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTOutputStream.java @@ -21,8 +21,6 @@ package com.sk89q.jnbt; import com.boydti.fawe.object.io.LittleEndianOutputStream; -import static com.google.common.base.Preconditions.checkNotNull; - import java.io.Closeable; import java.io.DataOutput; import java.io.DataOutputStream; @@ -32,13 +30,17 @@ import java.io.OutputStream; import java.util.List; import java.util.Map; +import static com.google.common.base.Preconditions.checkNotNull; + /** * This class writes NBT, or Named Binary Tag * {@code Tag} objects to an underlying {@code OutputStream}. * - *

The NBT format was created by Markus Persson, and the specification may be - * found at - * http://www.minecraft.net/docs/NBT.txt.

+ *

+ * The NBT format was created by Markus Persson, and the specification may be + * found at + * https://minecraft.gamepedia.com/NBT_format. + *

*/ public final class NBTOutputStream extends OutputStream implements Closeable, DataOutput { @@ -167,12 +169,12 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da } public void writeNamedTagName(String name, int type) throws IOException { -// byte[] nameBytes = name.getBytes(NBTConstants.CHARSET); + // byte[] nameBytes = name.getBytes(NBTConstants.CHARSET); os.writeByte(type); os.writeUTF(name); -// os.writeShort(nameBytes.length); -// os.write(nameBytes); + // os.writeShort(nameBytes.length); + // os.write(nameBytes); } public void writeLazyCompoundTag(String name, LazyWrite next) throws IOException { diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java index 1941d9508..cb765d2d7 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTUtils.java @@ -19,13 +19,13 @@ package com.sk89q.jnbt; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.storage.InvalidFormatException; import java.util.Map; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A class which contains NBT-related utility methods. * @@ -126,34 +126,34 @@ public final class NBTUtils { */ public static Class getTypeClass(int type) { switch (type) { - case NBTConstants.TYPE_END: - return EndTag.class; - case NBTConstants.TYPE_BYTE: - return ByteTag.class; - case NBTConstants.TYPE_SHORT: - return ShortTag.class; - case NBTConstants.TYPE_INT: - return IntTag.class; - case NBTConstants.TYPE_LONG: - return LongTag.class; - case NBTConstants.TYPE_FLOAT: - return FloatTag.class; - case NBTConstants.TYPE_DOUBLE: - return DoubleTag.class; - case NBTConstants.TYPE_BYTE_ARRAY: - return ByteArrayTag.class; - case NBTConstants.TYPE_STRING: - return StringTag.class; - case NBTConstants.TYPE_LIST: - return ListTag.class; - case NBTConstants.TYPE_COMPOUND: - return CompoundTag.class; - case NBTConstants.TYPE_INT_ARRAY: - return IntArrayTag.class; - case NBTConstants.TYPE_LONG_ARRAY: - return LongArrayTag.class; - default: - throw new IllegalArgumentException("Invalid tag type : " + type + case NBTConstants.TYPE_END: + return EndTag.class; + case NBTConstants.TYPE_BYTE: + return ByteTag.class; + case NBTConstants.TYPE_SHORT: + return ShortTag.class; + case NBTConstants.TYPE_INT: + return IntTag.class; + case NBTConstants.TYPE_LONG: + return LongTag.class; + case NBTConstants.TYPE_FLOAT: + return FloatTag.class; + case NBTConstants.TYPE_DOUBLE: + return DoubleTag.class; + case NBTConstants.TYPE_BYTE_ARRAY: + return ByteArrayTag.class; + case NBTConstants.TYPE_STRING: + return StringTag.class; + case NBTConstants.TYPE_LIST: + return ListTag.class; + case NBTConstants.TYPE_COMPOUND: + return CompoundTag.class; + case NBTConstants.TYPE_INT_ARRAY: + return IntArrayTag.class; + case NBTConstants.TYPE_LONG_ARRAY: + return LongArrayTag.class; + default: + throw new IllegalArgumentException("Invalid tag type : " + type + "."); } } @@ -179,7 +179,7 @@ public final class NBTUtils { * @param key the key to look for * @param expected the expected NBT class type * @return child tag - * @throws InvalidFormatException + * @throws InvalidFormatException if the format of the items is invalid */ public static T getChildTag(Map items, String key, Class expected) throws InvalidFormatException { if (!items.containsKey(key)) { diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java index 4345793d1..d5ba775a0 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java @@ -19,14 +19,13 @@ package com.sk89q.minecraft.util.commands; -import static com.google.common.base.Preconditions.checkNotNull; - import java.util.ArrayList; import java.util.List; import java.util.ListIterator; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + public class CommandException extends Exception { private List commandStack = new ArrayList<>(); diff --git a/worldedit-core/src/main/java/com/sk89q/util/StringUtil.java b/worldedit-core/src/main/java/com/sk89q/util/StringUtil.java index 8231d3aa8..8353db02e 100644 --- a/worldedit-core/src/main/java/com/sk89q/util/StringUtil.java +++ b/worldedit-core/src/main/java/com/sk89q/util/StringUtil.java @@ -149,7 +149,7 @@ public final class StringUtil { * @param initialIndex the initial index to start form * @return a new string */ - public static String joinString(Collection str, String delimiter,int initialIndex) { + public static String joinString(Collection str, String delimiter, int initialIndex) { if (str.isEmpty()) { return ""; } @@ -310,8 +310,9 @@ public final class StringUtil { return parseListInQuotes(input, delimiter, quoteOpen, quoteClose, false); } - public static List parseListInQuotes(String[] input, char delimiter, char quoteOpen, char quoteClose, boolean appendLeftover) { - List parsableBlocks = new ArrayList<>(); + public static List parseListInQuotes(String[] input, char delimiter, char quoteOpen, + char quoteClose, boolean appendLeftover) { + List parsableBlocks = new ArrayList<>(); StringBuilder buffer = new StringBuilder(); for (String split : input) { if (split.indexOf(quoteOpen) != -1 && split.indexOf(quoteClose) == -1) { diff --git a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java index cca293ddf..d2527bdbf 100644 --- a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java +++ b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; - import javax.annotation.Nullable; /** @@ -62,7 +61,7 @@ public class YAMLNode { /** * Gets a property at a location. This will either return an Object - * or null, with null meaning no configuration value exists at + * or null, with null meaning that no configuration value exists at * that location. This could potentially return a default value (not yet * implemented) as defined by a plugin, if this is a plugin-tied * configuration. @@ -274,7 +273,9 @@ public class YAMLNode { public Vector3 getVector(String path, Vector3 def) { Vector3 v = getVector(path); if (v == null) { - if (writeDefaults) setProperty(path, def); + if (writeDefaults) { + setProperty(path, def); + } return def; } return v; @@ -292,7 +293,9 @@ public class YAMLNode { public String getString(String path, String def) { String o = getString(path); if (o == null) { - if (writeDefaults) setProperty(path, def); + if (writeDefaults) { + setProperty(path, def); + } return def; } return o; @@ -329,7 +332,9 @@ public class YAMLNode { public int getInt(String path, int def) { Integer o = castInt(getProperty(path)); if (o == null) { - if (writeDefaults) setProperty(path, def); + if (writeDefaults) { + setProperty(path, def); + } return def; } else { return o; @@ -367,7 +372,9 @@ public class YAMLNode { public double getDouble(String path, double def) { Double o = castDouble(getProperty(path)); if (o == null) { - if (writeDefaults) setProperty(path, def); + if (writeDefaults) { + setProperty(path, def); + } return def; } else { return o; @@ -403,7 +410,9 @@ public class YAMLNode { public boolean getBoolean(String path, boolean def) { Boolean o = castBoolean(getProperty(path)); if (o == null) { - if (writeDefaults) setProperty(path, def); + if (writeDefaults) { + setProperty(path, def); + } return def; } else { return o; @@ -419,7 +428,9 @@ public class YAMLNode { */ @SuppressWarnings("unchecked") public List getKeys(String path) { - if (path == null) return new ArrayList<>(root.keySet()); + if (path == null) { + return new ArrayList<>(root.keySet()); + } Object o = getProperty(path); if (o == null) { return null; @@ -464,7 +475,9 @@ public class YAMLNode { public List getStringList(String path, List def) { List raw = getList(path); if (raw == null) { - if (writeDefaults && def != null) setProperty(path, def); + if (writeDefaults && def != null) { + setProperty(path, def); + } return def != null ? def : new ArrayList<>(); } @@ -494,7 +507,9 @@ public class YAMLNode { public List getIntList(String path, List def) { List raw = getList(path); if (raw == null) { - if (writeDefaults && def != null) setProperty(path, def); + if (writeDefaults && def != null) { + setProperty(path, def); + } return def != null ? def : new ArrayList<>(); } @@ -523,7 +538,9 @@ public class YAMLNode { public List getDoubleList(String path, List def) { List raw = getList(path); if (raw == null) { - if (writeDefaults && def != null) setProperty(path, def); + if (writeDefaults && def != null) { + setProperty(path, def); + } return def != null ? def : new ArrayList<>(); } @@ -552,7 +569,9 @@ public class YAMLNode { public List getBooleanList(String path, List def) { List raw = getList(path); if (raw == null) { - if (writeDefaults && def != null) setProperty(path, def); + if (writeDefaults && def != null) { + setProperty(path, def); + } return def != null ? def : new ArrayList<>(); } @@ -672,7 +691,9 @@ public class YAMLNode { public List getNodeList(String path, List def) { List raw = getList(path); if (raw == null) { - if (writeDefaults && def != null) setProperty(path, def); + if (writeDefaults && def != null) { + setProperty(path, def); + } return def != null ? def : new ArrayList<>(); } diff --git a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java index 48eb06e69..f67e6bd1a 100644 --- a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java +++ b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java @@ -110,10 +110,10 @@ public class YAMLProcessor extends YAMLNode { * @throws java.io.IOException on load error */ public void load() throws IOException { - try (InputStream stream = getInputStream()) { - if (stream == null) + if (stream == null) { throw new IOException("Stream is null!"); + } read(yaml.load(new UnicodeReader(stream))); } catch (YAMLProcessorException e) { root = new LinkedHashMap<>(); @@ -172,8 +172,9 @@ public class YAMLProcessor extends YAMLNode { parent.mkdirs(); } try (OutputStream stream = getOutputStream()) { - if (stream == null) + if (stream == null) { return false; + } OutputStreamWriter writer = new OutputStreamWriter(stream, StandardCharsets.UTF_8); if (header != null) { writer.append(header); @@ -247,7 +248,7 @@ public class YAMLProcessor extends YAMLNode { * * @param key the property key * @param comment the comment. May be {@code null}, in which case the comment - * is removed. + * is removed. */ public void setComment(String key, String... comment) { if (comment != null && comment.length > 0) { @@ -285,10 +286,11 @@ public class YAMLProcessor extends YAMLNode { } /** - * This method returns an empty ConfigurationNode for using as a - * default in methods that select a node from a node list. + * Get an empty ConfigurationNode for using as a default in methods that + * select a node from a node list. * - * @param writeDefaults true to write default values when a property is requested that doesn't exist + * @param writeDefaults true to write default values when a property is + * requested that doesn't exist * @return a node */ public static YAMLNode getEmptyNode(boolean writeDefaults) { 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 10e01fe01..26eb0421f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -19,12 +19,6 @@ package com.sk89q.worldedit; -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; - import com.boydti.fawe.FaweCache; import com.boydti.fawe.config.Caption; import com.boydti.fawe.config.Settings; @@ -135,6 +129,11 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -145,10 +144,12 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -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, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionFactory.java index 88b22bf1b..d6e3906e1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionFactory.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.event.extent.EditSessionEvent; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.util.eventbus.EventBus; import com.sk89q.worldedit.world.World; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Creates new {@link EditSession}s. To get an instance of this factory, * use {@link WorldEdit#getEditSessionFactory()}. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index 492c799f2..5e705aa3b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -29,7 +29,6 @@ import com.sk89q.worldedit.util.io.file.ArchiveNioSupports; import com.sk89q.worldedit.util.logging.LogFormat; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import com.sk89q.worldedit.world.snapshot.experimental.SnapshotDatabase; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index eeb297713..a636db1c3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -36,7 +36,6 @@ import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.TextureHolder; import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.wrappers.WorldWrapper; -import com.google.common.collect.Lists; import com.sk89q.jchronic.Chronic; import com.sk89q.jchronic.Options; import com.sk89q.jchronic.utils.Span; @@ -81,7 +80,6 @@ import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.snapshot.experimental.Snapshot; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import javax.annotation.Nullable; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java index ac5b9d04b..11515af92 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit; -import static com.google.common.base.Preconditions.checkArgument; -import static com.sk89q.worldedit.event.platform.Interaction.HIT; -import static com.sk89q.worldedit.event.platform.Interaction.OPEN; - +import com.google.common.base.Throwables; +import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import com.google.common.collect.SetMultimap; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.sk89q.worldedit.blocks.BaseItem; @@ -44,6 +44,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.expression.Expression; +import com.sk89q.worldedit.internal.expression.invoke.ReturnException; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.scripting.CraftScriptContext; import com.sk89q.worldedit.scripting.CraftScriptEngine; @@ -68,6 +69,9 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.registry.BundledBlockData; import com.sk89q.worldedit.world.registry.BundledItemData; import com.sk89q.worldedit.world.registry.LegacyMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; @@ -84,8 +88,9 @@ import java.util.Map; import javax.annotation.Nullable; import javax.script.ScriptException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import static com.google.common.base.Preconditions.checkArgument; +import static com.sk89q.worldedit.event.platform.Interaction.HIT; +import static com.sk89q.worldedit.event.platform.Interaction.OPEN; /** * The entry point and container for a working implementation of WorldEdit. @@ -111,8 +116,7 @@ public final class WorldEdit { private final PlatformManager platformManager = new PlatformManager(this); private final EditSessionFactory editSessionFactory = new EditSessionFactory.EditSessionFactoryImpl(eventBus); private final SessionManager sessions = new SessionManager(this); - private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator( - EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20, "WorldEdit Task Executor - %s")); + private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20, "WorldEdit Task Executor - %s")); private final Supervisor supervisor = new SimpleSupervisor(); private final TranslationManager translationManager = new TranslationManager(this); @@ -288,7 +292,9 @@ public final class WorldEdit { * @throws FilenameException thrown if the filename is invalid */ private File getSafeFile(@Nullable Actor actor, File dir, String filename, String defaultExt, String[] extensions, boolean isSave) throws FilenameException { - if (extensions != null && (extensions.length == 1 && extensions[0] == null)) extensions = null; + if (extensions != null && (extensions.length == 1 && extensions[0] == null)) { + extensions = null; + } File f; @@ -388,7 +394,7 @@ public final class WorldEdit { * Checks to see if the specified radius is within bounds. * * @param radius the radius - * @throws MaxRadiusException + * @throws MaxRadiusException if the radius is bigger than the configured radius */ public void checkMaxRadius(double radius) throws MaxRadiusException { if (getConfiguration().maxRadius > 0 && radius > getConfiguration().maxRadius) { @@ -400,7 +406,7 @@ public final class WorldEdit { * Checks to see if the specified brush radius is within bounds. * * @param radius the radius - * @throws MaxBrushRadiusException + * @throws MaxBrushRadiusException if the radius is bigger than the configured radius */ public void checkMaxBrushRadius(double radius) throws MaxBrushRadiusException { if (getConfiguration().maxBrushRadius > 0 && radius > getConfiguration().maxBrushRadius) { @@ -474,6 +480,38 @@ public final class WorldEdit { throw new UnknownDirectionException(dir.name()); } + private static final Map NAME_TO_DIRECTION_MAP; + + static { + SetMultimap directionNames = HashMultimap.create(); + for (Direction direction : Direction.valuesOf( + Direction.Flag.CARDINAL | Direction.Flag.UPRIGHT + )) { + String name = direction.name().toLowerCase(Locale.ROOT); + for (int i = 1; i <= name.length(); i++) { + directionNames.put(direction, name.substring(0, i)); + } + } + ImmutableMap.Builder nameToDirectionMap = ImmutableMap.builder(); + for (Direction direction : directionNames.keySet()) { + directionNames.get(direction).forEach(name -> + nameToDirectionMap.put(name, direction) + ); + } + for (Direction direction : ImmutableList.of(Direction.NORTH, Direction.SOUTH)) { + for (Direction diagonal : ImmutableList.of(Direction.WEST, Direction.EAST)) { + for (String dirName : directionNames.get(direction)) { + for (String diagName : directionNames.get(diagonal)) { + nameToDirectionMap.put(dirName + diagName, Direction.valueOf( + direction.name() + diagonal.name() + )); + } + } + } + } + NAME_TO_DIRECTION_MAP = nameToDirectionMap.build(); + } + /** * Get the direction vector for a player's direction. * @@ -483,68 +521,32 @@ public final class WorldEdit { * @throws UnknownDirectionException thrown if the direction is not known, or a relative direction is used with null player */ private Direction getPlayerDirection(@Nullable Player player, String dirStr) throws UnknownDirectionException { - final Direction dir; - - switch (dirStr.charAt(0)) { - case 'w': - dir = Direction.WEST; - break; - - case 'e': - dir = Direction.EAST; - break; - - case 's': - if (dirStr.indexOf('w') > 0) { - return Direction.SOUTHWEST; - } - - if (dirStr.indexOf('e') > 0) { - return Direction.SOUTHEAST; - } - dir = Direction.SOUTH; - break; - - case 'n': - if (dirStr.indexOf('w') > 0) { - return Direction.NORTHWEST; - } - - if (dirStr.indexOf('e') > 0) { - return Direction.NORTHEAST; - } - dir = Direction.NORTH; - break; - - case 'u': - dir = Direction.UP; - break; - - case 'd': - dir = Direction.DOWN; - break; - - case 'm': // me - case 'f': // forward - dir = getDirectionRelative(player, 0); - break; - - case 'b': // back - dir = getDirectionRelative(player, 180); - break; - - case 'l': // left - dir = getDirectionRelative(player, -90); - break; - - case 'r': // right - dir = getDirectionRelative(player, 90); - break; - - default: - throw new UnknownDirectionException(dirStr); + Direction byName = NAME_TO_DIRECTION_MAP.get(dirStr); + if (byName != null) { + return byName; + } + switch (dirStr) { + case "m": + case "me": + case "f": + case "forward": + return getDirectionRelative(player, 0); + + case "b": + case "back": + return getDirectionRelative(player, 180); + + case "l": + case "left": + return getDirectionRelative(player, -90); + + case "r": + case "right": + return getDirectionRelative(player, 90); + + default: + throw new UnknownDirectionException(dirStr); } - return dir; } private Direction getDirectionRelative(Player player, int yawOffset) throws UnknownDirectionException { @@ -622,8 +624,21 @@ public final class WorldEdit { * @param clicked the clicked block * @return false if you want the action to go through */ + @Deprecated public boolean handleBlockRightClick(Player player, Location clicked) { - BlockInteractEvent event = new BlockInteractEvent(player, clicked, OPEN); + return handleBlockRightClick(player, clicked, null); + } + + /** + * Called on right click. + * + * @param player the player + * @param clicked the clicked block + * @param face The clicked face + * @return false if you want the action to go through + */ + public boolean handleBlockRightClick(Player player, Location clicked, @Nullable Direction face) { + BlockInteractEvent event = new BlockInteractEvent(player, clicked, face, OPEN); getEventBus().post(event); return event.isCancelled(); } @@ -635,8 +650,21 @@ public final class WorldEdit { * @param clicked the clicked block * @return false if you want the action to go through */ + @Deprecated public boolean handleBlockLeftClick(Player player, Location clicked) { - BlockInteractEvent event = new BlockInteractEvent(player, clicked, HIT); + return handleBlockLeftClick(player, clicked, null); + } + + /** + * Called on left click. + * + * @param player the player + * @param clicked the clicked block + * @param face The clicked face + * @return false if you want the action to go through + */ + public boolean handleBlockLeftClick(Player player, Location clicked, @Nullable Direction face) { + BlockInteractEvent event = new BlockInteractEvent(player, clicked, face, HIT); getEventBus().post(event); return event.isCancelled(); } @@ -708,8 +736,11 @@ public final class WorldEdit { try { engine.evaluate(script, filename, vars); } catch (ScriptException e) { - player.printError(TranslatableComponent.of("worldedit.script.failed", TextComponent.of(e.getMessage(), TextColor.WHITE))); - logger.warn("Failed to execute script", e); + // non-exceptional return check + if (!(Throwables.getRootCause(e) instanceof ReturnException)) { + player.printError(TranslatableComponent.of("worldedit.script.failed", TextComponent.of(e.getMessage(), TextColor.WHITE))); + logger.warn("Failed to execute script", e); + } } catch (NumberFormatException | WorldEditException e) { throw e; } catch (Throwable e) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditException.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditException.java index 4f96d53be..844ca1ecd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditException.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditException.java @@ -19,15 +19,37 @@ package com.sk89q.worldedit; +import com.sk89q.worldedit.util.formatting.WorldEditText; +import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TextComponent; + +import java.util.Locale; + /** * Parent for all WorldEdit exceptions. */ public abstract class WorldEditException extends RuntimeException { + private final Component message; + /** * Create a new exception. */ protected WorldEditException() { + this.message = null; + } + + /** + * Create a new exception with a message. + * + * @param message the message + * @deprecated Use component version + */ + @Deprecated + protected WorldEditException(String message) { + super(message); + + this.message = TextComponent.of(message); } /** @@ -35,8 +57,24 @@ public abstract class WorldEditException extends RuntimeException { * * @param message the message */ - protected WorldEditException(String message) { - super(message); + protected WorldEditException(Component message) { + super(WorldEditText.reduceToText(message, Locale.getDefault())); + + this.message = message; + } + + /** + * Create a new exception with a message and a cause. + * + * @param message the message + * @param cause the cause + * @deprecated Use component version + */ + @Deprecated + protected WorldEditException(String message, Throwable cause) { + super(message, cause); + + this.message = TextComponent.of(message); } /** @@ -45,8 +83,10 @@ public abstract class WorldEditException extends RuntimeException { * @param message the message * @param cause the cause */ - protected WorldEditException(String message, Throwable cause) { - super(message, cause); + protected WorldEditException(Component message, Throwable cause) { + super(WorldEditText.reduceToText(message, Locale.getDefault()), cause); + + this.message = message; } /** @@ -56,5 +96,16 @@ public abstract class WorldEditException extends RuntimeException { */ protected WorldEditException(Throwable cause) { super(cause); + + this.message = null; + } + + /** + * Get the message of this exception as a rich text component. + * + * @return The rich message + */ + public Component getRichMessage() { + return this.message; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java index febe7cac4..aaf5235d7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit; -import javax.annotation.Nullable; import java.io.IOException; import java.io.UncheckedIOException; import java.net.JarURLConnection; @@ -27,6 +26,7 @@ import java.net.URL; import java.util.function.Supplier; import java.util.jar.Attributes; import java.util.jar.Manifest; +import javax.annotation.Nullable; /** * Represents WorldEdit info from the MANIFEST.MF file. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java index 3401af293..15578b4ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java @@ -19,13 +19,14 @@ package com.sk89q.worldedit.blocks; -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.world.NbtValued; import com.sk89q.worldedit.world.item.ItemType; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents an item, without an amount value. See {@link BaseItemStack} * for an instance with stack amount information. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java index 1f65c6a19..6dd2f62f8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java @@ -65,13 +65,17 @@ public final class Blocks { states.forEach((key, value) -> { @SuppressWarnings("unchecked") Property prop = (Property) existing.get(key); - if (prop == null) return; + if (prop == null) { + return; + } Object val = null; try { val = prop.getValueFor(value); } catch (IllegalArgumentException ignored) { } - if (val == null) return; + if (val == null) { + return; + } newMap.put(prop, val); }); return newMap; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java index 49058f17d..8c8855e88 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.command; -import static java.util.Objects.requireNonNull; -import static org.enginehub.piston.part.CommandParts.arg; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.sk89q.worldedit.LocalSession; @@ -47,7 +44,6 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextDecoration; -import java.util.stream.Collectors; import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManagerService; import org.enginehub.piston.CommandParameters; @@ -58,6 +54,11 @@ import org.enginehub.piston.inject.Key; import org.enginehub.piston.part.CommandArgument; import org.enginehub.piston.part.SubCommandPart; +import java.util.stream.Collectors; + +import static java.util.Objects.requireNonNull; +import static org.enginehub.piston.part.CommandParts.arg; + @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class ApplyBrushCommands { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java index d144bfb33..c0083ecab 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java @@ -19,17 +19,14 @@ package com.sk89q.worldedit.command; -import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; - -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.util.CommandPermissions; -import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; +import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; @@ -51,21 +48,25 @@ import com.sk89q.worldedit.util.formatting.component.PaginationBox; import com.sk89q.worldedit.util.formatting.component.TextUtils; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeData; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.registry.BiomeRegistry; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; -import java.util.List; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.Switch; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; + /** * Implements biome-related commands such as "/biomelist". */ @@ -88,30 +89,29 @@ public class BiomeCommands { @ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) { WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> { - BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() - .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); + BiomeRegistry biomeRegistry = + WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS) + .getRegistries().getBiomeRegistry(); - PaginationBox paginationBox = PaginationBox.fromStrings("Available Biomes", "/biomelist -p %page%", - BiomeType.REGISTRY.values().stream() - .map(biomeType -> { - String id = biomeType.getId(); - final BiomeData data = biomeRegistry.getData(biomeType); - if (data != null) { - String name = data.getName(); - return id + " (" + name + ")"; - } else { - return id; - } - }) - .collect(Collectors.toList())); - return paginationBox.create(page); + PaginationBox paginationBox = PaginationBox + .fromStrings("Available Biomes", "/biomelist -p %page%", + BiomeType.REGISTRY.values().stream().map(biomeType -> { + String id = biomeType.getId(); + final BiomeData data = biomeRegistry.getData(biomeType); + if (data != null) { + String name = data.getName(); + return id + " (" + name + ")"; + } else { + return id; + } + }).collect(Collectors.toList())); + return paginationBox.create(page); }, (Component) null); } @Command( name = "biomeinfo", desc = "Get the biome of the targeted block.", - aliases = { "/biomeinfo" }, descFooter = "By default, uses all blocks in your selection." ) @CommandPermissions("worldedit.biome.info") diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index e726217a7..55e214674 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.command; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Caption; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.brush.BlendBall; @@ -66,9 +65,8 @@ import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.command.factory.ReplaceFactory; -import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.command.argument.Arguments; +import com.sk89q.worldedit.command.factory.ReplaceFactory; import com.sk89q.worldedit.command.factory.TreeGeneratorFactory; import com.sk89q.worldedit.command.tool.BrushTool; import com.sk89q.worldedit.command.tool.InvalidToolBindException; @@ -91,6 +89,7 @@ import com.sk89q.worldedit.extension.platform.binding.ProvideBindings; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.Contextual; +import com.sk89q.worldedit.function.factory.Apply; import com.sk89q.worldedit.function.factory.Deform; import com.sk89q.worldedit.function.factory.Paint; import com.sk89q.worldedit.function.mask.ExistingBlockMask; @@ -106,13 +105,23 @@ import com.sk89q.worldedit.regions.factory.RegionFactory; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.TreeGenerator; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; 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 org.enginehub.piston.annotation.Command; +import org.enginehub.piston.annotation.CommandContainer; +import org.enginehub.piston.annotation.param.Arg; +import org.enginehub.piston.annotation.param.ArgFlag; +import org.enginehub.piston.annotation.param.Switch; +import org.enginehub.piston.inject.InjectedValueAccess; +import org.enginehub.piston.inject.Key; +import org.jetbrains.annotations.Range; + import java.awt.image.BufferedImage; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; @@ -123,17 +132,6 @@ import java.io.InputStream; import java.net.URI; import java.nio.file.FileSystems; import java.util.List; -import java.util.zip.GZIPInputStream; -import com.sk89q.worldedit.util.formatting.text.TextComponent; -import org.enginehub.piston.annotation.Command; -import com.sk89q.worldedit.function.factory.Apply; -import org.enginehub.piston.annotation.CommandContainer; -import org.enginehub.piston.annotation.param.Arg; -import org.enginehub.piston.annotation.param.ArgFlag; -import org.enginehub.piston.annotation.param.Switch; -import org.enginehub.piston.inject.InjectedValueAccess; -import org.enginehub.piston.inject.Key; -import org.jetbrains.annotations.Range; import static com.google.common.base.Preconditions.checkNotNull; @@ -155,237 +153,226 @@ public class BrushCommands { this.worldEdit = worldEdit; } - @Command( - name = "none", - aliases = "unbind", - desc = "Unbind a bound brush from your current item" - ) + @Command(name = "none", + aliases = "unbind", + desc = "Unbind a bound brush from your current item") void none(Player player, LocalSession session) throws WorldEditException { ToolCommands.setToolNone(player, session, true); } - @Command( - name = "blendball", - aliases = {"bb", "blend"}, - desc = "Smooths and blends terrain", - descFooter = "Smooths and blends terrain\n" + - "Pic: https://i.imgur.com/cNUQUkj.png → https://i.imgur.com/hFOFsNf.png" - ) + @Command(name = "blendball", + aliases = { + "bb", + "blend" + }, + desc = "Smooths and blends terrain", + descFooter = "Smooths and blends terrain\n" + + "Pic: https://i.imgur.com/cNUQUkj.png → https://i.imgur.com/hFOFsNf.png") @CommandPermissions("worldedit.brush.blendball") public void blendBallBrush(InjectedValueAccess context, - @Arg(desc = "The radius to sample for blending", def = "5") - Expression radius) throws WorldEditException { + @Arg(desc = "The radius to sample for blending", + def = "5") Expression radius) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); set(context, new BlendBall()).setSize(radius); } - @Command( - name = "erode", - desc = "Erodes terrain" - ) + @Command(name = "erode", + desc = "Erodes terrain") @CommandPermissions("worldedit.brush.erode") - public void erodeBrush(InjectedValueAccess context, - @Arg(desc = "The radius for eroding", def = "5") - Expression radius, - @Arg(desc = "erodeFaces", def = "6") int erodefaces, - @Arg(desc = "erodeRec", def = "0") int erodeRec, - @Arg(desc = "fillFaces", def = "1") int fillFaces, - @Arg(desc = "fillRec", def = "1") int fillRec - ) throws WorldEditException { + public void erodeBrush(InjectedValueAccess context, @Arg(desc = "The radius for eroding", + def = "5") Expression radius, + @Arg(desc = "erodeFaces", + def = "6") int erodefaces, @Arg(desc = "erodeRec", + def = "0") int erodeRec, @Arg(desc = "fillFaces", + def = "1") int fillFaces, + @Arg(desc = "fillRec", + def = "1") int fillRec) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); set(context, new ErodeBrush(erodefaces, erodeRec, fillFaces, fillRec)).setSize(radius); } - @Command( - name = "pull", - desc = "Pull terrain towards you" - ) + @Command(name = "pull", + desc = "Pull terrain towards you") @CommandPermissions("worldedit.brush.pull") public void pullBrush(InjectedValueAccess context, - @Arg(desc = "The radius to sample for blending", def = "5") - Expression radius, - @Arg(desc = "erodeFaces", def = "2") int erodefaces, - @Arg(desc = "erodeRec", def = "1") int erodeRec, - @Arg(desc = "fillFaces", def = "5") int fillFaces, - @Arg(desc = "fillRec", def = "1") int fillRec - ) throws WorldEditException { + @Arg(desc = "The radius to sample for blending", + def = "5") Expression radius, @Arg(desc = "erodeFaces", + def = "2") int erodefaces, @Arg(desc = "erodeRec", + def = "1") + int erodeRec, @Arg(desc = "fillFaces", + def = "5") int fillFaces, @Arg(desc = "fillRec", + def = "1") int fillRec) + throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); set(context, new RaiseBrush(erodefaces, erodeRec, fillFaces, fillRec)).setSize(radius); } - @Command( - name = "circle", - desc = "Creates a circle, which revolves around your facing direction" - ) + @Command(name = "circle", + desc = "Creates a circle, which revolves around your facing direction") @CommandPermissions("worldedit.brush.sphere") public void circleBrush(Player player, InjectedValueAccess context, - @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "The radius to sample for blending", def = "5") - Expression radius) throws WorldEditException { + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "The radius to sample for blending", + def = "5") Expression radius) + throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); set(context, new CircleBrush(player)).setSize(radius).setFill(fill); } - @Command( - name = "recursive", - aliases = {"recurse", "r"}, - desc = "Set all connected blocks", - descFooter = "Set all connected blocks\n" + - "Note: Set a mask to recurse along specific blocks" - ) + @Command(name = "recursive", + aliases = { + "recurse", + "r" + }, + desc = "Set all connected blocks", + descFooter = "Set all connected blocks\n" + + "Note: Set a mask to recurse along specific blocks") @CommandPermissions("worldedit.brush.recursive") public void recursiveBrush(InjectedValueAccess context, EditSession editSession, - @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "The radius to sample for blending", def = "5") - Expression radius, - @Switch(name = 'd', desc = "Apply in depth first order") - boolean depthFirst) throws WorldEditException { + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "The radius to sample for blending", + def = "5") Expression radius, @Switch(name = 'd', + desc = "Apply in depth first order") + boolean depthFirst) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - set(context, new RecurseBrush(depthFirst)) - .setSize(radius).setFill(fill).setMask(new IdMask(editSession)); + set(context, new RecurseBrush(depthFirst)).setSize(radius).setFill(fill) + .setMask(new IdMask(editSession)); } - @Command( - name = "line", - aliases = {"l"}, - desc = "Create lines" - ) + @Command(name = "line", + aliases = { "l" }, + desc = "Create lines") @CommandPermissions("worldedit.brush.line") - public void lineBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "The radius to sample for blending", def = "0") - Expression radius, - @Switch(name = 'h', desc = "Create only a shell") - boolean shell, - @Switch(name = 's', desc = "Selects the clicked point after drawing") - boolean select, - @Switch(name = 'f', desc = "Create a flat line") - boolean flat) throws WorldEditException { + public void lineBrush(InjectedValueAccess context, + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "The radius to sample for blending", + def = "0") Expression radius, @Switch(name = 'h', + desc = "Create only a shell") + boolean shell, @Switch(name = 's', + desc = "Selects the clicked point after drawing") boolean select, + @Switch(name = 'f', + desc = "Create a flat line") boolean flat) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); set(context, new LineBrush(shell, select, flat)).setSize(radius).setFill(fill); } - @Command( - name = "spline", - aliases = {"spl", "curve"}, - desc = "Join multiple objects together in a curve", - descFooter = "Click to select some objects,click the same block twice to connect the objects.\n" + - "Insufficient brush radius, or clicking the the wrong spot will result in undesired shapes. The shapes must be simple lines or loops.\n" + - "Pic1: http://i.imgur.com/CeRYAoV.jpg -> http://i.imgur.com/jtM0jA4.png\n" + - "Pic2: http://i.imgur.com/bUeyc72.png -> http://i.imgur.com/tg6MkcF.png" + - "Tutorial: https://www.planetminecraft.com/blog/fawe-tutorial/" - ) + @Command(name = "spline", + aliases = { + "spl", + "curve" + }, + desc = "Join multiple objects together in a curve", + descFooter = + "Click to select some objects,click the same block twice to connect the objects.\n" + + "Insufficient brush radius, or clicking the the wrong spot will result in undesired shapes. The shapes must be simple lines or loops.\n" + + "Pic1: http://i.imgur.com/CeRYAoV.jpg -> http://i.imgur.com/jtM0jA4.png\n" + + "Pic2: http://i.imgur.com/bUeyc72.png -> http://i.imgur.com/tg6MkcF.png" + + "Tutorial: https://www.planetminecraft.com/blog/fawe-tutorial/") @CommandPermissions("worldedit.brush.spline") public void splineBrush(Player player, InjectedValueAccess context, - @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "The radius to sample for blending", def = "25") - Expression radius) throws WorldEditException { + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "The radius to sample for blending", + def = "25") Expression radius) + throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); player.print(Caption.of("fawe.worldedit.brush.brush.spline", (radius))); - set(context, - new SplineBrush(player)) - .setSize(radius) - .setFill(fill); + set(context, new SplineBrush(player)).setSize(radius).setFill(fill); } - @Command( - name = "sweep", - aliases = {"sw", "vaesweep"}, - desc = "Sweep your clipboard content along a curve", - descFooter = "Sweeps your clipboard content along a curve.\n" + - "Define a curve by selecting the individual points with a brush\n" + - "Set [copies] to a value > 0 if you want to have your selection pasted a limited amount of times equally spaced on the curve" - ) + @Command(name = "sweep", + aliases = { + "sw", + "vaesweep" + }, + desc = "Sweep your clipboard content along a curve", + descFooter = "Sweeps your clipboard content along a curve.\n" + + "Define a curve by selecting the individual points with a brush\n" + + "Set [copies] to a value > 0 if you want to have your selection pasted a limited amount of times equally spaced on the curve") @CommandPermissions("worldedit.brush.sweep") - public void sweepBrush(Player player, InjectedValueAccess context, - @Arg(desc = "int", def = "-1") int copies) throws WorldEditException { + public void sweepBrush(Player player, InjectedValueAccess context, @Arg(desc = "int", + def = "-1") int copies) + throws WorldEditException { player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline")); set(context, new SweepBrush(copies)); } - @Command( - name = "catenary", - aliases = {"cat", "gravityline", "saggedline"}, - desc = "Create a hanging line between two points" - ) + @Command(name = "catenary", + aliases = { + "cat", + "gravityline", + "saggedline" + }, + desc = "Create a hanging line between two points") @CommandPermissions("worldedit.brush.spline") - public void catenaryBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, - @Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(from = 1, to=Integer.MAX_VALUE) double lengthFactor, - @Arg(desc = "The radius to sample for blending", def = "0") - Expression radius, - @Switch(name = 'h', desc = "Create only a shell") - boolean shell, - @Switch(name = 's', desc = "Select the clicked point after drawing") - boolean select, - @Switch(name = 'd', desc = "sags the catenary toward the facing direction") - boolean facingDirection) throws WorldEditException { + public void catenaryBrush(InjectedValueAccess context, + @Arg(desc = "Pattern") Pattern fill, @Arg(def = "1.2", + desc = "Length of wire compared to distance between points") + @Range(from = 1, + to = Integer.MAX_VALUE) double lengthFactor, + @Arg(desc = "The radius to sample for blending", + def = "0") Expression radius, @Switch(name = 'h', + desc = "Create only a shell") boolean shell, + @Switch(name = 's', + desc = "Select the clicked point after drawing") boolean select, @Switch(name = 'd', + desc = "sags the catenary toward the facing direction") + boolean facingDirection) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor); - set(context, - new CatenaryBrush(shell, select, facingDirection, lengthFactor)) - .setSize(radius) - .setFill(fill); + set(context, new CatenaryBrush(shell, select, facingDirection, lengthFactor)) + .setSize(radius).setFill(fill); } - @Command( - name = "surfacespline", - aliases = {"sspline", "sspl"}, - desc = "Draws a spline (curved line) on the surface", - descFooter = "Create a spline on the surface\n" + - "Video: https://www.youtube.com/watch?v=zSN-2jJxXlM" - ) + @Command(name = "surfacespline", + aliases = { + "sspline", + "sspl" + }, + desc = "Draws a spline (curved line) on the surface", + descFooter = "Create a spline on the surface\n" + + "Video: https://www.youtube.com/watch?v=zSN-2jJxXlM") @CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0, - public void surfaceSpline(Player player, InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "The radius to sample for blending", def = "0") - Expression radius, - @Arg(desc = "double", def = "0") double tension, - @Arg(desc = "double", def = "0") double bias, - @Arg(desc = "double", def = "0") double continuity, - @Arg(desc = "double", def = "10") double quality) throws WorldEditException { + public void surfaceSpline(Player player, InjectedValueAccess context, + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "The radius to sample for blending", + def = "0") Expression radius, + @Arg(desc = "double", + def = "0") double tension, @Arg(desc = "double", + def = "0") double bias, @Arg(desc = "double", + def = "0") + double continuity, @Arg(desc = "double", + def = "10") double quality) throws WorldEditException { player.print(Caption.of("fawe.worldedit.brush.brush.spline", (radius))); worldEdit.checkMaxBrushRadius(radius); - set(context, - new SurfaceSpline(tension, bias, continuity, quality)) - .setSize(radius) - .setFill(fill); + set(context, new SurfaceSpline(tension, bias, continuity, quality)).setSize(radius) + .setFill(fill); } - @Command( - name = "rock", - aliases = {"blob"}, - desc = "Creates a distorted sphere" - ) + @Command(name = "rock", + aliases = { "blob" }, + desc = "Creates a distorted sphere") @CommandPermissions("worldedit.brush.rock") public void blobBrush(InjectedValueAccess context, - @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "Vector3", def = "10") - Vector3 radius, - @Arg(desc = "double", def = "100") - double sphericity, - @Arg(desc = "double", def = "30") - double frequency, - @Arg(desc = "double", def = "50") - double amplitude) throws WorldEditException { + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "Vector3", + def = "10") Vector3 radius, @Arg(desc = "double", + def = "100") + double sphericity, @Arg(desc = "double", + def = "30") double frequency, @Arg(desc = "double", + def = "50") double amplitude) + throws WorldEditException { double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ()); worldEdit.checkMaxBrushRadius(max); - Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100); + Brush brush = + new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100); set(context, brush).setSize(max).setFill(fill); } - @Command( - name = "sphere", - aliases = { "s" }, - desc = "Choose the sphere brush" - ) + @Command(name = "sphere", + aliases = { "s" }, + desc = "Choose the sphere brush") @CommandPermissions("worldedit.brush.sphere") public void sphereBrush(Player player, InjectedValueAccess context, - @Arg(desc = "The pattern of blocks to set") - Pattern pattern, - @Arg(desc = "The radius of the sphere", def = "2") - Expression radius, - @Switch(name = 'h', desc = "Create hollow spheres instead") - boolean hollow, - @Switch(name = 'f', desc = "Create falling spheres instead") - boolean falling) throws WorldEditException { + @Arg(desc = "The pattern of blocks to set") Pattern pattern, + @Arg(desc = "The radius of the sphere", + def = "2") Expression radius, @Switch(name = 'h', + desc = "Create hollow spheres instead") + boolean hollow, @Switch(name = 'f', + desc = "Create falling spheres instead") boolean falling) + throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); Brush brush; if (hollow) { @@ -396,7 +383,8 @@ public class BrushCommands { switch (type.getInternalId()) { case BlockID.SAND: case BlockID.GRAVEL: - player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.try.other")); + player.print( + TranslatableComponent.of("fawe.worldedit.brush.brush.try.other")); falling = true; } } @@ -410,72 +398,73 @@ public class BrushCommands { set(context, brush).setSize(radius).setFill(pattern); } - @Command( - name = "shatter", - aliases = {"partition", "split"}, - desc = "Creates random lines to break the terrain into pieces", - descFooter = "Creates uneven lines separating terrain into multiple pieces\n" + - "Pic: https://i.imgur.com/2xKsZf2.png" - ) + @Command(name = "shatter", + aliases = { + "partition", + "split" + }, + desc = "Creates random lines to break the terrain into pieces", + descFooter = "Creates uneven lines separating terrain into multiple pieces\n" + + "Pic: https://i.imgur.com/2xKsZf2.png") @CommandPermissions("worldedit.brush.shatter") public void shatterBrush(EditSession editSession, InjectedValueAccess context, - @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "The radius to sample for blending", def = "10") - Expression radius, - @Arg(desc = "Lines", def = "10") int count) throws WorldEditException { + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "The radius to sample for blending", + def = "10") Expression radius, + @Arg(desc = "Lines", + def = "10") int count) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - set(context, - new ShatterBrush(count)) - .setSize(radius) - .setFill(fill) - .setMask(new ExistingBlockMask(editSession)); + set(context, new ShatterBrush(count)).setSize(radius).setFill(fill) + .setMask(new ExistingBlockMask(editSession)); } - @Command( - name = "stencil", - desc = "Use a height map to paint a surface", - descFooter = "Use a height map to paint any surface.\n" -) + @Command(name = "stencil", + desc = "Use a height map to paint a surface", + descFooter = "Use a height map to paint any surface.\n") @CommandPermissions("worldedit.brush.stencil") - public void stencilBrush(LocalSession session, InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "Expression", def = "5") Expression radius, - @Arg(desc = "String", def = "") String image, - @Arg(def = "0", desc = "rotation") @Range(from=0, to=360) int rotation, - @Arg(desc = "double", def = "1") double yscale, - @Switch(name = 'w', desc = "Apply at maximum saturation") boolean onlyWhite, - @Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate) throws WorldEditException, FileNotFoundException { + public void stencilBrush(LocalSession session, InjectedValueAccess context, + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "Expression", + def = "5") Expression radius, + @Arg(desc = "String", + def = "") String image, @Arg(def = "0", + desc = "rotation") @Range(from = 0, + to = 360) int rotation, + @Arg(desc = "double", + def = "1") double yscale, @Switch(name = 'w', + desc = "Apply at maximum saturation") + boolean onlyWhite, @Switch(name = 'r', + desc = "Apply random rotation") boolean randomRotate) + throws WorldEditException, FileNotFoundException { worldEdit.checkMaxBrushRadius(radius); InputStream stream = getHeightmapStream(image); HeightBrush brush; try { - brush = new StencilBrush(stream, rotation, yscale, onlyWhite, "#clipboard".equalsIgnoreCase(image) ? session.getClipboard().getClipboard() : null); + brush = new StencilBrush(stream, rotation, yscale, onlyWhite, + "#clipboard".equalsIgnoreCase(image) + ? session.getClipboard().getClipboard() : + null); } catch (EmptyClipboardException ignore) { brush = new StencilBrush(stream, rotation, yscale, onlyWhite, null); } if (randomRotate) { brush.setRandomRotate(true); } - set(context, - brush) - .setSize(radius) - .setFill(fill); + set(context, brush).setSize(radius).setFill(fill); } @Command( - name = "image", - desc = "Use a height map to paint a surface", - descFooter = "Use a height map to paint any surface.\n") + name = "image", + desc = "Use a height map to paint a surface", + descFooter = "Use a height map to paint any surface.\n" + ) @CommandPermissions("worldedit.brush.stencil") public void imageBrush(LocalSession session, InjectedValueAccess context, - @Arg(desc = "The size of the brush", def = "5") - Expression radius, - ProvideBindings.ImageUri imageUri, - @Arg(def = "1", desc = "scale height") - double yscale, - @Switch(name = 'a', desc = "Use image Alpha") - boolean alpha, - @Switch(name = 'f', desc = "Blend the image with existing terrain") - boolean fadeOut) throws WorldEditException, IOException { + @Arg(desc = "The size of the brush", + def = "5") Expression radius, ProvideBindings.ImageUri imageUri, @Arg(def = "1", + desc = "scale height") + double yscale, @Switch(name = 'a', + desc = "Use image Alpha") boolean alpha, @Switch(name = 'f', + desc = "Blend the image with existing terrain") + boolean fadeOut) throws WorldEditException, IOException { BufferedImage image = imageUri.load(); worldEdit.checkMaxBrushRadius(radius); if (yscale != 1) { @@ -490,37 +479,35 @@ public class BrushCommands { set(context, brush).setSize(radius); } - @Command( - name = "surface", - aliases = {"surf"}, - desc = "Use a height map to paint a surface", - descFooter = "Use a height map to paint any surface.\n" + - "The -w flag will only apply at maximum saturation\n" + - "The -r flag will apply random rotation" - ) + @Command(name = "surface", + aliases = { "surf" }, + desc = "Use a height map to paint a surface", + descFooter = "Use a height map to paint any surface.\n" + + "The -w flag will only apply at maximum saturation\n" + + "The -r flag will apply random rotation") @CommandPermissions("worldedit.brush.surface") - public void surfaceBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "Expression", def = "5") - Expression radius) throws WorldEditException { + public void surfaceBrush(InjectedValueAccess context, + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "Expression", + def = "5") Expression radius) + throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); set(context, new SurfaceSphereBrush()).setFill(fill).setSize(radius); } - @Command( - name = "scatter", - desc = "Scatter a pattern on a surface", - descFooter = "Set a number of blocks randomly on a surface each a certain distance apart.\n" + - "Video: https://youtu.be/RPZIaTbqoZw?t=34s" - ) + @Command(name = "scatter", + desc = "Scatter a pattern on a surface", + descFooter = + "Set a number of blocks randomly on a surface each a certain distance apart.\n" + + "Video: https://youtu.be/RPZIaTbqoZw?t=34s") @CommandPermissions("worldedit.brush.scatter") - public void scatterBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "radius", def = "5") - Expression radius, - @Arg(desc = "points", def = "5") - double points, - @Arg(desc = "distance", def = "1") - double distance, - @Switch(name = 'o', desc = "Overlay the block") boolean overlay) throws WorldEditException { + public void scatterBrush(InjectedValueAccess context, + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "radius", + def = "5") Expression radius, + @Arg(desc = "points", + def = "5") double points, @Arg(desc = "distance", + def = "1") double distance, @Switch(name = 'o', + desc = "Overlay the block") + boolean overlay) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); Brush brush; if (overlay) { @@ -531,108 +518,113 @@ public class BrushCommands { set(context, brush).setSize(radius).setFill(fill); } - @Command( - name = "populateschematic", - aliases = {"populateschem", "popschem", "pschem", "ps"}, - desc = "Scatter a schematic on a surface" - ) + @Command(name = "populateschematic", + aliases = { + "populateschem", + "popschem", + "pschem", + "ps" + }, + desc = "Scatter a schematic on a surface") @CommandPermissions("worldedit.brush.populateschematic") - public void scatterSchemBrush(Player player, InjectedValueAccess context, @Arg(desc = "Mask") Mask mask, - @Arg(name = "clipboard", desc = "Clipboard uri") String clipboardStr, - @Arg(desc = "Expression", def = "30") Expression radius, - @Arg(desc = "double", def = "50") double density, - @Switch(name = 'r', desc = "Apply random rotation") boolean rotate) throws WorldEditException { + public void scatterSchemBrush(Player player, InjectedValueAccess context, + @Arg(desc = "Mask") Mask mask, @Arg(name = "clipboard", + desc = "Clipboard uri") String clipboardStr, + @Arg(desc = "Expression", + def = "30") Expression radius, @Arg(desc = "double", + def = "50") double density, @Switch(name = 'r', + desc = "Apply random rotation") + boolean rotate) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); try { - MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true); + MultiClipboardHolder clipboards = + ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true); if (clipboards == null) { - player.print(Caption.of("fawe.error.schematic.not.found" , clipboardStr)); + player.print(Caption.of("fawe.error.schematic.not.found", clipboardStr)); return; } List holders = clipboards.getHolders(); if (holders == null) { - player.print(Caption.of("fawe.error.schematic.not.found" , clipboardStr)); + player.print(Caption.of("fawe.error.schematic.not.found", clipboardStr)); return; } - set(context, - new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius); + set(context, new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius); } catch (IOException e) { throw new RuntimeException(e); } } - @Command( - name = "layer", - desc = "Replaces terrain with a layer.", - descFooter = "Replaces terrain with a layer.\n" + - "Example: /br layer 5 95:1 95:2 35:15 - Places several layers on a surface\n" + - "Pic: https://i.imgur.com/XV0vYoX.png" - ) + @Command(name = "layer", + desc = "Replaces terrain with a layer.", + descFooter = "Replaces terrain with a layer.\n" + + "Example: /br layer 5 95:1 95:2 35:15 - Places several layers on a surface\n" + + "Pic: https://i.imgur.com/XV0vYoX.png") @CommandPermissions("worldedit.brush.layer") public void surfaceLayer(InjectedValueAccess context, - @Arg(desc = "Expression") Expression radius, List blockLayers) throws WorldEditException { + @Arg(desc = "Expression") Expression radius, List blockLayers) + throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); set(context, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius); } - @Command( - name = "splatter", - desc = "Splatter a pattern on a surface", - descFooter = "Sets a bunch of blocks randomly on a surface.\n" + - "Pic: https://i.imgur.com/hMD29oO.png\n" + - "Example: /br splatter stone,dirt 30 15\n" + - "Note: The seeds define how many splotches there are, recursion defines how large, solid defines whether the pattern is applied per seed, else per block." - ) + @Command(name = "splatter", + desc = "Splatter a pattern on a surface", + descFooter = "Sets a bunch of blocks randomly on a surface.\n" + + "Pic: https://i.imgur.com/hMD29oO.png\n" + + "Example: /br splatter stone,dirt 30 15\n" + + "Note: The seeds define how many splotches there are, recursion defines how large, solid defines whether the pattern is applied per seed, else per block.") @CommandPermissions("worldedit.brush.splatter") - public void splatterBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, - @Arg(desc = "Expression", def = "5") Expression radius, - @Arg(desc = "double", def = "1") double points, - @Arg(desc = "double", def = "5") double recursion, - @Arg(desc = "boolean", def = "true") boolean solid) throws WorldEditException { + public void splatterBrush(InjectedValueAccess context, + @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "Expression", + def = "5") Expression radius, + @Arg(desc = "double", + def = "1") double points, @Arg(desc = "double", + def = "5") double recursion, @Arg(desc = "boolean", + def = "true") + boolean solid) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - set(context, new SplatterBrush((int) points, (int) recursion, solid)).setSize(radius).setFill(fill); + set(context, new SplatterBrush((int) points, (int) recursion, solid)).setSize(radius) + .setFill(fill); } - @Command( - name = "scattercommand", - aliases = {"scattercmd", "scmd", "scommand"}, - desc = "Run commands at random points on a surface", - descFooter = - "Run commands at random points on a surface\n" + - " - Your selection will be expanded to the specified size around each point\n" + - " - Placeholders: {x}, {y}, {z}, {world}, {size}" - ) + @Command(name = "scattercommand", + aliases = { + "scattercmd", + "scmd", + "scommand" + }, + desc = "Run commands at random points on a surface", + descFooter = "Run commands at random points on a surface\n" + + " - Your selection will be expanded to the specified size around each point\n" + + " - Placeholders: {x}, {y}, {z}, {world}, {size}") @CommandPermissions("worldedit.brush.scattercommand") public void scatterCommandBrush(Player player, InjectedValueAccess context, - @Arg(desc = "The minimum distance between each point") - Expression radius, - @Arg(desc = "double", def = "1") - double points, - @Arg(desc = "double", def = "1") - double distance, - List commandStr) throws WorldEditException { + @Arg(desc = "The minimum distance between each point") Expression radius, + @Arg(desc = "double", + def = "1") double points, @Arg(desc = "double", + def = "1") double distance, List commandStr) + throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); set(context, new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " "))) - .setSize(radius); + .setSize(radius); } - @Command( - name = "cylinder", - aliases = { "cyl", "c" }, - desc = "Choose the cylinder brush" - ) + @Command(name = "cylinder", + aliases = { + "cyl", + "c" + }, + desc = "Choose the cylinder brush") @CommandPermissions("worldedit.brush.cylinder") public void cylinderBrush(InjectedValueAccess context, - @Arg(desc = "The pattern of blocks to set") - Pattern pattern, - @Arg(desc = "The radius of the cylinder", def = "2") - Expression radius, - @Arg(desc = "The height of the cylinder", def = "1") - int height, - @Switch(name = 'h', desc = "Create hollow cylinders instead") - boolean hollow) throws WorldEditException { + @Arg(desc = "The pattern of blocks to set") Pattern pattern, + @Arg(desc = "The radius of the cylinder", + def = "2") Expression radius, @Arg(desc = "The height of the cylinder", + def = "1") int height, @Switch(name = 'h', + desc = "Create hollow cylinders instead") + boolean hollow) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(height); @@ -645,29 +637,24 @@ public class BrushCommands { settings.setSize(radius).setFill(pattern); } - @Command( - name = "clipboard", - desc = "@Deprecated use instead: `/br copypaste`)", - descFooter = "Choose the clipboard brush.\n" + - "Without the -p flag, the paste will appear centered at the target location. " + - "With the flag, then the paste will appear relative to where you had " + - "stood relative to the copied area when you copied it." - ) + @Command(name = "clipboard", + desc = "@Deprecated use instead: `/br copypaste`)", + descFooter = "Choose the clipboard brush.\n" + + "Without the -p flag, the paste will appear centered at the target location. " + + "With the flag, then the paste will appear relative to where you had " + + "stood relative to the copied area when you copied it.") @Deprecated @CommandPermissions("worldedit.brush.clipboard") - public void clipboardBrush(Player player, LocalSession session, - @Switch(name = 'a', desc = "Don't paste air from the clipboard") - boolean ignoreAir, - @Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it") - boolean usingOrigin, - @Switch(name = 'e', desc = "Paste entities if available") - boolean pasteEntities, - @Switch(name = 'b', desc = "Paste biomes if available") - boolean pasteBiomes, - @ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard") - @ClipboardMask - Mask sourceMask, - InjectedValueAccess context) throws WorldEditException { + public void clipboardBrush(Player player, LocalSession session, @Switch(name = 'a', + desc = "Don't paste air from the clipboard") + boolean ignoreAir, @Switch(name = 'o', + desc = "Paste starting at the target location, instead of centering on it") + boolean usingOrigin, @Switch(name = 'e', + desc = "Paste entities if available") boolean pasteEntities, + @Switch(name = 'b', + desc = "Paste biomes if available") boolean pasteBiomes, @ArgFlag(name = 'm', + desc = "Skip blocks matching this mask in the clipboard") + @ClipboardMask Mask sourceMask, InjectedValueAccess context) throws WorldEditException { ClipboardHolder holder = session.getClipboard(); Clipboard clipboard = holder.getClipboard(); @@ -681,23 +668,20 @@ public class BrushCommands { worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1); set(context, - new ClipboardBrush(newHolder, ignoreAir, usingOrigin, pasteEntities, pasteBiomes, sourceMask)); + new ClipboardBrush(newHolder, ignoreAir, usingOrigin, pasteEntities, pasteBiomes, + sourceMask)); } - @Command( - name = "smooth", - desc = "Choose the terrain softener brush", - descFooter = "Example: '/brush smooth 2 4 grass_block,dirt,stone'" - ) + @Command(name = "smooth", + desc = "Choose the terrain softener brush", + descFooter = "Example: '/brush smooth 2 4 grass_block,dirt,stone'") @CommandPermissions("worldedit.brush.smooth") public void smoothBrush(Player player, LocalSession session, - @Arg(desc = "The radius to sample for softening", def = "2") - Expression radius, - @Arg(desc = "The number of iterations to perform", def = "4") - int iterations, - @Arg(desc = "The mask of blocks to use for the heightmap", def = "") - Mask maskOpt, - InjectedValueAccess context) throws WorldEditException { + @Arg(desc = "The radius to sample for softening", + def = "2") Expression radius, @Arg(desc = "The number of iterations to perform", + def = "4") int iterations, + @Arg(desc = "The mask of blocks to use for the heightmap", + def = "") Mask maskOpt, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); FaweLimit limit = Settings.IMP.getLimit(player); @@ -706,113 +690,129 @@ public class BrushCommands { set(context, new SmoothBrush(iterations, maskOpt)).setSize(radius); } - @Command( - name = "extinguish", - aliases = { "ex" }, - desc = "Shortcut fire extinguisher brush" - ) + @Command(name = "extinguish", + aliases = { "ex" }, + desc = "Shortcut fire extinguisher brush") @CommandPermissions("worldedit.brush.ex") public void extinguishBrush(InjectedValueAccess context, EditSession editSession, - @Arg(desc = "The radius to extinguish", def = "5") - Expression radius) throws WorldEditException { + @Arg(desc = "The radius to extinguish", + def = "5") Expression radius) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); - set(context, - new SphereBrush()) - .setSize(radius) - .setFill(BlockTypes.AIR.getDefaultState()) - .setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE)); + set(context, new SphereBrush()).setSize(radius).setFill(BlockTypes.AIR.getDefaultState()) + .setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE)); } - @Command( - name = "gravity", - aliases = { "grav" }, - desc = "Gravity brush, simulates the effect of gravity" - ) + @Command(name = "gravity", + aliases = { "grav" }, + desc = "Gravity brush, simulates the effect of gravity") @CommandPermissions("worldedit.brush.gravity") public void gravityBrush(InjectedValueAccess context, - @Arg(desc = "The radius to apply gravity in", def = "5") - Expression radius, - @Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius") - boolean fromMaxY) throws WorldEditException { + @Arg(desc = "The radius to apply gravity in", + def = "5") Expression radius, @Switch(name = 'h', + desc = "Affect blocks starting at max Y, rather than the target location Y + radius") + boolean fromMaxY) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); set(context, new GravityBrush(fromMaxY)).setSize(radius); } - @Command( - name = "height", - aliases = {"heightmap"}, - desc = "Raise or lower terrain using a heightmap", - descFooter = "This brush raises and lowers land.\n" + - " - The `-r` flag enables random off-axis rotation\n" + - " - The `-l` flag will work on snow layers\n" + - " - The `-s` flag disables smoothing\n" + - "Note: Use a negative yscale to reduce height\n" + - "Snow Pic: https://i.imgur.com/Hrzn0I4.png" - ) + @Command(name = "height", + aliases = { "heightmap" }, + desc = "Raise or lower terrain using a heightmap", + descFooter = "This brush raises and lowers land.\n" + + " - The `-r` flag enables random off-axis rotation\n" + + " - The `-l` flag will work on snow layers\n" + + " - The `-s` flag disables smoothing\n" + + "Note: Use a negative yscale to reduce height\n" + + "Snow Pic: https://i.imgur.com/Hrzn0I4.png") @CommandPermissions("worldedit.brush.height") - public void heightBrush(LocalSession session, @Arg(desc = "Expression", def = "5") Expression radius, @Arg(desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(from = 0, to = 360) int rotation, @Arg(desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "TODO") boolean randomRotate, @Switch(name = 'l', desc = "TODO") boolean layers, @Switch(name = 's', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - terrainBrush(session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); + public void heightBrush(LocalSession session, @Arg(desc = "Expression", + def = "5") Expression radius, + @Arg(desc = "String", + def = "") String image, @Arg(def = "0", + desc = "rotation") @Range(from = 0, + to = 360) int rotation, + @Arg(desc = "double", + def = "1") double yscale, @Switch(name = 'r', + desc = "TODO") boolean randomRotate, + @Switch(name = 'l', + desc = "TODO") boolean layers, @Switch(name = 's', + desc = "TODO") + boolean dontSmooth, InjectedValueAccess context) + throws WorldEditException, FileNotFoundException { + terrainBrush(session, radius, image, rotation, yscale, false, randomRotate, layers, + !dontSmooth, ScalableHeightMap.Shape.CONE, context); } - @Command( - name = "cliff", - aliases = {"flatcylinder"}, - desc = "Cliff brush", - descFooter = "This brush flattens terrain and creates cliffs." - ) + @Command(name = "cliff", + aliases = { "flatcylinder" }, + desc = "Cliff brush", + descFooter = "This brush flattens terrain and creates cliffs.") @CommandPermissions("worldedit.brush.height") - public void cliffBrush(LocalSession session, - @Arg(desc = "Expression", def = "5") - Expression radius, - @Arg(desc = "String", def = "") - String image, - @Arg(def = "0", desc = "rotation") @Step(90) @Range(from = 0, to = 360) - int rotation, - @Arg(desc = "double", def = "1") - double yscale, - @Switch(name = 'r', desc = "Enables random off-axis rotation") - boolean randomRotate, - @Switch(name = 'l', desc = "Will work on snow layers") - boolean layers, - @Switch(name = 's', desc = "Disables smoothing") - boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - terrainBrush(session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context); + public void cliffBrush(LocalSession session, @Arg(desc = "Expression", + def = "5") Expression radius, + @Arg(desc = "String", + def = "") String image, @Arg(def = "0", + desc = "rotation") @Step(90) @Range(from = 0, + to = 360) int rotation, + @Arg(desc = "double", + def = "1") double yscale, @Switch(name = 'r', + desc = "Enables random off-axis rotation") + boolean randomRotate, @Switch(name = 'l', + desc = "Will work on snow layers") boolean layers, + @Switch(name = 's', + desc = "Disables smoothing") boolean dontSmooth, InjectedValueAccess context) + throws WorldEditException, FileNotFoundException { + terrainBrush(session, radius, image, rotation, yscale, true, randomRotate, layers, + !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context); } - @Command( - name = "flatten", - aliases = {"flatmap", "flat"}, - desc = "This brush raises or lowers land towards the clicked point" - ) + @Command(name = "flatten", + aliases = { + "flatmap", + "flat" + }, + desc = "This brush raises or lowers land towards the clicked point") @CommandPermissions("worldedit.brush.height") - public void flattenBrush(LocalSession session, @Arg(desc = "Expression", def = "5") Expression radius, @Arg(desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(from = 0, to = 360) int rotation, @Arg(desc = "double", def = "1") double yscale, - @Switch(name = 'r', desc = "Enables random off-axis rotation") - boolean randomRotate, - @Switch(name = 'l', desc = "Will work on snow layers") - boolean layers, - @Switch(name = 's', desc = "Disables smoothing") - boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { - terrainBrush(session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context); + public void flattenBrush(LocalSession session, @Arg(desc = "Expression", + def = "5") Expression radius, + @Arg(desc = "String", + def = "") String image, @Arg(def = "0", + desc = "rotation") @Step(90) @Range(from = 0, + to = 360) int rotation, + @Arg(desc = "double", + def = "1") double yscale, @Switch(name = 'r', + desc = "Enables random off-axis rotation") + boolean randomRotate, @Switch(name = 'l', + desc = "Will work on snow layers") boolean layers, + @Switch(name = 's', + desc = "Disables smoothing") boolean dontSmooth, InjectedValueAccess context) + throws WorldEditException, FileNotFoundException { + terrainBrush(session, radius, image, rotation, yscale, true, randomRotate, layers, + !dontSmooth, ScalableHeightMap.Shape.CONE, context); } - private void terrainBrush(LocalSession session, - Expression radius, String image, int rotation, - double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, - Shape shape, InjectedValueAccess context) throws WorldEditException, FileNotFoundException { + private void terrainBrush(LocalSession session, Expression radius, String image, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, Shape shape, InjectedValueAccess context) + throws WorldEditException, FileNotFoundException { worldEdit.checkMaxBrushRadius(radius); InputStream stream = getHeightmapStream(image); HeightBrush brush; if (flat) { try { - brush = new FlattenBrush(stream, rotation, yscale, layers, smooth, "#clipboard".equalsIgnoreCase(image) ? session.getClipboard().getClipboard() : null, shape); + brush = new FlattenBrush(stream, rotation, yscale, layers, smooth, + "#clipboard".equalsIgnoreCase(image) ? + session.getClipboard().getClipboard() : + null, shape); } catch (EmptyClipboardException ignore) { brush = new FlattenBrush(stream, rotation, yscale, layers, smooth, null, shape); } } else { try { - brush = new HeightBrush(stream, rotation, yscale, layers, smooth, "#clipboard".equalsIgnoreCase(image) ? session.getClipboard().getClipboard() : null); + brush = new HeightBrush(stream, rotation, yscale, layers, smooth, + "#clipboard".equalsIgnoreCase(image) ? + session.getClipboard().getClipboard() : + null); } catch (EmptyClipboardException ignore) { brush = new HeightBrush(stream, rotation, yscale, layers, smooth, null); } @@ -820,51 +820,53 @@ public class BrushCommands { if (randomRotate) { brush.setRandomRotate(true); } - set(context, - brush) - .setSize(radius); + set(context, brush).setSize(radius); } private InputStream getHeightmapStream(String filename) throws FileNotFoundException { - if (filename == null) return null; + if (filename == null) { + return null; + } String filenamePng = filename.endsWith(".png") ? filename : filename + ".png"; - File file = new File(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HEIGHTMAP + File.separator + filenamePng); - if (file.exists()) return new FileInputStream(file); + File file = new File(Fawe.imp().getDirectory(), + Settings.IMP.PATHS.HEIGHTMAP + File.separator + filenamePng); + if (file.exists()) { + return new FileInputStream(file); + } URI uri = ImageUtil.getImageURI(filename); return ImageUtil.getInputStream(uri); } - @Command( - name = "copypaste", - aliases = {"cp", "copypasta"}, - desc = "Copy Paste brush", - descFooter = "Left click the base of an object to copy.\n" + - "Right click to paste\n" + - "Note: Works well with the clipboard scroll action\n" + - "Video: https://www.youtube.com/watch?v=RPZIaTbqoZw" - ) + @Command(name = "copypaste", + aliases = { + "cp", + "copypasta" + }, + desc = "Copy Paste brush", + descFooter = "Left click the base of an object to copy.\n" + "Right click to paste\n" + + "Note: Works well with the clipboard scroll action\n" + + "Video: https://www.youtube.com/watch?v=RPZIaTbqoZw") @CommandPermissions("worldedit.brush.copy") public void copy(Player player, LocalSession session, InjectedValueAccess context, - @Arg(desc = "Expression", def = "5") Expression radius, - @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, - @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate) throws WorldEditException { + @Arg(desc = "Expression", + def = "5") Expression radius, @Switch(name = 'r', + desc = "Apply random rotation on paste") + boolean randomRotate, @Switch(name = 'a', + desc = "Apply auto view based rotation on paste") + boolean autoRotate) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); player.print(Caption.of("fawe.worldedit.brush.brush.copy", (radius))); - set(context, - new CopyPastaBrush(player, session, randomRotate, autoRotate)) - .setSize(radius); + set(context, new CopyPastaBrush(player, session, randomRotate, autoRotate)).setSize(radius); } - @Command( - name = "command", - aliases = {"cmd"}, - desc = "Command brush", - descFooter = "Run the commands at the clicked position.\n" + - " - Your selection will be expanded to the specified size around each point\n" + - " - Placeholders: {x}, {y}, {z}, {world}, {size}" - ) + @Command(name = "command", + aliases = { "cmd" }, + desc = "Command brush", + descFooter = "Run the commands at the clicked position.\n" + + " - Your selection will be expanded to the specified size around each point\n" + + " - Placeholders: {x}, {y}, {z}, {world}, {size}") @CommandPermissions("worldedit.brush.command") public void command(InjectedValueAccess context, @Arg(desc = "Expression") Expression radius, @@ -874,13 +876,11 @@ public class BrushCommands { set(context, new CommandBrush(cmd)).setSize(radius); } - @Command( - name = "butcher", - aliases = { "kill" }, - desc = "Butcher brush, kills mobs within a radius" - ) + @Command(name = "butcher", + aliases = { "kill" }, + desc = "Butcher brush, kills mobs within a radius") @CommandPermissions("worldedit.brush.butcher") - public void butcherBrush(Player player, + public void butcherBrush(Player player, LocalSession session, @Arg(desc = "Radius to kill mobs in", def = "5") Expression radius, @Switch(name = 'p', desc = "Also kill pets") @@ -898,24 +898,25 @@ public class BrushCommands { @Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)") boolean killFriendly, @Switch(name = 'r', desc = "Also destroy armor stands") - boolean killArmorStands, - InjectedValueAccess context) throws WorldEditException { + boolean killArmorStands, InjectedValueAccess context) throws WorldEditException { worldEdit.checkMaxBrushRadius(radius); CreatureButcher flags = new CreatureButcher(player); - flags.or(CreatureButcher.Flags.FRIENDLY , killFriendly); // No permission check here. Flags will instead be filtered by the subsequent calls. - flags.or(CreatureButcher.Flags.PETS , killPets, "worldedit.butcher.pets"); - flags.or(CreatureButcher.Flags.NPCS , killNpcs, "worldedit.butcher.npcs"); - flags.or(CreatureButcher.Flags.GOLEMS , killGolems, "worldedit.butcher.golems"); - flags.or(CreatureButcher.Flags.ANIMALS , killAnimals, "worldedit.butcher.animals"); - flags.or(CreatureButcher.Flags.AMBIENT , killAmbient, "worldedit.butcher.ambient"); - flags.or(CreatureButcher.Flags.TAGGED , killWithName, "worldedit.butcher.tagged"); - flags.or(CreatureButcher.Flags.ARMOR_STAND , killArmorStands, "worldedit.butcher.armorstands"); + flags.or(CreatureButcher.Flags.FRIENDLY, killFriendly); // No permission check here. Flags will instead be filtered by the subsequent calls. + flags.or(CreatureButcher.Flags.PETS, killPets, "worldedit.butcher.pets"); + flags.or(CreatureButcher.Flags.NPCS, killNpcs, "worldedit.butcher.npcs"); + flags.or(CreatureButcher.Flags.GOLEMS, killGolems, "worldedit.butcher.golems"); + flags.or(CreatureButcher.Flags.ANIMALS, killAnimals, "worldedit.butcher.animals"); + flags.or(CreatureButcher.Flags.AMBIENT, killAmbient, "worldedit.butcher.ambient"); + flags.or(CreatureButcher.Flags.TAGGED, killWithName, "worldedit.butcher.tagged"); + flags.or(CreatureButcher.Flags.ARMOR_STAND, killArmorStands, + "worldedit.butcher.armorstands"); set(context, new ButcherBrush(flags)).setSize(radius); } - public BrushSettings process(Player player, Arguments arguments, BrushSettings settings) throws WorldEditException { + public BrushSettings process(Player player, Arguments arguments, BrushSettings settings) + throws WorldEditException { LocalSession session = worldEdit.getSessionManager().get(player); session.setTool(player, null); BrushTool tool = session.getBrushTool(player); @@ -923,13 +924,16 @@ public class BrushCommands { tool.setPrimary(settings); tool.setSecondary(settings); - player.print(Caption.of("fawe.worldedit.brush.brush.equipped" , arguments.get().split(" ")[1])); + player.print( + Caption.of("fawe.worldedit.brush.brush.equipped", arguments.get().split(" ")[1])); } return settings; } - public BrushSettings set(InjectedValueAccess context, Brush brush) throws InvalidToolBindException { - Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")); + public BrushSettings set(InjectedValueAccess context, Brush brush) + throws InvalidToolBindException { + Player player = context.injectedValue(Key.of(Player.class)) + .orElseThrow(() -> new IllegalStateException("No player")); LocalSession session = player.getSession(); BrushSettings bs = new BrushSettings(); BrushTool tool = session.getBrushTool(player, false); @@ -947,7 +951,8 @@ public class BrushCommands { String args = arguments.get(); bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1)); } - CommandPermissions perms = context.injectedValue(Key.of(CommandPermissions.class)).orElse(null); + CommandPermissions perms = + context.injectedValue(Key.of(CommandPermissions.class)).orElse(null); if (perms != null) { bs.addPermissions(perms.value()); } @@ -955,14 +960,14 @@ public class BrushCommands { return process(player, arguments, bs); } - @Command( - name = "savebrush", - aliases = {"save"}, - desc = "Save your current brush" - ) + @Command(name = "savebrush", + aliases = { "save" }, + desc = "Save your current brush") @CommandPermissions("worldedit.brush.save") - public void saveBrush(Player player, LocalSession session, @Arg(desc = "String name") String name, - @Switch(name = 'g', desc = "Save the brush globally") boolean root) throws WorldEditException, IOException { + public void saveBrush(Player player, LocalSession session, + @Arg(desc = "String name") String name, @Switch(name = 'g', + desc = "Save the brush globally") + boolean root) throws WorldEditException, IOException { BrushTool tool = session.getBrushTool(player); if (tool != null) { root |= name.startsWith("../"); @@ -981,70 +986,67 @@ public class BrushCommands { } file.createNewFile(); try (DataOutputStream out = new DataOutputStream( - new PGZIPOutputStream(new FileOutputStream(file)))) { + new PGZIPOutputStream(new FileOutputStream(file)))) { out.writeUTF(tool.toString()); } catch (Throwable e) { e.printStackTrace(); } - player.print(Caption.of("fawe.worldedit.schematic.schematic.saved" , name)); + player.print(Caption.of("fawe.worldedit.schematic.schematic.saved", name)); } else { player.printError(TranslatableComponent.of("fawe.worldedit.brush.brush.none")); } } // TODO: Ping @MattBDev to reimplement 2020-02-04 -// @Command( -// name = "loadbrush", -// aliases = {"load"}, -// desc = "Load a brush" -// ) -// @CommandPermissions("worldedit.brush.load") -// public void loadBrush(Player player, LocalSession session, @Arg(desc = "String name") String name) -// throws WorldEditException, IOException { -// name = FileSystems.getDefault().getPath(name).getFileName().toString(); -// File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes"); -// name = name.endsWith(".jsgz") ? name : name + ".jsgz"; -// File file = new File(folder, player.getUniqueId() + File.separator + name); -// if (!file.exists()) { -// file = new File(folder, name); -// } -// if (!file.exists()) { -// File[] files = folder.listFiles(pathname -> false); -// player.print(Caption.of("fawe.error.brush.not.found" , name)); -// return; -// } -// try (DataInputStream in = new DataInputStream( -// new GZIPInputStream(new FileInputStream(file)))) { -// String json = in.readUTF(); -// BrushTool tool = BrushTool.fromString(player, session, json); -// BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); -// session.setTool(item, tool, player); -// player.print(Caption.of("fawe.worldedit.brush.brush.equipped" , name)); -// } catch (Throwable e) { -// e.printStackTrace(); -// player.printError(TranslatableComponent.of("fawe.error.brush.incompatible")); -// } -// } + // @Command( + // name = "loadbrush", + // aliases = {"load"}, + // desc = "Load a brush" + // ) + // @CommandPermissions("worldedit.brush.load") + // public void loadBrush(Player player, LocalSession session, @Arg(desc = "String name") String name) + // throws WorldEditException, IOException { + // name = FileSystems.getDefault().getPath(name).getFileName().toString(); + // File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes"); + // name = name.endsWith(".jsgz") ? name : name + ".jsgz"; + // File file = new File(folder, player.getUniqueId() + File.separator + name); + // if (!file.exists()) { + // file = new File(folder, name); + // } + // if (!file.exists()) { + // File[] files = folder.listFiles(pathname -> false); + // player.print(Caption.of("fawe.error.brush.not.found" , name)); + // return; + // } + // try (DataInputStream in = new DataInputStream( + // new GZIPInputStream(new FileInputStream(file)))) { + // String json = in.readUTF(); + // BrushTool tool = BrushTool.fromString(player, session, json); + // BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); + // session.setTool(item, tool, player); + // player.print(Caption.of("fawe.worldedit.brush.brush.equipped" , name)); + // } catch (Throwable e) { + // e.printStackTrace(); + // player.printError(TranslatableComponent.of("fawe.error.brush.incompatible")); + // } + // } - @Command( - name = "/listbrush", - desc = "List saved brushes", - descFooter = "List all brushes in the brush directory" - ) + @Command(name = "/listbrush", + desc = "List saved brushes", + descFooter = "List all brushes in the brush directory") @CommandPermissions("worldedit.brush.list") - public void list(Actor actor, InjectedValueAccess args, - @ArgFlag(name = 'p', desc = "Prints the requested page", def = "0") - int page) throws WorldEditException { + public void list(Actor actor, InjectedValueAccess args, @ArgFlag(name = 'p', + desc = "Prints the requested page", + def = "0") int page) + throws WorldEditException { String baseCmd = "/brush loadbrush"; File dir = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes"); // TODO NOT IMPLEMENTED -// UtilityCommands.list(dir, actor, args, page, null, true, baseCmd); + // UtilityCommands.list(dir, actor, args, page, null, true, baseCmd); } - static void setOperationBasedBrush(Player player, LocalSession session, Expression radius, - Contextual factory, - RegionFactory shape, - String permission) throws WorldEditException { + static void setOperationBasedBrush(Player player, LocalSession session, Expression radius, Contextual factory, RegionFactory shape, String permission) + throws WorldEditException { WorldEdit.getInstance().checkMaxBrushRadius(radius); BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); tool.setSize(radius); @@ -1054,22 +1056,19 @@ public class BrushCommands { player.print(TextComponent.of("Set brush to " + factory)); } - @Command( - name = "deform", - desc = "Deform brush, applies an expression to an area" - ) + @Command(name = "deform", + desc = "Deform brush, applies an expression to an area") @CommandPermissions("worldedit.brush.deform") public void deform(Player player, LocalSession localSession, - @Arg(desc = "The shape of the region") - RegionFactory shape, - @Arg(desc = "The size of the brush", def = "5") - double radius, - @Arg(desc = "Expression to apply", def = "y-=0.2") - String expression, - @Switch(name = 'r', desc = "Use the game's coordinate origin") - boolean useRawCoords, - @Switch(name = 'o', desc = "Use the placement position as the origin") - boolean usePlacement) throws WorldEditException { + @Arg(desc = "The shape of the region") RegionFactory shape, + @Arg(desc = "The size of the brush", + def = "5") + double radius, @Arg(desc = "Expression to apply", + def = "y-=0.2") String expression, @Switch(name = 'r', + desc = "Use the game's coordinate origin") + boolean useRawCoords, + @Switch(name = 'o', desc = "Use the placement position as the origin") + boolean usePlacement) throws WorldEditException { Deform deform = new Deform(expression); if (useRawCoords) { deform.setMode(Deform.Mode.RAW_COORD); @@ -1087,12 +1086,12 @@ public class BrushCommands { ) @CommandPermissions("worldedit.brush.set") public void set(Player player, LocalSession localSession, - @Arg(desc = "The shape of the region") - RegionFactory shape, - @Arg(desc = "The size of the brush", def = "5") - Expression radius, - @Arg(desc = "The pattern of blocks to set") - Pattern pattern) throws WorldEditException { + @Arg(desc = "The shape of the region") + RegionFactory shape, + @Arg(desc = "The size of the brush", def = "5") + Expression radius, + @Arg(desc = "The pattern of blocks to set") + Pattern pattern) throws WorldEditException { setOperationBasedBrush(player, localSession, radius, new Apply(new ReplaceFactory(pattern)), shape, "worldedit.brush.set"); } @@ -1103,14 +1102,14 @@ public class BrushCommands { ) @CommandPermissions("worldedit.brush.forest") public void forest(Player player, LocalSession localSession, - @Arg(desc = "The shape of the region") - RegionFactory shape, - @Arg(desc = "The size of the brush", def = "5") - Expression radius, - @Arg(desc = "The density of the brush", def = "20") - double density, - @Arg(desc = "The type of tree to use") - TreeGenerator.TreeType type) throws WorldEditException { + @Arg(desc = "The shape of the region") + RegionFactory shape, + @Arg(desc = "The size of the brush", def = "5") + Expression radius, + @Arg(desc = "The density of the brush", def = "20") + double density, + @Arg(desc = "The type of tree to use") + TreeGenerator.TreeType type) throws WorldEditException { setOperationBasedBrush(player, localSession, radius, new Paint(new TreeGeneratorFactory(type), density / 100), shape, "worldedit.brush.forest"); } @@ -1138,7 +1137,7 @@ public class BrushCommands { @Arg(desc = "The shape of the region") RegionFactory shape, @Arg(desc = "The size of the brush", def = "5") - Expression radius) throws WorldEditException { + Expression radius) throws WorldEditException { setOperationBasedBrush(player, localSession, radius, new Deform("y+=1"), shape, "worldedit.brush.lower"); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java index a2c1e3cd1..e483c3a2d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java @@ -18,8 +18,6 @@ */ package com.sk89q.worldedit.command; -import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; -import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME; import com.google.gson.JsonIOException; import com.sk89q.worldedit.LocalSession; @@ -37,7 +35,6 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.component.PaginationBox; -import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; @@ -46,21 +43,23 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.LegacyChunkStore; import com.sk89q.worldedit.world.storage.McRegionChunkStore; -import java.io.IOException; -import java.nio.file.Files; - -import java.io.File; -import java.nio.file.Path; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.exception.StopExecutionException; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; +import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME; /** * Commands for working with chunks. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java index 6cfd12ef4..ac4d280e5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.PermissionCondition; -import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.annotation.MultiDirection; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java index d21acec38..d1288429d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.command; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.transform.BlockTransformExtent; @@ -33,6 +31,8 @@ import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Helper class to 'bake' a transform into a clipboard. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index 923add56e..d159caae4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -19,11 +19,8 @@ package com.sk89q.worldedit.command; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Caption; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.extent.ResettableExtent; import com.boydti.fawe.util.CachedTextureUtil; import com.boydti.fawe.util.CleanTextureUtil; @@ -44,10 +41,8 @@ import com.sk89q.worldedit.extension.input.DisallowedUsageException; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; - -import java.util.ArrayList; -import com.sk89q.worldedit.extent.clipboard.Clipboard; 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.util.SideEffect; import com.sk89q.worldedit.util.SideEffectSet; @@ -55,21 +50,26 @@ import com.sk89q.worldedit.util.formatting.component.PaginationBox; import com.sk89q.worldedit.util.formatting.component.SideEffectBox; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.item.ItemType; -import java.io.FileNotFoundException; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.TreeMap; -import java.util.concurrent.Callable; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.Switch; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.TreeMap; +import java.util.concurrent.Callable; + +import static com.google.common.base.Preconditions.checkNotNull; + /** * General WorldEdit commands. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index e78809bf6..5d193caa2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -18,16 +18,10 @@ */ package com.sk89q.worldedit.command; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; -import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; -import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; -import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Caption; import com.boydti.fawe.util.MainUtil; -import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.image.ImageUtil; import com.sk89q.worldedit.EditSession; @@ -58,17 +52,24 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockType; -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.net.URL; -import java.util.List; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Switch; import org.jetbrains.annotations.Range; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.URL; +import java.util.List; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; +import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; +import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; +import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; + /** * Commands for the generation of shapes and other objects. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java index 1e27040f9..4428615d7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java @@ -1,7 +1,5 @@ package com.sk89q.worldedit.command; -import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; - import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.Caption; @@ -23,7 +21,6 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.internal.annotation.AllowedRegion; import com.sk89q.worldedit.internal.annotation.Time; @@ -43,6 +40,14 @@ import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; +import org.enginehub.piston.annotation.Command; +import org.enginehub.piston.annotation.CommandContainer; +import org.enginehub.piston.annotation.param.Arg; +import org.enginehub.piston.annotation.param.ArgFlag; +import org.enginehub.piston.annotation.param.Switch; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Range; + import java.io.File; import java.lang.ref.Reference; import java.lang.ref.SoftReference; @@ -52,13 +57,8 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.function.Supplier; import javax.annotation.Nullable; -import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.annotation.CommandContainer; -import org.enginehub.piston.annotation.param.Arg; -import org.enginehub.piston.annotation.param.ArgFlag; -import org.enginehub.piston.annotation.param.Switch; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Range; + +import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class HistorySubCommands { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java index 2b390d2fa..6d26d5446 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java @@ -4,13 +4,14 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.util.StringMan; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import org.enginehub.piston.annotation.Command; +import org.enginehub.piston.exception.StopExecutionException; + import java.io.File; import java.util.Locale; import java.util.UUID; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.exception.StopExecutionException; //TODO This class breaks compilation //@CommandContainer diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MethodCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MethodCommands.java index a3aa3b47b..e86f42ea8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MethodCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MethodCommands.java @@ -1,10 +1,11 @@ package com.sk89q.worldedit.command; import com.sk89q.worldedit.command.argument.Arguments; -import java.util.Optional; import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.Key; +import java.util.Optional; + public class MethodCommands { public static String getArguments(InjectedValueAccess context) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java index 98c1a4523..965f0b53c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java @@ -18,9 +18,7 @@ */ package com.sk89q.worldedit.command; -import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; @@ -30,12 +28,14 @@ import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Switch; import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; /** * Commands for moving the player around. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java index d381594b2..a7f0942de 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.command; -import static java.util.Objects.requireNonNull; -import static org.enginehub.piston.part.CommandParts.arg; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.sk89q.worldedit.LocalSession; @@ -46,7 +43,6 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextDecoration; -import java.util.stream.Collectors; import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManagerService; import org.enginehub.piston.CommandParameters; @@ -57,6 +53,11 @@ import org.enginehub.piston.inject.Key; import org.enginehub.piston.part.CommandArgument; import org.enginehub.piston.part.SubCommandPart; +import java.util.stream.Collectors; + +import static java.util.Objects.requireNonNull; +import static org.enginehub.piston.part.CommandParts.arg; + @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class PaintBrushCommands { 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 0e6b19089..42a341fd0 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 @@ -19,14 +19,6 @@ package com.sk89q.worldedit.command; -import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; -import static com.sk89q.worldedit.command.util.Logging.LogMode.ORIENTATION_REGION; -import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; -import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; -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.FaweCache; import com.boydti.fawe.config.Caption; @@ -74,15 +66,23 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.Switch; -import org.jetbrains.annotations.Range; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; +import static com.sk89q.worldedit.command.util.Logging.LogMode.ORIENTATION_REGION; +import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; +import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; +import static com.sk89q.worldedit.regions.Regions.asFlatRegion; +import static com.sk89q.worldedit.regions.Regions.maximumBlockY; +import static com.sk89q.worldedit.regions.Regions.minimumBlockY; /** * Commands that operate on regions. 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 17f1e22b0..95f81c213 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 @@ -19,17 +19,12 @@ package com.sk89q.worldedit.command; -import static com.boydti.fawe.util.ReflectionUtils.as; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.config.Caption; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.schematic.MinecraftStructure; import com.boydti.fawe.util.MainUtil; -import com.boydti.fawe.util.MathMan; import com.google.common.base.Function; import com.google.common.collect.Multimap; import com.sk89q.worldedit.LocalConfiguration; @@ -57,11 +52,21 @@ import com.sk89q.worldedit.util.formatting.component.PaginationBox; import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.io.Closer; import com.sk89q.worldedit.util.io.file.FilenameException; +import org.enginehub.piston.annotation.Command; +import org.enginehub.piston.annotation.CommandContainer; +import org.enginehub.piston.annotation.param.Arg; +import org.enginehub.piston.annotation.param.ArgFlag; +import org.enginehub.piston.annotation.param.Switch; +import org.enginehub.piston.exception.StopExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; @@ -69,8 +74,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; - -import static com.google.common.base.Preconditions.checkArgument; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -86,14 +89,10 @@ import java.util.Map; 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; -import org.enginehub.piston.annotation.param.Arg; -import org.enginehub.piston.annotation.param.ArgFlag; -import org.enginehub.piston.annotation.param.Switch; -import org.enginehub.piston.exception.StopExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import static com.boydti.fawe.util.ReflectionUtils.as; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; //import com.boydti.fawe.object.schematic.visualizer.SchemVis; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ScriptingCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ScriptingCommands.java index 1c1499d22..64df0431e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ScriptingCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ScriptingCommands.java @@ -18,9 +18,7 @@ */ package com.sk89q.worldedit.command; -import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; @@ -28,15 +26,17 @@ import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.entity.Player; - -import java.io.File; -import java.util.List; -import java.util.stream.Stream; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; +import java.io.File; +import java.util.List; +import java.util.stream.Stream; + import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; /** 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 12a5fce77..0850a6f38 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 @@ -19,9 +19,6 @@ package com.sk89q.worldedit.command; -import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; -import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; - import com.boydti.fawe.config.Caption; import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.mask.IdMask; @@ -43,7 +40,6 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.block.BlockDistributionCounter; import com.sk89q.worldedit.function.mask.Mask; @@ -84,11 +80,6 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.storage.ChunkStore; -import java.io.File; -import java.net.URI; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; @@ -96,6 +87,15 @@ import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.Switch; import org.enginehub.piston.exception.StopExecutionException; +import java.io.File; +import java.net.URI; +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + +import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; +import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; + /** * Selection commands. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java index d62905123..e0e5a1ff6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.command; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -31,6 +30,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 33d15e4fd..942684422 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -19,20 +19,18 @@ package com.sk89q.worldedit.command; -import com.google.common.collect.Collections2; - -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.brush.InspectBrush; +import com.google.common.collect.Collections2; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.tool.BlockDataCyler; import com.sk89q.worldedit.command.tool.BlockReplacer; -import com.sk89q.worldedit.command.tool.InvalidToolBindException; import com.sk89q.worldedit.command.tool.DistanceWand; import com.sk89q.worldedit.command.tool.FloatingTreeRemover; import com.sk89q.worldedit.command.tool.FloodFillTool; +import com.sk89q.worldedit.command.tool.InvalidToolBindException; import com.sk89q.worldedit.command.tool.LongRangeBuildTool; import com.sk89q.worldedit.command.tool.NavigationWand; import com.sk89q.worldedit.command.tool.QueryTool; @@ -42,20 +40,21 @@ import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.util.HandSide; -import com.sk89q.worldedit.util.TreeGenerator; -import com.sk89q.worldedit.world.item.ItemType; -import org.enginehub.piston.annotation.Command; import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; import com.sk89q.worldedit.internal.command.CommandUtil; -import org.enginehub.piston.annotation.CommandContainer; -import org.enginehub.piston.annotation.param.Arg; +import com.sk89q.worldedit.util.HandSide; +import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.item.ItemType; import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManagerService; import org.enginehub.piston.CommandMetadata; import org.enginehub.piston.CommandParameters; +import org.enginehub.piston.annotation.Command; +import org.enginehub.piston.annotation.CommandContainer; +import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.part.SubCommandPart; import java.util.Optional; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java index 62295f8d7..ee2301609 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java @@ -20,12 +20,10 @@ package com.sk89q.worldedit.command; import com.boydti.fawe.config.Caption; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.brush.BrushSettings; import com.boydti.fawe.object.brush.TargetMode; import com.boydti.fawe.object.brush.scroll.Scroll; import com.boydti.fawe.object.brush.visualization.VisualMode; -import com.boydti.fawe.object.extent.ResettableExtent; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.StringMan; import com.google.common.collect.Iterables; @@ -45,6 +43,7 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.command.CommandArgParser; import com.sk89q.worldedit.util.HandSide; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; 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 b320dc300..dcfd82663 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 @@ -19,18 +19,14 @@ 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.Caption; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.DelegateConsumer; import com.boydti.fawe.object.function.QuadFunction; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.image.ImageUtil; import com.google.common.base.Function; -import com.google.common.collect.Lists; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalConfiguration; @@ -44,25 +40,23 @@ import com.sk89q.worldedit.command.util.CreatureButcher; import com.sk89q.worldedit.command.util.EntityRemover; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.PrintCommandHelp; +import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.EntityFunction; +import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.visitor.EntityVisitor; import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; - -import java.text.DecimalFormat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CylinderRegion; @@ -70,17 +64,25 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.formatting.component.SubtleFormat; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockTypes; +import org.enginehub.piston.annotation.Command; +import org.enginehub.piston.annotation.CommandContainer; +import org.enginehub.piston.annotation.param.Arg; +import org.enginehub.piston.annotation.param.ArgFlag; +import org.enginehub.piston.annotation.param.Switch; +import org.enginehub.piston.exception.StopExecutionException; + import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.URI; import java.nio.file.Files; +import java.text.DecimalFormat; import java.text.NumberFormat; -import java.util.AbstractMap; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; import java.util.Collections; @@ -93,13 +95,8 @@ import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; import javax.imageio.ImageIO; -import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.annotation.CommandContainer; -import org.enginehub.piston.annotation.param.Arg; -import org.enginehub.piston.annotation.param.ArgFlag; -import org.enginehub.piston.annotation.param.Switch; -import org.enginehub.piston.exception.StopExecutionException; -import org.jetbrains.annotations.Range; + +import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; /** * Utility commands. 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 3287fad18..1d221846f 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 @@ -21,8 +21,6 @@ package com.sk89q.worldedit.command; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweVersion; -import com.sk89q.worldedit.util.formatting.text.Component; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.util.IncendoPaster; import com.sk89q.worldedit.LocalSession; @@ -37,11 +35,18 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.PlatformManager; +import com.sk89q.worldedit.util.formatting.component.MessageBox; +import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; -import com.sk89q.worldedit.util.formatting.text.TextComponent; -import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; -import com.sk89q.worldedit.util.formatting.component.MessageBox; +import org.enginehub.piston.annotation.Command; +import org.enginehub.piston.annotation.CommandContainer; +import org.enginehub.piston.annotation.param.Arg; +import org.enginehub.piston.annotation.param.ArgFlag; +import org.enginehub.piston.annotation.param.Switch; + import java.io.IOException; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -52,11 +57,6 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import java.util.Map; -import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.annotation.CommandContainer; -import org.enginehub.piston.annotation.param.Arg; -import org.enginehub.piston.annotation.param.ArgFlag; -import org.enginehub.piston.annotation.param.Switch; @CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class}) public class WorldEditCommands { @@ -77,7 +77,7 @@ public class WorldEditCommands { public void version(Actor actor) { FaweVersion fVer = Fawe.get().getVersion(); String fVerStr = fVer == null ? "unknown" : "-" + fVer.build; - actor.print(TextComponent.of("FastAsyncWorldEdit" + fVerStr + " created by Empire92")); + actor.print(TextComponent.of("FastAsyncWorldEdit" + fVerStr + " created by Empire92, MattBDev, IronApollo, dordsor21 and NotMyFault")); if (fVer != null) { FaweVersion version = Fawe.get().getVersion(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/AbstractDirectionConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/AbstractDirectionConverter.java index c8342b038..8268a9f90 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/AbstractDirectionConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/AbstractDirectionConverter.java @@ -38,8 +38,8 @@ import org.enginehub.piston.converter.SuccessfulConversion; import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.Key; -import javax.annotation.Nullable; import java.util.List; +import javax.annotation.Nullable; import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix; @@ -56,7 +56,7 @@ public abstract class AbstractDirectionConverter implements ArgumentConverter } protected static void register(CommandManager commandManager, AbstractDirectionConverter converter, - Class keyClass, boolean includeDiagonals) { + Class keyClass, boolean includeDiagonals) { commandManager.registerConverter( Key.of(keyClass, direction(includeDiagonals)), converter diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/Chunk3dVectorConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/Chunk3dVectorConverter.java index bae5ea472..73bbe418c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/Chunk3dVectorConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/Chunk3dVectorConverter.java @@ -51,6 +51,8 @@ public class Chunk3dVectorConverter implements ArgumentConverter { return BlockVector3.at(cmps.get(0), 0, cmps.get(1)); case 3: return BlockVector3.at(cmps.get(0), cmps.get(1), cmps.get(2)); + default: + break; } throw new AssertionError("Expected 2 or 3 components"); }, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/DirectionConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/DirectionConverter.java index d83bc51c6..30dd95eb7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/DirectionConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/DirectionConverter.java @@ -26,8 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Direction; import org.enginehub.piston.CommandManager; -import javax.annotation.Nullable; import java.util.Optional; +import javax.annotation.Nullable; public final class DirectionConverter extends AbstractDirectionConverter { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EnumConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EnumConverter.java index f0f8e8ddd..116d84d77 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EnumConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EnumConverter.java @@ -30,12 +30,11 @@ import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.MultiKeyConverter; import org.enginehub.piston.inject.Key; -import javax.annotation.Nullable; - import java.util.EnumSet; import java.util.Locale; import java.util.Set; import java.util.function.Function; +import javax.annotation.Nullable; public final class EnumConverter { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java index e505b86a8..ae00d0b45 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java @@ -23,7 +23,6 @@ import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.blocks.BaseItem; -import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; @@ -48,10 +47,10 @@ import org.enginehub.piston.converter.SuccessfulConversion; import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.Key; -import javax.annotation.Nullable; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; +import javax.annotation.Nullable; public class FactoryConverter implements ArgumentConverter { @@ -64,22 +63,22 @@ public class FactoryConverter implements ArgumentConverter { new FactoryConverter<>(worldEdit, WorldEdit::getItemFactory, "item", null)); commandManager.registerConverter(Key.of(Mask.class, ClipboardMask.class), - new FactoryConverter<>(worldEdit, WorldEdit::getMaskFactory, "mask", - context -> { - try { - ClipboardHolder holder = context.getSession().getClipboard(); - Transform transform = holder.getTransform(); - Extent target; - if (transform.isIdentity()) { - target = holder.getClipboard(); - } else { - target = new BlockTransformExtent(holder.getClipboard(), transform); - } - context.setExtent(target); - } catch (EmptyClipboardException e) { - throw new IllegalStateException(e); - } - })); + new FactoryConverter<>(worldEdit, WorldEdit::getMaskFactory, "mask", + context -> { + try { + ClipboardHolder holder = context.getSession().getClipboard(); + Transform transform = holder.getTransform(); + Extent target; + if (transform.isIdentity()) { + target = holder.getClipboard(); + } else { + target = new BlockTransformExtent(holder.getClipboard(), transform); + } + context.setExtent(target); + } catch (EmptyClipboardException e) { + throw new IllegalStateException(e); + } + })); } private final WorldEdit worldEdit; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java index 085ce0cb9..2efa359c1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java @@ -62,7 +62,8 @@ public final class RegistryConverter implements ArgumentConvert FluidCategory.class, GameMode.class, WeatherType.class - ).stream() + ) + .stream() .map(c -> (Class) c) .forEach(registryType -> commandManager.registerConverter(Key.of(registryType), from(registryType)) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/SideEffectConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/SideEffectConverter.java index fd0ab684f..17f8b05ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/SideEffectConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/SideEffectConverter.java @@ -19,11 +19,7 @@ package com.sk89q.worldedit.command.argument; -import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix; - -import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.command.util.EntityRemover; import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; @@ -39,6 +35,8 @@ import java.util.Collection; import java.util.List; import java.util.Locale; +import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix; + public class SideEffectConverter implements ArgumentConverter { public static void register(CommandManager commandManager) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ItemUseFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ItemUseFactory.java index 7ad8866c3..b144a14a6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ItemUseFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ItemUseFactory.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.command.factory; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.blocks.BaseItem; -import com.sk89q.worldedit.function.ItemUseFunction; import com.sk89q.worldedit.function.Contextual; import com.sk89q.worldedit.function.EditContext; +import com.sk89q.worldedit.function.ItemUseFunction; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.World; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ReplaceFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ReplaceFactory.java index fa09c8911..4c1797b52 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ReplaceFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/factory/ReplaceFactory.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.command.factory; -import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; - import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.Contextual; import com.sk89q.worldedit.function.EditContext; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.pattern.Pattern; +import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; + public class ReplaceFactory implements Contextual { private final Pattern fill; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java index a3ece0f7e..07f1d2144 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.command.tool; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.google.common.collect.Lists; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; @@ -30,8 +29,10 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; @@ -39,6 +40,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import javax.annotation.Nullable; /** * A mode that cycles the data values of supported blocks. @@ -50,7 +52,7 @@ public class BlockDataCyler implements DoubleActionBlockTool { return player.hasPermission("worldedit.tool.data-cycler"); } - private Map> selectedProperties = new HashMap<>(); + private final Map> selectedProperties = new HashMap<>(); private boolean handleCycle(LocalConfiguration config, Player player, LocalSession session, Location clicked, boolean forward) { @@ -85,7 +87,7 @@ public class BlockDataCyler implements DoubleActionBlockTool { Property objProp = (Property) currentProperty; BlockState newBlock = block.with(objProp, currentProperty.getValues().get(index)); - try (EditSession editSession = session.createEditSession(player, "BlockDataCyler")) { + try (EditSession editSession = session.createEditSession(player)) { editSession.disableBuffering(); try { @@ -115,12 +117,12 @@ public class BlockDataCyler implements DoubleActionBlockTool { } @Override - public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { + public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) { return handleCycle(config, player, session, clicked, true); } @Override - public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { + public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) { return handleCycle(config, player, session, clicked, false); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockTool.java index 0ee513d75..df1b71903 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockTool.java @@ -23,19 +23,47 @@ import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Platform; +import com.sk89q.worldedit.internal.util.DeprecationUtil; +import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; +import javax.annotation.Nullable; + public interface BlockTool extends Tool { /** * Perform the primary action of this tool. * - * @param server - * @param config - * @param player - * @param session - * @param clicked * @return true to cancel the original event which triggered this action (if possible) + * @deprecated New subclasses should override + * {@link #actPrimary(Platform, LocalConfiguration, Player, LocalSession, Location, Direction)} + * instead */ - boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked); + @Deprecated + default boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { + return actPrimary(server, config, player, session, clicked, null); + } + + /** + * Perform the primary action of this tool. + * + * @param server The platform + * @param config The config instance + * @param player The player + * @param session The local session + * @param clicked The location that was clicked + * @param face The face that was clicked + * @return true to cancel the original event which triggered this action (if possible) + * @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility} + * for details + */ + @NonAbstractForCompatibility( + delegateName = "actPrimary", + delegateParams = { Platform.class, LocalConfiguration.class, Player.class, LocalSession.class, Location.class } + ) + default boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) { + DeprecationUtil.checkDelegatingOverride(getClass()); + return actPrimary(server, config, player, session, clicked); + } } 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 529580d35..41e7ad63a 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 @@ -19,14 +19,11 @@ package com.sk89q.worldedit.command.tool; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.implementation.IChunkExtent; import com.boydti.fawe.beta.implementation.processors.NullProcessor; import com.boydti.fawe.beta.implementation.processors.PersistentChunkSendProcessor; import com.boydti.fawe.config.Caption; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.brush.BrushSettings; import com.boydti.fawe.object.brush.MovableTool; import com.boydti.fawe.object.brush.ResettableTool; @@ -43,7 +40,6 @@ import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.MaskTraverser; import com.boydti.fawe.util.StringMan; -import com.google.gson.Gson; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -65,31 +61,36 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockType; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.function.Supplier; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Builds a shape at the place being looked at. */ -public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool, ResettableTool, Serializable { -// TODO: +public class BrushTool + implements DoubleActionTraceTool, ScrollTool, MovableTool, ResettableTool, Serializable { + // TODO: // Serialize methods // serialize BrushSettings (primary and secondary only if different) // set transient values e.g., context + public enum BrushAction { - PRIMARY, - SECONDARY + PRIMARY, SECONDARY } + protected static int MAX_RANGE = 500; protected static int DEFAULT_RANGE = 240; // 500 is laggy as the default protected int range = -1; @@ -108,7 +109,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Construct the tool. - * + * * @param permission the permission to check before use is allowed */ public BrushTool(String permission) { @@ -126,7 +127,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool public boolean isSet() { return primary.getBrush() != null || secondary.getBrush() != null; } - + public void update() { if (holder != null) { BrushCache.setTool(holder, this); @@ -210,7 +211,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Get the filter. - * + * * @return the filter */ public Mask getMask() { @@ -238,7 +239,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Set the block filter used for identifying blocks to replace. - * + * * @param filter the filter to set */ public void setMask(Mask filter) { @@ -251,7 +252,8 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool * * @return the mask used to stop block traces */ - public @Nullable Mask getTraceMask() { + @Nullable + public Mask getTraceMask() { return this.traceMask; } @@ -277,8 +279,8 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Set the brush. - * - * @param brush tbe brush + * + * @param brush tbe brush * @param permission the permission */ public void setBrush(Brush brush, String permission) { @@ -291,7 +293,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Get the current brush. - + * * @return the current brush */ public Brush getBrush() { @@ -300,7 +302,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Set the material. - * + * * @param material the material */ public void setFill(@Nullable Pattern material) { @@ -312,13 +314,14 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool * * @return the material */ - @Nullable public Pattern getMaterial() { + @Nullable + public Pattern getMaterial() { return getContext().getMaterial(); } /** * Get the set brush size. - * + * * @return a radius */ public double getSize() { @@ -327,7 +330,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Set the set brush size. - * + * * @param radius a radius */ public void setSize(double radius) { @@ -345,7 +348,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Get the set brush range. - * + * * @return the range of the brush in blocks */ public int getRange() { @@ -354,7 +357,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool /** * Set the set brush range. - * + * * @param range the range of the brush in blocks */ public void setRange(int range) { @@ -362,9 +365,10 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool } @Override - public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { + public boolean actPrimary(Platform server, LocalConfiguration config, Player player, + LocalSession session) { return act(BrushAction.PRIMARY, player, session); - } + } public BlockVector3 getPosition(EditSession editSession, Player player) { Location loc = player.getLocation(); @@ -376,7 +380,8 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool float pitch = loc.getPitch(); pitch = 23 - (pitch / 4); d += (int) (Math.sin(Math.toRadians(pitch)) * 50); - final Vector3 vector = loc.getDirection().withY(0).normalize().multiply(d).add(loc.getX(), loc.getY(), loc.getZ()); + final Vector3 vector = loc.getDirection().withY(0).normalize().multiply(d) + .add(loc.getX(), loc.getY(), loc.getZ()); return offset(vector, loc).toBlockPoint(); } case TARGET_POINT_HEIGHT: { @@ -401,7 +406,9 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool } private Vector3 offset(Vector3 target, Vector3 playerPos) { - if (targetOffset == 0) return target; + if (targetOffset == 0) { + return target; + } return target.subtract(target.subtract(playerPos).normalize().multiply(targetOffset)); } @@ -420,13 +427,18 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool case SECONDARY: setContext(secondary); break; + default: + throw new IllegalStateException("Unexpected value: " + action); } BrushSettings current = getContext(); Brush brush = current.getBrush(); - if (brush == null) return false; + if (brush == null) { + return false; + } if (!current.canUse(player)) { - player.print(Caption.of("fawe.error.no-perm" , StringMan.join(current.getPermissions(), ","))); + player.print( + Caption.of("fawe.error.no-perm", StringMan.join(current.getPermissions(), ","))); return false; } try (EditSession editSession = session.createEditSession(player, current.toString())) { @@ -484,7 +496,8 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool } @Override - public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) { + public boolean actSecondary(Platform server, LocalConfiguration config, Player player, + LocalSession session) { return act(BrushAction.SECONDARY, player, session); } @@ -506,7 +519,9 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool } public void setVisualMode(Player player, VisualMode visualMode) { - if (visualMode == null) visualMode = VisualMode.NONE; + if (visualMode == null) { + visualMode = VisualMode.NONE; + } if (this.visualMode != visualMode) { if (this.visualMode != VisualMode.NONE) { clear(player); @@ -563,31 +578,31 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool } @Deprecated - public synchronized void visualize(BrushTool.BrushAction action, Player player) throws WorldEditException { + public synchronized void visualize(BrushTool.BrushAction action, Player player) + throws WorldEditException { VisualMode mode = getVisualMode(); if (mode == VisualMode.NONE) { return; } BrushSettings current = getContext(); Brush brush = current.getBrush(); - if (brush == null) return; + if (brush == null) { + return; + } - EditSessionBuilder builder = new EditSessionBuilder(player.getWorld()) - .command(current.toString()) - .player(player) - .allowedRegionsEverywhere() - .autoQueue(false) - .blockBag(null) - .changeSetNull() - .fastmode(true) - .combineStages(true); + EditSessionBuilder builder = + new EditSessionBuilder(player.getWorld()).command(current.toString()).player(player) + .allowedRegionsEverywhere().autoQueue(false).blockBag(null).changeSetNull() + .fastmode(true).combineStages(true); EditSession editSession = builder.build(); World world = editSession.getWorld(); Supplier> players = () -> Collections.singleton(player); - PersistentChunkSendProcessor newVisualExtent = new PersistentChunkSendProcessor(world, this.visualExtent, players); - ExtentTraverser traverser = new ExtentTraverser<>(editSession).find(IChunkExtent.class); + PersistentChunkSendProcessor newVisualExtent = + new PersistentChunkSendProcessor(world, this.visualExtent, players); + ExtentTraverser traverser = + new ExtentTraverser<>(editSession).find(IChunkExtent.class); if (traverser == null) { throw new IllegalStateException("No queue found"); } @@ -612,6 +627,8 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool brush.build(editSession, position, current.getMaterial(), current.getSize()); break; } + default: + throw new IllegalStateException("Unexpected value: " + mode); } } editSession.flushQueue(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java index 642a8c4aa..7da2cb39f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DistanceWand.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.command.tool; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.entity.Player; @@ -29,6 +28,7 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; /** * A wand that can be used at a distance. @@ -42,7 +42,9 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool { @Override public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) { Location target = getTarget(player); - if (target == null) return true; + if (target == null) { + return true; + } RegionSelector selector = session.getRegionSelector(player.getWorld()); BlockVector3 blockPoint = target.toVector().toBlockPoint(); @@ -55,7 +57,9 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool { @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { Location target = getTarget(player); - if (target == null) return true; + if (target == null) { + return true; + } RegionSelector selector = session.getRegionSelector(player.getWorld()); BlockVector3 blockPoint = target.toVector().toBlockPoint(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DoubleActionBlockTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DoubleActionBlockTool.java index f2c37e99f..2bb58bf7f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DoubleActionBlockTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DoubleActionBlockTool.java @@ -23,8 +23,13 @@ import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Platform; +import com.sk89q.worldedit.internal.util.DeprecationUtil; +import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; +import javax.annotation.Nullable; + /** * Represents a block tool that also has a secondary/primary function. */ @@ -33,13 +38,36 @@ public interface DoubleActionBlockTool extends BlockTool { /** * Perform the secondary action of this block tool. * - * @param server - * @param config - * @param player - * @param session - * @param clicked * @return true to cancel the original event which triggered this action (if possible) + * @deprecated New subclasses must override + * {@link #actSecondary(Platform, LocalConfiguration, Player, LocalSession, Location, Direction)} + * instead */ - boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked); + @Deprecated + default boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { + return actSecondary(server, config, player, session, clicked, null); + } + + /** + * Perform the secondary action of this block tool. + * + * @param server The platform + * @param config The config instance + * @param player The player + * @param session The local session + * @param clicked The location that was clicked + * @param face The face that was clicked + * @return true to cancel the original event which triggered this action (if possible) + * @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility} + * for details + */ + @NonAbstractForCompatibility( + delegateName = "actSecondary", + delegateParams = { Platform.class, LocalConfiguration.class, Player.class, LocalSession.class, Location.class } + ) + default boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) { + DeprecationUtil.checkDelegatingOverride(getClass()); + return actSecondary(server, config, player, session, clicked); + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DoubleActionTraceTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DoubleActionTraceTool.java index 1c9b6f83f..491c758c0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DoubleActionTraceTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/DoubleActionTraceTool.java @@ -32,10 +32,10 @@ public interface DoubleActionTraceTool extends TraceTool { /** * Perform the secondary function of this tool. * - * @param server - * @param config - * @param player - * @param session + * @param server The platform + * @param config The config instance + * @param player The player + * @param session The local session * @return true to cancel the original event which triggered this action (if possible) */ boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java index 3d299f456..c3b5f6d58 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java @@ -19,9 +19,7 @@ package com.sk89q.worldedit.command.tool; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.collection.LocalBlockVectorSet; - import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -32,24 +30,26 @@ import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import org.jetbrains.annotations.Nullable; import java.util.Iterator; import java.util.Set; /** * A pickaxe mode that removes floating treetops (logs and leaves not connected - * to anything else) + * to anything else). */ public class FloatingTreeRemover implements BlockTool { - private int rangeSq; + private final int rangeSq; public FloatingTreeRemover() { - rangeSq = 100*100; + rangeSq = 100 * 100; } @Override @@ -68,7 +68,8 @@ public class FloatingTreeRemover implements BlockTool { @Override public boolean actPrimary(Platform server, LocalConfiguration config, - Player player, LocalSession session, Location clicked) { + Player player, LocalSession session, Location clicked, + @Nullable Direction face) { final World world = (World) clicked.getExtent(); final BlockState state = world.getBlock(clicked.toVector().toBlockPoint()); @@ -102,7 +103,7 @@ public class FloatingTreeRemover implements BlockTool { return true; } - private BlockVector3[] recurseDirections = { + private final BlockVector3[] recurseDirections = { Direction.NORTH.toBlockVector(), Direction.EAST.toBlockVector(), Direction.SOUTH.toBlockVector(), @@ -139,7 +140,8 @@ public class FloatingTreeRemover implements BlockTool { if (visited.add(next)) { BlockState state = world.getBlock(next); - if (state.getBlockType().getMaterial().isAir() || state.getBlockType() == BlockTypes.SNOW) { + if (state.getBlockType().getMaterial().isAir() + || state.getBlockType() == BlockTypes.SNOW) { continue; } if (isTreeBlock(state.getBlockType())) { @@ -147,7 +149,8 @@ public class FloatingTreeRemover implements BlockTool { } else { // we hit something solid - evaluate where we came from final BlockType currentType = world.getBlock(current).getBlockType(); - if (!BlockCategories.LEAVES.contains(currentType) && currentType != BlockTypes.VINE) { + if (!BlockCategories.LEAVES.contains(currentType) + && currentType != BlockTypes.VINE) { // log/shroom touching a wall/the ground => this is not a floating tree, bail out return null; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java index 10e1468e7..742f24bd6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java @@ -32,11 +32,13 @@ import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import org.jetbrains.annotations.Nullable; import java.util.Set; @@ -45,8 +47,8 @@ import java.util.Set; */ public class FloodFillTool implements BlockTool { - private int range; - private Pattern pattern; + private final int range; + private final Pattern pattern; public FloodFillTool(int range, Pattern pattern) { this.range = range; @@ -59,7 +61,7 @@ public class FloodFillTool implements BlockTool { } @Override - public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { + public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) { World world = (World) clicked.getExtent(); BlockVector3 origin = clicked.toVector().toBlockPoint(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java index 11532d04a..71b0a2f1c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.command.tool; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -32,6 +31,7 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.block.BaseBlock; /** @@ -39,8 +39,8 @@ import com.sk89q.worldedit.world.block.BaseBlock; */ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTool { - private Pattern primary; - private Pattern secondary; + private final Pattern primary; + private final Pattern secondary; public LongRangeBuildTool(Pattern secondary, Pattern primary) { super("worldedit.tool.lrbuild"); @@ -56,7 +56,9 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo @Override public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) { Location pos = getTargetFace(player); - if (pos == null) return false; + if (pos == null) { + return false; + } BlockBag bag = session.getBlockBag(player); try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) { @@ -84,7 +86,9 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { Location pos = getTargetFace(player); - if (pos == null) return false; + if (pos == null) { + return false; + } BlockBag bag = session.getBlockBag(player); try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java index 13477713c..2a3f0b145 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java @@ -27,6 +27,7 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.internal.block.BlockStateIdAccess; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; @@ -35,8 +36,7 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.registry.LegacyMapper; - -import java.util.OptionalInt; +import org.jetbrains.annotations.Nullable; /** * Looks up information about a block. @@ -49,7 +49,8 @@ public class QueryTool implements BlockTool { } @Override - public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { + public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable + Direction face) { World world = (World) clicked.getExtent(); EditSession editSession = session.createEditSession(player); @@ -60,21 +61,21 @@ public class QueryTool implements BlockTool { builder.append(TextComponent.of("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE)); builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW)); builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY) - .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.blockstate.hover")))); + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.blockstate.hover")))); final int internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState()); if (BlockStateIdAccess.isValidInternalId(internalId)) { - builder.append(TextComponent.of(" (" + internalId+ ") ", TextColor.DARK_GRAY) - .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.internalid.hover")))); + builder.append(TextComponent.of(" (" + internalId + ") ", TextColor.DARK_GRAY) + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.internalid.hover")))); } final int[] legacy = LegacyMapper.getInstance().getLegacyFromBlock(block.toImmutableState()); if (legacy != null) { builder.append(TextComponent.of(" (" + legacy[0] + ":" + legacy[1] + ") ", TextColor.DARK_GRAY) - .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.legacy.hover")))); + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.legacy.hover")))); } builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/" - + world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE) - .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.light.hover")))); + + world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE) + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.light.hover")))); player.print(builder.build()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java index a5077f94c..5731eccc4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java @@ -28,14 +28,14 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.function.block.BlockReplace; -import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import org.jetbrains.annotations.Nullable; import java.util.Set; @@ -45,7 +45,7 @@ import java.util.Set; */ public class RecursivePickaxe implements BlockTool { - private double range; + private final double range; public RecursivePickaxe(double range) { this.range = range; @@ -57,7 +57,7 @@ public class RecursivePickaxe implements BlockTool { } @Override - public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { + public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) { World world = (World) clicked.getExtent(); final BlockVector3 pos = clicked.toBlockPoint(); @@ -94,7 +94,7 @@ public class RecursivePickaxe implements BlockTool { BlockVector3 origin, double size, BlockType initialType, Set visited) throws MaxChangedBlocksException { final double distanceSq = origin.distanceSq(pos); - if (distanceSq > size*size || visited.contains(pos)) { + if (distanceSq > size * size || visited.contains(pos)) { return; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java index c20641a05..5f2f2775b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; -import com.sk89q.worldedit.extension.platform.PlatformManager; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.RegionSelector; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/Tool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/Tool.java index 2ed73209f..eaa949643 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/Tool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/Tool.java @@ -30,7 +30,7 @@ public interface Tool { /** * Checks to see if the player can still be using this tool (considering * permissions and such). - * + * * @param actor the actor * @return true if use is permitted */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TraceTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TraceTool.java index 6f18e2c71..ff7d29519 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TraceTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TraceTool.java @@ -29,10 +29,10 @@ public interface TraceTool extends Tool { /** * Perform the primary action of this trace tool. * - * @param server - * @param config - * @param player - * @param session + * @param server The platform + * @param config The config instance + * @param player The player + * @param session The local session * @return true to cancel the original event which triggered this action (if possible) */ boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java index c066c7d10..c714f04a3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java @@ -31,12 +31,12 @@ public interface Brush { /** * Build the object. - * + * * @param editSession the {@code EditSession} * @param position the position * @param pattern the pattern * @param size the size of the brush - * @throws MaxChangedBlocksException + * @throws MaxChangedBlocksException if the maximum block change limit is exceeded */ void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java index 69b64a037..08b26a09c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java @@ -23,12 +23,6 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.util.LocatedBlock; - -import java.util.LinkedHashSet; -import java.util.Set; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.util.collection.LocatedBlockList; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java index 80622c37d..c521d43d5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java @@ -33,10 +33,10 @@ import com.sk89q.worldedit.util.task.FutureForwardingTask; import com.sk89q.worldedit.util.task.Supervisor; import org.enginehub.piston.exception.CommandException; import org.enginehub.piston.exception.CommandExecutionException; +import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; import java.util.concurrent.Callable; import java.util.function.Consumer; @@ -133,6 +133,7 @@ public final class AsyncCommandBuilder { return future; } + @SuppressWarnings("deprecation") private T runTask() { T result = null; try { @@ -183,6 +184,7 @@ public final class AsyncCommandBuilder { // com.sk89q.minecraft.util.commands.CommandException. the ExceptionConverter currently expects converted // exceptions to be org.enginehub.piston.CommandException, throw it wraps the resulting InvocationTargetException in // a CommandExecutionException. here, we unwrap those layers to retrieve the original WG error message + @SuppressWarnings("deprecation") private Component tryExtractOldCommandException(CommandException converted) { Component message = null; if (converted instanceof CommandExecutionException) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CreatureButcher.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CreatureButcher.java index e43fee9d4..15b981323 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CreatureButcher.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CreatureButcher.java @@ -51,7 +51,9 @@ public class CreatureButcher { } public void or(int flag, boolean on) { - if (on) flags |= flag; + if (on) { + flags |= flag; + } } public void or(int flag, boolean on, String permission) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/EntityRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/EntityRemover.java index e59811b68..d78dc5725 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/EntityRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/EntityRemover.java @@ -23,8 +23,8 @@ import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.entity.metadata.EntityProperties; import com.sk89q.worldedit.function.EntityFunction; -import javax.annotation.Nullable; import java.util.regex.Pattern; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/FutureProgressListener.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/FutureProgressListener.java index 3a47679a6..f51ad710b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/FutureProgressListener.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/FutureProgressListener.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.command.util; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.sk89q.worldedit.extension.platform.Actor; @@ -29,6 +27,8 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import java.util.Timer; +import static com.google.common.base.Preconditions.checkNotNull; + public class FutureProgressListener implements Runnable { private static final Timer timer = new Timer(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/Logging.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/Logging.java index ec256f16e..89d91ffbf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/Logging.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/Logging.java @@ -33,27 +33,27 @@ public @interface Logging { enum LogMode { /** - * Player position + * Player position. */ POSITION, /** - * Region selection + * Region selection. */ REGION, /** - * Player orientation and region selection + * Player orientation and region selection. */ ORIENTATION_REGION, /** - * Either the player position or pos1, depending on the placeAtPos1 flag + * Either the player position or pos1, depending on the placeAtPos1 flag. */ PLACEMENT, /** - * Log all information available + * Log all information available. */ ALL } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/MessageTimerTask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/MessageTimerTask.java index fa12e40be..f4f0fc89d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/MessageTimerTask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/MessageTimerTask.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.command.util; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import java.util.TimerTask; +import static com.google.common.base.Preconditions.checkNotNull; + public class MessageTimerTask extends TimerTask { private final Actor sender; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PermissionCondition.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PermissionCondition.java index a1ce3abda..bcf22c4cc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PermissionCondition.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PermissionCondition.java @@ -48,8 +48,8 @@ public class PermissionCondition implements Command.Condition { @Override public boolean satisfied(InjectedValueAccess context) { - return permissions.isEmpty() || - context.injectedValue(ACTOR_KEY) + return permissions.isEmpty() + || context.injectedValue(ACTOR_KEY) .map(actor -> permissions.stream().anyMatch(actor::hasPermission)) .orElse(false); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PrintCommandHelp.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PrintCommandHelp.java index ca7f3a394..0ee502b36 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PrintCommandHelp.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/PrintCommandHelp.java @@ -19,10 +19,6 @@ package com.sk89q.worldedit.command.util; -import static com.sk89q.worldedit.internal.command.CommandUtil.byCleanName; -import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands; -import static java.util.stream.Collectors.toList; - import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; @@ -42,6 +38,10 @@ import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.sk89q.worldedit.internal.command.CommandUtil.byCleanName; +import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands; +import static java.util.stream.Collectors.toList; + /** * Implementation of the //help command. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/WorldEditAsyncCommandBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/WorldEditAsyncCommandBuilder.java index 901c461fc..64c763d9d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/WorldEditAsyncCommandBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/WorldEditAsyncCommandBuilder.java @@ -24,8 +24,8 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; -import javax.annotation.Nullable; import java.util.concurrent.Callable; +import javax.annotation.Nullable; /** * For internal WorldEdit use only. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java index f134e1c1f..7d5c26fb7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java @@ -1,7 +1,6 @@ package com.sk89q.worldedit.command.util.annotation; import com.boydti.fawe.config.Caption; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.util.task.InterruptableCondition; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.WorldEdit; @@ -15,6 +14,7 @@ import com.sk89q.worldedit.internal.util.Substring; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import org.enginehub.piston.exception.StopExecutionException; import org.enginehub.piston.inject.InjectAnnotation; import org.enginehub.piston.inject.InjectedValueAccess; @@ -33,7 +33,10 @@ import java.util.stream.Stream; * Indicates how the affected blocks should be hinted at in the log. */ @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.PARAMETER, ElementType.METHOD}) +@Target({ + ElementType.PARAMETER, + ElementType.METHOD + }) @InjectAnnotation public @interface Confirm { Processor value() default Processor.ALWAYS; @@ -45,10 +48,11 @@ public @interface Confirm { Region region = context.injectedValue(Key.of(Region.class, Selection.class)).orElseThrow(IncompleteRegionException::new); BlockVector3 pos1 = region.getMinimumPoint(); BlockVector3 pos2 = region.getMaximumPoint(); - long area = (pos2.getX() - pos1.getX()) * (pos2.getZ() - pos1.getZ() + 1) * (long) value; + long area = (pos2.getX() - pos1.getX()) * (pos2.getZ() - pos1.getZ() + 1) + * (long) value; long max = 2 << 18; if (max != -1 && area > max) { - actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , pos1, pos2, getArgs(context))); + actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region", pos1, pos2, getArgs(context))); return confirm(actor, context); } return true; @@ -59,7 +63,7 @@ public @interface Confirm { public boolean passes(Actor actor, InjectedValueAccess context, double value) { int max = WorldEdit.getInstance().getConfiguration().maxRadius; if (max != -1 && value > max) { - actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context))); + actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region", value, max, getArgs(context))); return Processor.confirm(actor, context); } return true; @@ -68,9 +72,9 @@ public @interface Confirm { LIMIT { @Override public boolean passes(Actor actor, InjectedValueAccess context, double value) { - int max = 50;// TODO configurable, get Key.of(Method.class) @Limit + int max = 50; //TODO configurable, get Key.of(Method.class) @Limit if (max != -1 && value > max) { - actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context))); + actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region", value, max, getArgs(context))); return Processor.confirm(actor, context); } return true; @@ -82,10 +86,11 @@ public @interface Confirm { actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm")); return confirm(actor, context); } - } - ; + }; - public boolean passes(Actor actor, InjectedValueAccess context, double value){return true;} + public boolean passes(Actor actor, InjectedValueAccess context, double value) { + return true; + } public T check(Actor actor, InjectedValueAccess context, T value) { if (!passes(actor, context, value.doubleValue())) { @@ -125,8 +130,8 @@ public @interface Confirm { if (condition.await(15, TimeUnit.SECONDS)) { return true; } - } catch (InterruptedException e) {} - finally { + } catch (InterruptedException ignored) { + } finally { if (actor.getMeta("cmdConfirm") == wait) { actor.deleteMeta("cmdConfirm"); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java index 642565ef8..b34b593c5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.entity; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.util.Location; @@ -30,6 +28,8 @@ import com.sk89q.worldedit.world.entity.EntityTypes; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents a mutable "snapshot" of an entity. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Entity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Entity.java index b82be020d..56e1097d6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Entity.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Entity.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.util.Faceted; import com.sk89q.worldedit.world.entity.EntityType; + import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/LazyBaseEntity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/LazyBaseEntity.java index ff34d8627..35fb2de7a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/LazyBaseEntity.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/LazyBaseEntity.java @@ -5,8 +5,8 @@ import com.boydti.fawe.util.TaskManager; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.world.entity.EntityType; -import javax.annotation.Nullable; import java.util.function.Supplier; +import javax.annotation.Nullable; public class LazyBaseEntity extends BaseEntity { private Supplier saveTag; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/MapMetadatable.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/MapMetadatable.java index efa807c7a..6cedcb415 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/MapMetadatable.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/MapMetadatable.java @@ -1,8 +1,9 @@ package com.sk89q.worldedit.entity; -import java.util.Map; import org.jetbrains.annotations.NotNull; +import java.util.Map; + public interface MapMetadatable extends Metadatable { Map getRawMeta(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java index 32f49f891..329586fe2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java @@ -25,7 +25,6 @@ import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.MainUtil; -import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; @@ -36,12 +35,13 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.internal.util.DeprecationUtil; +import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; @@ -51,9 +51,8 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.gamemode.GameMode; -import javax.annotation.Nullable; import java.io.File; -import java.io.IOException; +import javax.annotation.Nullable; /** * Represents a player @@ -301,8 +300,40 @@ public interface Player extends Entity, Actor { * @param pos where to move them * @param pitch the pitch (up/down) of the player's view in degrees * @param yaw the yaw (left/right) of the player's view in degrees + * @deprecated This method may fail without indication. Use + * {@link #trySetPosition(Vector3, float, float)} instead */ - void setPosition(Vector3 pos, float pitch, float yaw); + @Deprecated + default void setPosition(Vector3 pos, float pitch, float yaw) { + trySetPosition(pos, pitch, yaw); + } + + /** + * Attempt to move the player. + * + *

+ * This action may fail, due to other mods cancelling the move. + * If so, this method will return {@code false}. + *

+ * + * @param pos where to move them + * @param pitch the pitch (up/down) of the player's view in degrees + * @param yaw the yaw (left/right) of the player's view in degrees + * @return if the move was able to occur + * @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility} + * for details + */ + @NonAbstractForCompatibility( + delegateName = "setPosition", + delegateParams = { Vector3.class, float.class, float.class } + ) + default boolean trySetPosition(Vector3 pos, float pitch, float yaw) { + DeprecationUtil.checkDelegatingOverride(getClass()); + + setPosition(pos, pitch, yaw); + + return true; + } /** * Sends a fake block to the client. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/Event.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/Event.java index bce9eac7a..70d765390 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/Event.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/Event.java @@ -27,7 +27,7 @@ import com.sk89q.worldedit.WorldEdit; public abstract class Event { /** - * Returns true if this event was called and not cancelled + * Returns true if this event was called and not cancelled. * @return !isCancelled */ public boolean call() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/ActorSaveClipboardEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/ActorSaveClipboardEvent.java index 929c3b6aa..fdc84e369 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/ActorSaveClipboardEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/ActorSaveClipboardEvent.java @@ -1,6 +1,5 @@ package com.sk89q.worldedit.event.extent; -import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.Cancellable; import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extension.platform.Actor; @@ -11,7 +10,8 @@ import java.net.URI; public class ActorSaveClipboardEvent extends Event implements Cancellable { private final Actor actor; private final Clipboard clipboard; - private final URI source, destination; + private final URI source; + private final URI destination; private boolean cancelled; public ActorSaveClipboardEvent(Actor actor, Clipboard clipboard, URI source, URI destination) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java index 7b4cd9995..a6906f885 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java @@ -19,9 +19,7 @@ package com.sk89q.worldedit.event.extent; -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.EditSession; -import static com.sk89q.worldedit.EditSession.Stage; import com.sk89q.worldedit.event.Cancellable; import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extension.platform.Actor; @@ -32,6 +30,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.EditSession.Stage; + /** * Raised (several times) when a new {@link EditSession} is being instantiated. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java index 45f74c4b9..1b52bf26c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java @@ -19,16 +19,17 @@ package com.sk89q.worldedit.event.extent; -import static com.sk89q.worldedit.EditSession.Stage; - import com.sk89q.worldedit.event.Cancellable; import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; + import java.net.URI; +import static com.sk89q.worldedit.EditSession.Stage; + public class PasteEvent extends Event implements Cancellable { private final Actor actor; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/BlockInteractEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/BlockInteractEvent.java index 7549518ad..3e6890e51 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/BlockInteractEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/BlockInteractEvent.java @@ -19,13 +19,16 @@ package com.sk89q.worldedit.event.platform; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.event.Cancellable; import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; + /** * Called when a block is interacted with. */ @@ -34,6 +37,7 @@ public class BlockInteractEvent extends Event implements Cancellable { private final Actor cause; private final Location location; private final Interaction type; + private final Direction face; private boolean cancelled; /** @@ -43,12 +47,26 @@ public class BlockInteractEvent extends Event implements Cancellable { * @param location the location of the block * @param type the type of interaction */ + @Deprecated public BlockInteractEvent(Actor cause, Location location, Interaction type) { + this(cause, location, null, type); + } + + /** + * Create a new event. + * + * @param cause the causing actor + * @param location the location of the block + * @param face the face of the block that was interacted with + * @param type the type of interaction + */ + public BlockInteractEvent(Actor cause, Location location, @Nullable Direction face, Interaction type) { checkNotNull(cause); checkNotNull(location); checkNotNull(type); this.cause = cause; this.location = location; + this.face = face; this.type = type; } @@ -70,6 +88,16 @@ public class BlockInteractEvent extends Event implements Cancellable { return location; } + /** + * Get the face of the block that was interacted with. + * + * @return The interacted face + */ + @Nullable + public Direction getFace() { + return face; + } + /** * Get the type of interaction. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/CommandSuggestionEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/CommandSuggestionEvent.java index 09f070f42..709bcc49c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/CommandSuggestionEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/CommandSuggestionEvent.java @@ -18,6 +18,7 @@ */ package com.sk89q.worldedit.event.platform; + import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.util.Substring; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/ConfigurationLoadEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/ConfigurationLoadEvent.java index 1bfc11724..73d23131c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/ConfigurationLoadEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/ConfigurationLoadEvent.java @@ -19,11 +19,11 @@ package com.sk89q.worldedit.event.platform; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.event.Event; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Raised when the configuration has been loaded or re-loaded. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/PlayerInputEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/PlayerInputEvent.java index 67ef25268..2bc39ee97 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/PlayerInputEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/PlayerInputEvent.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.event.platform; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.Cancellable; import com.sk89q.worldedit.event.Event; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Raised whenever a player sends input. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java index d11c479d9..2f7b040bb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java @@ -20,7 +20,27 @@ package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extension.factory.parser.mask.*; +import com.sk89q.worldedit.extension.factory.parser.mask.AirMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.AngleMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.BiomeMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.BlockStateMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.BlocksMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.FalseMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.LiquidMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.NegateMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.OffsetMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.SimplexMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.TrueMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.XAxisMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.YAxisMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.ZAxisMaskParser; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.NoMatchException; import com.sk89q.worldedit.extension.input.ParserContext; @@ -69,7 +89,8 @@ public final class MaskFactory extends AbstractFactory { register(new XAxisMaskParser(worldEdit)); register(new YAxisMaskParser(worldEdit)); register(new ZAxisMaskParser(worldEdit)); - + register(new SimplexMaskParser(worldEdit)); + register(new AngleMaskParser(worldEdit)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java index 31491b2b8..69b2395ce 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java @@ -20,13 +20,11 @@ package com.sk89q.worldedit.extension.factory.parser; import com.boydti.fawe.config.Caption; -import com.google.common.collect.Maps; - import com.boydti.fawe.jnbt.JSON2NBT; import com.boydti.fawe.jnbt.NBTException; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.StringMan; - +import com.google.common.collect.Maps; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.NotABlockException; @@ -58,14 +56,13 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.FuzzyBlockState; +import com.sk89q.worldedit.world.entity.EntityType; +import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import java.util.Arrays; import java.util.HashMap; import java.util.Locale; -import com.sk89q.worldedit.world.entity.EntityType; -import com.sk89q.worldedit.world.entity.EntityTypes; - import java.util.Map; import java.util.stream.Stream; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/RichParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/RichParser.java index 6bd9261fa..7c19f55b0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/RichParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/RichParser.java @@ -1,6 +1,5 @@ package com.sk89q.worldedit.extension.factory.parser; -import com.sk89q.util.StringUtil; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; @@ -115,4 +114,40 @@ public abstract class RichParser extends InputParser { } return arguments.toArray(new String[0]); } + + /** + * Returns a stream of suggestions for positive doubles. + * + * @param argumentInput the given input to filter with. + * @return a stream of suggestions. + */ + protected Stream suggestPositiveDoubles(String argumentInput) { + if (argumentInput.isEmpty()) { + return Stream.of("1", "2", "3", "4", "5", "6", "7", "8", "9"); + } + // if already a valid number, suggest more digits + if (isDouble(argumentInput)) { + Stream numbers = Stream.of("", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); + if (argumentInput.indexOf('.') == -1) { + numbers = Stream.concat(numbers, Stream.of(".")); + } + return numbers.map(s -> argumentInput + s); + } + // no valid input anymore + return Stream.empty(); + } + + private static boolean isDouble(String input) { + boolean point = false; + for (char c : input.toCharArray()) { + if (!Character.isDigit(c)) { + if (c == '.' && !point) { + point = true; + } else { + return false; + } + } + } + return true; + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AirMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AirMaskParser.java index e8c5ef423..ec2059129 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AirMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AirMaskParser.java @@ -1,12 +1,12 @@ package com.sk89q.worldedit.extension.factory.parser.mask; import com.boydti.fawe.function.mask.AirMask; -import com.boydti.fawe.function.mask.LiquidMask; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.internal.registry.SimpleInputParser; + import java.util.List; public class AirMaskParser extends SimpleInputParser { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AngleMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AngleMaskParser.java new file mode 100644 index 000000000..0957a7e8c --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/AngleMaskParser.java @@ -0,0 +1,49 @@ +package com.sk89q.worldedit.extension.factory.parser.mask; + +import com.boydti.fawe.object.mask.AngleMask; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.factory.parser.RichParser; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.function.mask.Mask; +import org.jetbrains.annotations.NotNull; + +import java.util.stream.Stream; + +public class AngleMaskParser extends RichParser { + + public AngleMaskParser(WorldEdit worldEdit) { + super(worldEdit, "/"); + } + + @Override + protected Stream getSuggestions(String argumentInput, int index) { + if (index == 0 || index == 1) { + return suggestPositiveDoubles(argumentInput).flatMap(s -> Stream.of(s, s + "d")); + } + return null; + } + + @Override + protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException { + if (arguments.length != 2) return null; + String minArg = arguments[0]; + String maxArg = arguments[1]; + boolean degree = minArg.endsWith("d"); + if (degree ^ maxArg.endsWith("d")) { + throw new InputParseException("Cannot combine degree with block-step"); + } + double min, max; + if (degree) { + double minDeg = Double.parseDouble(minArg.substring(0, minArg.length() - 1)); + double maxDeg = Double.parseDouble(maxArg.substring(0, maxArg.length() - 1)); + min = (Math.tan(minDeg * (Math.PI / 180))); + max = (Math.tan(maxDeg * (Math.PI / 180))); + } else { + min = Double.parseDouble(minArg); + max = Double.parseDouble(maxArg); + } + + return new AngleMask(context.getExtent(), min, max, false, 1); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java index b578fd031..16122e313 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java @@ -77,6 +77,6 @@ public class BiomeMaskParser extends InputParser { biomes.add(biome); } - return Masks.asMask(new BiomeMask2D(context.getExtent(), biomes)); + return Masks.asMask(new BiomeMask2D(context.requireExtent(), biomes)); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java index 5fa9033b2..86b29e84e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java @@ -53,7 +53,7 @@ public class BlockCategoryMaskParser extends InputParser { if (category == null) { throw new InputParseException("Unrecognised tag '" + input.substring(2) + '\''); } else { - return new BlockCategoryMask(context.getExtent(), category); + return new BlockCategoryMask(context.requireExtent(), category); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockStateMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockStateMaskParser.java index ca47294b4..8b8060622 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockStateMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockStateMaskParser.java @@ -52,7 +52,7 @@ public class BlockStateMaskParser extends InputParser { boolean strict = input.charAt(1) == '='; String states = input.substring(2 + (strict ? 1 : 0), input.length() - 1); try { - return new BlockStateMask(context.getExtent(), + return new BlockStateMask(context.requireExtent(), Splitter.on(',').omitEmptyStrings().trimResults().withKeyValueSeparator('=').split(states), strict); } catch (Exception e) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java index d66d59ba9..636903d41 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.extension.factory.parser.mask; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; -import com.sk89q.worldedit.extension.input.NoMatchException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.Mask; @@ -55,7 +54,7 @@ public class BlocksMaskParser extends InputParser { if (holders.isEmpty()) { return null; } - return new BlockMask(context.getExtent(), holders); + return new BlockMask(context.requireExtent(), holders); } catch (InputParseException e) { return null; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExistingMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExistingMaskParser.java index 1f55824ae..389a401a7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExistingMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExistingMaskParser.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.factory.parser.mask; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.Mask; @@ -42,7 +43,7 @@ public class ExistingMaskParser extends SimpleInputParser { } @Override - public Mask parseFromSimpleInput(String input, ParserContext context) { - return new ExistingBlockMask(context.getExtent()); + public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException { + return new ExistingBlockMask(context.requireExtent()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExpressionMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExpressionMaskParser.java index 7438e2759..9ef5cba1a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExpressionMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExpressionMaskParser.java @@ -57,7 +57,7 @@ public class ExpressionMaskParser extends InputParser { try { Expression exp = Expression.compile(input.substring(1), "x", "y", "z"); WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment( - context.getExtent(), Vector3.ONE, Vector3.ZERO); + context.requireExtent(), Vector3.ONE, Vector3.ZERO); exp.setEnvironment(env); if (context.getActor() != null) { SessionOwner owner = context.getActor(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/LiquidMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/LiquidMaskParser.java index 444ac1c40..5ad703df2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/LiquidMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/LiquidMaskParser.java @@ -5,7 +5,6 @@ import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.internal.registry.SimpleInputParser; import java.util.List; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/OffsetMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/OffsetMaskParser.java index b6c222f2e..447125204 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/OffsetMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/OffsetMaskParser.java @@ -61,7 +61,7 @@ public class OffsetMaskParser extends InputParser { if (input.length() > 1) { submask = worldEdit.getMaskFactory().parseFromInput(input.substring(1), context); } else { - submask = new ExistingBlockMask(context.getExtent()); + submask = new ExistingBlockMask(context.requireExtent()); } OffsetMask offsetMask = new OffsetMask(submask, BlockVector3.at(0, firstChar == '>' ? -1 : 1, 0)); return new MaskIntersection(offsetMask, Masks.negate(submask)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SimplexMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SimplexMaskParser.java new file mode 100644 index 000000000..450416839 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SimplexMaskParser.java @@ -0,0 +1,39 @@ +package com.sk89q.worldedit.extension.factory.parser.mask; + +import com.boydti.fawe.object.mask.SimplexMask; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.factory.parser.RichParser; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.function.mask.Mask; +import org.jetbrains.annotations.NotNull; + +import java.util.stream.Stream; + +public class SimplexMaskParser extends RichParser { + private static final String SIMPLEX_PREFIX = "#simplex"; + + public SimplexMaskParser(WorldEdit worldEdit) { + super(worldEdit, SIMPLEX_PREFIX); + } + + @Override + protected Stream getSuggestions(String argumentInput, int index) { + if (index < 3) { + suggestPositiveDoubles(argumentInput); + } + return Stream.empty(); + } + + @Override + protected Mask parseFromInput(@NotNull String[] arguments, ParserContext context) throws InputParseException { + if (arguments.length != 3) return null; + double scale = Double.parseDouble(arguments[0]); + double min = Double.parseDouble(arguments[1]); + double max = Double.parseDouble(arguments[2]); + scale = 1d / Math.max(1d, scale); + min = (min - 50d) / 50d; + max = (max - 50d) / 50d; + return new SimplexMask(scale, min, max); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SolidMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SolidMaskParser.java index 412240a64..f2c702d8c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SolidMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SolidMaskParser.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.factory.parser.mask; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.SolidBlockMask; @@ -42,7 +43,7 @@ public class SolidMaskParser extends SimpleInputParser { } @Override - public Mask parseFromSimpleInput(String input, ParserContext context) { - return new SolidBlockMask(context.getExtent()); + public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException { + return new SolidBlockMask(context.requireExtent()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/YAxisMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/YAxisMaskParser.java index 12108010d..f60ff0999 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/YAxisMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/YAxisMaskParser.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.extension.factory.parser.mask; -import com.boydti.fawe.function.mask.XAxisMask; import com.boydti.fawe.function.mask.YAxisMask; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ZAxisMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ZAxisMaskParser.java index 754c2876d..774f007bd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ZAxisMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ZAxisMaskParser.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.extension.factory.parser.mask; -import com.boydti.fawe.function.mask.XAxisMask; import com.boydti.fawe.function.mask.ZAxisMask; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SimplexPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SimplexPatternParser.java index 547f96390..f8f4a0311 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SimplexPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SimplexPatternParser.java @@ -22,19 +22,7 @@ public class SimplexPatternParser extends RichParser { @Override protected Stream getSuggestions(String argumentInput, int index) { if (index == 0) { - if (argumentInput.isEmpty()) { - return Stream.of("1", "2", "3", "4", "5", "6", "7", "8", "9"); - } - // if already a valid number, suggest more digits - if (isDouble(argumentInput)) { - Stream numbers = Stream.of("", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); - if (argumentInput.indexOf('.') == -1) { - numbers = Stream.concat(numbers, Stream.of(".")); - } - return numbers.map(s -> argumentInput + s); - } - // no valid input anymore - return Stream.empty(); + return suggestPositiveDoubles(argumentInput); } if (index == 1) { return worldEdit.getPatternFactory().getSuggestions(argumentInput).stream(); @@ -58,18 +46,4 @@ public class SimplexPatternParser extends RichParser { throw new InputParseException("Pattern " + inner.getClass().getSimpleName() + " cannot be used with #simplex"); } } - - private static boolean isDouble(String input) { - boolean point = false; - for (char c : input.toCharArray()) { - if (!Character.isDigit(c)) { - if (c == '.' && !point) { - point = true; - } else { - return false; - } - } - } - return true; - } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java index a4aefaba2..448425e59 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java @@ -65,8 +65,7 @@ public abstract class AbstractNonPlayerActor implements Actor { // Queue for async tasks private AtomicInteger runningCount = new AtomicInteger(); - private AsyncNotifyQueue asyncNotifyQueue = new AsyncNotifyQueue( - (thread, throwable) -> { + private AsyncNotifyQueue asyncNotifyQueue = new AsyncNotifyQueue((thread, throwable) -> { while (throwable.getCause() != null) { throwable = throwable.getCause(); } @@ -83,11 +82,11 @@ public abstract class AbstractNonPlayerActor implements Actor { }); /** - * Run a task either async, or on the current thread + * Run a task either async, or on the current thread. * - * @param ifFree + * @param ifFree the task to run if free * @param checkFree Whether to first check if a task is running - * @param async + * @param async TODO Description * @return false if the task was ran or queued */ @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 4419f34f6..868711c7a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -19,14 +19,12 @@ package com.sk89q.worldedit.extension.platform; -import com.boydti.fawe.object.task.AsyncNotifyQueue; -import com.sk89q.worldedit.EditSession; - -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.exception.FaweException; +import com.boydti.fawe.object.task.AsyncNotifyQueue; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.WEManager; +import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; @@ -43,8 +41,6 @@ import com.sk89q.worldedit.regions.Polygonal2DRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector; - -import javax.annotation.Nullable; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.CylinderRegionSelector; import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector; @@ -53,8 +49,10 @@ import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.auth.AuthorizationException; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -65,10 +63,12 @@ import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; + import java.io.File; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; +import javax.annotation.Nullable; /** * An abstract implementation of both a {@link Actor} and a {@link Player} @@ -150,37 +150,45 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { public boolean isHoldingPickAxe() { ItemType item = getItemInHand(HandSide.MAIN_HAND).getType(); return item == ItemTypes.IRON_PICKAXE - || item == ItemTypes.WOODEN_PICKAXE - || item == ItemTypes.STONE_PICKAXE - || item == ItemTypes.DIAMOND_PICKAXE - || item == ItemTypes.GOLDEN_PICKAXE; + || item == ItemTypes.WOODEN_PICKAXE + || item == ItemTypes.STONE_PICKAXE + || item == ItemTypes.DIAMOND_PICKAXE + || item == ItemTypes.GOLDEN_PICKAXE + || item == ItemTypes.NETHERITE_PICKAXE; } @Override public void findFreePosition(Location searchPos) { Extent world = searchPos.getExtent(); - int x = searchPos.getBlockX(); - int y = Math.max(0, searchPos.getBlockY()); - int origY = y; - int yPlusSearchHeight = y + WorldEdit.getInstance().getConfiguration().defaultVerticalHeight; - int z = searchPos.getBlockZ(); - int maxY = Math.min(255, yPlusSearchHeight) + 2; + int worldMinY = world.getMinimumPoint().getY(); + int worldMaxY = world.getMaximumPoint().getY(); + + int x = searchPos.getBlockX(); + int y = Math.max(worldMinY, searchPos.getBlockY()); + int origY = y; + int z = searchPos.getBlockZ(); + int yPlusSearchHeight = y + WorldEdit.getInstance().getConfiguration().defaultVerticalHeight; + int maxY = Math.min(worldMaxY, yPlusSearchHeight) + 2; byte free = 0; BlockVector3 mutablePos = MutableBlockVector3.ZERO; while (y <= maxY) { - if (!world.getBlock(mutablePos.setComponents(x, y, z)).getBlockType().getMaterial() - .isMovementBlocker()) { + if (!world.getBlock(mutablePos.setComponents(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { ++free; } else { free = 0; } if (free == 2) { + boolean worked = true; + if (y - 1 != origY) { - setPosition(Vector3.at(x + 0.5, y - 2 + 1, z + 0.5)); + worked = trySetPosition(Vector3.at(x + 0.5, y - 2 + 1, z + 0.5)); + } + + if (worked) { return; } } @@ -192,15 +200,20 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public void setOnGround(Location searchPos) { Extent world = searchPos.getExtent(); - int x = searchPos.getBlockX(); - int y = Math.max(0, searchPos.getBlockY()); - int z = searchPos.getBlockZ(); - while (y >= 0) { + int worldMinY = world.getMinimumPoint().getY(); + + int x = searchPos.getBlockX(); + int y = Math.max(worldMinY, searchPos.getBlockY()); + int z = searchPos.getBlockZ(); + int yLessSearchHeight = y - WorldEdit.getInstance().getConfiguration().defaultVerticalHeight; + int minY = Math.min(worldMinY, yLessSearchHeight) + 2; + + while (y >= minY) { final BlockVector3 pos = BlockVector3.at(x, y, z); final BlockState id = world.getBlock(pos); - if (id.getBlockType().getMaterial().isMovementBlocker()) { - setPosition(Vector3.at(x + 0.5, y + +BlockTypeUtil.centralTopLimit(id), z + 0.5)); + if (id.getBlockType().getMaterial().isMovementBlocker() + && trySetPosition(Vector3.at(x + 0.5, y + 1, z + 0.5))) { return; } @@ -213,6 +226,33 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { findFreePosition(getBlockLocation()); } + /** + * Determines if the block at the given location "harms" the player, either by suffocation + * or other means. + */ + private boolean isPlayerHarmingBlock(BlockVector3 location) { + BlockType type = getWorld().getBlock(location).getBlockType(); + return type.getMaterial().isMovementBlocker() || type == BlockTypes.LAVA + || BlockCategories.FIRE.contains(type); + } + + /** + * Check if the location is a good place to leave a standing player. + * + * @param location where the player would be placed (not Y offset) + * @return if the player can stand at the location + */ + private boolean isLocationGoodForStanding(BlockVector3 location) { + if (isPlayerHarmingBlock(location.add(0, 1, 0))) { + return false; + } + if (isPlayerHarmingBlock(location)) { + return false; + } + return getWorld().getBlock(location.add(0, -1, 0)).getBlockType().getMaterial() + .isMovementBlocker(); + } + @Override public boolean ascendLevel() { final Location pos = getBlockLocation(); @@ -247,21 +287,21 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (!lastState) { lastState = BlockTypeUtil.centralBottomLimit(state) != 1; continue; - } + } if (freeStart == -1) { freeStart = level + BlockTypeUtil.centralTopLimit(state); } else { double bottomLimit = BlockTypeUtil.centralBottomLimit(state); double space = level + bottomLimit - freeStart; if (space >= height) { - setPosition(Vector3.at(x + 0.5, freeStart, z + 0.5)); - return true; - } + trySetPosition(Vector3.at(x + 0.5, freeStart, z + 0.5)); + return true; + } // Not enough room, reset the free position if (bottomLimit != 1) { freeStart = -1; - } - } + } + } } else { freeStart = -1; lastState = true; @@ -312,7 +352,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { double freeStart = level + topLimit; double space = freeEnd - freeStart; if (space >= height) { - setPosition(Vector3.at(x + 0.5, freeStart, z + 0.5)); + trySetPosition(Vector3.at(x + 0.5, freeStart, z + 0.5)); return true; } // Not enough room, reset the free position @@ -350,8 +390,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { while (y <= world.getMaximumPoint().getY()) { // Found a ceiling! - if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial() - .isMovementBlocker()) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { int platformY = Math.max(initialY, y - 3 - clearance); if (platformY < initialY) { // if ==, they already have the given clearance, if <, clearance is too large return false; @@ -375,17 +414,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public boolean ascendUpwards(int distance, boolean alwaysGlass) { + final World world = getWorld(); final Location pos = getBlockLocation(); final int x = pos.getBlockX(); final int initialY = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY() + 1); final int z = pos.getBlockZ(); - final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance); - final Extent world = getLocation().getExtent(); + final int maxY = Math.min(world.getMaxY() + 1, initialY + distance); - while (y <= world.getMaximumPoint().getY() + 2) { - if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial() - .isMovementBlocker()) { + while (y <= world.getMaxY() + 2) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { break; // Hit something } else if (y > maxY + 1) { break; @@ -409,12 +447,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { try (EditSession session = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 1, this)) { session.setBlock(spot, BlockTypes.GLASS.getDefaultState()); } catch (MaxChangedBlocksException ignored) { + } } - } } else { setFlying(true); } - setPosition(Vector3.at(x + 0.5, y, z + 0.5)); + trySetPosition(Vector3.at(x + 0.5, y, z + 0.5)); } /** @@ -473,7 +511,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { return getBlockTrace(range, false); } - @Override public Location getSolidBlockTrace(int range) { TargetBlock tb = new TargetBlock(this, range, 0.2); @@ -510,9 +547,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { return typeId.getBlockType().getDefaultState().toBaseBlock(); } else { return BlockTypes.AIR.getDefaultState().toBaseBlock(); // FAWE returns air here - /* - throw new NotABlockException(); - */ } } @@ -523,7 +557,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { } /** - * Advances the block target block until the current block is a wall + * Advances the block target block until the current block is a wall. + * * @return true if a wall is found */ private boolean advanceToWall(TargetBlock hitBlox) { @@ -540,7 +575,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { } /** - * Advances the block target block until the current block is a free + * Advances the block target block until the current block is a free spot. + * * @return true if a free spot is found */ private boolean advanceToFree(TargetBlock hitBlox) { @@ -555,31 +591,32 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { return false; } + @Override public boolean passThroughForwardWall(int range) { TargetBlock hitBlox = new TargetBlock(this, range, 0.2); if (!advanceToWall(hitBlox)) { return false; - } + } if (!advanceToFree(hitBlox)) { - return false; - } + return false; + } Location foundBlock = hitBlox.getCurrentBlock(); if (foundBlock != null) { setOnGround(foundBlock); - return true; - } + return true; + } return false; } @Override - public void setPosition(Vector3 pos) { + public boolean trySetPosition(Vector3 pos) { final Location location = getLocation(); - setPosition(pos, location.getPitch(), location.getYaw()); + return trySetPosition(pos, location.getPitch(), location.getYaw()); } @Override @@ -655,11 +692,11 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { } /** - * Run a task either async, or on the current thread + * Run a task either async, or on the current thread. * - * @param ifFree + * @param ifFree the task to run if free * @param checkFree Whether to first check if a task is running - * @param async + * @param async TODO description * @return false if the task was ran or queued */ public boolean runAction(Runnable ifFree, boolean checkFree, boolean async) { @@ -686,7 +723,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { /** - * Get the player's current allowed WorldEdit regions + * Get the player's current allowed WorldEdit regions. * * @return an array of allowed regions */ @@ -699,7 +736,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { } /** - * Get the largest region in the player's allowed WorldEdit region + * Get the largest region in the player's allowed WorldEdit region. * * @return */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java index e72fb2d1a..909f6817b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java @@ -20,8 +20,6 @@ package com.sk89q.worldedit.extension.platform; import com.boydti.fawe.Fawe; -import com.sk89q.worldedit.util.formatting.text.TextComponent; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.brush.visualization.VirtualWorld; @@ -173,7 +171,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab boolean runAction(Runnable ifFree, boolean checkFree, boolean async); /** - * Decline any pending actions + * Decline any pending actions. * @return true if an action was pending */ default boolean decline() { @@ -186,7 +184,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab } /** - * Confirm any pending actions + * Confirm any pending actions. * @return true if an action was pending */ default boolean confirm() { @@ -199,9 +197,9 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab } /** - * Queue an action to run async + * Queue an action to run async. * - * @param run + * @param run the action to run */ default void queueAction(Runnable run) { runAction(run, false, true); @@ -227,7 +225,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab } /** - * Attempt to cancel all pending and running actions + * Attempt to cancel all pending and running actions. * @param close if Extents are closed * @return number of cancelled actions */ @@ -252,8 +250,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab } catch (IOException e) { e.printStackTrace(); } - } - else { + } else { try { world.close(false); } catch (IOException e) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Capability.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Capability.java index 0e43e960a..246b55704 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Capability.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Capability.java @@ -19,11 +19,6 @@ package com.sk89q.worldedit.extension.platform; -import com.sk89q.worldedit.internal.block.BlockStateIdAccess; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.registry.BlockRegistry; - /** * A collection of capabilities that a {@link Platform} may support. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java index cc25ab5c7..da50537cd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Locatable.java @@ -54,9 +54,27 @@ public interface Locatable { * Sets the position of this actor. * * @param pos where to move them + * @deprecated This method may fail without indication. Use {@link #trySetPosition(Vector3)} + * instead */ + @Deprecated default void setPosition(Vector3 pos) { - setLocation(new Location(getExtent(), pos)); + trySetPosition(pos); + } + + /** + * Attempts to set the position of this actor. + * + *

+ * This action may fail, due to other mods cancelling the move. + * If so, this method will return {@code false}. + *

+ * + * @param pos the position to set + * @return if the position was able to be set + */ + default boolean trySetPosition(Vector3 pos) { + return setLocation(new Location(getExtent(), pos)); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java index 1f92543aa..929bbefc4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java @@ -27,11 +27,10 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.registry.Registries; import org.enginehub.piston.CommandManager; -import javax.annotation.Nullable; - import java.util.List; import java.util.Map; import java.util.Set; +import javax.annotation.Nullable; /** * Represents a platform that WorldEdit has been implemented for. @@ -177,5 +176,10 @@ public interface Platform { */ Map getCapabilities(); + /** + * Get a set of {@link SideEffect}s supported by this platform. + * + * @return A set of supported side effects + */ Set getSupportedSideEffects(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 2b533f170..475737f0d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extension.platform; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.Fawe; import com.boydti.fawe.command.AnvilCommands; import com.boydti.fawe.command.AnvilCommandsRegistration; @@ -131,21 +129,6 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.logging.DynamicStreamHandler; import com.sk89q.worldedit.util.logging.LogFormat; import com.sk89q.worldedit.world.World; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.logging.FileHandler; -import java.util.logging.Level; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import javax.annotation.Nullable; import org.enginehub.piston.Command; import org.enginehub.piston.CommandManager; import org.enginehub.piston.converter.ArgumentConverter; @@ -171,6 +154,24 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; + /** * Handles the registration and invocation of commands. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 6ce088ac3..da181a270 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -19,15 +19,11 @@ package com.sk89q.worldedit.extension.platform; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.config.Settings; -import com.boydti.fawe.wrappers.AsyncPlayer; -import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.pattern.PatternTraverser; +import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; import com.boydti.fawe.wrappers.WorldWrapper; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -50,7 +46,11 @@ import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.eventbus.Subscribe; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.Collection; import java.util.EnumMap; @@ -60,8 +60,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Manages registered {@link Platform}s for WorldEdit. Platforms are diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java index 6cd5dfa5f..aa8fa9359 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extension.platform; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.BaseEntity; @@ -37,12 +35,13 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; - -import java.util.Locale; import com.sk89q.worldedit.world.gamemode.GameMode; -import javax.annotation.Nullable; +import java.util.Locale; import java.util.UUID; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; public class PlayerProxy extends AbstractPlayerActor { @@ -131,8 +130,8 @@ public class PlayerProxy extends AbstractPlayerActor { } @Override - public void setPosition(Vector3 pos, float pitch, float yaw) { - basePlayer.setPosition(pos, pitch, yaw); + public boolean trySetPosition(Vector3 pos, float pitch, float yaw) { + return basePlayer.trySetPosition(pos, pitch, yaw); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/Bindings.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/Bindings.java index 5be75cf5f..19e50170f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/Bindings.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/Bindings.java @@ -1,13 +1,7 @@ package com.sk89q.worldedit.extension.platform.binding; -import static org.slf4j.LoggerFactory.getLogger; - -import com.boydti.fawe.Fawe; -import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.StringMan; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.internal.annotation.Selection; -import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import org.enginehub.piston.CommandManager; @@ -17,14 +11,14 @@ import org.enginehub.piston.converter.SuccessfulConversion; import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.InjectedValueStore; import org.enginehub.piston.inject.Key; -import org.enginehub.piston.util.ValueProvider; import java.lang.annotation.Annotation; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Optional; import java.util.function.Function; -import java.util.function.Supplier; + +import static org.slf4j.LoggerFactory.getLogger; public class Bindings { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/PrimitiveBindings.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/PrimitiveBindings.java index 7c5436818..af9cc9a68 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/PrimitiveBindings.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/PrimitiveBindings.java @@ -9,6 +9,7 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.math.Vector3; + import java.util.Locale; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/ProvideBindings.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/ProvideBindings.java index 1a50ad03f..3028007af 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/ProvideBindings.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/ProvideBindings.java @@ -14,25 +14,12 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.internal.annotation.AllowedRegion; import com.sk89q.worldedit.internal.annotation.Selection; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.request.Request; -import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; 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.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.registry.BiomeRegistry; -import java.awt.image.BufferedImage; -import java.net.URI; -import java.util.Collection; -import java.util.Optional; import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.InjectedValueStore; import org.enginehub.piston.inject.Key; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/permission/ActorSelectorLimits.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/permission/ActorSelectorLimits.java index 5712fcb4e..b8eecb071 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/permission/ActorSelectorLimits.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/permission/ActorSelectorLimits.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extension.platform.permission; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Actor; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; import java.util.Optional; +import static com.google.common.base.Preconditions.checkNotNull; + public class ActorSelectorLimits implements SelectorLimits { private final LocalConfiguration configuration; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractBufferingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractBufferingExtent.java index 98d5f3c04..e2f0fe2b4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractBufferingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractBufferingExtent.java @@ -20,6 +20,8 @@ package com.sk89q.worldedit.extent; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.internal.util.DeprecationUtil; +import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -68,22 +70,33 @@ public abstract class AbstractBufferingExtent extends AbstractDelegateExtent { return block; } + /** + * Gets a block from the buffer. + * + * @deprecated New subclasses should override {@link #getBufferedFullBlock(BlockVector3)} + * instead + */ @Deprecated protected Optional getBufferedBlock(BlockVector3 position) { throw new IllegalStateException("Invalid BufferingExtent provided. Must override `getBufferedFullBlock(BlockVector3)`."); } - //TODO make below abstract /** * Gets a block from the buffer, or null if not buffered. * - * This **must** be overridden, and will be abstract in WorldEdit 8. - * * @param position The position * @return The buffered block, or null + * @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility} + * for details */ + @NonAbstractForCompatibility( + delegateName = "getBufferedBlock", + delegateParams = { BlockVector3.class } + ) @Nullable protected BaseBlock getBufferedFullBlock(BlockVector3 position) { + DeprecationUtil.checkDelegatingOverride(getClass()); return getBufferedBlock(position).orElse(null); } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index 467de473d..bf46bfeaa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.extent; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.HistoryExtent; @@ -32,7 +29,6 @@ import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; -import com.sk89q.worldedit.extension.platform.PlatformManager; import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.OperationQueue; @@ -53,6 +49,11 @@ import org.jetbrains.annotations.Range; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; + /** * A base class for {@link Extent}s that merely passes extents onto another. */ @@ -84,7 +85,7 @@ public class AbstractDelegateExtent implements Extent { @Override public BlockState getBlock(BlockVector3 position) { - return extent.getBlock(position.getX(),position.getY(),position.getZ()); + return extent.getBlock(position.getX(), position.getY(), position.getZ()); } /* @@ -198,8 +199,8 @@ public class AbstractDelegateExtent implements Extent { } @Override - public > boolean setBlock(int x, @Range(from = 0, to = 255) int y, int z, T block) - throws WorldEditException { + public > boolean setBlock(int x, @Range(from = 0, to = 255) int y, + int z, T block) throws WorldEditException { return extent.setBlock(x, y, z, block); } @@ -252,7 +253,7 @@ public class AbstractDelegateExtent implements Extent { public int getBrightness(int x, int y, int z) { return extent.getBrightness(x, y, z); } - + @Override public String toString() { return super.toString() + ":" + (extent == this ? "" : extent.toString()); @@ -273,7 +274,8 @@ public class AbstractDelegateExtent implements Extent { } @Override - public @Nullable Operation commit() { + public @Nullable + Operation commit() { Operation ours = commitBefore(); Operation other = null; if (extent != this) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java index 0c3de3d4f..b03c0f62b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -37,9 +35,11 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Stores changes to a {@link ChangeSet}. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index b9c20c8f0..caa5086a6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -19,13 +19,10 @@ package com.sk89q.worldedit.extent; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.implementation.filter.block.ExtentFilterBlock; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.IBatchProcessor; +import com.boydti.fawe.beta.implementation.filter.block.ExtentFilterBlock; import com.boydti.fawe.object.changeset.AbstractChangeSet; import com.boydti.fawe.object.clipboard.WorldCopyClipboard; import com.boydti.fawe.object.exception.FaweException; @@ -76,9 +73,10 @@ import java.util.List; import java.util.Set; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A world, portion of a world, clipboard, or other object that can have blocks * set or entities placed. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java index 134e29f95..1b531e12f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java @@ -20,9 +20,10 @@ package com.sk89q.worldedit.extent; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.internal.util.DeprecationUtil; +import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; @@ -77,17 +78,48 @@ public interface InputExtent { * * @param position the (x, z) location to check the biome at * @return the biome at the location + * @deprecated Biomes in Minecraft are 3D now, use {@link InputExtent#getBiome(BlockVector3)} */ + @Deprecated default BiomeType getBiome(BlockVector2 position) { return getBiomeType(position.getX(), 0, position.getZ()); } default BiomeType getBiomeType(int x, int y, int z) { - return getBiome(MutableBlockVector2.get(x, z)); + return getBiome(MutableBlockVector3.get(x, y, z)); } /** - * Get the light level at the given location + * Get the biome at the given location. + * + *

+ * If there is no biome available, then the ocean biome should be + * returned. + *

+ * + *

+ * As implementation varies per Minecraft version, this may not exactly get + * this positions biome. On versions prior to 1.15, this will get the entire + * column. On later versions it will get the 4x4x4 cube's biome. + *

+ * + * @param position the (x, y, z) location to check the biome at + * @return the biome at the location + * @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility} + * for details + */ + @NonAbstractForCompatibility( + delegateName = "getBiome", + delegateParams = { BlockVector2.class } + ) + default BiomeType getBiome(BlockVector3 position) { + DeprecationUtil.checkDelegatingOverride(getClass()); + + return getBiome(position.toBlockVector2()); + } + + /** + * Get the light level at the given location. * * @param position location * @return the light level at the location @@ -101,7 +133,7 @@ public interface InputExtent { } /** - * Get the sky light level at the given location + * Get the sky light level at the given location. * * @param position location * @return the sky light level at the location diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java index c2bc8f7a7..8d033df9e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java @@ -37,7 +37,6 @@ import com.sk89q.worldedit.world.block.BlockTypes; import java.util.Collections; import java.util.List; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/PassthroughExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/PassthroughExtent.java index d6b387d94..5488ee124 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/PassthroughExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/PassthroughExtent.java @@ -20,6 +20,7 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; + import java.util.List; import java.util.Set; import java.util.UUID; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java index 699b73d43..6cdb36654 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.buffer; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractBufferingExtent; import com.sk89q.worldedit.extent.Extent; @@ -30,8 +28,11 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.collection.BlockMap; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; + import java.util.Map; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Buffers changes to an {@link Extent} and allows retrieval of the changed blocks, * without modifying the underlying extent. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java index 0c3aa726e..357fe5053 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.buffer; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; @@ -31,18 +29,21 @@ import com.sk89q.worldedit.function.pattern.BiomePattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.AbstractFlatRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.regions.AbstractFlatRegion; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; + import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Buffers changes to an {@link Extent} and allows later retrieval for * actual application of the changes. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index 4d0bb889f..1d3228c80 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -37,12 +37,12 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; +import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; import java.util.Iterator; import java.util.List; import java.util.UUID; -import org.jetbrains.annotations.NotNull; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; import java.util.stream.Collectors; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java index bb416743c..b478a99c7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.clipboard; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.beta.Filter; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.clipboard.CPUOptimizedClipboard; @@ -50,6 +48,8 @@ import com.sk89q.worldedit.regions.Regions; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; +import org.jetbrains.annotations.NotNull; + import java.io.Closeable; import java.io.File; import java.io.FileOutputStream; @@ -59,7 +59,8 @@ import java.net.URI; import java.util.Iterator; import java.util.UUID; import javax.annotation.Nullable; -import org.jetbrains.annotations.NotNull; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Specifies an object that implements something suitable as a "clipboard." diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/StoredEntity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/StoredEntity.java index ebece5abf..a44923892 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/StoredEntity.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/StoredEntity.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.extent.clipboard; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.util.Location; +import static com.google.common.base.Preconditions.checkNotNull; + /** * An implementation of {@link Entity} that stores a {@link BaseEntity} with it. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java index 9baaa2b21..6a6eb4f38 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java @@ -21,9 +21,8 @@ package com.sk89q.worldedit.extent.clipboard.io; import com.boydti.fawe.object.io.PGZIPOutputStream; import com.boydti.fawe.object.io.ResettableFileInputStream; -import com.boydti.fawe.object.schematic.PNGWriter; import com.boydti.fawe.object.schematic.MinecraftStructure; - +import com.boydti.fawe.object.schematic.PNGWriter; import com.google.common.collect.ImmutableSet; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTOutputStream; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java index 67c589c26..91ec599c5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java @@ -19,19 +19,15 @@ package com.sk89q.worldedit.extent.clipboard.io; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.io.PGZIPOutputStream; import com.boydti.fawe.util.MainUtil; -import com.google.gson.Gson; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.math.BlockVector3; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -39,9 +35,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URI; import java.net.URL; -import java.util.HashMap; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A collection of supported clipboard formats. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java index 509a69809..f3e6b6874 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.clipboard.io; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.config.Caption; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.clipboard.LazyClipboardHolder; @@ -36,6 +34,7 @@ import com.google.common.io.Files; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Actor; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -59,6 +58,8 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + public class ClipboardFormats { private static final Map aliasMap = new HashMap<>(); @@ -73,7 +74,9 @@ public class ClipboardFormats { ClipboardFormat old = aliasMap.put(lowKey, format); if (old != null) { aliasMap.put(lowKey, old); - WorldEdit.logger.warn(format.getClass().getName() + " cannot override existing alias '" + lowKey + "' used by " + old.getClass().getName()); + WorldEdit.logger.warn( + format.getClass().getName() + " cannot override existing alias '" + lowKey + + "' used by " + old.getClass().getName()); } } for (String ext : format.getFileExtensions()) { @@ -124,6 +127,7 @@ public class ClipboardFormats { /** * Detect the format using the given extension + * * @param extension the extension * @return the format, otherwise null if one cannot be detected */ @@ -132,8 +136,8 @@ public class ClipboardFormats { checkNotNull(extension); Collection> entries = getFileExtensionMap().entries(); - for(Map.Entry entry : entries) { - if(entry.getKey().equalsIgnoreCase(extension)) { + for (Map.Entry entry : entries) { + if (entry.getKey().equalsIgnoreCase(extension)) { return entry.getValue(); } } @@ -142,6 +146,8 @@ public class ClipboardFormats { } /** + * A mapping from extensions to formats. + * * @return a multimap from a file extension to the potential matching formats. */ public static Multimap getFileExtensionMap() { @@ -170,21 +176,27 @@ public class ClipboardFormats { LocalConfiguration config = worldEdit.getConfiguration(); if (input.startsWith("url:")) { if (!player.hasPermission("worldedit.schematic.load.web")) { - if (message) player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.web")); + if (message) { + player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.web")); + } return null; } URL base = new URL(Settings.IMP.WEB.URL); - input = new URL(base, "uploads/" + input.substring(4) + "." + format.getPrimaryFileExtension()).toString(); + input = new URL(base, "uploads/" + input.substring(4) + "." + + format.getPrimaryFileExtension()).toString(); } if (input.startsWith("http")) { return null; } - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { + if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS + && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() + && !player.hasPermission("worldedit.schematic.load.other")) { player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other")); return null; } File working = worldEdit.getWorkingDirectoryFile(config.saveDir); - File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working; + File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? + new File(working, player.getUniqueId().toString()) : working; File f; if (input.startsWith("#")) { String[] extensions; @@ -195,12 +207,18 @@ public class ClipboardFormats { } f = player.openFileOpenDialog(extensions); if (f == null || !f.exists()) { - if (message) player.printError("Schematic " + input + " does not exist! (" + f + ")"); + if (message) { + player.printError("Schematic " + input + " does not exist! (" + f + ")"); + } return null; } } else { - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { - if (message) player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other")); + if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS + && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() + && !player.hasPermission("worldedit.schematic.load.other")) { + if (message) { + player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other")); + } return null; } if (format == null && input.matches(".*\\.[\\w].*")) { @@ -216,18 +234,24 @@ public class ClipboardFormats { } } if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) { - if (message) player.printError("Schematic " + input + " does not exist! (" + ((f != null) && f.exists()) + "|" + f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")"); + if (message) { + player.printError( + "Schematic " + input + " does not exist! (" + ((f != null) && f.exists()) + "|" + + f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")"); + } return null; } if (format == null && f.isFile()) { format = findByFile(f); if (format == null) { - player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format" , f.getName())); + player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format", f.getName())); return null; } } if (!f.exists()) { - if (message) player.print(Caption.of("fawe.error.schematic.not.found" , input)); + if (message) { + player.print(Caption.of("fawe.error.schematic.not.found", input)); + } return null; } if (!f.isDirectory()) { @@ -237,7 +261,9 @@ public class ClipboardFormats { } URIClipboardHolder[] clipboards = loadAllFromDirectory(f); if (clipboards.length < 1) { - if (message) player.print(Caption.of("fawe.error.schematic.not.found" , input)); + if (message) { + player.print(Caption.of("fawe.error.schematic.not.found", input)); + } return null; } return new MultiClipboardHolder(f.toURI(), clipboards); @@ -290,7 +316,9 @@ public class ClipboardFormats { LazyClipboardHolder[] arr = clipboards.toArray(new LazyClipboardHolder[0]); try { MultiClipboardHolder multi = new MultiClipboardHolder(url.toURI()); - for (LazyClipboardHolder h : arr) multi.add(h); + for (LazyClipboardHolder h : arr) { + multi.add(h); + } return multi; } catch (URISyntaxException e) { throw new RuntimeException(e); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardReader.java index 974bf7616..a0c479040 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardReader.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.extent.clipboard.io; import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; + import java.io.Closeable; import java.io.IOException; import java.util.OptionalInt; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardWriter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardWriter.java index c23306fd5..096a5e67f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardWriter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardWriter.java @@ -24,9 +24,9 @@ import com.sk89q.jnbt.FloatTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.extent.clipboard.Clipboard; - import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; + import java.io.Closeable; import java.io.IOException; import java.util.ArrayList; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java index e20059636..cbd10c53e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java @@ -20,8 +20,6 @@ package com.sk89q.worldedit.extent.clipboard.io; import com.google.common.collect.ImmutableList; - -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; @@ -60,12 +58,14 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.HashSet; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Reads schematic files that are compatible with MCEdit and other editors. * @deprecated Use SchematicStreamer diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/NBTSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/NBTSchematicReader.java index 085d29531..2f85025c9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/NBTSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/NBTSchematicReader.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.extent.clipboard.io; import com.sk89q.jnbt.Tag; -import javax.annotation.Nullable; import java.io.IOException; import java.util.Map; +import javax.annotation.Nullable; /** * Base class for NBT schematic readers diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java index 358edc19c..fcf335fce 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java @@ -19,12 +19,7 @@ package com.sk89q.worldedit.extent.clipboard.io; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; - import com.boydti.fawe.FaweCache; -import com.boydti.fawe.jnbt.streamer.InfoReader; -import com.boydti.fawe.jnbt.streamer.IntValueReader; import com.boydti.fawe.jnbt.streamer.StreamDelegate; import com.boydti.fawe.jnbt.streamer.ValueReader; import com.boydti.fawe.object.FaweInputStream; @@ -48,8 +43,6 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.biome.BiomeType; -import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockID; @@ -61,6 +54,9 @@ import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.LegacyMapper; +import net.jpountz.lz4.LZ4BlockInputStream; +import net.jpountz.lz4.LZ4BlockOutputStream; + import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -68,8 +64,9 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.function.Function; -import net.jpountz.lz4.LZ4BlockInputStream; -import net.jpountz.lz4.LZ4BlockOutputStream; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; /** * Reads schematic files based that are compatible with MCEdit and other editors. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java index a461fbcc6..78fdd2303 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.clipboard.io; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.collect.Maps; import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.CompoundTag; @@ -54,6 +52,8 @@ import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Writes schematic files using the Sponge schematic format. */ @@ -292,4 +292,4 @@ public class SpongeSchematicWriter implements ClipboardWriter { public void close() throws IOException { outputStream.close(); } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java index c2187ff1b..c2ea290a3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.extent.inventory; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.object.exception.FaweException; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; @@ -29,6 +28,7 @@ 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 java.util.Arrays; import java.util.HashMap; import java.util.Map; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java index 246eff4c7..ab1d96735 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java @@ -39,8 +39,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; -import java.util.Optional; /** * Re-orders blocks into several stages. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index be7f26b24..b9b444a15 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -18,23 +18,6 @@ */ package com.sk89q.worldedit.extent.transform; -import static com.sk89q.worldedit.util.Direction.ASCENDING_EAST; -import static com.sk89q.worldedit.util.Direction.ASCENDING_NORTH; -import static com.sk89q.worldedit.util.Direction.ASCENDING_SOUTH; -import static com.sk89q.worldedit.util.Direction.ASCENDING_WEST; -import static com.sk89q.worldedit.util.Direction.DOWN; -import static com.sk89q.worldedit.util.Direction.EAST; -import static com.sk89q.worldedit.util.Direction.Flag; -import static com.sk89q.worldedit.util.Direction.NORTH; -import static com.sk89q.worldedit.util.Direction.NORTHEAST; -import static com.sk89q.worldedit.util.Direction.NORTHWEST; -import static com.sk89q.worldedit.util.Direction.SOUTH; -import static com.sk89q.worldedit.util.Direction.SOUTHEAST; -import static com.sk89q.worldedit.util.Direction.SOUTHWEST; -import static com.sk89q.worldedit.util.Direction.UP; -import static com.sk89q.worldedit.util.Direction.WEST; -import static com.sk89q.worldedit.util.Direction.findClosest; -import static com.sk89q.worldedit.util.Direction.values; import com.boydti.fawe.object.extent.ResettableExtent; import com.sk89q.jnbt.ByteTag; @@ -57,6 +40,9 @@ 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 com.sk89q.worldedit.world.block.BlockTypesCache; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -65,10 +51,24 @@ import java.util.Locale; import java.util.Map; import javax.annotation.Nullable; -import com.sk89q.worldedit.world.block.BlockTypesCache; -import org.jetbrains.annotations.NotNull; - import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.util.Direction.ASCENDING_EAST; +import static com.sk89q.worldedit.util.Direction.ASCENDING_NORTH; +import static com.sk89q.worldedit.util.Direction.ASCENDING_SOUTH; +import static com.sk89q.worldedit.util.Direction.ASCENDING_WEST; +import static com.sk89q.worldedit.util.Direction.DOWN; +import static com.sk89q.worldedit.util.Direction.EAST; +import static com.sk89q.worldedit.util.Direction.Flag; +import static com.sk89q.worldedit.util.Direction.NORTH; +import static com.sk89q.worldedit.util.Direction.NORTHEAST; +import static com.sk89q.worldedit.util.Direction.NORTHWEST; +import static com.sk89q.worldedit.util.Direction.SOUTH; +import static com.sk89q.worldedit.util.Direction.SOUTHEAST; +import static com.sk89q.worldedit.util.Direction.SOUTHWEST; +import static com.sk89q.worldedit.util.Direction.UP; +import static com.sk89q.worldedit.util.Direction.WEST; +import static com.sk89q.worldedit.util.Direction.findClosest; +import static com.sk89q.worldedit.util.Direction.values; /** * Transforms blocks themselves (but not their position) according to a diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java index 7e89fa721..0ff2d4d1d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.validation; -import static com.google.common.base.Preconditions.checkArgument; - import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; +import static com.google.common.base.Preconditions.checkArgument; + /** * Limits the number of blocks that can be changed before a * {@link MaxChangedBlocksException} is thrown. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java index 63ca586e6..376c6534c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.validation; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; @@ -29,6 +27,8 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Validates set data to prevent creating invalid blocks and such. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java index 50f2a9a30..b87416080 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.world; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; @@ -30,6 +28,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Handles various quirks when setting blocks, such as ice turning * into water or containers dropping their contents. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java index a2ea51ed4..af139e40d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.world; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; @@ -30,6 +28,8 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Automatically loads chunks when blocks are accessed. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SideEffectExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SideEffectExtent.java index 1a6b78505..f63a855e1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SideEffectExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SideEffectExtent.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.world; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.function.operation.Operation; @@ -39,6 +37,8 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * An extent that sets blocks in the world, with a {@link SideEffectSet}. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java index 941d49d13..637646e22 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.extent.world; -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; @@ -27,6 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Makes changes to the world as if a player had done so during survival mode. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/CombinedRegionFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/CombinedRegionFunction.java index 3ea4c642e..114cd7fd8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/CombinedRegionFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/CombinedRegionFunction.java @@ -19,14 +19,15 @@ package com.sk89q.worldedit.function; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.math.BlockVector3; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Executes several region functions in order. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/EditContext.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/EditContext.java index b26f8d74f..9a048cd82 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/EditContext.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/EditContext.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.function; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.Pattern; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.regions.Region; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + public class EditContext { private Extent destination; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/EntityFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/EntityFunction.java index 9ce9915fa..6bbb669f0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/EntityFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/EntityFunction.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.function; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Entity; -import java.util.function.Predicate; /** * Applies a function to entities. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java index 02b3f42d0..980ba9538 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.function; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.math.BlockVector2; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Passes calls to {@link #apply(BlockVector2)} to the * delegate {@link com.sk89q.worldedit.function.FlatRegionFunction} if they @@ -54,4 +54,4 @@ public class FlatRegionMaskingFilter implements FlatRegionFunction { return mask.test(position) && function.apply(position); } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java index 5e4c7c545..321f6ca81 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.function; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Applies a {@link RegionFunction} to the first ground block. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java index 1214497b7..6b4bd0cc7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskTestFunction.java @@ -19,12 +19,13 @@ package com.sk89q.worldedit.function; -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Passes calls to {@link #apply(BlockVector3)} to the * delegate {@link RegionFunction} if they diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java index d1ab8957d..ffb0b4e47 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.function; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Passes calls to {@link #apply(BlockVector3)} to the * delegate {@link com.sk89q.worldedit.function.RegionFunction} if they diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java index 9b98bd48d..0ec6c2c80 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.function.biome; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.FlatRegionFunction; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.function.pattern.BiomePattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.world.biome.BiomeType; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Replaces the biome at the locations that this function is applied to. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/ExtentBiomeCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/ExtentBiomeCopy.java index 94f3256f3..fa1ee8b34 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/ExtentBiomeCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/ExtentBiomeCopy.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.function.biome; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.FlatRegionFunction; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.world.biome.BiomeType; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Copies the biome from one extent to another. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java index 00fbcd553..460997585 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.function.block; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Replaces blocks with a given pattern. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java index 1e5c62873..9c5675a7f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.function.block; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.worldedit.WorldEditException; @@ -34,6 +32,8 @@ import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction.Flag; import com.sk89q.worldedit.world.block.BaseBlock; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Copies blocks from one extent to another. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java index 51886a60a..eb21f28fb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.function.block; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.LayerFunction; @@ -30,6 +28,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Makes a layer of grass on top, three layers of dirt below, and smooth stone * only below that for all layers that originally consist of grass, dirt, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index 2ce4e64e4..b097b9eca 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -19,16 +19,8 @@ package com.sk89q.worldedit.function.entity; -import com.boydti.fawe.util.ReflectionUtils; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTagBuilder; -import com.sk89q.jnbt.FloatTag; -import com.sk89q.jnbt.IntTag; -import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; @@ -44,8 +36,7 @@ import com.sk89q.worldedit.util.Direction.Flag; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.entity.EntityTypes; -import java.util.Arrays; -import java.util.Map; +import static com.google.common.base.Preconditions.checkNotNull; /** * Copies entities provided to the function to the provided destination diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Apply.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Apply.java index 324fe72f1..7ff183a37 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Apply.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Apply.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.function.factory; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; - import com.sk89q.worldedit.function.Contextual; import com.sk89q.worldedit.function.EditContext; import com.sk89q.worldedit.function.RegionFunction; @@ -30,6 +27,9 @@ import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.regions.NullRegion; import com.sk89q.worldedit.regions.Region; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; + public class Apply implements Contextual { private final Region region; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java index aab9adb8d..9d0f11d2d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.function.factory; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; - import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; @@ -42,6 +39,9 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; + public class Deform implements Contextual { private Extent destination; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Paint.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Paint.java index 908608b81..4f1c1453b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Paint.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Paint.java @@ -19,12 +19,6 @@ package com.sk89q.worldedit.function.factory; -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; -import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.Contextual; @@ -39,6 +33,12 @@ import com.sk89q.worldedit.math.noise.RandomNoise; import com.sk89q.worldedit.regions.NullRegion; import com.sk89q.worldedit.regions.Region; +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; +import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; + public class Paint implements Contextual { private final Extent destination; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java index 8e65302c9..598a219fd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java @@ -1,13 +1,14 @@ package com.sk89q.worldedit.function.generator; -import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.session.ClipboardHolder; + import java.util.List; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java index 7ab06f2ff..b1bb9aaee 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java @@ -15,15 +15,13 @@ public abstract class ABlockMask extends AbstractExtentMask { super(extent); } - @Override - public boolean test(Extent extent, BlockVector3 vector) { + @Override public boolean test(Extent extent, BlockVector3 vector) { return test(vector.getBlock(extent)); } public abstract boolean test(BlockState state); - @Override - public String toString() { + @Override public String toString() { List strings = new ArrayList<>(); for (BlockType type : BlockTypesCache.values) { if (type != null) { @@ -44,8 +42,7 @@ public abstract class ABlockMask extends AbstractExtentMask { return StringMan.join(strings, ","); } - @Override - public Mask tryCombine(Mask mask) { + @Override public Mask tryCombine(Mask mask) { if (mask instanceof ABlockMask) { ABlockMask other = (ABlockMask) mask; BlockMask newMask = new BlockMask(getExtent()); @@ -57,14 +54,15 @@ public abstract class ABlockMask extends AbstractExtentMask { } } Mask tmp = newMask.tryOptimize(); - if (tmp == null) tmp = newMask; + if (tmp == null) { + tmp = newMask; + } return tmp; } return null; } - @Override - public Mask tryOr(Mask mask) { + @Override public Mask tryOr(Mask mask) { if (mask instanceof ABlockMask) { ABlockMask other = (ABlockMask) mask; BlockMask newMask = new BlockMask(getExtent()); @@ -76,7 +74,9 @@ public abstract class ABlockMask extends AbstractExtentMask { } } Mask tmp = newMask.tryOptimize(); - if (tmp == null) tmp = newMask; + if (tmp == null) { + tmp = newMask; + } return tmp; } return null; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java index dd87fafdb..e7dc75dc5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java @@ -19,11 +19,10 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.session.request.Request; + +import static com.google.common.base.Preconditions.checkNotNull; /** * An abstract implementation of {@link Mask} that takes uses an {@link Extent}. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java index 30124bb93..27ef80d40 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.world.biome.BiomeType; @@ -30,6 +28,8 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Tests true if the biome at applied points is the same as the one given. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java index 5b679f748..fb5ce2387 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java @@ -19,13 +19,14 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockCategory; + import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A mask that tests whether a block matches a given {@link BlockCategory}, or tag. */ @@ -37,6 +38,7 @@ public class BlockCategoryMask extends AbstractExtentMask { super(extent); checkNotNull(category); this.category = category; + this.category.getAll(); // load category so BlockCategory#contains actually works } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index 31259f5dd..160d1a28d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.math.BlockVector3; @@ -38,6 +36,8 @@ import java.util.List; import java.util.function.Predicate; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A mask that checks whether blocks at the given positions are matched by * a block in a list. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java index 76bc67c8a..f075f735c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java @@ -4,7 +4,6 @@ import com.boydti.fawe.command.SuggestInputParseException; import com.boydti.fawe.object.collection.FastBitSet; import com.boydti.fawe.object.string.MutableCharSequence; import com.boydti.fawe.util.StringMan; - import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.registry.state.AbstractProperty; @@ -16,7 +15,17 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; -import java.util.*; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.function.BiPredicate; import java.util.function.Predicate; import java.util.stream.Collectors; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java index 2d420cd6c..36159f9b7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java @@ -19,17 +19,18 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.HashSet; import java.util.Set; import javax.annotation.Nullable; -import org.jetbrains.annotations.NotNull; + +import static com.google.common.base.Preconditions.checkNotNull; /** * A mask that checks whether blocks at the given positions are matched by diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java index fce4714c5..6c0c7a925 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java @@ -19,12 +19,13 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkArgument; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; + import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkArgument; + /** * Has the criteria where the Y value of passed positions must be within * a certain range of Y values (inclusive). diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java index 730cb93aa..edef9f5b5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; + import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java index 55dd8e034..2385af935 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java @@ -19,17 +19,17 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; -import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; -import javax.annotation.Nullable; import java.util.function.IntSupplier; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; /** * A mask that evaluates an expression. @@ -90,4 +90,4 @@ public class ExpressionMask extends AbstractMask { return new ExpressionMask2D(expression, timeout); } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java index 123c0a54c..bf906f22e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java @@ -19,16 +19,17 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.EvaluationException; +import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.math.BlockVector2; + import java.util.function.IntSupplier; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + public class ExpressionMask2D extends AbstractMask2D { private final Expression expression; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java index 9adc170ea..99bc0f869 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java @@ -1,10 +1,10 @@ package com.sk89q.worldedit.function.mask; -import javax.annotation.Nullable; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; +import javax.annotation.Nullable; + public class InverseMask extends AbstractMask { private final Mask mask; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java index 8a9c9a4aa..eb333069e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java @@ -26,8 +26,8 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.session.request.Request; - import org.jetbrains.annotations.Nullable; + import java.util.function.Consumer; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java index 26374f2cf..d10714aae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java @@ -19,11 +19,9 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; + import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; @@ -38,6 +36,9 @@ import java.util.Set; import java.util.function.Function; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; + /** * Combines several masks and requires that all masks return true * when a certain position is tested. It serves as a logical AND operation diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java index e10dfb53d..9eb4a3f82 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection2D.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; @@ -29,6 +27,8 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Tests true if all contained masks test true. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java index 9ba06d73a..551c1f7c4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; + import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashSet; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java index a255a0436..b6c141ff7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Various utility functions related to {@link Mask} and {@link Mask2D}. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java index 22a77f209..909caefa9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java @@ -19,15 +19,16 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.noise.NoiseGenerator; + import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A mask that uses a noise generator and returns true whenever the noise * generator returns a value above the given density. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java index b4a7a5aad..0945f3143 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.noise.NoiseGenerator; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A mask that uses a noise generator and returns true whenever the noise * generator returns a value above the given density. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java index d6a3dc7f6..d086f6c88 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Checks whether another mask tests true for a position that is offset * a given vector. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java index cb0832beb..cb7b2307f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.MutableBlockVector2; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Checks whether another mask tests true for a position that is offset * a given vector. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java index 10a02ca27..b35496e1a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/RegionMask.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.function.mask; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.boydti.fawe.Fawe; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; + import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A mask that tests whether given positions are contained within a region. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java index cf28fe38f..67b0ce75b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.function.mask; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java index 10e910dde..881781271 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java @@ -2,7 +2,6 @@ package com.sk89q.worldedit.function.operation; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; -import com.sk89q.worldedit.function.visitor.FlatRegionVisitor; import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; @@ -11,6 +10,7 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; + import java.util.List; public class BackwardsExtentBlockCopy extends RegionVisitor implements Operation { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ChangeSetExecutor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ChangeSetExecutor.java index 1559d4bba..7168b3d60 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ChangeSetExecutor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ChangeSetExecutor.java @@ -19,16 +19,17 @@ package com.sk89q.worldedit.function.operation; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.object.changeset.AbstractChangeSet; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.history.changeset.ChangeSet; + import java.util.Iterator; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Performs an undo or redo from a given {@link ChangeSet}. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/DelegateOperation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/DelegateOperation.java index b0a881eae..6c1611455 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/DelegateOperation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/DelegateOperation.java @@ -19,14 +19,11 @@ package com.sk89q.worldedit.function.operation; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.collect.Iterables; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.util.formatting.text.Component; -import java.util.Collection; -import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; /** * Executes a delegete operation, but returns to another operation upon diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java index e12921516..5c8f188c4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.operation; -import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard; import com.boydti.fawe.object.extent.BlockTranslateExtent; import com.boydti.fawe.object.extent.PositionTransformExtent; import com.boydti.fawe.object.function.block.BiomeCopy; @@ -32,9 +31,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.metadata.EntityProperties; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.FastSchematicReader; import com.sk89q.worldedit.function.CombinedRegionFunction; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionMaskTestFunction; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/OperationQueue.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/OperationQueue.java index b9a9a36ab..09b45f8e0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/OperationQueue.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/OperationQueue.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.function.operation; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.sk89q.worldedit.WorldEditException; @@ -32,6 +30,8 @@ import java.util.Deque; import java.util.List; import java.util.stream.Collectors; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Executes multiple queues in order. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetBlockMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetBlockMap.java index 99607ae16..ede81dea5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetBlockMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetBlockMap.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.function.operation; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.util.LocatedBlock; import com.sk89q.worldedit.util.collection.BlockMap; import com.sk89q.worldedit.world.block.BaseBlock; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetLocatedBlocks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetLocatedBlocks.java index 2989bdcec..68c120904 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetLocatedBlocks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetLocatedBlocks.java @@ -19,13 +19,11 @@ package com.sk89q.worldedit.function.operation; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.util.LocatedBlock; -import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; public class SetLocatedBlocks implements Operation { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java index a934bc17a..d2b516fd4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.function.pattern; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A pattern that returns the same {@link BaseBlock} each time. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java index 3e02cdfaa..3539a110c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java @@ -22,8 +22,6 @@ package com.sk89q.worldedit.function.pattern; import com.boydti.fawe.object.collection.RandomCollection; import com.boydti.fawe.object.random.SimpleRandom; import com.boydti.fawe.object.random.TrueRandom; - -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; @@ -34,6 +32,8 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Uses a random pattern of a weighted list of patterns. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java index 0746ac06b..cfef0cf92 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java @@ -19,14 +19,13 @@ package com.sk89q.worldedit.function.pattern; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Returns the blocks from {@link Extent}, repeating when out of bounds. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java index a8610b80d..d84b2d2ac 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.pattern; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java index 9682ff378..f21368c72 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.function.util; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.math.BlockVector2; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Offsets the position parameter by adding a given offset vector. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java index 7ac57da1f..b721d7dbb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.function.util; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector3; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Offsets the position parameter by adding a given offset vector. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index e85b7a4f1..8ae8a7168 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -19,12 +19,8 @@ package com.sk89q.worldedit.function.visitor; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.collect.ImmutableList; - -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.collection.BlockVectorSet; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; @@ -32,16 +28,20 @@ import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; -import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.Direction; +import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Performs a breadth-first search starting from points added with * {@link #visit(BlockVector3)}. The search continues diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java index 3d03c6c49..3283d24c6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.function.visitor; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Visits adjacent points on the same X-Z plane as long as the points * pass the given mask, and then executes the provided region diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/EntityVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/EntityVisitor.java index 9d4405ca2..3d0444cf7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/EntityVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/EntityVisitor.java @@ -20,22 +20,19 @@ package com.sk89q.worldedit.function.visitor; import com.google.common.collect.ImmutableList; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.collect.Lists; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.EntityFunction; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; import java.util.Iterator; -import com.sk89q.worldedit.util.formatting.text.TextComponent; -import com.sk89q.worldedit.util.formatting.text.format.TextColor; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Visits entities as provided by an {@code Iterator}. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java index 799f69bb1..d15557670 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java @@ -20,21 +20,19 @@ package com.sk89q.worldedit.function.visitor; import com.google.common.collect.ImmutableList; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; - -import com.google.common.collect.Lists; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.regions.FlatRegion; - -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Applies region functions to columns in a {@link FlatRegion}. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java index 3fed7f678..b3b49a2b1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.function.visitor; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.LayerFunction; import com.sk89q.worldedit.function.mask.Mask2D; @@ -32,7 +29,8 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.FlatRegion; -import java.util.List; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; /** * Visits the layers within a region. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/NonRisingVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/NonRisingVisitor.java index 1bafdb45d..ca3396675 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/NonRisingVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/NonRisingVisitor.java @@ -23,8 +23,6 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; -import java.util.Collection; - /** * A {@link RecursiveVisitor} that goes orthogonally to the side and down, but never up. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java index 0ce97d0c8..62ffb185e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.function.visitor; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; +import static com.google.common.base.Preconditions.checkNotNull; + /** * An implementation of an {@link BreadthFirstSearch} that uses a mask to * determine where a block should be visited. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java index 7e8b00667..92ebb7673 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/ScanChunk.java @@ -4,6 +4,7 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector3; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.LongArraySet; + import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BiomeChange.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BiomeChange.java index f8c0ef597..8ca920042 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BiomeChange.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BiomeChange.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.history.change; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.world.biome.BiomeType; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents a biome change that may be undone or replayed. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java index ce7c26926..637c4375d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.history.change; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.history.UndoContext; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents a block change that may be undone or replayed. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityCreate.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityCreate.java index e406f8403..79330510e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityCreate.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityCreate.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.history.change; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.util.Location; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Logs the creation of an entity and removes the entity upon undo. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityRemove.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityRemove.java index 3af1c4072..8ad6c9ae0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityRemove.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/EntityRemove.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.history.change; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.util.Location; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Tracks the removal of an entity. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java index 47c957419..f9d31b78f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.history.changeset; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.object.changeset.SimpleChangeSetSummary; import com.google.common.collect.Lists; import com.sk89q.worldedit.history.change.BlockChange; @@ -32,6 +30,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Stores all {@link Change}s in an {@link ArrayList}. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java index 05ac90c78..8d01e153f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.history.changeset; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.collect.Iterators; import com.sk89q.worldedit.history.change.BlockChange; import com.sk89q.worldedit.history.change.Change; @@ -31,6 +29,8 @@ import com.sk89q.worldedit.util.collection.LocatedBlockList; import java.util.ArrayList; import java.util.Iterator; +import static com.google.common.base.Preconditions.checkNotNull; + /** * An extension of {@link ArrayListHistory} that stores {@link BlockChange}s * separately in two {@link ArrayList}s. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSetSummary.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSetSummary.java index 78e4a8b8a..b8367ea3b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSetSummary.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSetSummary.java @@ -2,7 +2,6 @@ package com.sk89q.worldedit.history.changeset; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypesCache; import java.util.ArrayList; import java.util.HashMap; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java index 665210694..d0f25e16a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java @@ -38,7 +38,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; -import java.nio.file.StandardOpenOption; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java index 5447b944a..67eda6795 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java @@ -23,9 +23,9 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.registry.BlockRegistry; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import javax.annotation.Nullable; import java.util.BitSet; import java.util.OptionalInt; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkState; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/ConfirmHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/ConfirmHandler.java index 3f3f7786a..5396da859 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/ConfirmHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/ConfirmHandler.java @@ -22,13 +22,13 @@ package com.sk89q.worldedit.internal.command; import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.formatting.text.TextComponent; -import java.util.Optional; import org.enginehub.piston.CommandParameters; import org.enginehub.piston.exception.StopExecutionException; import org.enginehub.piston.gen.CommandCallListener; import org.enginehub.piston.inject.Key; import java.lang.reflect.Method; +import java.util.Optional; /** * Logs called commands to a logger. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/MethodInjector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/MethodInjector.java index f0ead981f..0ca5e85b7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/MethodInjector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/MethodInjector.java @@ -2,13 +2,11 @@ package com.sk89q.worldedit.internal.command; import org.enginehub.piston.CommandParameters; import org.enginehub.piston.gen.CommandCallListener; -import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.InjectedValueStore; import org.enginehub.piston.inject.Key; import org.enginehub.piston.util.ValueProvider; import java.lang.reflect.Method; -import java.util.Optional; public class MethodInjector implements CommandCallListener { @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java index 2ca8f3bd3..e56b6a135 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java @@ -38,7 +38,6 @@ import com.sk89q.worldedit.world.block.BlockTypes; import java.util.HashMap; import java.util.Map; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ExpressionHandles.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ExpressionHandles.java index 892fca4fd..1985c5a99 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ExpressionHandles.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ExpressionHandles.java @@ -30,7 +30,6 @@ import it.unimi.dsi.fastutil.doubles.Double2ObjectMaps; import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.Token; -import javax.annotation.Nullable; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -38,6 +37,7 @@ import java.util.Objects; import java.util.function.DoubleBinaryOperator; import java.util.function.Supplier; import java.util.stream.Collectors; +import javax.annotation.Nullable; import static com.sk89q.worldedit.internal.expression.ExpressionHelper.check; import static com.sk89q.worldedit.internal.expression.ExpressionHelper.checkIterations; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ReturnException.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ReturnException.java index bd4a757fb..66066223f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ReturnException.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ReturnException.java @@ -22,9 +22,11 @@ package com.sk89q.worldedit.internal.expression.invoke; /** * Thrown when a return is encountered, to pop the stack frames and return the value easily. * + *

* Should be caught by the executor. + *

*/ -class ReturnException extends RuntimeException { +public class ReturnException extends RuntimeException { private final Double result; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java index a5844306d..0ad5e90b7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.internal.registry; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.NoMatchException; @@ -31,6 +29,8 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import static com.google.common.base.Preconditions.checkNotNull; + /** * An abstract implementation of a factory for internal usage. * @@ -58,7 +58,9 @@ public abstract class AbstractFactory { /** * Gets an immutable list of parsers. * + *

* To add parsers, use the register method. + *

* * @return the parsers */ @@ -82,12 +84,12 @@ public abstract class AbstractFactory { public List getSuggestions(String input) { return parsers.stream().flatMap( - p -> p.getSuggestions(input) + p -> p.getSuggestions(input) ).collect(Collectors.toList()); } /** - * Registers an InputParser to this factory + * Registers an InputParser to this factory. * * @param inputParser The input parser */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/BiomeMath.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/BiomeMath.java index a8e4a9518..c2d6abfe1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/BiomeMath.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/BiomeMath.java @@ -25,7 +25,7 @@ public class BiomeMath { // From BiomeArray / BiomeContainer public static final int HORIZONTAL_SECTION_COUNT = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2; - public static final int VERTICAL_SECTION_COUNT = (int)Math.round(Math.log(256.0D) / Math.log(2.0D)) - 2; + public static final int VERTICAL_SECTION_COUNT = (int) Math.round(Math.log(256.0D) / Math.log(2.0D)) - 2; public static final int HORIZONTAL_BIT_MASK = (1 << HORIZONTAL_SECTION_COUNT) - 1; public static final int VERTICAL_BIT_MASK = (1 << VERTICAL_SECTION_COUNT) - 1; @@ -41,9 +41,9 @@ public class BiomeMath { * @return the index into the standard MC biome array */ public static int computeBiomeIndex(int x, int y, int z) { - int l = x & HORIZONTAL_BIT_MASK; - int m = MathHelper.clamp(y, 0, VERTICAL_BIT_MASK); - int n = z & HORIZONTAL_BIT_MASK; + int l = (x >> 2) & HORIZONTAL_BIT_MASK; + int m = MathHelper.clamp(y >> 2, 0, VERTICAL_BIT_MASK); + int n = (z >> 2) & HORIZONTAL_BIT_MASK; return m << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT | n << HORIZONTAL_SECTION_COUNT | l; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/DeprecationUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/DeprecationUtil.java new file mode 100644 index 000000000..089d0411a --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/DeprecationUtil.java @@ -0,0 +1,109 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.internal.util; + +import com.google.common.base.Joiner; +import com.google.common.base.Throwables; +import com.sk89q.worldedit.world.block.BlockCategories; +import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.BlockTypes; + +import java.lang.reflect.Method; +import java.util.stream.Stream; + +public class DeprecationUtil { + + private DeprecationUtil() { + } + + /** + * Verify that one of the two functions is overridden. Caller method must be the new method, + * annotated with {@link NonAbstractForCompatibility}. + * + * @param implementingClass the result of calling {@link Object#getClass()} + */ + public static void checkDelegatingOverride(Class implementingClass) { + // pull the information about the caller + StackTraceElement caller = Throwables.lazyStackTrace(new Throwable()).get(1); + // find the matching caller method + Method callingMethod = getCallingMethod(caller); + NonAbstractForCompatibility annotation = + callingMethod.getAnnotation(NonAbstractForCompatibility.class); + // get the deprecated method + Method deprecatedMethod; + try { + deprecatedMethod = implementingClass.getMethod( + annotation.delegateName(), annotation.delegateParams() + ); + } catch (NoSuchMethodException e) { + throw new AssertionError( + "Missing method referenced by " + NonAbstractForCompatibility.class, e + ); + } + // Check if the deprecated method was overridden. If the declaring class is the caller's + // class, then it wasn't. That means that the caller method (i.e. the new method) should be + // overridden by the implementing class. + // There's no need to check if the new method has been overridden, since the only other + // way this could be reached is if someone calls `super.xyz`, which they have no reason to. + if (deprecatedMethod.getDeclaringClass().getName().equals(caller.getClassName())) { + throw new IllegalStateException("Class " + implementingClass.getName() + + " must override " + methodToString(callingMethod)); + } + } + + private static Method getCallingMethod(StackTraceElement callerInfo) { + Method[] declaredMethods; + try { + declaredMethods = Class.forName(callerInfo.getClassName()).getDeclaredMethods(); + } catch (ClassNotFoundException e) { + throw new AssertionError("Caller class missing?", e); + } + for (Method declaredMethod : declaredMethods) { + if (declaredMethod.isAnnotationPresent(NonAbstractForCompatibility.class) + && declaredMethod.getName().equals(callerInfo.getMethodName())) { + return declaredMethod; + } + } + throw new IllegalStateException("Failed to find caller method " + + callerInfo.getMethodName() + " annotated with " + NonAbstractForCompatibility.class); + } + + private static String methodToString(Method method) { + StringBuilder builder = new StringBuilder(method.getDeclaringClass().getCanonicalName()) + .append('.') + .append(method.getName()) + .append('('); + Joiner.on(", ").appendTo(builder, Stream.of(method.getParameterTypes()) + .map(Class::getSimpleName) + .iterator()); + builder.append(')'); + return builder.toString(); + } + + public static boolean isSign(BlockType blockType) { + @SuppressWarnings("deprecation") + BlockType sign = BlockTypes.SIGN; + @SuppressWarnings("deprecation") + BlockType wallSign = BlockTypes.WALL_SIGN; + return blockType == sign || blockType == wallSign + || BlockCategories.SIGNS.contains(blockType); + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/NonAbstractForCompatibility.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/NonAbstractForCompatibility.java new file mode 100644 index 000000000..f67131d73 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/NonAbstractForCompatibility.java @@ -0,0 +1,57 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.internal.util; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * The annotated method is only non-{@code abstract} for compatibility with old subclasses, + * and will be made {@code abstract} in the next major version of WorldEdit. + * + *

+ * Any new subclasses must override the annotated method, failing to do so will result in + * an exception at runtime. + *

+ */ +@Documented +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface NonAbstractForCompatibility { + + // Note that this annotation only functions properly if no other method in the same class + // shares the name of the annotated function AND is also annotated with this annotation. + // Otherwise, we cannot uniquely determine the calling method via reflection hacks. + // This could be changed, but it's not currently necessary. + + /** + * The name of the method delegated to by the annotated method. + */ + String delegateName(); + + /** + * The parameter types of the method delegated to by the annotated method. + */ + Class[] delegateParams(); + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/Substring.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/Substring.java index 0ffe91d71..7a3ddfdbe 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/Substring.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/Substring.java @@ -77,12 +77,16 @@ public final class Substring { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } Substring substring1 = (Substring) o; - return start == substring1.start && - end == substring1.end && - substring.equals(substring1.substring); + return start == substring1.start + && end == substring1.end + && substring.equals(substring1.substring); } @Override @@ -92,10 +96,10 @@ public final class Substring { @Override public String toString() { - return "Substring{" + - "substring='" + substring + "'" + - ",start=" + start + - ",end=" + end + - "}"; + return "Substring{" + + "substring='" + substring + "'" + + ",start=" + start + + ",end=" + end + + "}"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java index 84fcace71..f2b4dc967 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.math; import com.sk89q.worldedit.math.transform.AffineTransform; + import java.util.Comparator; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java index bb9448e8a..1023ebfc6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java @@ -18,21 +18,22 @@ */ package com.sk89q.worldedit.math; -import static com.sk89q.worldedit.math.BitMath.mask; -import static com.sk89q.worldedit.math.BitMath.unpackX; -import static com.sk89q.worldedit.math.BitMath.unpackY; -import static com.sk89q.worldedit.math.BitMath.unpackZ; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.transform.AffineTransform; - -import static com.google.common.base.Preconditions.checkArgument; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; + import java.util.Comparator; +import static com.google.common.base.Preconditions.checkArgument; +import static com.sk89q.worldedit.math.BitMath.mask; +import static com.sk89q.worldedit.math.BitMath.unpackX; +import static com.sk89q.worldedit.math.BitMath.unpackY; +import static com.sk89q.worldedit.math.BitMath.unpackZ; + /** * An immutable 3-dimensional vector. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java index dd7399c64..025c1beed 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java @@ -19,13 +19,6 @@ package com.sk89q.worldedit.math; -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.collect.ComparisonChain; -import com.sk89q.worldedit.math.transform.AffineTransform; - -import java.util.Comparator; - /** * An immutable 3-dimensional vector. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java index c14cb7cd9..ff3461e0f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.math; -import static com.google.common.base.Preconditions.checkArgument; - import com.boydti.fawe.util.MathMan; import com.google.common.collect.ComparisonChain; import com.sk89q.worldedit.math.transform.AffineTransform; import java.util.Comparator; +import static com.google.common.base.Preconditions.checkArgument; + /** * An immutable 3-dimensional vector. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index ea4d57ff3..ee9a4645a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.math.convolution; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.function.mask.Mask; @@ -32,9 +30,12 @@ import com.sk89q.worldedit.registry.state.PropertyGroup; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; + import java.util.Iterator; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Allows applications of Kernels onto the region's height map. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java index 9c370ee5a..b7dac41aa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java @@ -21,13 +21,14 @@ package com.sk89q.worldedit.math.interpolation; -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector3; import java.util.Collections; import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A Kochanek-Bartels interpolation; continuous in the 2nd derivative. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java index 7b701f5fe..1378ddd14 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java @@ -21,12 +21,12 @@ package com.sk89q.worldedit.math.interpolation; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.Vector3; import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Simple linear interpolation. Mainly used for testing. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java index 1da9d5b2d..97f8b8920 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.math.noise; import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.math.Vector3; - import net.royawesome.jlibnoise.module.Module; import java.util.Random; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java index 0415a36c1..1dd893484 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.math.transform; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MathUtils; import com.sk89q.worldedit.math.Vector3; + import java.io.Serializable; /** @@ -38,23 +39,32 @@ public class AffineTransform implements Transform, Serializable { /** * coefficients for x coordinate. */ - private double m00, m01, m02, m03; + private final double m00; + private final double m01; + private final double m02; + private double m03; /** * coefficients for y coordinate. */ - private double m10, m11, m12, m13; + private final double m10; + private final double m11; + private final double m12; + private double m13; /** * coefficients for z coordinate. */ - private double m20, m21, m22, m23; + private final double m20; + private final double m21; + private final double m22; + private double m23; // =================================================================== // constructors /** - * Creates a new affine transform3D set to identity + * Creates a new affine transform3D set to identity. */ public AffineTransform() { // init to identity matrix @@ -89,14 +99,11 @@ public class AffineTransform implements Transform, Serializable { m22 = coefs[10]; m23 = coefs[11]; } else { - throw new IllegalArgumentException( - "Input array must have 9 or 12 elements"); + throw new IllegalArgumentException("Input array must have 9 or 12 elements"); } } - public AffineTransform(double xx, double yx, double zx, double tx, - double xy, double yy, double zy, double ty, double xz, double yz, - double zz, double tz) { + public AffineTransform(double xx, double yx, double zx, double tx, double xy, double yy, double zy, double ty, double xz, double yz, double zz, double tz) { m00 = xx; m01 = yx; m02 = zx; @@ -116,31 +123,40 @@ public class AffineTransform implements Transform, Serializable { @Override public boolean isIdentity() { - if (m00 != 1) + if (m00 != 1) { return false; - if (m11 != 1) + } + if (m11 != 1) { return false; - if (m22 != 1) + } + if (m22 != 1) { return false; - if (m01 != 0) + } + if (m01 != 0) { return false; - if (m02 != 0) + } + if (m02 != 0) { return false; - if (m03 != 0) + } + if (m03 != 0) { return false; - if (m10 != 0) + } + if (m10 != 0) { return false; - if (m12 != 0) + } + if (m12 != 0) { return false; - if (m13 != 0) + } + if (m13 != 0) { return false; - if (m20 != 0) + } + if (m20 != 0) { return false; - if (m21 != 0) + } + if (m21 != 0) { return false; - if (m23 != 0) - return false; - return true; + } + return m23 == 0; } /** @@ -148,7 +164,20 @@ public class AffineTransform implements Transform, Serializable { * 12 double. */ public double[] coefficients() { - return new double[]{m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23}; + return new double[] { + m00, + m01, + m02, + m03, + m10, + m11, + m12, + m13, + m20, + m21, + m22, + m23 + }; } public boolean isOffAxis() { @@ -169,8 +198,8 @@ public class AffineTransform implements Transform, Serializable { * @return the determinant of the transform. */ private double determinant() { - return m00 * (m11 * m22 - m12 * m21) - m01 * (m10 * m22 - m20 * m12) - + m02 * (m10 * m21 - m20 * m11); + return m00 * (m11 * m22 - m12 * m21) - m01 * (m10 * m22 - m20 * m12) + m02 * (m10 * m21 + - m20 * m11); } /** @@ -178,24 +207,26 @@ public class AffineTransform implements Transform, Serializable { */ @Override public AffineTransform inverse() { - if (inverse != null) return inverse; + if (inverse != null) { + return inverse; + } double det = this.determinant(); return new AffineTransform( - (m11 * m22 - m21 * m12) / det, - (m21 * m02 - m01 * m22) / det, - (m01 * m12 - m11 * m02) / det, - (m01 * (m22 * m13 - m12 * m23) + m02 * (m11 * m23 - m21 * m13) - - m03 * (m11 * m22 - m21 * m12)) / det, - (m20 * m12 - m10 * m22) / det, - (m00 * m22 - m20 * m02) / det, - (m10 * m02 - m00 * m12) / det, - (m00 * (m12 * m23 - m22 * m13) - m02 * (m10 * m23 - m20 * m13) - + m03 * (m10 * m22 - m20 * m12)) / det, - (m10 * m21 - m20 * m11) / det, - (m20 * m01 - m00 * m21) / det, - (m00 * m11 - m10 * m01) / det, - (m00 * (m21 * m13 - m11 * m23) + m01 * (m10 * m23 - m20 * m13) - - m03 * (m10 * m21 - m20 * m11)) / det); + (m11 * m22 - m21 * m12) / det, + (m21 * m02 - m01 * m22) / det, + (m01 * m12 - m11 * m02) / det, + (m01 * (m22 * m13 - m12 * m23) + m02 * (m11 * m23 - m21 * m13) - m03 * (m11 * m22 + - m21 * m12)) / det, + (m20 * m12 - m10 * m22) / det, + (m00 * m22 - m20 * m02) / det, + (m10 * m02 - m00 * m12) / det, + (m00 * (m12 * m23 - m22 * m13) - m02 * (m10 * m23 - m20 * m13) + m03 * (m10 * m22 + - m20 * m12)) / det, + (m10 * m21 - m20 * m11) / det, + (m20 * m01 - m00 * m21) / det, + (m00 * m11 - m10 * m01) / det, + (m00 * (m21 * m13 - m11 * m23) + m01 * (m10 * m23 - m20 * m13) - m03 * (m10 * m21 + - m20 * m11)) / det); } // =================================================================== @@ -221,10 +252,7 @@ public class AffineTransform implements Transform, Serializable { double n21 = m20 * that.m01 + m21 * that.m11 + m22 * that.m21; double n22 = m20 * that.m02 + m21 * that.m12 + m22 * that.m22; double n23 = m20 * that.m03 + m21 * that.m13 + m22 * that.m23 + m23; - return new AffineTransform( - n00, n01, n02, n03, - n10, n11, n12, n13, - n20, n21, n22, n23); + return new AffineTransform(n00, n01, n02, n03, n10, n11, n12, n13, n20, n21, n22, n23); } /** @@ -247,10 +275,7 @@ public class AffineTransform implements Transform, Serializable { double n21 = that.m20 * m01 + that.m21 * m11 + that.m22 * m21; double n22 = that.m20 * m02 + that.m21 * m12 + that.m22 * m22; double n23 = that.m20 * m03 + that.m21 * m13 + that.m22 * m23 + that.m23; - return new AffineTransform( - n00, n01, n02, n03, - n10, n11, n12, n13, - n20, n21, n22, n23); + return new AffineTransform(n00, n01, n02, n03, n10, n11, n12, n13, n20, n21, n22, n23); } public AffineTransform translate(Vector3 vec) { @@ -268,31 +293,19 @@ public class AffineTransform implements Transform, Serializable { public AffineTransform rotateX(double theta) { double cot = MathUtils.dCos(theta); double sit = MathUtils.dSin(theta); - return concatenate( - new AffineTransform( - 1, 0, 0, 0, - 0, cot, -sit, 0, - 0, sit, cot, 0)); + return concatenate(new AffineTransform(1, 0, 0, 0, 0, cot, -sit, 0, 0, sit, cot, 0)); } public AffineTransform rotateY(double theta) { double cot = MathUtils.dCos(theta); double sit = MathUtils.dSin(theta); - return concatenate( - new AffineTransform( - cot, 0, sit, 0, - 0, 1, 0, 0, - -sit, 0, cot, 0)); + return concatenate(new AffineTransform(cot, 0, sit, 0, 0, 1, 0, 0, -sit, 0, cot, 0)); } public AffineTransform rotateZ(double theta) { double cot = MathUtils.dCos(theta); double sit = MathUtils.dSin(theta); - return concatenate( - new AffineTransform( - cot, -sit, 0, 0, - sit, cot, 0, 0, - 0, 0, 1, 0)); + return concatenate(new AffineTransform(cot, -sit, 0, 0, sit, cot, 0, 0, 0, 0, 1, 0)); } public AffineTransform scale(double s) { @@ -309,9 +322,15 @@ public class AffineTransform implements Transform, Serializable { public boolean isScaled(Vector3 vector) { boolean flip = false; - if (vector.getX() != 0 && m00 < 0) flip = !flip; - if (vector.getY() != 0 && m11 < 0) flip = !flip; - if (vector.getZ() != 0 && m22 < 0) flip = !flip; + if (vector.getX() != 0 && m00 < 0) { + flip = !flip; + } + if (vector.getY() != 0 && m11 < 0) { + flip = !flip; + } + if (vector.getZ() != 0 && m22 < 0) { + flip = !flip; + } return flip; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java index e5f2a2586..0baf52899 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.math.transform; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.Vector3; import java.util.ArrayList; @@ -28,6 +26,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Combines several transforms in order. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java index 5d0412259..71286507b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java @@ -19,10 +19,10 @@ package com.sk89q.worldedit.math.transform; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.util.Location; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Various utility methods related to {@link Transform}s. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java index 0cdd5348a..c33d371bd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.regions; import com.boydti.fawe.object.collection.BlockVectorSet; -import com.google.common.primitives.Longs; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; @@ -112,9 +111,9 @@ public abstract class AbstractRegion extends AbstractSet implement BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - return (max.getX() - min.getX() + 1L) * - (max.getY() - min.getY() + 1L) * - (max.getZ() - min.getZ() + 1L); + return (max.getX() - min.getX() + 1L) + * (max.getY() - min.getY() + 1L) + * (max.getZ() - min.getZ() + 1L); } /** @@ -220,24 +219,25 @@ public abstract class AbstractRegion extends AbstractSet implement @Override public boolean equals(Object o) { - if(o == this) { + if (o == this) { return true; } - if(!(o instanceof Region)){ + if (!(o instanceof Region)) { return false; } Region region = ((Region) o); - if(this.getWorld() != region.getWorld()){ - if(this.getWorld() == null || region.getWorld() == null){ + if (this.getWorld() != region.getWorld()) { + if (this.getWorld() == null || region.getWorld() == null) { return false; } } - if(this.getWorld().equals(region.getWorld()) - && this.getMinimumPoint().equals(region.getMinimumPoint()) - && this.getMaximumPoint().equals(region.getMaximumPoint()) - && this.getVolume() == region.getVolume()){ + if (this.getWorld().equals(region.getWorld()) + && this.getMinimumPoint().equals(region.getMinimumPoint()) + && this.getMaximumPoint().equals(region.getMaximumPoint()) + && this.getVolume() == region.getVolume()) { return true; } return false; } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java index 9e21a24a8..ec4acb33a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.regions; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.polyhedron.Edge; @@ -33,9 +31,10 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + public class ConvexPolyhedralRegion extends AbstractRegion { /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index f54749b42..acaff7439 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -19,15 +19,12 @@ package com.sk89q.worldedit.regions; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.collection.BlockVectorSet; import com.sk89q.worldedit.math.BlockVector2; @@ -36,12 +33,15 @@ import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.ChunkStore; +import org.jetbrains.annotations.NotNull; import java.util.AbstractSet; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Set; -import org.jetbrains.annotations.NotNull; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; /** * An axis-aligned cuboid. It can be defined using two corners of the cuboid. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java index faf78b7f7..fd337da2c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java @@ -19,13 +19,11 @@ package com.sk89q.worldedit.regions; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; @@ -41,6 +39,8 @@ import java.math.RoundingMode; import java.util.Iterator; import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents a cylindrical region. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/IDelegateRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/IDelegateRegion.java index ad08dbaba..4f8e90ed1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/IDelegateRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/IDelegateRegion.java @@ -6,10 +6,10 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.World; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; import java.util.Iterator; import java.util.List; import java.util.Set; +import javax.annotation.Nullable; public interface IDelegateRegion extends Region { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index 549faf501..1bc811d5d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -35,7 +35,6 @@ import com.sk89q.worldedit.world.World; import java.util.List; import java.util.Set; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java index c56d9413f..2d065a4d6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java @@ -30,7 +30,6 @@ import com.sk89q.worldedit.world.World; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java index f607c5172..0d6fec7c0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionSelector.java @@ -29,13 +29,12 @@ import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.World; +import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import org.jetbrains.annotations.Nullable; - /** * Region selectors create {@link Region}s from a series of "selected points." * They are used, for example, to allow users to create a {@link CuboidRegion} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java index 733313421..51f5b7ca8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.regions; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; @@ -31,9 +29,10 @@ import com.sk89q.worldedit.world.World; import java.util.ArrayList; import java.util.Iterator; import java.util.List; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Transforms another region according to a provided vector {@code Transform}. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java index 6a7a06780..bc332c0b0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.regions.iterator; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.FlatRegion; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.regions.FlatRegion; import java.util.Iterator; import java.util.NoSuchElementException; +import static com.google.common.base.Preconditions.checkNotNull; + public class FlatRegion3DIterator implements Iterator { private Iterator flatIterator; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java index 8bd0a48dc..842986c0d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.regions.iterator; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.regions.Region; import java.util.Iterator; import java.util.NoSuchElementException; +import static com.google.common.base.Preconditions.checkNotNull; + public class FlatRegionIterator implements Iterator { private Region region; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java index c01dfe213..023c5b51b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.regions.iterator; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import java.util.Iterator; +import static com.google.common.base.Preconditions.checkNotNull; + public class RegionIterator implements Iterator { private final Region region; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java index dcf098d3c..9e882520a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java @@ -19,10 +19,10 @@ package com.sk89q.worldedit.regions.polyhedron; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.Vector3; +import static com.google.common.base.Preconditions.checkNotNull; + public class Edge { private final Vector3 start; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java index 5e5f7a770..82140491c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java @@ -19,10 +19,10 @@ package com.sk89q.worldedit.regions.polyhedron; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.Vector3; +import static com.google.common.base.Preconditions.checkNotNull; + public class Triangle { private String tag = "Triangle"; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java index 09156446b..06c5ed326 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.regions.selector; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; @@ -45,9 +43,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Creates a {@code ConvexPolyhedralRegion} from a user's selections. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java index dab4721d8..003ba8a7c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.regions.selector; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; @@ -40,9 +38,10 @@ import com.sk89q.worldedit.world.World; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Creates a {@code CuboidRegion} from a user's selections. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java index 10de56191..d246dbe1b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.regions.selector; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; @@ -39,14 +36,16 @@ import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.limit.SelectorLimits; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Creates a {@code CylinderRegionSelector} from a user's selections. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java index c42de1fad..9c9ce4ad2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.regions.selector; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; @@ -40,9 +38,10 @@ import com.sk89q.worldedit.world.World; import java.util.ArrayList; import java.util.List; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Creates a {@code EllipsoidRegionSelector} from a user's selections. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java index 3ab10dfc2..8455f9685 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.regions.selector; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extension.platform.Actor; @@ -42,9 +40,10 @@ import com.sk89q.worldedit.world.World; import java.util.Collections; import java.util.List; import java.util.Optional; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Creates a {@code Polygonal2DRegion} from a user's selections. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/NamespacedRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/NamespacedRegistry.java index c6bd40ca3..4b5033241 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/NamespacedRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/NamespacedRegistry.java @@ -19,10 +19,6 @@ package com.sk89q.worldedit.registry; -import static com.google.common.base.Preconditions.checkState; -import static java.util.Objects.requireNonNull; -import static org.enginehub.piston.converter.SuggestionHelper.byPrefix; - import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -33,6 +29,10 @@ import java.util.function.Predicate; import java.util.stream.Stream; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; +import static org.enginehub.piston.converter.SuggestionHelper.byPrefix; + public final class NamespacedRegistry extends Registry { private static final String MINECRAFT_NAMESPACE = "minecraft"; private final Set knownNamespaces = new HashSet<>(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java index f5e02aee6..e5a979039 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.registry; -import static com.google.common.base.Preconditions.checkState; -import static java.util.Objects.requireNonNull; - import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -29,9 +26,11 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Set; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; + public class Registry implements Iterable { private final Map map = new HashMap<>(); private final String name; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java index 777e8afc9..a301ca905 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java @@ -20,13 +20,12 @@ package com.sk89q.worldedit.registry.state; import com.boydti.fawe.util.MathMan; - -import static com.google.common.base.Preconditions.checkState; -import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; -import javax.annotation.Nullable; import java.util.List; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkState; public abstract class AbstractProperty implements Property { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/BooleanProperty.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/BooleanProperty.java index 2c72d6ee0..63b19f6d7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/BooleanProperty.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/BooleanProperty.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.registry.state; import java.util.List; - import javax.annotation.Nullable; public class BooleanProperty extends AbstractProperty { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalProperty.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalProperty.java index 17f71604c..0df593340 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalProperty.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/DirectionalProperty.java @@ -24,7 +24,6 @@ import com.sk89q.worldedit.util.Direction; import java.util.Arrays; import java.util.List; import java.util.Locale; - import javax.annotation.Nullable; public class DirectionalProperty extends AbstractProperty { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/IntegerProperty.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/IntegerProperty.java index 225846eff..78144e43e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/IntegerProperty.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/IntegerProperty.java @@ -23,7 +23,6 @@ import com.boydti.fawe.util.StringMan; import java.util.Collections; import java.util.List; - import javax.annotation.Nullable; public class IntegerProperty extends AbstractProperty { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/Property.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/Property.java index 01e59dcd3..a35cfd5d9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/Property.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/Property.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.registry.state; import java.util.List; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/PropertyGroup.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/PropertyGroup.java index f8d233fb5..fc2fee400 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/PropertyGroup.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/PropertyGroup.java @@ -1,13 +1,11 @@ package com.sk89q.worldedit.registry.state; -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 com.sk89q.worldedit.world.block.BlockTypesCache; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.function.Function; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/PropertyKey.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/PropertyKey.java index 89f59a279..0b0776215 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/PropertyKey.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/PropertyKey.java @@ -1,6 +1,7 @@ package com.sk89q.worldedit.registry.state; import com.boydti.fawe.util.ReflectionUtils; + import java.util.HashMap; import java.util.Locale; import java.util.Map; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptEngine.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptEngine.java index 8f946800f..c5423aa88 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptEngine.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptEngine.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.scripting; import java.util.Map; - import javax.script.ScriptException; public interface CraftScriptEngine { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/NashornCraftScriptEngine.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/NashornCraftScriptEngine.java index cbfbce69d..0ee6d71e4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/NashornCraftScriptEngine.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/NashornCraftScriptEngine.java @@ -23,10 +23,10 @@ import com.boydti.fawe.Fawe; import com.sk89q.worldedit.WorldEditException; import jdk.nashorn.api.scripting.NashornScriptEngineFactory; +import java.util.Map; import javax.script.ScriptEngine; import javax.script.ScriptException; import javax.script.SimpleBindings; -import java.util.Map; public class NashornCraftScriptEngine implements CraftScriptEngine { private static NashornScriptEngineFactory FACTORY; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java index b61edb0d3..04f7cb399 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java @@ -35,6 +35,14 @@ public class RhinoContextFactory extends ContextFactory { @Override protected Context makeContext() { RhinoContext cx = new RhinoContext(this); + try { + // Try to set ES6 compat flag (since 1.7.7) + Context.class.getDeclaredField("VERSION_ES6"); + cx.setLanguageVersion(RhinoContext.VERSION_ES6); + } catch (NoSuchFieldException e) { + // best we can do, compatible with 1.7R2 that many people probably use + cx.setLanguageVersion(Context.VERSION_1_7); + } cx.setInstructionObserverThreshold(10000); return cx; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java index 8d56d86db..d48b6461c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java @@ -31,9 +31,9 @@ import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.ScriptableObject; import org.mozilla.javascript.WrappedException; -import javax.script.ScriptException; import java.io.StringReader; import java.util.Map; +import javax.script.ScriptException; public class RhinoCraftScriptEngine implements CraftScriptEngine { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/ClipboardHolder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/ClipboardHolder.java index 93e6b2b4a..8f78bcbe5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/ClipboardHolder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/ClipboardHolder.java @@ -19,18 +19,16 @@ package com.sk89q.worldedit.session; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.transform.Identity; import com.sk89q.worldedit.math.transform.Transform; -import java.io.Closeable; import java.util.Collections; import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Holds the clipboard and the current transform on the clipboard. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java index 91cb29b06..b8b365240 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.session; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.util.MaskTraverser; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.extent.Extent; @@ -36,6 +34,8 @@ import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.transform.Transform; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Builds an operation to paste the contents of a clipboard. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java index c9b81e304..b80a28453 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.session; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; @@ -29,8 +27,6 @@ import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.command.tool.InvalidToolBindException; -import com.sk89q.worldedit.command.tool.NavigationWand; -import com.sk89q.worldedit.command.tool.SelectionWand; import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; @@ -47,7 +43,6 @@ import com.sk89q.worldedit.world.item.ItemTypes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.util.HashMap; @@ -57,6 +52,9 @@ import java.util.Timer; import java.util.TimerTask; import java.util.UUID; import java.util.concurrent.Callable; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Session manager for WorldEdit. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/Request.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/Request.java index 8c8c749c5..916ddb4df 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/Request.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/Request.java @@ -26,8 +26,8 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.world.World; -import javax.annotation.Nullable; import java.util.List; +import javax.annotation.Nullable; /** * Describes the current request using a {@link ThreadLocal}. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java index 3e4df7593..1db0c040f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java @@ -35,8 +35,8 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import javax.annotation.Nullable; import java.util.List; +import javax.annotation.Nullable; public class RequestExtent implements Extent { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java index ac823fc28..90a56e283 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java @@ -27,7 +27,6 @@ import java.util.HashMap; import java.util.List; import java.util.Optional; import java.util.OptionalInt; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Enums.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Enums.java index 7e9160eb0..9f397c127 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Enums.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Enums.java @@ -19,10 +19,10 @@ package com.sk89q.worldedit.util; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Helper methods for enums. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java index ff3924558..6248569dc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java @@ -25,7 +25,6 @@ import java.io.File; import java.util.Arrays; import java.util.HashSet; import java.util.Set; - import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/GuavaUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/GuavaUtil.java index 861858aed..1e6fddbfa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/GuavaUtil.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/GuavaUtil.java @@ -19,10 +19,10 @@ package com.sk89q.worldedit.util; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + public final class GuavaUtil { private GuavaUtil() {} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java index e2b3235f6..4e80fab19 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.util; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import java.util.Objects; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents a block located at some position. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java index 8088f8cfd..a81be436c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.util; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3Impl; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents a location in a world with has a direction. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index 393133b5d..ff4593cda 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -26,8 +26,6 @@ import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.util.report.Unreported; import com.sk89q.worldedit.world.registry.LegacyMapper; -import com.sk89q.worldedit.world.snapshot.SnapshotRepository; -import com.sk89q.worldedit.world.snapshot.experimental.fs.FileSystemSnapshotDatabase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,10 +36,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.UncheckedIOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Arrays; import java.util.HashSet; import java.util.Properties; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java index 6aeab5aed..a0e081e54 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java @@ -26,7 +26,6 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; -import com.sk89q.worldedit.world.World; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java index a98307acb..65ecc3af2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java @@ -35,7 +35,6 @@ import java.util.Locale; import java.util.Map; import java.util.Random; import java.util.Set; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/WeightedChoice.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/WeightedChoice.java index e384ecf73..dcc0b3a27 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/WeightedChoice.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/WeightedChoice.java @@ -19,11 +19,11 @@ package com.sk89q.worldedit.util; -import static com.google.common.base.Preconditions.checkNotNull; - import java.util.Optional; import java.util.function.Function; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Returns the best choice given a weighting function and a target weight. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index 2fd4aefea..f20dac6de 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.session.SessionManager; import com.sk89q.worldedit.util.report.Unreported; -import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import org.slf4j.Logger; import java.io.IOException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/Int2BaseBlockMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/Int2BaseBlockMap.java index 906f64c86..2969c57c3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/Int2BaseBlockMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/Int2BaseBlockMap.java @@ -33,9 +33,9 @@ import it.unimi.dsi.fastutil.objects.AbstractObjectSet; import it.unimi.dsi.fastutil.objects.ObjectIterator; import it.unimi.dsi.fastutil.objects.ObjectSet; -import javax.annotation.Nonnull; import java.util.NoSuchElementException; import java.util.function.BiFunction; +import javax.annotation.Nonnull; /** * Int-to-BaseBlock map, but with optimizations for common cases. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java index 55c7f1a21..314dd3781 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java @@ -26,9 +26,9 @@ import com.sk89q.worldedit.util.LocatedBlock; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; -import javax.annotation.Nullable; import java.util.Collection; import java.util.Iterator; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java index 03c001138..e744b76cc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java @@ -35,8 +35,10 @@ class AnnotatedSubscriberFinder implements SubscriberFindingStrategy { /** * {@inheritDoc} * + *

* This implementation finds all methods marked with a {@link Subscribe} * annotation. + *

*/ @Override public Multimap, EventHandler> findAllSubscribers(Object listener) { @@ -51,9 +53,10 @@ class AnnotatedSubscriberFinder implements SubscriberFindingStrategy { Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 1) { throw new IllegalArgumentException( - "Method " + method + " has @Subscribe annotation, but requires " + - parameterTypes.length + " arguments. Event handler methods " + - "must require a single argument."); + "Method " + method + " has @Subscribe annotation, but requires " + + parameterTypes.length + " arguments. Event handler methods " + + "must require a single argument." + ); } Class eventType = parameterTypes[0]; EventHandler handler = new MethodEventHandler(annotation.priority(), listener, method); @@ -66,4 +69,4 @@ class AnnotatedSubscriberFinder implements SubscriberFindingStrategy { return methodsInListener; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java index aaafb4dc8..6488af945 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java @@ -19,10 +19,10 @@ package com.sk89q.worldedit.util.eventbus; -import static com.google.common.base.Preconditions.checkNotNull; - import java.lang.reflect.InvocationTargetException; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Event handler object for {@link EventBus} that is able to dispatch * an event. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/MethodEventHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/MethodEventHandler.java index 1d825927e..a0575e83f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/MethodEventHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/MethodEventHandler.java @@ -19,10 +19,10 @@ package com.sk89q.worldedit.util.eventbus; -import static com.google.common.base.Preconditions.checkNotNull; - import java.lang.reflect.Method; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Invokes a {@link Method} to dispatch an event. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java index 88b3222ee..ad87ae363 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.util.eventbus; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - import java.lang.annotation.Retention; import java.lang.annotation.Target; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + /** * Used to mark methods as event handlers. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java index 3698ca881..334f7c2d4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java @@ -19,73 +19,28 @@ package com.sk89q.worldedit.util.formatting; -import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.util.formatting.text.Component; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; -import org.enginehub.piston.config.Config; import org.enginehub.piston.config.ConfigHolder; +import org.enginehub.piston.config.ConfigRenderer; import org.enginehub.piston.config.TextConfig; import org.enginehub.piston.util.TextHelper; -import java.lang.reflect.Method; -import java.util.List; import java.util.Locale; public class WorldEditText { + private static final ConfigRenderer RENDERER = ConfigRenderer.getInstance(); public static final ConfigHolder CONFIG_HOLDER = ConfigHolder.create(); - private static final Method METHOD_APPLY; static { CONFIG_HOLDER.getConfig(TextConfig.commandPrefix()).setValue("/"); - try { - METHOD_APPLY = Config.class.getDeclaredMethod("apply", List.class); - METHOD_APPLY.setAccessible(true); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } } public static Component format(Component component, Locale locale) { - return CONFIG_HOLDER.replace(WorldEdit.getInstance().getTranslationManager().convertText(recursiveReplace(component), locale)); - } - - private static Component recursiveReplace(Component input) { - if (input instanceof TranslatableComponent) { - TranslatableComponent tc = (TranslatableComponent)input; - List args = tc.args(); - if (args != (args = replaceChildren(args))) { - input = tc = tc.args(args); - } - if (CONFIG_HOLDER.getConfigs().containsKey(tc.key())) { - Config config = CONFIG_HOLDER.getConfigs().get(tc.key()); - try { - return (Component) METHOD_APPLY.invoke(config, replaceChildren(tc.args())); - } catch (Throwable e) { - e.printStackTrace(); - } - } - } - List original = input.children(); - List replacement = replaceChildren(original); - return original == replacement ? input : input.children(replacement); - } - - private static List replaceChildren(List input) { - if (input.isEmpty()) { - return input; - } - ImmutableList.Builder copy = ImmutableList.builder(); - boolean modified = false; - for (Component component : input) { - Component replacement = recursiveReplace(component); - if (replacement != component) { - modified = true; - } - copy.add(replacement); - } - return modified ? copy.build() : input; + return WorldEdit.getInstance().getTranslationManager().convertText( + RENDERER.render(component, CONFIG_HOLDER), + locale + ); } public static String reduceToText(Component component, Locale locale) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java index ed5ab2db2..f8014b64d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java @@ -29,8 +29,8 @@ import org.enginehub.piston.CommandParameters; import org.enginehub.piston.config.ColorConfig; import org.enginehub.piston.util.HelpGenerator; -import javax.annotation.Nullable; import java.util.List; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/MessageBox.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/MessageBox.java index 223d92f16..3dcfa6610 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/MessageBox.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/MessageBox.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.util.formatting.component; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.base.Strings; import com.google.common.collect.Sets; import com.sk89q.worldedit.util.formatting.text.Component; @@ -28,6 +26,8 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextDecoration; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Makes for a box with a border above and below. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/PaginationBox.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/PaginationBox.java index 8c444b16f..ef3932930 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/PaginationBox.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/PaginationBox.java @@ -19,23 +19,19 @@ package com.sk89q.worldedit.util.formatting.component; -import com.boydti.fawe.object.collection.AdaptedSetCollection; import com.google.common.base.Function; import com.google.common.collect.Collections2; -import com.google.common.collect.Lists; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; -import javax.annotation.Nullable; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashSet; import java.util.List; import java.util.function.Supplier; +import javax.annotation.Nullable; public abstract class PaginationBox extends MessageBox { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java index 12f7492ec..d12c4c9d1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java @@ -19,15 +19,14 @@ package com.sk89q.worldedit.util.function; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.base.Function; import java.util.Locale; import java.util.regex.Pattern; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Provides a Levenshtein distance between a given string and each string * that this function is applied to. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/logging/DynamicStreamHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/logging/DynamicStreamHandler.java index 0c9e89c8c..c6a17b4d2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/logging/DynamicStreamHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/logging/DynamicStreamHandler.java @@ -26,7 +26,6 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.SimpleFormatter; import java.util.logging.StreamHandler; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java index 09f05ef4e..8c28774a9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java @@ -19,9 +19,8 @@ package com.sk89q.worldedit.util.paste; -import com.sk89q.worldedit.command.util.AsyncCommandBuilder; - import com.boydti.fawe.util.IncendoPaster; +import com.sk89q.worldedit.command.util.AsyncCommandBuilder; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/DataReport.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/DataReport.java index 93dc8a90c..b77068768 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/DataReport.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/DataReport.java @@ -22,7 +22,11 @@ package com.sk89q.worldedit.util.report; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/SystemInfoReport.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/SystemInfoReport.java index 91f14c2fd..2426e3669 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/SystemInfoReport.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/SystemInfoReport.java @@ -19,7 +19,13 @@ package com.sk89q.worldedit.util.report; -import java.lang.management.*; +import java.lang.management.ClassLoadingMXBean; +import java.lang.management.GarbageCollectorMXBean; +import java.lang.management.ManagementFactory; +import java.lang.management.OperatingSystemMXBean; +import java.lang.management.RuntimeMXBean; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/AbstractTask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/AbstractTask.java index e81e2bf22..2a86dc020 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/AbstractTask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/AbstractTask.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.util.task; import com.google.common.util.concurrent.AbstractFuture; -import javax.annotation.Nullable; import java.util.Date; import java.util.UUID; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java index 61f5d75a9..671988887 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java @@ -22,11 +22,11 @@ package com.sk89q.worldedit.util.task; import com.google.common.util.concurrent.ListenableFuture; import com.sk89q.worldedit.util.task.progress.Progress; -import javax.annotation.Nullable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/Task.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/Task.java index 169cf1718..f390a6b75 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/Task.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/Task.java @@ -22,9 +22,9 @@ package com.sk89q.worldedit.util.task; import com.google.common.util.concurrent.ListenableFuture; import com.sk89q.worldedit.util.task.progress.ProgressObservable; -import javax.annotation.Nullable; import java.util.Date; import java.util.UUID; +import javax.annotation.Nullable; /** * A task is a job that can be scheduled, run, or cancelled. Tasks can report diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/time/FileNameDateTimeParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/time/FileNameDateTimeParser.java index a12ee7d1c..5456187d4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/time/FileNameDateTimeParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/time/FileNameDateTimeParser.java @@ -20,17 +20,15 @@ package com.sk89q.worldedit.util.time; import com.google.common.collect.Streams; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.util.io.file.MorePaths; -import javax.annotation.Nullable; import java.nio.file.Path; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import javax.annotation.Nullable; /** * Parses date-times by looking at the file name. File names without a time diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/time/SnapshotDateTimeParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/time/SnapshotDateTimeParser.java index 85780c110..effb6ec41 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/time/SnapshotDateTimeParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/time/SnapshotDateTimeParser.java @@ -19,9 +19,9 @@ package com.sk89q.worldedit.util.time; -import javax.annotation.Nullable; import java.nio.file.Path; import java.time.ZonedDateTime; +import javax.annotation.Nullable; /** * Instances of this interface try to determine an {@link ZonedDateTime} from a given diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java index 34e7179b0..074908c15 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java @@ -20,12 +20,10 @@ package com.sk89q.worldedit.world; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.function.mask.BlockMaskBuilder; -import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.math.BlockVector2; @@ -34,14 +32,14 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.SideEffectSet; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.weather.WeatherType; +import com.sk89q.worldedit.world.weather.WeatherTypes; import java.nio.file.Path; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.weather.WeatherTypes; -import javax.annotation.Nullable; import java.util.PriorityQueue; +import javax.annotation.Nullable; /** * An abstract implementation of {@link World}. @@ -106,7 +104,9 @@ public abstract class AbstractWorld implements World { taskId = server.schedule(0, 1, () -> { int max = Math.max(1, Math.min(30, effectQueue.size() / 3)); for (int i = 0; i < max; ++i) { - if (effectQueue.isEmpty()) return; + if (effectQueue.isEmpty()) { + return; + } effectQueue.poll().play(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index f3d6dd18a..dc6bd0aac 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -20,10 +20,10 @@ package com.sk89q.worldedit.world; import com.boydti.fawe.beta.IChunkGet; -import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.beta.implementation.blocks.NullChunkGet; -import com.sk89q.jnbt.CompoundTag; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.google.common.collect.ImmutableSet; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; @@ -48,10 +48,10 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherTypes; -import javax.annotation.Nullable; import java.util.Collections; import java.util.List; import java.util.Set; +import javax.annotation.Nullable; /** * A null implementation of {@link World} that drops all changes and diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java index 8a2a42c46..d3dc6a699 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java @@ -39,9 +39,10 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherTypes; -import javax.annotation.Nullable; + import java.nio.file.Path; import java.util.function.Supplier; +import javax.annotation.Nullable; /** * An abstract implementation of {@link World}. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java index 9388dcace..107096e85 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java @@ -19,9 +19,9 @@ package com.sk89q.worldedit.world; +import com.boydti.fawe.beta.IChunkCache; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.implementation.packet.ChunkPacket; -import com.boydti.fawe.beta.IChunkCache; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; @@ -48,7 +48,6 @@ import com.sk89q.worldedit.world.weather.WeatherType; import java.nio.file.Path; import java.util.Locale; import java.util.Set; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeName.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeName.java index 9dadc4ff3..1c7d0c588 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeName.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeName.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.world.biome; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.base.Function; import com.sk89q.worldedit.world.registry.BiomeRegistry; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Returns the name of a biome using a given {@code BiomeRegistry}. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java index b75e597f5..45fa19c4f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java @@ -19,8 +19,8 @@ package com.sk89q.worldedit.world.biome; -import javax.annotation.Nullable; import java.util.Collection; +import javax.annotation.Nullable; /** * Stores a list of common Biome String IDs. @@ -31,10 +31,12 @@ public final class BiomeTypes { @Nullable public static final BiomeType BADLANDS_PLATEAU = get("minecraft:badlands_plateau"); @Nullable public static final BiomeType BAMBOO_JUNGLE = get("minecraft:bamboo_jungle"); @Nullable public static final BiomeType BAMBOO_JUNGLE_HILLS = get("minecraft:bamboo_jungle_hills"); + @Nullable public static final BiomeType BASALT_DELTAS = get("minecraft:basalt_deltas"); @Nullable public static final BiomeType BEACH = get("minecraft:beach"); @Nullable public static final BiomeType BIRCH_FOREST = get("minecraft:birch_forest"); @Nullable public static final BiomeType BIRCH_FOREST_HILLS = get("minecraft:birch_forest_hills"); @Nullable public static final BiomeType COLD_OCEAN = get("minecraft:cold_ocean"); + @Nullable public static final BiomeType CRIMSON_FOREST = get("minecraft:crimson_forest"); @Nullable public static final BiomeType DARK_FOREST = get("minecraft:dark_forest"); @Nullable public static final BiomeType DARK_FOREST_HILLS = get("minecraft:dark_forest_hills"); @Nullable public static final BiomeType DEEP_COLD_OCEAN = get("minecraft:deep_cold_ocean"); @@ -72,7 +74,8 @@ public final class BiomeTypes { @Nullable public static final BiomeType MOUNTAINS = get("minecraft:mountains"); @Nullable public static final BiomeType MUSHROOM_FIELD_SHORE = get("minecraft:mushroom_field_shore"); @Nullable public static final BiomeType MUSHROOM_FIELDS = get("minecraft:mushroom_fields"); - @Nullable public static final BiomeType NETHER = get("minecraft:nether"); + @Nullable @Deprecated public static final BiomeType NETHER = get("minecraft:nether"); + @Nullable public static final BiomeType NETHER_WASTES = get("minecraft:nether_wastes"); @Nullable public static final BiomeType OCEAN = get("minecraft:ocean"); @Nullable public static final BiomeType PLAINS = get("minecraft:plains"); @Nullable public static final BiomeType RIVER = get("minecraft:river"); @@ -87,6 +90,7 @@ public final class BiomeTypes { @Nullable public static final BiomeType SNOWY_TAIGA_HILLS = get("minecraft:snowy_taiga_hills"); @Nullable public static final BiomeType SNOWY_TAIGA_MOUNTAINS = get("minecraft:snowy_taiga_mountains"); @Nullable public static final BiomeType SNOWY_TUNDRA = get("minecraft:snowy_tundra"); + @Nullable public static final BiomeType SOUL_SAND_VALLEY = get("minecraft:soul_sand_valley"); @Nullable public static final BiomeType STONE_SHORE = get("minecraft:stone_shore"); @Nullable public static final BiomeType SUNFLOWER_PLAINS = get("minecraft:sunflower_plains"); @Nullable public static final BiomeType SWAMP = get("minecraft:swamp"); @@ -99,6 +103,7 @@ public final class BiomeTypes { @Nullable public static final BiomeType THE_END = get("minecraft:the_end"); @Nullable public static final BiomeType THE_VOID = get("minecraft:the_void"); @Nullable public static final BiomeType WARM_OCEAN = get("minecraft:warm_ocean"); + @Nullable public static final BiomeType WARPED_FOREST = get("minecraft:warped_forest"); @Nullable public static final BiomeType WOODED_BADLANDS_PLATEAU = get("minecraft:wooded_badlands_plateau"); @Nullable public static final BiomeType WOODED_HILLS = get("minecraft:wooded_hills"); @Nullable public static final BiomeType WOODED_MOUNTAINS = get("minecraft:wooded_mountains"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/Biomes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/Biomes.java index d3f6b2812..3802fc730 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/Biomes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/Biomes.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.world.biome; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.base.Functions; import com.sk89q.worldedit.util.WeightedChoice; import com.sk89q.worldedit.util.WeightedChoice.Choice; @@ -30,9 +28,10 @@ import com.sk89q.worldedit.world.registry.BiomeRegistry; import java.util.Collection; import java.util.Optional; import java.util.function.Function; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Utility methods related to biomes. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java index 114355e43..f5b7d342c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.world.block; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; @@ -33,11 +31,13 @@ import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.LegacyMapper; + import java.util.Map; import java.util.Objects; - import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents a "snapshot" of a block with NBT Data. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java index 9b7a20b98..687cf20a7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java @@ -81,6 +81,7 @@ public final class BlockCategories { public static final BlockCategory WOODEN_STAIRS = get("minecraft:wooden_stairs"); public static final BlockCategory WOODEN_TRAPDOORS = get("minecraft:wooden_trapdoors"); public static final BlockCategory WOOL = get("minecraft:wool"); + public static final BlockCategory FIRE = get("minecraft:fire"); private BlockCategories() { } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index 8d3bcb3d2..13b1392a2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -42,10 +42,12 @@ import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.world.registry.BlockMaterial; -import javax.annotation.Nullable; -import java.util.*; +import java.util.Collections; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.annotation.Nullable; /** * An immutable class that represents the state a block can be in. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java index 983e52571..91a263005 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java @@ -23,17 +23,16 @@ import com.boydti.fawe.beta.ITileInput; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.blocks.TileEntityBlock; import com.sk89q.worldedit.extent.OutputExtent; - import com.sk89q.worldedit.function.pattern.Pattern; -import java.util.Locale; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.world.registry.BlockMaterial; -import javax.annotation.Nullable; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; +import javax.annotation.Nullable; public interface BlockStateHolder> extends TileEntityBlock, Pattern { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java index f7db97fd8..583b7cd93 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java @@ -38,14 +38,14 @@ import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.LegacyMapper; -import java.util.function.Function; -import javax.annotation.Nullable; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkArgument; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeSwitch.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeSwitch.java index 333ba0554..13a75ddb8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeSwitch.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeSwitch.java @@ -1,8 +1,6 @@ package com.sk89q.worldedit.world.block; -import java.util.function.Consumer; import java.util.function.Function; -import java.util.function.Supplier; public class BlockTypeSwitch implements Function { private final T[] tasks; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeUtil.java index 3c85aae3f..244c642a3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeUtil.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeUtil.java @@ -21,8 +21,6 @@ package com.sk89q.worldedit.world.block; import com.sk89q.worldedit.registry.state.PropertyGroup; import com.sk89q.worldedit.registry.state.PropertyKey; -import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockTypes; import static com.google.common.base.Preconditions.checkNotNull; @@ -211,4 +209,4 @@ public class BlockTypeUtil { } } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index e38247c68..8ce3f19ba 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -25,12 +25,12 @@ import com.boydti.fawe.util.StringMan; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.world.registry.LegacyMapper; -import javax.annotation.Nullable; import java.lang.reflect.Field; import java.util.Locale; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.annotation.Nullable; /** * Stores a list of common Block String IDs. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/ImmutableBaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/ImmutableBaseBlock.java index fcc6c1945..08469e2c6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/ImmutableBaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/ImmutableBaseBlock.java @@ -1,6 +1,5 @@ package com.sk89q.worldedit.world.block; -import com.boydti.fawe.beta.ITileInput; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java index 76afa606b..3e7f5b128 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java @@ -35,21 +35,21 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.storage.InvalidFormatException; -import javax.annotation.Nullable; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; public class AnvilChunk implements Chunk { - private CompoundTag rootTag; - private byte[][] blocks; - private byte[][] blocksAdd; - private byte[][] data; - private int rootX; - private int rootZ; + private final CompoundTag rootTag; + private final byte[][] blocks; + private final byte[][] blocksAdd; + private final byte[][] data; + private final int rootX; + private final int rootZ; - private Map> tileEntities; + private Map> tileEntities; /** * Construct the chunk with a compound tag. @@ -85,14 +85,14 @@ public class AnvilChunk implements Chunk { } blocks[y] = NBTUtils.getChildTag(sectionTag.getValue(), - "Blocks", ByteArrayTag.class).getValue(); + "Blocks", ByteArrayTag.class).getValue(); data[y] = NBTUtils.getChildTag(sectionTag.getValue(), "Data", - ByteArrayTag.class).getValue(); + ByteArrayTag.class).getValue(); // 4096 ID block support if (sectionTag.getValue().containsKey("Add")) { blocksAdd[y] = NBTUtils.getChildTag(sectionTag.getValue(), - "Add", ByteArrayTag.class).getValue(); + "Add", ByteArrayTag.class).getValue(); } } @@ -100,17 +100,16 @@ public class AnvilChunk implements Chunk { for (byte[] block : blocks) { if (block.length != sectionsize) { throw new InvalidFormatException( - "Chunk blocks byte array expected " + "to be " - + sectionsize + " bytes; found " - + block.length); + "Chunk blocks byte array expected " + "to be " + sectionsize + " bytes; found " + + block.length); } } for (byte[] aData : data) { if (aData.length != (sectionsize / 2)) { - throw new InvalidFormatException("Chunk block data byte array " - + "expected to be " + sectionsize + " bytes; found " - + aData.length); + throw new InvalidFormatException( + "Chunk block data byte array " + "expected to be " + sectionsize + + " bytes; found " + aData.length); } } } @@ -177,12 +176,9 @@ public class AnvilChunk implements Chunk { /** * Used to load the tile entities. - * - * @throws DataException */ private void populateTileEntities() throws DataException { - List tags = NBTUtils.getChildTag(rootTag.getValue(), - "TileEntities", ListTag.class).getValue(); + List tags = NBTUtils.getChildTag(rootTag.getValue(), "TileEntities", ListTag.class).getValue(); tileEntities = new HashMap<>(); @@ -216,6 +212,8 @@ public class AnvilChunk implements Chunk { z = ((IntTag) entry.getValue()).getValue(); } break; + default: + break; } values.put(entry.getKey(), entry.getValue()); @@ -256,7 +254,8 @@ public class AnvilChunk implements Chunk { BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, data); if (state == null) { - WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk."); + WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data + + " found when loading legacy anvil chunk."); return BlockTypes.AIR.getDefaultState().toBaseBlock(); } CompoundTag tileEntity = getBlockTileEntity(position); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java index 5cf07bd91..dd568483f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java @@ -35,10 +35,10 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.storage.InvalidFormatException; -import javax.annotation.Nullable; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; /** * The chunk format for Minecraft 1.13 and newer diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityType.java index 966cbaa77..cb9238003 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityType.java @@ -20,8 +20,8 @@ package com.sk89q.worldedit.world.entity; import com.sk89q.worldedit.registry.Keyed; -import com.sk89q.worldedit.registry.RegistryItem; import com.sk89q.worldedit.registry.NamespacedRegistry; +import com.sk89q.worldedit.registry.RegistryItem; public class EntityType implements RegistryItem, Keyed { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java index e174bff09..97dfc868a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java @@ -19,8 +19,8 @@ package com.sk89q.worldedit.world.entity; -import javax.annotation.Nullable; import java.util.Locale; +import javax.annotation.Nullable; public class EntityTypes { @@ -64,6 +64,7 @@ public class EntityTypes { @Nullable public static final EntityType GHAST = get("minecraft:ghast"); @Nullable public static final EntityType GIANT = get("minecraft:giant"); @Nullable public static final EntityType GUARDIAN = get("minecraft:guardian"); + @Nullable public static final EntityType HOGLIN = get("minecraft:hoglin"); @Nullable public static final EntityType HOPPER_MINECART = get("minecraft:hopper_minecart"); @Nullable public static final EntityType HORSE = get("minecraft:horse"); @Nullable public static final EntityType HUSK = get("minecraft:husk"); @@ -85,6 +86,7 @@ public class EntityTypes { @Nullable public static final EntityType PARROT = get("minecraft:parrot"); @Nullable public static final EntityType PHANTOM = get("minecraft:phantom"); @Nullable public static final EntityType PIG = get("minecraft:pig"); + @Nullable public static final EntityType PIGLIN = get("minecraft:piglin"); @Nullable public static final EntityType PILLAGER = get("minecraft:pillager"); @Nullable public static final EntityType PLAYER = get("minecraft:player"); @Nullable public static final EntityType POLAR_BEAR = get("minecraft:polar_bear"); @@ -108,6 +110,7 @@ public class EntityTypes { @Nullable public static final EntityType SPIDER = get("minecraft:spider"); @Nullable public static final EntityType SQUID = get("minecraft:squid"); @Nullable public static final EntityType STRAY = get("minecraft:stray"); + @Nullable public static final EntityType STRIDER = get("minecraft:strider"); @Nullable public static final EntityType TNT = get("minecraft:tnt"); @Nullable public static final EntityType TNT_MINECART = get("minecraft:tnt_minecart"); @Nullable public static final EntityType TRADER_LLAMA = get("minecraft:trader_llama"); @@ -123,10 +126,12 @@ public class EntityTypes { @Nullable public static final EntityType WITHER_SKELETON = get("minecraft:wither_skeleton"); @Nullable public static final EntityType WITHER_SKULL = get("minecraft:wither_skull"); @Nullable public static final EntityType WOLF = get("minecraft:wolf"); + @Nullable public static final EntityType ZOGLIN = get("minecraft:zoglin"); @Nullable public static final EntityType ZOMBIE = get("minecraft:zombie"); @Nullable public static final EntityType ZOMBIE_HORSE = get("minecraft:zombie_horse"); - @Nullable public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman"); + @Nullable @Deprecated public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman"); @Nullable public static final EntityType ZOMBIE_VILLAGER = get("minecraft:zombie_villager"); + @Nullable public static final EntityType ZOMBIFIED_PIGLIN = get("minecraft:zombified_piglin"); private EntityTypes() { } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java index b27813fd9..b1345af74 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java @@ -28,23 +28,32 @@ public final class ItemCategories { public static final ItemCategory ANVIL = get("minecraft:anvil"); public static final ItemCategory ARROWS = get("minecraft:arrows"); public static final ItemCategory BANNERS = get("minecraft:banners"); + public static final ItemCategory BEACON_PAYMENT_ITEMS = get("minecraft:beacon_payment_items"); public static final ItemCategory BEDS = get("minecraft:beds"); public static final ItemCategory BIRCH_LOGS = get("minecraft:birch_logs"); public static final ItemCategory BOATS = get("minecraft:boats"); public static final ItemCategory BUTTONS = get("minecraft:buttons"); public static final ItemCategory CARPETS = get("minecraft:carpets"); public static final ItemCategory COALS = get("minecraft:coals"); + public static final ItemCategory CREEPER_DROP_MUSIC_DISCS = get("minecraft:creeper_drop_music_discs"); + public static final ItemCategory CRIMSON_STEMS = get("minecraft:crimson_stems"); public static final ItemCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs"); public static final ItemCategory DOORS = get("minecraft:doors"); public static final ItemCategory FENCES = get("minecraft:fences"); public static final ItemCategory FISHES = get("minecraft:fishes"); public static final ItemCategory FLOWERS = get("minecraft:flowers"); + public static final ItemCategory FURNACE_MATERIALS = get("minecraft:furnace_materials"); + public static final ItemCategory GOLD_ORES = get("minecraft:gold_ores"); public static final ItemCategory JUNGLE_LOGS = get("minecraft:jungle_logs"); public static final ItemCategory LEAVES = get("minecraft:leaves"); public static final ItemCategory LECTERN_BOOKS = get("minecraft:lectern_books"); public static final ItemCategory LOGS = get("minecraft:logs"); + public static final ItemCategory LOGS_THAT_BURN = get("minecraft:logs_that_burn"); public static final ItemCategory MUSIC_DISCS = get("minecraft:music_discs"); + public static final ItemCategory NON_FLAMMABLE_WOOD = get("minecraft:non_flammable_wood"); public static final ItemCategory OAK_LOGS = get("minecraft:oak_logs"); + public static final ItemCategory PIGLIN_LOVED = get("minecraft:piglin_loved"); + public static final ItemCategory PIGLIN_REPELLENTS = get("minecraft:piglin_repellents"); public static final ItemCategory PLANKS = get("minecraft:planks"); public static final ItemCategory RAILS = get("minecraft:rails"); public static final ItemCategory SAND = get("minecraft:sand"); @@ -52,12 +61,15 @@ public final class ItemCategories { public static final ItemCategory SIGNS = get("minecraft:signs"); public static final ItemCategory SLABS = get("minecraft:slabs"); public static final ItemCategory SMALL_FLOWERS = get("minecraft:small_flowers"); + public static final ItemCategory SOUL_FIRE_BASE_BLOCKS = get("minecraft:soul_fire_base_blocks"); public static final ItemCategory SPRUCE_LOGS = get("minecraft:spruce_logs"); public static final ItemCategory STAIRS = get("minecraft:stairs"); public static final ItemCategory STONE_BRICKS = get("minecraft:stone_bricks"); + public static final ItemCategory STONE_TOOL_MATERIALS = get("minecraft:stone_tool_materials"); public static final ItemCategory TALL_FLOWERS = get("minecraft:tall_flowers"); public static final ItemCategory TRAPDOORS = get("minecraft:trapdoors"); public static final ItemCategory WALLS = get("minecraft:walls"); + public static final ItemCategory WARPED_STEMS = get("minecraft:warped_stems"); public static final ItemCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons"); public static final ItemCategory WOODEN_DOORS = get("minecraft:wooden_doors"); public static final ItemCategory WOODEN_FENCES = get("minecraft:wooden_fences"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java index 167572da6..b96d7bb96 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java @@ -29,7 +29,6 @@ import com.sk89q.worldedit.registry.RegistryItem; import com.sk89q.worldedit.util.concurrency.LazyReference; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.ItemMaterial; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java index 32babbc03..34a6679a1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java @@ -20,17 +20,13 @@ package com.sk89q.worldedit.world.item; import com.boydti.fawe.object.string.JoinedCharSequence; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.ItemTypesCache; import com.sk89q.worldedit.world.registry.LegacyMapper; -import javax.annotation.Nullable; import java.lang.reflect.Field; import java.util.Collection; -import java.util.Optional; import java.util.Locale; +import javax.annotation.Nullable; public final class ItemTypes { @@ -588,6 +584,7 @@ public final class ItemTypes { @Nullable public static final ItemType NETHER_STAR = init(); @Nullable public static final ItemType NETHER_WART = init(); @Nullable public static final ItemType NETHER_WART_BLOCK = init(); + @Nullable public static final ItemType NETHERITE_PICKAXE = init(); @Nullable public static final ItemType NETHERRACK = init(); @Nullable public static final ItemType NOTE_BLOCK = init(); @Nullable public static final ItemType OAK_BOAT = init(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java index dc4743018..9d43f9e08 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java @@ -23,11 +23,11 @@ import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; -import javax.annotation.Nullable; -import java.util.OptionalInt; import java.util.Collection; import java.util.Collections; import java.util.Map; +import java.util.OptionalInt; +import javax.annotation.Nullable; /** * Provides information on blocks and provides methods to create them. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java index 81a310314..28197f6bc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java @@ -33,13 +33,13 @@ import com.sk89q.worldedit.util.io.ResourceLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; /** * Provides block data based on the built-in block database that is bundled diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java index 0e5615475..19c38af83 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java @@ -26,7 +26,6 @@ import com.sk89q.worldedit.world.block.BlockType; import java.util.Collections; import java.util.Map; import java.util.OptionalInt; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java index 40ff378be..ace1a5787 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java @@ -31,13 +31,13 @@ import com.sk89q.worldedit.util.io.ResourceLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; /** * Provides item data based on the built-in item database that is bundled diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java index c522451ac..16d08973d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java @@ -23,9 +23,9 @@ import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; -import javax.annotation.Nullable; import java.util.Collection; import java.util.Collections; +import javax.annotation.Nullable; /** * Provides information on entities. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java index 20c0683b1..205370273 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.world.registry; import com.sk89q.worldedit.world.item.ItemType; -import javax.annotation.Nullable; import java.util.Collection; import java.util.Collections; +import javax.annotation.Nullable; public interface ItemRegistry { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java index d4c457aea..3dbc02c4c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java @@ -46,12 +46,12 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; +import javax.annotation.Nullable; public final class LegacyMapper { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughItemMaterial.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughItemMaterial.java index 5e811e018..d9a1bcca6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughItemMaterial.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughItemMaterial.java @@ -19,10 +19,10 @@ package com.sk89q.worldedit.world.registry; -import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; - import javax.annotation.Nullable; +import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; + public class PassthroughItemMaterial implements ItemMaterial { private static final ItemMaterial DEFAULT_MATERIAL = new SimpleItemMaterial(0, 0); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotDateParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotDateParser.java index 323bef842..fdf1f8288 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotDateParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotDateParser.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.world.snapshot; import java.io.File; import java.util.Calendar; - import javax.annotation.Nullable; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java index e6fe6aec7..61465b8fa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java @@ -23,7 +23,6 @@ package com.sk89q.worldedit.world.snapshot; import com.sk89q.worldedit.world.storage.MissingWorldException; -import javax.annotation.Nullable; import java.io.File; import java.io.FilenameFilter; import java.time.ZoneOffset; @@ -33,6 +32,7 @@ import java.util.Calendar; import java.util.Collections; import java.util.List; import java.util.Locale; +import javax.annotation.Nullable; /** * A repository contains zero or more snapshots. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FileSystemSnapshotDatabase.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FileSystemSnapshotDatabase.java index 64febdd66..a3d960ce8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FileSystemSnapshotDatabase.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FileSystemSnapshotDatabase.java @@ -35,7 +35,6 @@ import com.sk89q.worldedit.world.snapshot.experimental.Snapshot; import com.sk89q.worldedit.world.snapshot.experimental.SnapshotDatabase; import com.sk89q.worldedit.world.snapshot.experimental.SnapshotInfo; -import javax.annotation.Nullable; import java.io.IOException; import java.net.URI; import java.nio.file.Files; @@ -47,6 +46,7 @@ import java.util.Objects; import java.util.Optional; import java.util.ServiceLoader; import java.util.stream.Stream; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkArgument; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FolderSnapshot.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FolderSnapshot.java index f753d2507..97e9c8eaa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FolderSnapshot.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FolderSnapshot.java @@ -32,7 +32,6 @@ import com.sk89q.worldedit.world.storage.McRegionChunkStore; import com.sk89q.worldedit.world.storage.McRegionReader; import com.sk89q.worldedit.world.storage.MissingChunkException; -import javax.annotation.Nullable; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -41,6 +40,7 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; import java.util.zip.GZIPInputStream; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkState; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/NBTConversions.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/NBTConversions.java index 3da5c0047..d7673ade4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/NBTConversions.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/NBTConversions.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.world.storage; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.jnbt.ListTag; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.util.Location; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Utility methods for working with NBT data used in Minecraft. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedLegacyChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedLegacyChunkStore.java index 19350d831..083df5088 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedLegacyChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedLegacyChunkStore.java @@ -35,7 +35,7 @@ import java.util.zip.ZipFile; */ public class ZippedLegacyChunkStore extends LegacyChunkStore { - private ZipFile zip; + private final ZipFile zip; private String folder; /** @@ -45,8 +45,6 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore { * * @param zipFile the zip file * @param folder the folder - * @throws IOException - * @throws ZipException */ public ZippedLegacyChunkStore(File zipFile, String folder) throws IOException, ZipException { this.folder = folder; @@ -59,8 +57,6 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore { * be detected. * * @param zipFile the zip file - * @throws IOException - * @throws ZipException */ public ZippedLegacyChunkStore(File zipFile) throws IOException, ZipException { zip = new ZipFile(zipFile); @@ -73,8 +69,6 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore { * @param f2 the second part of the path * @param name the name of the file * @return an input stream - * @throws IOException - * @throws DataException */ @Override protected InputStream getInputStream(String f1, String f2, String name) throws IOException, DataException { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java index ca3854bcd..644c63509 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java @@ -48,8 +48,6 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { * * @param zipFile the ZIP file * @param folder the folder - * @throws IOException - * @throws ZipException */ public ZippedMcRegionChunkStore(File zipFile, String folder) throws IOException, ZipException { this.zipFile = zipFile; @@ -63,8 +61,6 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { * be detected. * * @param zipFile the ZIP file - * @throws IOException - * @throws ZipException */ public ZippedMcRegionChunkStore(File zipFile) throws IOException, ZipException { this.zipFile = zipFile; @@ -87,7 +83,9 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { if (testEntry.getName().startsWith(worldName + "/")) { if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/')); - if (folder.endsWith("poi")) continue; + if (folder.endsWith("poi")) { + continue; + } name = folder + "/" + name; break; } diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4BlockInputStream.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4BlockInputStream.java index 0c6f9fc5a..05f84d580 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4BlockInputStream.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4BlockInputStream.java @@ -14,15 +14,20 @@ package net.jpountz.lz4; * limitations under the License. */ +import net.jpountz.util.SafeUtils; + import java.io.EOFException; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.Checksum; -import net.jpountz.util.SafeUtils; - -import static net.jpountz.lz4.LZ4BlockOutputStream.*; +import static net.jpountz.lz4.LZ4BlockOutputStream.COMPRESSION_LEVEL_BASE; +import static net.jpountz.lz4.LZ4BlockOutputStream.COMPRESSION_METHOD_LZ4; +import static net.jpountz.lz4.LZ4BlockOutputStream.COMPRESSION_METHOD_RAW; +import static net.jpountz.lz4.LZ4BlockOutputStream.HEADER_LENGTH; +import static net.jpountz.lz4.LZ4BlockOutputStream.MAGIC; +import static net.jpountz.lz4.LZ4BlockOutputStream.MAGIC_LENGTH; /** * {@link InputStream} implementation to decode data written with @@ -234,4 +239,4 @@ public final class LZ4BlockInputStream extends FilterInputStream { + ", decompressor=" + decompressor + ", checksum=" + checksum + ")"; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4BlockOutputStream.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4BlockOutputStream.java index 149ba3680..3b4443fd8 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4BlockOutputStream.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4BlockOutputStream.java @@ -16,11 +16,12 @@ package net.jpountz.lz4; * This file has been modified for use in the FAWE project. */ +import net.jpountz.util.SafeUtils; + import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.zip.Checksum; -import net.jpountz.util.SafeUtils; /** * Streaming LZ4 (not compatible with the LZ4 Frame format). diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4ByteBufferUtils.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4ByteBufferUtils.java index fa0b5101b..99b2055b5 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4ByteBufferUtils.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4ByteBufferUtils.java @@ -17,9 +17,17 @@ package net.jpountz.lz4; import java.nio.ByteBuffer; import java.nio.ByteOrder; - -import static net.jpountz.lz4.LZ4Constants.*; -import static net.jpountz.util.ByteBufferUtils.*; +import static net.jpountz.lz4.LZ4Constants.COPY_LENGTH; +import static net.jpountz.lz4.LZ4Constants.LAST_LITERALS; +import static net.jpountz.lz4.LZ4Constants.ML_BITS; +import static net.jpountz.lz4.LZ4Constants.ML_MASK; +import static net.jpountz.lz4.LZ4Constants.RUN_MASK; +import static net.jpountz.util.ByteBufferUtils.readByte; +import static net.jpountz.util.ByteBufferUtils.readInt; +import static net.jpountz.util.ByteBufferUtils.readLong; +import static net.jpountz.util.ByteBufferUtils.writeByte; +import static net.jpountz.util.ByteBufferUtils.writeInt; +import static net.jpountz.util.ByteBufferUtils.writeLong; enum LZ4ByteBufferUtils { ; diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4Factory.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4Factory.java index 01637f852..57c6e5845 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4Factory.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4Factory.java @@ -14,13 +14,13 @@ package net.jpountz.lz4; * limitations under the License. */ +import net.jpountz.util.Native; +import net.jpountz.util.Utils; + import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; -import net.jpountz.util.Native; -import net.jpountz.util.Utils; - import static net.jpountz.lz4.LZ4Constants.DEFAULT_COMPRESSION_LEVEL; import static net.jpountz.lz4.LZ4Constants.MAX_COMPRESSION_LEVEL; diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4HCJNICompressor.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4HCJNICompressor.java index 924582b4e..66113e733 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4HCJNICompressor.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4HCJNICompressor.java @@ -14,10 +14,10 @@ package net.jpountz.lz4; * limitations under the License. */ -import java.nio.ByteBuffer; import net.jpountz.util.ByteBufferUtils; import net.jpountz.util.SafeUtils; +import java.nio.ByteBuffer; import static net.jpountz.lz4.LZ4Constants.DEFAULT_COMPRESSION_LEVEL; diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4HCJavaSafeCompressor.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4HCJavaSafeCompressor.java index 70a660712..ccfac974b 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4HCJavaSafeCompressor.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4HCJavaSafeCompressor.java @@ -2,14 +2,21 @@ package net.jpountz.lz4; -import java.nio.ByteBuffer; -import java.util.Arrays; import net.jpountz.lz4.LZ4Utils.Match; import net.jpountz.util.ByteBufferUtils; import net.jpountz.util.SafeUtils; +import java.nio.ByteBuffer; +import java.util.Arrays; -import static net.jpountz.lz4.LZ4Constants.*; +import static net.jpountz.lz4.LZ4Constants.DEFAULT_COMPRESSION_LEVEL; +import static net.jpountz.lz4.LZ4Constants.HASH_TABLE_SIZE_HC; +import static net.jpountz.lz4.LZ4Constants.LAST_LITERALS; +import static net.jpountz.lz4.LZ4Constants.MAX_DISTANCE; +import static net.jpountz.lz4.LZ4Constants.MF_LIMIT; +import static net.jpountz.lz4.LZ4Constants.MIN_MATCH; +import static net.jpountz.lz4.LZ4Constants.ML_MASK; +import static net.jpountz.lz4.LZ4Constants.OPTIMAL_ML; import static net.jpountz.lz4.LZ4Utils.copyTo; import static net.jpountz.lz4.LZ4Utils.hashHC; diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNI.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNI.java index cfc134ec2..6df58ef73 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNI.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNI.java @@ -14,9 +14,10 @@ package net.jpountz.lz4; * limitations under the License. */ -import java.nio.ByteBuffer; import net.jpountz.util.Native; +import java.nio.ByteBuffer; + /** * JNI bindings to the original C implementation of LZ4. diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNICompressor.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNICompressor.java index 83295ec2f..fef6d1af7 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNICompressor.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNICompressor.java @@ -14,12 +14,12 @@ package net.jpountz.lz4; * limitations under the License. */ +import java.nio.ByteBuffer; + import static net.jpountz.util.ByteBufferUtils.checkNotReadOnly; import static net.jpountz.util.ByteBufferUtils.checkRange; import static net.jpountz.util.SafeUtils.checkRange; -import java.nio.ByteBuffer; - /** * Fast {@link LZ4Compressor} implemented with JNI bindings to the original C * implementation of LZ4. diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNIFastDecompressor.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNIFastDecompressor.java index 328fe03a2..e198300ff 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNIFastDecompressor.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNIFastDecompressor.java @@ -15,10 +15,11 @@ package net.jpountz.lz4; */ -import java.nio.ByteBuffer; import net.jpountz.util.ByteBufferUtils; import net.jpountz.util.SafeUtils; +import java.nio.ByteBuffer; + /** * {@link LZ4FastDecompressor} implemented with JNI bindings to the original C diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNISafeDecompressor.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNISafeDecompressor.java index 0777736a5..f0cf7ad94 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNISafeDecompressor.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JNISafeDecompressor.java @@ -15,10 +15,11 @@ package net.jpountz.lz4; */ -import java.nio.ByteBuffer; import net.jpountz.util.ByteBufferUtils; import net.jpountz.util.SafeUtils; +import java.nio.ByteBuffer; + /** * {@link LZ4SafeDecompressor} implemented with JNI bindings to the original C * implementation of LZ4. diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeCompressor.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeCompressor.java index 63f15ab7f..ce591fe99 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeCompressor.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeCompressor.java @@ -2,13 +2,24 @@ package net.jpountz.lz4; -import java.nio.ByteBuffer; -import java.util.Arrays; import net.jpountz.util.ByteBufferUtils; import net.jpountz.util.SafeUtils; +import java.nio.ByteBuffer; +import java.util.Arrays; -import static net.jpountz.lz4.LZ4Constants.*; +import static net.jpountz.lz4.LZ4Constants.HASH_TABLE_SIZE; +import static net.jpountz.lz4.LZ4Constants.HASH_TABLE_SIZE_64K; +import static net.jpountz.lz4.LZ4Constants.LAST_LITERALS; +import static net.jpountz.lz4.LZ4Constants.LZ4_64K_LIMIT; +import static net.jpountz.lz4.LZ4Constants.MAX_DISTANCE; +import static net.jpountz.lz4.LZ4Constants.MF_LIMIT; +import static net.jpountz.lz4.LZ4Constants.MIN_LENGTH; +import static net.jpountz.lz4.LZ4Constants.MIN_MATCH; +import static net.jpountz.lz4.LZ4Constants.ML_BITS; +import static net.jpountz.lz4.LZ4Constants.ML_MASK; +import static net.jpountz.lz4.LZ4Constants.RUN_MASK; +import static net.jpountz.lz4.LZ4Constants.SKIP_STRENGTH; import static net.jpountz.lz4.LZ4Utils.hash; import static net.jpountz.lz4.LZ4Utils.hash64k; diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeFastDecompressor.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeFastDecompressor.java index 365b52489..46f71a20b 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeFastDecompressor.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeFastDecompressor.java @@ -2,12 +2,16 @@ package net.jpountz.lz4; -import java.nio.ByteBuffer; import net.jpountz.util.ByteBufferUtils; import net.jpountz.util.SafeUtils; +import java.nio.ByteBuffer; -import static net.jpountz.lz4.LZ4Constants.*; +import static net.jpountz.lz4.LZ4Constants.COPY_LENGTH; +import static net.jpountz.lz4.LZ4Constants.MIN_MATCH; +import static net.jpountz.lz4.LZ4Constants.ML_BITS; +import static net.jpountz.lz4.LZ4Constants.ML_MASK; +import static net.jpountz.lz4.LZ4Constants.RUN_MASK; /** * Decompressor. diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeSafeDecompressor.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeSafeDecompressor.java index 7d8fc8604..9557bc4cb 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeSafeDecompressor.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4JavaSafeSafeDecompressor.java @@ -2,12 +2,16 @@ package net.jpountz.lz4; -import java.nio.ByteBuffer; import net.jpountz.util.ByteBufferUtils; import net.jpountz.util.SafeUtils; +import java.nio.ByteBuffer; -import static net.jpountz.lz4.LZ4Constants.*; +import static net.jpountz.lz4.LZ4Constants.COPY_LENGTH; +import static net.jpountz.lz4.LZ4Constants.MIN_MATCH; +import static net.jpountz.lz4.LZ4Constants.ML_BITS; +import static net.jpountz.lz4.LZ4Constants.ML_MASK; +import static net.jpountz.lz4.LZ4Constants.RUN_MASK; /** * Decompressor. diff --git a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4SafeUtils.java b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4SafeUtils.java index fc3e0ccc9..6a9cbea04 100644 --- a/worldedit-core/src/main/java/net/jpountz/lz4/LZ4SafeUtils.java +++ b/worldedit-core/src/main/java/net/jpountz/lz4/LZ4SafeUtils.java @@ -16,7 +16,6 @@ package net.jpountz.lz4; import net.jpountz.util.SafeUtils; - import static net.jpountz.lz4.LZ4Constants.LAST_LITERALS; import static net.jpountz.lz4.LZ4Constants.ML_BITS; import static net.jpountz.lz4.LZ4Constants.ML_MASK; diff --git a/worldedit-core/src/main/java/net/jpountz/util/Native.java b/worldedit-core/src/main/java/net/jpountz/util/Native.java index c09baba20..796acd252 100644 --- a/worldedit-core/src/main/java/net/jpountz/util/Native.java +++ b/worldedit-core/src/main/java/net/jpountz/util/Native.java @@ -21,7 +21,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.FilenameFilter; /** FOR INTERNAL USE ONLY */ public enum Native { diff --git a/worldedit-core/src/main/java/net/jpountz/util/UnsafeUtils.java b/worldedit-core/src/main/java/net/jpountz/util/UnsafeUtils.java index b66bfce6b..9f0c6d6e6 100644 --- a/worldedit-core/src/main/java/net/jpountz/util/UnsafeUtils.java +++ b/worldedit-core/src/main/java/net/jpountz/util/UnsafeUtils.java @@ -14,10 +14,10 @@ package net.jpountz.util; * limitations under the License. */ -import java.lang.reflect.Field; -import java.nio.ByteOrder; import sun.misc.Unsafe; +import java.lang.reflect.Field; +import java.nio.ByteOrder; import static net.jpountz.util.Utils.NATIVE_BYTE_ORDER; diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java index c650c3da8..f336166a8 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java @@ -21,17 +21,12 @@ package com.sk89q.worldedit.extent.transform; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import java.util.HashSet; import java.util.Set; -import static org.junit.jupiter.api.Assertions.assertEquals; - @Disabled("A platform is currently required to get properties, preventing this test.") public class BlockTransformExtentTest { diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/RealExpressionTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/RealExpressionTest.java index 625e023a1..402fe90f5 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/RealExpressionTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/RealExpressionTest.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.internal.expression; import com.sk89q.worldedit.math.Vector3; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.function.Consumer; import java.util.stream.Stream; diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/util/collection/BlockMapTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/util/collection/BlockMapTest.java index 6a9fda239..4a1700429 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/util/collection/BlockMapTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/util/collection/BlockMapTest.java @@ -19,52 +19,7 @@ package com.sk89q.worldedit.util.collection; -import com.google.common.collect.ImmutableMap; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extension.platform.Capability; -import com.sk89q.worldedit.extension.platform.Platform; -import com.sk89q.worldedit.extension.platform.PlatformManager; -import com.sk89q.worldedit.extension.platform.Preference; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.registry.Registry; -import com.sk89q.worldedit.util.test.VariedVectorGenerator; -import com.sk89q.worldedit.util.test.VariedVectors; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.registry.BundledRegistries; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIfSystemProperty; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import java.lang.reflect.Field; -import java.util.AbstractMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assumptions.assumeFalse; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; @DisplayName("An ordered block map") class BlockMapTest { diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FSSDContext.java b/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FSSDContext.java index d63ff3936..29cb174e1 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FSSDContext.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FSSDContext.java @@ -24,13 +24,13 @@ import com.sk89q.worldedit.util.io.file.ArchiveDir; import com.sk89q.worldedit.util.io.file.ArchiveNioSupport; import com.sk89q.worldedit.world.snapshot.experimental.Snapshot; -import javax.annotation.Nullable; import java.io.IOException; import java.net.URI; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.stream.Stream; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkArgument; import static java.util.stream.Collectors.toList; diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FSSDTestType.java b/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FSSDTestType.java index 25c5c4317..259f10650 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FSSDTestType.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FSSDTestType.java @@ -38,7 +38,6 @@ import java.util.List; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Stream; - import static com.sk89q.worldedit.world.snapshot.experimental.fs.FileSystemSnapshotDatabaseTest.CHUNK_POS; import static com.sk89q.worldedit.world.snapshot.experimental.fs.FileSystemSnapshotDatabaseTest.CHUNK_TAG; import static com.sk89q.worldedit.world.snapshot.experimental.fs.FileSystemSnapshotDatabaseTest.TIME_ONE; diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java index 1ee00d311..cae7cb1dd 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java @@ -172,8 +172,9 @@ public class FabricPlayer extends AbstractPlayerActor { } @Override - public void setPosition(Vector3 pos, float pitch, float yaw) { + public boolean trySetPosition(Vector3 pos, float pitch, float yaw) { this.player.networkHandler.requestTeleport(pos.getX(), pos.getY(), pos.getZ(), yaw, pitch); + return true; } @Override diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index 289ed5c75..647bee1eb 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -168,8 +168,9 @@ public class ForgePlayer extends AbstractPlayerActor { } @Override - public void setPosition(Vector3 pos, float pitch, float yaw) { + public boolean trySetPosition(Vector3 pos, float pitch, float yaw) { this.player.connection.setPlayerLocation(pos.getX(), pos.getY(), pos.getZ(), yaw, pitch); + return true; } @Override diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java index 6603a5bd4..1681c1df9 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java @@ -165,12 +165,12 @@ public class SpongePlayer extends AbstractPlayerActor { } @Override - public void setPosition(Vector3 pos, float pitch, float yaw) { + public boolean trySetPosition(Vector3 pos, float pitch, float yaw) { org.spongepowered.api.world.Location loc = new org.spongepowered.api.world.Location<>( - this.player.getWorld(), pos.getX(), pos.getY(), pos.getZ() + this.player.getWorld(), pos.getX(), pos.getY(), pos.getZ() ); - this.player.setLocationAndRotation(loc, new Vector3d(pitch, yaw, 0)); + return this.player.setLocationAndRotation(loc, new Vector3d(pitch, yaw, 0)); } @Override