Skip to content
This repository was archived by the owner on Oct 12, 2024. It is now read-only.

Commit 7f8163a

Browse files
authored
Add permission to silently join/leave servers (#175)
1 parent f53d276 commit 7f8163a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

common/src/main/java/net/william278/huskchat/config/Locales.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class Locales {
4141

4242
private final HuskChat plugin;
4343
private final Map<String, String> locales = new LinkedHashMap<>();
44+
private static final String SILENT_JOIN_PERMISSION = "huskchat.silent_join";
45+
private static final String SILENT_QUIT_PERMISSION = "huskchat.silent_quit";
4446

4547
public Locales(@NotNull HuskChat plugin) {
4648
this.plugin = plugin;
@@ -208,13 +210,19 @@ public void sendFormattedBroadcastMessage(@NotNull Player player, @NotNull Strin
208210
}
209211

210212
public void sendJoinMessage(@NotNull Player player) {
213+
if (player.hasPermission(SILENT_JOIN_PERMISSION)) {
214+
return;
215+
}
211216
plugin.replacePlaceholders(player,
212217
plugin.getDataGetter().getTextFromNode(player, "huskchat.join_message")
213218
.orElse(plugin.getSettings().getJoinMessageFormat()))
214219
.thenAccept(replaced -> sendJoinQuitMessage(player, new MineDown(replaced).toComponent()));
215220
}
216221

217222
public void sendQuitMessage(@NotNull Player player) {
223+
if (player.hasPermission(SILENT_QUIT_PERMISSION)) {
224+
return;
225+
}
218226
plugin.replacePlaceholders(player,
219227
plugin.getDataGetter().getTextFromNode(player, "huskchat.quit_message")
220228
.orElse(plugin.getSettings().getQuitMessageFormat()))

common/src/main/resources/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,12 @@ join_and_quit_messages:
205205
join:
206206
enabled: false
207207
# Use the huskchat.join_message.[text] permission to override this per-group if needed
208+
# Use the huskchat.silent_join permission for a player to join without sending a message
208209
format: '&e%name% joined the network'
209210
quit:
210211
enabled: false
211212
# Use the huskchat.quit_message.[text] permission to override this per-group if needed
213+
# Use the huskchat.silent_quit permission for a player to quit without sending a message
212214
format: '&e%name% left the network'
213215
broadcast_scope: GLOBAL # Note that on Velocity/Bungee, PASSTHROUGH modes won't cancel local join/quit messages
214216

0 commit comments

Comments
 (0)