Skip to content

Commit

Permalink
Fix sign protection. Resolves #246; resolves #215. Thx @kuohsuanlo!
Browse files Browse the repository at this point in the history
  • Loading branch information
Sataniel98 committed Feb 11, 2018
1 parent 5e944cd commit f4f48b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand All @@ -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();
Expand All @@ -71,7 +72,7 @@ public void onBlockBreakWithSignOnIt(BlockBreakEvent event) {
event.setCancelled(bbe.isCancelled());
}

@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
Player player = event.getPlayer();
Expand All @@ -85,21 +86,21 @@ public void onBlockBreak(BlockBreakEvent event) {
}
}

@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) {
Expand Down Expand Up @@ -138,7 +139,7 @@ public void onPlayerPortal(PlayerPortalEvent event) {
}
}

@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPortalCreation(PlayerInteractEvent event) {
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(event.getPlayer());
if (!dPlayer.isCreatingPortal()) {
Expand Down Expand Up @@ -174,7 +175,7 @@ public void onPortalCreation(PlayerInteractEvent event) {

/* 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()) {
Expand Down Expand Up @@ -205,7 +206,7 @@ public void onInteract(PlayerInteractEvent event) {
}

@Deprecated
@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onSignChange(SignChangeEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -549,7 +550,7 @@ public boolean onBreak(BlockBreakEvent event) {
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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand All @@ -42,7 +43,7 @@ public DWorldListener(DWorldCache dWorlds) {
this.dWorlds = dWorlds;
}

@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
// DEditWorld Signs
Expand All @@ -61,7 +62,7 @@ public void onBlockBreak(BlockBreakEvent event) {
}
}

@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlock();

Expand All @@ -75,7 +76,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
}
}

@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockIgnite(BlockIgniteEvent event) {
if (dWorlds.getInstanceByWorld(event.getBlock().getWorld()) == null) {
return;
Expand All @@ -86,7 +87,7 @@ public void onBlockIgnite(BlockIgniteEvent event) {
}
}

@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockSpread(BlockSpreadEvent event) {
Block block = event.getSource();

Expand All @@ -106,7 +107,7 @@ public void onChunkUnload(ChunkUnloadEvent event) {
}
}

@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityExplode(EntityExplodeEvent event) {
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());

Expand All @@ -121,7 +122,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
}
}

@EventHandler
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
DGameWorld gameWorld = DGameWorld.getByWorld(event.getEntity().getWorld());
if (gameWorld != null) {
Expand Down

0 comments on commit f4f48b2

Please sign in to comment.