Fix tests

This commit is contained in:
dordsor21 2021-12-28 23:22:59 +00:00
parent 36857a5064
commit 3ec1912046
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,113 @@
package com.fastasyncworldedit.util;
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.AbstractPlatform;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Preference;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.registry.Registries;
import org.enginehub.piston.CommandManager;
import org.jetbrains.annotations.Nullable;
import java.util.EnumMap;
import java.util.Map;
import java.util.Set;
public class StubPlatform extends AbstractPlatform {
@Override
public Registries getRegistries() {
return null;
}
@Override
public int getDataVersion() {
return Constants.DATA_VERSION_MC_1_18;
}
@Override
public boolean isValidMobType(final String type) {
return false;
}
@Override
public void reload() {
}
@Nullable
@Override
public Player matchPlayer(final Player player) {
return null;
}
@Nullable
@Override
public World matchWorld(final World world) {
return null;
}
@Override
public void registerCommands(final CommandManager commandManager) {
}
@Override
public void setGameHooksEnabled(final boolean enabled) {
}
@Override
public LocalConfiguration getConfiguration() {
return null;
}
@Override
public String getVersion() {
return "TEST";
}
@Override
public String getPlatformName() {
return "TEST";
}
@Override
public String getPlatformVersion() {
return "TEST";
}
@Override
public Map<Capability, Preference> getCapabilities() {
Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class);
capabilities.put(Capability.WORLD_EDITING, Preference.PREFER_OTHERS);
return capabilities;
}
@Override
public Set<SideEffect> getSupportedSideEffects() {
return null;
}
@Override
public RelighterFactory getRelighterFactory() {
return null;
}
// Use most "extreme" value
@Override
public int getVersionMinY() {
return -64;
}
// Use most "extreme" value
@Override
public int getVersionMaxY() {
return 319;
}
}

View File

@ -19,7 +19,9 @@
package com.sk89q.worldedit.internal.util;
import com.fastasyncworldedit.util.StubPlatform;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import it.unimi.dsi.fastutil.ints.IntRBTreeSet;
@ -71,6 +73,10 @@ public class RegionOptimizedVectorSorterTest {
0, 1, 10, 100, 1_000, 10_000, 100_000, 1_000_000, 10_000_000
})
void checkSorted(int size) {
//FAWE start - required for AbstractRegion recalculation testing height limits with null world
WorldEdit.getInstance().getPlatformManager().register(new StubPlatform());
WorldEdit.getInstance().getPlatformManager().handlePlatformsRegistered(null);
//FAWE end
Random rng = new Random(size);
List<BlockVector3> toSort;
if (size == 0) {