From 3ec19120465fa25bd01046fc6d1f277a6ae03ab6 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 28 Dec 2021 23:22:59 +0000 Subject: [PATCH] Fix tests --- .../fastasyncworldedit/util/StubPlatform.java | 113 ++++++++++++++++++ .../util/RegionOptimizedVectorSorterTest.java | 6 + 2 files changed, 119 insertions(+) create mode 100644 worldedit-core/src/test/java/com/fastasyncworldedit/util/StubPlatform.java diff --git a/worldedit-core/src/test/java/com/fastasyncworldedit/util/StubPlatform.java b/worldedit-core/src/test/java/com/fastasyncworldedit/util/StubPlatform.java new file mode 100644 index 000000000..9d7ac96c2 --- /dev/null +++ b/worldedit-core/src/test/java/com/fastasyncworldedit/util/StubPlatform.java @@ -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 getCapabilities() { + Map capabilities = new EnumMap<>(Capability.class); + capabilities.put(Capability.WORLD_EDITING, Preference.PREFER_OTHERS); + return capabilities; + } + + @Override + public Set 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; + } + +} diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorterTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorterTest.java index bb4a26739..a1582bf04 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorterTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorterTest.java @@ -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 toSort; if (size == 0) {