Cleanup and maintenance
Updates Spigot version Removes MockBukkit and related tests, as it makes updating a hassle Bumps API version to 1.20 Removes legacy sign updating
This commit is contained in:
		
							
								
								
									
										10
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								pom.xml
									
									
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    <groupId>net.knarcraft</groupId>
 | 
					    <groupId>net.knarcraft</groupId>
 | 
				
			||||||
    <artifactId>Stargate</artifactId>
 | 
					    <artifactId>Stargate</artifactId>
 | 
				
			||||||
    <version>0.11.5.10</version>
 | 
					    <version>0.11.5.11</version>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <licenses>
 | 
					    <licenses>
 | 
				
			||||||
        <license>
 | 
					        <license>
 | 
				
			||||||
@@ -53,7 +53,7 @@
 | 
				
			|||||||
        <dependency>
 | 
					        <dependency>
 | 
				
			||||||
            <groupId>org.spigotmc</groupId>
 | 
					            <groupId>org.spigotmc</groupId>
 | 
				
			||||||
            <artifactId>spigot-api</artifactId>
 | 
					            <artifactId>spigot-api</artifactId>
 | 
				
			||||||
            <version>1.20-R0.1-SNAPSHOT</version>
 | 
					            <version>1.21.8-R0.1-SNAPSHOT</version>
 | 
				
			||||||
            <scope>provided</scope>
 | 
					            <scope>provided</scope>
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
        <dependency>
 | 
					        <dependency>
 | 
				
			||||||
@@ -62,12 +62,6 @@
 | 
				
			|||||||
            <version>1.7.1</version>
 | 
					            <version>1.7.1</version>
 | 
				
			||||||
            <scope>provided</scope>
 | 
					            <scope>provided</scope>
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
        <dependency>
 | 
					 | 
				
			||||||
            <groupId>com.github.seeseemelk</groupId>
 | 
					 | 
				
			||||||
            <artifactId>MockBukkit-v1.18</artifactId>
 | 
					 | 
				
			||||||
            <version>2.85.2</version>
 | 
					 | 
				
			||||||
            <scope>test</scope>
 | 
					 | 
				
			||||||
        </dependency>
 | 
					 | 
				
			||||||
        <dependency>
 | 
					        <dependency>
 | 
				
			||||||
            <groupId>org.jetbrains</groupId>
 | 
					            <groupId>org.jetbrains</groupId>
 | 
				
			||||||
            <artifactId>annotations</artifactId>
 | 
					            <artifactId>annotations</artifactId>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,5 @@
 | 
				
			|||||||
package net.knarcraft.stargate.utility;
 | 
					package net.knarcraft.stargate.utility;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.knarcraft.stargate.Stargate;
 | 
					 | 
				
			||||||
import org.bukkit.DyeColor;
 | 
					import org.bukkit.DyeColor;
 | 
				
			||||||
import org.bukkit.block.Sign;
 | 
					import org.bukkit.block.Sign;
 | 
				
			||||||
import org.bukkit.block.sign.Side;
 | 
					import org.bukkit.block.sign.Side;
 | 
				
			||||||
@@ -12,8 +11,6 @@ import org.jetbrains.annotations.Nullable;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
public final class SignHelper {
 | 
					public final class SignHelper {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static final boolean HAS_SIGN_SIDES = hasSignSides();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private SignHelper() {
 | 
					    private SignHelper() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -26,13 +23,7 @@ public final class SignHelper {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @NotNull
 | 
					    @NotNull
 | 
				
			||||||
    public static String[] getLines(@NotNull Sign sign) {
 | 
					    public static String[] getLines(@NotNull Sign sign) {
 | 
				
			||||||
        if (HAS_SIGN_SIDES) {
 | 
					 | 
				
			||||||
        return sign.getSide(Side.FRONT).getLines();
 | 
					        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();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -43,13 +34,7 @@ public final class SignHelper {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Nullable
 | 
					    @Nullable
 | 
				
			||||||
    public static DyeColor getDye(@NotNull Sign sign) {
 | 
					    public static DyeColor getDye(@NotNull Sign sign) {
 | 
				
			||||||
        if (HAS_SIGN_SIDES) {
 | 
					 | 
				
			||||||
        return sign.getSide(Side.FRONT).getColor();
 | 
					        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();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -60,29 +45,7 @@ public final class SignHelper {
 | 
				
			|||||||
     * @param text <p>The text to set</p>
 | 
					     * @param text <p>The text to set</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void setSignLine(@NotNull Sign sign, int line, @NotNull String text) {
 | 
					    public static void setSignLine(@NotNull Sign sign, int line, @NotNull String text) {
 | 
				
			||||||
        if (HAS_SIGN_SIDES) {
 | 
					 | 
				
			||||||
        sign.getSide(Side.FRONT).setLine(line, text);
 | 
					        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 <p>True if the server supports sign side differentiation</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@ description: The original, and still the best, MineCraft transportation solution
 | 
				
			|||||||
author: EpicKnarvik97
 | 
					author: EpicKnarvik97
 | 
				
			||||||
authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]
 | 
					authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]
 | 
				
			||||||
website: https://sgrewritten.org/legacygit
 | 
					website: https://sgrewritten.org/legacygit
 | 
				
			||||||
api-version: 1.16
 | 
					api-version: 1.20
 | 
				
			||||||
softdepend: [ Vault, dynmap, Geyser-Spigot, floodgate ]
 | 
					softdepend: [ Vault, dynmap, Geyser-Spigot, floodgate ]
 | 
				
			||||||
commands:
 | 
					commands:
 | 
				
			||||||
  stargate:
 | 
					  stargate:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -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<RelativeBlockVector> expected = new ArrayList<>();
 | 
					 | 
				
			||||||
        expected.add(new RelativeBlockVector(1, 3, 0));
 | 
					 | 
				
			||||||
        expected.add(new RelativeBlockVector(2, 3, 0));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        List<RelativeBlockVector> exits = layout.getExits();
 | 
					 | 
				
			||||||
        exits.forEach((blockVector) -> assertTrue(expected.contains(blockVector)));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    public void gateLayoutBorderTest() {
 | 
					 | 
				
			||||||
        List<RelativeBlockVector> 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<RelativeBlockVector> 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<RelativeBlockVector> 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));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -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));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user