Skip to content

Commit

Permalink
Silent join/quit for permission (#75)
Browse files Browse the repository at this point in the history
* Add silentJoin/Quit permissions

Co-authored-by: _Soft1k_ <[email protected]>
  • Loading branch information
xKumorio and SoftikGithub authored Jun 14, 2022
1 parent 9412550 commit 9d5191a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ private void onPlayerJoinEvent(PlayerJoinEvent evt) {
));
return;
}
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("JoinMessage").replace("%player%", evt.getPlayer().getName())));
if (!evt.getPlayer().hasPermission("anarchyexploitfixes.silentJoin"))
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("JoinMessage").replace("%player%", evt.getPlayer().getName())));
}
}
return;
Expand Down Expand Up @@ -66,13 +67,15 @@ private void onPlayerLeave(PlayerQuitEvent evt) {
if (config.getBoolean("ConnectionMsgsOnByDefault")) {
for (Player p : Bukkit.getOnlinePlayers()) {
if (!plugin.connectionMsgs.contains(p.getName())) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("LeaveMessage").replace("%player%", evt.getPlayer().getName())));
if (!evt.getPlayer().hasPermission("anarchyexploitfixes.silentLeave"))
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("LeaveMessage").replace("%player%", evt.getPlayer().getName())));
}
}
} else {
for (Player p : Bukkit.getOnlinePlayers()) {
if (plugin.connectionMsgs.contains(p.getName())) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("LeaveMessage").replace("%player%", evt.getPlayer().getName())));
if (!evt.getPlayer().hasPermission("anarchyexploitfixes.silentLeave"))
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("LeaveMessage").replace("%player%", evt.getPlayer().getName())));
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ KickMessage: "&6You have lost connection to the server"
PreventSpamKick: false
Preventlinks: false # Code by John200410, edited by moomoo
Replace@: false

# If you want to hide yourself or someone else when logging into the game, just give these rights:
# anarchyexploitfixes.silentJoin
# anarchyexploitfixes.silentLeave
JoinLeaveMessages: false
ConnectionMsgsOnByDefault: true # /toggleconnectionmsgs
EnableFirstJoinMessage: false
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ commands:

permissions:
anarchyexploitfixes.netherroofbypass:
description: Bypass nether roof restrictions. (if enabled)
description: Bypass nether roof restrictions. (if enabled)
anarchyexploitfixes.silentJoin:
description: enable silent join mode
anarchyexploitfixes.silentLeave:
description: enable silent join mode

0 comments on commit 9d5191a

Please sign in to comment.