diff --git a/pom.xml b/pom.xml
index 8360a6a..8b576fd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,13 @@
GitHub
https://github.com/BentoBoxWorld/Challenges/issues
+
+
+
+ bentoboxworld
+ https://repo.codemc.org/repository/bentoboxworld/
+
+
UTF-8
@@ -35,16 +42,16 @@
21
2.0.9
- 1.21-R0.1-SNAPSHOT
+ 1.21.3-R0.1-SNAPSHOT
1.2.3-SNAPSHOT
- 2.4.2
+ 2.7.1-SNAPSHOT
2.6.3
1.7
1.2.0
${build.version}-SNAPSHOT
- 1.3.2
+ 1.4.0
-LOCAL
BentoBoxWorld_Challenges
@@ -83,17 +90,6 @@
-
-
- codemc-snapshots
- https://repo.codemc.org/repository/maven-snapshots
-
-
- codemc-releases
- https://repo.codemc.org/repository/maven-releases
-
-
-
apache.snapshots
@@ -108,6 +104,10 @@
https://hub.spigotmc.org/nexus/content/repositories/snapshots
+
+ bentoboxworld
+ https://repo.codemc.io/repository/bentoboxworld/c
+
codemc-repo
https://repo.codemc.io/repository/maven-public
diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml
index 13c59e0..8cd6b89 100755
--- a/src/main/resources/addon.yml
+++ b/src/main/resources/addon.yml
@@ -1,7 +1,7 @@
name: Challenges
main: world.bentobox.challenges.ChallengesAddon
version: ${version}${build.number}
-api-version: 1.17
+api-version: 2.7.1
repository: 'BentoBoxWorld/Challenges'
metrics: true
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 3c1152d..7debe79 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,7 +1,7 @@
name: BentoBox-Challenges
main: world.bentobox.challenges.ChallengesPladdon
version: ${project.version}${build.number}
-api-version: "1.17"
+api-version: "1.21"
authors: [tastybento, BONNe]
contributors: ["The BentoBoxWorld Community"]
diff --git a/src/test/java/world/bentobox/challenges/tasks/TryToCompleteTest.java b/src/test/java/world/bentobox/challenges/tasks/TryToCompleteTest.java
index 363367a..89c2dd6 100644
--- a/src/test/java/world/bentobox/challenges/tasks/TryToCompleteTest.java
+++ b/src/test/java/world/bentobox/challenges/tasks/TryToCompleteTest.java
@@ -1,10 +1,12 @@
package world.bentobox.challenges.tasks;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -30,6 +32,7 @@ import org.bukkit.World.Environment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
+import org.bukkit.entity.Player.Spigot;
import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@@ -41,6 +44,7 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
@@ -49,6 +53,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
+import net.md_5.bungee.api.chat.TextComponent;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.AddonDescription;
import world.bentobox.bentobox.api.addons.GameModeAddon;
@@ -119,6 +124,8 @@ public class TryToCompleteTest {
@Mock
private BoundingBox bb;
private Set onlinePlayers;
+ @Mock
+ private Spigot spigot;
/**
*/
@@ -207,6 +214,7 @@ public class TryToCompleteTest {
when(user.getPlayer()).thenReturn(player);
UUID uniqueId = UUID.randomUUID();
when(player.getUniqueId()).thenReturn(uniqueId);
+ when(player.spigot()).thenReturn(spigot);
when(user.getUniqueId()).thenReturn(uniqueId);
when(user.getTranslation(anyString()))
.thenAnswer((Answer) invocation -> invocation.getArgument(0, String.class));
@@ -702,4 +710,32 @@ public class TryToCompleteTest {
}
+ /**
+ * Check that spigot sent the message
+ * @param message - message to check
+ */
+ public void checkSpigotMessage(String expectedMessage) {
+ checkSpigotMessage(expectedMessage, 1);
+ }
+
+ public void checkSpigotMessage(String expectedMessage, int expectedOccurrences) {
+ // Capture the argument passed to spigot().sendMessage(...) if messages are sent
+ ArgumentCaptor captor = ArgumentCaptor.forClass(TextComponent.class);
+
+ // Verify that sendMessage() was called at least 0 times (capture any sent messages)
+ verify(spigot, atLeast(0)).sendMessage(captor.capture());
+
+ // Get all captured TextComponents
+ List capturedMessages = captor.getAllValues();
+
+ // Count the number of occurrences of the expectedMessage in the captured messages
+ long actualOccurrences = capturedMessages.stream().map(component -> component.toLegacyText()) // Convert each TextComponent to plain text
+ .filter(messageText -> messageText.contains(expectedMessage)) // Check if the message contains the expected text
+ .count(); // Count how many times the expected message appears
+
+ // Assert that the number of occurrences matches the expectedOccurrences
+ assertEquals("Expected message occurrence mismatch: " + expectedMessage, expectedOccurrences,
+ actualOccurrences);
+ }
+
}