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