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

Commit

Permalink
Chat: fix messages for people with permission
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Nov 24, 2023
1 parent 266b10f commit 93e5275
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.flectone.chat.module.commands.SpyListener;
import net.flectone.chat.module.integrations.IntegrationsModule;
import net.flectone.chat.util.MessageUtil;
import net.flectone.chat.util.PlayerUtil;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.World;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void playerChatEvent(@NotNull AsyncPlayerChatEvent event) {
}
}

if (playerChat == null) {
if (playerChat == null || !sender.hasPermission(getPermission())) {
String chatNotFound = locale.getVaultString(sender, getModule() + ".not-found");
sender.sendMessage(MessageUtil.formatAll(sender, chatNotFound));

Expand Down Expand Up @@ -99,7 +100,12 @@ public void playerChatEvent(@NotNull AsyncPlayerChatEvent event) {
}
}

List<Player> recipientsList = new ArrayList<>(Bukkit.getOnlinePlayers());
List<Player> recipientsList = (List<Player>) PlayerUtil.getPlayersWithFeature(getModule() + ".enable");
recipientsList = (List<Player>) PlayerUtil.getPlayersWithFeature(recipientsList, getModule() + ".list." + playerChat + ".enable");

String finalPlayerChat = playerChat;
recipientsList.removeIf(player -> !player.hasPermission(getPermission())
|| !player.hasPermission(getPermission() + "." + finalPlayerChat));

List<String> chatWorldsList = config.getVaultStringList(sender, getModule() + ".list." + playerChat + ".worlds");
if (!chatWorldsList.isEmpty()) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ permissions:
default: true
flectonechat.player-message.book:
default: true
flectonechat.player-message.chat:
default: true
flectonechat.player-message.chat.local:
default: true
flectonechat.player-message.chat.global:
Expand Down

0 comments on commit 93e5275

Please sign in to comment.