diff --git a/pom.xml b/pom.xml index 2a32c67..a813cb2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,190 +1,199 @@ - - 4.0.0 - world.bentobox - limits - 0.2.0-SNAPSHOT - addon-limits - An add-on for BentoBox that limits blocks and entities on islands. - https://github.com/BentoBoxWorld/addon-level - 2018 + + 4.0.0 + world.bentobox + limits + 0.2.1-SNAPSHOT + addon-limits + An add-on for BentoBox that limits blocks and entities on islands. + https://github.com/BentoBoxWorld/addon-level + 2018 - - scm:git:https://github.com/BentoBoxWorld/addon-limits.git - scm:git:git@github.com:BentoBoxWorld/addon-limits.git - https://github.com/BentoBoxWorld/addon-limits - + + scm:git:https://github.com/BentoBoxWorld/addon-limits.git + scm:git:git@github.com:BentoBoxWorld/addon-limits.git + https://github.com/BentoBoxWorld/addon-limits + - - GitHub - https://github.com/BentoBoxWorld/addon-limits/issues - + + GitHub + https://github.com/BentoBoxWorld/addon-limits/issues + - - UTF-8 - UTF-8 - 1.8 - 1.7.4 - + + UTF-8 + UTF-8 + 1.8 + 1.7.4 + - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots - - - codemc - https://repo.codemc.org/repository/maven-snapshots/ - - + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots + + + codemc + https://repo.codemc.org/repository/maven-snapshots/ + - - - org.spigotmc - spigot-api - 1.13.2-R0.1-SNAPSHOT - provided - - - org.mockito - mockito-all - 1.10.19 - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - org.powermock - powermock-api-mockito - ${powermock.version} - test - - - world.bentobox - bentobox - 1.4.0-SNAPSHOT - provided - - + + + + + org.spigotmc + spigot-api + 1.13.2-R0.1-SNAPSHOT + provided + + + org.mockito + mockito-all + 1.10.19 + test + + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito + ${powermock.version} + test + + + world.bentobox + bentobox + 1.4.0-SNAPSHOT + provided + + + com.songoda + EpicSpawners-API + 5.2 + provided + + + + + clean package + + + src/main/resources + true + + + src/main/resources/locales + ./locales + false + + + + + org.apache.maven.plugins + maven-clean-plugin + 3.1.0 + + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.0 + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.0 + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.1 + + public + false + -Xdoclint:none + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.1 + + false + + + + org.apache.maven.plugins + maven-install-plugin + 2.5.2 + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + + org.jacoco + jacoco-maven-plugin + 0.8.1 + + true + + + + pre-unit-test + + prepare-agent + + + + post-unit-test + + report + + + + + + - - clean package - - - src/main/resources - true - - - src/main/resources/locales - ./locales - false - - - - - org.apache.maven.plugins - maven-clean-plugin - 3.1.0 - - - org.apache.maven.plugins - maven-resources-plugin - 3.1.0 - - - org.apache.maven.plugins - maven-compiler-plugin - 3.7.0 - - ${java.version} - ${java.version} - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.0 - - - org.apache.maven.plugins - maven-jar-plugin - 3.1.0 - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.1 - - public - false - -Xdoclint:none - - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.1.1 - - false - - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - - - org.jacoco - jacoco-maven-plugin - 0.8.1 - - true - - - - pre-unit-test - - prepare-agent - - - - post-unit-test - - report - - - - - - - \ No newline at end of file diff --git a/src/main/java/bentobox/addon/limits/listeners/BlockLimitsListener.java b/src/main/java/bentobox/addon/limits/listeners/BlockLimitsListener.java index 9838f7e..659c60b 100644 --- a/src/main/java/bentobox/addon/limits/listeners/BlockLimitsListener.java +++ b/src/main/java/bentobox/addon/limits/listeners/BlockLimitsListener.java @@ -12,6 +12,7 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -39,6 +40,8 @@ import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.Database; import world.bentobox.bentobox.util.Util; +import com.songoda.epicspawners.api.events.SpawnerBreakEvent; + /** * @author tastybento * @@ -142,22 +145,32 @@ public class BlockLimitsListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlock(BlockBreakEvent e) { - notify(e, User.getInstance(e.getPlayer()), process(e.getBlock(), false), e.getBlock().getType()); + handleBreak(e, e.getPlayer(), e.getBlock()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onBlockBreak(SpawnerBreakEvent e) { + Block b = e.getSpawner().getLocation().getBlock(); + handleBreak(e, e.getPlayer(), b); + } + + private void handleBreak(Cancellable e, Player player, Block b) { + notify(e, User.getInstance(player), process(b, false), b.getType()); // Player breaks a block and there was a redstone dust/repeater/... above - if (e.getBlock().getRelative(BlockFace.UP).getType() == Material.REDSTONE_WIRE || e.getBlock().getRelative(BlockFace.UP).getType() == Material.REPEATER || e.getBlock().getRelative(BlockFace.UP).getType() == Material.COMPARATOR || e.getBlock().getRelative(BlockFace.UP).getType() == Material.REDSTONE_TORCH) { - process(e.getBlock().getRelative(BlockFace.UP), false); + if (b.getRelative(BlockFace.UP).getType() == Material.REDSTONE_WIRE || b.getRelative(BlockFace.UP).getType() == Material.REPEATER || b.getRelative(BlockFace.UP).getType() == Material.COMPARATOR || b.getRelative(BlockFace.UP).getType() == Material.REDSTONE_TORCH) { + process(b.getRelative(BlockFace.UP), false); } - if (e.getBlock().getRelative(BlockFace.EAST).getType() == Material.REDSTONE_WALL_TORCH) { - process(e.getBlock().getRelative(BlockFace.EAST), false); + if (b.getRelative(BlockFace.EAST).getType() == Material.REDSTONE_WALL_TORCH) { + process(b.getRelative(BlockFace.EAST), false); } - if (e.getBlock().getRelative(BlockFace.WEST).getType() == Material.REDSTONE_WALL_TORCH) { - process(e.getBlock().getRelative(BlockFace.WEST), false); + if (b.getRelative(BlockFace.WEST).getType() == Material.REDSTONE_WALL_TORCH) { + process(b.getRelative(BlockFace.WEST), false); } - if (e.getBlock().getRelative(BlockFace.SOUTH).getType() == Material.REDSTONE_WALL_TORCH) { - process(e.getBlock().getRelative(BlockFace.SOUTH), false); + if (b.getRelative(BlockFace.SOUTH).getType() == Material.REDSTONE_WALL_TORCH) { + process(b.getRelative(BlockFace.SOUTH), false); } - if (e.getBlock().getRelative(BlockFace.NORTH).getType() == Material.REDSTONE_WALL_TORCH) { - process(e.getBlock().getRelative(BlockFace.NORTH), false); + if (b.getRelative(BlockFace.NORTH).getType() == Material.REDSTONE_WALL_TORCH) { + process(b.getRelative(BlockFace.NORTH), false); } }