Add and apply .editorconfig from P2 (#1195)

* Consistenty use javax annotations.
 - Unfortunately jetbrains annotations seem to be exposed transitively via core somewhere, but with the correct IDE settings, annotations can be defaulted to javax
 - Cleaning up of import order in #1195
 - Must be merged before #1195

* Add and apply .editorconfig from P2
 - Does not rearrange entries

* Address some comments

* add back some javadoc comments

* Address final comments

Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
dordsor21
2021-07-24 16:34:05 +01:00
committed by GitHub
parent 3b4beba7d6
commit 8c0195970b
1143 changed files with 143599 additions and 9952 deletions

View File

@ -1,13 +1,13 @@
package com.fastasyncworldedit.bukkit;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class BukkitPermissionAttachmentManager {
private final WorldEditPlugin plugin;
@ -33,4 +33,5 @@ public class BukkitPermissionAttachmentManager {
p.removeAttachment(attach);
}
}
}

View File

@ -1,29 +1,27 @@
package com.fastasyncworldedit.bukkit;
import com.fastasyncworldedit.bukkit.util.image.BukkitImageViewer;
import com.fastasyncworldedit.core.FAWEPlatformAdapterImpl;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.IFawe;
import com.fastasyncworldedit.core.queue.implementation.preloader.AsyncPreloader;
import com.fastasyncworldedit.core.queue.implementation.preloader.Preloader;
import com.fastasyncworldedit.core.queue.implementation.QueueHandler;
import com.fastasyncworldedit.bukkit.adapter.BukkitQueueHandler;
import com.fastasyncworldedit.bukkit.adapter.NMSAdapter;
import com.fastasyncworldedit.bukkit.listener.BrushListener;
import com.fastasyncworldedit.bukkit.listener.ChunkListener9;
import com.fastasyncworldedit.bukkit.listener.RenderListener;
import com.fastasyncworldedit.bukkit.regions.GriefPreventionFeature;
import com.fastasyncworldedit.bukkit.regions.GriefDefenderFeature;
import com.fastasyncworldedit.bukkit.regions.GriefPreventionFeature;
import com.fastasyncworldedit.bukkit.regions.ResidenceFeature;
import com.fastasyncworldedit.bukkit.regions.TownyFeature;
import com.fastasyncworldedit.bukkit.regions.WorldGuardFeature;
import com.fastasyncworldedit.bukkit.util.BukkitTaskManager;
import com.fastasyncworldedit.bukkit.util.ItemUtil;
import com.fastasyncworldedit.bukkit.util.MinecraftVersion;
//import com.fastasyncworldedit.bukkit.util.image.BukkitImageViewer;
import com.fastasyncworldedit.bukkit.util.image.BukkitImageViewer;
import com.fastasyncworldedit.core.FAWEPlatformAdapterImpl;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.IFawe;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.queue.implementation.QueueHandler;
import com.fastasyncworldedit.core.queue.implementation.preloader.AsyncPreloader;
import com.fastasyncworldedit.core.queue.implementation.preloader.Preloader;
import com.fastasyncworldedit.core.regions.FaweMaskManager;
import com.fastasyncworldedit.core.util.ThirdPartyManager;
import com.fastasyncworldedit.core.util.TaskManager;
import com.fastasyncworldedit.core.util.WEManager;
import com.fastasyncworldedit.core.util.image.ImageViewer;
@ -44,7 +42,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.UUID;
@ -91,7 +88,7 @@ public class FaweBukkit implements IFawe, Listener {
TaskManager.IMP.task(() -> {
// Fix for ProtocolSupport
Settings.IMP.PROTOCOL_SUPPORT_FIX =
Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport");
Bukkit.getPluginManager().isPluginEnabled("ProtocolSupport");
// This class
Bukkit.getPluginManager().registerEvents(FaweBukkit.this, FaweBukkit.this.plugin);
@ -101,7 +98,8 @@ public class FaweBukkit implements IFawe, Listener {
});
}
@Override public QueueHandler getQueueHandler() {
@Override
public QueueHandler getQueueHandler() {
return new BukkitQueueHandler();
}
@ -112,20 +110,12 @@ public class FaweBukkit implements IFawe, Listener {
PluginManager manager = Bukkit.getPluginManager();
if (manager.getPlugin("PacketListenerApi") == null) {
File output = new File(plugin.getDataFolder().getParentFile(),
"PacketListenerAPI_v3.7.6-SNAPSHOT.jar");
byte[] jarData = ThirdPartyManager.PacketListenerAPI.download();
try (FileOutputStream fos = new FileOutputStream(output)) {
fos.write(jarData);
}
LOGGER.error("PacketListener not found! Please install PacketListenerAPI v3.7.6 or above before attempting to " +
"complete image-related edits");
}
if (manager.getPlugin("MapManager") == null) {
File output = new File(plugin.getDataFolder().getParentFile(),
"MapManager_v1.7.8-SNAPSHOT.jar");
byte[] jarData = ThirdPartyManager.MapManager.download();
try (FileOutputStream fos = new FileOutputStream(output)) {
fos.write(jarData);
}
LOGGER.error("MapManager not found! Please install PacketListenerAPI v1.7.8 or above before attempting to " +
"complete image-related edits");
}
return new BukkitImageViewer(BukkitAdapter.adapt(player));
} catch (Throwable ignored) {
@ -133,7 +123,8 @@ public class FaweBukkit implements IFawe, Listener {
return null;
}
@Override public File getDirectory() {
@Override
public File getDirectory() {
return plugin.getDataFolder();
}
@ -151,21 +142,22 @@ public class FaweBukkit implements IFawe, Listener {
return tmp;
}
@Override public String getDebugInfo() {
@Override
public String getDebugInfo() {
StringBuilder msg = new StringBuilder();
Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins();
msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n");
msg.append("Plugins (").append(plugins.length).append("): \n");
for (Plugin p : plugins) {
msg.append(" - ").append(p.getName()).append(":").append("\n")
.append(" • Version: ").append(p.getDescription().getVersion()).append("\n")
.append(" • Enabled: ").append(p.isEnabled()).append("\n")
.append(" • Main: ").append(p.getDescription().getMain()).append("\n")
.append(" • Authors: ").append(p.getDescription().getAuthors()).append("\n")
.append(" • Load Before: ").append(p.getDescription().getLoadBefore()).append("\n")
.append(" • Dependencies: ").append(p.getDescription().getDepend()).append("\n")
.append(" • Soft Dependencies: ").append(p.getDescription().getSoftDepend()).append("\n")
.append(" • Provides: ").append(p.getDescription().getProvides()).append("\n");
.append(" • Version: ").append(p.getDescription().getVersion()).append("\n")
.append(" • Enabled: ").append(p.isEnabled()).append("\n")
.append(" • Main: ").append(p.getDescription().getMain()).append("\n")
.append(" • Authors: ").append(p.getDescription().getAuthors()).append("\n")
.append(" • Load Before: ").append(p.getDescription().getLoadBefore()).append("\n")
.append(" • Dependencies: ").append(p.getDescription().getDepend()).append("\n")
.append(" • Soft Dependencies: ").append(p.getDescription().getSoftDepend()).append("\n")
.append(" • Provides: ").append(p.getDescription().getProvides()).append("\n");
}
return msg.toString();
}
@ -173,7 +165,8 @@ public class FaweBukkit implements IFawe, Listener {
/**
* The task manager handles sync/async tasks.
*/
@Override public TaskManager getTaskManager() {
@Override
public TaskManager getTaskManager() {
return new BukkitTaskManager(plugin);
}
@ -184,9 +177,10 @@ public class FaweBukkit implements IFawe, Listener {
/**
* A mask manager handles region restrictions e.g., PlotSquared plots / WorldGuard regions
*/
@Override public Collection<FaweMaskManager> getMaskManagers() {
@Override
public Collection<FaweMaskManager> getMaskManagers() {
final Plugin worldguardPlugin =
Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
final ArrayList<FaweMaskManager> managers = new ArrayList<>();
if (worldguardPlugin != null && worldguardPlugin.isEnabled()) {
try {
@ -212,7 +206,7 @@ public class FaweBukkit implements IFawe, Listener {
}
}
final Plugin griefpreventionPlugin =
Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
if (griefpreventionPlugin != null && griefpreventionPlugin.isEnabled()) {
try {
managers.add(new GriefPreventionFeature(griefpreventionPlugin));
@ -259,26 +253,31 @@ 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;
}
@ -295,11 +294,12 @@ public class FaweBukkit implements IFawe, Listener {
if (plotSquared.getClass().getPackage().toString().contains("intellectualsites")) {
WEManager.IMP.managers.add(new com.fastasyncworldedit.bukkit.regions.plotsquaredv4.PlotSquaredFeature());
LOGGER.info("Plugin 'PlotSquared' found. Using it now.");
} else if (PlotSquared.get().getVersion().version[0] == 6){
} else if (PlotSquared.get().getVersion().version[0] == 6) {
WEManager.IMP.managers.add(new com.fastasyncworldedit.bukkit.regions.plotsquared.PlotSquaredFeature());
LOGGER.info("Plugin 'PlotSquared' found. Using it now.");
} else {
LOGGER.error("Incompatible version of PlotSquared found. Please use PlotSquared v6.");
}
}
}

View File

@ -1,8 +1,8 @@
package com.fastasyncworldedit.bukkit.adapter;
import co.aikar.timings.Timings;
import com.fastasyncworldedit.core.queue.implementation.QueueHandler;
import com.fastasyncworldedit.bukkit.listener.ChunkListener;
import com.fastasyncworldedit.core.queue.implementation.QueueHandler;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import org.apache.logging.log4j.Logger;
import org.spigotmc.AsyncCatcher;
@ -17,6 +17,7 @@ public class BukkitQueueHandler extends QueueHandler {
private static boolean alertTimingsChange = true;
private static Method methodCheck;
static {
try {
methodCheck = Class.forName("co.aikar.timings.TimingsManager").getDeclaredMethod("recheckEnabled");
@ -61,4 +62,5 @@ public class BukkitQueueHandler extends QueueHandler {
}
}
}
}

View File

@ -16,6 +16,7 @@ import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
public abstract class CachedBukkitAdapter implements IBukkitAdapter {
private int[] itemTypes;
private int[] blockTypes;
@ -98,4 +99,5 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
throw e;
}
}
}

View File

@ -1,13 +1,14 @@
package com.fastasyncworldedit.bukkit.adapter;
import javax.annotation.Nonnull;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nonnull;
public class DelegateLock extends ReentrantLockWithGetOwner {
private final ReentrantLock parent;
private volatile boolean modified;
private final AtomicInteger count;
@ -106,4 +107,5 @@ public class DelegateLock extends ReentrantLockWithGetOwner {
public synchronized String toString() {
return parent.toString();
}
}

View File

@ -3,6 +3,7 @@ package com.fastasyncworldedit.bukkit.adapter;
import java.util.concurrent.Semaphore;
public class DelegateSemaphore extends Semaphore {
private final Semaphore delegate;
public DelegateSemaphore(int permits, Semaphore delegate) {
@ -30,4 +31,5 @@ public class DelegateSemaphore extends Semaphore {
public synchronized void release() {
this.delegate.release();
}
}

View File

@ -1,11 +1,9 @@
package com.fastasyncworldedit.bukkit.adapter;
import static com.google.common.base.Preconditions.checkNotNull;
import com.fastasyncworldedit.bukkit.util.BukkitItemStack;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitEntity;
import com.fastasyncworldedit.bukkit.util.BukkitItemStack;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
@ -25,8 +23,6 @@ import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
import java.util.Locale;
import com.sk89q.worldedit.world.item.ItemTypes;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -35,6 +31,10 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Locale;
import static com.google.common.base.Preconditions.checkNotNull;
public interface IBukkitAdapter {
/**
@ -81,7 +81,7 @@ public interface IBukkitAdapter {
/**
* Create a Bukkit location from a WorldEdit position with a Bukkit world.
*
* @param world the Bukkit world
* @param world the Bukkit world
* @param position the WorldEdit position
* @return a Bukkit location
*/
@ -90,7 +90,8 @@ public interface IBukkitAdapter {
checkNotNull(position);
return new org.bukkit.Location(
world,
position.getX(), position.getY(), position.getZ());
position.getX(), position.getY(), position.getZ()
);
}
default org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) {
@ -100,7 +101,7 @@ public interface IBukkitAdapter {
/**
* Create a Bukkit location from a WorldEdit location with a Bukkit world.
*
* @param world the Bukkit world
* @param world the Bukkit world
* @param location the WorldEdit location
* @return a Bukkit location
*/
@ -111,7 +112,8 @@ public interface IBukkitAdapter {
world,
location.getX(), location.getY(), location.getZ(),
location.getYaw(),
location.getPitch());
location.getPitch()
);
}
/**
@ -192,7 +194,7 @@ public interface IBukkitAdapter {
default BlockType asBlockType(Material material) {
checkNotNull(material);
if (!material.isBlock()) {
throw new IllegalArgumentException(material.getKey().toString() + " is not a block!") {
throw new IllegalArgumentException(material.getKey() + " is not a block!") {
@Override
public synchronized Throwable fillInStackTrace() {
return this;
@ -203,7 +205,6 @@ public interface IBukkitAdapter {
}
/**
* Converts a Material to a ItemType
*
@ -269,6 +270,7 @@ public interface IBukkitAdapter {
default BukkitPlayer adapt(Player player) {
return WorldEditPlugin.getInstance().wrapPlayer(player);
}
/**
* Create a Bukkit Player from a WorldEdit Player.
*
@ -298,7 +300,7 @@ public interface IBukkitAdapter {
* Checks equality between a WorldEdit BlockType and a Bukkit Material
*
* @param blockType The WorldEdit BlockType
* @param type The Bukkit Material
* @param type The Bukkit Material
* @return If they are equal
*/
default boolean equals(BlockType blockType, Material type) {
@ -351,4 +353,5 @@ public interface IBukkitAdapter {
throw new NotABlockException();
}
}
}

View File

@ -12,6 +12,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
@ -21,7 +22,6 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@ -38,6 +38,7 @@ import java.util.Map;
import java.util.OptionalInt;
public interface IDelegateBukkitImplAdapter<T> extends BukkitImplAdapter<T> {
BukkitImplAdapter<T> getParent();
@Override
@ -262,4 +263,5 @@ public interface IDelegateBukkitImplAdapter<T> extends BukkitImplAdapter<T> {
default BlockState asBlockState(ItemStack itemStack) {
return getParent().asBlockState(itemStack);
}
}

View File

@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.Map;
public abstract class MapChunkUtil<T> {
protected Field fieldX;
protected Field fieldZ;
protected Field fieldHeightMap;
@ -50,4 +51,5 @@ public abstract class MapChunkUtil<T> {
return null;
}
}
}

View File

@ -1,11 +1,11 @@
package com.fastasyncworldedit.bukkit.adapter;
import com.fastasyncworldedit.core.FAWEPlatformAdapterImpl;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.world.block.BlockID;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.math.BlockVector3;
import com.fastasyncworldedit.core.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
@ -13,8 +13,11 @@ import java.util.Map;
import java.util.function.Function;
public class NMSAdapter implements FAWEPlatformAdapterImpl {
public static int createPalette(int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy,
int[] num_palette_buffer, char[] set, Map<BlockVector3, Integer> ticking_blocks, boolean fastmode) {
public static int createPalette(
int[] blockToPalette, int[] paletteToBlock, int[] blocksCopy,
int[] num_palette_buffer, char[] set, Map<BlockVector3, Integer> ticking_blocks, boolean fastmode
) {
int air = 0;
int num_palette = 0;
char lastOrdinal = BlockID.__RESERVED__;
@ -43,9 +46,11 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
if (ticking) {
BlockState state = BlockState.getFromOrdinal(ordinal);
ticking_blocks
.put(BlockVector3.at(i & 15, (i >> 8) & 15, (i >> 4) & 15),
WorldEditPlugin.getInstance().getBukkitImplAdapter()
.getInternalBlockStateId(state).orElse(0));
.put(
BlockVector3.at(i & 15, (i >> 8) & 15, (i >> 4) & 15),
WorldEditPlugin.getInstance().getBukkitImplAdapter()
.getInternalBlockStateId(state).orElse(0)
);
}
}
}
@ -61,9 +66,11 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
return air;
}
public static int createPalette(int layer, int[] blockToPalette, int[] paletteToBlock,
int[] blocksCopy, int[] num_palette_buffer, Function<Integer, char[]> get, char[] set,
Map<BlockVector3, Integer> ticking_blocks, boolean fastmode) {
public static int createPalette(
int layer, int[] blockToPalette, int[] paletteToBlock,
int[] blocksCopy, int[] num_palette_buffer, Function<Integer, char[]> get, char[] set,
Map<BlockVector3, Integer> ticking_blocks, boolean fastmode
) {
int air = 0;
int num_palette = 0;
char[] getArr = null;
@ -100,9 +107,11 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
if (ticking) {
BlockState state = BlockState.getFromOrdinal(ordinal);
ticking_blocks
.put(BlockVector3.at(i & 15, (i >> 8) & 15, (i >> 4) & 15),
WorldEditPlugin.getInstance().getBukkitImplAdapter()
.getInternalBlockStateId(state).orElse(0));
.put(
BlockVector3.at(i & 15, (i >> 8) & 15, (i >> 4) & 15),
WorldEditPlugin.getInstance().getBukkitImplAdapter()
.getInternalBlockStateId(state).orElse(0)
);
}
}
}
@ -126,9 +135,11 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
}
if (ticking) {
BlockState state = BlockState.getFromOrdinal(ordinal);
ticking_blocks.put(BlockVector3.at(i & 15, (i >> 8) & 15, (i >> 4) & 15),
WorldEditPlugin.getInstance().getBukkitImplAdapter()
.getInternalBlockStateId(state).orElse(0));
ticking_blocks.put(
BlockVector3.at(i & 15, (i >> 8) & 15, (i >> 4) & 15),
WorldEditPlugin.getInstance().getBukkitImplAdapter()
.getInternalBlockStateId(state).orElse(0)
);
}
}
int palette = blockToPalette[ordinal];
@ -192,4 +203,5 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
}
((BukkitGetBlocks) chunk).send(mask, lighting);
}
}

View File

@ -1,19 +1,25 @@
package com.fastasyncworldedit.bukkit.adapter;
import com.fastasyncworldedit.core.queue.IQueueChunk;
import com.fastasyncworldedit.core.queue.IQueueExtent;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.extent.processor.lighting.NMSRelighter;
import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode;
import com.fastasyncworldedit.core.extent.processor.lighting.Relighter;
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode;
import com.fastasyncworldedit.core.queue.IQueueChunk;
import com.fastasyncworldedit.core.queue.IQueueExtent;
import com.sk89q.worldedit.world.World;
import javax.annotation.Nonnull;
public class NMSRelighterFactory implements RelighterFactory {
@Override
public @Nonnull Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue) {
return new NMSRelighter(queue,
relightMode != null ? relightMode : RelightMode.valueOf(Settings.IMP.LIGHTING.MODE));
public @Nonnull
Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue) {
return new NMSRelighter(
queue,
relightMode != null ? relightMode : RelightMode.valueOf(Settings.IMP.LIGHTING.MODE)
);
}
}

View File

@ -8,4 +8,5 @@ public class ReentrantLockWithGetOwner extends ReentrantLock {
public Thread getOwner() {
return super.getOwner();
}
}
}

View File

@ -1,9 +1,9 @@
package com.fastasyncworldedit.bukkit.adapter;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.queue.IChunkCache;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.util.MathMan;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
@ -16,6 +16,9 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import org.apache.logging.log4j.Logger;
import org.bukkit.generator.BlockPopulator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@ -30,20 +33,18 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
import org.apache.logging.log4j.Logger;
import org.bukkit.generator.BlockPopulator;
/**
* Represents an abstract regeneration handler.
*
* @param <IChunkAccess> the type of the {@Code IChunkAccess} of the current Minecraft implementation
* @param <ProtoChunk> the type of the {@Code ProtoChunk} of the current Minecraft implementation
* @param <Chunk> the type of the {@Code Chunk} of the current Minecraft implementation
* @param <ChunkStatus> the type of the {@Code ChunkStatusWrapper} wrapping the {@Code ChunkStatus} enum
* @param <ProtoChunk> the type of the {@Code ProtoChunk} of the current Minecraft implementation
* @param <Chunk> the type of the {@Code Chunk} of the current Minecraft implementation
* @param <ChunkStatus> the type of the {@Code ChunkStatusWrapper} wrapping the {@Code ChunkStatus} enum
*/
public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess, Chunk extends IChunkAccess, ChunkStatus extends Regenerator.ChunkStatusWrapper<IChunkAccess>> {
private static final Logger LOGGER = LogManagerCompat.getLogger();
protected final org.bukkit.World originalBukkitWorld;
protected final Region region;
protected final Extent target;
@ -53,7 +54,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
protected final Map<ChunkStatus, Concurrency> chunkStati = new LinkedHashMap<>();
protected boolean generateConcurrent = true;
protected long seed;
private final Long2ObjectLinkedOpenHashMap<ProtoChunk> protoChunks = new Long2ObjectLinkedOpenHashMap<>();
private final Long2ObjectOpenHashMap<Chunk> chunks = new Long2ObjectOpenHashMap<>();
private ExecutorService executor;
@ -61,10 +62,11 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/**
* Initializes an abstract regeneration handler.
*
* @param originalBukkitWorld the Bukkit world containing all the information on how to regenerate the {code Region}
* @param region the selection to regenerate
* @param target the target {@code Extent} to paste the regenerated blocks into
* @param options the options to used while regenerating and pasting into the target {@code Extent}
* @param region the selection to regenerate
* @param target the target {@code Extent} to paste the regenerated blocks into
* @param options the options to used while regenerating and pasting into the target {@code Extent}
*/
public Regenerator(org.bukkit.World originalBukkitWorld, Region region, Extent target, RegenOptions options) {
this.originalBukkitWorld = originalBukkitWorld;
@ -75,6 +77,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/**
* Regenerates the selected {@code Region}.
*
* @return whether or not the regeneration process was successful
* @throws Exception when something goes terribly wrong
*/
@ -116,6 +119,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/**
* Returns the {@code ProtoChunk} at the given chunk coordinates.
*
* @param x the chunk x coordinate
* @param z the chunk z coordinate
* @return the {@code ProtoChunk} at the given chunk coordinates or null if it is not part of the regeneration process or has not been initialized yet.
@ -126,6 +130,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/**
* Returns the {@code Chunk} at the given chunk coordinates.
*
* @param x the chunk x coordinate
* @param z the chunk z coordinate
* @return the {@code Chunk} at the given chunk coordinates or null if it is not part of the regeneration process or has not been converted yet.
@ -142,12 +147,13 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
//TODO: can we get that required radius down without affecting chunk generation (e.g. strucures, features, ...)?
//for now it is working well and fast, if we are bored in the future we could do the research (a lot of it) to reduce the border radius
//generate chunk coords lists with a certain radius
Int2ObjectOpenHashMap<List<Long>> chunkCoordsForRadius = new Int2ObjectOpenHashMap<>();
chunkStati.keySet().stream().map(ChunkStatusWrapper::requiredNeigborChunkRadius0).distinct().forEach(radius -> {
if (radius == -1) //ignore ChunkStatus.EMPTY
if (radius == -1) { //ignore ChunkStatus.EMPTY
return;
}
int border = 16 - radius; //9 = 8 + 1, 8: max border radius used in chunk stages, 1: need 1 extra chunk for chunk features to generate at the border of the region
chunkCoordsForRadius.put(radius, getChunkCoordsRegen(region, border));
});
@ -161,8 +167,9 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
//generate lists for RegionLimitedWorldAccess, need to be square with odd length (e.g. 17x17), 17 = 1 middle chunk + 8 border chunks * 2
Int2ObjectOpenHashMap<Long2ObjectOpenHashMap<List<IChunkAccess>>> worldlimits = new Int2ObjectOpenHashMap<>();
chunkStati.keySet().stream().map(ChunkStatusWrapper::requiredNeigborChunkRadius0).distinct().forEach(radius -> {
if (radius == -1) //ignore ChunkStatus.EMPTY
if (radius == -1) { //ignore ChunkStatus.EMPTY
return;
}
Long2ObjectOpenHashMap<List<IChunkAccess>> map = new Long2ObjectOpenHashMap<>();
for (Long xz : chunkCoordsForRadius.get(radius)) {
int x = MathMan.unpairIntX(xz);
@ -281,19 +288,19 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
// realExtent.setBlockLight(vec, extent.getBrightness(vec));
}
}
//functions to be implemented by sub class
private void cleanup0() {
if (executor != null) {
executor.shutdownNow();
}
cleanup();
}
//functions to be implemented by sub class
/**
* <p>Implement the preparation process in here. DO NOT instanciate any variable here that require the cleanup function. This function is for gathering further information before initializing a new
* world.</p>
*
*
* <p>Fields required to be initialized: chunkStati, seed</p>
* <p>For chunkStati also see {code ChunkStatusWrapper}.</p>
*
@ -303,20 +310,21 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/**
* Implement the creation of the seperate world in here.
*
* <p>
* Fields required to be initialized: generateConcurrent
*
* @return true if everything went fine, otherwise false. When false is returned the Regenerator halts the regeneration process and calls the cleanup function.
* @throws java.lang.Exception When the implementation of this method throws and exception the Regenerator halts the regeneration process and calls the cleanup function.
*/
protected abstract boolean initNewWorld() throws Exception;
/**
* Implement the cleanup of all the mess that is created during the regeneration process (initNewWorld() and generate()).This function must not throw any exceptions.
*/
protected abstract void cleanup();
//functions to implement by sub class - regenate related
/**
* Implement the initialization of a {@code ProtoChunk} here.
*
@ -352,28 +360,39 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/**
* Implement the population of the {@code Chunk} with the given chunk random and {@code BlockPopulator} here.
*
* @param chunk the {@code Chunk} to populate
* @param chunk the {@code Chunk} to populate
* @param random the chunk random to use for population
* @param pop the {@code BlockPopulator} to use
* @param pop the {@code BlockPopulator} to use
*/
protected abstract void populate(Chunk chunk, Random random, BlockPopulator pop);
/**
* Implement the initialization an {@code IChunkCache<IChunkGet>} here. Use will need the {@code getChunkAt} function
*
* @return an initialized {@code IChunkCache<IChunkGet>}
*/
protected abstract IChunkCache<IChunkGet> initSourceQueueCache();
//algorithms
private List<Long> getChunkCoordsRegen(Region region, int border) { //needs to be square num of chunks
BlockVector3 oldMin = region.getMinimumPoint();
BlockVector3 newMin = BlockVector3.at((oldMin.getX() >> 4 << 4) - border * 16, oldMin.getY(), (oldMin.getZ() >> 4 << 4) - border * 16);
BlockVector3 newMin = BlockVector3.at(
(oldMin.getX() >> 4 << 4) - border * 16,
oldMin.getY(),
(oldMin.getZ() >> 4 << 4) - border * 16
);
BlockVector3 oldMax = region.getMaximumPoint();
BlockVector3 newMax = BlockVector3.at((oldMax.getX() >> 4 << 4) + (border + 1) * 16 - 1, oldMax.getY(), (oldMax.getZ() >> 4 << 4) + (border + 1) * 16 - 1);
BlockVector3 newMax = BlockVector3.at(
(oldMax.getX() >> 4 << 4) + (border + 1) * 16 - 1,
oldMax.getY(),
(oldMax.getZ() >> 4 << 4) + (border + 1) * 16 - 1
);
Region adjustedRegion = new CuboidRegion(newMin, newMax);
return adjustedRegion.getChunks().stream()
.map(c -> BlockVector2.at(c.getX(), c.getZ()))
.sorted(Comparator.<BlockVector2>comparingInt(c -> c.getZ()).thenComparingInt(c -> c.getX())) //needed for RegionLimitedWorldAccess
.sorted(Comparator
.<BlockVector2>comparingInt(c -> c.getZ())
.thenComparingInt(c -> c.getX())) //needed for RegionLimitedWorldAccess
.map(c -> MathMan.pairInt(c.getX(), c.getZ()))
.collect(Collectors.toList());
}
@ -381,11 +400,14 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/**
* Creates a list of chunkcoord rows that may be executed concurrently
*
* @param allcoords the coords that should be sorted into rows, must be sorted by z and x
* @param allcoords the coords that should be sorted into rows, must be sorted by z and x
* @param requiredNeighborChunkRadius the radius of neighbor chunks that may not be written to conccurently (ChunkStatus.requiredNeighborRadius)
* @return a list of chunkcoords rows that may be executed concurrently
*/
private SequentialTasks<ConcurrentTasks<SequentialTasks<Long>>> getChunkStatusTaskRows(List<Long> allcoords, int requiredNeighborChunkRadius) {
private SequentialTasks<ConcurrentTasks<SequentialTasks<Long>>> getChunkStatusTaskRows(
List<Long> allcoords,
int requiredNeighborChunkRadius
) {
int requiredneighbors = Math.max(0, requiredNeighborChunkRadius);
int minx = allcoords.isEmpty() ? 0 : MathMan.unpairIntX(allcoords.get(0));
@ -413,8 +435,9 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
tasks = new SequentialTasks(numlists);
for (int offset = 0; offset < numlists; offset++) {
ConcurrentTasks<SequentialTasks<Long>> para = new ConcurrentTasks((maxz - minz + 1) / numlists + 1);
for (int i = 0; minx + i * numlists + offset <= maxx; i++)
for (int i = 0; minx + i * numlists + offset <= maxx; i++) {
para.add(byx.get(minx + i * numlists + offset));
}
tasks.add(para);
}
} else {
@ -437,8 +460,9 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
tasks = new SequentialTasks(numlists);
for (int offset = 0; offset < numlists; offset++) {
ConcurrentTasks<SequentialTasks<Long>> para = new ConcurrentTasks((maxx - minx + 1) / numlists + 1);
for (int i = 0; minz + i * numlists + offset <= maxz; i++)
for (int i = 0; minz + i * numlists + offset <= maxz; i++) {
para.add(byz.get(minz + i * numlists + offset));
}
tasks.add(para);
}
}
@ -456,8 +480,10 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
}
//classes
/**
* This class is used to wrap the ChunkStatus of the current Minecraft implementation and as the implementation to execute a chunk generation step.
*
* @param <IChunkAccess> the IChunkAccess class of the current Minecraft implementation
*/
public static abstract class ChunkStatusWrapper<IChunkAccess> {
@ -483,9 +509,9 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/**
* Return the name of the wrapped {@code ChunkStatus}.
*
* @param xz represents the chunk coordinates of the chunk to process as denoted by {@code MathMan}
* @param accessibleChunks a list of chunks that will be used during the execution of the wrapped {@code ChunkStatus}.
* This list is order in the correct order required by the {@code ChunkStatus}, unless Mojang suddenly decides to do things differently.
* @param xz represents the chunk coordinates of the chunk to process as denoted by {@code MathMan}
* @param accessibleChunks a list of chunks that will be used during the execution of the wrapped {@code ChunkStatus}.
* This list is order in the correct order required by the {@code ChunkStatus}, unless Mojang suddenly decides to do things differently.
*/
public abstract void processChunk(Long xz, List<IChunkAccess> accessibleChunks);
@ -493,9 +519,13 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
try {
processChunk(xz, accessibleChunks);
} catch (Exception e) {
LOGGER.error("Error while running " + name() + " on chunk " + MathMan.unpairIntX(xz) + "/" + MathMan.unpairIntY(xz), e);
LOGGER.error(
"Error while running " + name() + " on chunk " + MathMan.unpairIntX(xz) + "/" + MathMan.unpairIntY(xz),
e
);
}
}
}
public enum Concurrency {
@ -509,6 +539,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
public SequentialTasks(int expectedsize) {
super(expectedsize);
}
}
public static class ConcurrentTasks<T> extends Tasks<T> {
@ -516,6 +547,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
public ConcurrentTasks(int expectedsize) {
super(expectedsize);
}
}
public static class Tasks<T> implements Iterable<T> {
@ -537,7 +569,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
public int size() {
return tasks.size();
}
@Override
public Iterator<T> iterator() {
return tasks.iterator();
@ -547,5 +579,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
public String toString() {
return tasks.toString();
}
}
}

View File

@ -1,6 +1,5 @@
package com.fastasyncworldedit.bukkit.adapter;
import com.fastasyncworldedit.bukkit.adapter.CachedBukkitAdapter;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -11,6 +10,7 @@ import org.bukkit.block.data.BlockData;
import static com.google.common.base.Preconditions.checkNotNull;
public class SimpleBukkitAdapter extends CachedBukkitAdapter {
private BlockData[][] blockDataCache;
private boolean init() {
@ -18,7 +18,7 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
return false;
}
this.blockDataCache = new BlockData[BlockTypes.size()][];
blockDataCache[0] = new BlockData[] {Material.AIR.createBlockData()};
blockDataCache[0] = new BlockData[]{Material.AIR.createBlockData()};
return true;
}
@ -51,4 +51,5 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
throw e;
}
}
}

View File

@ -2,10 +2,10 @@ package com.fastasyncworldedit.bukkit.filter;
import com.fastasyncworldedit.core.regions.filter.CuboidRegionFilter;
import com.fastasyncworldedit.core.util.TaskManager;
import com.sk89q.worldedit.math.BlockVector2;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.GriefDefender;
import com.flowpowered.math.vector.Vector3i;
import com.griefdefender.api.GriefDefender;
import com.griefdefender.api.claim.Claim;
import com.sk89q.worldedit.math.BlockVector2;
import org.bukkit.World;
import java.util.ArrayDeque;
@ -15,6 +15,7 @@ import java.util.function.Supplier;
import static com.google.common.base.Preconditions.checkNotNull;
public class GriefDefenderFilter extends CuboidRegionFilter {
private final Collection<Claim> claims;
private final World world;
@ -37,4 +38,5 @@ public class GriefDefenderFilter extends CuboidRegionFilter {
}
}
}
}

View File

@ -14,13 +14,14 @@ import java.util.function.Supplier;
import static com.google.common.base.Preconditions.checkNotNull;
public class GriefPreventionFilter extends CuboidRegionFilter {
private final Collection<Claim> claims;
private final World world;
public GriefPreventionFilter(World world) {
checkNotNull(world);
this.claims = TaskManager.IMP.sync(
(Supplier<Collection<Claim>>) () -> new ArrayDeque<>(GriefPrevention.instance.dataStore.getClaims()));
(Supplier<Collection<Claim>>) () -> new ArrayDeque<>(GriefPrevention.instance.dataStore.getClaims()));
this.world = world;
}
@ -36,4 +37,5 @@ public class GriefPreventionFilter extends CuboidRegionFilter {
}
}
}
}

View File

@ -32,7 +32,7 @@ public class WorldGuardFilter extends CuboidRegionFilter {
public void calculateRegions() {
Fawe.get().getQueueHandler().sync(() -> {
WorldGuardFilter.this.manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(
BukkitAdapter.adapt(world));
BukkitAdapter.adapt(world));
for (ProtectedRegion region : manager.getRegions().values()) {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
@ -69,4 +69,5 @@ public class WorldGuardFilter extends CuboidRegionFilter {
ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
}
}

View File

@ -20,6 +20,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.Plugin;
public class BrushListener implements Listener {
public BrushListener(Plugin plugin) {
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@ -53,7 +54,8 @@ public class BrushListener implements Listener {
public void onPlayerMove(PlayerMoveEvent event) {
Location from = event.getFrom();
Location to = event.getTo();
if ((from.getYaw() != to.getYaw() && from.getPitch() != to.getPitch()) || from.getBlockX() != to.getBlockX() || from.getBlockZ() != to.getBlockZ() || from.getBlockY() != to.getBlockY()) {
if ((from.getYaw() != to.getYaw() && from.getPitch() != to.getPitch()) || from.getBlockX() != to.getBlockX() || from.getBlockZ() != to
.getBlockZ() || from.getBlockY() != to.getBlockY()) {
Player bukkitPlayer = event.getPlayer();
com.sk89q.worldedit.entity.Player player = BukkitAdapter.adapt(bukkitPlayer);
LocalSession session = player.getSession();
@ -83,4 +85,5 @@ public class BrushListener implements Listener {
}
}
}
}

View File

@ -1,7 +1,7 @@
package com.fastasyncworldedit.bukkit.listener;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.bukkit.FaweBukkit;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.util.FaweTimer;
import com.fastasyncworldedit.core.util.MathMan;
@ -50,8 +50,8 @@ public abstract class ChunkListener implements Listener {
private static final Logger LOGGER = LogManagerCompat.getLogger();
protected int rateLimit = 0;
protected Location lastCancelPos;
private int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS,
Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS};
private final int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS,
Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS};
public ChunkListener() {
if (Settings.IMP.TICK_LIMITER.ENABLED) {
@ -62,7 +62,7 @@ public abstract class ChunkListener implements Listener {
Location tmpLoc = lastCancelPos;
if (tmpLoc != null) {
LOGGER.debug("[FAWE Tick Limiter] Detected and cancelled physics lag source at "
+ tmpLoc);
+ tmpLoc);
}
rateLimit--;
physicsFreeze = false;
@ -93,7 +93,7 @@ public abstract class ChunkListener implements Listener {
public static boolean itemFreeze = false;
protected final Long2ObjectOpenHashMap<Boolean> badChunks = new Long2ObjectOpenHashMap<>();
private Long2ObjectOpenHashMap<int[]> counter = new Long2ObjectOpenHashMap<>();
private final Long2ObjectOpenHashMap<int[]> counter = new Long2ObjectOpenHashMap<>();
private int lastX = Integer.MIN_VALUE;
private int lastZ = Integer.MIN_VALUE;
private int[] lastCount;
@ -248,7 +248,7 @@ public abstract class ChunkListener implements Listener {
physStart = System.currentTimeMillis();
return;
} else if (System.currentTimeMillis() - physStart
< Settings.IMP.TICK_LIMITER.PHYSICS_MS) {
< Settings.IMP.TICK_LIMITER.PHYSICS_MS) {
return;
}
}
@ -281,7 +281,7 @@ public abstract class ChunkListener implements Listener {
String methodName = elem.getMethodName();
// setAir | setTypeAndData (hacky, but this needs to be efficient)
if (methodName.charAt(0) == 's' && methodName.length() == 6
|| methodName.length() == 14) {
|| methodName.length() == 14) {
return true;
}
}
@ -370,16 +370,16 @@ public abstract class ChunkListener implements Listener {
String className = elem.getClassName();
int len = className.length();
if (len > 15 && className.charAt(len - 15) == 'E' && className
.endsWith("EntityFireworks")) {
.endsWith("EntityFireworks")) {
for (Entity ent : world.getEntities()) {
if (ent.getType() == EntityType.FIREWORK) {
Vector velocity = ent.getVelocity();
double vertical = Math.abs(velocity.getY());
if (Math.abs(velocity.getX()) > vertical
|| Math.abs(velocity.getZ()) > vertical) {
|| Math.abs(velocity.getZ()) > vertical) {
LOGGER.warn(
"[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at "
+ ent.getLocation());
"[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at "
+ ent.getLocation());
ent.remove();
}
}
@ -409,9 +409,10 @@ public abstract class ChunkListener implements Listener {
if (rateLimit <= 0) {
rateLimit = 20;
LOGGER.warn(
"[FAWE `tick-limiter`] Detected and cancelled item lag source at " + loc);
"[FAWE `tick-limiter`] Detected and cancelled item lag source at " + loc);
}
event.setCancelled(true);
}
}
}

View File

@ -86,4 +86,5 @@ public class ChunkListener9 extends ChunkListener {
StackTraceElement[] elems = getElements(ex);
return elems.length > i ? elems[i] : null;
}
}

View File

@ -86,7 +86,7 @@ public class RenderListener implements Listener {
} else {
int[] val = views.get(uuid);
if (val == null) {
val = new int[] {value, (int) Fawe.get().getTimer().getTick()};
val = new int[]{value, (int) Fawe.get().getTimer().getTick()};
UUID uid = player.getUniqueId();
views.put(uid, val);
} else {
@ -136,4 +136,5 @@ public class RenderListener implements Listener {
UUID uid = player.getUniqueId();
views.remove(uid);
}
}

View File

@ -13,9 +13,9 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.PluginBase;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.io.InputStream;
import java.util.Iterator;
@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
public class PluginPreloader extends PluginBase {
private World world;
private Set<BlockVector2> loaded;
private int index;
@ -79,7 +80,7 @@ public class PluginPreloader extends PluginBase {
return;
}
Fawe.get().getQueueHandler().syncWhenFree(() -> {
for (; iter.hasNext() && invalidator.get();index++) {
for (; iter.hasNext() && invalidator.get(); index++) {
BlockVector2 chunk = iter.next();
if (!world.isChunkLoaded(chunk.getX(), chunk.getZ())) {
world.addPluginChunkTicket(chunk.getX(), chunk.getZ(), this);
@ -199,7 +200,13 @@ public class PluginPreloader extends PluginBase {
@Override
@Nullable
public List<String> onTabComplete(@Nonnull CommandSender sender, @Nonnull Command command, @Nonnull String alias, String[] args) {
public List<String> onTabComplete(
@Nonnull CommandSender sender,
@Nonnull Command command,
@Nonnull String alias,
String[] args
) {
return null;
}
}

View File

@ -12,4 +12,5 @@ public abstract class BukkitMaskManager extends FaweMaskManager {
public boolean hasMemberPermission(Permissible player) {
return player.hasPermission("fawe." + getKey() + ".member");
}
}

View File

@ -28,7 +28,9 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener
}
public boolean isAllowed(Player player, Claim claim, MaskType type) {
return GriefDefender.getCore().isEnabled(player.getWorld().getUID()) && !claim.isWilderness() && (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim.getOwnerUniqueId().equals(player.getUniqueId()) ||
return GriefDefender.getCore().isEnabled(player.getWorld().getUID()) && !claim.isWilderness() && (claim
.getOwnerName()
.equalsIgnoreCase(player.getName()) || claim.getOwnerUniqueId().equals(player.getUniqueId()) ||
type == MaskType.MEMBER && claim.getUserTrusts(TrustTypes.BUILDER).contains(player.getUniqueId()));
}
@ -41,8 +43,16 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener
if (!claim.isWilderness()) {
if (isAllowed(player, claim, type)) {
claim.getGreaterBoundaryCorner().getX();
final BlockVector3 pos1 = BlockVector3.at(claim.getLesserBoundaryCorner().getX(), claim.getLesserBoundaryCorner().getY(), claim.getLesserBoundaryCorner().getZ());
final BlockVector3 pos2 = BlockVector3.at(claim.getGreaterBoundaryCorner().getX(), claim.getGreaterBoundaryCorner().getY(), claim.getGreaterBoundaryCorner().getZ());
final BlockVector3 pos1 = BlockVector3.at(
claim.getLesserBoundaryCorner().getX(),
claim.getLesserBoundaryCorner().getY(),
claim.getLesserBoundaryCorner().getZ()
);
final BlockVector3 pos2 = BlockVector3.at(
claim.getGreaterBoundaryCorner().getX(),
claim.getGreaterBoundaryCorner().getY(),
claim.getGreaterBoundaryCorner().getZ()
);
return new FaweMask(new CuboidRegion(pos1, pos2)) {
@Override
@ -59,4 +69,5 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener
public RegionFilter getFilter(String world) {
return new GriefDefenderFilter(Bukkit.getWorld(world));
}
}

View File

@ -26,8 +26,10 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
}
public boolean isAllowed(Player player, Claim claim, MaskType type) {
return claim != null && (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim.getOwnerName().equals(player.getUniqueId()) ||
type == MaskType.MEMBER && claim.allowBuild(player, Material.AIR) == null);
return claim != null && (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim
.getOwnerName()
.equals(player.getUniqueId()) ||
type == MaskType.MEMBER && claim.allowBuild(player, Material.AIR) == null);
}
@Override
@ -37,8 +39,16 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
if (claim != null) {
if (isAllowed(player, claim, type)) {
claim.getGreaterBoundaryCorner().getBlockX();
final BlockVector3 pos1 = BlockVector3.at(claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ());
final BlockVector3 pos2 = BlockVector3.at(claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ());
final BlockVector3 pos1 = BlockVector3.at(
claim.getLesserBoundaryCorner().getBlockX(),
0,
claim.getLesserBoundaryCorner().getBlockZ()
);
final BlockVector3 pos2 = BlockVector3.at(
claim.getGreaterBoundaryCorner().getBlockX(),
256,
claim.getGreaterBoundaryCorner().getBlockZ()
);
return new FaweMask(new CuboidRegion(pos1, pos2)) {
@Override
@ -55,4 +65,5 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
public RegionFilter getFilter(String world) {
return new GriefPreventionFilter(Bukkit.getWorld(world));
}
}

View File

@ -19,8 +19,8 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
private static final Logger LOGGER = LogManagerCompat.getLogger();
private FaweBukkit plugin;
private Plugin residence;
private final FaweBukkit plugin;
private final Plugin residence;
public ResidenceFeature(final Plugin residencePlugin, final FaweBukkit p3) {
super(residencePlugin.getName());
@ -31,9 +31,11 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
public boolean isAllowed(Player player, ClaimedResidence residence, MaskType type) {
return residence != null &&
(residence.getOwner().equals(player.getName()) ||
residence.getOwner().equals(player.getUniqueId().toString()) ||
type == MaskType.MEMBER && TaskManager.IMP.sync(() -> residence.getPermissions().playerHas(player, "build", false)));
(residence.getOwner().equals(player.getName()) ||
residence.getOwner().equals(player.getUniqueId().toString()) ||
type == MaskType.MEMBER && TaskManager.IMP.sync(() -> residence
.getPermissions()
.playerHas(player, "build", false)));
}
@Override
@ -61,4 +63,5 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
}
return null;
}
}

View File

@ -83,10 +83,10 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
if (isMember) {
final Chunk chunk = location.getChunk();
final BlockVector3 pos1 = BlockVector3
.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
final BlockVector3 pos2 = BlockVector3.at(
chunk.getX() * 16 + 15, 156, chunk.getZ() * 16
+ 15);
chunk.getX() * 16 + 15, 156, chunk.getZ() * 16
+ 15);
return new FaweMask(new CuboidRegion(pos1, pos2)) {
@Override
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
@ -98,4 +98,5 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
}
return null;
}
}

View File

@ -1,8 +1,8 @@
package com.fastasyncworldedit.bukkit.regions;
import com.fastasyncworldedit.bukkit.filter.WorldGuardFilter;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.fastasyncworldedit.core.regions.FaweMask;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.fastasyncworldedit.core.regions.filter.RegionFilter;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
@ -28,9 +28,11 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import java.util.Locale;
public class WorldGuardFeature extends BukkitMaskManager implements Listener {
private final WorldGuardPlugin worldguard;
private static final Logger LOGGER = LogManagerCompat.getLogger();
@ -67,9 +69,18 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
if (global != null && isAllowed(player, global)) {
return global;
}
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(location.getX(), location.getY(), location.getZ()));
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(
location.getX(),
location.getY(),
location.getZ()
));
//Merge WorldGuardFlag
if (player.hasPermission("fawe.worldguardflag") && !regions.testState(player, Flags.BUILD, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK)) {
if (player.hasPermission("fawe.worldguardflag") && !regions.testState(
player,
Flags.BUILD,
Flags.BLOCK_PLACE,
Flags.BLOCK_BREAK
)) {
return null;
}
for (ProtectedRegion region : regions) {
@ -117,8 +128,16 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
pos2 = BlockVector3.at(Integer.MAX_VALUE, 255, Integer.MAX_VALUE);
} else {
if (myregion instanceof ProtectedCuboidRegion) {
pos1 = BlockVector3.at(myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
pos2 = BlockVector3.at(myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
pos1 = BlockVector3.at(
myregion.getMinimumPoint().getBlockX(),
myregion.getMinimumPoint().getBlockY(),
myregion.getMinimumPoint().getBlockZ()
);
pos2 = BlockVector3.at(
myregion.getMaximumPoint().getBlockX(),
myregion.getMaximumPoint().getBlockY(),
myregion.getMaximumPoint().getBlockZ()
);
} else {
return new FaweMask(adapt(myregion)) {
@Override
@ -144,6 +163,7 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
}
private static class AdaptedRegion extends AbstractRegion {
private final ProtectedRegion region;
public AdaptedRegion(ProtectedRegion region) {
@ -175,6 +195,7 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
public boolean contains(BlockVector3 position) {
return region.contains(position);
}
}
private static Region adapt(ProtectedRegion region) {
@ -192,4 +213,5 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
}
return new AdaptedRegion(region);
}
}

View File

@ -33,9 +33,9 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.checkerframework.checker.nullness.qual.NonNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@ -46,18 +46,20 @@ import static org.bukkit.Bukkit.getWorld;
public class FaweDelegateRegionManager {
public boolean setCuboids(final @NonNull PlotArea area,
final @NonNull Set<CuboidRegion> regions,
final @NonNull Pattern blocks,
int minY,
int maxY,
Runnable whenDone) {
public boolean setCuboids(
final @NonNull PlotArea area,
final @NonNull Set<CuboidRegion> regions,
final @NonNull Pattern blocks,
int minY,
int maxY,
Runnable whenDone
) {
TaskManager.IMP.async(() -> {
synchronized (FaweDelegateRegionManager.class) {
World world = BukkitAdapter.adapt(getWorld(area.getWorldName()));
EditSession session =
new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull()
.autoQueue(false).build();
new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull()
.autoQueue(false).build();
for (CuboidRegion region : regions) {
region.setPos1(region.getPos1().withY(minY));
region.setPos2(region.getPos2().withY(maxY));
@ -67,7 +69,8 @@ public class FaweDelegateRegionManager {
session.flushQueue();
for (CuboidRegion region : regions) {
FaweAPI.fixLighting(world, region, null,
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE));
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE)
);
}
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
@ -84,14 +87,22 @@ public class FaweDelegateRegionManager {
return hpw.getType() != PlotAreaType.AUGMENTED || hpw.getTerrain() == PlotAreaTerrainType.NONE;
}
public boolean handleClear(@Nonnull Plot plot,
@Nullable Runnable whenDone,
@Nonnull PlotManager manager) {
public boolean handleClear(
@Nonnull Plot plot,
@Nullable Runnable whenDone,
@Nonnull PlotManager manager
) {
TaskManager.IMP.async(() -> {
synchronized (FaweDelegateRegionManager.class) {
final HybridPlotWorld hybridPlotWorld = ((HybridPlotManager) manager).getHybridPlotWorld();
World world = BukkitAdapter.adapt(getWorld(hybridPlotWorld.getWorldName()));
EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession editSession = new EditSessionBuilder(world)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
if (!hybridPlotWorld.PLOT_SCHEMATIC || !Settings.Schematics.PASTE_ON_TOP) {
final BlockType bedrock;
@ -107,12 +118,22 @@ public class FaweDelegateRegionManager {
final BiomeType biome = hybridPlotWorld.getPlotBiome();
BlockVector3 pos1 = plot.getBottomAbs().getBlockVector3().withY(0);
BlockVector3 pos2 = pos1.add(BlockVector3.at(hybridPlotWorld.PLOT_WIDTH - 1, 255, hybridPlotWorld.PLOT_WIDTH - 1));
BlockVector3 pos2 = pos1.add(BlockVector3.at(
hybridPlotWorld.PLOT_WIDTH - 1,
255,
hybridPlotWorld.PLOT_WIDTH - 1
));
Region bedrockRegion = new CuboidRegion(pos1, pos2.withY(0));
Region fillingRegion = new CuboidRegion(pos1.withY(1), pos2.withY(hybridPlotWorld.PLOT_HEIGHT - 1));
Region floorRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT), pos2.withY(hybridPlotWorld.PLOT_HEIGHT));
Region airRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT + 1), pos2.withY(manager.getWorldHeight()));
Region floorRegion = new CuboidRegion(
pos1.withY(hybridPlotWorld.PLOT_HEIGHT),
pos2.withY(hybridPlotWorld.PLOT_HEIGHT)
);
Region airRegion = new CuboidRegion(
pos1.withY(hybridPlotWorld.PLOT_HEIGHT + 1),
pos2.withY(manager.getWorldHeight())
);
editSession.setBlocks(bedrockRegion, bedrock);
editSession.setBlocks(fillingRegion, filling);
@ -124,14 +145,25 @@ public class FaweDelegateRegionManager {
if (hybridPlotWorld.PLOT_SCHEMATIC) {
// We cannot reuse the editsession
EditSession scheditsession = !Settings.Schematics.PASTE_ON_TOP ? editSession :
new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
new EditSessionBuilder(world)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
File schematicFile = new File(hybridPlotWorld.getRoot(), "plot.schem");
if (!schematicFile.exists()) {
schematicFile = new File(hybridPlotWorld.getRoot(), "plot.schematic");
}
BlockVector3 to = plot.getBottomAbs().getBlockVector3().withY(Settings.Schematics.PASTE_ON_TOP ? hybridPlotWorld.SCHEM_Y : 1);
BlockVector3 to = plot.getBottomAbs().getBlockVector3().withY(Settings.Schematics.PASTE_ON_TOP
? hybridPlotWorld.SCHEM_Y
: 1);
try {
Clipboard clip = ClipboardFormats.findByFile(schematicFile).getReader(new FileInputStream(schematicFile)).read();
Clipboard clip = ClipboardFormats
.findByFile(schematicFile)
.getReader(new FileInputStream(schematicFile))
.read();
clip.paste(scheditsession, to, true, true, true);
} catch (IOException e) {
e.printStackTrace();
@ -142,28 +174,49 @@ public class FaweDelegateRegionManager {
// Be verbose in editsession flushing
editSession.flushQueue();
FaweAPI.fixLighting(world, new CuboidRegion(plot.getBottomAbs().getBlockVector3(), plot.getTopAbs().getBlockVector3()), null,
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE));
FaweAPI.fixLighting(
world,
new CuboidRegion(plot.getBottomAbs().getBlockVector3(), plot.getTopAbs().getBlockVector3()),
null,
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE)
);
TaskManager.IMP.task(whenDone);
}
});
return true;
}
public void swap(Location pos1,
Location pos2,
Location swapPos,
final Runnable whenDone) {
public void swap(
Location pos1,
Location pos2,
Location swapPos,
final Runnable whenDone
) {
TaskManager.IMP.async(() -> {
synchronized (FaweDelegateRegionManager.class) {
//todo because of the following code this should proably be in the Bukkit module
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorldName()));
World pos3World = BukkitAdapter.adapt(getWorld(swapPos.getWorldName()));
WorldEdit.getInstance().getEditSessionFactory().getEditSession(pos1World, -1);
EditSession sessionA = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession sessionB = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession sessionA = new EditSessionBuilder(pos1World)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
EditSession sessionB = new EditSessionBuilder(pos3World)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
CuboidRegion regionA = new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3());
CuboidRegion regionB = new CuboidRegion(swapPos.getBlockVector3(), swapPos.getBlockVector3().add(pos2.getBlockVector3()).subtract(pos1.getBlockVector3()));
CuboidRegion regionB = new CuboidRegion(
swapPos.getBlockVector3(),
swapPos.getBlockVector3().add(pos2.getBlockVector3()).subtract(pos1.getBlockVector3())
);
regionA.setWorld(pos1World);
regionB.setWorld(pos3World);
Clipboard clipA = Clipboard.create(regionA, UUID.randomUUID());
@ -181,10 +234,18 @@ public class FaweDelegateRegionManager {
e.printStackTrace();
}
FaweAPI.fixLighting(pos1World, new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()), null,
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE));
FaweAPI.fixLighting(pos1World, new CuboidRegion(swapPos.getBlockVector3(),
BlockVector3.at(swapPos.getX() + pos2.getX() - pos1.getX(), 0, swapPos.getZ() + pos2.getZ() - pos1.getZ())), null,
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE));
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE)
);
FaweAPI.fixLighting(pos1World, new CuboidRegion(
swapPos.getBlockVector3(),
BlockVector3.at(
swapPos.getX() + pos2.getX() - pos1.getX(),
0,
swapPos.getZ() + pos2.getZ() - pos1.getZ()
)
), null,
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE)
);
TaskManager.IMP.task(whenDone);
}
});
@ -195,7 +256,13 @@ public class FaweDelegateRegionManager {
region.expand(BlockVector3.at(-extendBiome, 0, -extendBiome));
TaskManager.IMP.async(() -> {
synchronized (FaweDelegateRegionManager.class) {
EditSession editSession = new EditSessionBuilder(BukkitAdapter.adapt(getWorld(world))).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession editSession = new EditSessionBuilder(BukkitAdapter.adapt(getWorld(world)))
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
FlatRegionFunction replace = new BiomeReplace(editSession, biome);
FlatRegionVisitor visitor = new FlatRegionVisitor(region, replace);
try {
@ -209,24 +276,50 @@ public class FaweDelegateRegionManager {
});
}
public boolean copyRegion(final @NonNull Location pos1,
final @NonNull Location pos2,
final @NonNull Location pos3,
final @NonNull Runnable whenDone) {
public boolean copyRegion(
final @NonNull Location pos1,
final @NonNull Location pos2,
final @NonNull Location pos3,
final @NonNull Runnable whenDone
) {
TaskManager.IMP.async(() -> {
synchronized (FaweDelegateRegionManager.class) {
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorldName()));
World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorldName()));
EditSession from = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession to = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()));
EditSession from = new EditSessionBuilder(pos1World)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
EditSession to = new EditSessionBuilder(pos3World)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
CuboidRegion region = new CuboidRegion(
BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()),
BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())
);
ForwardExtentCopy copy = new ForwardExtentCopy(
from,
region,
to,
BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ())
);
try {
Operations.completeLegacy(copy);
to.flushQueue();
FaweAPI.fixLighting(pos1World,
new CuboidRegion(pos3.getBlockVector3(), pos3.getBlockVector3().add(pos2.getBlockVector3().subtract(pos1.getBlockVector3()))),
null, RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE));
new CuboidRegion(
pos3.getBlockVector3(),
pos3.getBlockVector3().add(pos2.getBlockVector3().subtract(pos1.getBlockVector3()))
),
null, RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.IMP.LIGHTING.MODE)
);
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
@ -240,8 +333,17 @@ public class FaweDelegateRegionManager {
TaskManager.IMP.async(() -> {
synchronized (FaweDelegateRegionManager.class) {
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorldName()));
try (EditSession editSession = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) {
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
try (EditSession editSession = new EditSessionBuilder(pos1World)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build()) {
CuboidRegion region = new CuboidRegion(
BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()),
BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())
);
editSession.regenerate(region);
editSession.flushQueue();
}
@ -250,4 +352,5 @@ public class FaweDelegateRegionManager {
});
return true;
}
}

View File

@ -3,6 +3,10 @@ package com.fastasyncworldedit.bukkit.regions.plotsquared;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader;
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriter;
import com.fastasyncworldedit.core.jnbt.CompressedCompoundTag;
import com.fastasyncworldedit.core.jnbt.CompressedSchematicTag;
import com.fastasyncworldedit.core.util.EditSessionBuilder;
import com.fastasyncworldedit.core.util.IOUtil;
import com.plotsquared.core.PlotSquared;
@ -15,16 +19,12 @@ import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.jnbt.CompoundTag;
import com.fastasyncworldedit.core.jnbt.CompressedCompoundTag;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.Tag;
import com.fastasyncworldedit.core.jnbt.CompressedSchematicTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader;
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriter;
import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
@ -33,8 +33,8 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import net.jpountz.lz4.LZ4BlockInputStream;
import org.anarres.parallelgzip.ParallelGZIPOutputStream;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.EOFException;
@ -56,13 +56,15 @@ public class FaweDelegateSchematicHandler {
private static final AtomicBoolean exportingAll = new AtomicBoolean();
public void paste(final Schematic schematic,
final Plot plot,
final int xOffset,
final int yOffset,
final int zOffset,
final boolean autoHeight,
final RunnableVal<Boolean> whenDone) {
public void paste(
final Schematic schematic,
final Plot plot,
final int xOffset,
final int yOffset,
final int zOffset,
final boolean autoHeight,
final RunnableVal<Boolean> whenDone
) {
Runnable r = () -> {
if (whenDone != null) {
whenDone.value = false;
@ -78,8 +80,8 @@ public class FaweDelegateSchematicHandler {
// Validate dimensions
CuboidRegion region = plot.getLargestRegion();
if (((region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + xOffset + 1) < WIDTH) || (
(region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT
> 256)) {
(region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT
> 256)) {
TaskManager.runTask(whenDone);
return;
}
@ -94,8 +96,9 @@ public class FaweDelegateSchematicHandler {
y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
} else {
y_offset_actual = yOffset + 1 + PlotSquared.platform().worldUtil()
.getHighestBlockSynchronous(plot.getWorldName(), region.getMinimumPoint().getX() + 1,
region.getMinimumPoint().getZ() + 1);
.getHighestBlockSynchronous(plot.getWorldName(), region.getMinimumPoint().getX() + 1,
region.getMinimumPoint().getZ() + 1
);
}
}
} else {
@ -103,10 +106,10 @@ public class FaweDelegateSchematicHandler {
}
final BlockVector3 to = BlockVector3
.at(region.getMinimumPoint().getX() + xOffset, y_offset_actual, region.getMinimumPoint().getZ() + zOffset);
.at(region.getMinimumPoint().getX() + xOffset, y_offset_actual, region.getMinimumPoint().getZ() + zOffset);
try (EditSession editSession = new EditSessionBuilder(FaweAPI.getWorld(plot.getWorldName())).checkMemory(false)
.fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) {
.fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) {
final Clipboard clipboard = schematic.getClipboard();
clipboard.paste(editSession, to, true, false, true);
if (whenDone != null) {
@ -135,20 +138,20 @@ public class FaweDelegateSchematicHandler {
if (cTag instanceof CompressedSchematicTag) {
Clipboard clipboard = (Clipboard) cTag.getSource();
try (OutputStream stream = new FileOutputStream(tmp);
NBTOutputStream output = new NBTOutputStream(
new BufferedOutputStream(new ParallelGZIPOutputStream(stream)))) {
NBTOutputStream output = new NBTOutputStream(
new BufferedOutputStream(new ParallelGZIPOutputStream(stream)))) {
new FastSchematicWriter(output).write(clipboard);
}
} else {
try (OutputStream stream = new FileOutputStream(tmp);
BufferedOutputStream output = new BufferedOutputStream(new ParallelGZIPOutputStream(stream))) {
BufferedOutputStream output = new BufferedOutputStream(new ParallelGZIPOutputStream(stream))) {
LZ4BlockInputStream is = cTag.adapt(cTag.getSource());
IOUtil.copy(is, output);
}
}
} else {
try (OutputStream stream = new FileOutputStream(tmp);
NBTOutputStream output = new NBTOutputStream(new ParallelGZIPOutputStream(stream))) {
NBTOutputStream output = new NBTOutputStream(new ParallelGZIPOutputStream(stream))) {
Map<String, Tag> map = tag.getValue();
output.writeNamedTag("Schematic", map.getOrDefault("Schematic", tag));
}
@ -193,7 +196,7 @@ public class FaweDelegateSchematicHandler {
public Schematic getSchematic(@Nonnull InputStream is) {
try {
FastSchematicReader schematicReader = new FastSchematicReader(
new NBTInputStream(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(is)))));
new NBTInputStream(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(is)))));
Clipboard clip = schematicReader.read();
return new Schematic(clip);
} catch (IOException e) {
@ -203,7 +206,7 @@ public class FaweDelegateSchematicHandler {
}
try {
SpongeSchematicReader schematicReader =
new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is)));
new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is)));
Clipboard clip = schematicReader.read();
return new Schematic(clip);
} catch (IOException e2) {
@ -213,17 +216,18 @@ public class FaweDelegateSchematicHandler {
}
try {
MCEditSchematicReader schematicReader =
new MCEditSchematicReader(new NBTInputStream(new GZIPInputStream(is)));
new MCEditSchematicReader(new NBTInputStream(new GZIPInputStream(is)));
Clipboard clip = schematicReader.read();
return new Schematic(clip);
} catch (IOException e3) {
e.printStackTrace();
LOGGER.warn(
is + " | " + is.getClass().getCanonicalName() + " is not in GZIP format : " + e
.getMessage());
is + " | " + is.getClass().getCanonicalName() + " is not in GZIP format : " + e
.getMessage());
}
}
}
return null;
}
}

View File

@ -2,6 +2,7 @@ package com.fastasyncworldedit.bukkit.regions.plotsquared;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.fastasyncworldedit.core.queue.IQueueChunk;
import com.fastasyncworldedit.core.queue.IQueueExtent;
import com.plotsquared.core.queue.LightingMode;
@ -12,15 +13,14 @@ import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
@ -29,7 +29,7 @@ public class FaweQueueCoordinator extends QueueCoordinator {
public final IQueueExtent<IQueueChunk> instance;
private final World world;
private BlockVector3 mutable = new MutableBlockVector3();
private final BlockVector3 mutable = new MutableBlockVector3();
private boolean setbiome = false;
public FaweQueueCoordinator(World world) {
@ -202,4 +202,5 @@ public class FaweQueueCoordinator extends QueueCoordinator {
public boolean isSettingTiles() {
return false;
}
}

View File

@ -12,10 +12,10 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
@CommandDeclaration(command = "trimchunks",
permission = "plots.admin",
description = "Delete unmodified portions of your plotworld",
requiredType = RequiredType.PLAYER,
category = CommandCategory.ADMINISTRATION)
permission = "plots.admin",
description = "Delete unmodified portions of your plotworld",
requiredType = RequiredType.PLAYER,
category = CommandCategory.ADMINISTRATION)
public class FaweTrim extends SubCommand {
private boolean ran = false;
@ -28,7 +28,7 @@ public class FaweTrim extends SubCommand {
}
if (strings.length != 2) {
plotPlayer.sendMessage(StaticCaption
.of("First make a backup of your world called <world-copy> then stand in the middle of an empty plot"));
.of("First make a backup of your world called <world-copy> then stand in the middle of an empty plot"));
plotPlayer.sendMessage(StaticCaption.of("use /plot trimall <world> <boolean-delete-unowned>"));
return false;
}
@ -52,4 +52,5 @@ public class FaweTrim extends SubCommand {
});
return true;
}
}

View File

@ -11,6 +11,7 @@ import java.util.ArrayList;
import static com.google.common.base.Preconditions.checkNotNull;
public class PlotRegionFilter extends CuboidRegionFilter {
private final PlotArea area;
public PlotRegionFilter(PlotArea area) {
@ -27,4 +28,5 @@ public class PlotRegionFilter extends CuboidRegionFilter {
add(BlockVector2.at(bottom.getX(), bottom.getZ()), BlockVector2.at(top.getX(), top.getZ()));
}
}
}

View File

@ -35,43 +35,53 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
@CommandDeclaration(command = "generatebiome",
permission = "plots.generatebiome",
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.PLAYER,
description = "Generate a biome in your plot",
aliases = {"bg", "gb"},
usage = "/plots generatebiome <biome>")
permission = "plots.generatebiome",
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.PLAYER,
description = "Generate a biome in your plot",
aliases = {"bg", "gb"},
usage = "/plots generatebiome <biome>")
public class PlotSetBiome extends Command {
public PlotSetBiome() {
super(MainCommand.getInstance(), true);
}
@Override
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player,
String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
public CompletableFuture<Boolean> execute(
final PlotPlayer<?> player,
String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone
) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.generatebiome"),
TranslatableCaption.of("permission.no_plot_perms"));
checkTrue(
plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.generatebiome"),
TranslatableCaption.of("permission.no_plot_perms")
);
if (plot.getRunning() != 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
return null;
}
checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", getUsage()));
Templates.of("value", getUsage())
);
final Set<CuboidRegion> regions = plot.getRegions();
BiomeRegistry biomeRegistry =
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries()
.getBiomeRegistry();
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries()
.getBiomeRegistry();
Collection<BiomeType> knownBiomes = BiomeTypes.values();
final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
if (biome == null) {
String biomes = StringMan.join(BiomeType.REGISTRY.values(),
TranslatableCaption.of("blocklist.block_list_separator").getComponent(player));
String biomes = StringMan.join(
BiomeType.REGISTRY.values(),
TranslatableCaption.of("blocklist.block_list_separator").getComponent(player)
);
player.sendMessage(TranslatableCaption.of("biome.need_biome"));
player.sendMessage(TranslatableCaption.of("commandconfig.subcommand_set_options_header"),
Templates.of("values", biomes));
player.sendMessage(
TranslatableCaption.of("commandconfig.subcommand_set_options_header"),
Templates.of("values", biomes)
);
return CompletableFuture.completedFuture(false);
}
confirm.run(this, () -> {
@ -82,9 +92,9 @@ public class PlotSetBiome extends Command {
plot.addRunning();
TaskManager.IMP.async(() -> {
EditSession session =
new EditSessionBuilder(BukkitAdapter.adapt(Bukkit.getWorld(plot.getArea().getWorldName())))
.autoQueue(false).checkMemory(false).allowedRegionsEverywhere()
.player(BukkitAdapter.adapt(Bukkit.getPlayer(player.getUUID()))).limitUnlimited().build();
new EditSessionBuilder(BukkitAdapter.adapt(Bukkit.getWorld(plot.getArea().getWorldName())))
.autoQueue(false).checkMemory(false).allowedRegionsEverywhere()
.player(BukkitAdapter.adapt(Bukkit.getPlayer(player.getUUID()))).limitUnlimited().build();
long seed = ThreadLocalRandom.current().nextLong();
for (CuboidRegion region : regions) {
session.regenerate(region, biome, seed);
@ -105,4 +115,5 @@ public class PlotSetBiome extends Command {
.map(value -> new Command(null, false, value, "", RequiredType.PLAYER, null) {
}).collect(Collectors.toList());
}
}

View File

@ -69,9 +69,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
}
UUID uid = player.getUniqueId();
return !plot.getFlag(NoWorldeditFlag.class) && (plot.isOwner(uid) || type == MaskType.MEMBER && (
plot.getTrusted().contains(uid) || plot.getTrusted().contains(DBFunc.EVERYONE)
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) && player
.hasPermission("fawe.plotsquared.member")) || player.hasPermission("fawe.plotsquared.admin"));
plot.getTrusted().contains(uid) || plot.getTrusted().contains(DBFunc.EVERYONE)
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) && player
.hasPermission("fawe.plotsquared.member")) || player.hasPermission("fawe.plotsquared.admin"));
}
@Override
@ -90,7 +90,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
if (regions.size() == 1) {
CuboidRegion region = regions.iterator().next();
if (region.getMinimumPoint().getX() == Integer.MIN_VALUE
&& region.getMaximumPoint().getX() == Integer.MAX_VALUE) {
&& region.getMaximumPoint().getX() == Integer.MAX_VALUE) {
regions.clear();
}
}
@ -116,8 +116,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
} else {
World world = FaweAPI.getWorld(area.getWorldName());
List<Region> weRegions = regions.stream().map(
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()),
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ()))).collect(Collectors.toList());
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()),
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ())
)).collect(Collectors.toList());
maskedRegion = new RegionIntersection(world, weRegions);
}
@ -140,4 +141,5 @@ public class PlotSquaredFeature extends FaweMaskManager {
}
return null;
}
}

View File

@ -23,7 +23,7 @@ import static org.bukkit.Bukkit.getWorld;
public class FaweChunkManager extends ChunkManager {
private ChunkManager parent;
private final ChunkManager parent;
public FaweChunkManager(ChunkManager parent) {
this.parent = parent;
@ -50,7 +50,13 @@ public class FaweChunkManager extends ChunkManager {
}
@Override
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
public void swap(
final Location pos1,
final Location pos2,
final Location pos3,
final Location pos4,
final Runnable whenDone
) {
if (!Settings.IMP.PLOTSQUARED_INTEGRATION.COPY_AND_SWAP) {
parent.swap(pos1, pos2, pos3, pos4, whenDone);
}
@ -60,11 +66,29 @@ public class FaweChunkManager extends ChunkManager {
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld()));
WorldEdit.getInstance().getEditSessionFactory().getEditSession(
pos1World,-1);
EditSession sessionA = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession sessionB = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
CuboidRegion regionB = new CuboidRegion(BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()), BlockVector3.at(pos4.getX(), pos4.getY(), pos4.getZ()));
pos1World, -1);
EditSession sessionA = new EditSessionBuilder(pos1World)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
EditSession sessionB = new EditSessionBuilder(pos3World)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
CuboidRegion regionA = new CuboidRegion(
BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()),
BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())
);
CuboidRegion regionB = new CuboidRegion(
BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()),
BlockVector3.at(pos4.getX(), pos4.getY(), pos4.getZ())
);
ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint());
ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, sessionA, regionA.getMinimumPoint());
try {
@ -89,10 +113,30 @@ public class FaweChunkManager extends ChunkManager {
synchronized (FaweChunkManager.class) {
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld()));
EditSession from = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession to = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()));
EditSession from = new EditSessionBuilder(pos1World)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
EditSession to = new EditSessionBuilder(pos3World)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
CuboidRegion region = new CuboidRegion(
BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()),
BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())
);
ForwardExtentCopy copy = new ForwardExtentCopy(
from,
region,
to,
BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ())
);
try {
Operations.completeLegacy(copy);
to.flushQueue();
@ -111,10 +155,11 @@ public class FaweChunkManager extends ChunkManager {
synchronized (FaweChunkManager.class) {
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
try (EditSession editSession = new EditSessionBuilder(pos1World).checkMemory(false)
.fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) {
.fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) {
CuboidRegion region = new CuboidRegion(
BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()),
BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()),
BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())
);
editSession.regenerate(region);
editSession.flushQueue();
}
@ -123,4 +168,5 @@ public class FaweChunkManager extends ChunkManager {
});
return true;
}
}

View File

@ -3,13 +3,13 @@ package com.fastasyncworldedit.bukkit.regions.plotsquaredv4;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.fastasyncworldedit.core.queue.IQueueChunk;
import com.fastasyncworldedit.core.queue.IQueueExtent;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
@ -20,7 +20,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
public final IQueueExtent<IQueueChunk> instance;
private final World world;
private BlockVector3 mutable = new MutableBlockVector3();
private final BlockVector3 mutable = new MutableBlockVector3();
public FaweLocalBlockQueue(String worldName) {
super(worldName);
@ -127,4 +127,5 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
instance.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.IMP.asTag(tag));
return true;
}
}

View File

@ -3,6 +3,9 @@ package com.fastasyncworldedit.bukkit.regions.plotsquaredv4;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard;
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriter;
import com.fastasyncworldedit.core.jnbt.CompressedCompoundTag;
import com.fastasyncworldedit.core.jnbt.CompressedSchematicTag;
import com.fastasyncworldedit.core.util.EditSessionBuilder;
import com.fastasyncworldedit.core.util.IOUtil;
import com.fastasyncworldedit.core.util.TaskManager;
@ -13,8 +16,6 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.sk89q.jnbt.CompoundTag;
import com.fastasyncworldedit.core.jnbt.CompressedCompoundTag;
import com.fastasyncworldedit.core.jnbt.CompressedSchematicTag;
import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.EditSession;
@ -22,7 +23,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
@ -43,6 +43,7 @@ import java.util.UUID;
import static org.bukkit.Bukkit.getWorld;
public class FaweSchematicHandler extends SchematicHandler {
@Override
public boolean restoreTile(LocalBlockQueue queue, CompoundTag compoundTag, int x, int y, int z) {
if (queue instanceof FaweLocalBlockQueue) {
@ -59,8 +60,17 @@ public class FaweSchematicHandler extends SchematicHandler {
Location pos1 = corners[0];
Location pos2 = corners[1];
World adaptedWorld = BukkitAdapter.adapt(getWorld(world));
final CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ()));
final EditSession editSession = new EditSessionBuilder(adaptedWorld).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
final CuboidRegion region = new CuboidRegion(
BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()),
BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())
);
final EditSession editSession = new EditSessionBuilder(adaptedWorld)
.checkMemory(false)
.fastmode(true)
.limitUnlimited()
.changeSetNull()
.autoQueue(false)
.build();
ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region, false, true);
@ -84,17 +94,20 @@ public class FaweSchematicHandler extends SchematicHandler {
CompressedCompoundTag cTag = (CompressedCompoundTag) tag;
if (cTag instanceof CompressedSchematicTag) {
Clipboard clipboard = (Clipboard) cTag.getSource();
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new BufferedOutputStream(new ParallelGZIPOutputStream(stream)))) {
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new BufferedOutputStream(
new ParallelGZIPOutputStream(stream)))) {
new FastSchematicWriter(output).write(clipboard);
}
} else {
try (OutputStream stream = new FileOutputStream(tmp); BufferedOutputStream output = new BufferedOutputStream(new ParallelGZIPOutputStream(stream))) {
try (OutputStream stream = new FileOutputStream(tmp); BufferedOutputStream output = new BufferedOutputStream(
new ParallelGZIPOutputStream(stream))) {
LZ4BlockInputStream is = cTag.adapt(cTag.getSource());
IOUtil.copy(is, stream);
}
}
} else {
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new ParallelGZIPOutputStream(stream))) {
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new ParallelGZIPOutputStream(
stream))) {
Map<String, Tag> map = tag.getValue();
output.writeNamedTag("Schematic", map.getOrDefault("Schematic", tag));
}
@ -138,4 +151,5 @@ public class FaweSchematicHandler extends SchematicHandler {
}
}, whenDone);
}
}

View File

@ -26,7 +26,8 @@ public class FaweTrim extends SubCommand {
return false;
}
if (strings.length != 2) {
plotPlayer.sendMessage("First make a backup of your world called <world-copy> then stand in the middle of an empty plot");
plotPlayer.sendMessage(
"First make a backup of your world called <world-copy> then stand in the middle of an empty plot");
plotPlayer.sendMessage("use /plot trimall <world> <boolean-delete-unowned>");
return false;
}
@ -53,4 +54,5 @@ public class FaweTrim extends SubCommand {
});
return true;
}
}

View File

@ -11,6 +11,7 @@ import java.util.ArrayList;
import static com.google.common.base.Preconditions.checkNotNull;
public class PlotRegionFilter extends CuboidRegionFilter {
private final PlotArea area;
public PlotRegionFilter(PlotArea area) {
@ -27,4 +28,5 @@ public class PlotRegionFilter extends CuboidRegionFilter {
add(BlockVector2.at(bottom.getX(), bottom.getZ()), BlockVector2.at(top.getX(), top.getZ()));
}
}
}

View File

@ -24,11 +24,12 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import org.bukkit.Bukkit;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Bukkit;
@CommandDeclaration(
command = "generatebiome",
@ -40,29 +41,40 @@ import org.bukkit.Bukkit;
usage = "/plots generatebiome <biome>"
)
public class PlotSetBiome extends Command {
public PlotSetBiome() {
super(MainCommand.getInstance(), true);
}
@Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
public CompletableFuture<Boolean> execute(
final PlotPlayer player,
String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone
) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.admin.command.generatebiome"), Captions.NO_PLOT_PERMS);
.hasPermission(player, "plots.admin.command.generatebiome"), Captions.NO_PLOT_PERMS);
if (plot.getRunning() != 0) {
Captions.WAIT_FOR_TIMER.send(player);
return null;
}
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
final Set<CuboidRegion> regions = plot.getRegions();
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
BiomeRegistry biomeRegistry = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.GAME_HOOKS)
.getRegistries()
.getBiomeRegistry();
Collection<BiomeType> knownBiomes = BiomeTypes.values();
final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
if (biome == null) {
String biomes = StringMan
.join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated());
Captions.NEED_BIOME.send(player);
MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.toString() + biomes);
MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER + biomes);
return CompletableFuture.completedFuture(false);
}
confirm.run(this, () -> {
@ -90,4 +102,5 @@ public class PlotSetBiome extends Command {
return CompletableFuture.completedFuture(true);
}
}

View File

@ -1,9 +1,9 @@
package com.fastasyncworldedit.bukkit.regions.plotsquaredv4;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.fastasyncworldedit.core.regions.FaweMask;
import com.fastasyncworldedit.core.regions.FaweMaskManager;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.fastasyncworldedit.core.regions.filter.RegionFilter;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
@ -97,11 +97,11 @@ public class PlotSquaredFeature extends FaweMaskManager {
}
UUID uid = player.getUniqueId();
return !Flags.NO_WORLDEDIT.isTrue(plot) && (plot.isOwner(uid)
|| type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted()
.contains(DBFunc.EVERYONE)
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE))
&& player.hasPermission("fawe.plotsquared.member")) || player
.hasPermission("fawe.plotsquared.admin"));
|| type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted()
.contains(DBFunc.EVERYONE)
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE))
&& player.hasPermission("fawe.plotsquared.member")) || player
.hasPermission("fawe.plotsquared.admin"));
}
@Override
@ -119,7 +119,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
regions = WEManager.getMask(pp);
if (regions.size() == 1) {
CuboidRegion region = regions.iterator().next();
if (region.getMinimumPoint().getX() == Integer.MIN_VALUE && region.getMaximumPoint().getX() == Integer.MAX_VALUE) {
if (region.getMinimumPoint().getX() == Integer.MIN_VALUE && region
.getMaximumPoint()
.getX() == Integer.MAX_VALUE) {
regions.clear();
}
}
@ -132,7 +134,14 @@ public class PlotSquaredFeature extends FaweMaskManager {
int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255;
final HashSet<RegionWrapper> faweRegions = new HashSet<>();
for (CuboidRegion current : regions) {
faweRegions.add(new RegionWrapper(current.getMinimumX(), current.getMaximumX(), min, max, current.getMinimumZ(), current.getMaximumZ()));
faweRegions.add(new RegionWrapper(
current.getMinimumX(),
current.getMaximumX(),
min,
max,
current.getMinimumZ(),
current.getMaximumZ()
));
}
final CuboidRegion region = regions.iterator().next();
final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
@ -148,8 +157,12 @@ public class PlotSquaredFeature extends FaweMaskManager {
} else {
World world = FaweAPI.getWorld(area.worldname);
List<Region> weRegions = regions.stream()
.map(r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()), BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ())))
.collect(Collectors.toList());
.map(r -> new CuboidRegion(
world,
BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()),
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ())
))
.collect(Collectors.toList());
maskedRegion = new RegionIntersection(world, weRegions);
}
@ -172,4 +185,5 @@ public class PlotSquaredFeature extends FaweMaskManager {
}
return null;
}
}

View File

@ -1,8 +1,7 @@
package com.fastasyncworldedit.bukkit.util;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.bukkit.FaweBukkit;
import com.fastasyncworldedit.bukkit.util.ItemUtil;
import com.fastasyncworldedit.core.Fawe;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -12,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
import javax.annotation.Nullable;
public class BukkitItemStack extends BaseItemStack {
private ItemStack stack;
private Object nativeItem;
private boolean loadedNBT;
@ -75,4 +75,5 @@ public class BukkitItemStack extends BaseItemStack {
}
super.setNbtData(nbtData);
}
}

View File

@ -7,6 +7,7 @@ import org.bukkit.Server;
import java.lang.reflect.Method;
public class BukkitReflectionUtils {
/**
* Prefix of Bukkit classes.
*/
@ -55,4 +56,5 @@ public class BukkitReflectionUtils {
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
return packageName.substring(packageName.lastIndexOf('.') + 1);
}
}

View File

@ -4,6 +4,7 @@ import com.fastasyncworldedit.core.util.TaskManager;
import org.apache.commons.lang.mutable.MutableInt;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import javax.annotation.Nonnull;
public class BukkitTaskManager extends TaskManager {
@ -52,4 +53,5 @@ public class BukkitTaskManager extends TaskManager {
Bukkit.getScheduler().cancelTask(task);
}
}
}

View File

@ -1,7 +1,6 @@
package com.fastasyncworldedit.bukkit.util;
import com.fastasyncworldedit.core.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
@ -39,7 +38,10 @@ public class ItemUtil {
this.fieldHandle = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredField("handle"));
Class<?> classNBTTagCompound = BukkitReflectionUtils.getNmsClass("NBTTagCompound");
this.methodSetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("setTag", classNBTTagCompound));
this.methodAsBukkitCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asBukkitCopy", classNMSItem));
this.methodAsBukkitCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod(
"asBukkitCopy",
classNMSItem
));
}
public Object getNMSItem(ItemStack item) {
@ -56,7 +58,6 @@ public class ItemUtil {
}
public CompoundTag getNBT(ItemStack item) {
try {
if (!item.hasItemMeta()) {
@ -113,4 +114,5 @@ public class ItemUtil {
}
return null;
}
}

View File

@ -2,6 +2,7 @@ package com.fastasyncworldedit.bukkit.util;
import com.google.common.collect.ComparisonChain;
import org.bukkit.Bukkit;
import javax.annotation.Nonnull;
/**
@ -119,19 +120,28 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MinecraftVersion that = (MinecraftVersion) o;
if (getMajor() != that.getMajor()) return false;
if (getMinor() != that.getMinor()) return false;
if (getMajor() != that.getMajor()) {
return false;
}
if (getMinor() != that.getMinor()) {
return false;
}
return getRelease() == that.getRelease();
}
/**
* Determines the server version based on the package path, e.g. {@code org.bukkit.craftbukkit.v1_16_R3},
* where v1_16_R3 is the resolved version.
* where v1_16_R3 is the resolved version. Note: as of Minecraft 1.17, NMS is no longer versioned thus this
* method may have poor results.
*
* @return The package version.
*/

View File

@ -5,15 +5,17 @@ import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultUtil {
public final Permission permission;
public VaultUtil() {
final RegisteredServiceProvider<Permission> permissionProvider =
Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
if (permissionProvider != null) {
this.permission = permissionProvider.getProvider();
} else {
this.permission = null;
}
}
}

View File

@ -14,4 +14,5 @@ public class WorldUnloadedException extends WorldEditException {
public WorldUnloadedException() {
super(Caption.of("worldedit.error.world-unloaded"));
}
}

View File

@ -20,13 +20,14 @@ import org.inventivetalent.mapmanager.controller.MultiMapController;
import org.inventivetalent.mapmanager.manager.MapManager;
import org.inventivetalent.mapmanager.wrapper.MapWrapper;
import javax.annotation.Nullable;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Collection;
import javax.annotation.Nullable;
public class BukkitImageViewer implements ImageViewer {
private final MapManager mapManager;
private final Player player;
private BufferedImage last;
@ -148,7 +149,13 @@ public class BukkitImageViewer implements ImageViewer {
last = image;
int width = frames.length;
int height = frames[0].length;
BufferedImage scaled = ImageUtil.getScaledInstance(image, 128 * width, 128 * height, RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
BufferedImage scaled = ImageUtil.getScaledInstance(
image,
128 * width,
128 * height,
RenderingHints.VALUE_INTERPOLATION_BILINEAR,
false
);
MapWrapper mapWrapper = mapManager.wrapMultiImage(scaled, width, height);
MultiMapController controller = (MultiMapController) mapWrapper.getController();
controller.addViewer(player);
@ -169,7 +176,13 @@ public class BukkitImageViewer implements ImageViewer {
image = drawable.draw();
}
last = image;
BufferedImage scaled = ImageUtil.getScaledInstance(image, 128, 128, RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
BufferedImage scaled = ImageUtil.getScaledInstance(
image,
128,
128,
RenderingHints.VALUE_INTERPOLATION_BILINEAR,
false
);
MapWrapper mapWrapper = mapManager.wrapImage(scaled);
MapController controller = mapWrapper.getController();
controller.addViewer(player);
@ -199,4 +212,5 @@ public class BukkitImageViewer implements ImageViewer {
public void close() throws IOException {
last = null;
}
}