3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-09-16 04:51:22 +02:00

refactor: Address .editorconfig violations

Dieser Commit ist enthalten in:
NotMyFault 2021-10-18 23:09:21 +02:00
Ursprung 9a33789e41
Commit bd9476a175
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 158F5701A6AAD00C
53 geänderte Dateien mit 1415 neuen und 1127 gelöschten Zeilen

Datei anzeigen

@ -141,6 +141,7 @@ import org.bukkit.generator.ChunkGenerator;
import org.spigotmc.SpigotConfig;
import org.spigotmc.WatchdogThread;
import javax.annotation.Nullable;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@ -162,7 +163,6 @@ import java.util.concurrent.ForkJoinPool;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
@ -193,7 +193,8 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
serverWorldsField.setAccessible(true);
getChunkFutureMethod = ServerChunkCache.class.getDeclaredMethod("getChunkFutureMainThread",
int.class, int.class, ChunkStatus.class, boolean.class);
int.class, int.class, ChunkStatus.class, boolean.class
);
getChunkFutureMethod.setAccessible(true);
chunkProviderExecutorField = ServerChunkCache.class.getDeclaredField(
@ -349,8 +350,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
@Override
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(org.bukkit.World world) {
return new PaperweightWorldNativeAccess(this,
new WeakReference<>(((CraftWorld) world).getHandle()));
return new PaperweightWorldNativeAccess(
this,
new WeakReference<>(((CraftWorld) world).getHandle())
);
}
private static net.minecraft.core.Direction adapt(Direction face) {
@ -462,7 +465,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
return TranslatableComponent.of(CraftItemStack.asNMSCopy(BukkitAdapter.adapt(itemStack)).getDescriptionId());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Map<String, Property<?>> properties = Maps.newTreeMap(String::compareTo);
@ -474,11 +477,25 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) {
property = new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
} else if (state instanceof DirectionProperty) {
property = new DirectionalProperty(state.getName(),
(List<Direction>) state.getPossibleValues().stream().map(e -> Direction.valueOf(((StringRepresentable) e).getSerializedName().toUpperCase(Locale.ROOT))).collect(Collectors.toList()));
property = new DirectionalProperty(
state.getName(),
(List<Direction>) state
.getPossibleValues()
.stream()
.map(e -> Direction.valueOf(((StringRepresentable) e)
.getSerializedName()
.toUpperCase(Locale.ROOT)))
.collect(Collectors.toList())
);
} else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) {
property = new EnumProperty(state.getName(),
(List<String>) state.getPossibleValues().stream().map(e -> ((StringRepresentable) e).getSerializedName()).collect(Collectors.toList()));
property = new EnumProperty(
state.getName(),
(List<String>) state
.getPossibleValues()
.stream()
.map(e -> ((StringRepresentable) e).getSerializedName())
.collect(Collectors.toList())
);
} else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) {
property = new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues()));
} else {
@ -536,7 +553,8 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
}
fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack);
fakePlayer.absMoveTo(position.getBlockX(), position.getBlockY(), position.getBlockZ(),
(float) face.toVector().toYaw(), (float) face.toVector().toPitch());
(float) face.toVector().toYaw(), (float) face.toVector().toPitch()
);
final BlockPos blockPos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos);
@ -545,7 +563,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
UseOnContext context = new UseOnContext(fakePlayer, InteractionHand.MAIN_HAND, rayTrace);
InteractionResult result = stack.placeItem(context, InteractionHand.MAIN_HAND);
if (result != InteractionResult.SUCCESS) {
if (worldServer.getBlockState(blockPos).use(worldServer, fakePlayer, InteractionHand.MAIN_HAND, rayTrace).consumesAction()) {
if (worldServer
.getBlockState(blockPos)
.use(worldServer, fakePlayer, InteractionHand.MAIN_HAND, rayTrace)
.consumesAction()) {
result = InteractionResult.SUCCESS;
} else {
result = stack.getItem().use(worldServer, fakePlayer, InteractionHand.MAIN_HAND).getResult();
@ -559,7 +580,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
public boolean canPlaceAt(org.bukkit.World world, BlockVector3 position, BlockState blockState) {
int internalId = BlockStateIdAccess.getBlockStateId(blockState);
net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId);
return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.getX(), position.getY(), position.getZ()));
return blockData.canSurvive(
((CraftWorld) world).getHandle(),
new BlockPos(position.getX(), position.getY(), position.getZ())
);
}
@Override
@ -661,7 +685,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
}
@SuppressWarnings("unchecked")
private Dynamic<net.minecraft.nbt.Tag> recursivelySetSeed(Dynamic<net.minecraft.nbt.Tag> dynamic, long seed, Set<Dynamic<net.minecraft.nbt.Tag>> seen) {
private Dynamic<net.minecraft.nbt.Tag> recursivelySetSeed(
Dynamic<net.minecraft.nbt.Tag> dynamic,
long seed,
Set<Dynamic<net.minecraft.nbt.Tag>> seen
) {
if (!seen.add(dynamic)) {
return dynamic;
}
@ -685,7 +713,8 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
}
@SuppressWarnings("unchecked")
private void regenForWorld(Region region, Extent extent, ServerLevel serverWorld, RegenOptions options) throws WorldEditException {
private void regenForWorld(Region region, Extent extent, ServerLevel serverWorld, RegenOptions options) throws
WorldEditException {
List<CompletableFuture<ChunkAccess>> chunkLoadings = submitChunkLoadTasks(region, serverWorld);
BlockableEventLoop<Runnable> executor;
try {
@ -935,6 +964,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
}
private class SpigotWatchdog implements Watchdog {
private final Field instanceField;
private final Field lastTickField;
@ -959,9 +989,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
logger.log(Level.WARNING, "Failed to tick watchdog", e);
}
}
}
private static class MojangWatchdog implements Watchdog {
private final DedicatedServer server;
private final Field tickField;
@ -981,9 +1013,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
} catch (IllegalAccessException ignored) {
}
}
}
private static class NoOpWorldLoadListener implements ChunkProgressListener {
@Override
public void updateSpawnPos(ChunkPos spawnPos) {
}
@ -1003,5 +1037,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter {
@Override
public void setChunkRadius(int radius) {
}
}
}

Datei anzeigen

@ -49,6 +49,7 @@ import net.minecraft.world.item.DyeColor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.EnumMap;
@ -62,20 +63,19 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
/**
* Handles converting all Pre 1.13.2 data using the Legacy DataFix System (ported to 1.13.2)
*
* <p>
* We register a DFU Fixer per Legacy Data Version and apply the fixes using legacy strategy
* which is safer, faster and cleaner code.
*
* <p>
* The pre DFU code did not fail when the Source version was unknown.
*
* <p>
* This class also provides util methods for converting compounds to wrap the update call to
* receive the source version in the compound
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer {
@SuppressWarnings("unchecked")
@ -118,7 +118,12 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
private String fixBlockState(String blockState, int srcVer) {
net.minecraft.nbt.CompoundTag stateNBT = stateToNBT(blockState);
Dynamic<net.minecraft.nbt.Tag> dynamic = new Dynamic<>(OPS_NBT, stateNBT);
net.minecraft.nbt.CompoundTag fixed = (net.minecraft.nbt.CompoundTag) INSTANCE.fixer.update(References.BLOCK_STATE, dynamic, srcVer, DATA_VERSION).getValue();
net.minecraft.nbt.CompoundTag fixed = (net.minecraft.nbt.CompoundTag) INSTANCE.fixer.update(
References.BLOCK_STATE,
dynamic,
srcVer,
DATA_VERSION
).getValue();
return nbtToState(fixed);
}
@ -128,7 +133,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
if (tagCompound.contains("Properties", 10)) {
sb.append('[');
net.minecraft.nbt.CompoundTag props = tagCompound.getCompound("Properties");
sb.append(props.getAllKeys().stream().map(k -> k + "=" + props.getString(k).replace("\"", "")).collect(Collectors.joining(",")));
sb.append(props
.getAllKeys()
.stream()
.map(k -> k + "=" + props.getString(k).replace("\"", ""))
.collect(Collectors.joining(",")));
sb.append(']');
}
return sb.toString();
@ -220,6 +229,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
@SuppressWarnings("unchecked")
private class WrappedDataFixer implements DataFixer {
private final DataFixer realFixer;
WrappedDataFixer(DataFixer realFixer) {
@ -240,7 +250,12 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return realFixer.update(type, dynamic, sourceVer, targetVer);
}
private net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp, int sourceVer, int desiredVersion) {
private net.minecraft.nbt.CompoundTag convert(
LegacyType type,
net.minecraft.nbt.CompoundTag cmp,
int sourceVer,
int desiredVersion
) {
List<DataConverter> converters = PaperweightDataConverters.this.converters.get(type);
if (converters != null && !converters.isEmpty()) {
for (DataConverter converter : converters) {
@ -265,6 +280,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
public Schema getSchema(int i) {
return realFixer.getSchema(i);
}
}
public static net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp) {
@ -275,7 +291,12 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return convert(type.getDFUType(), cmp, sourceVer);
}
public static net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
public static net.minecraft.nbt.CompoundTag convert(
LegacyType type,
net.minecraft.nbt.CompoundTag cmp,
int sourceVer,
int targetVer
) {
return convert(type.getDFUType(), cmp, sourceVer, targetVer);
}
@ -288,16 +309,25 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return convert(type, cmp, sourceVer, DATA_VERSION);
}
public static net.minecraft.nbt.CompoundTag convert(TypeReference type, net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
public static net.minecraft.nbt.CompoundTag convert(
TypeReference type,
net.minecraft.nbt.CompoundTag cmp,
int sourceVer,
int targetVer
) {
if (sourceVer >= targetVer) {
return cmp;
}
return (net.minecraft.nbt.CompoundTag) INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, cmp), sourceVer, targetVer).getValue();
return (net.minecraft.nbt.CompoundTag) INSTANCE.fixer
.update(type, new Dynamic<>(OPS_NBT, cmp), sourceVer, targetVer)
.getValue();
}
public interface DataInspector {
net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer);
}
public interface DataConverter {
@ -305,6 +335,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
int getDataVersion();
net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp);
}
@ -582,7 +613,13 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return key;
}
private static void convertCompound(LegacyType type, net.minecraft.nbt.CompoundTag cmp, String key, int sourceVer, int targetVer) {
private static void convertCompound(
LegacyType type,
net.minecraft.nbt.CompoundTag cmp,
String key,
int sourceVer,
int targetVer
) {
cmp.put(key, convert(type, cmp.getCompound(key), sourceVer, targetVer));
}
@ -658,6 +695,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataInspectorBlockEntity implements DataInspector {
@ -840,6 +878,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
@ -859,7 +898,12 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
abstract net.minecraft.nbt.CompoundTag inspectChecked(net.minecraft.nbt.CompoundTag nbttagcompound, int sourceVer, int targetVer);
abstract net.minecraft.nbt.CompoundTag inspectChecked(
net.minecraft.nbt.CompoundTag nbttagcompound,
int sourceVer,
int targetVer
);
}
private static class DataInspectorItemList extends DataInspectorTagged {
@ -878,6 +922,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return nbttagcompound;
}
}
private static class DataInspectorItem extends DataInspectorTagged {
@ -896,6 +941,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return nbttagcompound;
}
}
private static class DataConverterMaterialId implements DataConverter {
@ -1296,6 +1342,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterBanner implements DataConverter {
@ -1342,6 +1389,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterPotionId implements DataConverter {
@ -1619,7 +1667,15 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
private static class DataConverterMinecart implements DataConverter {
private static final List<String> a = Lists.newArrayList("MinecartRideable", "MinecartChest", "MinecartFurnace", "MinecartTNT", "MinecartSpawner", "MinecartHopper", "MinecartCommandBlock");
private static final List<String> a = Lists.newArrayList(
"MinecartRideable",
"MinecartChest",
"MinecartFurnace",
"MinecartTNT",
"MinecartSpawner",
"MinecartHopper",
"MinecartCommandBlock"
);
DataConverterMinecart() {
}
@ -1643,6 +1699,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterMobSpawner implements DataConverter {
@ -1687,6 +1744,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
}
private static class DataConverterUUID implements DataConverter {
@ -1705,11 +1763,47 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterHealth implements DataConverter {
private static final Set<String> a = Sets.newHashSet("ArmorStand", "Bat", "Blaze", "CaveSpider", "Chicken", "Cow", "Creeper", "EnderDragon", "Enderman", "Endermite", "EntityHorse", "Ghast", "Giant", "Guardian", "LavaSlime", "MushroomCow", "Ozelot", "Pig", "PigZombie", "Rabbit", "Sheep", "Shulker", "Silverfish", "Skeleton", "Slime", "SnowMan", "Spider", "Squid", "Villager", "VillagerGolem", "Witch", "WitherBoss", "Wolf", "Zombie");
private static final Set<String> a = Sets.newHashSet(
"ArmorStand",
"Bat",
"Blaze",
"CaveSpider",
"Chicken",
"Cow",
"Creeper",
"EnderDragon",
"Enderman",
"Endermite",
"EntityHorse",
"Ghast",
"Giant",
"Guardian",
"LavaSlime",
"MushroomCow",
"Ozelot",
"Pig",
"PigZombie",
"Rabbit",
"Sheep",
"Shulker",
"Silverfish",
"Skeleton",
"Slime",
"SnowMan",
"Spider",
"Squid",
"Villager",
"VillagerGolem",
"Witch",
"WitherBoss",
"Wolf",
"Zombie"
);
DataConverterHealth() {
}
@ -1738,6 +1832,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterSaddle implements DataConverter {
@ -1762,6 +1857,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterHanging implements DataConverter {
@ -1800,6 +1896,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterDropChances implements DataConverter {
@ -1823,13 +1920,15 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
if (cmp.contains("ArmorDropChances", 9)) {
nbttaglist = cmp.getList("ArmorDropChances", 5);
if (nbttaglist.size() == 4 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F && nbttaglist.getFloat(2) == 0.0F && nbttaglist.getFloat(3) == 0.0F) {
if (nbttaglist.size() == 4 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F && nbttaglist.getFloat(
2) == 0.0F && nbttaglist.getFloat(3) == 0.0F) {
cmp.remove("ArmorDropChances");
}
}
return cmp;
}
}
private static class DataConverterRiding implements DataConverter {
@ -1865,6 +1964,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
nbttagcompound.remove("Riding");
return nbttagcompound1;
}
}
private static class DataConverterBook implements DataConverter {
@ -1933,6 +2033,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterCookedFish implements DataConverter {
@ -1953,6 +2054,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterZombie implements DataConverter {
@ -1995,6 +2097,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
private int convert(int i) {
return i >= 0 && i < 6 ? i : -1;
}
}
private static class DataConverterVBO implements DataConverter {
@ -2010,6 +2113,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
cmp.putString("useVbo", "true");
return cmp;
}
}
private static class DataConverterGuardian implements DataConverter {
@ -2032,6 +2136,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterSkeleton implements DataConverter {
@ -2060,6 +2165,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterZombieType implements DataConverter {
@ -2098,6 +2204,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterHorse implements DataConverter {
@ -2140,6 +2247,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterTileEntity implements DataConverter {
@ -2302,7 +2410,8 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
String s = cmp.getString("id");
if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s)) {
if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(
s)) {
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag");
if (!nbttagcompound1.contains("Potion", 8)) {
@ -2316,6 +2425,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterShulker implements DataConverter {
@ -2334,11 +2444,12 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterShulkerBoxItem implements DataConverter {
public static final String[] a = new String[] { "minecraft:white_shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box" };
public static final String[] a = new String[]{"minecraft:white_shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box"};
DataConverterShulkerBoxItem() {
}
@ -2375,6 +2486,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterShulkerBoxBlock implements DataConverter {
@ -2393,6 +2505,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterLang implements DataConverter {
@ -2411,6 +2524,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterTotem implements DataConverter {
@ -2429,6 +2543,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterBedBlock implements DataConverter {
@ -2476,6 +2591,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterBedItem implements DataConverter {
@ -2494,12 +2610,14 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataConverterSignText implements DataConverter {
public static final Gson a = new GsonBuilder().registerTypeAdapter(Component.class, new JsonDeserializer() {
MutableComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
MutableComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws
JsonParseException {
if (jsonelement.isJsonPrimitive()) {
return new TextComponent(jsonelement.getAsString());
} else if (jsonelement.isJsonArray()) {
@ -2509,7 +2627,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
while (iterator.hasNext()) {
JsonElement jsonelement1 = (JsonElement) iterator.next();
MutableComponent ichatbasecomponent1 = this.a(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext);
MutableComponent ichatbasecomponent1 = this.a(
jsonelement1,
jsonelement1.getClass(),
jsondeserializationcontext
);
if (ichatbasecomponent == null) {
ichatbasecomponent = ichatbasecomponent1;
@ -2524,7 +2646,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
}
}
public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
public Object deserialize(
JsonElement jsonelement,
Type type,
JsonDeserializationContext jsondeserializationcontext
) throws JsonParseException {
return this.a(jsonelement, type, jsondeserializationcontext);
}
}).create();
@ -2590,9 +2716,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
nbttagcompound.putString(s, Component.Serializer.toJson(object));
}
}
private static class DataInspectorPlayerVehicle implements DataInspector {
@Override
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
if (cmp.contains("RootVehicle", 10)) {
@ -2605,9 +2733,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataInspectorLevelPlayer implements DataInspector {
@Override
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
if (cmp.contains("Player", 10)) {
@ -2616,9 +2746,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataInspectorStructure implements DataInspector {
@Override
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
net.minecraft.nbt.ListTag nbttaglist;
@ -2649,9 +2781,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataInspectorChunks implements DataInspector {
@Override
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
if (cmp.contains("Level", 10)) {
@ -2663,7 +2797,15 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
nbttaglist = nbttagcompound1.getList("Entities", 10);
for (j = 0; j < nbttaglist.size(); ++j) {
nbttaglist.set(j, convert(LegacyType.ENTITY, (net.minecraft.nbt.CompoundTag) nbttaglist.get(j), sourceVer, targetVer));
nbttaglist.set(
j,
convert(
LegacyType.ENTITY,
(net.minecraft.nbt.CompoundTag) nbttaglist.get(j),
sourceVer,
targetVer
)
);
}
}
@ -2671,16 +2813,26 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
nbttaglist = nbttagcompound1.getList("TileEntities", 10);
for (j = 0; j < nbttaglist.size(); ++j) {
nbttaglist.set(j, convert(LegacyType.BLOCK_ENTITY, (net.minecraft.nbt.CompoundTag) nbttaglist.get(j), sourceVer, targetVer));
nbttaglist.set(
j,
convert(
LegacyType.BLOCK_ENTITY,
(net.minecraft.nbt.CompoundTag) nbttaglist.get(j),
sourceVer,
targetVer
)
);
}
}
}
return cmp;
}
}
private static class DataInspectorEntityPassengers implements DataInspector {
@Override
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
if (cmp.contains("Passengers", 9)) {
@ -2693,9 +2845,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataInspectorPlayer implements DataInspector {
@Override
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
convertItems(cmp, "Inventory", sourceVer, targetVer);
@ -2710,9 +2864,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataInspectorVillagers implements DataInspector {
ResourceLocation entityVillager = getKey("EntityVillager");
@Override
@ -2736,9 +2892,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataInspectorMobSpawnerMinecart implements DataInspector {
ResourceLocation entityMinecartMobSpawner = getKey("EntityMinecartMobSpawner");
ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
@ -2753,9 +2911,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataInspectorMobSpawnerMobs implements DataInspector {
ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
@Override
@ -2776,9 +2936,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
private static class DataInspectorCommandBlock implements DataInspector {
ResourceLocation tileEntityCommand = getKey("TileEntityCommand");
@Override
@ -2791,5 +2953,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return cmp;
}
}
}

Datei anzeigen

@ -37,7 +37,11 @@ import java.util.OptionalInt;
import java.util.UUID;
class PaperweightFakePlayer extends ServerPlayer {
private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]");
private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile(
UUID.nameUUIDFromBytes("worldedit".getBytes()),
"[WorldEdit]"
);
private static final Vec3 ORIGIN = new Vec3(0.0D, 0.0D, 0.0D);
PaperweightFakePlayer(ServerLevel world) {
@ -95,4 +99,5 @@ class PaperweightFakePlayer extends ServerPlayer {
@Override
public void openTextEdit(SignBlockEntity sign) {
}
}

Datei anzeigen

@ -35,11 +35,13 @@ import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData;
import org.bukkit.event.block.BlockPhysicsEvent;
import javax.annotation.Nullable;
import java.lang.ref.WeakReference;
import java.util.Objects;
import javax.annotation.Nullable;
public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
public class PaperweightWorldNativeAccess implements
WorldNativeAccess<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
private static final int UPDATE = 1;
private static final int NOTIFY = 2;
@ -81,12 +83,19 @@ public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChun
@Nullable
@Override
public net.minecraft.world.level.block.state.BlockState setBlockState(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState state) {
public net.minecraft.world.level.block.state.BlockState setBlockState(
LevelChunk chunk,
BlockPos position,
net.minecraft.world.level.block.state.BlockState state
) {
return chunk.setType(position, state, false, this.sideEffectSet.shouldApply(SideEffect.UPDATE));
}
@Override
public net.minecraft.world.level.block.state.BlockState getValidBlockForPosition(net.minecraft.world.level.block.state.BlockState block, BlockPos position) {
public net.minecraft.world.level.block.state.BlockState getValidBlockForPosition(
net.minecraft.world.level.block.state.BlockState block,
BlockPos position
) {
return Block.updateFromNeighbourShapes(block, getWorld(), position);
}
@ -106,7 +115,12 @@ public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChun
}
@Override
public void notifyBlockUpdate(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
public void notifyBlockUpdate(
LevelChunk chunk,
BlockPos position,
net.minecraft.world.level.block.state.BlockState oldState,
net.minecraft.world.level.block.state.BlockState newState
) {
if (chunk.getSections()[getWorld().getSectionIndex(position.getY())] != null) {
getWorld().sendBlockUpdated(position, oldState, newState, UPDATE | NOTIFY);
}
@ -125,7 +139,11 @@ public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChun
}
@Override
public void notifyNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
public void notifyNeighbors(
BlockPos pos,
net.minecraft.world.level.block.state.BlockState oldState,
net.minecraft.world.level.block.state.BlockState newState
) {
ServerLevel world = getWorld();
if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
world.updateNeighborsAt(pos, oldState.getBlock());
@ -149,14 +167,22 @@ public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChun
}
@Override
public void updateNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, int recursionLimit) {
public void updateNeighbors(
BlockPos pos,
net.minecraft.world.level.block.state.BlockState oldState,
net.minecraft.world.level.block.state.BlockState newState,
int recursionLimit
) {
ServerLevel world = getWorld();
// a == updateNeighbors
// b == updateDiagonalNeighbors
oldState.updateIndirectNeighbourShapes(world, pos, NOTIFY, recursionLimit);
if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
CraftWorld craftWorld = world.getWorld();
BlockPhysicsEvent event = new BlockPhysicsEvent(craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), CraftBlockData.fromData(newState));
BlockPhysicsEvent event = new BlockPhysicsEvent(
craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()),
CraftBlockData.fromData(newState)
);
world.getCraftServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
@ -167,7 +193,11 @@ public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChun
}
@Override
public void onBlockStateChange(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) {
public void onBlockStateChange(
BlockPos pos,
net.minecraft.world.level.block.state.BlockState oldState,
net.minecraft.world.level.block.state.BlockState newState
) {
getWorld().onBlockStateChange(pos, oldState, newState);
}

Datei anzeigen

@ -513,7 +513,10 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
@Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack(Registry.ITEM.get(ResourceLocation.tryParse(baseItemStack.getType().getId())), baseItemStack.getAmount());
ItemStack stack = new ItemStack(
Registry.ITEM.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
baseItemStack.getAmount()
);
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
return CraftItemStack.asCraftMirror(stack);
}
@ -525,7 +528,11 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
) {
TreeType bukkitType = BukkitWorld.toBukkitTreeType(treeType);
if (bukkitType == TreeType.CHORUS_PLANT) {
blockVector3 = blockVector3.add(0, 1, 0); // bukkit skips the feature gen which does this offset normally, so we have to add it back
blockVector3 = blockVector3.add(
0,
1,
0
); // bukkit skips the feature gen which does this offset normally, so we have to add it back
}
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
serverLevel.captureTreeGeneration = true;

Datei anzeigen

@ -491,7 +491,8 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
existingSection = levelChunkSections[layer];
if (existingSection == null) {
LOGGER.error("Skipping invalid null section. chunk: {}, {} layer: {}", chunkX, chunkZ,
+ layer);
+layer
);
continue;
}
}
@ -535,7 +536,8 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
layer
)) {
LOGGER.error("Skipping invalid null section. chunk: {}, {} layer: {}", chunkX, chunkZ,
+ layer);
+layer
);
} else {
updateGet(nmsChunk, levelChunkSections, newSection, setArr, layer);
}

Datei anzeigen

@ -73,11 +73,8 @@ import org.bukkit.generator.BlockPopulator;
import javax.annotation.Nullable;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.file.Path;
import java.util.Collections;
import java.util.HashSet;

Datei anzeigen

@ -7,7 +7,6 @@ import com.fastasyncworldedit.core.regions.FaweMaskManager;
import com.fastasyncworldedit.core.regions.filter.RegionFilter;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.command.MainCommand;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.PlotPlayer;

Datei anzeigen

@ -16,7 +16,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import java.net.URL;
/**
* @hidden
*
*/
public class UpdateNotification {

Datei anzeigen

@ -23,6 +23,7 @@ package com.sk89q.worldedit.bukkit.adapter;
* Reflection helper to deal with obfuscation.
*/
public class Refraction {
private static final String MOJANG_MAPPED_CLASS_NAME = "net.minecraft.nbt.ListTag";
private static final boolean IS_MOJANG_MAPPED;
@ -43,4 +44,5 @@ public class Refraction {
private Refraction() {
}
}

Datei anzeigen

@ -911,8 +911,7 @@ public class StubServer implements Server {
}
@Override
public @NotNull
<T extends Keyed> Iterable<Tag<T>> getTags(@NotNull String s, @NotNull Class<T> aClass) {
public @NotNull <T extends Keyed> Iterable<Tag<T>> getTags(@NotNull String s, @NotNull Class<T> aClass) {
return null;
}

Datei anzeigen

@ -2,8 +2,6 @@ package com.fastasyncworldedit.core;
/**
* An internal FAWE class not meant for public use.
*
* @hidden
**/
public class FaweVersion {

Datei anzeigen

@ -3,7 +3,6 @@ package com.fastasyncworldedit.core.command.tool.brush;
import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.command.tool.ResettableTool;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.internal.exception.FaweException;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush;

Datei anzeigen

@ -331,7 +331,7 @@ public class Config {
/**
* Get the field for a specific config node and instance.
*
* <p>
* As expiry can have multiple blocks there will be multiple instances
*
* @param split the node (split by period)

Datei anzeigen

@ -228,6 +228,7 @@ public class Settings extends Config {
" - \"extended[true:false]\""
})
public List<String> REMAP_PROPERTIES = new ArrayList<>();
}
public static class HISTORY {

Datei anzeigen

@ -5,7 +5,6 @@ import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.util.MemUtil;
import com.fastasyncworldedit.core.util.Permission;
import com.fastasyncworldedit.core.util.WEManager;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent;

Datei anzeigen

@ -12,6 +12,7 @@ public abstract class SimpleClipboard implements Clipboard {
private final int volume;
private BlockVector3 offset;
private BlockVector3 origin;
SimpleClipboard(BlockVector3 dimensions, BlockVector3 offset) {
this.size = dimensions;
this.offset = offset;

Datei anzeigen

@ -2,7 +2,6 @@ package com.fastasyncworldedit.core.history.changeset;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.history.change.BlockChange;

Datei anzeigen

@ -6,7 +6,6 @@ import java.lang.reflect.Field;
/**
* This is an internal class not meant to be used outside the FAWE internals.
* @hidden
*/
public class UnsafeUtility {

Datei anzeigen

@ -45,12 +45,12 @@ import com.fastasyncworldedit.core.function.pattern.ExistingPattern;
import com.fastasyncworldedit.core.function.visitor.DirectionalVisitor;
import com.fastasyncworldedit.core.history.changeset.AbstractChangeSet;
import com.fastasyncworldedit.core.history.changeset.BlockBagChangeSet;
import com.fastasyncworldedit.core.limit.FaweLimit;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.fastasyncworldedit.core.math.MutableBlockVector2;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.fastasyncworldedit.core.math.random.SimplexNoise;
import com.fastasyncworldedit.core.limit.FaweLimit;
import com.fastasyncworldedit.core.queue.implementation.preloader.Preloader;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.fastasyncworldedit.core.util.ExtentTraverser;

Datei anzeigen

@ -52,9 +52,9 @@ import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder;
import com.fastasyncworldedit.core.function.mask.IdMask;
import com.fastasyncworldedit.core.function.mask.SingleBlockTypeMask;
import com.fastasyncworldedit.core.limit.FaweLimit;
import com.fastasyncworldedit.core.math.heightmap.ScalableHeightMap;
import com.fastasyncworldedit.core.math.heightmap.ScalableHeightMap.Shape;
import com.fastasyncworldedit.core.limit.FaweLimit;
import com.fastasyncworldedit.core.util.MainUtil;
import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.util.StringMan;

Datei anzeigen

@ -39,7 +39,6 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World;

Datei anzeigen

@ -36,7 +36,6 @@ import com.sk89q.worldedit.command.argument.Arguments;
import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;

Datei anzeigen

@ -513,15 +513,20 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (actor != null) {
if (!actor.hasPermission("worldedit.anyblock")
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId().toLowerCase(Locale.ROOT))) {
throw new DisallowedUsageException(Caption.of("worldedit.error.disallowed-block", TextComponent.of(blockType.getId())));
throw new DisallowedUsageException(Caption.of(
"worldedit.error.disallowed-block",
TextComponent.of(blockType.getId())
));
}
FaweLimit limit = actor.getLimit();
if (!limit.isUnlimited()) {
// No need to account for blocked states/properties as it will simply return false in the equality check
// during contains.
if (limit.DISALLOWED_BLOCKS.contains(blockType.getId().toLowerCase(Locale.ROOT))) {
throw new DisallowedUsageException(Caption.of("fawe.error.limit.disallowed-block",
TextComponent.of(blockType.getId())));
throw new DisallowedUsageException(Caption.of(
"fawe.error.limit.disallowed-block",
TextComponent.of(blockType.getId())
));
}
}
}

Datei anzeigen

@ -159,7 +159,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
/**
* Immediately terminate execution of the script, but without a failure message.
*
* <p>
* This exits by throwing an exception, which if caught will prevent
* the script from exiting
*/

Datei anzeigen

@ -344,7 +344,10 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
//FAWE end
BlockType type = this.getBlockType();
// Lazily initialize the map
Map<? extends Property<?>, Object> map = Maps.asMap(type.getPropertiesSet(), (Function<Property<?>, Object>) this::getState);
Map<? extends Property<?>, Object> map = Maps.asMap(
type.getPropertiesSet(),
(Function<Property<?>, Object>) this::getState
);
//noinspection RedundantCast - This is required for compilation, etc.
return Collections.unmodifiableMap((Map<Property<?>, Object>) map);
//FAWE end

Datei anzeigen

@ -20,16 +20,13 @@
package com.sk89q.worldedit.world.chunk;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* A 16 by 16 block chunk.
@ -46,6 +43,7 @@ public interface Chunk {
BaseBlock getBlock(BlockVector3 position) throws DataException;
//FAWE start - biome and entity restore
/**
* Get a biome.
*
@ -59,6 +57,7 @@ public interface Chunk {
/**
* Get the stored entities.
*
* @return list of stored entities
*/
default List<BaseEntity> getEntities() throws DataException {

Datei anzeigen

@ -149,8 +149,10 @@ public final class LegacyMapper {
// if it's still null, both fixer and default failed
if (state == null) {
LOGGER.error("Unknown block: {}. Neither the DataFixer nor defaulting worked to recognize this block.",
value);
LOGGER.error(
"Unknown block: {}. Neither the DataFixer nor defaulting worked to recognize this block.",
value
);
} else {
// it's not null so one of them succeeded, now use it
blockToStringMap.put(state, id);

Datei anzeigen

@ -28,8 +28,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.nbt.BinaryTag;
import com.sk89q.worldedit.util.nbt.BinaryTagTypes;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.util.nbt.ListBinaryTag;
import com.sk89q.worldedit.world.DataException;

Datei anzeigen

@ -87,6 +87,7 @@ public abstract class ChunkStore implements Closeable {
public abstract CompoundTag getChunkTag(BlockVector2 position, World world) throws DataException, IOException;
//FAWE start - biome and entity restore
/**
* Get the tag for the entities stored in a chunk from the entities folder. 1.17+ use only.
* If an error occurs, returns null.

Datei anzeigen

@ -1,15 +1,12 @@
{
"prefix": "&8(&4&lFAWE&8)&7 {0}",
"fawe.worldedit.history.find.element": "&2{0} {1} &7ago &3{2}m &6{3} &c/{4}",
"fawe.worldedit.history.find.element.more": " - Changes: {0}\n - Bounds: {1} -> {2}\n - Extra: {3}\n - Size on Disk: {4}",
"fawe.worldedit.history.find.hover": "{0} blocks changed, click for more info",
"fawe.worldedit.history.distr.summary_null": "Could not find edit summary for inputs.",
"fawe.info.lighting.propagate.selection": "Lighting has been propagated in {0} chunks. (Note: To remove light use //removelight)",
"fawe.info.updated.lighting.selection": "Lighting has been updated in {0} chunks. (It may take a second for the packets to send)",
"fawe.info.set.region": "Selection set to your current allowed region",
"fawe.info.worldedit.toggle.tips.on": "Disabled FAWE tips.",
"fawe.info.worldedit.toggle.tips.off": "Enabled FAWE tips.",
"fawe.info.worldedit.bypassed": "Currently bypassing FAWE restriction.",
@ -17,30 +14,21 @@
"fawe.info.worldedit.oom.admin": "Possible options:\n - //fast\n - Do smaller edits\n - Allocate more memory\n - Disable `max-memory-percent`",
"fawe.info.temporarily-not-working": "Temporarily not working",
"fawe.info.update-available": "An update for FastAsyncWorldEdit is available. You are {0} build(s) out of date.\nYou are running version {1}, the latest version is {2}.\nUpdate at {3}",
"fawe.web.generating.link": "Uploading {0}, please wait...",
"fawe.web.generating.link.failed": "Failed to generate download link!",
"fawe.web.download.link": "{0}",
"fawe.worldedit.general.texture.disabled": "Texturing reset",
"fawe.worldedit.general.texture.set": "Set texturing to {1}",
"fawe.worldedit.general.source.mask.disabled": "Global source mask disabled",
"fawe.worldedit.general.source.mask": "Global source mask set",
"fawe.worldedit.general.transform.disabled": "Global transform disabled",
"fawe.worldedit.general.transform": "Global transform set",
"fawe.worldedit.copy.command.copy": "{0} blocks were copied.",
"fawe.worldedit.cut.command.cut.lazy": "{0} blocks will be removed on paste",
"fawe.worldedit.paste.command.paste": "The clipboard has been pasted at {0}",
"fawe.worldedit.history.command.undo.disabled": "Undo disabled, use: //fast",
"fawe.worldedit.selection.selection.count": "Counted {0} blocks.",
"fawe.worldedit.anvil.world.is.loaded": "The world shouldn't be in use when executing. Unload the world, or use -f to override (save first)",
"fawe.worldedit.brush.brush.reset": "Reset your brush. (SHIFT + Click)",
"fawe.worldedit.brush.brush.none": "You aren't holding a brush!",
"fawe.worldedit.brush.brush.scroll.action.set": "Set scroll action to {0}",
@ -63,37 +51,27 @@
"fawe.worldedit.brush.brush.source.mask": "Brush source mask set",
"fawe.worldedit.brush.brush.transform.disabled": "Brush transform disabled",
"fawe.worldedit.brush.brush.transform": "Brush transform set",
"fawe.worldedit.rollback.rollback.element": "Undoing {0}",
"fawe.worldedit.tool.tool.inspect": "Inspect tool bound to {0}.",
"fawe.worldedit.tool.tool.inspect.info": "{0} changed {1} to {2} {3} ago",
"fawe.worldedit.tool.tool.inspect.info.footer": "Total: {0} changes",
"fawe.worldedit.tool.tool.range.error": "Maximum range: {0}.",
"fawe.worldedit.tool.tool.lrbuild.info": "Left-click set to {0}; right-click set to {1}.",
"fawe.worldedit.utility.nothing.confirmed": "You have no actions pending confirmation.",
"fawe.worldedit.schematic.schematic.move.exists": "{0} already exists",
"fawe.worldedit.schematic.schematic.move.success": "{0} -> {1}",
"fawe.worldedit.schematic.schematic.move.failed": "{0} no moved: {1}",
"fawe.worldedit.schematic.schematic.loaded": "{0} loaded. Paste it with //paste",
"fawe.worldedit.schematic.schematic.saved": "{0} saved.",
"fawe.worldedit.schematic.schematic.none": "No files found.",
"fawe.worldedit.clipboard.clipboard.uri.not.found": "You do not have {0} loaded",
"fawe.worldedit.clipboard.clipboard.cleared": "Clipboard cleared",
"fawe.worldedit.clipboard.clipboard.invalid.format": "Unknown clipboard format: {0}",
"fawe.worldedit.visitor.visitor.block": "{0} blocks affected",
"fawe.worldedit.selector.selector.fuzzy.pos1": "Region set and expanded from {0} {1}.",
"fawe.worldedit.selector.selector.fuzzy.pos2": "Added expansion of {0} {1}.",
"fawe.progress.progress.message": "{1}/{0} ({2}%) @{3}cps {4}s left",
"fawe.progress.progress.finished": "[ Done! ]",
"fawe.error.command.syntax": "Usage: {0}",
"fawe.error.no-perm": "You are lacking the permission node: {0}",
"fawe.error.block.not.allowed": "You are not allowed to use: {0}",
@ -151,7 +129,6 @@
"fawe.error.clipboard.on.disk.version.mismatch": "Clipboard version mismatch. Please delete your clipboards folder and restart the server.",
"fawe.error.limit.disallowed-block": "Your limit disallows use of block '{0}'",
"fawe.error.limit.disallowed-property": "Your limit disallows use of property '{0}'",
"fawe.cancel.count": "Cancelled {0} edits.",
"fawe.cancel.reason.confirm": "Use //confirm to execute {0}",
"fawe.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}",
@ -176,16 +153,13 @@
"fawe.cancel.reason.player-only": "This operation requires a player, and cannot be executed from console, or without an actor.",
"fawe.cancel.reason.actor-required": "This operation requires an actor.",
"fawe.cancel.worldedit.failed.load.chunk": "Skipped loading chunk: {0};{1}. Try increasing chunk-wait.",
"fawe.navigation.no.block": "No block in sight! (or too far)",
"fawe.selection.sel.max": "{0} points maximum.",
"fawe.selection.sel.fuzzy": "Fuzzy selector: Left click to select all contingent blocks, right click to add. To select an air cavity, use //pos1.",
"fawe.selection.sel.fuzzy-instruction": "Select all connected blocks (magic wand)",
"fawe.selection.sel.convex.polyhedral": "Convex polyhedral selector: Left click=First vertex, right click to add more.",
"fawe.selection.sel.polyhedral": "Select a hollow polyhedral",
"fawe.selection.sel.list": "For a list of selection types use: //sel list",
"fawe.tips.tip.sel.list": "Tip: See the different selection modes with //sel list",
"fawe.tips.tip.select.connected": "Tip: Select all connected blocks with //sel fuzzy",
"fawe.tips.tip.set.pos1": "Tip: Use pos1 as a pattern with //set pos1",
@ -222,17 +196,13 @@
"fawe.tips.tip.regen.1": "Tip: Use a seed with /regen [biome] [seed]",
"fawe.tips.tip.biome.pattern": "Tip: The #biome[forest] pattern can be used in any command",
"fawe.tips.tip.biome.mask": "Tip: Restrict to a biome with the `$jungle` mask",
"fawe.regen.time": "Regenerating region, this might take a while!",
"worldedit.expand.description.vert": "Vertically expand the selection to world limits.",
"worldedit.expand.expanded": "Region expanded {0} blocks",
"worldedit.expand.expanded.vert": "Region expanded {0} blocks (top-to-bottom).",
"worldedit.biomeinfo.lineofsight": "Biomes at line of sight point: {0}",
"worldedit.biomeinfo.position": "Biomes at your position: {0}",
"worldedit.biomeinfo.selection": "Biomes in your selection: {0}",
"worldedit.error.disabled": "This functionality is disabled (see WorldEdit configuration).",
"worldedit.error.no-match": "No match for '{0}'.",
"worldedit.error.unknown": "Unknown error occurred: {0}",
@ -280,7 +250,6 @@
"worldedit.error.unknown-tag": "Tag name '{0}' was not recognized.",
"worldedit.error.empty-tag": "Tag name '{0}' has no contents.",
"worldedit.error.unknown-biome": "Biome name '{0}' was not recognized.",
"worldedit.brush.radius-too-large": "Maximum allowed brush radius: {0}",
"worldedit.brush.apply.description": "Apply brush, apply a function to every block",
"worldedit.brush.apply.radius": "The size of the brush",
@ -307,9 +276,7 @@
"worldedit.brush.butcher.equip": "Butcher brush equipped ({0}).",
"worldedit.brush.operation.equip": "Set brush to {0}.",
"worldedit.brush.none.equip": "Brush unbound from your current item.",
"worldedit.setbiome.changed": "Biomes were changed in {0} columns. You may have to rejoin your game (or close and reopen your world) to see a change.",
"worldedit.drawsel.disabled": "Server CUI disabled.",
"worldedit.drawsel.enabled": "Server CUI enabled. This only supports cuboid regions, with a maximum size of {0}x{1}x{2}.",
"worldedit.drawsel.disabled.already": "Server CUI already disabled.",
@ -345,15 +312,12 @@
"worldedit.watchdog.inactive": "Watchdog hook now inactive.",
"worldedit.world.remove": "Removed world override.",
"worldedit.world.set": "Set the world override to {0}. (Use //world to go back to default)",
"worldedit.undo.undone": "Undid {0} available edits.",
"worldedit.undo.none": "Nothing left to undo.",
"worldedit.redo.redone": "Redid {0} available edits.",
"worldedit.redo.none": "Nothing left to redo.",
"worldedit.clearhistory.cleared": "History cleared.",
"worldedit.raytrace.noblock": "No block in sight!",
"worldedit.restore.not-configured": "Snapshot/backup restore is not configured.",
"worldedit.restore.not-available": "That snapshot does not exist or is not available.",
"worldedit.restore.failed": "Failed to load snapshot: {0}",
@ -367,14 +331,12 @@
"worldedit.restore.chunk-load-failed": "No chunks could be loaded. (Bad archive?)",
"worldedit.restore.block-place-failed": "Errors prevented any blocks from being restored.",
"worldedit.restore.block-place-error": "Last error: {0}",
"worldedit.snapshot.use.newest": "Now using newest snapshot.",
"worldedit.snapshot.use": "Snapshot set to: {0}",
"worldedit.snapshot.none-before": "Couldn't find a snapshot before {0}.",
"worldedit.snapshot.none-after": "Couldn't find a snapshot after {0}.",
"worldedit.snapshot.index-above-0": "Invalid index, must be greater than or equal to 1.",
"worldedit.snapshot.index-oob": "Invalid index, must be between 1 and {0}.",
"worldedit.schematic.unknown-format": "Unknown schematic format: {0}.",
"worldedit.schematic.load.does-not-exist": "Schematic {0} does not exist!",
"worldedit.schematic.load.loading": "(Please wait... loading schematic.)",
@ -408,7 +370,6 @@
"worldedit.schematic.file-perm-fail": "Creation of '{0}' failed! Check file permission.",
"worldedit.schematic.sorting-old-new": "Cannot sort by oldest and newest.",
"worldedit.schematic.unsupported-minecraft-version": "This version of WorldEdit does not support your Minecraft version. Schematics will not work until this is resolved.",
"worldedit.pos.already-set": "Position already set.",
"worldedit.pos.console-require-coords": "You must provide coordinates as console.",
"worldedit.hpos.no-block": "No block in sight!",
@ -450,12 +411,10 @@
"worldedit.select.convex.limit-message": "{0} points maximum.",
"worldedit.select.convex.description": "Select a convex polyhedral",
"worldedit.select.default-set": "Your default region selector is now {0}.",
"worldedit.chunkinfo.chunk": "Chunk: {0}, {1}",
"worldedit.chunkinfo.old-filename": "Old format: {0}",
"worldedit.chunkinfo.mcregion-filename": "McRegion: region/{0}",
"worldedit.listchunks.listfor": "Listing chunks for: {0}",
"worldedit.drain.drained": "{0} blocks have been drained.",
"worldedit.fill.created": "{0} blocks have been filled.",
"worldedit.fillr.created": "{0} blocks have been filled.",
@ -475,14 +434,12 @@
"worldedit.remove.explain-all": "Use -1 to remove all entities in loaded chunks",
"worldedit.calc.invalid": "'{0}' could not be parsed as a valid expression",
"worldedit.calc.invalid.with-error": "'{0}' could not be parsed as a valid expression: '{1}'",
"worldedit.paste.pasted": "The clipboard has been pasted at {0}",
"worldedit.paste.selected": "Selected clipboard paste region.",
"worldedit.rotate.no-interpolation": "Note: Interpolation is not yet supported, so angles that are multiples of 90 is recommended.",
"worldedit.rotate.rotated": "The clipboard copy has been rotated.",
"worldedit.flip.flipped": "The clipboard copy has been flipped.",
"worldedit.clearclipboard.cleared": "Clipboard cleared.",
"worldedit.set.done": "Operation completed.",
"worldedit.set.done.verbose": "Operation completed ({0}).",
"worldedit.line.changed": "{0} blocks have been changed.",
@ -507,7 +464,6 @@
"worldedit.hollow.changed": "{0} blocks have been changed.",
"worldedit.forest.created": "{0} trees created.",
"worldedit.flora.created": "{0} flora created.",
"worldedit.unstuck.moved": "There you go!",
"worldedit.ascend.obstructed": "No free spot above you found.",
"worldedit.ascend.moved": "Ascended {0} levels.",
@ -521,7 +477,6 @@
"worldedit.jumpto.none": "No block in sight (or too far away)!",
"worldedit.up.obstructed": "You would hit something above you.",
"worldedit.up.moved": "Woosh!",
"worldedit.cyl.invalid-radius": "You must either specify 1 or 2 radius values.",
"worldedit.cyl.created": "{0} blocks have been created.",
"worldedit.hcyl.thickness-too-large": "Thickness cannot be larger than x or z radii.",
@ -532,7 +487,6 @@
"worldedit.pyramid.created": "{0} blocks have been created.",
"worldedit.generate.created": "{0} blocks have been created.",
"worldedit.generatebiome.changed": "{0} biomes affected.",
"worldedit.reload.config": "Configuration reloaded!",
"worldedit.report.written": "FAWE report written to {0}",
"worldedit.report.error": "Failed to write report: {0}",
@ -542,14 +496,12 @@
"worldedit.timezone.current": "The current time in that timezone is: {0}",
"worldedit.version.version": "FAWE version:\n - Date {0}\n - Commit {1}\n - Build {2}\n - Platform {3}",
"worldedit.version.bukkit.unsupported-adapter": "This FAWE version does not fully support your version of Bukkit. Block entities (e.g. chests) will be empty, block properties (e.g. rotation) will be missing, and other things may not work.\nUpdate FAWE and your server software to restore this functionality:\n{0}",
"worldedit.trace.no-tracing-extents": "Trace: No extent was used.",
"worldedit.trace.action-failed": "Trace: Action(s) {0} at {1} discarded by extent {2}",
"worldedit.trace.active.already": "Trace mode already active.",
"worldedit.trace.inactive.already": "Trace mode already inactive.",
"worldedit.trace.active": "Trace mode now active.",
"worldedit.trace.inactive": "Trace mode now inactive.",
"worldedit.command.time-elapsed": "{0}s elapsed (history: {1} changed; {2} blocks/sec).",
"worldedit.command.permissions": "You are not permitted to do that. Are you in the right mode?",
"worldedit.command.player-only": "This command must be used with a player.",
@ -559,7 +511,6 @@
"worldedit.pastebin.uploading": "(Please wait... sending output to paste service...)",
"worldedit.session.cant-find-session": "Unable to find session for {0}",
"worldedit.platform.no-file-dialog": "File dialogs are not supported in your environment.",
"worldedit.tool.max-block-changes": "Max blocks change limit reached.",
"worldedit.tool.no-block": "No block in sight!",
"worldedit.tool.repl.equip": "Block replacer tool bound to {0}.",
@ -588,9 +539,7 @@
"worldedit.tool.lrbuild.equip": "Long-range building tool bound to {0}.",
"worldedit.tool.lrbuild.set": "Left-click set to {0}; right-click set to {1}.",
"worldedit.tool.stack.equip": "Stack tool bound to {0}.",
"worldedit.tool.unbind-instruction": "Run {0} while holding the item to unbind it.",
"worldedit.tool.superpickaxe.mode.single": "Mode is now single. Left click with a pickaxe. // to disable.",
"worldedit.tool.superpickaxe.mode.area": "Mode is now area. Left click with a pickaxe. // to disable.",
"worldedit.tool.superpickaxe.mode.recursive": "Mode is now recursive. Left click with a pickaxe. // to disable.",
@ -606,7 +555,6 @@
"worldedit.tool.size.set": "Brush size set.",
"worldedit.tool.tracemask.set": "Trace mask set.",
"worldedit.tool.tracemask.disabled": "Trace mask disabled.",
"worldedit.execute.script-permissions": "You don't have permission to use that script.",
"worldedit.executelast.no-script": "Use /cs with a script name first.",
"worldedit.script.read-error": "Script read error: {0}",
@ -615,15 +563,12 @@
"worldedit.script.no-script-engine": "Failed to find an installed script engine.\nPlease see https://worldedit.enginehub.org/en/latest/usage/other/craftscripts/",
"worldedit.script.failed": "Failed to execute: {0}",
"worldedit.script.failed-console": "Failed to execute (see console): {0}",
"worldedit.operation.affected.biome": "{0} biomes affected",
"worldedit.operation.affected.block": "{0} blocks affected",
"worldedit.operation.affected.column": "{0} columns affected",
"worldedit.operation.affected.entity": "{0} entities affected",
"worldedit.operation.deform.expression": "deformed using {0}",
"worldedit.error.parser.invalid-nbt": "Invalid NBT Data in input: '{0}'. Error: {1}",
"worldedit.selection.convex.info.vertices": "Vertices: {0}",
"worldedit.selection.convex.info.triangles": "Triangles: {0}",
"worldedit.selection.convex.explain.primary": "Started new selection with vertex {0}.",
@ -652,7 +597,6 @@
"worldedit.selection.polygon2d.explain.secondary": "Added point #{0} at {1}.",
"worldedit.selection.sphere.explain.secondary": "Radius set to {0}.",
"worldedit.selection.sphere.explain.secondary-defined": "Radius set to {0} ({1}).",
"worldedit.sideeffect.lighting": "Lighting",
"worldedit.sideeffect.lighting.description": "Updates block lighting",
"worldedit.sideeffect.neighbors": "Neighbors",
@ -670,11 +614,9 @@
"worldedit.sideeffect.state.off": "Off",
"worldedit.sideeffect.box.current": "Current",
"worldedit.sideeffect.box.change-to": "Click to set to {0}",
"worldedit.help.command-not-found": "The command '{0}' could not be found.",
"worldedit.help.no-subcommands": "'{0}' has no sub-commands. (Maybe '{1}' is for a parameter?)",
"worldedit.help.subcommand-not-found": "The sub-command '{0}' under '{1}' could not be found.",
"worldedit.cli.stopping": "Stopping!",
"worldedit.cli.unknown-command": "Unknown command!"
}

Datei anzeigen

@ -147,7 +147,7 @@ public class CommandContextTest {
public void testSlice() {
try {
CommandContext context = new CommandContext("foo bar baz");
assertArrayEquals(new String[] { "foo", "bar", "baz" }, context.getSlice(0));
assertArrayEquals(new String[]{"foo", "bar", "baz"}, context.getSlice(0));
} catch (CommandException e) {
LOGGER.warn("Error", e);
@ -165,4 +165,5 @@ public class CommandContextTest {
fail("Error creating CommandContext");
}
}
}

Datei anzeigen

@ -55,4 +55,5 @@ class CommandArgParserTest {
Substring.wrap("b", 2, 3)
), argParse("a b"));
}
}

Datei anzeigen

@ -122,4 +122,5 @@ class BaseExpressionTest {
expression.optimize();
return expression;
}
}

Datei anzeigen

@ -82,8 +82,10 @@ class ExpressionTest extends BaseExpressionTest {
assertEquals(8, compile("foo+bar", "foo", "bar").evaluate(5D, 3D), 0);
// variables need to be assigned first
EvaluationException ex = assertThrows(EvaluationException.class,
() -> simpleEval("a*=5"));
EvaluationException ex = assertThrows(
EvaluationException.class,
() -> simpleEval("a*=5")
);
assertTrue(ex.getMessage().contains("not initialized yet"));
// can't modify e, pi, true, false
@ -214,45 +216,63 @@ class ExpressionTest extends BaseExpressionTest {
public void testErrors() {
// test lexer errors
{
ExpressionException e = assertThrows(ExpressionException.class,
() -> compile("#"));
ExpressionException e = assertThrows(
ExpressionException.class,
() -> compile("#")
);
assertEquals(0, e.getPosition(), "Error position");
}
// test parser errors
{
ExpressionException e = assertThrows(ExpressionException.class,
() -> compile("x"));
ExpressionException e = assertThrows(
ExpressionException.class,
() -> compile("x")
);
assertEquals(0, e.getPosition(), "Error position");
}
{
ExpressionException e = assertThrows(ExpressionException.class,
() -> compile("x()"));
ExpressionException e = assertThrows(
ExpressionException.class,
() -> compile("x()")
);
assertEquals(0, e.getPosition(), "Error position");
}
{
// verify that you must return a value
ExpressionException e = assertThrows(ExpressionException.class,
() -> compile("return"));
ExpressionException e = assertThrows(
ExpressionException.class,
() -> compile("return")
);
assertEquals(6, e.getPosition(), "Error position");
}
assertThrows(ExpressionException.class,
() -> compile("("));
assertThrows(ExpressionException.class,
() -> compile("x("));
assertThrows(
ExpressionException.class,
() -> compile("(")
);
assertThrows(
ExpressionException.class,
() -> compile("x(")
);
// test overloader errors
{
ExpressionException e = assertThrows(ExpressionException.class,
() -> compile("atan2(1)"));
ExpressionException e = assertThrows(
ExpressionException.class,
() -> compile("atan2(1)")
);
assertEquals(0, e.getPosition(), "Error position");
}
{
ExpressionException e = assertThrows(ExpressionException.class,
() -> compile("atan2(1, 2, 3)"));
ExpressionException e = assertThrows(
ExpressionException.class,
() -> compile("atan2(1, 2, 3)")
);
assertEquals(0, e.getPosition(), "Error position");
}
{
ExpressionException e = assertThrows(ExpressionException.class,
() -> compile("rotate(1, 2, 3)"));
ExpressionException e = assertThrows(
ExpressionException.class,
() -> compile("rotate(1, 2, 3)")
);
assertEquals(7, e.getPosition(), "Error position");
}
@ -420,9 +440,11 @@ class ExpressionTest extends BaseExpressionTest {
@Test
public void testTimeout() {
ExpressionTimeoutException e = assertTimeoutPreemptively(Duration.ofSeconds(10), () ->
assertThrows(ExpressionTimeoutException.class,
assertThrows(
ExpressionTimeoutException.class,
() -> simpleEval("for(i=0;i<256;i++){for(j=0;j<256;j++){for(k=0;k<256;k++){for(l=0;l<256;l++){ln(pi)}}}}"),
"Loop was not stopped.")
"Loop was not stopped."
)
);
assertTrue(e.getMessage().contains("Calculations exceeded time limit"));
}

Datei anzeigen

@ -45,4 +45,5 @@ public class ExpressionTestCase {
public String toString() {
return expression + " -> " + result;
}
}

Datei anzeigen

@ -49,7 +49,8 @@ class RealExpressionTest extends BaseExpressionTest {
postChecks.accept(expr);
double data = readSlot(expr, "data");
assertEquals(expectedData, (int) data,
"Test case " + this + " failed (data)");
"Test case " + this + " failed (data)"
);
});
}
@ -57,6 +58,7 @@ class RealExpressionTest extends BaseExpressionTest {
public String toString() {
return loc + " -> " + result;
}
}
private static TestCase testCase(Vector3 loc, double result) {
@ -73,25 +75,29 @@ class RealExpressionTest extends BaseExpressionTest {
for (TestCase aCase : cases) {
Vector3 loc = aCase.loc;
assertEquals(aCase.result, compiled.evaluate(loc.getX(), loc.getY(), loc.getZ()), 0,
"Test case " + aCase + " failed (result)");
"Test case " + aCase + " failed (result)"
);
aCase.postChecks.accept(compiled);
}
}
@Test
void torus() {
checkExpression("(0.75-sqrt(x^2+y^2))^2+z^2 < 0.25^2",
checkExpression(
"(0.75-sqrt(x^2+y^2))^2+z^2 < 0.25^2",
testCase(Vector3.at(0, 0, 0), 0),
testCase(Vector3.at(0.5, 0.5, 0.5), 0),
testCase(Vector3.at(1, 0, 0), 0),
testCase(Vector3.at(0.5, 0.5, 0), 1),
testCase(Vector3.at(0.75, 0.5, 0), 1),
testCase(Vector3.at(0.75, 0, 0), 1));
testCase(Vector3.at(0.75, 0, 0), 1)
);
}
@Test
void gnarledOakTree() {
checkExpression("(0.5+sin(atan2(x,z)*8)*0.2)*(sqrt(x*x+z*z)/0.5)^(-2)-1.2 < y",
checkExpression(
"(0.5+sin(atan2(x,z)*8)*0.2)*(sqrt(x*x+z*z)/0.5)^(-2)-1.2 < y",
testCase(Vector3.at(-1, -1, -1), 1),
testCase(Vector3.at(-1, 0, 1), 1),
testCase(Vector3.at(1, 1, 1), 1),
@ -99,18 +105,21 @@ class RealExpressionTest extends BaseExpressionTest {
testCase(Vector3.at(0, 0, 0), 0),
testCase(Vector3.at(0, 1, 0), 0),
testCase(Vector3.at(0, 0, 0.32274), 0),
testCase(Vector3.at(0, 0, 0.32275), 1));
testCase(Vector3.at(0, 0, 0.32275), 1)
);
}
@Test
void rainbowTorus() {
checkExpression("data=(32+15/2/pi*atan2(x,y))%16; (0.75-sqrt(x^2+y^2))^2+z^2 < 0.25^2",
checkExpression(
"data=(32+15/2/pi*atan2(x,y))%16; (0.75-sqrt(x^2+y^2))^2+z^2 < 0.25^2",
testCase(Vector3.at(0, 0, 0), 0),
testCase(Vector3.at(0.5, 0.5, 0.5), 0),
testCase(Vector3.at(1, 0, 0), 0),
testCase(Vector3.at(0.5, 0.5, 0), 1).withData(1),
testCase(Vector3.at(0.75, 0.5, 0), 1).withData(2),
testCase(Vector3.at(0.75, 0, 0), 1).withData(3));
testCase(Vector3.at(0.75, 0, 0), 1).withData(3)
);
}
@Test
@ -123,48 +132,59 @@ class RealExpressionTest extends BaseExpressionTest {
testCases = Stream.concat(Stream.of(testCases), Stream.of(
testCase(Vector3.at(0, 1, 0), 0)
)).toArray(TestCase[]::new);
checkExpression("data=(32+y*16+1)%16; y^2/9+x^2/6*(1/(1-0.4*y))+z^2/6*(1/(1-0.4*y))<0.08",
testCases);
checkExpression(
"data=(32+y*16+1)%16; y^2/9+x^2/6*(1/(1-0.4*y))+z^2/6*(1/(1-0.4*y))<0.08",
testCases
);
}
@Test
void heart() {
checkExpression("(z/2)^2+x^2+(5*y/4-sqrt(abs(x)))^2<0.6",
checkExpression(
"(z/2)^2+x^2+(5*y/4-sqrt(abs(x)))^2<0.6",
testCase(Vector3.at(0, 0, -1), 1),
testCase(Vector3.at(0, 1, -1), 0),
testCase(Vector3.at(-0.5, 1, 0), 1));
testCase(Vector3.at(-0.5, 1, 0), 1)
);
}
@Test
void sineWave() {
checkExpression("sin(x*5)/2<y",
checkExpression(
"sin(x*5)/2<y",
testCase(Vector3.at(1, -0.47947, 0), 0),
testCase(Vector3.at(1, -0.47946, 0), 1),
testCase(Vector3.at(2, -0.27202, 0), 0),
testCase(Vector3.at(2, -0.27201, 0), 1),
testCase(Vector3.at(3, 0.32513, 0), 0),
testCase(Vector3.at(3, 0.32515, 0), 1));
testCase(Vector3.at(3, 0.32515, 0), 1)
);
}
@Test
void radialCosine() {
checkExpression("cos(sqrt(x^2+z^2)*5)/2<y",
checkExpression(
"cos(sqrt(x^2+z^2)*5)/2<y",
testCase(Vector3.at(0, 0.5, 0), 0),
testCase(Vector3.at(0, 0.51, 0), 1),
testCase(Vector3.at(Math.PI / 5, -0.5, 0), 0),
testCase(Vector3.at(Math.PI / 5, -0.49, 0), 1),
testCase(Vector3.at(Math.PI / 10, 0, 0), 0),
testCase(Vector3.at(Math.PI / 10, 0.1, 0), 1));
testCase(Vector3.at(Math.PI / 10, 0.1, 0), 1)
);
}
@Test
void circularHyperboloid() {
checkExpression("-(z^2/12)+(y^2/4)-(x^2/12)>-0.03",
checkExpression(
"-(z^2/12)+(y^2/4)-(x^2/12)>-0.03",
testCase(Vector3.at(0, 0, 0), 1),
testCase(Vector3.at(0, 1, 0), 1),
testCase(Vector3.at(0, 1, 1), 1),
testCase(Vector3.at(1, 1, 1), 1),
testCase(Vector3.at(0, 0, 1), 0),
testCase(Vector3.at(1, 0, 1), 0));
testCase(Vector3.at(1, 0, 1), 0)
);
}
}

Datei anzeigen

@ -28,6 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class DeprecationUtilTest {
public interface ModifiedApi {
@Deprecated
default boolean oldApi() {
return newApi();
@ -41,24 +42,30 @@ public class DeprecationUtilTest {
DeprecationUtil.checkDelegatingOverride(getClass());
return oldApi();
}
}
public static class OldImpl implements ModifiedApi {
@SuppressWarnings("deprecation")
@Override
public boolean oldApi() {
return false;
}
}
public static class NewImpl implements ModifiedApi {
@Override
public boolean newApi() {
return true;
}
}
public static class NewBadImpl implements ModifiedApi {
}
@Test

Datei anzeigen

@ -39,6 +39,7 @@ import static org.junit.jupiter.api.Assertions.fail;
* Verifies that {@link RegionOptimizedVectorSorter} sorts properly.
*/
public class RegionOptimizedVectorSorterTest {
/**
* Find factors, smallest to biggest.
*
@ -128,4 +129,5 @@ public class RegionOptimizedVectorSorterTest {
}
}
}
}

Datei anzeigen

@ -150,7 +150,7 @@ public class LocationTest {
World world = mock(World.class);
long start = System.currentTimeMillis();
BlockVector3 location1 = BlockVector3.ZERO;
location1.add(10,10,10);
location1.add(10, 10, 10);
System.out.println(System.currentTimeMillis() - start + " ms");
}

Datei anzeigen

@ -29,17 +29,21 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
abstract class PositionListTest {
static class Long extends PositionListTest {
@Override
protected PositionList createPositionList() {
return new LongPositionList();
}
}
static class Vector extends PositionListTest {
@Override
protected PositionList createPositionList() {
return new VectorPositionList();
}
}
private final VariedVectorGenerator generator = new VariedVectorGenerator(true);
@ -116,4 +120,5 @@ abstract class PositionListTest {
assertEquals(0, positionList.size());
});
}
}

Datei anzeigen

@ -69,4 +69,5 @@ public class EventBusTest {
eventBus.post(e2);
assertEquals(singletonList(e1), subscriber.events);
}
}

Datei anzeigen

@ -66,4 +66,5 @@ class MorePathsTest {
MorePaths.iterPaths(Paths.get("a")).collect(toList())
);
}
}

Datei anzeigen

@ -20,8 +20,10 @@
package com.sk89q.worldedit.util.test;
public class ResourceLockKeys {
public static final String WORLDEDIT_PLATFORM = "WORLDEDIT_PLATFORM";
private ResourceLockKeys() {
}
}

Datei anzeigen

@ -63,7 +63,8 @@ public class VariedVectorGenerator {
BlockVector3.at(-maxXZ, -maxY - 1, -maxXZ),
BlockVector3.at(maxXZ, -maxY - 1, maxXZ),
BlockVector3.at(-maxXZ, maxY, -maxXZ),
BlockVector3.at(maxXZ, maxY, maxXZ));
BlockVector3.at(maxXZ, maxY, maxXZ)
);
}
public Stream<BlockVector3> makeVectorsStream() {
@ -108,4 +109,5 @@ public class VariedVectorGenerator {
}
};
}
}

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.util.test;
import com.sk89q.worldedit.math.BlockVector3;
public class VariedVectorPair {
public final BlockVector3 first;
public final BlockVector3 second;
@ -29,4 +30,5 @@ public class VariedVectorPair {
this.first = first;
this.second = second;
}
}

Datei anzeigen

@ -36,6 +36,7 @@ import static com.sk89q.worldedit.world.snapshot.experimental.fs.FileSystemSnaps
import static com.sk89q.worldedit.world.snapshot.experimental.fs.FileSystemSnapshotDatabaseTest.REGION_DATA;
interface EntryMaker<T> {
EntryMaker<ZonedDateTime> TIMESTAMPED_DIR = (directory, time) -> {
Path timestampedDir = directory.resolve(time.format(FORMATTER));
Files.createDirectories(timestampedDir);
@ -63,6 +64,7 @@ interface EntryMaker<T> {
};
class DimInfo {
final String worldName;
final int dim;
@ -70,6 +72,7 @@ interface EntryMaker<T> {
this.worldName = worldName;
this.dim = dim;
}
}
EntryMaker<DimInfo> WORLD_DIM_DIR = (directory, dimInfo) -> {

Datei anzeigen

@ -24,13 +24,13 @@ import com.sk89q.worldedit.util.io.file.ArchiveDir;
import com.sk89q.worldedit.util.io.file.ArchiveNioSupport;
import com.sk89q.worldedit.world.snapshot.experimental.Snapshot;
import javax.annotation.Nullable;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.stream.Collectors.toList;
@ -75,8 +75,10 @@ class FSSDContext {
snapshots = snapshotStream.collect(toList());
}
try {
assertTrue(snapshots.size() <= 1,
"Too many snapshots matched for " + worldName);
assertTrue(
snapshots.size() <= 1,
"Too many snapshots matched for " + worldName
);
return requireSnapshot(name, snapshots.stream().findAny().orElse(null));
} catch (Throwable t) {
Closer closer = Closer.create();
@ -101,4 +103,5 @@ class FSSDContext {
return archiveNioSupport.tryOpenAsDir(archive)
.orElseThrow(() -> new AssertionError("No archive opener for " + archive));
}
}

Datei anzeigen

@ -54,10 +54,14 @@ enum FSSDTestType {
@Override
List<DynamicTest> getTests(FSSDContext context) {
return ImmutableList.of(
dynamicTest("return an empty stream from getSnapshots(worldName)",
() -> context.db.getSnapshots(WORLD_ALPHA)),
dynamicTest("return an empty optional from getSnapshot(name)",
() -> context.db.getSnapshot(context.nameUri(WORLD_ALPHA)))
dynamicTest(
"return an empty stream from getSnapshots(worldName)",
() -> context.db.getSnapshots(WORLD_ALPHA)
),
dynamicTest(
"return an empty optional from getSnapshot(name)",
() -> context.db.getSnapshot(context.nameUri(WORLD_ALPHA))
)
);
}
},
@ -120,15 +124,21 @@ enum FSSDTestType {
EntryMaker.WORLD_DIR.createEntry(timestampedDir, WORLD_ALPHA);
EntryMaker.WORLD_ARCHIVE.createEntry(timestampedDir, WORLD_BETA);
return ImmutableList.of(
dynamicContainer("world dir",
singleSnapTest(context,
dynamicContainer(
"world dir",
singleSnapTest(
context,
root.relativize(timestampedDir) + File.separator + WORLD_ALPHA,
TIME_ONE)
TIME_ONE
)
),
dynamicContainer("world archive",
singleSnapTest(context,
dynamicContainer(
"world archive",
singleSnapTest(
context,
root.relativize(timestampedDir) + File.separator + WORLD_BETA + ".zip",
TIME_ONE)
TIME_ONE
)
)
);
}
@ -144,10 +154,13 @@ enum FSSDTestType {
EntryMaker.WORLD_ARCHIVE.createEntry(timestampedDir.getPath(), WORLD_BETA);
}
return ImmutableList.of(
dynamicContainer("world dir",
singleSnapTest(context,
dynamicContainer(
"world dir",
singleSnapTest(
context,
root.relativize(timestampedArchive) + File.separator + WORLD_ALPHA,
TIME_ONE)
TIME_ONE
)
)
);
}
@ -163,15 +176,21 @@ enum FSSDTestType {
EntryMaker.WORLD_DIR.createEntry(timestampedDirA, WORLD_ALPHA);
EntryMaker.WORLD_ARCHIVE.createEntry(timestampedDirB, WORLD_BETA);
return ImmutableList.of(
dynamicContainer("world dir",
singleSnapTest(context,
dynamicContainer(
"world dir",
singleSnapTest(
context,
root.relativize(timestampedDirA) + File.separator + WORLD_ALPHA,
TIME_ONE)
TIME_ONE
)
),
dynamicContainer("world archive",
singleSnapTest(context,
dynamicContainer(
"world archive",
singleSnapTest(
context,
root.relativize(timestampedDirB) + File.separator + WORLD_BETA + ".zip",
TIME_ONE)
TIME_ONE
)
)
);
}
@ -251,8 +270,10 @@ enum FSSDTestType {
}
};
List<DynamicTest> singleSnapTest(FSSDContext context, String name,
ZonedDateTime time) {
List<DynamicTest> singleSnapTest(
FSSDContext context, String name,
ZonedDateTime time
) {
return ImmutableList.of(
dynamicTest("return a valid snapshot for " + name, () -> {
try (Snapshot snapshot = context.requireSnapshot(name)) {
@ -267,8 +288,10 @@ enum FSSDTestType {
);
}
private static void assertValidSnapshot(ZonedDateTime time,
Snapshot snapshot) throws IOException, DataException {
private static void assertValidSnapshot(
ZonedDateTime time,
Snapshot snapshot
) throws IOException, DataException {
assertEquals(time, snapshot.getInfo().getDateTime());
// MCA file
assertEquals(CHUNK_TAG.toString(), snapshot.getChunkTag(CHUNK_POS).toString());

Datei anzeigen

@ -142,14 +142,18 @@ class FileSystemSnapshotDatabaseTest {
try {
Path relative = root.getFileSystem().getPath("relative");
Files.createDirectories(relative);
FileSystemSnapshotDatabase db2 = new FileSystemSnapshotDatabase(relative,
ArchiveNioSupports.combined());
FileSystemSnapshotDatabase db2 = new FileSystemSnapshotDatabase(
relative,
ArchiveNioSupports.combined()
);
assertEquals(root.getFileSystem().getPath(".").toRealPath()
.resolve(relative), db2.getRoot());
Path absolute = root.resolve("absolute");
Files.createDirectories(absolute);
FileSystemSnapshotDatabase db3 = new FileSystemSnapshotDatabase(absolute,
ArchiveNioSupports.combined());
FileSystemSnapshotDatabase db3 = new FileSystemSnapshotDatabase(
absolute,
ArchiveNioSupports.combined()
);
assertEquals(absolute, db3.getRoot());
} finally {
deleteTree(root);
@ -178,8 +182,10 @@ class FileSystemSnapshotDatabaseTest {
});
}
private static Stream<? extends DynamicNode> getTests(ArchiveNioSupport nioSupport,
FSSDTestType type) throws IOException {
private static Stream<? extends DynamicNode> getTests(
ArchiveNioSupport nioSupport,
FSSDTestType type
) throws IOException {
Path root = newTempDb();
try {
Path dbRoot = root.resolve("snapshots");