org.jetbrains
annotations
diff --git a/src/main/java/net/knarcraft/stargate/utility/SignHelper.java b/src/main/java/net/knarcraft/stargate/utility/SignHelper.java
index 30ce624..f76acc9 100644
--- a/src/main/java/net/knarcraft/stargate/utility/SignHelper.java
+++ b/src/main/java/net/knarcraft/stargate/utility/SignHelper.java
@@ -1,6 +1,5 @@
package net.knarcraft.stargate.utility;
-import net.knarcraft.stargate.Stargate;
import org.bukkit.DyeColor;
import org.bukkit.block.Sign;
import org.bukkit.block.sign.Side;
@@ -12,8 +11,6 @@ import org.jetbrains.annotations.Nullable;
*/
public final class SignHelper {
- private static final boolean HAS_SIGN_SIDES = hasSignSides();
-
private SignHelper() {
}
@@ -26,13 +23,7 @@ public final class SignHelper {
*/
@NotNull
public static String[] getLines(@NotNull Sign sign) {
- if (HAS_SIGN_SIDES) {
- return sign.getSide(Side.FRONT).getLines();
- } else {
- // Note: This is depreciated, but is currently necessary for pre-1.19.4 support
- //noinspection deprecation
- return sign.getLines();
- }
+ return sign.getSide(Side.FRONT).getLines();
}
/**
@@ -43,13 +34,7 @@ public final class SignHelper {
*/
@Nullable
public static DyeColor getDye(@NotNull Sign sign) {
- if (HAS_SIGN_SIDES) {
- return sign.getSide(Side.FRONT).getColor();
- } else {
- // Note: This is depreciated, but is currently necessary for pre-1.19.4 support
- //noinspection deprecation
- return sign.getColor();
- }
+ return sign.getSide(Side.FRONT).getColor();
}
/**
@@ -60,29 +45,7 @@ public final class SignHelper {
* @param text The text to set
*/
public static void setSignLine(@NotNull Sign sign, int line, @NotNull String text) {
- if (HAS_SIGN_SIDES) {
- sign.getSide(Side.FRONT).setLine(line, text);
- } else {
- // Note: This is depreciated, but is currently necessary for pre-1.19.4 support
- //noinspection deprecation
- sign.setLine(line, text);
- }
- }
-
- /**
- * Checks whether the running version differentiates between the front or back of a sign
- *
- * @return True if the server supports sign side differentiation
- */
- private static boolean hasSignSides() {
- try {
- Class> aClass = Class.forName("org.bukkit.block.Sign");
- aClass.getMethod("getSide", Side.class);
- return true;
- } catch (ClassNotFoundException | NoSuchMethodException ignored) {
- Stargate.debug("SignHelper::hasSignSides", "Detected legacy Spigot");
- return false;
- }
+ sign.getSide(Side.FRONT).setLine(line, text);
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 0077c5e..ac87012 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -5,7 +5,7 @@ description: The original, and still the best, MineCraft transportation solution
author: EpicKnarvik97
authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]
website: https://sgrewritten.org/legacygit
-api-version: 1.16
+api-version: 1.20
softdepend: [ Vault, dynmap, Geyser-Spigot, floodgate ]
commands:
stargate:
diff --git a/src/test/java/net/knarcraft/stargate/BlockLocationTest.java b/src/test/java/net/knarcraft/stargate/BlockLocationTest.java
deleted file mode 100644
index 61ddc86..0000000
--- a/src/test/java/net/knarcraft/stargate/BlockLocationTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package net.knarcraft.stargate;
-
-import be.seeseemelk.mockbukkit.MockBukkit;
-import be.seeseemelk.mockbukkit.WorldMock;
-import net.knarcraft.stargate.container.BlockLocation;
-import org.bukkit.Material;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-
-public class BlockLocationTest {
- private WorldMock mockWorld;
-
- @BeforeEach
- public void setUp() {
- mockWorld = new WorldMock(Material.DIRT, 5);
- }
-
- @AfterEach
- public void tearDown() {
- MockBukkit.unmock();
- }
-
- @Test
- public void equalsTest() {
- BlockLocation location1 = new BlockLocation(mockWorld, 1, 3, 4);
- BlockLocation location2 = new BlockLocation(mockWorld, 1, 3, 4);
- assertEquals(location1, location2);
- }
-
- @Test
- public void notEqualsTest1() {
- BlockLocation location1 = new BlockLocation(mockWorld, 1, 3, 4);
- BlockLocation location2 = new BlockLocation(mockWorld, 2, 3, 4);
- assertNotEquals(location1, location2);
- }
-
- @Test
- public void notEqualsTest2() {
- BlockLocation location1 = new BlockLocation(mockWorld, 1, 3, 4);
- BlockLocation location2 = new BlockLocation(mockWorld, 1, 5, 4);
- assertNotEquals(location1, location2);
- }
-
- @Test
- public void notEqualsTest3() {
- BlockLocation location1 = new BlockLocation(mockWorld, 1, 3, 4);
- BlockLocation location2 = new BlockLocation(mockWorld, 1, 3, 7);
- assertNotEquals(location1, location2);
- }
-
- @Test
- public void notEqualsTest4() {
- BlockLocation location1 = new BlockLocation(mockWorld, 1, 3, 4);
- BlockLocation location2 = new BlockLocation(new WorldMock(Material.DIRT, 4), 1, 3, 4);
- assertNotEquals(location1, location2);
- }
-
- @Test
- public void makeRelativeTest() {
- BlockLocation location = new BlockLocation(mockWorld, 3, 7, 19);
- BlockLocation newLocation = location.makeRelativeBlockLocation(34, 65, 75);
- assertEquals(37, newLocation.getBlockX());
- assertEquals(72, newLocation.getBlockY());
- assertEquals(94, newLocation.getBlockZ());
- }
-
- @Test
- public void materialTest() {
- BlockLocation location = new BlockLocation(mockWorld, 0, 0, 0);
- assertNotEquals(Material.BOOKSHELF, location.getType());
- location.setType(Material.BOOKSHELF);
- assertEquals(Material.BOOKSHELF, location.getType());
- }
-
- @Test
- public void toStringTest() {
- BlockLocation location = new BlockLocation(mockWorld, 56, 87, 34);
- assertEquals("56,87,34", location.toString());
- }
-
-}
diff --git a/src/test/java/net/knarcraft/stargate/container/BlockLocationTest.java b/src/test/java/net/knarcraft/stargate/container/BlockLocationTest.java
deleted file mode 100644
index 520627a..0000000
--- a/src/test/java/net/knarcraft/stargate/container/BlockLocationTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package net.knarcraft.stargate.container;
-
-import be.seeseemelk.mockbukkit.WorldMock;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class BlockLocationTest {
-
- @Test
- public void makeRelativeBlockLocationTest() {
- WorldMock world = new WorldMock();
- BlockLocation startLocation = new BlockLocation(world, 5, 4, 3);
-
- //Move to some other, different location
- BlockLocation relativeLocation = startLocation.makeRelativeBlockLocation(4, 6, 8);
- Assertions.assertNotEquals(startLocation, relativeLocation);
-
- //Move back to make sure we can go back to where we started by going in the opposite direction
- BlockLocation sameAsStartLocation = relativeLocation.makeRelativeBlockLocation(-4, -6, -8);
- Assertions.assertEquals(startLocation, sameAsStartLocation);
- }
-
- @Test
- public void getRelativeLocationTest() {
- WorldMock world = new WorldMock();
- BlockLocation startLocation = new BlockLocation(world, 7, 3, 6);
-
- RelativeBlockVector relativeBlockVector = new RelativeBlockVector(2, 1, 3);
- BlockLocation relativeLocation1 = startLocation.getRelativeLocation(relativeBlockVector, 0);
- //With yaw = 0, going right goes in the x direction, and out goes in the z direction, while y is decremented
- BlockLocation targetLocation1 = new BlockLocation(world, 9, 2, 9);
- Assertions.assertEquals(targetLocation1, relativeLocation1);
-
- BlockLocation relativeLocation2 = startLocation.getRelativeLocation(relativeBlockVector, 90);
- //With yaw = 90, going right goes in the z direction, and out goes in the -x direction, while y is decremented
- BlockLocation targetLocation2 = new BlockLocation(world, 4, 2, 8);
- Assertions.assertEquals(targetLocation2, relativeLocation2);
-
- BlockLocation relativeLocation3 = startLocation.getRelativeLocation(relativeBlockVector, 180);
- //With yaw = 180, going right goes in the -x direction, and out goes in the -z direction, while y is decremented
- BlockLocation targetLocation3 = new BlockLocation(world, 5, 2, 3);
- Assertions.assertEquals(targetLocation3, relativeLocation3);
-
- BlockLocation relativeLocation4 = startLocation.getRelativeLocation(relativeBlockVector, 270);
- //With yaw = 270, going right goes in the -z direction, and out goes in the x direction, while y is decremented
- BlockLocation targetLocation4 = new BlockLocation(world, 10, 2, 4);
- Assertions.assertEquals(targetLocation4, relativeLocation4);
- }
-
-}
diff --git a/src/test/java/net/knarcraft/stargate/portal/GateLayoutTest.java b/src/test/java/net/knarcraft/stargate/portal/GateLayoutTest.java
deleted file mode 100644
index acb613e..0000000
--- a/src/test/java/net/knarcraft/stargate/portal/GateLayoutTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package net.knarcraft.stargate.portal;
-
-import be.seeseemelk.mockbukkit.MockBukkit;
-import be.seeseemelk.mockbukkit.ServerMock;
-import be.seeseemelk.mockbukkit.WorldMock;
-import net.knarcraft.stargate.Stargate;
-import net.knarcraft.stargate.container.RelativeBlockVector;
-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;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class GateLayoutTest {
-
- private static GateLayout layout;
-
- @BeforeAll
- public static void setUp() {
- ServerMock server = MockBukkit.mock();
- server.addWorld(new WorldMock(Material.DIRT, 5));
- System.setProperty("bstats.relocatecheck", "false");
- MockBukkit.load(Stargate.class);
- Gate gate = GateHandler.getGateByName("nethergate.gate");
- if (gate != null) {
- layout = gate.getLayout();
- } else {
- throw new IllegalStateException("Could not set up tests, because nethergate.gate is unavailable");
- }
- }
-
- @AfterAll
- public static void tearDown() {
- @Nullable ServerMock mock = MockBukkit.getMock();
- if (mock != null) {
- mock.getPluginManager().disablePlugins();
- }
- MockBukkit.unmock();
- }
-
- @Test
- public void gateLayoutExitTest() {
- assertEquals(new RelativeBlockVector(1, 3, 0), layout.getExit());
- }
-
- @Test
- public void gateLayoutExitsTest() {
- List expected = new ArrayList<>();
- expected.add(new RelativeBlockVector(1, 3, 0));
- expected.add(new RelativeBlockVector(2, 3, 0));
-
- List exits = layout.getExits();
- exits.forEach((blockVector) -> assertTrue(expected.contains(blockVector)));
- }
-
- @Test
- public void gateLayoutBorderTest() {
- List expected = new ArrayList<>();
- expected.add(new RelativeBlockVector(1, 0, 0));
- expected.add(new RelativeBlockVector(2, 0, 0));
- expected.add(new RelativeBlockVector(0, 1, 0));
- expected.add(new RelativeBlockVector(0, 2, 0));
- expected.add(new RelativeBlockVector(0, 3, 0));
- expected.add(new RelativeBlockVector(1, 4, 0));
- expected.add(new RelativeBlockVector(2, 4, 0));
- expected.add(new RelativeBlockVector(3, 1, 0));
- expected.add(new RelativeBlockVector(3, 2, 0));
- expected.add(new RelativeBlockVector(3, 3, 0));
-
- RelativeBlockVector[] borderBlocks = layout.getBorder();
- for (RelativeBlockVector blockVector : borderBlocks) {
- assertTrue(expected.contains(blockVector));
- }
- }
-
- @Test
- public void gateLayoutControlsTest() {
- List expected = new ArrayList<>();
- expected.add(new RelativeBlockVector(0, 2, 0));
- expected.add(new RelativeBlockVector(3, 2, 0));
-
- RelativeBlockVector[] controlBlocks = layout.getControls();
- for (RelativeBlockVector blockVector : controlBlocks) {
- assertTrue(expected.contains(blockVector));
- }
- }
-
- @Test
- public void gateLayoutEntrancesTest() {
- List expected = new ArrayList<>();
- expected.add(new RelativeBlockVector(1, 1, 0));
- expected.add(new RelativeBlockVector(2, 1, 0));
- expected.add(new RelativeBlockVector(1, 2, 0));
- expected.add(new RelativeBlockVector(2, 2, 0));
- expected.add(new RelativeBlockVector(1, 3, 0));
- expected.add(new RelativeBlockVector(2, 3, 0));
-
- RelativeBlockVector[] controlBlocks = layout.getEntrances();
- for (RelativeBlockVector blockVector : controlBlocks) {
- assertTrue(expected.contains(blockVector));
- }
- }
-
-}
diff --git a/src/test/java/net/knarcraft/stargate/utility/DirectionHelperTest.java b/src/test/java/net/knarcraft/stargate/utility/DirectionHelperTest.java
deleted file mode 100644
index 6de3716..0000000
--- a/src/test/java/net/knarcraft/stargate/utility/DirectionHelperTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package net.knarcraft.stargate.utility;
-
-import be.seeseemelk.mockbukkit.WorldMock;
-import org.bukkit.Location;
-import org.bukkit.World;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class DirectionHelperTest {
-
- @Test
- public void getYawFromLocationTest() {
- World world = new WorldMock();
- Location location1 = new Location(world, 100, 0, 100);
- Location location2 = new Location(world, 100, 0, 101);
-
- double yaw = DirectionHelper.getYawFromLocationDifference(location1, location2);
- Assertions.assertEquals(0, yaw);
-
- location2 = new Location(world, 100, 0, 99);
- yaw = DirectionHelper.getYawFromLocationDifference(location1, location2);
- Assertions.assertEquals(180, yaw);
-
- location2 = new Location(world, 101, 0, 100);
- yaw = DirectionHelper.getYawFromLocationDifference(location1, location2);
- Assertions.assertEquals(270, yaw);
-
- location2 = new Location(world, 99, 0, 100);
- yaw = DirectionHelper.getYawFromLocationDifference(location1, location2);
- Assertions.assertEquals(90, yaw);
- }
-
-}
diff --git a/src/test/java/net/knarcraft/stargate/utility/MaterialHelperTest.java b/src/test/java/net/knarcraft/stargate/utility/MaterialHelperTest.java
deleted file mode 100644
index f8481b2..0000000
--- a/src/test/java/net/knarcraft/stargate/utility/MaterialHelperTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package net.knarcraft.stargate.utility;
-
-import be.seeseemelk.mockbukkit.MockBukkit;
-import org.bukkit.Material;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-public class MaterialHelperTest {
-
- @BeforeAll
- public static void setUp() {
- MockBukkit.mock();
- }
-
- @AfterAll
- public static void tearDown() {
- MockBukkit.unmock();
- }
-
- @Test
- public void isWallCoralTest() {
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.DEAD_BRAIN_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.BRAIN_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.DEAD_BUBBLE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.BUBBLE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.DEAD_FIRE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.FIRE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.DEAD_HORN_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.HORN_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.DEAD_TUBE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isWallCoral(Material.TUBE_CORAL_WALL_FAN));
-
- Assertions.assertFalse(MaterialHelper.isWallCoral(Material.DEAD_TUBE_CORAL));
- Assertions.assertFalse(MaterialHelper.isWallCoral(Material.TUBE_CORAL));
- Assertions.assertFalse(MaterialHelper.isWallCoral(Material.TUBE_CORAL_BLOCK));
- }
-
- @Test
- public void isButtonCompatibleTest() {
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.DEAD_BRAIN_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.BRAIN_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.DEAD_BUBBLE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.BUBBLE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.DEAD_FIRE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.FIRE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.DEAD_HORN_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.HORN_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.DEAD_TUBE_CORAL_WALL_FAN));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.TUBE_CORAL_WALL_FAN));
-
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.STONE_BUTTON));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.BIRCH_BUTTON));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.ACACIA_BUTTON));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.CRIMSON_BUTTON));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.OAK_BUTTON));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.DARK_OAK_BUTTON));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.JUNGLE_BUTTON));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.POLISHED_BLACKSTONE_BUTTON));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.SPRUCE_BUTTON));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.WARPED_BUTTON));
-
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.BLACK_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.RED_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.GREEN_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.BLUE_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.YELLOW_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.CYAN_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.LIME_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.BROWN_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.GRAY_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.LIGHT_BLUE_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.LIGHT_GRAY_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.MAGENTA_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.ORANGE_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.PINK_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.PURPLE_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.WHITE_SHULKER_BOX));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.SHULKER_BOX));
-
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.CHEST));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.ENDER_CHEST));
- Assertions.assertTrue(MaterialHelper.isButtonCompatible(Material.TRAPPED_CHEST));
-
- //Chek something random to make sure isButtonCompatible is not just "return true;"
- Assertions.assertFalse(MaterialHelper.isButtonCompatible(Material.OAK_LOG));
- }
-
-}