diff --git a/pom.xml b/pom.xml
index 0d3807310..388e3c60d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,7 +88,7 @@
-LOCAL
- 2.0.1
+ 2.1.0
bentobox-world
https://sonarcloud.io
${project.basedir}/lib
diff --git a/src/main/java/world/bentobox/bentobox/managers/PlaceholdersManager.java b/src/main/java/world/bentobox/bentobox/managers/PlaceholdersManager.java
index 8917e61e2..5d410bc01 100644
--- a/src/main/java/world/bentobox/bentobox/managers/PlaceholdersManager.java
+++ b/src/main/java/world/bentobox/bentobox/managers/PlaceholdersManager.java
@@ -4,6 +4,8 @@
import java.util.Optional;
import java.util.UUID;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@@ -167,6 +169,26 @@ private void registerTeamMemberPlaceholders(@NonNull GameModeAddon addon) {
return "";
});
}
+ // Counts
+ // Number of online members
+ registerPlaceholder(addon, "island_online_members_count", user -> {
+ if (user == null)
+ return "";
+ Island island = plugin.getIslands().getIsland(addon.getOverWorld(), user);
+ return island != null
+ ? String.valueOf(island.getMemberSet(RanksManager.MEMBER_RANK).stream()
+ .map(Bukkit::getOfflinePlayer).filter(OfflinePlayer::isOnline).count())
+ : "";
+ });
+ // Number of online members of visited island
+ registerPlaceholder(addon, "visited_island_online_members_count", user -> {
+ if (user == null)
+ return "";
+ return plugin.getIslands().getIslandAt(user.getLocation())
+ .map(island -> String.valueOf(island.getMemberSet(RanksManager.MEMBER_RANK).stream()
+ .map(Bukkit::getOfflinePlayer).filter(OfflinePlayer::isOnline).count()))
+ .orElse("");
+ });
}
/**
diff --git a/src/test/java/world/bentobox/bentobox/managers/PlaceholdersManagerTest.java b/src/test/java/world/bentobox/bentobox/managers/PlaceholdersManagerTest.java
index 7d22a6155..ded48fb62 100644
--- a/src/test/java/world/bentobox/bentobox/managers/PlaceholdersManagerTest.java
+++ b/src/test/java/world/bentobox/bentobox/managers/PlaceholdersManagerTest.java
@@ -77,7 +77,7 @@ public void tearDown() {
public void testRegisterGameModePlaceholdersAllDefaults() {
pm.registerDefaultPlaceholders(addon);
// + 300 because we register team member placeholders up to 50 members
- verify(hook, times(GameModePlaceholder.values().length + 300)).registerPlaceholder(any(), anyString(), any());
+ verify(hook, times(GameModePlaceholder.values().length + 302)).registerPlaceholder(any(), anyString(), any());
}
/**
@@ -91,6 +91,7 @@ public void testRegisterDefaultPlaceholdersSomePreregistered() {
pm.registerDefaultPlaceholders(addon);
// 3 less registrations for this addon
- verify(hook, times(GameModePlaceholder.values().length - 3 + 300)).registerPlaceholder(any(), anyString(), any());
+ verify(hook, times(GameModePlaceholder.values().length - 3 + 302)).registerPlaceholder(any(), anyString(),
+ any());
}
}