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

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>
Dieser Commit ist enthalten in:
dordsor21 2021-07-24 16:34:05 +01:00 committet von GitHub
Ursprung 3b4beba7d6
Commit 8c0195970b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
1143 geänderte Dateien mit 143599 neuen und 9952 gelöschten Zeilen

1013
.editorconfig Normale Datei

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

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

Datei anzeigen

@ -1,29 +1,27 @@
package com.fastasyncworldedit.bukkit; 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.BukkitQueueHandler;
import com.fastasyncworldedit.bukkit.adapter.NMSAdapter; import com.fastasyncworldedit.bukkit.adapter.NMSAdapter;
import com.fastasyncworldedit.bukkit.listener.BrushListener; import com.fastasyncworldedit.bukkit.listener.BrushListener;
import com.fastasyncworldedit.bukkit.listener.ChunkListener9; import com.fastasyncworldedit.bukkit.listener.ChunkListener9;
import com.fastasyncworldedit.bukkit.listener.RenderListener; import com.fastasyncworldedit.bukkit.listener.RenderListener;
import com.fastasyncworldedit.bukkit.regions.GriefPreventionFeature;
import com.fastasyncworldedit.bukkit.regions.GriefDefenderFeature; import com.fastasyncworldedit.bukkit.regions.GriefDefenderFeature;
import com.fastasyncworldedit.bukkit.regions.GriefPreventionFeature;
import com.fastasyncworldedit.bukkit.regions.ResidenceFeature; import com.fastasyncworldedit.bukkit.regions.ResidenceFeature;
import com.fastasyncworldedit.bukkit.regions.TownyFeature; import com.fastasyncworldedit.bukkit.regions.TownyFeature;
import com.fastasyncworldedit.bukkit.regions.WorldGuardFeature; import com.fastasyncworldedit.bukkit.regions.WorldGuardFeature;
import com.fastasyncworldedit.bukkit.util.BukkitTaskManager; import com.fastasyncworldedit.bukkit.util.BukkitTaskManager;
import com.fastasyncworldedit.bukkit.util.ItemUtil; import com.fastasyncworldedit.bukkit.util.ItemUtil;
import com.fastasyncworldedit.bukkit.util.MinecraftVersion; 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.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.regions.FaweMaskManager;
import com.fastasyncworldedit.core.util.ThirdPartyManager;
import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.TaskManager;
import com.fastasyncworldedit.core.util.WEManager; import com.fastasyncworldedit.core.util.WEManager;
import com.fastasyncworldedit.core.util.image.ImageViewer; import com.fastasyncworldedit.core.util.image.ImageViewer;
@ -44,7 +42,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
@ -101,7 +98,8 @@ public class FaweBukkit implements IFawe, Listener {
}); });
} }
@Override public QueueHandler getQueueHandler() { @Override
public QueueHandler getQueueHandler() {
return new BukkitQueueHandler(); return new BukkitQueueHandler();
} }
@ -112,20 +110,12 @@ public class FaweBukkit implements IFawe, Listener {
PluginManager manager = Bukkit.getPluginManager(); PluginManager manager = Bukkit.getPluginManager();
if (manager.getPlugin("PacketListenerApi") == null) { if (manager.getPlugin("PacketListenerApi") == null) {
File output = new File(plugin.getDataFolder().getParentFile(), LOGGER.error("PacketListener not found! Please install PacketListenerAPI v3.7.6 or above before attempting to " +
"PacketListenerAPI_v3.7.6-SNAPSHOT.jar"); "complete image-related edits");
byte[] jarData = ThirdPartyManager.PacketListenerAPI.download();
try (FileOutputStream fos = new FileOutputStream(output)) {
fos.write(jarData);
}
} }
if (manager.getPlugin("MapManager") == null) { if (manager.getPlugin("MapManager") == null) {
File output = new File(plugin.getDataFolder().getParentFile(), LOGGER.error("MapManager not found! Please install PacketListenerAPI v1.7.8 or above before attempting to " +
"MapManager_v1.7.8-SNAPSHOT.jar"); "complete image-related edits");
byte[] jarData = ThirdPartyManager.MapManager.download();
try (FileOutputStream fos = new FileOutputStream(output)) {
fos.write(jarData);
}
} }
return new BukkitImageViewer(BukkitAdapter.adapt(player)); return new BukkitImageViewer(BukkitAdapter.adapt(player));
} catch (Throwable ignored) { } catch (Throwable ignored) {
@ -133,7 +123,8 @@ public class FaweBukkit implements IFawe, Listener {
return null; return null;
} }
@Override public File getDirectory() { @Override
public File getDirectory() {
return plugin.getDataFolder(); return plugin.getDataFolder();
} }
@ -151,7 +142,8 @@ public class FaweBukkit implements IFawe, Listener {
return tmp; return tmp;
} }
@Override public String getDebugInfo() { @Override
public String getDebugInfo() {
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins(); Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins();
msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n"); msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n");
@ -173,7 +165,8 @@ public class FaweBukkit implements IFawe, Listener {
/** /**
* The task manager handles sync/async tasks. * The task manager handles sync/async tasks.
*/ */
@Override public TaskManager getTaskManager() { @Override
public TaskManager getTaskManager() {
return new BukkitTaskManager(plugin); return new BukkitTaskManager(plugin);
} }
@ -184,7 +177,8 @@ public class FaweBukkit implements IFawe, Listener {
/** /**
* A mask manager handles region restrictions e.g., PlotSquared plots / WorldGuard regions * 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 = final Plugin worldguardPlugin =
Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"); Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
final ArrayList<FaweMaskManager> managers = new ArrayList<>(); final ArrayList<FaweMaskManager> managers = new ArrayList<>();
@ -259,26 +253,31 @@ public class FaweBukkit implements IFawe, Listener {
wePlayer.unregister(); wePlayer.unregister();
} }
@Override public String getPlatform() { @Override
public String getPlatform() {
return "Bukkit"; return "Bukkit";
} }
@Override public UUID getUUID(String name) { @Override
public UUID getUUID(String name) {
return Bukkit.getOfflinePlayer(name).getUniqueId(); return Bukkit.getOfflinePlayer(name).getUniqueId();
} }
@Override public String getName(UUID uuid) { @Override
public String getName(UUID uuid) {
return Bukkit.getOfflinePlayer(uuid).getName(); return Bukkit.getOfflinePlayer(uuid).getName();
} }
@Override public Preloader getPreloader() { @Override
public Preloader getPreloader() {
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
return new AsyncPreloader(); return new AsyncPreloader();
} }
return null; return null;
} }
@Override public boolean isChunksStretched() { @Override
public boolean isChunksStretched() {
return chunksStretched; return chunksStretched;
} }
@ -302,4 +301,5 @@ public class FaweBukkit implements IFawe, Listener {
LOGGER.error("Incompatible version of PlotSquared found. Please use PlotSquared v6."); LOGGER.error("Incompatible version of PlotSquared found. Please use PlotSquared v6.");
} }
} }
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -1,9 +1,9 @@
package com.fastasyncworldedit.bukkit.adapter; package com.fastasyncworldedit.bukkit.adapter;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.queue.IChunkCache; import com.fastasyncworldedit.core.queue.IChunkCache;
import com.fastasyncworldedit.core.queue.IChunkGet; import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent; import com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.MathMan;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.util.LogManagerCompat; 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.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; 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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
@ -30,11 +33,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.logging.log4j.Logger;
import org.bukkit.generator.BlockPopulator;
/** /**
* Represents an abstract regeneration handler. * Represents an abstract regeneration handler.
*
* @param <IChunkAccess> the type of the {@Code IChunkAccess} of the current Minecraft implementation * @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 <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 <Chunk> the type of the {@Code Chunk} of the current Minecraft implementation
@ -61,6 +62,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/** /**
* Initializes an abstract regeneration handler. * Initializes an abstract regeneration handler.
*
* @param originalBukkitWorld the Bukkit world containing all the information on how to regenerate the {code Region} * @param originalBukkitWorld the Bukkit world containing all the information on how to regenerate the {code Region}
* @param region the selection to regenerate * @param region the selection to regenerate
* @param target the target {@code Extent} to paste the regenerated blocks into * @param target the target {@code Extent} to paste the regenerated blocks into
@ -75,6 +77,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/** /**
* Regenerates the selected {@code Region}. * Regenerates the selected {@code Region}.
*
* @return whether or not the regeneration process was successful * @return whether or not the regeneration process was successful
* @throws Exception when something goes terribly wrong * @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. * Returns the {@code ProtoChunk} at the given chunk coordinates.
*
* @param x the chunk x coordinate * @param x the chunk x coordinate
* @param z the chunk z 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. * @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. * Returns the {@code Chunk} at the given chunk coordinates.
*
* @param x the chunk x coordinate * @param x the chunk x coordinate
* @param z the chunk z 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. * @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.
@ -146,8 +151,9 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
//generate chunk coords lists with a certain radius //generate chunk coords lists with a certain radius
Int2ObjectOpenHashMap<List<Long>> chunkCoordsForRadius = new Int2ObjectOpenHashMap<>(); Int2ObjectOpenHashMap<List<Long>> chunkCoordsForRadius = new Int2ObjectOpenHashMap<>();
chunkStati.keySet().stream().map(ChunkStatusWrapper::requiredNeigborChunkRadius0).distinct().forEach(radius -> { chunkStati.keySet().stream().map(ChunkStatusWrapper::requiredNeigborChunkRadius0).distinct().forEach(radius -> {
if (radius == -1) //ignore ChunkStatus.EMPTY if (radius == -1) { //ignore ChunkStatus.EMPTY
return; 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 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)); 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 //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<>(); Int2ObjectOpenHashMap<Long2ObjectOpenHashMap<List<IChunkAccess>>> worldlimits = new Int2ObjectOpenHashMap<>();
chunkStati.keySet().stream().map(ChunkStatusWrapper::requiredNeigborChunkRadius0).distinct().forEach(radius -> { chunkStati.keySet().stream().map(ChunkStatusWrapper::requiredNeigborChunkRadius0).distinct().forEach(radius -> {
if (radius == -1) //ignore ChunkStatus.EMPTY if (radius == -1) { //ignore ChunkStatus.EMPTY
return; return;
}
Long2ObjectOpenHashMap<List<IChunkAccess>> map = new Long2ObjectOpenHashMap<>(); Long2ObjectOpenHashMap<List<IChunkAccess>> map = new Long2ObjectOpenHashMap<>();
for (Long xz : chunkCoordsForRadius.get(radius)) { for (Long xz : chunkCoordsForRadius.get(radius)) {
int x = MathMan.unpairIntX(xz); int x = MathMan.unpairIntX(xz);
@ -282,6 +289,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
} }
} }
//functions to be implemented by sub class
private void cleanup0() { private void cleanup0() {
if (executor != null) { if (executor != null) {
executor.shutdownNow(); executor.shutdownNow();
@ -289,7 +297,6 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
cleanup(); 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 * <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> * world.</p>
@ -303,7 +310,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/** /**
* Implement the creation of the seperate world in here. * Implement the creation of the seperate world in here.
* * <p>
* Fields required to be initialized: generateConcurrent * 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. * @return true if everything went fine, otherwise false. When false is returned the Regenerator halts the regeneration process and calls the cleanup function.
@ -317,6 +324,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
protected abstract void cleanup(); protected abstract void cleanup();
//functions to implement by sub class - regenate related //functions to implement by sub class - regenate related
/** /**
* Implement the initialization of a {@code ProtoChunk} here. * Implement the initialization of a {@code ProtoChunk} here.
* *
@ -360,6 +368,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
/** /**
* Implement the initialization an {@code IChunkCache<IChunkGet>} here. Use will need the {@code getChunkAt} function * Implement the initialization an {@code IChunkCache<IChunkGet>} here. Use will need the {@code getChunkAt} function
*
* @return an initialized {@code IChunkCache<IChunkGet>} * @return an initialized {@code IChunkCache<IChunkGet>}
*/ */
protected abstract IChunkCache<IChunkGet> initSourceQueueCache(); protected abstract IChunkCache<IChunkGet> initSourceQueueCache();
@ -367,13 +376,23 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
//algorithms //algorithms
private List<Long> getChunkCoordsRegen(Region region, int border) { //needs to be square num of chunks private List<Long> getChunkCoordsRegen(Region region, int border) { //needs to be square num of chunks
BlockVector3 oldMin = region.getMinimumPoint(); 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 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); Region adjustedRegion = new CuboidRegion(newMin, newMax);
return adjustedRegion.getChunks().stream() return adjustedRegion.getChunks().stream()
.map(c -> BlockVector2.at(c.getX(), c.getZ())) .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())) .map(c -> MathMan.pairInt(c.getX(), c.getZ()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@ -385,7 +404,10 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
* @param requiredNeighborChunkRadius the radius of neighbor chunks that may not be written to conccurently (ChunkStatus.requiredNeighborRadius) * @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 * @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 requiredneighbors = Math.max(0, requiredNeighborChunkRadius);
int minx = allcoords.isEmpty() ? 0 : MathMan.unpairIntX(allcoords.get(0)); 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); tasks = new SequentialTasks(numlists);
for (int offset = 0; offset < numlists; offset++) { for (int offset = 0; offset < numlists; offset++) {
ConcurrentTasks<SequentialTasks<Long>> para = new ConcurrentTasks((maxz - minz + 1) / numlists + 1); 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)); para.add(byx.get(minx + i * numlists + offset));
}
tasks.add(para); tasks.add(para);
} }
} else { } else {
@ -437,8 +460,9 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
tasks = new SequentialTasks(numlists); tasks = new SequentialTasks(numlists);
for (int offset = 0; offset < numlists; offset++) { for (int offset = 0; offset < numlists; offset++) {
ConcurrentTasks<SequentialTasks<Long>> para = new ConcurrentTasks((maxx - minx + 1) / numlists + 1); 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)); para.add(byz.get(minz + i * numlists + offset));
}
tasks.add(para); tasks.add(para);
} }
} }
@ -456,8 +480,10 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
} }
//classes //classes
/** /**
* This class is used to wrap the ChunkStatus of the current Minecraft implementation and as the implementation to execute a chunk generation step. * 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 * @param <IChunkAccess> the IChunkAccess class of the current Minecraft implementation
*/ */
public static abstract class ChunkStatusWrapper<IChunkAccess> { public static abstract class ChunkStatusWrapper<IChunkAccess> {
@ -493,9 +519,13 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
try { try {
processChunk(xz, accessibleChunks); processChunk(xz, accessibleChunks);
} catch (Exception e) { } 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 { public enum Concurrency {
@ -509,6 +539,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
public SequentialTasks(int expectedsize) { public SequentialTasks(int expectedsize) {
super(expectedsize); super(expectedsize);
} }
} }
public static class ConcurrentTasks<T> extends Tasks<T> { public static class ConcurrentTasks<T> extends Tasks<T> {
@ -516,6 +547,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
public ConcurrentTasks(int expectedsize) { public ConcurrentTasks(int expectedsize) {
super(expectedsize); super(expectedsize);
} }
} }
public static class Tasks<T> implements Iterable<T> { public static class Tasks<T> implements Iterable<T> {
@ -547,5 +579,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
public String toString() { public String toString() {
return tasks.toString(); return tasks.toString();
} }
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.fastasyncworldedit.bukkit.adapter; package com.fastasyncworldedit.bukkit.adapter;
import com.fastasyncworldedit.bukkit.adapter.CachedBukkitAdapter;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; 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; import static com.google.common.base.Preconditions.checkNotNull;
public class SimpleBukkitAdapter extends CachedBukkitAdapter { public class SimpleBukkitAdapter extends CachedBukkitAdapter {
private BlockData[][] blockDataCache; private BlockData[][] blockDataCache;
private boolean init() { private boolean init() {
@ -51,4 +51,5 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
throw e; throw e;
} }
} }
} }

Datei anzeigen

@ -2,10 +2,10 @@ package com.fastasyncworldedit.bukkit.filter;
import com.fastasyncworldedit.core.regions.filter.CuboidRegionFilter; import com.fastasyncworldedit.core.regions.filter.CuboidRegionFilter;
import com.fastasyncworldedit.core.util.TaskManager; 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.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 org.bukkit.World;
import java.util.ArrayDeque; import java.util.ArrayDeque;
@ -15,6 +15,7 @@ import java.util.function.Supplier;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
public class GriefDefenderFilter extends CuboidRegionFilter { public class GriefDefenderFilter extends CuboidRegionFilter {
private final Collection<Claim> claims; private final Collection<Claim> claims;
private final World world; private final World world;
@ -37,4 +38,5 @@ public class GriefDefenderFilter extends CuboidRegionFilter {
} }
} }
} }
} }

Datei anzeigen

@ -14,6 +14,7 @@ import java.util.function.Supplier;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
public class GriefPreventionFilter extends CuboidRegionFilter { public class GriefPreventionFilter extends CuboidRegionFilter {
private final Collection<Claim> claims; private final Collection<Claim> claims;
private final World world; private final World world;
@ -36,4 +37,5 @@ public class GriefPreventionFilter extends CuboidRegionFilter {
} }
} }
} }
} }

Datei anzeigen

@ -69,4 +69,5 @@ public class WorldGuardFilter extends CuboidRegionFilter {
ApplicableRegionSet set = manager.getApplicableRegions(regionRegion); ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__"); return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
} }
} }

Datei anzeigen

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

Datei anzeigen

@ -1,7 +1,7 @@
package com.fastasyncworldedit.bukkit.listener; package com.fastasyncworldedit.bukkit.listener;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.bukkit.FaweBukkit; import com.fastasyncworldedit.bukkit.FaweBukkit;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.util.FaweTimer; import com.fastasyncworldedit.core.util.FaweTimer;
import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.MathMan;
@ -50,7 +50,7 @@ public abstract class ChunkListener implements Listener {
private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final Logger LOGGER = LogManagerCompat.getLogger();
protected int rateLimit = 0; protected int rateLimit = 0;
protected Location lastCancelPos; protected Location lastCancelPos;
private int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS, private final int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS,
Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS}; Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS};
public ChunkListener() { public ChunkListener() {
@ -93,7 +93,7 @@ public abstract class ChunkListener implements Listener {
public static boolean itemFreeze = false; public static boolean itemFreeze = false;
protected final Long2ObjectOpenHashMap<Boolean> badChunks = new Long2ObjectOpenHashMap<>(); 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 lastX = Integer.MIN_VALUE;
private int lastZ = Integer.MIN_VALUE; private int lastZ = Integer.MIN_VALUE;
private int[] lastCount; private int[] lastCount;
@ -414,4 +414,5 @@ public abstract class ChunkListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }

Datei anzeigen

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

Datei anzeigen

@ -136,4 +136,5 @@ public class RenderListener implements Listener {
UUID uid = player.getUniqueId(); UUID uid = player.getUniqueId();
views.remove(uid); views.remove(uid);
} }
} }

Datei anzeigen

@ -13,9 +13,9 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.PluginBase; import org.bukkit.plugin.PluginBase;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.PluginLoader;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.Iterator; import java.util.Iterator;
@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger; import java.util.logging.Logger;
public class PluginPreloader extends PluginBase { public class PluginPreloader extends PluginBase {
private World world; private World world;
private Set<BlockVector2> loaded; private Set<BlockVector2> loaded;
private int index; private int index;
@ -199,7 +200,13 @@ public class PluginPreloader extends PluginBase {
@Override @Override
@Nullable @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; return null;
} }
} }

Datei anzeigen

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

Datei anzeigen

@ -28,7 +28,9 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener
} }
public boolean isAllowed(Player player, Claim claim, MaskType type) { 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())); 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 (!claim.isWilderness()) {
if (isAllowed(player, claim, type)) { if (isAllowed(player, claim, type)) {
claim.getGreaterBoundaryCorner().getX(); claim.getGreaterBoundaryCorner().getX();
final BlockVector3 pos1 = BlockVector3.at(claim.getLesserBoundaryCorner().getX(), claim.getLesserBoundaryCorner().getY(), claim.getLesserBoundaryCorner().getZ()); final BlockVector3 pos1 = BlockVector3.at(
final BlockVector3 pos2 = BlockVector3.at(claim.getGreaterBoundaryCorner().getX(), claim.getGreaterBoundaryCorner().getY(), claim.getGreaterBoundaryCorner().getZ()); 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)) { return new FaweMask(new CuboidRegion(pos1, pos2)) {
@Override @Override
@ -59,4 +69,5 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener
public RegionFilter getFilter(String world) { public RegionFilter getFilter(String world) {
return new GriefDefenderFilter(Bukkit.getWorld(world)); return new GriefDefenderFilter(Bukkit.getWorld(world));
} }
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -98,4 +98,5 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
} }
return null; return null;
} }
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -3,6 +3,10 @@ package com.fastasyncworldedit.bukkit.regions.plotsquared;
import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.FaweAPI; import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.FaweCache; 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.EditSessionBuilder;
import com.fastasyncworldedit.core.util.IOUtil; import com.fastasyncworldedit.core.util.IOUtil;
import com.plotsquared.core.PlotSquared; 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.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.fastasyncworldedit.core.jnbt.CompressedCompoundTag;
import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.fastasyncworldedit.core.jnbt.CompressedSchematicTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; 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.MCEditSchematicReader;
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader; import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.internal.util.LogManagerCompat;
@ -33,8 +33,8 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import net.jpountz.lz4.LZ4BlockInputStream; import net.jpountz.lz4.LZ4BlockInputStream;
import org.anarres.parallelgzip.ParallelGZIPOutputStream; import org.anarres.parallelgzip.ParallelGZIPOutputStream;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.EOFException; import java.io.EOFException;
@ -56,13 +56,15 @@ public class FaweDelegateSchematicHandler {
private static final AtomicBoolean exportingAll = new AtomicBoolean(); private static final AtomicBoolean exportingAll = new AtomicBoolean();
public void paste(final Schematic schematic, public void paste(
final Schematic schematic,
final Plot plot, final Plot plot,
final int xOffset, final int xOffset,
final int yOffset, final int yOffset,
final int zOffset, final int zOffset,
final boolean autoHeight, final boolean autoHeight,
final RunnableVal<Boolean> whenDone) { final RunnableVal<Boolean> whenDone
) {
Runnable r = () -> { Runnable r = () -> {
if (whenDone != null) { if (whenDone != null) {
whenDone.value = false; whenDone.value = false;
@ -95,7 +97,8 @@ public class FaweDelegateSchematicHandler {
} else { } else {
y_offset_actual = yOffset + 1 + PlotSquared.platform().worldUtil() y_offset_actual = yOffset + 1 + PlotSquared.platform().worldUtil()
.getHighestBlockSynchronous(plot.getWorldName(), region.getMinimumPoint().getX() + 1, .getHighestBlockSynchronous(plot.getWorldName(), region.getMinimumPoint().getX() + 1,
region.getMinimumPoint().getZ() + 1); region.getMinimumPoint().getZ() + 1
);
} }
} }
} else { } else {
@ -226,4 +229,5 @@ public class FaweDelegateSchematicHandler {
} }
return null; return null;
} }
} }

Datei anzeigen

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

Datei anzeigen

@ -52,4 +52,5 @@ public class FaweTrim extends SubCommand {
}); });
return true; return true;
} }
} }

Datei anzeigen

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

Datei anzeigen

@ -42,24 +42,30 @@ import java.util.stream.Collectors;
aliases = {"bg", "gb"}, aliases = {"bg", "gb"},
usage = "/plots generatebiome <biome>") usage = "/plots generatebiome <biome>")
public class PlotSetBiome extends Command { public class PlotSetBiome extends Command {
public PlotSetBiome() { public PlotSetBiome() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override @Override
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, public CompletableFuture<Boolean> execute(
final PlotPlayer<?> player,
String[] args, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone
) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.generatebiome"), checkTrue(
TranslatableCaption.of("permission.no_plot_perms")); plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.generatebiome"),
TranslatableCaption.of("permission.no_plot_perms")
);
if (plot.getRunning() != 0) { if (plot.getRunning() != 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
return null; return null;
} }
checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"), checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", getUsage())); Templates.of("value", getUsage())
);
final Set<CuboidRegion> regions = plot.getRegions(); final Set<CuboidRegion> regions = plot.getRegions();
BiomeRegistry biomeRegistry = BiomeRegistry biomeRegistry =
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries() WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries()
@ -67,11 +73,15 @@ public class PlotSetBiome extends Command {
Collection<BiomeType> knownBiomes = BiomeTypes.values(); Collection<BiomeType> knownBiomes = BiomeTypes.values();
final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry); final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
if (biome == null) { if (biome == null) {
String biomes = StringMan.join(BiomeType.REGISTRY.values(), String biomes = StringMan.join(
TranslatableCaption.of("blocklist.block_list_separator").getComponent(player)); BiomeType.REGISTRY.values(),
TranslatableCaption.of("blocklist.block_list_separator").getComponent(player)
);
player.sendMessage(TranslatableCaption.of("biome.need_biome")); player.sendMessage(TranslatableCaption.of("biome.need_biome"));
player.sendMessage(TranslatableCaption.of("commandconfig.subcommand_set_options_header"), player.sendMessage(
Templates.of("values", biomes)); TranslatableCaption.of("commandconfig.subcommand_set_options_header"),
Templates.of("values", biomes)
);
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
confirm.run(this, () -> { confirm.run(this, () -> {
@ -105,4 +115,5 @@ public class PlotSetBiome extends Command {
.map(value -> new Command(null, false, value, "", RequiredType.PLAYER, null) { .map(value -> new Command(null, false, value, "", RequiredType.PLAYER, null) {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
} }

Datei anzeigen

@ -117,7 +117,8 @@ public class PlotSquaredFeature extends FaweMaskManager {
World world = FaweAPI.getWorld(area.getWorldName()); World world = FaweAPI.getWorld(area.getWorldName());
List<Region> weRegions = regions.stream().map( List<Region> weRegions = regions.stream().map(
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()), r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()),
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ()))).collect(Collectors.toList()); BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ())
)).collect(Collectors.toList());
maskedRegion = new RegionIntersection(world, weRegions); maskedRegion = new RegionIntersection(world, weRegions);
} }
@ -140,4 +141,5 @@ public class PlotSquaredFeature extends FaweMaskManager {
} }
return null; return null;
} }
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -26,7 +26,8 @@ public class FaweTrim extends SubCommand {
return false; return false;
} }
if (strings.length != 2) { 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>"); plotPlayer.sendMessage("use /plot trimall <world> <boolean-delete-unowned>");
return false; return false;
} }
@ -53,4 +54,5 @@ public class FaweTrim extends SubCommand {
}); });
return true; return true;
} }
} }

Datei anzeigen

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

Datei anzeigen

@ -24,11 +24,12 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes; import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import org.bukkit.Bukkit;
import java.util.Collection; import java.util.Collection;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Bukkit;
@CommandDeclaration( @CommandDeclaration(
command = "generatebiome", command = "generatebiome",
@ -40,12 +41,18 @@ import org.bukkit.Bukkit;
usage = "/plots generatebiome <biome>" usage = "/plots generatebiome <biome>"
) )
public class PlotSetBiome extends Command { public class PlotSetBiome extends Command {
public PlotSetBiome() { public PlotSetBiome() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@Override @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); final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()) || Permissions 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);
@ -55,14 +62,19 @@ public class PlotSetBiome extends Command {
} }
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage()); checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
final Set<CuboidRegion> regions = plot.getRegions(); 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(); Collection<BiomeType> knownBiomes = BiomeTypes.values();
final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry); final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
if (biome == null) { if (biome == null) {
String biomes = StringMan String biomes = StringMan
.join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated()); .join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated());
Captions.NEED_BIOME.send(player); 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); return CompletableFuture.completedFuture(false);
} }
confirm.run(this, () -> { confirm.run(this, () -> {
@ -90,4 +102,5 @@ public class PlotSetBiome extends Command {
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }
} }

Datei anzeigen

@ -1,9 +1,9 @@
package com.fastasyncworldedit.bukkit.regions.plotsquaredv4; package com.fastasyncworldedit.bukkit.regions.plotsquaredv4;
import com.fastasyncworldedit.core.FaweAPI; import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.fastasyncworldedit.core.regions.FaweMask; import com.fastasyncworldedit.core.regions.FaweMask;
import com.fastasyncworldedit.core.regions.FaweMaskManager; import com.fastasyncworldedit.core.regions.FaweMaskManager;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.fastasyncworldedit.core.regions.filter.RegionFilter; import com.fastasyncworldedit.core.regions.filter.RegionFilter;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand; import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
@ -119,7 +119,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
regions = WEManager.getMask(pp); regions = WEManager.getMask(pp);
if (regions.size() == 1) { if (regions.size() == 1) {
CuboidRegion region = regions.iterator().next(); 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(); regions.clear();
} }
} }
@ -132,7 +134,14 @@ public class PlotSquaredFeature extends FaweMaskManager {
int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255; int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255;
final HashSet<RegionWrapper> faweRegions = new HashSet<>(); final HashSet<RegionWrapper> faweRegions = new HashSet<>();
for (CuboidRegion current : regions) { 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 CuboidRegion region = regions.iterator().next();
final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ()); final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
@ -148,7 +157,11 @@ public class PlotSquaredFeature extends FaweMaskManager {
} else { } else {
World world = FaweAPI.getWorld(area.worldname); World world = FaweAPI.getWorld(area.worldname);
List<Region> weRegions = regions.stream() 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()))) .map(r -> new CuboidRegion(
world,
BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()),
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ())
))
.collect(Collectors.toList()); .collect(Collectors.toList());
maskedRegion = new RegionIntersection(world, weRegions); maskedRegion = new RegionIntersection(world, weRegions);
} }
@ -172,4 +185,5 @@ public class PlotSquaredFeature extends FaweMaskManager {
} }
return null; return null;
} }
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -2,6 +2,7 @@ package com.fastasyncworldedit.bukkit.util;
import com.google.common.collect.ComparisonChain; import com.google.common.collect.ComparisonChain;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
/** /**
@ -119,19 +120,28 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) {
if (o == null || getClass() != o.getClass()) return false; return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MinecraftVersion that = (MinecraftVersion) o; MinecraftVersion that = (MinecraftVersion) o;
if (getMajor() != that.getMajor()) return false; if (getMajor() != that.getMajor()) {
if (getMinor() != that.getMinor()) return false; return false;
}
if (getMinor() != that.getMinor()) {
return false;
}
return getRelease() == that.getRelease(); return getRelease() == that.getRelease();
} }
/** /**
* Determines the server version based on the package path, e.g. {@code org.bukkit.craftbukkit.v1_16_R3}, * 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. * @return The package version.
*/ */

Datei anzeigen

@ -5,6 +5,7 @@ import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultUtil { public class VaultUtil {
public final Permission permission; public final Permission permission;
public VaultUtil() { public VaultUtil() {
@ -16,4 +17,5 @@ public class VaultUtil {
this.permission = null; this.permission = null;
} }
} }
} }

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -25,12 +25,12 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import javax.annotation.Nullable;
import java.security.CodeSource; import java.security.CodeSource;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -109,7 +109,8 @@ public class ClassSourceValidator {
builder.append("** the version of ").append(plugin.getName()).append(" that you downloaded, you\n"); builder.append("** the version of ").append(plugin.getName()).append(" that you downloaded, you\n");
builder.append("** will be using a broken mix of old ").append(plugin.getName()).append(" (that came\n"); builder.append("** will be using a broken mix of old ").append(plugin.getName()).append(" (that came\n");
builder.append("** with the plugin) and your downloaded version. THIS MAY\n"); builder.append("** with the plugin) and your downloaded version. THIS MAY\n");
builder.append("** SEVERELY BREAK ").append(plugin.getName().toUpperCase(Locale.ROOT)).append(" AND ALL OF ITS FEATURES.\n"); builder.append("** SEVERELY BREAK ").append(plugin.getName().toUpperCase(Locale.ROOT)).append(
" AND ALL OF ITS FEATURES.\n");
builder.append("**\n"); builder.append("**\n");
builder.append("** This may have happened because the developer is using\n"); builder.append("** This may have happened because the developer is using\n");
builder.append("** the ").append(plugin.getName()).append(" API and thinks that including\n"); builder.append("** the ").append(plugin.getName()).append(" API and thinks that including\n");
@ -128,4 +129,5 @@ public class ClassSourceValidator {
LOGGER.error(builder.toString()); LOGGER.error(builder.toString());
} }
} }

Datei anzeigen

@ -29,4 +29,5 @@ public interface CommandInspector {
String getFullText(Command command); String getFullText(Command command);
boolean testPermission(CommandSender sender, Command command); boolean testPermission(CommandSender sender, Command command);
} }

Datei anzeigen

@ -37,8 +37,10 @@ import java.util.Set;
public class CommandRegistration { public class CommandRegistration {
static { static {
Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class, Bukkit.getServer().getHelpMap().registerHelpTopicFactory(
new DynamicPluginCommandHelpTopic.Factory()); DynamicPluginCommand.class,
new DynamicPluginCommandHelpTopic.Factory()
);
} }
protected final Plugin plugin; protected final Plugin plugin;
@ -72,8 +74,14 @@ public class CommandRegistration {
return false; return false;
} }
for (CommandInfo command : registered) { for (CommandInfo command : registered) {
DynamicPluginCommand cmd = new DynamicPluginCommand(command.getAliases(), DynamicPluginCommand cmd = new DynamicPluginCommand(
command.getDesc(), "/" + command.getAliases()[0] + " " + command.getUsage(), executor, command.getRegisteredWith(), plugin); command.getAliases(),
command.getDesc(),
"/" + command.getAliases()[0] + " " + command.getUsage(),
executor,
command.getRegisteredWith(),
plugin
);
cmd.setPermissions(command.getPermissions()); cmd.setPermissions(command.getPermissions());
commandMap.register(plugin.getDescription().getName(), cmd); commandMap.register(plugin.getDescription().getName(), cmd);
} }

Datei anzeigen

@ -69,7 +69,13 @@ public class CommandsManagerRegistration extends CommandRegistration {
} }
} }
toRegister.add(new CommandInfo(command.usage(), command.desc(), command.aliases(), commands, permissions == null ? null : permissions.toArray(new String[permissions.size()]))); toRegister.add(new CommandInfo(
command.usage(),
command.desc(),
command.aliases(),
commands,
permissions == null ? null : permissions.toArray(new String[permissions.size()])
));
} }
return register(toRegister); return register(toRegister);

Datei anzeigen

@ -43,7 +43,14 @@ public class DynamicPluginCommand extends org.bukkit.command.Command implements
protected final Plugin owningPlugin; protected final Plugin owningPlugin;
protected String[] permissions = new String[0]; protected String[] permissions = new String[0];
public DynamicPluginCommand(String[] aliases, String desc, String usage, CommandExecutor owner, Object registeredWith, Plugin plugin) { public DynamicPluginCommand(
String[] aliases,
String desc,
String usage,
CommandExecutor owner,
Object registeredWith,
Plugin plugin
) {
super(aliases[0], desc, usage, Arrays.asList(aliases)); super(aliases[0], desc, usage, Arrays.asList(aliases));
this.owner = owner; this.owner = owner;
this.owningPlugin = plugin; this.owningPlugin = plugin;
@ -118,4 +125,5 @@ public class DynamicPluginCommand extends org.bukkit.command.Command implements
} }
return super.testPermissionSilent(sender); return super.testPermissionSilent(sender);
} }
} }

Datei anzeigen

@ -139,10 +139,12 @@ public class DynamicPluginCommandHelpTopic extends HelpTopic {
} }
public static class Factory implements HelpTopicFactory<DynamicPluginCommand> { public static class Factory implements HelpTopicFactory<DynamicPluginCommand> {
@Override @Override
public HelpTopic createTopic(DynamicPluginCommand command) { public HelpTopic createTopic(DynamicPluginCommand command) {
return new DynamicPluginCommandHelpTopic(command); return new DynamicPluginCommandHelpTopic(command);
} }
} }
} }

Datei anzeigen

@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public class ConfigurationPermissionsResolver implements PermissionsResolver { public class ConfigurationPermissionsResolver implements PermissionsResolver {
private final YAMLProcessor config; private final YAMLProcessor config;
private final Map<String, Set<String>> userPermissionsCache = new HashMap<>(); private final Map<String, Set<String>> userPermissionsCache = new HashMap<>();
private final Set<String> defaultPermissionsCache = new HashSet<>(); private final Set<String> defaultPermissionsCache = new HashSet<>();

Datei anzeigen

@ -174,4 +174,5 @@ public class DinnerPermsResolver implements PermissionsResolver {
public String getDetectionMessage() { public String getDetectionMessage() {
return "Using the Bukkit Permissions API."; return "Using the Bukkit Permissions API.";
} }
} }

Datei anzeigen

@ -20,10 +20,11 @@
package com.sk89q.wepif; package com.sk89q.wepif;
import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.internal.util.LogManagerCompat;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;

Datei anzeigen

@ -28,6 +28,7 @@ import org.bukkit.World;
import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permissible;
public class GroupManagerResolver extends DinnerPermsResolver { public class GroupManagerResolver extends DinnerPermsResolver {
private final WorldsHolder worldsHolder; private final WorldsHolder worldsHolder;
public static PermissionsResolver factory(Server server, YAMLProcessor config) { public static PermissionsResolver factory(Server server, YAMLProcessor config) {
@ -128,4 +129,5 @@ public class GroupManagerResolver extends DinnerPermsResolver {
public String getDetectionMessage() { public String getDetectionMessage() {
return "GroupManager detected! Using GroupManager for permissions."; return "GroupManager detected! Using GroupManager for permissions.";
} }
} }

Datei anzeigen

@ -27,6 +27,7 @@ import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.PermissionUser; import ru.tehkode.permissions.PermissionUser;
public class PermissionsExResolver extends DinnerPermsResolver { public class PermissionsExResolver extends DinnerPermsResolver {
private final PermissionManager manager; private final PermissionManager manager;
public static PermissionsResolver factory(Server server, YAMLProcessor config) { public static PermissionsResolver factory(Server server, YAMLProcessor config) {
@ -90,4 +91,5 @@ public class PermissionsExResolver extends DinnerPermsResolver {
public String getDetectionMessage() { public String getDetectionMessage() {
return "PermissionsEx detected! Using PermissionsEx for permissions."; return "PermissionsEx detected! Using PermissionsEx for permissions.";
} }
} }

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.wepif;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
public interface PermissionsProvider { public interface PermissionsProvider {
boolean hasPermission(String name, String permission); boolean hasPermission(String name, String permission);
boolean hasPermission(String worldName, String name, String permission); boolean hasPermission(String worldName, String name, String permission);
@ -37,4 +38,5 @@ public interface PermissionsProvider {
boolean inGroup(OfflinePlayer player, String group); boolean inGroup(OfflinePlayer player, String group);
String[] getGroups(OfflinePlayer player); String[] getGroups(OfflinePlayer player);
} }

Datei anzeigen

@ -20,7 +20,9 @@
package com.sk89q.wepif; package com.sk89q.wepif;
public interface PermissionsResolver extends PermissionsProvider { public interface PermissionsResolver extends PermissionsProvider {
void load(); void load();
String getDetectionMessage(); String getDetectionMessage();
} }

Datei anzeigen

@ -272,9 +272,11 @@ public class PermissionsResolverManager implements PermissionsResolver {
} }
public static class MissingPluginException extends Exception { public static class MissingPluginException extends Exception {
} }
class ServerListener implements org.bukkit.event.Listener { class ServerListener implements org.bukkit.event.Listener {
@EventHandler @EventHandler
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
Plugin plugin = event.getPlugin(); Plugin plugin = event.getPlugin();
@ -303,6 +305,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
void register(Plugin plugin) { void register(Plugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
} }
} }

Datei anzeigen

@ -32,7 +32,8 @@ public class PluginPermissionsResolver implements PermissionsResolver {
public static PermissionsResolver factory(Server server, YAMLProcessor config) { public static PermissionsResolver factory(Server server, YAMLProcessor config) {
// Looking for service // Looking for service
RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(PermissionsProvider.class); RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(
PermissionsProvider.class);
if (serviceProvider != null) { if (serviceProvider != null) {
return new PluginPermissionsResolver(serviceProvider.getProvider(), serviceProvider.getPlugin()); return new PluginPermissionsResolver(serviceProvider.getProvider(), serviceProvider.getPlugin());

Datei anzeigen

@ -19,11 +19,11 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter;
import com.fastasyncworldedit.bukkit.adapter.SimpleBukkitAdapter;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter;
import com.fastasyncworldedit.bukkit.adapter.SimpleBukkitAdapter;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -49,9 +49,9 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -184,11 +184,16 @@ public enum BukkitAdapter {
return null; return null;
} }
switch (face) { switch (face) {
case NORTH: return Direction.NORTH; case NORTH:
case SOUTH: return Direction.SOUTH; return Direction.NORTH;
case WEST: return Direction.WEST; case SOUTH:
case EAST: return Direction.EAST; return Direction.SOUTH;
case DOWN: return Direction.DOWN; case WEST:
return Direction.WEST;
case EAST:
return Direction.EAST;
case DOWN:
return Direction.DOWN;
case UP: case UP:
default: default:
return Direction.UP; return Direction.UP;
@ -220,7 +225,8 @@ public enum BukkitAdapter {
adapt(location.getWorld()), adapt(location.getWorld()),
position, position,
location.getYaw(), location.getYaw(),
location.getPitch()); location.getPitch()
);
} }
/** /**
@ -236,7 +242,8 @@ public enum BukkitAdapter {
adapt((World) location.getExtent()), adapt((World) location.getExtent()),
position.getX(), position.getY(), position.getZ(), position.getX(), position.getY(), position.getZ(),
location.getYaw(), location.getYaw(),
location.getPitch()); location.getPitch()
);
} }
/** /**
@ -251,7 +258,8 @@ public enum BukkitAdapter {
checkNotNull(position); checkNotNull(position);
return new org.bukkit.Location( return new org.bukkit.Location(
world, world,
position.getX(), position.getY(), position.getZ()); position.getX(), position.getY(), position.getZ()
);
} }
/** /**
@ -266,7 +274,8 @@ public enum BukkitAdapter {
checkNotNull(position); checkNotNull(position);
return new org.bukkit.Location( return new org.bukkit.Location(
world, world,
position.getX(), position.getY(), position.getZ()); position.getX(), position.getY(), position.getZ()
);
} }
/** /**
@ -283,7 +292,8 @@ public enum BukkitAdapter {
world, world,
location.getX(), location.getY(), location.getZ(), location.getX(), location.getY(), location.getZ(),
location.getYaw(), location.getYaw(),
location.getPitch()); location.getPitch()
);
} }
/** /**
@ -392,8 +402,8 @@ public enum BukkitAdapter {
//FAWE end //FAWE end
} }
private static EnumMap<Material, BlockType> materialBlockTypeCache = new EnumMap<>(Material.class); private static final EnumMap<Material, BlockType> materialBlockTypeCache = new EnumMap<>(Material.class);
private static EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class); private static final EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);
/** /**
* Converts a Material to a BlockType. * Converts a Material to a BlockType.
@ -421,8 +431,8 @@ public enum BukkitAdapter {
//FAWE end //FAWE end
} }
private static Int2ObjectMap<BlockState> blockStateCache = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<BlockState> blockStateCache = new Int2ObjectOpenHashMap<>();
private static Map<String, BlockState> blockStateStringCache = new HashMap<>(); private static final Map<String, BlockState> blockStateStringCache = new HashMap<>();
/** /**
* Create a WorldEdit BlockState from a Bukkit BlockData. * Create a WorldEdit BlockState from a Bukkit BlockData.
@ -436,7 +446,7 @@ public enum BukkitAdapter {
//FAWE end //FAWE end
} }
private static Int2ObjectMap<BlockData> blockDataCache = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<BlockData> blockDataCache = new Int2ObjectOpenHashMap<>();
/** /**
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder. * Create a Bukkit BlockData from a WorldEdit BlockStateHolder.

Datei anzeigen

@ -43,4 +43,5 @@ public class BukkitBlockCategoryRegistry implements BlockCategoryRegistry {
Tag<Material> tag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, new NamespacedKey(namespace, key), Material.class); Tag<Material> tag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, new NamespacedKey(namespace, key), Material.class);
return getFromBukkitTag(tag); return getFromBukkitTag(tag);
} }
} }

Datei anzeigen

@ -33,10 +33,8 @@ import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.BlockCommandSender; import org.bukkit.command.BlockCommandSender;
import javax.annotation.Nonnull;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Locale; import java.util.Locale;
@ -192,11 +190,13 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
updateActive(); updateActive();
} else { } else {
// we should update it eventually // we should update it eventually
Bukkit.getScheduler().callSyncMethod(plugin, Bukkit.getScheduler().callSyncMethod(
plugin,
() -> { () -> {
updateActive(); updateActive();
return null; return null;
}); }
);
} }
return active; return active;
} }
@ -212,4 +212,5 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
} }
}; };
} }
} }

Datei anzeigen

@ -20,8 +20,8 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
@ -30,11 +30,11 @@ import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.OptionalInt; import java.util.OptionalInt;
import javax.annotation.Nullable;
public class BukkitBlockRegistry extends BundledBlockRegistry { public class BukkitBlockRegistry extends BundledBlockRegistry {
@ -144,6 +144,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
public boolean isTranslucent() { public boolean isTranslucent() {
return material.isTransparent(); return material.isTransparent();
} }
} }
//FAWE start //FAWE start

Datei anzeigen

@ -84,4 +84,5 @@ class BukkitCommandInspector implements CommandInspector {
return false; return false;
} }
} }
} }

Datei anzeigen

@ -30,9 +30,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import javax.annotation.Nullable;
import java.util.Locale; import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -114,7 +114,8 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
} }
//FAWE start //FAWE start
@Override public void setPermission(String permission, boolean value) { @Override
public void setPermission(String permission, boolean value) {
} }
//FAWE end //FAWE end
@ -162,4 +163,5 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
} }
}; };
} }
} }

Datei anzeigen

@ -34,7 +34,8 @@ public class BukkitConfiguration extends YAMLConfiguration {
public boolean noOpPermissions = false; public boolean noOpPermissions = false;
public boolean commandBlockSupport = false; public boolean commandBlockSupport = false;
@Unreported private final WorldEditPlugin plugin; @Unreported
private final WorldEditPlugin plugin;
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) { public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
super(config, LogManager.getLogger(plugin.getLogger().getName())); super(config, LogManager.getLogger(plugin.getLogger().getName()));
@ -72,4 +73,5 @@ public class BukkitConfiguration extends YAMLConfiguration {
public Path getWorkingDirectoryPath() { public Path getWorkingDirectoryPath() {
return plugin.getDataFolder().toPath(); return plugin.getDataFolder().toPath();
} }
} }

Datei anzeigen

@ -27,12 +27,10 @@ import com.sk89q.worldedit.entity.metadata.EntityProperties;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.NullWorld; import com.sk89q.worldedit.world.NullWorld;
import com.sk89q.worldedit.world.entity.EntityTypes;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import java.lang.ref.WeakReference;
import java.util.Locale;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.lang.ref.WeakReference;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -136,4 +134,5 @@ public class BukkitEntity implements Entity {
return null; return null;
} }
} }
} }

Datei anzeigen

@ -170,4 +170,5 @@ class BukkitEntityProperties implements EntityProperties {
public boolean isWaterCreature() { public boolean isWaterCreature() {
return entity instanceof WaterMob; return entity instanceof WaterMob;
} }
} }

Datei anzeigen

@ -43,4 +43,5 @@ public class BukkitItemCategoryRegistry implements ItemCategoryRegistry {
Tag<Material> tag = Bukkit.getTag(Tag.REGISTRY_ITEMS, new NamespacedKey(namespace, key), Material.class); Tag<Material> tag = Bukkit.getTag(Tag.REGISTRY_ITEMS, new NamespacedKey(namespace, key), Material.class);
return getFromBukkitTag(tag); return getFromBukkitTag(tag);
} }
} }

Datei anzeigen

@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
class BukkitItemRegistry extends BundledItemRegistry { class BukkitItemRegistry extends BundledItemRegistry {
@Override @Override
public Component getRichName(ItemType itemType) { public Component getRichName(ItemType itemType) {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) { if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {

Datei anzeigen

@ -21,8 +21,8 @@ package com.sk89q.worldedit.bukkit;
import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.util.task.RunnableVal;
import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.TaskManager;
import com.fastasyncworldedit.core.util.task.RunnableVal;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
import com.sk89q.wepif.VaultResolver; import com.sk89q.wepif.VaultResolver;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -63,14 +63,14 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachment;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BukkitPlayer extends AbstractPlayerActor { public class BukkitPlayer extends AbstractPlayerActor {
@ -236,7 +236,14 @@ public class BukkitPlayer extends AbstractPlayerActor {
} }
org.bukkit.World finalWorld = world; org.bukkit.World finalWorld = world;
//FAWE end //FAWE end
return TaskManager.IMP.sync(() -> player.teleport(new Location(finalWorld, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch))); return TaskManager.IMP.sync(() -> player.teleport(new Location(
finalWorld,
pos.getX(),
pos.getY(),
pos.getZ(),
yaw,
pitch
)));
} }
@Override @Override
@ -333,7 +340,8 @@ public class BukkitPlayer extends AbstractPlayerActor {
getWorld(), getWorld(),
position, position,
nativeLocation.getYaw(), nativeLocation.getYaw(),
nativeLocation.getPitch()); nativeLocation.getPitch()
);
} }
@Override @Override
@ -350,9 +358,11 @@ public class BukkitPlayer extends AbstractPlayerActor {
public void sendAnnouncements() { public void sendAnnouncements() {
if (WorldEditPlugin.getInstance().getLifecycledBukkitImplAdapter() == null) { if (WorldEditPlugin.getInstance().getLifecycledBukkitImplAdapter() == null) {
//FAWE start - swap out EH download url with ours //FAWE start - swap out EH download url with ours
print(Caption.of("worldedit.version.bukkit.unsupported-adapter", print(Caption.of(
"worldedit.version.bukkit.unsupported-adapter",
TextComponent.of("https://intellectualsites.github.io/download/fawe.html", TextColor.AQUA) TextComponent.of("https://intellectualsites.github.io/download/fawe.html", TextColor.AQUA)
.clickEvent(ClickEvent.openUrl("https://intellectualsites.github.io/download/fawe.html")))); .clickEvent(ClickEvent.openUrl("https://intellectualsites.github.io/download/fawe.html"))
));
//FAWE end //FAWE end
} }
} }

Datei anzeigen

@ -19,13 +19,13 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.extent.inventory.BlockBagException; import com.sk89q.worldedit.extent.inventory.BlockBagException;
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException; import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException; import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -35,7 +35,7 @@ import org.bukkit.inventory.ItemStack;
public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag { public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag {
//FAWE end //FAWE end
private Player player; private final Player player;
private ItemStack[] items; private ItemStack[] items;
/** /**
@ -194,7 +194,11 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
@Override @Override
public void setItem(int slot, BaseItem block) { public void setItem(int slot, BaseItem block) {
loadInventory(); loadInventory();
BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1); BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(
block.getType(),
block.getNbtData(),
1
);
items[slot] = BukkitAdapter.adapt(stack); items[slot] = BukkitAdapter.adapt(stack);
} }
//FAWE end //FAWE end

Datei anzeigen

@ -23,7 +23,6 @@ import com.sk89q.worldedit.world.registry.BiomeRegistry;
import com.sk89q.worldedit.world.registry.BlockCategoryRegistry; import com.sk89q.worldedit.world.registry.BlockCategoryRegistry;
import com.sk89q.worldedit.world.registry.BlockRegistry; import com.sk89q.worldedit.world.registry.BlockRegistry;
import com.sk89q.worldedit.world.registry.BundledRegistries; import com.sk89q.worldedit.world.registry.BundledRegistries;
import com.sk89q.worldedit.world.registry.EntityRegistry;
import com.sk89q.worldedit.world.registry.ItemCategoryRegistry; import com.sk89q.worldedit.world.registry.ItemCategoryRegistry;
import com.sk89q.worldedit.world.registry.ItemRegistry; import com.sk89q.worldedit.world.registry.ItemRegistry;

Datei anzeigen

@ -45,8 +45,9 @@ import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumMap; import java.util.EnumMap;
@ -55,7 +56,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.annotation.Nullable;
import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText; import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
@ -116,8 +116,7 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
if (!type.startsWith("minecraft:")) { if (!type.startsWith("minecraft:")) {
return false; return false;
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation") final EntityType entityType = EntityType.fromName(type.substring(10));
final EntityType entityType = EntityType.fromName(type.substring(10));
return entityType != null && entityType.isAlive(); return entityType != null && entityType.isAlive();
} }
@ -187,9 +186,16 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
command.getAliases().stream() command.getAliases().stream()
).toArray(String[]::new); ).toArray(String[]::new);
// TODO Handle localisation correctly // TODO Handle localisation correctly
return new CommandInfo(reduceToText(command.getUsage(), WorldEdit.getInstance().getConfiguration().defaultLocale), return new CommandInfo(
reduceToText(command.getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale), aliases, reduceToText(
inspector, permissionsArray); command.getUsage(),
WorldEdit.getInstance().getConfiguration().defaultLocale
),
reduceToText(command.getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale),
aliases,
inspector,
permissionsArray
);
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
} }
@ -264,7 +270,8 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
//FAWE start //FAWE start
@Override @Override
public @Nonnull RelighterFactory getRelighterFactory() { public @Nonnull
RelighterFactory getRelighterFactory() {
if (this.relighterFactory == null) { if (this.relighterFactory == null) {
this.relighterFactory = this.plugin.getBukkitImplAdapter().getRelighterFactory(); this.relighterFactory = this.plugin.getBukkitImplAdapter().getRelighterFactory();
LOGGER.info("Using " + this.relighterFactory.getClass().getCanonicalName() + " as relighter factory."); LOGGER.info("Using " + this.relighterFactory.getClass().getCanonicalName() + " as relighter factory.");

Datei anzeigen

@ -177,6 +177,7 @@ public class BukkitWorld extends AbstractWorld {
} }
//FAWE start //FAWE start
/** /**
* Get the world handle. * Get the world handle.
* *
@ -332,7 +333,8 @@ public class BukkitWorld extends AbstractWorld {
pt = pt.add(0, 1, 0); // bukkit skips the feature gen which does this offset normally, so we have to add it back pt = pt.add(0, 1, 0); // bukkit skips the feature gen which does this offset normally, so we have to add it back
} }
return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType, return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType,
new EditSessionBlockChangeDelegate(editSession)); new EditSessionBlockChangeDelegate(editSession)
);
} }
@Override @Override
@ -527,8 +529,10 @@ public class BukkitWorld extends AbstractWorld {
} }
@Override @Override
public Set<SideEffect> applySideEffects(BlockVector3 position, com.sk89q.worldedit.world.block.BlockState previousType, public Set<SideEffect> applySideEffects(
SideEffectSet sideEffectSet) { BlockVector3 position, com.sk89q.worldedit.world.block.BlockState previousType,
SideEffectSet sideEffectSet
) {
if (worldNativeAccess != null) { if (worldNativeAccess != null) {
worldNativeAccess.applySideEffects(position, previousType, sideEffectSet); worldNativeAccess.applySideEffects(position, previousType, sideEffectSet);
return Sets.intersection( return Sets.intersection(

Datei anzeigen

@ -23,7 +23,6 @@ import com.sk89q.worldedit.LocalSession;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener; import org.bukkit.plugin.messaging.PluginMessageListener;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/** /**

Datei anzeigen

@ -29,7 +29,7 @@ import org.bukkit.block.data.BlockData;
*/ */
public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
private EditSession editSession; private final EditSession editSession;
public EditSessionBlockChangeDelegate(EditSession editSession) { public EditSessionBlockChangeDelegate(EditSession editSession) {
this.editSession = editSession; this.editSession = editSession;

Datei anzeigen

@ -77,7 +77,11 @@ public class WorldEditListener implements Listener {
InjectedValueStore store = MapBackedValueStore.create(); InjectedValueStore store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), context -> store.injectValue(Key.of(Actor.class), context ->
Optional.of(plugin.wrapCommandSender(event.getPlayer()))); Optional.of(plugin.wrapCommandSender(event.getPlayer())));
CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().getCommandManager(); CommandManager commandManager = plugin
.getWorldEdit()
.getPlatformManager()
.getPlatformCommandManager()
.getCommandManager();
event.getCommands().removeIf(name -> event.getCommands().removeIf(name ->
// remove if in the manager and not satisfied // remove if in the manager and not satisfied
commandManager.getCommand(name) commandManager.getCommand(name)
@ -151,4 +155,5 @@ public class WorldEditListener implements Listener {
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
plugin.getWorldEdit().getEventBus().post(new SessionIdleEvent(new BukkitPlayer.SessionKeyImpl(event.getPlayer()))); plugin.getWorldEdit().getEventBus().post(new SessionIdleEvent(new BukkitPlayer.SessionKeyImpl(event.getPlayer())));
} }
} }

Datei anzeigen

@ -117,7 +117,8 @@ public class WorldEditPlugin extends JavaPlugin {
Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins(); Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins();
for (Plugin p : plugins) { for (Plugin p : plugins) {
if (p.getName().equals("WorldEdit")) { if (p.getName().equals("WorldEdit")) {
LOGGER.warn("You installed WorldEdit alongside FastAsyncWorldEdit. That is unneeded and will cause unforeseen issues, " + LOGGER.warn(
"You installed WorldEdit alongside FastAsyncWorldEdit. That is unneeded and will cause unforeseen issues, " +
"because FastAsyncWorldEdit already provides WorldEdit. " + "because FastAsyncWorldEdit already provides WorldEdit. " +
"Stop your server and delete the 'worldedit-bukkit' jar from your plugins folder."); "Stop your server and delete the 'worldedit-bukkit' jar from your plugins folder.");
} }
@ -202,7 +203,8 @@ public class WorldEditPlugin extends JavaPlugin {
getServer().getPluginManager().registerEvents(new WorldInitListener(), this); getServer().getPluginManager().registerEvents(new WorldInitListener(), this);
} else { } else {
//FAWE start //FAWE start
LOGGER.warn("Server reload detected. This may cause various issues with FastAsyncWorldEdit and dependent plugins. Reloading the server is not advised."); LOGGER.warn(
"Server reload detected. This may cause various issues with FastAsyncWorldEdit and dependent plugins. Reloading the server is not advised.");
LOGGER.warn("For more information why reloading is bad, see https://madelinemiller.dev/blog/problem-with-reload/"); LOGGER.warn("For more information why reloading is bad, see https://madelinemiller.dev/blog/problem-with-reload/");
//FAWE end //FAWE end
try { try {
@ -298,7 +300,8 @@ public class WorldEditPlugin extends JavaPlugin {
ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString())); ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString()));
} }
} catch (NoSuchMethodError ignored) { } catch (NoSuchMethodError ignored) {
LOGGER.warn("The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update."); LOGGER.warn(
"The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update.");
} }
} }
@ -475,6 +478,7 @@ public class WorldEditPlugin extends JavaPlugin {
} }
//FAWE start //FAWE start
/** /**
* Get the permissions attachment manager in use * Get the permissions attachment manager in use
* *
@ -565,6 +569,7 @@ public class WorldEditPlugin extends JavaPlugin {
} }
private class WorldInitListener implements Listener { private class WorldInitListener implements Listener {
private boolean loaded = false; private boolean loaded = false;
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
@ -575,9 +580,11 @@ public class WorldEditPlugin extends JavaPlugin {
loaded = true; loaded = true;
setupWorldData(); setupWorldData();
} }
} }
private class AsyncTabCompleteListener implements Listener { private class AsyncTabCompleteListener implements Listener {
AsyncTabCompleteListener() { AsyncTabCompleteListener() {
} }
@ -597,7 +604,8 @@ public class WorldEditPlugin extends JavaPlugin {
// Strip leading slash, if present. // Strip leading slash, if present.
label = label.startsWith("/") ? label.substring(1) : label; label = label.startsWith("/") ? label.substring(1) : label;
final Optional<org.enginehub.piston.Command> command final Optional<org.enginehub.piston.Command> command
= WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(label); = WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(
label);
if (!command.isPresent()) { if (!command.isPresent()) {
return; return;
} }
@ -608,5 +616,7 @@ public class WorldEditPlugin extends JavaPlugin {
event.setCompletions(CommandUtil.fixSuggestions(buffer, suggestEvent.getSuggestions())); event.setCompletions(CommandUtil.fixSuggestions(buffer, suggestEvent.getSuggestions()));
event.setHandled(true); event.setHandled(true);
} }
} }
} }

Datei anzeigen

@ -38,4 +38,5 @@ public class AdapterLoadException extends Exception {
public AdapterLoadException(Throwable cause) { public AdapterLoadException(Throwable cause) {
super(cause); super(cause);
} }
} }

Datei anzeigen

@ -23,8 +23,8 @@ import com.fastasyncworldedit.bukkit.FaweBukkit;
import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter; import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter;
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory; import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory; import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket; import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
import com.sk89q.jnbt.AdventureNBTConverter; import com.sk89q.jnbt.AdventureNBTConverter;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
@ -59,10 +59,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import javax.annotation.Nullable;
import java.util.Map; import java.util.Map;
import java.util.OptionalInt; import java.util.OptionalInt;
import java.util.Set; import java.util.Set;
import javax.annotation.Nullable;
/** /**
* An interface for adapters of various Bukkit implementations. * An interface for adapters of various Bukkit implementations.
@ -243,6 +243,7 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
/** /**
* Regenerate a region in the given world, so it appears "as new". * Regenerate a region in the given world, so it appears "as new".
*
* @param world the world to regen in * @param world the world to regen in
* @param region the region to regen * @param region the region to regen
* @param extent the extent to use for setting blocks * @param extent the extent to use for setting blocks

Datei anzeigen

@ -4,8 +4,8 @@ import com.fastasyncworldedit.bukkit.util.MinecraftVersion;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class MinecraftVersionTest { public class MinecraftVersionTest {

Datei anzeigen

@ -30,6 +30,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
public class DinnerPermsResolverTest { public class DinnerPermsResolverTest {
private DinnerPermsResolver resolver; private DinnerPermsResolver resolver;
@BeforeEach @BeforeEach
@ -86,4 +87,5 @@ public class DinnerPermsResolverTest {
assertTrue(resolver.inGroup(permissible, "b")); assertTrue(resolver.inGroup(permissible, "b"));
assertFalse(resolver.inGroup(permissible, "c")); assertFalse(resolver.inGroup(permissible, "c"));
} }
} }

Datei anzeigen

@ -31,15 +31,16 @@ import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nonnull;
public class TestOfflinePermissible implements OfflinePlayer, Permissible { public class TestOfflinePermissible implements OfflinePlayer, Permissible {
private boolean op; private boolean op;
private UUID randomUuid = UUID.randomUUID(); private UUID randomUuid = UUID.randomUUID();
@ -252,14 +253,18 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
} }
@Override @Override
public void incrementStatistic(@Nonnull Statistic statistic, @Nonnull Material material, public void incrementStatistic(
int amount) throws IllegalArgumentException { @Nonnull Statistic statistic, @Nonnull Material material,
int amount
) throws IllegalArgumentException {
} }
@Override @Override
public void decrementStatistic(@Nonnull Statistic statistic, @Nonnull Material material, public void decrementStatistic(
int amount) throws IllegalArgumentException { @Nonnull Statistic statistic, @Nonnull Material material,
int amount
) throws IllegalArgumentException {
} }
@ -288,20 +293,27 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
} }
@Override @Override
public void incrementStatistic(@Nonnull Statistic statistic, @Nonnull EntityType entityType, public void incrementStatistic(
int amount) throws IllegalArgumentException { @Nonnull Statistic statistic, @Nonnull EntityType entityType,
int amount
) throws IllegalArgumentException {
} }
@Override @Override
public void decrementStatistic(@Nonnull Statistic statistic, @Nonnull EntityType entityType, public void decrementStatistic(
int amount) { @Nonnull Statistic statistic, @Nonnull EntityType entityType,
int amount
) {
} }
@Override @Override
public void setStatistic(@Nonnull Statistic statistic, @Nonnull EntityType entityType, public void setStatistic(
int newValue) { @Nonnull Statistic statistic, @Nonnull EntityType entityType,
int newValue
) {
} }
} }

Datei anzeigen

@ -1,5 +1,4 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
plugins { plugins {
`java-library` `java-library`

Datei anzeigen

@ -5,4 +5,5 @@ package com.sk89q.worldedit.cli;
* annoying, if you try to use the CLI as plugin. * annoying, if you try to use the CLI as plugin.
*/ */
public class AccessPoint { public class AccessPoint {
} }

Datei anzeigen

@ -30,8 +30,11 @@ public class CLIBlockCategoryRegistry implements BlockCategoryRegistry {
@Override @Override
public Set<BlockType> getCategorisedByName(String category) { public Set<BlockType> getCategorisedByName(String category) {
return CLIWorldEdit.inst.getFileRegistries().getDataFile().blocktags.getOrDefault(category, Collections.emptyList()).stream() return CLIWorldEdit.inst.getFileRegistries().getDataFile().blocktags
.getOrDefault(category, Collections.emptyList())
.stream()
.map(BlockType.REGISTRY::get) .map(BlockType.REGISTRY::get)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} }
} }

Datei anzeigen

@ -31,10 +31,10 @@ import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BundledBlockRegistry; import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Nullable;
public class CLIBlockRegistry extends BundledBlockRegistry { public class CLIBlockRegistry extends BundledBlockRegistry {
@ -52,7 +52,11 @@ public class CLIBlockRegistry extends BundledBlockRegistry {
return new EnumProperty(key, values); return new EnumProperty(key, values);
} }
case "direction": { case "direction": {
List<Direction> fixedValues = values.stream().map(String::toUpperCase).map(Direction::valueOf).collect(Collectors.toList()); List<Direction> fixedValues = values
.stream()
.map(String::toUpperCase)
.map(Direction::valueOf)
.collect(Collectors.toList());
return new DirectionalProperty(key, fixedValues); return new DirectionalProperty(key, fixedValues);
} }
default: default:
@ -69,4 +73,5 @@ public class CLIBlockRegistry extends BundledBlockRegistry {
(key, value) -> createProperty(value.type, key, value.values); (key, value) -> createProperty(value.type, key, value.values);
return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform)); return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform));
} }
} }

Datei anzeigen

@ -29,6 +29,7 @@ import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.serializer.plain.PlainComponentSerializer; import com.sk89q.worldedit.util.formatting.text.serializer.plain.PlainComponentSerializer;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.File; import java.io.File;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -188,4 +189,5 @@ public class CLICommandSender implements Actor {
public Map<String, Object> getRawMeta() { public Map<String, Object> getRawMeta() {
return null; return null;
} }
} }

Datei anzeigen

@ -37,4 +37,5 @@ public class CLIConfiguration extends PropertiesConfiguration {
public Path getWorkingDirectoryPath() { public Path getWorkingDirectoryPath() {
return CLIWorldEdit.inst.getWorkingDir(); return CLIWorldEdit.inst.getWorkingDir();
} }
} }

Datei anzeigen

@ -33,6 +33,7 @@ import java.util.concurrent.ExecutionException;
@CommandContainer @CommandContainer
public class CLIExtraCommands { public class CLIExtraCommands {
@Command( @Command(
name = "selectworld", name = "selectworld",
desc = "Select the entire world" desc = "Select the entire world"
@ -59,4 +60,5 @@ public class CLIExtraCommands {
} }
} }
} }
} }

Datei anzeigen

@ -33,4 +33,5 @@ public class CLIItemCategoryRegistry implements ItemCategoryRegistry {
.map(ItemType.REGISTRY::get) .map(ItemType.REGISTRY::get)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} }
} }

Datei anzeigen

@ -34,6 +34,7 @@ import com.sk89q.worldedit.world.registry.Registries;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
@ -41,7 +42,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import javax.annotation.Nullable;
class CLIPlatform extends AbstractPlatform { class CLIPlatform extends AbstractPlatform {
@ -171,4 +171,5 @@ class CLIPlatform extends AbstractPlatform {
public void addWorld(World world) { public void addWorld(World world) {
worlds.add(world); worlds.add(world);
} }
} }

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen