mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-19 15:48:10 +01:00
Fixed a bunch of small bugs
This commit is contained in:
parent
2eb6c76da8
commit
e9402c55e6
@ -33,6 +33,7 @@
|
|||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
import org.bukkit.event.block.BlockDispenseEvent;
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
|
import org.bukkit.event.block.BlockExpEvent;
|
||||||
import org.bukkit.event.block.BlockFadeEvent;
|
import org.bukkit.event.block.BlockFadeEvent;
|
||||||
import org.bukkit.event.block.BlockFormEvent;
|
import org.bukkit.event.block.BlockFormEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
@ -139,7 +140,7 @@ public void onBlockBreak(BlockBreakEvent event) {
|
|||||||
if (held.getTypeId() > 0
|
if (held.getTypeId() > 0
|
||||||
&& !(ItemType.usesDamageValue(held.getTypeId())
|
&& !(ItemType.usesDamageValue(held.getTypeId())
|
||||||
|| BlockType.usesData(held.getTypeId()))) {
|
|| BlockType.usesData(held.getTypeId()))) {
|
||||||
held.setDurability((short) -1);
|
held.setDurability(Material.getMaterial(held.getTypeId()).getMaxDurability());
|
||||||
player.setItemInHand(held);
|
player.setItemInHand(held);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -872,4 +873,17 @@ public void onBlockDispense(BlockDispenseEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when a block yields exp
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockExp(BlockExpEvent event) {
|
||||||
|
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||||
|
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
|
||||||
|
if (wcfg.disableExpDrops) {
|
||||||
|
event.setExpToDrop(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -88,9 +88,6 @@
|
|||||||
public class WorldGuardEntityListener implements Listener {
|
public class WorldGuardEntityListener implements Listener {
|
||||||
|
|
||||||
private WorldGuardPlugin plugin;
|
private WorldGuardPlugin plugin;
|
||||||
private EntityType fireballType;
|
|
||||||
private EntityType witherType;
|
|
||||||
private EntityType witherSkullType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object;
|
* Construct the object;
|
||||||
@ -99,10 +96,6 @@ public class WorldGuardEntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
public WorldGuardEntityListener(WorldGuardPlugin plugin) {
|
public WorldGuardEntityListener(WorldGuardPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
fireballType = BukkitUtil.tryEnum(EntityType.class, "LARGE_FIREBALL", "FIREBALL");
|
|
||||||
witherType = BukkitUtil.tryEnum(EntityType.class, "WITHER");
|
|
||||||
witherSkullType = BukkitUtil.tryEnum(EntityType.class, "WITHER_SKULL");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -563,20 +556,71 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not all explosions come from an entity
|
if (ent instanceof Creeper) {
|
||||||
if (ent != null) {
|
if (wcfg.blockCreeperBlockDamage) {
|
||||||
if (ent instanceof Wither) {
|
event.blockList().clear();
|
||||||
if (wcfg.blockWitherBlockDamage) {
|
return;
|
||||||
event.blockList().clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.blockWitherExplosions) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wcfg.blockCreeperExplosions) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcfg.useRegions) {
|
||||||
|
if (wcfg.useRegions) {
|
||||||
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
|
|
||||||
|
for (Block block : event.blockList()) {
|
||||||
|
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.CREEPER_EXPLOSION)) {
|
||||||
|
event.blockList().clear();
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ent instanceof EnderDragon) {
|
||||||
|
if (wcfg.blockEnderDragonBlockDamage) {
|
||||||
|
event.blockList().clear();
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcfg.useRegions) {
|
||||||
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
|
|
||||||
|
for (Block block : event.blockList()) {
|
||||||
|
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE)) {
|
||||||
|
event.blockList().clear();
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ent instanceof TNTPrimed) {
|
||||||
|
if (wcfg.blockTNTBlockDamage) {
|
||||||
|
event.blockList().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcfg.blockTNTExplosions) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcfg.useRegions) {
|
||||||
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
|
|
||||||
|
for (Block block : event.blockList()) {
|
||||||
|
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.TNT)) {
|
||||||
|
event.blockList().clear();
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ent instanceof Fireball) {
|
||||||
if (ent instanceof WitherSkull) {
|
if (ent instanceof WitherSkull) {
|
||||||
if (wcfg.blockWitherSkullBlockDamage) {
|
if (wcfg.blockWitherSkullBlockDamage) {
|
||||||
event.blockList().clear();
|
event.blockList().clear();
|
||||||
@ -587,73 +631,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (ent instanceof Creeper) {
|
|
||||||
if (wcfg.blockCreeperBlockDamage) {
|
|
||||||
event.blockList().clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.blockCreeperExplosions) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
|
||||||
if (wcfg.useRegions) {
|
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
|
||||||
|
|
||||||
for (Block block : event.blockList()) {
|
|
||||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.CREEPER_EXPLOSION)) {
|
|
||||||
event.blockList().clear();
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (ent instanceof EnderDragon) {
|
|
||||||
if (wcfg.blockEnderDragonBlockDamage) {
|
|
||||||
event.blockList().clear();
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
|
||||||
|
|
||||||
for (Block block : event.blockList()) {
|
|
||||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE)) {
|
|
||||||
event.blockList().clear();
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (ent instanceof TNTPrimed) {
|
|
||||||
if (wcfg.blockTNTBlockDamage) {
|
|
||||||
event.blockList().clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.blockTNTExplosions) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
|
||||||
|
|
||||||
for (Block block : event.blockList()) {
|
|
||||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.TNT)) {
|
|
||||||
event.blockList().clear();
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (ent instanceof Fireball && !(ent instanceof WitherSkull)) {
|
|
||||||
if (wcfg.blockFireballBlockDamage) {
|
if (wcfg.blockFireballBlockDamage) {
|
||||||
event.blockList().clear();
|
event.blockList().clear();
|
||||||
return;
|
return;
|
||||||
@ -663,21 +641,31 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// allow wither skull blocking since there is no dedicated flag atm
|
||||||
|
if (wcfg.useRegions) {
|
||||||
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
for (Block block : event.blockList()) {
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.GHAST_FIREBALL)) {
|
||||||
|
event.blockList().clear();
|
||||||
for (Block block : event.blockList()) {
|
event.setCancelled(true);
|
||||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.GHAST_FIREBALL)) {
|
return;
|
||||||
event.blockList().clear();
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (ent instanceof Wither) {
|
||||||
|
if (wcfg.blockWitherBlockDamage) {
|
||||||
|
event.blockList().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcfg.blockWitherExplosions) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// null entity, caused by another plugin or so
|
// unhandled entity
|
||||||
if (wcfg.blockOtherExplosions) {
|
if (wcfg.blockOtherExplosions) {
|
||||||
event.blockList().clear();
|
event.blockList().clear();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -694,6 +682,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (wcfg.signChestProtection) {
|
if (wcfg.signChestProtection) {
|
||||||
for (Block block : event.blockList()) {
|
for (Block block : event.blockList()) {
|
||||||
if (wcfg.isChestProtected(block)) {
|
if (wcfg.isChestProtected(block)) {
|
||||||
@ -720,31 +709,27 @@ public void onExplosionPrime(ExplosionPrimeEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getEntityType() == witherType) {
|
if (event.getEntityType() == EntityType.WITHER) {
|
||||||
if (wcfg.blockWitherExplosions) {
|
if (wcfg.blockWitherExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (event.getEntityType() == EntityType.WITHER_SKULL) {
|
||||||
else if (event.getEntityType() == witherSkullType) {
|
|
||||||
if (wcfg.blockWitherSkullExplosions) {
|
if (wcfg.blockWitherSkullExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (event.getEntityType() == EntityType.FIREBALL) {
|
||||||
else if (event.getEntityType() == fireballType) {
|
|
||||||
if (wcfg.blockFireballExplosions) {
|
if (wcfg.blockFireballExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (event.getEntityType() == EntityType.CREEPER) {
|
||||||
else if (event.getEntityType() == EntityType.CREEPER) {
|
|
||||||
if (wcfg.blockCreeperExplosions) {
|
if (wcfg.blockCreeperExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (event.getEntityType() == EntityType.PRIMED_TNT) {
|
||||||
else if (event.getEntityType() == EntityType.PRIMED_TNT) {
|
|
||||||
if (wcfg.blockTNTExplosions) {
|
if (wcfg.blockTNTExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -810,7 +795,7 @@ public void onCreatePortal(EntityCreatePortalEvent event) {
|
|||||||
|
|
||||||
switch (event.getEntityType()) {
|
switch (event.getEntityType()) {
|
||||||
case ENDER_DRAGON:
|
case ENDER_DRAGON:
|
||||||
if (wcfg.blockEnderDragonBlockDamage) event.setCancelled(true);
|
if (wcfg.blockEnderDragonPortalCreation) event.setCancelled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -856,7 +841,7 @@ public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
|||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onEndermanPickup(EntityChangeBlockEvent event) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||||
Entity ent = event.getEntity();
|
Entity ent = event.getEntity();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = block.getLocation();
|
Location location = block.getLocation();
|
||||||
@ -875,8 +860,7 @@ public void onEndermanPickup(EntityChangeBlockEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ent.getType() == witherType) {
|
} else if (ent.getType() == EntityType.WITHER) {
|
||||||
|
|
||||||
if (wcfg.blockWitherBlockDamage || wcfg.blockWitherExplosions) {
|
if (wcfg.blockWitherBlockDamage || wcfg.blockWitherExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -570,7 +570,8 @@ private void handleBlockLeftClick(PlayerInteractEvent event) {
|
|||||||
|
|
||||||
if (block.getRelative(event.getBlockFace()).getTypeId() == BlockID.FIRE) {
|
if (block.getRelative(event.getBlockFace()).getTypeId() == BlockID.FIRE) {
|
||||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||||
&& !set.canBuild(localPlayer)) {
|
&& !mgr.getApplicableRegions(block.getRelative(event.getBlockFace())
|
||||||
|
.getLocation()).canBuild(localPlayer)) {
|
||||||
event.setUseInteractedBlock(Result.DENY);
|
event.setUseInteractedBlock(Result.DENY);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -664,7 +665,9 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
|||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(block);
|
Vector pt = toVector(block);
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||||
|
Block placedIn = block.getRelative(event.getBlockFace());
|
||||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||||
|
ApplicableRegionSet placedInSet = mgr.getApplicableRegions(placedIn.getLocation());
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
|
|
||||||
if (item.getTypeId() == wcfg.regionWand && plugin.hasPermission(player, "worldguard.region.wand")) {
|
if (item.getTypeId() == wcfg.regionWand && plugin.hasPermission(player, "worldguard.region.wand")) {
|
||||||
@ -689,26 +692,28 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block placedOn = block.getRelative(event.getBlockFace());
|
|
||||||
if (item.getTypeId() == BlockID.TNT) {
|
if (item.getTypeId() == BlockID.TNT) {
|
||||||
|
// workaround for a bug that allowed tnt to trigger instantly if placed
|
||||||
|
// next to redstone, without plugins getting the block place event
|
||||||
|
// (not sure if this actually still happens)
|
||||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||||
&& !plugin.getGlobalRegionManager().allows(
|
&& !placedInSet.allows(DefaultFlag.TNT, localPlayer)) {
|
||||||
DefaultFlag.TNT, placedOn.getLocation(), localPlayer)) {
|
|
||||||
event.setUseItemInHand(Result.DENY);
|
event.setUseItemInHand(Result.DENY);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hacky workaround for craftbukkit bug
|
// hacky workaround for craftbukkit bug
|
||||||
|
// has since been fixed, but leaving for legacy
|
||||||
if (item.getTypeId() == BlockID.STEP
|
if (item.getTypeId() == BlockID.STEP
|
||||||
|| item.getTypeId() == BlockID.WOODEN_STEP) {
|
|| item.getTypeId() == BlockID.WOODEN_STEP) {
|
||||||
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)) {
|
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)) {
|
||||||
boolean cancel = false;
|
boolean cancel = false;
|
||||||
if ((block.getTypeId() == item.getTypeId())
|
if ((block.getTypeId() == item.getTypeId())
|
||||||
&& !plugin.getGlobalRegionManager().canBuild(player, block.getLocation())) {
|
&& !set.canBuild(localPlayer)) {
|
||||||
// if we are on a step already, the new block will end up in the same block as the interact
|
// if we are on a step already, the new block will end up in the same block as the interact
|
||||||
cancel = true;
|
cancel = true;
|
||||||
} else if (!plugin.getGlobalRegionManager().canBuild(player, placedOn.getLocation())) {
|
} else if (!placedInSet.canBuild(localPlayer)) {
|
||||||
// if we are on another block, the half-slab in hand will be pushed to the adjacent block
|
// if we are on another block, the half-slab in hand will be pushed to the adjacent block
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
@ -740,9 +745,9 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
|||||||
b0 = 1;
|
b0 = 1;
|
||||||
}
|
}
|
||||||
// end mojang-level code
|
// end mojang-level code
|
||||||
Block headLoc = placedOn.getRelative(b0, 0, b1);
|
Location headLoc = placedIn.getRelative(b0, 0, b1).getLocation();
|
||||||
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
|
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
|
||||||
&& !(plugin.canBuild(player, block) && plugin.canBuild(player, headLoc))) {
|
&& !mgr.getApplicableRegions(headLoc).canBuild(localPlayer)) {
|
||||||
// note that normal block placement is handled later, this is just a workaround
|
// note that normal block placement is handled later, this is just a workaround
|
||||||
// for the location of the head block of the bed
|
// for the location of the head block of the bed
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||||
@ -751,6 +756,44 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (block.getTypeId() == BlockID.PISTON_MOVING_PIECE) {
|
||||||
|
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||||
|
&& !set.canBuild(localPlayer)) {
|
||||||
|
event.setUseInteractedBlock(Result.DENY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getTypeId() == ItemID.WOODEN_DOOR_ITEM || item.getTypeId() == ItemID.IRON_DOOR_ITEM) {
|
||||||
|
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
|
||||||
|
&& !placedInSet.canBuild(localPlayer)) {
|
||||||
|
// note that normal block placement is handled later, this is just a workaround
|
||||||
|
// for the location of the top block of the door
|
||||||
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getTypeId() == ItemID.FIRE_CHARGE || item.getTypeId() == ItemID.FLINT_AND_TINDER) {
|
||||||
|
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
|
||||||
|
&& !placedInSet.canBuild(localPlayer)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.setUseItemInHand(Result.DENY);
|
||||||
|
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to use that here.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getTypeId() == ItemID.EYE_OF_ENDER && block.getTypeId() == BlockID.END_PORTAL_FRAME) {
|
||||||
|
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||||
|
&& !set.canBuild(localPlayer)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.setUseItemInHand(Result.DENY);
|
||||||
|
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to use that here.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (item.getTypeId() == ItemID.INK_SACK
|
if (item.getTypeId() == ItemID.INK_SACK
|
||||||
&& item.getData() != null) {
|
&& item.getData() != null) {
|
||||||
if (item.getData().getData() == 15 // bonemeal
|
if (item.getData().getData() == 15 // bonemeal
|
||||||
@ -886,8 +929,8 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
|||||||
|| item.getTypeId() == ItemID.POWERED_MINECART
|
|| item.getTypeId() == ItemID.POWERED_MINECART
|
||||||
|| item.getTypeId() == ItemID.STORAGE_MINECART)) {
|
|| item.getTypeId() == ItemID.STORAGE_MINECART)) {
|
||||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||||
&& !set.canBuild(localPlayer)
|
&& !placedInSet.canBuild(localPlayer)
|
||||||
&& !set.allows(DefaultFlag.PLACE_VEHICLE, localPlayer)) {
|
&& !placedInSet.allows(DefaultFlag.PLACE_VEHICLE, localPlayer)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to place vehicles here.");
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to place vehicles here.");
|
||||||
event.setUseItemInHand(Result.DENY);
|
event.setUseItemInHand(Result.DENY);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -897,8 +940,8 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
|||||||
|
|
||||||
if (item.getTypeId() == ItemID.WOOD_BOAT) {
|
if (item.getTypeId() == ItemID.WOOD_BOAT) {
|
||||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||||
&& !set.canBuild(localPlayer)
|
&& !placedInSet.canBuild(localPlayer)
|
||||||
&& !set.allows(DefaultFlag.PLACE_VEHICLE, localPlayer)) {
|
&& !placedInSet.allows(DefaultFlag.PLACE_VEHICLE, localPlayer)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to place vehicles here.");
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to place vehicles here.");
|
||||||
event.setUseItemInHand(Result.DENY);
|
event.setUseItemInHand(Result.DENY);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user