Explicitly sets user for break blocks check.

The user was not being set. Also the ordering of event handling was
random because both listeners had the same priority.

Should fix:
https://github.com/BentoBoxWorld/BentoBox/issues/534
This commit is contained in:
tastybento 2019-02-11 07:39:03 -08:00
parent 28c89ff814
commit 1d5057ec5a
2 changed files with 8 additions and 4 deletions

View File

@ -264,12 +264,16 @@ public class BlockInteractionListener extends FlagListener {
}
/**
* Prevents blocks that are protected from being broken, which would bypass the protection
* When breaking blocks is allowed, this protects
* specific blocks from being broken, which would bypass the protection.
* For example, player enables break blocks, but chests are still protected
* Fires after the BreakBlocks check.
*
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent e) {
setUser(User.getInstance(e.getPlayer()));
checkClickedBlock(e, e.getBlock().getLocation(), e.getBlock().getType());
}
}

View File

@ -29,7 +29,7 @@ public class BreakBlocksListener extends FlagListener {
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent e) {
checkIsland(e, e.getBlock().getLocation(), Flags.BREAK_BLOCKS);
setUser(User.getInstance(e.getPlayer())).checkIsland(e, e.getBlock().getLocation(), Flags.BREAK_BLOCKS);
}
/**
@ -74,7 +74,7 @@ public class BreakBlocksListener extends FlagListener {
case CAKE:
case DRAGON_EGG:
case SPAWNER:
checkIsland(e, e.getClickedBlock().getLocation(), Flags.BREAK_BLOCKS);
setUser(User.getInstance(e.getPlayer())).checkIsland(e, e.getClickedBlock().getLocation(), Flags.BREAK_BLOCKS);
break;
default:
break;