Make send- and receive- chat flags respect group flags.

This commit is contained in:
wizjany 2018-02-24 09:39:16 -05:00
parent 3a332fd87d
commit d2c52f7c1b

View File

@ -153,14 +153,16 @@ public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld()); WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld());
if (wcfg.useRegions) { if (wcfg.useRegions) {
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.SEND_CHAT, player.getLocation())) { LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.SEND_CHAT, player.getLocation(), localPlayer)) {
player.sendMessage(ChatColor.RED + "You don't have permission to chat in this region!"); player.sendMessage(ChatColor.RED + "You don't have permission to chat in this region!");
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
for (Iterator<Player> i = event.getRecipients().iterator(); i.hasNext();) { for (Iterator<Player> i = event.getRecipients().iterator(); i.hasNext();) {
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.RECEIVE_CHAT, i.next().getLocation())) { Player rPlayer = i.next();
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.RECEIVE_CHAT, rPlayer.getLocation(), plugin.wrapPlayer(rPlayer))) {
i.remove(); i.remove();
} }
} }