Skip to content

Commit d9403fa

Browse files
authored
Merge pull request #43 from BentoBoxWorld/develop
Release 1.3.0
2 parents 093ac15 + a672d3d commit d9403fa

File tree

5 files changed

+143
-37
lines changed

5 files changed

+143
-37
lines changed

pom.xml

Lines changed: 84 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,27 @@
4949
</issueManagement>
5050

5151
<distributionManagement>
52-
<snapshotRepository>
53-
<id>codemc-snapshots</id>
54-
<url>https://repo.codemc.org/repository/maven-snapshots</url>
55-
</snapshotRepository>
5652
<repository>
57-
<id>codemc-releases</id>
58-
<url>https://repo.codemc.org/repository/maven-releases</url>
53+
<id>bentoboxworld</id>
54+
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
5955
</repository>
6056
</distributionManagement>
6157

6258
<properties>
6359
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6460
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
65-
<java.version>1.8</java.version>
61+
<java.version>21</java.version>
6662
<!-- Non-minecraft related dependencies -->
67-
<powermock.version>2.0.2</powermock.version>
63+
<powermock.version>2.0.9</powermock.version>
6864
<!-- More visible way how to change dependency versions -->
69-
<spigot.version>1.16.3-R0.1-SNAPSHOT</spigot.version>
70-
<bentobox.version>1.15.4-SNAPSHOT</bentobox.version>
65+
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
66+
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
7167
<!-- Revision variable removes warning about dynamic version -->
7268
<revision>${build.version}-SNAPSHOT</revision>
7369
<!-- Do not change unless you want different name for local builds. -->
7470
<build.number>-LOCAL</build.number>
7571
<!-- This allows to change between versions. -->
76-
<build.version>1.2.0</build.version>
72+
<build.version>1.3.0</build.version>
7773
</properties>
7874

7975
<!-- Profiles will allow to automatically change build version. -->
@@ -123,6 +119,10 @@
123119
<id>spigot-repo</id>
124120
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
125121
</repository>
122+
<repository>
123+
<id>bentoboxworld</id>
124+
<url>https://repo.codemc.org/repository/bentoboxworld</url>
125+
</repository>
126126
<repository>
127127
<id>codemc-repo</id>
128128
<url>https://repo.codemc.org/repository/maven-public/</url>
@@ -145,7 +145,7 @@
145145
<dependency>
146146
<groupId>org.mockito</groupId>
147147
<artifactId>mockito-core</artifactId>
148-
<version>3.0.0</version>
148+
<version>3.11.2</version>
149149
<scope>test</scope>
150150
</dependency>
151151
<dependency>
@@ -209,26 +209,61 @@
209209
<configuration>
210210
<source>${java.version}</source>
211211
<target>${java.version}</target>
212+
<release>${java.version}</release>
212213
</configuration>
213214
</plugin>
214215
<plugin>
215216
<groupId>org.apache.maven.plugins</groupId>
216217
<artifactId>maven-surefire-plugin</artifactId>
217-
<version>2.22.0</version>
218+
<version>3.0.0-M5</version>
219+
<configuration>
220+
<argLine>
221+
${argLine}
222+
--add-opens java.base/java.lang=ALL-UNNAMED
223+
--add-opens java.base/java.math=ALL-UNNAMED
224+
--add-opens java.base/java.io=ALL-UNNAMED
225+
--add-opens java.base/java.util=ALL-UNNAMED
226+
--add-opens
227+
java.base/java.util.stream=ALL-UNNAMED
228+
--add-opens java.base/java.text=ALL-UNNAMED
229+
--add-opens
230+
java.base/java.util.regex=ALL-UNNAMED
231+
--add-opens
232+
java.base/java.nio.channels.spi=ALL-UNNAMED
233+
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
234+
--add-opens java.base/java.net=ALL-UNNAMED
235+
--add-opens
236+
java.base/java.util.concurrent=ALL-UNNAMED
237+
--add-opens java.base/sun.nio.fs=ALL-UNNAMED
238+
--add-opens java.base/sun.nio.cs=ALL-UNNAMED
239+
--add-opens java.base/java.nio.file=ALL-UNNAMED
240+
--add-opens
241+
java.base/java.nio.charset=ALL-UNNAMED
242+
--add-opens
243+
java.base/java.lang.reflect=ALL-UNNAMED
244+
--add-opens
245+
java.logging/java.util.logging=ALL-UNNAMED
246+
--add-opens java.base/java.lang.ref=ALL-UNNAMED
247+
--add-opens java.base/java.util.jar=ALL-UNNAMED
248+
--add-opens java.base/java.util.zip=ALL-UNNAMED
249+
</argLine>
250+
251+
</configuration>
218252
</plugin>
219253
<plugin>
220254
<groupId>org.apache.maven.plugins</groupId>
221255
<artifactId>maven-jar-plugin</artifactId>
222-
<version>3.1.0</version>
256+
<version>3.2.0</version>
223257
</plugin>
224258
<plugin>
225259
<groupId>org.apache.maven.plugins</groupId>
226260
<artifactId>maven-javadoc-plugin</artifactId>
227-
<version>3.0.1</version>
261+
<version>3.1.1</version>
228262
<configuration>
229263
<show>public</show>
230264
<failOnError>false</failOnError>
231265
<additionalJOption>-Xdoclint:none</additionalJOption>
266+
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
232267
</configuration>
233268
<executions>
234269
<execution>
@@ -262,6 +297,40 @@
262297
<artifactId>maven-deploy-plugin</artifactId>
263298
<version>2.8.2</version>
264299
</plugin>
300+
<plugin>
301+
<groupId>org.jacoco</groupId>
302+
<artifactId>jacoco-maven-plugin</artifactId>
303+
<version>0.8.10</version>
304+
<configuration>
305+
<append>true</append>
306+
<excludes>
307+
<!-- This is required to prevent Jacoco from adding
308+
synthetic fields to a JavaBean class (causes errors in testing) -->
309+
<exclude>**/*Names*</exclude>
310+
<!-- Prevents the Material is too large to mock error -->
311+
<exclude>org/bukkit/Material*</exclude>
312+
</excludes>
313+
</configuration>
314+
<executions>
315+
<execution>
316+
<id>prepare-agent</id>
317+
<goals>
318+
<goal>prepare-agent</goal>
319+
</goals>
320+
</execution>
321+
<execution>
322+
<id>report</id>
323+
<goals>
324+
<goal>report</goal>
325+
</goals>
326+
<configuration>
327+
<formats>
328+
<format>XML</format>
329+
</formats>
330+
</configuration>
331+
</execution>
332+
</executions>
333+
</plugin>
265334
</plugins>
266335
</build>
267336

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package world.bentobox.chat;
2+
3+
4+
import world.bentobox.bentobox.api.addons.Addon;
5+
import world.bentobox.bentobox.api.addons.Pladdon;
6+
7+
/**
8+
* @author tastybento
9+
*
10+
*/
11+
public class ChatPladdon extends Pladdon {
12+
private Addon addon;
13+
14+
@Override
15+
public Addon getAddon() {
16+
if (addon == null) {
17+
addon = new Chat();
18+
}
19+
return addon;
20+
}
21+
}

src/main/java/world/bentobox/chat/listeners/ChatListener.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public class ChatListener implements Listener, EventExecutor {
3333
private static final String MESSAGE = "[message]";
3434
private final Chat addon;
3535
private final Set<UUID> teamChatUsers;
36-
private final Map<Island, Set<Player>> islands;
36+
private final Map<Island, Set<Player>> islandChatters;
3737
// List of which users are spying or not on team and island chat
3838
private final Set<UUID> spies;
3939
private final Set<UUID> islandSpies;
4040

4141
public ChatListener(Chat addon) {
4242
this.teamChatUsers = new HashSet<>();
43-
this.islands = new HashMap<>();
43+
this.islandChatters = new HashMap<>();
4444
this.addon = addon;
4545
// Initialize spies
4646
spies = new HashSet<>();
@@ -83,8 +83,8 @@ public void onChat(final AsyncPlayerChatEvent e) {
8383
}
8484
}
8585
addon.getIslands().getIslandAt(p.getLocation())
86-
.filter(islands.keySet()::contains)
87-
.filter(i -> islands.get(i).contains(p))
86+
.filter(islandChatters.keySet()::contains)
87+
.filter(i -> islandChatters.get(i).contains(p))
8888
.ifPresent(i -> {
8989
// Cancel the event
9090
e.setCancelled(true);
@@ -99,17 +99,13 @@ public void onChat(final AsyncPlayerChatEvent e) {
9999
// Removes player from TeamChat set if he left the island
100100
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
101101
public void onLeave(TeamLeaveEvent e) {
102-
103-
if (teamChatUsers.contains(e.getPlayerUUID()))
104-
teamChatUsers.remove(e.getPlayerUUID());
102+
teamChatUsers.remove(e.getPlayerUUID());
105103
}
106104

107105
// Removes player from TeamChat set if he was kicked from the island
108106
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
109107
public void onKick(TeamKickEvent e) {
110-
111-
if (teamChatUsers.contains(e.getPlayerUUID()))
112-
teamChatUsers.remove(e.getPlayerUUID());
108+
teamChatUsers.remove(e.getPlayerUUID());
113109
}
114110

115111
public void islandChat(Island i, Player player, String message) {
@@ -157,6 +153,20 @@ public boolean isTeamChat(UUID playerUUID) {
157153
return this.teamChatUsers.contains(playerUUID);
158154
}
159155

156+
/**
157+
* Whether the player has chat on or not. Note that with multiple islands the response is true
158+
* if *any* chat is enabled
159+
* @param playerUUID - player's UUID
160+
* @return true if chat is active on any island
161+
*/
162+
public boolean isChat(UUID playerUUID) {
163+
Player p = Bukkit.getPlayer(playerUUID);
164+
if (p == null) {
165+
return false;
166+
}
167+
return this.islandChatters.values().stream().anyMatch(playerSet -> playerSet.contains(p));
168+
}
169+
160170
/**
161171
* Toggles team chat spy. Spy must also have the spy permission to see chats
162172
* @param playerUUID - the player's UUID
@@ -206,20 +216,17 @@ public boolean togglePlayerTeamChat(UUID playerUUID) {
206216
/**
207217
* Toggle island chat state
208218
* @param island - island
219+
* @param player - player
209220
* @return true if island chat is now on, otherwise false
210221
*/
211222
public boolean toggleIslandChat(Island island, Player player) {
212-
if (islands.containsKey(island)) {
213-
if (islands.get(island).contains(player)) {
214-
islands.get(island).remove(player);
215-
return false;
216-
}
217-
islands.get(island).add(player);
218-
return true;
219-
}
220-
else {
221-
islands.put(island, new HashSet<>());
222-
islands.get(island).add(player);
223+
var chatters = islandChatters.computeIfAbsent(island, k -> new HashSet<>());
224+
225+
if (chatters.contains(player)) {
226+
chatters.remove(player);
227+
return false;
228+
} else {
229+
chatters.add(player);
223230
return true;
224231
}
225232
}

src/main/resources/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Configuration file for Chat 1.2.0-SNAPSHOT-LOCAL.
1+
# Configuration file for Chat {$version}.
22
team-chat:
33
# Lists the gamemodes in which you want the Team Chat to be effective.
44
gamemodes:

src/main/resources/plugin.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: BentoBox-Chat
2+
main: world.bentobox.chat.ChatPladdon
3+
version: ${project.version}${build.number}
4+
api-version: "1.16"
5+
6+
authors: [tastybento]
7+
contributors: ["The BentoBoxWorld Community"]
8+
website: https://bentobox.world
9+
description: ${project.description}

0 commit comments

Comments
 (0)