diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8eab538e8..55e1a9cae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,10 +22,10 @@ jobs: run: | cd uSkyBlock-Core/src/main/po && perl en2pirate.pl && cd - cd uSkyBlock-Core/src/main/po && perl en2kitteh.pl && cd - - - name: JDK 17 + - name: JDK 21 uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' - name: Install gettext run: sudo apt-get install -y gettext diff --git a/bukkit-utils/pom.xml b/bukkit-utils/pom.xml index 7d3bf8e0f..7e3d4ba34 100644 --- a/bukkit-utils/pom.xml +++ b/bukkit-utils/pom.xml @@ -54,16 +54,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 - - 16 - UTF-8 - org.apache.maven.plugins maven-jar-plugin - 3.2.0 @@ -75,7 +69,6 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.0 public false @@ -93,7 +86,6 @@ org.apache.maven.plugins maven-source-plugin - 3.2.1 attach-sources @@ -125,13 +117,6 @@ ${vaultapi.version} true - - - - - - - org.hamcrest hamcrest-core diff --git a/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/command/BaseCommandExecutorTest.java b/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/command/BaseCommandExecutorTest.java index 44d9f5700..e502fe5a9 100644 --- a/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/command/BaseCommandExecutorTest.java +++ b/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/command/BaseCommandExecutorTest.java @@ -4,7 +4,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.mockito.ArgumentMatchers; -import org.mockito.Matchers; import org.mockito.Mockito; import org.mockito.stubbing.Answer; @@ -13,7 +12,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.when; @@ -27,11 +26,9 @@ public static void setUp() { mycmd.add(new AbstractCommand("hello|h", "myplugin.perm.hello", "say hello to the player") { @Override public boolean execute(CommandSender sender, String alias, Map data, String... args) { - sender.sendMessage(new String[]{ - "Hello! and welcome " + sender.getName(), - "I was called with : " + alias, - "I had " + args.length + " arguments: " + Arrays.asList(args) - }); + sender.sendMessage("Hello! and welcome " + sender.getName(), + "I was called with : " + alias, + "I had " + args.length + " arguments: " + Arrays.asList(args)); return true; } }); @@ -62,26 +59,22 @@ private void addPerm(CommandSender sender, String s) { when(sender.hasPermission(ArgumentMatchers.isA(String.class))).thenReturn(true); } - private void addOp(CommandSender sender) { - when(sender.isOp()).thenReturn(true); - } - private CommandSender createCommandSender() { CommandSender mock = Mockito.mock(CommandSender.class); Answer answer = invocationOnMock -> { for (Object o : invocationOnMock.getArguments()) { if (o != null && o.getClass().isArray()) { for (Object o2 : (Object[]) o) { - messages.append("" + o2 + "\n"); + messages.append(o2).append("\n"); } } else { - messages.append("" + o + "\n"); + messages.append(o).append("\n"); } } return null; }; doAnswer(answer).when(mock).sendMessage(anyString()); - doAnswer(answer).when(mock).sendMessage(Matchers.any()); + doAnswer(answer).when(mock).sendMessage(ArgumentMatchers.any(String[].class)); return mock; } -} \ No newline at end of file +} diff --git a/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/command/CompositeCommandTest.java b/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/command/CompositeCommandTest.java index c764f08dd..6fb59e129 100644 --- a/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/command/CompositeCommandTest.java +++ b/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/command/CompositeCommandTest.java @@ -14,13 +14,13 @@ import java.util.UUID; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; public class CompositeCommandTest { - private static UUID ownerUUID = UUID.randomUUID(); - private static UUID adminUUID = UUID.randomUUID(); - private static UUID modUUID = UUID.randomUUID(); + private static final UUID ownerUUID = UUID.randomUUID(); + private static final UUID adminUUID = UUID.randomUUID(); + private static final UUID modUUID = UUID.randomUUID(); private static BaseCommandExecutor executor; @BeforeClass @@ -89,7 +89,7 @@ public void PermOnAdmin() { executor.onCommand(player, null, "alias", new String[]{"admin", "sub"}); verify(player).sendMessage("executed admin"); - assertThat(messages, Matchers.contains(new String[]{"executed admin", "§eYou do not have access (§4perm.sub§e)"})); + assertThat(messages, Matchers.contains("executed admin", "§eYou do not have access (§4perm.sub§e)")); } @Test @@ -103,7 +103,7 @@ public void AllPerms() { executor.onCommand(player, null, "alias", new String[]{"admin", "sub"}); verify(player).sendMessage("executed admin"); - assertThat(messages, Matchers.contains(new String[]{"executed admin", "from sub"})); + assertThat(messages, Matchers.contains("executed admin", "from sub")); } @Test @@ -116,7 +116,7 @@ public void NoPerm_PermissionOverride() { // Act executor.onCommand(player, null, "alias", new String[]{"admin", "sub"}); - assertThat(messages, Matchers.contains(new String[]{"executed admin", "from sub"})); + assertThat(messages, Matchers.contains("executed admin", "from sub")); } @Test @@ -129,7 +129,7 @@ public void NoPerm_PermissionSubOverride() { // Act executor.onCommand(player, null, "alias", new String[]{"admin", "sub"}); - assertThat(messages, Matchers.contains(new String[]{"§eYou do not have access (§4plugin§e)"})); + assertThat(messages, Matchers.contains("§eYou do not have access (§4plugin§e)")); } @Test @@ -145,7 +145,7 @@ public void BasePerm_PermissionCompositeOverride() { // Act executor.onCommand(player, null, "alias", new String[]{"admin", "sub"}); - assertThat(messages, Matchers.contains(new String[]{"executed admin", "from sub"})); + assertThat(messages, Matchers.contains("executed admin", "from sub")); } @Test @@ -162,7 +162,7 @@ public void BasePerm_PermissionAbstractCommandOverride() { // Act executor.onCommand(player, null, "alias", new String[]{"admin", "sub2"}); - assertThat(messages, Matchers.contains(new String[]{"executed admin", "from sub2"})); + assertThat(messages, Matchers.contains("executed admin", "from sub2")); } private List recordMessages(Player player) { @@ -175,4 +175,4 @@ private List recordMessages(Player player) { return messages; } -} \ No newline at end of file +} diff --git a/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/util/BukkitServerMock.java b/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/util/BukkitServerMock.java index 526f2e2fb..94bc3f04e 100644 --- a/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/util/BukkitServerMock.java +++ b/bukkit-utils/src/test/java/dk/lockfuglsang/minecraft/util/BukkitServerMock.java @@ -17,7 +17,7 @@ import java.util.Objects; import java.util.TreeMap; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; public class BukkitServerMock { diff --git a/po-utils/pom.xml b/po-utils/pom.xml index ebe67b21d..023e26809 100644 --- a/po-utils/pom.xml +++ b/po-utils/pom.xml @@ -46,11 +46,8 @@ + org.apache.maven.plugins maven-compiler-plugin - - 17 - utf-8 - org.apache.maven.plugins diff --git a/pom.xml b/pom.xml index 88a1a6dec..34035a80e 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ 2.2 4.13.2 5.9.0 - 3.12.4 + 5.14.2 @@ -69,40 +69,51 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.13.0 - 17 + 21 + UTF-8 org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.2 org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.11.2 org.apache.maven.plugins maven-shade-plugin - 3.4.1 + 3.6.0 org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.1 + + + org.apache.maven.plugins + maven-clean-plugin + 3.4.0 org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 + 3.5.2 org.apache.maven.plugins maven-failsafe-plugin - 3.0.0-M5 + 3.5.2 + + + org.apache.maven.plugins + maven-assembly-plugin + 3.7.1 @@ -110,7 +121,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.0.0 + 3.5.0 enforce-maven diff --git a/uSkyBlock-API/pom.xml b/uSkyBlock-API/pom.xml index 339148212..211bbe7fe 100644 --- a/uSkyBlock-API/pom.xml +++ b/uSkyBlock-API/pom.xml @@ -4,6 +4,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + uSkyBlock + ovh.uskyblock + 3.1.0-SNAPSHOT + com.github.rlf uSkyBlock-API 3.1.0-SNAPSHOT @@ -31,7 +36,7 @@ org.spigotmc spigot-api - 1.20.4-R0.1-SNAPSHOT + ${spigotapi.version} provided true @@ -47,20 +52,14 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 - - 17 - org.apache.maven.plugins maven-jar-plugin - 3.2.0 org.apache.maven.plugins maven-javadoc-plugin - 3.2.0 public false @@ -84,7 +83,6 @@ org.apache.maven.plugins maven-source-plugin - 3.2.1 attach-sources diff --git a/uSkyBlock-APIv2/pom.xml b/uSkyBlock-APIv2/pom.xml index 10bd75876..f54a135e7 100644 --- a/uSkyBlock-APIv2/pom.xml +++ b/uSkyBlock-APIv2/pom.xml @@ -28,11 +28,8 @@ + org.apache.maven.plugins maven-compiler-plugin - - 17 - utf-8 - org.apache.maven.plugins diff --git a/uSkyBlock-Core/pom.xml b/uSkyBlock-Core/pom.xml index 33503cbbb..c5f77cbc1 100644 --- a/uSkyBlock-Core/pom.xml +++ b/uSkyBlock-Core/pom.xml @@ -16,10 +16,6 @@ org.apache.maven.plugins maven-compiler-plugin - - 17 - utf-8 - com.google.code.maven-replacer-plugin @@ -52,7 +48,7 @@ org.codehaus.mojo buildnumber-maven-plugin - 1.4 + 3.2.1 generate-resources @@ -120,8 +116,8 @@ + org.apache.maven.plugins maven-clean-plugin - 3.1.0 @@ -140,7 +136,7 @@ org.apache.maven.plugins maven-antrun-plugin - 1.8 + 3.1.0 prepare-package diff --git a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/challenge/ChallengeFormatTest.java b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/challenge/ChallengeFormatTest.java index 03cc1f8aa..44f965284 100644 --- a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/challenge/ChallengeFormatTest.java +++ b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/challenge/ChallengeFormatTest.java @@ -11,7 +11,6 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.argThat; import static org.mockito.Mockito.when; public class ChallengeFormatTest { @@ -80,4 +79,4 @@ public void getMissingRequirement_AllFullyCompleted() { String missingRequirement = ChallengeFormat.getMissingRequirement(playerInfo, Arrays.asList("cobblestonegenerator", "pumpkinfarmer:2"), challengeLogic); assertThat(missingRequirement, is(nullValue())); } -} \ No newline at end of file +} diff --git a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/chat/ChatEventsTest.java b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/chat/ChatEventsTest.java index 4ea6c1aec..96f61342a 100644 --- a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/chat/ChatEventsTest.java +++ b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/chat/ChatEventsTest.java @@ -33,7 +33,7 @@ public void setUp() { when(fakeScheduler.runTask(any(Plugin.class), any(Runnable.class))).thenReturn(mock(BukkitTask.class)); when(fakeServer.getScheduler()).thenReturn(fakeScheduler); - fakeLogic = spy(mock(ChatLogic.class)); + fakeLogic = mock(ChatLogic.class); doNothing().when(fakeLogic).sendMessage(any(), any(), any()); listener = new ChatEvents(fakeLogic, fakePlugin); diff --git a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/event/InternalEventsTest.java b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/event/InternalEventsTest.java index bb18bd6db..e5513cd7a 100644 --- a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/event/InternalEventsTest.java +++ b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/event/InternalEventsTest.java @@ -32,7 +32,7 @@ public class InternalEventsTest { @Before public void setUp() { - fakePlugin = spy(mock(uSkyBlock.class)); + fakePlugin = mock(uSkyBlock.class); internalEvents = new InternalEvents(fakePlugin); YamlConfiguration config = new YamlConfiguration(); @@ -40,7 +40,7 @@ public void setUp() { config.set("options.party.leave-commands", Arrays.asList("dont", "stop", "me", "now")); doReturn(config).when(fakePlugin).getConfig(); - fakeBlockLimitLogic = spy(mock(BlockLimitLogic.class)); + fakeBlockLimitLogic = mock(BlockLimitLogic.class); doNothing().when(fakeBlockLimitLogic).updateBlockCount(any(), any()); doReturn(fakeBlockLimitLogic).when(fakePlugin).getBlockLimitLogic(); @@ -73,7 +73,7 @@ public void testOnCreate() { @Test public void testOnMemberJoin() { IslandInfo fakeIslandInfo = mock(IslandInfo.class); - PlayerInfo fakePlayerInfo = spy(mock(PlayerInfo.class)); + PlayerInfo fakePlayerInfo = mock(PlayerInfo.class); doReturn(true).when(fakePlayerInfo).execCommands(any()); List commandList = fakePlugin.getConfig().getStringList("options.party.join-commands"); @@ -86,7 +86,7 @@ public void testOnMemberJoin() { @Test public void testOnMemberLeft() { IslandInfo fakeIslandInfo = mock(IslandInfo.class); - PlayerInfo fakePlayerInfo = spy(mock(PlayerInfo.class)); + PlayerInfo fakePlayerInfo = mock(PlayerInfo.class); doReturn(true).when(fakePlayerInfo).execCommands(any()); List commandList = fakePlugin.getConfig().getStringList("options.party.leave-commands"); @@ -103,7 +103,7 @@ public void testOnScoreChanged() { Location islandLocation = new Location(null, -10.00, 25.00, 10.00); uSkyBlockScoreChangedEvent event = new uSkyBlockScoreChangedEvent(fakePlayer, fakePlugin, - fakeIslandScore, islandLocation); + fakeIslandScore, islandLocation); internalEvents.onScoreChanged(event); verify(fakeBlockLimitLogic).updateBlockCount(islandLocation, fakeIslandScore); } @@ -113,12 +113,12 @@ public void testOnInfoEvent() { Player fakePlayer = getFakePlayer(); Location islandLocation = new Location(null, -10.00, 25.00, 10.00); Callback callback = - new Callback() { - @Override - public void run() { - // Do nothing - } - }; + new Callback<>() { + @Override + public void run() { + // Do nothing + } + }; IslandInfoEvent event = new IslandInfoEvent(fakePlayer, islandLocation, callback); internalEvents.onInfoEvent(event); diff --git a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/event/MenuEventsTest.java b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/event/MenuEventsTest.java index efa4a4db6..8b8c04053 100644 --- a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/event/MenuEventsTest.java +++ b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/event/MenuEventsTest.java @@ -29,8 +29,8 @@ public class MenuEventsTest { @Before public void setUp() { uSkyBlock fakePlugin = mock(uSkyBlock.class); - fakeConfigMenu = spy(mock(ConfigMenu.class)); - fakeMenu = spy(mock(SkyBlockMenu.class)); + fakeConfigMenu = mock(ConfigMenu.class); + fakeMenu = mock(SkyBlockMenu.class); doNothing().when(fakeConfigMenu).onClick(any(InventoryClickEvent.class)); doNothing().when(fakeMenu).onClick(any(InventoryClickEvent.class)); diff --git a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/island/IslandLocatorLogicTest.java b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/island/IslandLocatorLogicTest.java index 98fd0c695..88b86918c 100644 --- a/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/island/IslandLocatorLogicTest.java +++ b/uSkyBlock-Core/src/test/java/us/talabrek/ultimateskyblock/island/IslandLocatorLogicTest.java @@ -6,7 +6,6 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.junit.Test; -import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import us.talabrek.ultimateskyblock.Settings; import us.talabrek.ultimateskyblock.uSkyBlock; @@ -25,7 +24,7 @@ import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -64,13 +63,10 @@ public void testNextIslandLocationReservationConcurrency() throws Exception { final List locations = new ArrayList<>(); ThreadGroup threadGroup = new ThreadGroup("My"); for (int i = 0; i < 10; i++) { - Thread t = new Thread(threadGroup, new Runnable() { - @Override - public void run() { - Player player = createPlayerMock(); - Location location = locator.getNextIslandLocation(player); - locations.add(location); - } + Thread t = new Thread(threadGroup, () -> { + Player player = createPlayerMock(); + Location location = locator.getNextIslandLocation(player); + locations.add(location); }); t.start(); } @@ -84,12 +80,7 @@ public void run() { private Player createPlayerMock() { Player player = mock(Player.class); - when(player.getLocation()).then(new Answer() { - @Override - public Location answer(InvocationOnMock invocationOnMock) throws Throwable { - return new Location(null, 100, 100, 100); - } - }); + when(player.getLocation()).then((Answer) invocationOnMock -> new Location(null, 100, 100, 100)); return player; } diff --git a/uSkyBlock-Plugin/pom.xml b/uSkyBlock-Plugin/pom.xml index e2cb7ed0e..9d23c4627 100644 --- a/uSkyBlock-Plugin/pom.xml +++ b/uSkyBlock-Plugin/pom.xml @@ -16,7 +16,6 @@ maven-assembly-plugin - 3.1.1 distro-assembly