fix NOT_BLACKLISTED perms

This commit is contained in:
okx-code
2026-05-12 02:20:21 +01:00
parent 5d474d6e6b
commit cae4db47c1
4 changed files with 19 additions and 16 deletions

View File

@@ -76,8 +76,6 @@ public class CivChat2Manager {
private int muteTimeSeconds;
private Group modsGroup;
private final StarManager starManager;
public CivChat2Manager(CivChat2 pluginInstance, ServerBroadcaster broadcaster, StarManager starManager) {

View File

@@ -16,12 +16,12 @@ import vg.civcraft.mc.namelayer.permission.PermissionType;
public class NLGroupBroadcastListener implements BroadcastListener {
private final Group group;
private final String groupName;
public NLGroupBroadcastListener(final Group group) {
Preconditions.checkNotNull(group, "group");
public NLGroupBroadcastListener(final String groupName) {
Preconditions.checkNotNull(groupName, "groupName");
this.group = group;
this.groupName = groupName;
}
@Override
@@ -29,7 +29,11 @@ public class NLGroupBroadcastListener implements BroadcastListener {
Location l = pearl.getHolder().getLocation();
String name = pearl.getHolder().getName();
String msg = String.format(ChatUtils.parseColor(Lang.groupPearlBroadcast), group.getName(), pearl.getPlayerName(), name, l.getBlockX(), l.getBlockY(), l.getBlockZ(), l.getWorld().getName());
Group group = GroupManager.getGroup(groupName);
if (group == null) {
return;
}
String msg = String.format(ChatUtils.parseColor(Lang.groupPearlBroadcast), groupName, pearl.getPlayerName(), name, l.getBlockX(), l.getBlockY(), l.getBlockZ(), l.getWorld().getName());
GroupManager gm = NameLayerAPI.getGroupManager();
@@ -55,16 +59,16 @@ public class NLGroupBroadcastListener implements BroadcastListener {
NLGroupBroadcastListener other = (NLGroupBroadcastListener) o;
return group.equals(other.group);
return this.groupName.equals(other.groupName);
}
@Override
public int hashCode() {
return group.hashCode();
return groupName.hashCode();
}
@Override
public boolean contains(Object o) {
return group.equals(o);
return groupName.equals(o);
}
}

View File

@@ -38,10 +38,11 @@ public class CmdPearlBroadcast extends PearlCommand {
}
// First check for a group
String groupName = argAsString(0);
if (plugin.isNameLayerEnabled()) {
GroupManager gm = NameLayerAPI.getGroupManager();
// First look for a matching group
Group g = GroupManager.getGroup(argAsString(0));
Group g = GroupManager.getGroup(groupName);
if (g != null) {
if (!gm.hasAccess(g, player().getUniqueId(), PermissionType.getPermission("WRITE_CHAT"))) {
@@ -51,13 +52,13 @@ public class CmdPearlBroadcast extends PearlCommand {
} else {
//If they are already broadcasting to group then remove the listener for that group
if (pearl.isBroadcastingTo(g)) {
pearl.removeBroadcastListener(new NLGroupBroadcastListener(g));
pearl.removeBroadcastListener(new NLGroupBroadcastListener(groupName));
msg(Lang.groupStoppedBcasting, g.getName());
return;
}
// Ok the group exists and the player has permission. Create the listener
pearl.addBroadcastListener(new NLGroupBroadcastListener(g));
pearl.addBroadcastListener(new NLGroupBroadcastListener(groupName));
msg(Lang.groupNowBcasting, g.getName());
return;
}
@@ -65,7 +66,7 @@ public class CmdPearlBroadcast extends PearlCommand {
}
// No group found, try to find a player
Player player = plugin.getPlayer(argAsString(0));
Player player = plugin.getPlayer(groupName);
if (player == null) {
msg(Lang.pearlNoPlayer);
return;

View File

@@ -1218,8 +1218,8 @@ public final class NameLayerWriteCoordinator {
}
private static void validateRole(final String role) {
if (!Set.of("MEMBERS", "MODS", "ADMINS", "OWNER").contains(role)) {
throw new IllegalArgumentException("role must be MEMBERS, MODS, ADMINS, or OWNER");
if (!Set.of("MEMBERS", "MODS", "ADMINS", "OWNER", "NOT_BLACKLISTED").contains(role)) {
throw new IllegalArgumentException("role must be MEMBERS, MODS, ADMINS, NOT_BLACKLISTED, or OWNER");
}
}