diff --git a/pom.xml b/pom.xml
index b2b5e0c..12209fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,31 +49,27 @@
-
- codemc-snapshots
- https://repo.codemc.org/repository/maven-snapshots
-
- codemc-releases
- https://repo.codemc.org/repository/maven-releases
+ bentoboxworld
+ https://repo.codemc.org/repository/bentoboxworld/
UTF-8
UTF-8
- 1.8
+ 21
- 2.0.2
+ 2.0.9
- 1.16.3-R0.1-SNAPSHOT
- 1.15.4-SNAPSHOT
+ 1.21.3-R0.1-SNAPSHOT
+ 2.7.1-SNAPSHOT
${build.version}-SNAPSHOT
-LOCAL
- 1.2.0
+ 1.3.0
@@ -123,6 +119,10 @@
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots
+
+ bentoboxworld
+ https://repo.codemc.org/repository/bentoboxworld
+
codemc-repo
https://repo.codemc.org/repository/maven-public/
@@ -145,7 +145,7 @@
org.mockito
mockito-core
- 3.0.0
+ 3.11.2
test
@@ -209,26 +209,61 @@
${java.version}
+ ${java.version}
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.0
+ 3.0.0-M5
+
+
+ ${argLine}
+ --add-opens java.base/java.lang=ALL-UNNAMED
+ --add-opens java.base/java.math=ALL-UNNAMED
+ --add-opens java.base/java.io=ALL-UNNAMED
+ --add-opens java.base/java.util=ALL-UNNAMED
+ --add-opens
+ java.base/java.util.stream=ALL-UNNAMED
+ --add-opens java.base/java.text=ALL-UNNAMED
+ --add-opens
+ java.base/java.util.regex=ALL-UNNAMED
+ --add-opens
+ java.base/java.nio.channels.spi=ALL-UNNAMED
+ --add-opens java.base/sun.nio.ch=ALL-UNNAMED
+ --add-opens java.base/java.net=ALL-UNNAMED
+ --add-opens
+ java.base/java.util.concurrent=ALL-UNNAMED
+ --add-opens java.base/sun.nio.fs=ALL-UNNAMED
+ --add-opens java.base/sun.nio.cs=ALL-UNNAMED
+ --add-opens java.base/java.nio.file=ALL-UNNAMED
+ --add-opens
+ java.base/java.nio.charset=ALL-UNNAMED
+ --add-opens
+ java.base/java.lang.reflect=ALL-UNNAMED
+ --add-opens
+ java.logging/java.util.logging=ALL-UNNAMED
+ --add-opens java.base/java.lang.ref=ALL-UNNAMED
+ --add-opens java.base/java.util.jar=ALL-UNNAMED
+ --add-opens java.base/java.util.zip=ALL-UNNAMED
+
+
+
org.apache.maven.plugins
maven-jar-plugin
- 3.1.0
+ 3.2.0
org.apache.maven.plugins
maven-javadoc-plugin
- 3.0.1
+ 3.1.1
public
false
-Xdoclint:none
+ ${java.home}/bin/javadoc
@@ -262,6 +297,40 @@
maven-deploy-plugin
2.8.2
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.10
+
+ true
+
+
+ **/*Names*
+
+ org/bukkit/Material*
+
+
+
+
+ prepare-agent
+
+ prepare-agent
+
+
+
+ report
+
+ report
+
+
+
+ XML
+
+
+
+
+
diff --git a/src/main/java/world/bentobox/chat/ChatPladdon.java b/src/main/java/world/bentobox/chat/ChatPladdon.java
new file mode 100644
index 0000000..5e1086d
--- /dev/null
+++ b/src/main/java/world/bentobox/chat/ChatPladdon.java
@@ -0,0 +1,21 @@
+package world.bentobox.chat;
+
+
+import world.bentobox.bentobox.api.addons.Addon;
+import world.bentobox.bentobox.api.addons.Pladdon;
+
+/**
+ * @author tastybento
+ *
+ */
+public class ChatPladdon extends Pladdon {
+ private Addon addon;
+
+ @Override
+ public Addon getAddon() {
+ if (addon == null) {
+ addon = new Chat();
+ }
+ return addon;
+ }
+}
diff --git a/src/main/java/world/bentobox/chat/listeners/ChatListener.java b/src/main/java/world/bentobox/chat/listeners/ChatListener.java
index a8ab994..1ee29af 100644
--- a/src/main/java/world/bentobox/chat/listeners/ChatListener.java
+++ b/src/main/java/world/bentobox/chat/listeners/ChatListener.java
@@ -33,14 +33,14 @@ public class ChatListener implements Listener, EventExecutor {
private static final String MESSAGE = "[message]";
private final Chat addon;
private final Set teamChatUsers;
- private final Map> islands;
+ private final Map> islandChatters;
// List of which users are spying or not on team and island chat
private final Set spies;
private final Set islandSpies;
public ChatListener(Chat addon) {
this.teamChatUsers = new HashSet<>();
- this.islands = new HashMap<>();
+ this.islandChatters = new HashMap<>();
this.addon = addon;
// Initialize spies
spies = new HashSet<>();
@@ -83,8 +83,8 @@ public void onChat(final AsyncPlayerChatEvent e) {
}
}
addon.getIslands().getIslandAt(p.getLocation())
- .filter(islands.keySet()::contains)
- .filter(i -> islands.get(i).contains(p))
+ .filter(islandChatters.keySet()::contains)
+ .filter(i -> islandChatters.get(i).contains(p))
.ifPresent(i -> {
// Cancel the event
e.setCancelled(true);
@@ -99,17 +99,13 @@ public void onChat(final AsyncPlayerChatEvent e) {
// Removes player from TeamChat set if he left the island
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onLeave(TeamLeaveEvent e) {
-
- if (teamChatUsers.contains(e.getPlayerUUID()))
- teamChatUsers.remove(e.getPlayerUUID());
+ teamChatUsers.remove(e.getPlayerUUID());
}
// Removes player from TeamChat set if he was kicked from the island
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onKick(TeamKickEvent e) {
-
- if (teamChatUsers.contains(e.getPlayerUUID()))
- teamChatUsers.remove(e.getPlayerUUID());
+ teamChatUsers.remove(e.getPlayerUUID());
}
public void islandChat(Island i, Player player, String message) {
@@ -157,6 +153,20 @@ public boolean isTeamChat(UUID playerUUID) {
return this.teamChatUsers.contains(playerUUID);
}
+ /**
+ * Whether the player has chat on or not. Note that with multiple islands the response is true
+ * if *any* chat is enabled
+ * @param playerUUID - player's UUID
+ * @return true if chat is active on any island
+ */
+ public boolean isChat(UUID playerUUID) {
+ Player p = Bukkit.getPlayer(playerUUID);
+ if (p == null) {
+ return false;
+ }
+ return this.islandChatters.values().stream().anyMatch(playerSet -> playerSet.contains(p));
+ }
+
/**
* Toggles team chat spy. Spy must also have the spy permission to see chats
* @param playerUUID - the player's UUID
@@ -206,20 +216,17 @@ public boolean togglePlayerTeamChat(UUID playerUUID) {
/**
* Toggle island chat state
* @param island - island
+ * @param player - player
* @return true if island chat is now on, otherwise false
*/
public boolean toggleIslandChat(Island island, Player player) {
- if (islands.containsKey(island)) {
- if (islands.get(island).contains(player)) {
- islands.get(island).remove(player);
- return false;
- }
- islands.get(island).add(player);
- return true;
- }
- else {
- islands.put(island, new HashSet<>());
- islands.get(island).add(player);
+ var chatters = islandChatters.computeIfAbsent(island, k -> new HashSet<>());
+
+ if (chatters.contains(player)) {
+ chatters.remove(player);
+ return false;
+ } else {
+ chatters.add(player);
return true;
}
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 99aee54..aba90fc 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,4 +1,4 @@
-# Configuration file for Chat 1.2.0-SNAPSHOT-LOCAL.
+# Configuration file for Chat {$version}.
team-chat:
# Lists the gamemodes in which you want the Team Chat to be effective.
gamemodes:
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..42961f2
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,9 @@
+name: BentoBox-Chat
+main: world.bentobox.chat.ChatPladdon
+version: ${project.version}${build.number}
+api-version: "1.16"
+
+authors: [tastybento]
+contributors: ["The BentoBoxWorld Community"]
+website: https://bentobox.world
+description: ${project.description}