From 3da09947f2617ae6c10982fcef962a99937d2f00 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 13 Jan 2024 09:06:52 -0800 Subject: [PATCH 1/5] Updated POM plugin versions --- pom.xml | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index b2b5e0c..731562d 100644 --- a/pom.xml +++ b/pom.xml @@ -64,16 +64,16 @@ UTF-8 1.8 - 2.0.2 + 2.0.9 - 1.16.3-R0.1-SNAPSHOT - 1.15.4-SNAPSHOT + 1.20.4-R0.1-SNAPSHOT + 2.0.0-SNAPSHOT ${build.version}-SNAPSHOT -LOCAL - 1.2.0 + 1.2.1 @@ -145,7 +145,7 @@ org.mockito mockito-core - 3.0.0 + 3.11.2 test @@ -214,21 +214,55 @@ 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 +296,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 + + + + + From dc523033bb0ec9bccfbb173c0edbb4d491676be8 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 13 Jan 2024 09:09:44 -0800 Subject: [PATCH 2/5] Update to Java 17 --- pom.xml | 3 ++- src/main/resources/config.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 731562d..d0a3afe 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ UTF-8 UTF-8 - 1.8 + 17 2.0.9 @@ -209,6 +209,7 @@ ${java.version} ${java.version} + ${java.version} 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: From 406f92239d850390a2a68790a6bed577e96807eb Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 26 Sep 2024 15:48:16 -0700 Subject: [PATCH 3/5] Make Pladdon --- pom.xml | 2 +- .../java/world/bentobox/chat/ChatPladdon.java | 21 +++++++++++++++++++ src/main/resources/plugin.yml | 9 ++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/main/java/world/bentobox/chat/ChatPladdon.java create mode 100644 src/main/resources/plugin.yml diff --git a/pom.xml b/pom.xml index d0a3afe..b00e84c 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ UTF-8 UTF-8 - 17 + 21 2.0.9 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/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} From bcfe093c562564396df90bb33f996fc47c44219d Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 26 Sep 2024 16:03:05 -0700 Subject: [PATCH 4/5] Add method to check if player has chat enabled --- .../bentobox/chat/listeners/ChatListener.java | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) 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; } } From a672d3dd40376abd71996e386caec50223e93691 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 9 Nov 2024 15:23:50 -0800 Subject: [PATCH 5/5] Update CodeMC and 1.21.3 --- pom.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index b00e84c..12209fa 100644 --- a/pom.xml +++ b/pom.xml @@ -49,13 +49,9 @@ - - 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/ @@ -66,14 +62,14 @@ 2.0.9 - 1.20.4-R0.1-SNAPSHOT - 2.0.0-SNAPSHOT + 1.21.3-R0.1-SNAPSHOT + 2.7.1-SNAPSHOT ${build.version}-SNAPSHOT -LOCAL - 1.2.1 + 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/