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

Commit

Permalink
Add permission to silently join/leave servers (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
QarthO authored Dec 3, 2023
1 parent f53d276 commit 7f8163a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class Locales {

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

public Locales(@NotNull HuskChat plugin) {
this.plugin = plugin;
Expand Down Expand Up @@ -208,13 +210,19 @@ public void sendFormattedBroadcastMessage(@NotNull Player player, @NotNull Strin
}

public void sendJoinMessage(@NotNull Player player) {
if (player.hasPermission(SILENT_JOIN_PERMISSION)) {
return;
}
plugin.replacePlaceholders(player,
plugin.getDataGetter().getTextFromNode(player, "huskchat.join_message")
.orElse(plugin.getSettings().getJoinMessageFormat()))
.thenAccept(replaced -> sendJoinQuitMessage(player, new MineDown(replaced).toComponent()));
}

public void sendQuitMessage(@NotNull Player player) {
if (player.hasPermission(SILENT_QUIT_PERMISSION)) {
return;
}
plugin.replacePlaceholders(player,
plugin.getDataGetter().getTextFromNode(player, "huskchat.quit_message")
.orElse(plugin.getSettings().getQuitMessageFormat()))
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ join_and_quit_messages:
join:
enabled: false
# Use the huskchat.join_message.[text] permission to override this per-group if needed
# Use the huskchat.silent_join permission for a player to join without sending a message
format: '&e%name% joined the network'
quit:
enabled: false
# Use the huskchat.quit_message.[text] permission to override this per-group if needed
# Use the huskchat.silent_quit permission for a player to quit without sending a message
format: '&e%name% left the network'
broadcast_scope: GLOBAL # Note that on Velocity/Bungee, PASSTHROUGH modes won't cancel local join/quit messages

Expand Down

0 comments on commit 7f8163a

Please sign in to comment.