mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-24 18:19:03 +01:00
Added send-chat and receive-chat flags
This commit is contained in:
parent
ad5b1cdcba
commit
e67304389d
@ -39,6 +39,7 @@
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -263,6 +264,28 @@ public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld());
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.SEND_CHAT, player.getLocation())) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to chat in this region!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
for (Iterator<Player> i = event.getRecipients().iterator(); i.hasNext();) {
|
||||
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.RECEIVE_CHAT, i.next().getLocation())) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
if (event.getRecipients().size() == 0) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
@ -59,6 +59,8 @@ public final class DefaultFlag {
|
||||
public static final StateFlag ENDER_BUILD = new StateFlag("enderman-grief", true);
|
||||
public static final StateFlag INVINCIBILITY = new StateFlag("invincible", false, RegionGroup.ALL);
|
||||
public static final StateFlag EXP_DROPS = new StateFlag("exp-drops", true, RegionGroup.ALL);
|
||||
public static final StateFlag SEND_CHAT = new StateFlag("send-chat", true);
|
||||
public static final StateFlag RECEIVE_CHAT = new StateFlag("receive-chat", true);
|
||||
public static final StateFlag ENTRY = new StateFlag("entry", true);
|
||||
public static final StateFlag EXIT = new StateFlag("exit", true);
|
||||
public static final StateFlag ENTITY_PAINTING_DESTROY = new StateFlag("entity-painting-destroy", true);
|
||||
@ -93,7 +95,7 @@ public final class DefaultFlag {
|
||||
HEAL_AMOUNT, HEAL_DELAY, MIN_HEAL, MAX_HEAL,
|
||||
FEED_DELAY, FEED_AMOUNT, MIN_FOOD, MAX_FOOD,
|
||||
SNOW_FALL, SNOW_MELT, ICE_FORM, ICE_MELT,
|
||||
MUSHROOMS, LEAF_DECAY, GRASS_SPREAD,
|
||||
MUSHROOMS, LEAF_DECAY, GRASS_SPREAD, SEND_CHAT, RECEIVE_CHAT,
|
||||
FIRE_SPREAD, LAVA_FIRE, LAVA_FLOW, WATER_FLOW,
|
||||
TELE_LOC, SPAWN_LOC, POTION_SPLASH,
|
||||
BLOCKED_CMDS, ALLOWED_CMDS, PRICE, BUYABLE,
|
||||
|
Loading…
Reference in New Issue
Block a user