3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 04:20:06 +01:00
Dieser Commit ist enthalten in:
MattBDev 2020-02-14 14:29:08 -05:00
Ursprung 647665c3b0
Commit 49dbd4b76b
17 geänderte Dateien mit 49 neuen und 70 gelöschten Zeilen

Datei anzeigen

@ -20,12 +20,8 @@ public class GriefPreventionFilter extends CuboidRegionFilter {
public GriefPreventionFilter(World world) { public GriefPreventionFilter(World world) {
checkNotNull(world); checkNotNull(world);
this.claims = TaskManager.IMP.sync(new Supplier<Collection<Claim>>() { this.claims = TaskManager.IMP.sync(
@Override (Supplier<Collection<Claim>>) () -> new ArrayDeque<>(GriefPrevention.instance.dataStore.getClaims()));
public Collection<Claim> get() {
return new ArrayDeque<>(GriefPrevention.instance.dataStore.getClaims());
}
});
this.world = world; this.world = world;
} }

Datei anzeigen

@ -8,6 +8,7 @@ import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.regions.general.CuboidRegionFilter; import com.boydti.fawe.regions.general.CuboidRegionFilter;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
@ -28,7 +29,8 @@ public class WorldGuardFilter extends CuboidRegionFilter {
@Override @Override
public void calculateRegions() { public void calculateRegions() {
Fawe.get().getQueueHandler().sync(() -> { Fawe.get().getQueueHandler().sync(() -> {
WorldGuardFilter.this.manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(FaweAPI.getWorld(world.getName())); WorldGuardFilter.this.manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(
BukkitAdapter.adapt(world));
for (ProtectedRegion region : manager.getRegions().values()) { for (ProtectedRegion region : manager.getRegions().values()) {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();

Datei anzeigen

@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
public abstract class BukkitMaskManager extends FaweMaskManager { public abstract class BukkitMaskManager extends FaweMaskManager {
@ -9,7 +10,7 @@ public abstract class BukkitMaskManager extends FaweMaskManager {
super(plugin); super(plugin);
} }
public boolean hasMemberPermission(Player player) { public boolean hasMemberPermission(Permissible player) {
return player.hasPermission("fawe." + getKey() + ".member"); return player.hasPermission("fawe." + getKey() + ".member");
} }
} }

Datei anzeigen

@ -12,8 +12,8 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class ResidenceFeature extends BukkitMaskManager implements Listener { public class ResidenceFeature extends BukkitMaskManager implements Listener {
FaweBukkit plugin; private FaweBukkit plugin;
Plugin residence; private Plugin residence;
public ResidenceFeature(final Plugin residencePlugin, final FaweBukkit p3) { public ResidenceFeature(final Plugin residencePlugin, final FaweBukkit p3) {
super(residencePlugin.getName()); super(residencePlugin.getName());

Datei anzeigen

@ -19,7 +19,7 @@ import org.bukkit.plugin.Plugin;
public class TownyFeature extends BukkitMaskManager implements Listener { public class TownyFeature extends BukkitMaskManager implements Listener {
private Plugin towny; private final Plugin towny;
public TownyFeature(Plugin townyPlugin) { public TownyFeature(Plugin townyPlugin) {
super(townyPlugin.getName()); super(townyPlugin.getName());

Datei anzeigen

@ -27,7 +27,7 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class Worldguard extends BukkitMaskManager implements Listener { public class Worldguard extends BukkitMaskManager implements Listener {
private WorldGuardPlugin worldguard; private final WorldGuardPlugin worldguard;
private WorldGuardPlugin getWorldGuard() { private WorldGuardPlugin getWorldGuard() {
final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard"); final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard");

Datei anzeigen

@ -21,7 +21,7 @@ import org.bukkit.plugin.Plugin;
public class WorldguardFlag extends BukkitMaskManager implements Listener { public class WorldguardFlag extends BukkitMaskManager implements Listener {
private WorldGuardPlugin worldguard; private final WorldGuardPlugin worldguard;
public WorldguardFlag(Plugin plugin) { public WorldguardFlag(Plugin plugin) {
super("worldguardflag"); super("worldguardflag");

Datei anzeigen

@ -30,7 +30,7 @@ public class BukkitReflectionUtils {
try { try {
final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle"); final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
final Object handle = getHandle.invoke(server); final Object handle = getHandle.invoke(server);
final Class handleServerClass = handle.getClass(); final Class<?> handleServerClass = handle.getClass();
pas = handleServerClass.getName().split("\\."); pas = handleServerClass.getName().split("\\.");
if (pas.length == 5) { if (pas.length == 5) {
final String verM = pas[3]; final String verM = pas[3];

Datei anzeigen

@ -1,22 +1,15 @@
package com.boydti.fawe.bukkit.wrapper.state; package com.boydti.fawe.bukkit.wrapper.state;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Map.Entry;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import net.minecraft.server.v1_14_R1.NBTBase; import java.util.Collections;
import net.minecraft.server.v1_14_R1.NBTTagCompound; import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_14_R1.persistence.CraftPersistentDataAdapterContext;
import org.bukkit.craftbukkit.v1_14_R1.persistence.CraftPersistentDataTypeRegistry;
import org.bukkit.persistence.PersistentDataAdapterContext; import org.bukkit.persistence.PersistentDataAdapterContext;
import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;

Datei anzeigen

@ -45,7 +45,7 @@ public class AsyncSign extends AsyncBlockState implements Sign {
private String toJson(String oldInput) { private String toJson(String oldInput) {
if (oldInput == null || oldInput.isEmpty()) return ""; if (oldInput == null || oldInput.isEmpty()) return "";
return LegacyComponentSerializer.INSTANCE.serialize(TextComponent.of(oldInput)); return LegacyComponentSerializer.legacy().serialize(TextComponent.of(oldInput));
} }
@Override @Override

Datei anzeigen

@ -1,11 +1,13 @@
package com.boydti.fawe.beta; package com.boydti.fawe.beta;
import org.jetbrains.annotations.Range;
/** /**
* IGetBlocks may be cached by the WorldChunkCache so that it can be used between multiple * IGetBlocks may be cached by the WorldChunkCache so that it can be used between multiple
* IQueueExtents - avoids conversion between a palette and raw data on every block get * IQueueExtents - avoids conversion between a palette and raw data on every block get
*/ */
public interface IChunkCache<T> extends Trimable { public interface IChunkCache<T> extends Trimable {
T get(int chunkX, int chunkZ); T get(@Range(from = 0, to = 15) int chunkX, @Range(from = 0, to = 15) int chunkZ);
@Override @Override
default boolean trim(boolean aggressive) { default boolean trim(boolean aggressive) {

Datei anzeigen

@ -13,6 +13,7 @@ import java.io.Flushable;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jetbrains.annotations.Range;
/** /**
* TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which * TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which
@ -53,15 +54,15 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
* @param z * @param z
* @return * @return
*/ */
IChunkGet getCachedGet(int x, int z); IChunkGet getCachedGet(@Range(from = 0, to = 15) int x, @Range(from = 0, to = 15) int z);
/** /**
* Get the cached chunk set object * Get the cached chunk set object
* @param x * @param chunkX
* @param z * @param chunkZ
* @return * @return
*/ */
IChunkSet getCachedSet(int x, int z); IChunkSet getCachedSet(@Range(from = 0, to = 15) int chunkX, @Range(from = 0, to = 15) int chunkZ);
/** /**
* Submit the chunk so that it's changes are applied to the world * Submit the chunk so that it's changes are applied to the world

Datei anzeigen

@ -105,7 +105,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return delegate.get(this).getEntity(uuid); return delegate.get(this).getEntity(uuid);
} }
public static final IBlockDelegate BOTH = new IBlockDelegate() { private static final IBlockDelegate BOTH = new IBlockDelegate() {
@Override @Override
public IChunkGet get(ChunkHolder chunk) { public IChunkGet get(ChunkHolder chunk) {
return chunk.chunkExisting; return chunk.chunkExisting;
@ -144,7 +144,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.chunkExisting.getFullBlock(x, y, z); return chunk.chunkExisting.getFullBlock(x, y, z);
} }
}; };
public static final IBlockDelegate GET = new IBlockDelegate() {
private static final IBlockDelegate GET = new IBlockDelegate() {
@Override @Override
public IChunkGet get(ChunkHolder chunk) { public IChunkGet get(ChunkHolder chunk) {
return chunk.chunkExisting; return chunk.chunkExisting;
@ -189,7 +190,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.chunkExisting.getFullBlock(x, y, z); return chunk.chunkExisting.getFullBlock(x, y, z);
} }
}; };
public static final IBlockDelegate SET = new IBlockDelegate() {
private static final IBlockDelegate SET = new IBlockDelegate() {
@Override @Override
public IChunkGet get(ChunkHolder chunk) { public IChunkGet get(ChunkHolder chunk) {
chunk.getOrCreateGet(); chunk.getOrCreateGet();
@ -235,7 +237,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.getFullBlock(x, y, z); return chunk.getFullBlock(x, y, z);
} }
}; };
public static final IBlockDelegate NULL = new IBlockDelegate() {
private static final IBlockDelegate NULL = new IBlockDelegate() {
@Override @Override
public IChunkGet get(ChunkHolder chunk) { public IChunkGet get(ChunkHolder chunk) {
chunk.getOrCreateGet(); chunk.getOrCreateGet();
@ -287,11 +290,6 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
} }
}; };
// @Override
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
//// block.flood(get, set, mask, block, );
// }
@Override @Override
public Map<BlockVector3, CompoundTag> getTiles() { public Map<BlockVector3, CompoundTag> getTiles() {
return delegate.get(this).getTiles(); return delegate.get(this).getTiles();

Datei anzeigen

@ -23,27 +23,17 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
public class CharFilterBlock extends ChunkFilterBlock { public class CharFilterBlock extends ChunkFilterBlock {
private static final SetDelegate FULL = new SetDelegate() { private static final SetDelegate FULL = (block, value) -> block.setArr[block.index] = value;
@Override private static final SetDelegate NULL = (block, value) -> block.initSet().set(block, value);
public final void set(CharFilterBlock block, char value) {
block.setArr[block.index] = value;
}
};
private static final SetDelegate NULL = new SetDelegate() {
@Override
public void set(CharFilterBlock block, char value) {
block.initSet().set(block, value);
}
};
private CharGetBlocks get; private CharGetBlocks get;
private IChunkSet set; private IChunkSet set;
private char[] getArr; private char[] getArr;
private @Nullable private @Nullable char[] setArr;
char[] setArr;
private SetDelegate delegate; private SetDelegate delegate;
// local // local
private int layer, index, x, y, z, xx, yy, zz, chunkX, chunkZ; private int layer, index, x, y, z, xx, yy, zz, chunkX, chunkZ;
@ -65,11 +55,10 @@ public class CharFilterBlock extends ChunkFilterBlock {
public final ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer) { public final ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer) {
this.get = (CharGetBlocks) iget; this.get = (CharGetBlocks) iget;
this.layer = layer; this.layer = layer;
final IBlocks get = (CharGetBlocks) iget; if (!iget.hasSection(layer)) {
if (!get.hasSection(layer)) {
getArr = FaweCache.IMP.EMPTY_CHAR_4096; getArr = FaweCache.IMP.EMPTY_CHAR_4096;
} else { } else {
getArr = get.load(layer); getArr = iget.load(layer);
} }
this.set = iset; this.set = iset;
if (set.hasSection(layer)) { if (set.hasSection(layer)) {
@ -445,6 +434,6 @@ public class CharFilterBlock extends ChunkFilterBlock {
private interface SetDelegate { private interface SetDelegate {
void set(CharFilterBlock block, char value); void set(@NotNull CharFilterBlock block, char value);
} }
} }

Datei anzeigen

@ -72,13 +72,13 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
} }
@Override @Override
public IChunkGet getCachedGet(int x, int z) { public IChunkGet getCachedGet(int chunkX, int chunkZ) {
return cacheGet.get(x, z); return cacheGet.get(chunkX, chunkZ);
} }
@Override @Override
public IChunkSet getCachedSet(int x, int z) { public IChunkSet getCachedSet(int chunkX, int chunkZ) {
return cacheSet.get(x, z); return cacheSet.get(chunkX, chunkZ);
} }
/** /**

Datei anzeigen

@ -94,6 +94,7 @@ import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -335,7 +336,7 @@ public class LocalSession implements TextureHolder {
} }
public List<ChangeSet> getHistory() { public List<ChangeSet> getHistory() {
return Lists.transform(history, this::getChangeSet); return history.stream().map(this::getChangeSet).collect(Collectors.toList());
} }
public boolean save() { public boolean save() {

Datei anzeigen

@ -111,9 +111,6 @@ public class RegionCommands {
int affected = editSession.setBlocks(region, pattern); int affected = editSession.setBlocks(region, pattern);
if (affected != 0) { if (affected != 0) {
actor.printInfo(TranslatableComponent.of("worldedit.set.done")); actor.printInfo(TranslatableComponent.of("worldedit.set.done"));
if (!actor.hasPermission("fawe.tips"))
System.out.println("TODO FIXME TIPS");
// TranslatableComponent.of("fawe.tips.tip.fast").or(TranslatableComponent.of("fawe.tips.tip.cancel"), TranslatableComponent.of("fawe.tips.tip.mask"), TranslatableComponent.of("fawe.tips.tip.mask.angle"), TranslatableComponent.of("fawe.tips.tip.set.linear"), TranslatableComponent.of("fawe.tips.tip.surface.spread"), TranslatableComponent.of("fawe.tips.tip.set.hand")).send(actor);
} }
return affected; return affected;
} }
@ -424,7 +421,7 @@ public class RegionCommands {
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw FaweCache.MAX_CHECKS; throw FaweCache.MAX_CHECKS;
} }
int affected = 0; int affected;
try { try {
HeightMap heightMap = new HeightMap(editSession, region, mask, snow); HeightMap heightMap = new HeightMap(editSession, region, mask, snow);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
@ -609,9 +606,7 @@ public class RegionCommands {
@Logging(REGION) @Logging(REGION)
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public void regenerateChunk(Actor actor, World world, LocalSession session, public void regenerateChunk(Actor actor, World world, LocalSession session,
EditSession editSession, @Selection Region region, EditSession editSession, @Selection Region region) throws WorldEditException {
@Arg(def = "", desc = "Regenerate with biome") BiomeType biome,
@Arg(def = "", desc = "Regenerate with seed") Long seed) throws WorldEditException {
Mask mask = session.getMask(); Mask mask = session.getMask();
boolean success; boolean success;
try { try {
@ -702,6 +697,7 @@ public class RegionCommands {
@ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask) throws WorldEditException { @ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask) throws WorldEditException {
checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask; Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask); int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
actor.printInfo(TranslatableComponent.of("worldedit.hollow.changed", TextComponent.of(affected))); actor.printInfo(TranslatableComponent.of("worldedit.hollow.changed", TextComponent.of(affected)));
return affected; return affected;