mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-22 16:17:44 +00:00
x
This commit is contained in:
1 parent
1a6fff35e8
commit
11efae428f
56 files changed
+2052
-2694
No files matched your search
-7
@@ -4,8 +4,6 @@ import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.nms.INMSBinding;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineTarget;
|
||||
import art.arcane.iris.engine.platform.ChunkReplacementListener;
|
||||
import art.arcane.iris.engine.platform.ChunkReplacementOptions;
|
||||
import art.arcane.iris.engine.platform.PlatformChunkGenerator;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -15,7 +13,6 @@ import org.junit.Test;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -108,10 +105,6 @@ public class WorldLifecycleRuntimeLevelStemTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectChunkReplacement(World world, int x, int z, Executor syncExecutor, ChunkReplacementOptions options, ChunkReplacementListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.structure;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class BulkStructureImporterTemplateNameTest {
|
||||
@Test
|
||||
public void minecraftKeysDropTheNamespacePrefix() {
|
||||
assertEquals("village/plains", BulkStructureImporter.templateNameFor("minecraft:village/plains"));
|
||||
assertEquals("igloo/top", BulkStructureImporter.templateNameFor("minecraft:igloo/top"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void datapackKeysKeepNamespaceAsDirectory() {
|
||||
assertEquals("nova_structures/temple/large", BulkStructureImporter.templateNameFor("nova_structures:temple/large"));
|
||||
assertEquals("aquaculture/treasure", BulkStructureImporter.templateNameFor("aquaculture:treasure"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keyWithoutNamespaceDefaultsToMinecraft() {
|
||||
assertEquals("village", BulkStructureImporter.templateNameFor("village"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pathIsLowercasedAndSanitized() {
|
||||
assertEquals("nova/foo_bar", BulkStructureImporter.templateNameFor("nova:Foo Bar"));
|
||||
assertEquals("nova/weird_name", BulkStructureImporter.templateNameFor("nova:weird@name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void duplicateSlashesAreCollapsedAndLeadingSlashStripped() {
|
||||
assertEquals("nova/a/b", BulkStructureImporter.templateNameFor("nova:a//b"));
|
||||
assertEquals("nova/leading", BulkStructureImporter.templateNameFor("nova:/leading"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.structure;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class StructureImporterModeTest {
|
||||
@Test
|
||||
public void parseModeDefaultsToOverwriteForNull() {
|
||||
assertEquals(StructureImporter.Mode.OVERWRITE, StructureImporter.parseMode(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseModeDefaultsToOverwriteForUnknownAndEmpty() {
|
||||
assertEquals(StructureImporter.Mode.OVERWRITE, StructureImporter.parseMode(""));
|
||||
assertEquals(StructureImporter.Mode.OVERWRITE, StructureImporter.parseMode("garbage"));
|
||||
assertEquals(StructureImporter.Mode.OVERWRITE, StructureImporter.parseMode("overwrite"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseModeRecognizesAllAddOnlyAliases() {
|
||||
assertEquals(StructureImporter.Mode.ADD_ONLY, StructureImporter.parseMode("add"));
|
||||
assertEquals(StructureImporter.Mode.ADD_ONLY, StructureImporter.parseMode("addonly"));
|
||||
assertEquals(StructureImporter.Mode.ADD_ONLY, StructureImporter.parseMode("add_only"));
|
||||
assertEquals(StructureImporter.Mode.ADD_ONLY, StructureImporter.parseMode("add-only"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseModeIsCaseInsensitive() {
|
||||
assertEquals(StructureImporter.Mode.ADD_ONLY, StructureImporter.parseMode("ADD"));
|
||||
assertEquals(StructureImporter.Mode.MERGE, StructureImporter.parseMode("MERGE"));
|
||||
assertEquals(StructureImporter.Mode.MERGE, StructureImporter.parseMode("merge"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deriveNameFromStringLowercasesAndNormalizesSeparators() {
|
||||
assertEquals("minecraft_village_plains", StructureImporter.deriveName("minecraft:village/plains"));
|
||||
assertEquals("nova_structures_temple", StructureImporter.deriveName("Nova_Structures:Temple"));
|
||||
assertEquals("minecraft_ancient_city", StructureImporter.deriveName("minecraft:ancient_city"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deriveNameFromNamespacedKeyJoinsNamespaceAndPath() {
|
||||
assertEquals("minecraft_village", StructureImporter.deriveName(NamespacedKey.minecraft("village")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deriveNameFromNamespacedKeyNormalizesSlashesInPath() {
|
||||
NamespacedKey key = NamespacedKey.fromString("nova_structures:temple/large");
|
||||
assertEquals("nova_structures_temple_large", StructureImporter.deriveName(key));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.core.structure;
|
||||
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class StructureSchemaKeysTest {
|
||||
@Test
|
||||
public void vanillaKeysAreNormalizedToIrisLoadKeyForm() {
|
||||
KList<String> result = StructureSchemaKeys.collect(
|
||||
Arrays.asList("minecraft:village_plains", "minecraft:stronghold", "minecraft:ancient_city"),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList());
|
||||
|
||||
assertTrue(result.contains("minecraft_village_plains"));
|
||||
assertTrue(result.contains("minecraft_stronghold"));
|
||||
assertTrue(result.contains("minecraft_ancient_city"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void strongholdIsAlwaysOfferedEvenWithoutAnImportedFile() {
|
||||
KList<String> result = StructureSchemaKeys.collect(
|
||||
Arrays.asList("minecraft:stronghold", "minecraft:fortress", "minecraft:monument"),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList());
|
||||
|
||||
assertTrue(result.contains("minecraft_stronghold"));
|
||||
assertTrue(result.contains("minecraft_fortress"));
|
||||
assertTrue(result.contains("minecraft_monument"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void datapackStructuresAreNormalizedAndIncluded() {
|
||||
KList<String> result = StructureSchemaKeys.collect(
|
||||
Arrays.asList("nova_structures:temple", "Nova_Structures:Big/Castle"),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList());
|
||||
|
||||
assertTrue(result.contains("nova_structures_temple"));
|
||||
assertTrue(result.contains("nova_structures_big_castle"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jigsawComponentPiecesAreExcluded() {
|
||||
List<String> pieces = Arrays.asList(
|
||||
"village/taiga/houses/taiga_small_house_5",
|
||||
"bastion/units/rampart_plates/plate_0",
|
||||
"village/common/animals/cat_black",
|
||||
"trial_chambers/corridor/straight_1",
|
||||
"end_city/third_floor_1",
|
||||
"igloo/middle");
|
||||
|
||||
KList<String> result = StructureSchemaKeys.collect(
|
||||
Arrays.asList("minecraft:village_taiga", "minecraft:bastion_remnant"),
|
||||
pieces,
|
||||
pieces);
|
||||
|
||||
for (String piece : pieces) {
|
||||
assertFalse("component piece must not be a valid structure key: " + piece, result.contains(piece));
|
||||
}
|
||||
assertTrue(result.contains("minecraft_village_taiga"));
|
||||
assertTrue(result.contains("minecraft_bastion_remnant"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importedCustomStructuresAreKept() {
|
||||
KList<String> result = StructureSchemaKeys.collect(
|
||||
Collections.emptyList(),
|
||||
Arrays.asList("mypack_castle", "custom/cool_tower"),
|
||||
Collections.emptyList());
|
||||
|
||||
assertTrue(result.contains("mypack_castle"));
|
||||
assertTrue(result.contains("custom/cool_tower"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importedStructureThatCollidesWithAPieceIsDropped() {
|
||||
KList<String> result = StructureSchemaKeys.collect(
|
||||
Collections.emptyList(),
|
||||
Arrays.asList("village/taiga/houses/taiga_small_house_5", "minecraft_village_plains"),
|
||||
Collections.singletonList("village/taiga/houses/taiga_small_house_5"));
|
||||
|
||||
assertFalse(result.contains("village/taiga/houses/taiga_small_house_5"));
|
||||
assertTrue(result.contains("minecraft_village_plains"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void vanillaAndImportedEquivalentsDeduplicate() {
|
||||
KList<String> result = StructureSchemaKeys.collect(
|
||||
Collections.singletonList("minecraft:ancient_city"),
|
||||
Collections.singletonList("minecraft_ancient_city"),
|
||||
Collections.emptyList());
|
||||
|
||||
int occurrences = 0;
|
||||
for (String key : result) {
|
||||
if (key.equals("minecraft_ancient_city")) {
|
||||
occurrences++;
|
||||
}
|
||||
}
|
||||
assertEquals(1, occurrences);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resultIsSorted() {
|
||||
KList<String> result = StructureSchemaKeys.collect(
|
||||
Arrays.asList("minecraft:zombie_village", "minecraft:ancient_city", "minecraft:monument"),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList());
|
||||
|
||||
KList<String> sorted = new KList<>(result);
|
||||
Collections.sort(sorted);
|
||||
assertEquals(sorted, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullCollectionsAreHandled() {
|
||||
KList<String> result = StructureSchemaKeys.collect(null, null, null);
|
||||
assertTrue(result.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void blankAndNullEntriesAreIgnored() {
|
||||
KList<String> result = StructureSchemaKeys.collect(
|
||||
Arrays.asList("minecraft:village_plains", "", null, " "),
|
||||
Arrays.asList("custom_one", "", null),
|
||||
Arrays.asList("", null));
|
||||
|
||||
assertTrue(result.contains("minecraft_village_plains"));
|
||||
assertTrue(result.contains("custom_one"));
|
||||
assertEquals(2, result.size());
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class IrisStructureLocatorContractTest {
|
||||
@Test
|
||||
public void placedKeysIsEmptyForNullEngine() {
|
||||
assertTrue(IrisStructureLocator.placedKeys(null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPlacedIsFalseForNullEngine() {
|
||||
assertFalse(IrisStructureLocator.isPlaced(null, "minecraft:ancient_city"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPlacedIsFalseForNullOrEmptyKey() {
|
||||
Engine engine = mock(Engine.class);
|
||||
assertFalse(IrisStructureLocator.isPlaced(engine, null));
|
||||
assertFalse(IrisStructureLocator.isPlaced(engine, ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suppressesVanillaIsFalseForNullEngine() {
|
||||
assertFalse(IrisStructureLocator.suppressesVanilla(null, "minecraft:ancient_city"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suppressesVanillaIsFalseForNullOrEmptyKey() {
|
||||
Engine engine = mock(Engine.class);
|
||||
assertFalse(IrisStructureLocator.suppressesVanilla(engine, null));
|
||||
assertFalse(IrisStructureLocator.suppressesVanilla(engine, ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startsInChunkIsFalseForNullEngine() {
|
||||
assertFalse(IrisStructureLocator.startsInChunk(null, "minecraft:ancient_city", 0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void locateReturnsNullForNullEngine() {
|
||||
assertNull(IrisStructureLocator.locate(null, "minecraft:village_taiga", 0, 0, 100));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void locateReturnsNullForNullOrEmptyKey() {
|
||||
Engine engine = mock(Engine.class);
|
||||
assertNull(IrisStructureLocator.locate(engine, null, 0, 0, 100));
|
||||
assertNull(IrisStructureLocator.locate(engine, "", 0, 0, 100));
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.framework;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class StructureReachabilityContractTest {
|
||||
@Test
|
||||
public void reachableKeysIsEmptyForNullEngine() {
|
||||
assertTrue(StructureReachability.reachableKeys(null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reachableKeysIsEmptyWhenEngineHasNoData() {
|
||||
Engine engine = mock(Engine.class);
|
||||
assertTrue(StructureReachability.reachableKeys(engine).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isReachableIsFalseForNullEngine() {
|
||||
assertFalse(StructureReachability.isReachable(null, "minecraft:village_taiga"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isReachableIsFalseForNullOrEmptyKey() {
|
||||
Engine engine = mock(Engine.class);
|
||||
assertFalse(StructureReachability.isReachable(engine, null));
|
||||
assertFalse(StructureReachability.isReachable(engine, ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isReachableIsFalseWhenNothingIsReachable() {
|
||||
Engine engine = mock(Engine.class);
|
||||
assertFalse(StructureReachability.isReachable(engine, "minecraft:village_taiga"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingBiomeKeysIsEmptyForNullEngine() {
|
||||
assertTrue(StructureReachability.missingBiomeKeys(null, "minecraft:village_taiga").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingBiomeKeysIsEmptyForNullKey() {
|
||||
Engine engine = mock(Engine.class);
|
||||
assertTrue(StructureReachability.missingBiomeKeys(engine, null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingBiomeKeysIsEmptyWhenWorldUnavailable() {
|
||||
Engine engine = mock(Engine.class);
|
||||
assertTrue(StructureReachability.missingBiomeKeys(engine, "minecraft:village_taiga").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidateIsNullSafe() {
|
||||
StructureReachability.invalidate(null);
|
||||
StructureReachability.invalidate(mock(Engine.class));
|
||||
}
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object;
|
||||
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class IrisImportedStructureControlTest {
|
||||
private static KList<String> keys(String... values) {
|
||||
KList<String> list = new KList<>();
|
||||
for (String value : values) {
|
||||
list.add(value);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultModeGeneratesEveryVanillaStructure() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl();
|
||||
assertTrue(control.shouldGenerate("minecraft:village_plains"));
|
||||
assertTrue(control.shouldGenerate("minecraft:stronghold"));
|
||||
assertTrue(control.shouldGenerate("minecraft:ocean_monument"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultModeGeneratesDatapackStructures() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl();
|
||||
assertTrue(control.isDatapackOverrides());
|
||||
assertTrue(control.shouldGenerate("nova_structures:desert_temple"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disabledBlacklistMatchesExactKey() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setDisabled(keys("minecraft:stronghold"));
|
||||
assertFalse(control.shouldGenerate("minecraft:stronghold"));
|
||||
assertTrue(control.shouldGenerate("minecraft:village_plains"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disabledBlacklistMatchesNamespacePrefix() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setDisabled(keys("minecraft:village"));
|
||||
assertFalse(control.shouldGenerate("minecraft:village_plains"));
|
||||
assertFalse(control.shouldGenerate("minecraft:village_taiga"));
|
||||
assertFalse(control.shouldGenerate("minecraft:village_snowy"));
|
||||
assertTrue(control.shouldGenerate("minecraft:stronghold"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allOffWhitelistMatchesExactKey() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setMode(VanillaStructureMode.ALL_OFF)
|
||||
.setEnabled(keys("minecraft:village_plains"));
|
||||
assertTrue(control.shouldGenerate("minecraft:village_plains"));
|
||||
assertFalse(control.shouldGenerate("minecraft:village_taiga"));
|
||||
assertFalse(control.shouldGenerate("minecraft:stronghold"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allOffWhitelistMatchesNamespacePrefix() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setMode(VanillaStructureMode.ALL_OFF)
|
||||
.setEnabled(keys("minecraft:village"));
|
||||
assertTrue(control.shouldGenerate("minecraft:village_taiga"));
|
||||
assertTrue(control.shouldGenerate("minecraft:village_desert"));
|
||||
assertFalse(control.shouldGenerate("minecraft:stronghold"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customModeBehavesLikeWhitelist() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setMode(VanillaStructureMode.CUSTOM)
|
||||
.setEnabled(keys("minecraft:village_plains"));
|
||||
assertTrue(control.shouldGenerate("minecraft:village_plains"));
|
||||
assertFalse(control.shouldGenerate("minecraft:stronghold"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void datapackOverridesFalseBlocksDatapackKeysWhileAllOn() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setDatapackOverrides(false);
|
||||
assertFalse(control.shouldGenerate("nova_structures:desert_temple"));
|
||||
assertFalse(control.shouldGenerate("aquaculture:treasure_vault"));
|
||||
assertTrue(control.shouldGenerate("minecraft:village_plains"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void datapackOverridesFalseBlocksDatapackKeyEvenWhenWhitelisted() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setMode(VanillaStructureMode.ALL_OFF)
|
||||
.setEnabled(keys("nova_structures:desert_temple", "minecraft:village_plains"))
|
||||
.setDatapackOverrides(false);
|
||||
assertFalse(control.shouldGenerate("nova_structures:desert_temple"));
|
||||
assertTrue(control.shouldGenerate("minecraft:village_plains"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void datapackOverridesTrueAllowsDatapackKeysWhileAllOn() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setDatapackOverrides(true);
|
||||
assertTrue(control.shouldGenerate("nova_structures:desert_temple"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keyWithoutNamespaceIsNotTreatedAsDatapack() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setDatapackOverrides(false);
|
||||
assertTrue(control.shouldGenerate("village_plains"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void minecraftKeyIsNeverTreatedAsDatapack() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setDatapackOverrides(false);
|
||||
assertTrue(control.shouldGenerate("minecraft:ancient_city"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void activeTrueWhenAllOn() {
|
||||
assertTrue(new IrisImportedStructureControl().active());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void activeFalseWhenAllOffWithoutWhitelist() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setMode(VanillaStructureMode.ALL_OFF);
|
||||
assertFalse(control.active());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void activeTrueWhenAllOffWithWhitelist() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setMode(VanillaStructureMode.ALL_OFF)
|
||||
.setEnabled(keys("minecraft:village_plains"));
|
||||
assertTrue(control.active());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void activeFalseWhenCustomWithoutWhitelist() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setMode(VanillaStructureMode.CUSTOM);
|
||||
assertFalse(control.active());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyOrNullListEntriesNeverMatchEveryKey() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setDisabled(keys("", null));
|
||||
assertTrue(control.shouldGenerate("minecraft:village_plains"));
|
||||
assertTrue(control.shouldGenerate("minecraft:stronghold"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullKeyIsNullSafeAndNotWhitelisted() {
|
||||
IrisImportedStructureControl control = new IrisImportedStructureControl()
|
||||
.setMode(VanillaStructureMode.ALL_OFF)
|
||||
.setEnabled(keys("minecraft:village_plains"));
|
||||
assertFalse(control.shouldGenerate(null));
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package art.arcane.iris.engine.platform;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class BukkitChunkGeneratorOverlayPolicyTest {
|
||||
@Test
|
||||
public void skipsAirOverlayBlocks() {
|
||||
BlockData air = mock(BlockData.class);
|
||||
doReturn(Material.AIR).when(air).getMaterial();
|
||||
|
||||
assertFalse(BukkitChunkGenerator.shouldApplyMantleOverlayBlock(air));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipsCaveAirOverlayBlocks() {
|
||||
BlockData air = mock(BlockData.class);
|
||||
doReturn(Material.CAVE_AIR).when(air).getMaterial();
|
||||
|
||||
assertFalse(BukkitChunkGenerator.shouldApplyMantleOverlayBlock(air));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipsVoidAirOverlayBlocks() {
|
||||
BlockData air = mock(BlockData.class);
|
||||
doReturn(Material.VOID_AIR).when(air).getMaterial();
|
||||
|
||||
assertFalse(BukkitChunkGenerator.shouldApplyMantleOverlayBlock(air));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appliesSolidOverlayBlocks() {
|
||||
BlockData stone = mock(BlockData.class);
|
||||
doReturn(Material.STONE).when(stone).getMaterial();
|
||||
|
||||
assertTrue(BukkitChunkGenerator.shouldApplyMantleOverlayBlock(stone));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipsNullOverlayBlocks() {
|
||||
assertFalse(BukkitChunkGenerator.shouldApplyMantleOverlayBlock(null));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user