mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Part 1 of upstream merge and format
This commit is contained in:
parent
79771e83e0
commit
3bc692ff11
18
NOTICE.txt
Normal file
18
NOTICE.txt
Normal file
@ -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.
|
||||
|
@ -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>("grgit").head()?.abbreviatedId
|
||||
} catch (e: Exception) {
|
||||
logger.warn("Error getting commit hash", e)
|
||||
|
||||
"no_git_id"
|
||||
"no.git.id"
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -21,7 +21,7 @@ fun Project.applyCommonConfiguration() {
|
||||
}
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
cacheChangingModulesFor(5, "minutes")
|
||||
cacheChangingModulesFor(5, "MINUTES")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<CheckstyleExtension> {
|
||||
// configFile = rootProject.file("config/checkstyle/checkstyle.xml")
|
||||
// toolVersion = "7.6.1"
|
||||
// toolVersion = "8.34"
|
||||
// }
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
|
@ -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"
|
||||
|
@ -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<FaweMaskManager> getMaskManagers() {
|
||||
final Plugin worldguardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
@Override public Collection<FaweMaskManager> getMaskManagers() {
|
||||
final Plugin worldguardPlugin =
|
||||
Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
final ArrayList<FaweMaskManager> 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());
|
||||
|
@ -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<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
||||
private static final Function<BlockPosition, BlockVector3> posNms2We =
|
||||
v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
||||
|
||||
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
private static final Function<TileEntity, CompoundTag> nmsTile2We =
|
||||
tileEntity -> new LazyCompoundTag_1_14(
|
||||
Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
|
||||
@Override
|
||||
public Map<BlockVector3, CompoundTag> 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<Entity>[] slices = getChunk().getEntitySlices();
|
||||
int size = 0;
|
||||
for (List<Entity> 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<CompoundTag> iterator() {
|
||||
Iterable<CompoundTag> 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<CompoundTag> 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;
|
||||
@ -272,15 +292,16 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
entity.valid = false;
|
||||
}
|
||||
|
||||
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 extends Future<T>> 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
|
||||
@ -309,7 +330,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;
|
||||
|
||||
@ -318,13 +341,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;
|
||||
}
|
||||
}
|
||||
@ -349,9 +375,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);
|
||||
@ -399,12 +428,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<UUID> 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<Entity>[] entities = nmsChunk.getEntitySlices();
|
||||
@ -426,7 +457,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
|
||||
Set<CompoundTag> 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) {
|
||||
@ -435,7 +468,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);
|
||||
@ -450,18 +484,23 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
Entity entity = type.a(nmsWorld);
|
||||
if (entity != null) {
|
||||
UUID uuid = entity.getUniqueID();
|
||||
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
|
||||
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
|
||||
entityTagMap.put("UUIDMost",
|
||||
new LongTag(uuid.getMostSignificantBits()));
|
||||
entityTagMap.put("UUIDLeast",
|
||||
new LongTag(uuid.getLeastSignificantBits()));
|
||||
if (nativeTag != 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);
|
||||
for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
||||
tag.remove(name);
|
||||
}
|
||||
entity.f(tag);
|
||||
}
|
||||
entity.setLocation(x, y, z, yaw, pitch);
|
||||
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
nmsWorld
|
||||
.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -472,7 +511,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
// set tiles
|
||||
Map<BlockVector3, CompoundTag> 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<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
||||
@ -490,8 +531,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));
|
||||
@ -514,8 +557,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) {
|
||||
@ -532,7 +578,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);
|
||||
@ -545,7 +593,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();
|
||||
}
|
||||
@ -577,11 +627,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<IBlockData> blocks = section.getBlocks();
|
||||
final DataBits bits = (DataBits) BukkitAdapter_1_14.fieldBits.get(blocks);
|
||||
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_14.fieldPalette.get(blocks);
|
||||
final DataPalette<IBlockData> palette =
|
||||
(DataPalette<IBlockData>) BukkitAdapter_1_14.fieldPalette.get(blocks);
|
||||
|
||||
final int bitsPerEntry = bits.c();
|
||||
final long[] blockStates = bits.a();
|
||||
@ -695,7 +747,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -708,12 +760,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++) {
|
||||
@ -745,7 +799,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
try {
|
||||
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();
|
||||
|
||||
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_14.fieldPalette.get(blocksExisting);
|
||||
final DataPalette<IBlockData> palette =
|
||||
(DataPalette<IBlockData>) BukkitAdapter_1_14.fieldPalette
|
||||
.get(blocksExisting);
|
||||
int paletteSize;
|
||||
|
||||
if (palette instanceof DataPaletteLinear) {
|
||||
|
@ -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) {
|
||||
|
@ -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<ItemStack> getDrops() {
|
||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops());
|
||||
}
|
||||
|
||||
@NotNull @Override
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ItemStack> 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<MetadataValue> 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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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> T whenLoaded(Supplier<T> task) {
|
||||
|
@ -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<br>
|
||||
* - Use world.commit() to execute all the changes<br>
|
||||
* - Any Chunk/Block/BlockState objects returned should also be safe to use from the same async thread<br>
|
||||
* - Only block read,write and biome write are fast, other methods will perform slower async<br>
|
||||
* -
|
||||
* @see #wrap(World)
|
||||
* @see #create(WorldCreator)
|
||||
* - Use world.commit() to execute all the changes<br>
|
||||
* - Any Chunk/Block/BlockState objects returned should also be safe to use from the same async thread<br>
|
||||
* - Only block read,write and biome write are fast, other methods will perform slower async<br>
|
||||
* -
|
||||
*
|
||||
* @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 <T> void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t) {
|
||||
public <T> 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 <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, T t) {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i,
|
||||
T t) {
|
||||
parent.spawnParticle(particle, location, i, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, T data) {
|
||||
public <T> 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 <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, double v, double v1, double v2, T t) {
|
||||
public <T> 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 <T> void spawnParticle(@NotNull Particle particle, double v, double v1, double v2, int i, double v3, double v4, double v5, T t) {
|
||||
public <T> 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 <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int i, double v, double v1, double v2, double v3, T t) {
|
||||
public <T> 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 <T extends AbstractArrow> @NotNull T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class<T> clazz) {
|
||||
public <T extends AbstractArrow> @NotNull T spawnArrow(@NotNull Location location,
|
||||
@NotNull Vector direction, float speed, float spread, @NotNull Class<T> 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 <T extends Entity> @NotNull Collection<T> getEntitiesByClass(final @NotNull Class<T> cls) {
|
||||
public <T extends Entity> @NotNull Collection<T> getEntitiesByClass(
|
||||
final @NotNull Class<T> cls) {
|
||||
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(cls));
|
||||
}
|
||||
|
||||
@ -481,7 +502,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Entity> getNearbyEntities(final @NotNull Location location, final double x, final double y, final double z) {
|
||||
public @NotNull Collection<Entity> 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 <T extends Entity> @NotNull T spawn(final @NotNull Location location, final @NotNull Class<T> clazz) throws IllegalArgumentException {
|
||||
public <T extends Entity> @NotNull T spawn(final @NotNull Location location,
|
||||
final @NotNull Class<T> clazz) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz, Consumer<T> function) throws IllegalArgumentException {
|
||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
||||
Consumer<T> function) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz, @Nullable Consumer<T> function, CreatureSpawnEvent.@NotNull SpawnReason reason) throws IllegalArgumentException {
|
||||
public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz,
|
||||
@Nullable Consumer<T> 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<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -692,7 +722,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void playEffect(final @NotNull Location location, final @NotNull Effect effect, final T data, final int radius) {
|
||||
public <T> void playEffect(final @NotNull Location location, final @NotNull Effect effect,
|
||||
final T data, final int radius) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@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<Object>() {
|
||||
@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<Object>() {
|
||||
@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<Object>() {
|
||||
@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<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
@ -1042,13 +1080,14 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0, Predicate<Entity> arg1) {
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull BoundingBox arg0,
|
||||
Predicate<Entity> arg1) {
|
||||
return parent.getNearbyEntities(arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull Location arg0, double arg1, double arg2, double arg3,
|
||||
Predicate<Entity> arg4) {
|
||||
public @NotNull Collection<Entity> getNearbyEntities(@NotNull Location arg0, double arg1,
|
||||
double arg2, double arg3, Predicate<Entity> 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<Entity> arg6) {
|
||||
public RayTraceResult rayTrace(@NotNull Location arg0, @NotNull Vector arg1, double arg2,
|
||||
@NotNull FluidCollisionMode arg3, boolean arg4, double arg5, Predicate<Entity> 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<Entity> arg3) {
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1,
|
||||
double arg2, Predicate<Entity> arg3) {
|
||||
return parent.rayTraceEntities(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1, double arg2, double arg3,
|
||||
Predicate<Entity> arg4) {
|
||||
public RayTraceResult rayTraceEntities(@NotNull Location arg0, @NotNull Vector arg1,
|
||||
double arg2, double arg3, Predicate<Entity> 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<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent) {
|
||||
public @NotNull CompletableFuture<Chunk> 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 <T> void spawnParticle(
|
||||
@NotNull Particle particle, List<Player> 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 <T> void spawnParticle(@NotNull Particle particle, List<Player> 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 <T> void spawnParticle(@NotNull Particle particle, List<Player> list, Player player, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t, boolean b) {
|
||||
public <T> void spawnParticle(@NotNull Particle particle, List<Player> 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 <T> 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
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -31,10 +31,10 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
private YAMLProcessor config;
|
||||
private Map<String, Set<String>> userPermissionsCache;
|
||||
private Set<String> defaultPermissionsCache;
|
||||
private Map<String, Set<String>> userGroups;
|
||||
private final YAMLProcessor config;
|
||||
private final Map<String, Set<String>> userPermissionsCache = new HashMap<>();
|
||||
private final Set<String> defaultPermissionsCache = new HashSet<>();
|
||||
private final Map<String, Set<String>> 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<String, Set<String>> userGroupPermissions = new HashMap<>();
|
||||
|
||||
|
@ -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
|
||||
|
@ -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];
|
||||
|
@ -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<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>();
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private final List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<? extends PermissionsResolver>[] 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;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class bPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
return new bPermissionsResolver(server);
|
||||
}
|
||||
|
||||
|
||||
private final Server server;
|
||||
|
||||
public bPermissionsResolver(Server server) {
|
||||
|
@ -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!");
|
||||
}
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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<Chunk> future = Fawe.get().getQueueHandler().sync((Supplier<Chunk>) () -> freshWorld.getChunkAt(X, Z));
|
||||
Future<Chunk> future = Fawe.get().getQueueHandler().sync((Supplier<Chunk>) () -> freshWorld.getChunkAt(
|
||||
chunkX, chunkZ));
|
||||
while (!future.isDone()) {
|
||||
// this feels so dirty
|
||||
freshWorld.getChunkProvider().runTasks();
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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.<br>
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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<Nothing> {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<Character> current;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
|
@ -10,7 +10,6 @@ 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;
|
||||
@ -19,6 +18,7 @@ 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 {
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -1,30 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2008, http://www.snakeyaml.org
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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 <a href="http://yaml.org/spec/1.1/#id859333">Figure 3.1. Processing
|
||||
* Overview</a>
|
||||
* @param data
|
||||
* instance to build the representation tree for
|
||||
* @param data instance to build the representation tree for
|
||||
* @return representation tree
|
||||
* @see <a href="http://yaml.org/spec/1.1/#id859333">Figure 3.1. Processing
|
||||
* Overview</a>
|
||||
*/
|
||||
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<? extends Object> 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<Object> 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<? extends Object> data, Writer output) {
|
||||
dumpAll(data, output, null);
|
||||
}
|
||||
|
||||
private void dumpAll(Iterator<? extends Object> 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.
|
||||
* </p>
|
||||
*
|
||||
* @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 <code>null</code> 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
|
||||
* <code>null</code> 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 <code>null</code> 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
|
||||
* <code>null</code> 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)
|
||||
* </p>
|
||||
*
|
||||
* @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 <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
|
||||
* @param data
|
||||
* representation tree
|
||||
* @param data representation tree
|
||||
* @return Event list
|
||||
* @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
|
||||
*/
|
||||
public List<Event> 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 <T>
|
||||
* 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 <T> 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 <T>
|
||||
* 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 <T> 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 <T>
|
||||
* 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 <T> 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<Object> 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<Object> 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<Object> 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 <a href="http://yaml.org/spec/1.1/#id859333">Figure 3.1. Processing
|
||||
* Overview</a>
|
||||
* @param yaml
|
||||
* YAML document
|
||||
* @param yaml YAML document
|
||||
* @return parsed root Node for the specified YAML document
|
||||
* @see <a href="http://yaml.org/spec/1.1/#id859333">Figure 3.1. Processing
|
||||
* Overview</a>
|
||||
*/
|
||||
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 <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
|
||||
* @param yaml
|
||||
* stream of YAML documents
|
||||
* @param yaml stream of YAML documents
|
||||
* @return parsed root Nodes for all the specified YAML documents
|
||||
* @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
|
||||
*/
|
||||
public Iterable<Node> 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 <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
|
||||
* @param yaml
|
||||
* YAML document(s)
|
||||
* @param yaml YAML document(s)
|
||||
* @return parsed events
|
||||
* @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
|
||||
*/
|
||||
public Iterable<Event> parse(Reader yaml) {
|
||||
final Parser parser = new ParserImpl(new StreamReader(yaml));
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The encoding used may follow the system dependent default.
|
||||
* </p>
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
|
@ -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.
|
||||
*
|
||||
* <p>
|
||||
* The minimum value this may be is 2, and the maximum is 9.
|
||||
* </p>
|
||||
*
|
||||
* @return How much to indent by
|
||||
*/
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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}.
|
||||
*/
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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<SettingType, Object> 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<String, Object> 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<? extends String>) 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<String, Object> 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<? extends String>) 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<String> perms = getPermissions();
|
||||
for (String perm : perms) {
|
||||
if (actor.hasPermission(perm)) return true;
|
||||
if (actor.hasPermission(perm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return perms.isEmpty();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user