Fix sign protection. Resolves #246; resolves #215. Thx @kuohsuanlo!

This commit is contained in:
Daniel Saukel 2018-02-12 00:00:23 +01:00
parent 5e944cd920
commit f4f48b2c47
3 changed files with 18 additions and 15 deletions

View File

@ -29,6 +29,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
@ -47,7 +48,7 @@ public class GlobalProtectionListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreakWithSignOnIt(BlockBreakEvent event) {
Block block = event.getBlock();
Player player = event.getPlayer();
@ -71,7 +72,7 @@ public class GlobalProtectionListener implements Listener {
event.setCancelled(bbe.isCancelled());
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
Player player = event.getPlayer();
@ -85,21 +86,21 @@ public class GlobalProtectionListener implements Listener {
}
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockSpread(BlockSpreadEvent event) {
if (DPortal.getByBlock(event.getBlock()) != null) {
event.setCancelled(true);
}
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockPhysics(BlockPhysicsEvent event) {
if (DPortal.getByBlock(event.getBlock()) != null) {
event.setCancelled(true);
}
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityExplode(EntityExplodeEvent event) {
List<Block> blocklist = event.blockList();
for (Block block : blocklist) {
@ -138,7 +139,7 @@ public class GlobalProtectionListener implements Listener {
}
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPortalCreation(PlayerInteractEvent event) {
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(event.getPlayer());
if (!dPlayer.isCreatingPortal()) {
@ -174,7 +175,7 @@ public class GlobalProtectionListener implements Listener {
/* SUBJECT TO CHANGE */
@Deprecated
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (plugin.getDPlayers().getByPlayer(player).isInBreakMode()) {
@ -205,7 +206,7 @@ public class GlobalProtectionListener implements Listener {
}
@Deprecated
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onSignChange(SignChangeEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();

View File

@ -16,6 +16,7 @@
*/
package io.github.dre2n.dungeonsxl.world;
import io.github.dre2n.commons.misc.BlockUtil;
import io.github.dre2n.commons.misc.FileUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
@ -549,7 +550,7 @@ public class DGameWorld extends DInstanceWorld {
Player player = event.getPlayer();
Block block = event.getBlock();
for (DSign dSign : dSigns) {
if (block.equals(dSign.getSign().getBlock()) && dSign.getType().isProtected()) {
if ((block.equals(dSign.getSign().getBlock()) || block.equals(BlockUtil.getAttachedBlock(dSign.getSign().getBlock()))) && dSign.getType().isProtected()) {
return true;
}
}

View File

@ -20,6 +20,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockIgniteEvent;
@ -42,7 +43,7 @@ public class DWorldListener implements Listener {
this.dWorlds = dWorlds;
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
// DEditWorld Signs
@ -61,7 +62,7 @@ public class DWorldListener implements Listener {
}
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
@ -75,7 +76,7 @@ public class DWorldListener implements Listener {
}
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockIgnite(BlockIgniteEvent event) {
if (dWorlds.getInstanceByWorld(event.getBlock().getWorld()) == null) {
return;
@ -86,7 +87,7 @@ public class DWorldListener implements Listener {
}
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockSpread(BlockSpreadEvent event) {
Block block = event.getSource();
@ -106,7 +107,7 @@ public class DWorldListener implements Listener {
}
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityExplode(EntityExplodeEvent event) {
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
@ -121,7 +122,7 @@ public class DWorldListener implements Listener {
}
}
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
if (gameWorld != null) {