Minor changes

This commit is contained in:
MattBDev 2020-02-14 14:29:08 -05:00
parent 647665c3b0
commit 49dbd4b76b
17 changed files with 49 additions and 70 deletions

View File

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

View File

@ -8,6 +8,7 @@ import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.regions.general.CuboidRegionFilter;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
@ -28,7 +29,8 @@ public class WorldGuardFilter extends CuboidRegionFilter {
@Override
public void calculateRegions() {
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()) {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,22 +1,15 @@
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.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag;
import net.minecraft.server.v1_14_R1.NBTBase;
import net.minecraft.server.v1_14_R1.NBTTagCompound;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.lang.Validate;
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.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;

View File

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

View File

@ -1,11 +1,13 @@
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
* IQueueExtents - avoids conversion between a palette and raw data on every block get
*/
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
default boolean trim(boolean aggressive) {

View File

@ -13,6 +13,7 @@ import java.io.Flushable;
import java.util.Set;
import java.util.concurrent.Future;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Range;
/**
* TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which
@ -53,15 +54,15 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
* @param z
* @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
* @param x
* @param z
* @param chunkX
* @param chunkZ
* @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

View File

@ -105,7 +105,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return delegate.get(this).getEntity(uuid);
}
public static final IBlockDelegate BOTH = new IBlockDelegate() {
private static final IBlockDelegate BOTH = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
return chunk.chunkExisting;
@ -144,7 +144,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.chunkExisting.getFullBlock(x, y, z);
}
};
public static final IBlockDelegate GET = new IBlockDelegate() {
private static final IBlockDelegate GET = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
return chunk.chunkExisting;
@ -189,7 +190,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.chunkExisting.getFullBlock(x, y, z);
}
};
public static final IBlockDelegate SET = new IBlockDelegate() {
private static final IBlockDelegate SET = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
chunk.getOrCreateGet();
@ -235,7 +237,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.getFullBlock(x, y, z);
}
};
public static final IBlockDelegate NULL = new IBlockDelegate() {
private static final IBlockDelegate NULL = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
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
public Map<BlockVector3, CompoundTag> getTiles() {
return delegate.get(this).getTiles();

View File

@ -23,27 +23,17 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
public class CharFilterBlock extends ChunkFilterBlock {
private static final SetDelegate FULL = new SetDelegate() {
@Override
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 static final SetDelegate FULL = (block, value) -> block.setArr[block.index] = value;
private static final SetDelegate NULL = (block, value) -> block.initSet().set(block, value);
private CharGetBlocks get;
private IChunkSet set;
private char[] getArr;
private @Nullable
char[] setArr;
private @Nullable char[] setArr;
private SetDelegate delegate;
// local
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) {
this.get = (CharGetBlocks) iget;
this.layer = layer;
final IBlocks get = (CharGetBlocks) iget;
if (!get.hasSection(layer)) {
if (!iget.hasSection(layer)) {
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
} else {
getArr = get.load(layer);
getArr = iget.load(layer);
}
this.set = iset;
if (set.hasSection(layer)) {
@ -445,6 +434,6 @@ public class CharFilterBlock extends ChunkFilterBlock {
private interface SetDelegate {
void set(CharFilterBlock block, char value);
void set(@NotNull CharFilterBlock block, char value);
}
}

View File

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

View File

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

View File

@ -111,9 +111,6 @@ public class RegionCommands {
int affected = editSession.setBlocks(region, pattern);
if (affected != 0) {
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;
}
@ -424,7 +421,7 @@ public class RegionCommands {
if (volume >= limit.MAX_CHECKS) {
throw FaweCache.MAX_CHECKS;
}
int affected = 0;
int affected;
try {
HeightMap heightMap = new HeightMap(editSession, region, mask, snow);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
@ -609,9 +606,7 @@ public class RegionCommands {
@Logging(REGION)
@Confirm(Confirm.Processor.REGION)
public void regenerateChunk(Actor actor, World world, LocalSession session,
EditSession editSession, @Selection Region region,
@Arg(def = "", desc = "Regenerate with biome") BiomeType biome,
@Arg(def = "", desc = "Regenerate with seed") Long seed) throws WorldEditException {
EditSession editSession, @Selection Region region) throws WorldEditException {
Mask mask = session.getMask();
boolean success;
try {
@ -702,6 +697,7 @@ public class RegionCommands {
@ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask) throws WorldEditException {
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
actor.printInfo(TranslatableComponent.of("worldedit.hollow.changed", TextComponent.of(affected)));
return affected;