Updates MockBukkit, and fixes some test-related issues
Fixes JUnit 5's After being used instead of AfterEach Fixes a potential NullPointerException when tearing down GateLayoutTest
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -66,8 +66,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.seeseemelk</groupId>
|
||||
<artifactId>MockBukkit-v1.18</artifactId>
|
||||
<version>2.85.2</version>
|
||||
<artifactId>MockBukkit-v1.20</artifactId>
|
||||
<version>3.78.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@@ -65,23 +65,22 @@ public class ConfigTabCompleter implements TabCompleter {
|
||||
private List<String> getPossibleOptionValues(@NotNull ConfigOption selectedOption,
|
||||
@NotNull String typedText) {
|
||||
switch (selectedOption) {
|
||||
case LANGUAGE:
|
||||
case LANGUAGE -> {
|
||||
//Return available languages
|
||||
return filterMatchingStartsWith(languages, typedText);
|
||||
case GATE_FOLDER:
|
||||
case PORTAL_FOLDER:
|
||||
case DEFAULT_GATE_NETWORK:
|
||||
}
|
||||
case GATE_FOLDER, PORTAL_FOLDER, DEFAULT_GATE_NETWORK -> {
|
||||
//Just return the default value as most values should be possible
|
||||
if (typedText.trim().isEmpty()) {
|
||||
return List.of((String) selectedOption.getDefaultValue());
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
case MAIN_SIGN_COLOR:
|
||||
case HIGHLIGHT_SIGN_COLOR:
|
||||
case FREE_GATES_COLOR:
|
||||
}
|
||||
case MAIN_SIGN_COLOR, HIGHLIGHT_SIGN_COLOR, FREE_GATES_COLOR -> {
|
||||
//Return all colors
|
||||
return filterMatchingStartsWith(chatColors, typedText);
|
||||
}
|
||||
}
|
||||
|
||||
//If the config value is a boolean, show the two boolean values
|
||||
|
@@ -4,7 +4,7 @@ import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
import be.seeseemelk.mockbukkit.WorldMock;
|
||||
import net.knarcraft.stargate.container.BlockLocation;
|
||||
import org.bukkit.Material;
|
||||
import org.junit.After;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class BlockLocationTest {
|
||||
mockWorld = new WorldMock(Material.DIRT, 5);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
MockBukkit.unmock();
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ import net.knarcraft.stargate.portal.property.gate.Gate;
|
||||
import net.knarcraft.stargate.portal.property.gate.GateHandler;
|
||||
import net.knarcraft.stargate.portal.property.gate.GateLayout;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -39,7 +40,10 @@ public class GateLayoutTest {
|
||||
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
MockBukkit.getMock().getPluginManager().disablePlugins();
|
||||
@Nullable ServerMock mock = MockBukkit.getMock();
|
||||
if (mock != null) {
|
||||
mock.getPluginManager().disablePlugins();
|
||||
}
|
||||
MockBukkit.unmock();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user