Skip to content

Commit ddd93ae

Browse files
committed
Refactors ignore command for staff exemption
Changes the ignore command to use the `essentials.ignore.exempt` permission instead of relying on JPerms for staff identification. This allows admins to easily configure staff members who cannot be ignored, regardless of their group membership. Also, ensures that exempted players are automatically unignored by all other players upon joining.
1 parent 34a1d60 commit ddd93ae

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import java.util.logging.Level;
1818
import java.util.logging.Logger;
1919

20+
import static org.bukkit.Bukkit.getPlayer;
21+
2022

2123
public class EssentialsPlayerListener extends PlayerListener {
2224
private static final Logger LOGGER = Logger.getLogger("Minecraft");
@@ -57,6 +59,23 @@ public void onPlayerChat(final PlayerChatEvent event) {
5759
if (ess.getSettings().changeDisplayName()) {
5860
user.setDisplayName(user.getNick());
5961
}
62+
63+
// If the user has ignore exempt permission, unignore them for all players
64+
if (user.hasPermission("essentials.ignore.exempt") || user.isOp()) {
65+
for (Player p : ess.getServer().getOnlinePlayers()) {
66+
// Skip self
67+
if(p.getName().equalsIgnoreCase(user.getName())) {
68+
continue;
69+
}
70+
71+
User u = ess.getUser(p);
72+
73+
// If the viewer is ignoring the poster, unignore them
74+
if (u.isIgnoredPlayer(user.getName())) {
75+
u.setIgnoredPlayer(user.getName(), false);
76+
}
77+
}
78+
}
6079
}
6180

6281
@Override

Essentials/src/main/java/com/earth2me/essentials/commands/Commandignore.java

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,10 @@ protected void run(Server server, User user, String commandLabel, String[] args)
5656
}
5757
String name = u.getName();
5858

59-
if (server.getPluginManager().getPlugin("JPerms") != null) {
60-
JohnyPerms permsPlugin = (JohnyPerms) server.getPluginManager().getPlugin("JPerms");
61-
if (permsPlugin != null) {
62-
JohnyPermsAPI permsAPI = new JohnyPermsAPI(permsPlugin);
63-
UUID uuid = getUUIDFromCache(name);
64-
if (uuid != null) {
65-
PermissionsUser jpUser = permsAPI.getUser(uuid);
66-
if (jpUser != null) {
67-
String groupName = jpUser.getGroup().getName().toLowerCase().trim();
68-
if (groupName.equals("trial") ||
69-
groupName.equals("helper") ||
70-
groupName.equals("moderator") ||
71-
groupName.equals("admin")) {
72-
user.sendMessage(ChatColor.RED + "You cannot ignore staff members!");
73-
return;
74-
}
75-
}
76-
}
77-
}
59+
if(u.hasPermission("essentials.ignore.exempt") || u.isOp()) {
60+
user.setIgnoredPlayer(name, false); // Ensure they are not ignored. This is useful if an op/exempt player was ignored before gaining exempt status.
61+
user.sendMessage(Util.format("ignoreExempt", u.getName()));
62+
return;
7863
}
7964

8065
if (user.isIgnoredPlayer(name)) {

Essentials/src/main/resources/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ unableToSpawnMob = Unable to spawn mob.
324324
unbannedIP = Unbanned IP address.
325325
unbannedPlayer = Unbanned player.
326326
unignorePlayer = You are not ignoring player {0} anymore.
327+
ignoreExempt = \u00a7cYou cannot ignore that player.
327328
unknownItemId = Unknown item id: {0}
328329
unknownItemInList = Unknown item {0} in {1} list.
329330
unknownItemName = Unknown item name: {0}

0 commit comments

Comments
 (0)