From 448229892c7f57da42da96e1c51434dae88a907e Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 18 May 2019 09:40:58 -0700 Subject: [PATCH 1/7] Adds support for EpicSpawners --- pom.xml | 375 +++++++++--------- .../limits/listeners/BlockLimitsListener.java | 35 +- 2 files changed, 216 insertions(+), 194 deletions(-) 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); } } From 3450fe4695919cd64b771ae604461b44799608fd Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 24 May 2019 19:54:48 -0700 Subject: [PATCH 2/7] Handles count of islands that have no count history. https://github.com/BentoBoxWorld/addon-limits/issues/20 --- src/main/java/bentobox/addon/limits/commands/LimitsCalc.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/bentobox/addon/limits/commands/LimitsCalc.java b/src/main/java/bentobox/addon/limits/commands/LimitsCalc.java index f0f2945..de6be8f 100644 --- a/src/main/java/bentobox/addon/limits/commands/LimitsCalc.java +++ b/src/main/java/bentobox/addon/limits/commands/LimitsCalc.java @@ -135,6 +135,9 @@ public class LimitsCalc { private void tidyUp() { // Cancel task.cancel(); + if (ibc == null) { + ibc = new IslandBlockCount(); + } ibc.setBlockCount(blockCount); bll.setIsland(island.getUniqueId(), ibc); sender.sendMessage("admin.limits.calc.finished"); From 4b40d041b28d4dcaa7a5d644a010c927e1625611 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 25 May 2019 10:28:43 -0700 Subject: [PATCH 3/7] Updated POM for CodeMC --- pom.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a813cb2..0d47d78 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,10 @@ codemc https://repo.codemc.org/repository/maven-snapshots/ - + + codemc-repo + https://repo.codemc.org/repository/maven-public/ + From e0ad361c8ba8cf12d0881e2871ae4b8823dab21c Mon Sep 17 00:00:00 2001 From: tastybento Date: Tue, 28 May 2019 23:27:35 -0700 Subject: [PATCH 4/7] Change for where server does not have EpicSpawners installed. https://github.com/BentoBoxWorld/addon-limits/issues/20 --- .../java/bentobox/addon/limits/Limits.java | 8 +++++ .../limits/listeners/BlockLimitsListener.java | 10 +----- .../listeners/EpicSpawnersListener.java | 33 +++++++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 src/main/java/bentobox/addon/limits/listeners/EpicSpawnersListener.java diff --git a/src/main/java/bentobox/addon/limits/Limits.java b/src/main/java/bentobox/addon/limits/Limits.java index 8064fef..a2b62ed 100644 --- a/src/main/java/bentobox/addon/limits/Limits.java +++ b/src/main/java/bentobox/addon/limits/Limits.java @@ -3,12 +3,14 @@ package bentobox.addon.limits; import java.util.List; import java.util.stream.Collectors; +import org.bukkit.Bukkit; import org.bukkit.World; import bentobox.addon.limits.commands.AdminCommand; import bentobox.addon.limits.commands.PlayerCommand; import bentobox.addon.limits.listeners.BlockLimitsListener; import bentobox.addon.limits.listeners.EntityLimitListener; +import bentobox.addon.limits.listeners.EpicSpawnersListener; import bentobox.addon.limits.listeners.JoinListener; import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.GameModeAddon; @@ -55,6 +57,12 @@ public class Limits extends Addon { registerListener(blockLimitListener); registerListener(new JoinListener(this)); registerListener(new EntityLimitListener(this)); + // Register epic spawners one tick after load + Bukkit.getScheduler().runTask(getPlugin(), () -> { + if (Bukkit.getServer().getPluginManager().getPlugin("EpicSpawners") != null) { + registerListener(new EpicSpawnersListener(this)); + } + }); // Done } diff --git a/src/main/java/bentobox/addon/limits/listeners/BlockLimitsListener.java b/src/main/java/bentobox/addon/limits/listeners/BlockLimitsListener.java index 659c60b..f6067e5 100644 --- a/src/main/java/bentobox/addon/limits/listeners/BlockLimitsListener.java +++ b/src/main/java/bentobox/addon/limits/listeners/BlockLimitsListener.java @@ -40,8 +40,6 @@ 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 * @@ -148,13 +146,7 @@ public class BlockLimitsListener implements Listener { 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) { + 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 (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) { diff --git a/src/main/java/bentobox/addon/limits/listeners/EpicSpawnersListener.java b/src/main/java/bentobox/addon/limits/listeners/EpicSpawnersListener.java new file mode 100644 index 0000000..9d22c5d --- /dev/null +++ b/src/main/java/bentobox/addon/limits/listeners/EpicSpawnersListener.java @@ -0,0 +1,33 @@ +package bentobox.addon.limits.listeners; + +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; + +import com.songoda.epicspawners.api.events.SpawnerBreakEvent; + +import bentobox.addon.limits.Limits; + +/** + * @author tastybento + * + */ +public class EpicSpawnersListener implements Listener { + + Limits addon; + + /** + * @param addon + */ + public EpicSpawnersListener(Limits addon) { + this.addon = addon; + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onBlockBreak(SpawnerBreakEvent e) { + Block b = e.getSpawner().getLocation().getBlock(); + addon.getBlockLimitListener().handleBreak(e, e.getPlayer(), b); + } + +} From 9eec32f467bb639498219f4d43156682ea66076c Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 14 Jun 2019 18:14:32 -0700 Subject: [PATCH 5/7] Version up --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0d47d78..af5839e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 world.bentobox limits - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT addon-limits An add-on for BentoBox that limits blocks and entities on islands. https://github.com/BentoBoxWorld/addon-level From 539f7d604fb9ceebf8364bf5a0fa020fe8ebb6ef Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 14 Jun 2019 18:14:57 -0700 Subject: [PATCH 6/7] Fixes permission limits with multiple permissions https://github.com/BentoBoxWorld/addon-limits/issues/21 --- src/main/java/bentobox/addon/limits/listeners/JoinListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/bentobox/addon/limits/listeners/JoinListener.java b/src/main/java/bentobox/addon/limits/listeners/JoinListener.java index 9faccea..6bb8d1d 100644 --- a/src/main/java/bentobox/addon/limits/listeners/JoinListener.java +++ b/src/main/java/bentobox/addon/limits/listeners/JoinListener.java @@ -37,8 +37,8 @@ public class JoinListener implements Listener { private void checkPerms(Player player, String permissionPrefix, String islandId, String gameMode) { IslandBlockCount ibc = addon.getBlockLimitListener().getIsland(islandId); - int limit = -1; for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { + int limit = -1; if (perms.getPermission().startsWith(permissionPrefix)) { // Get the Material String[] split = perms.getPermission().split("\\."); From 3e073db3ff932f8329f0413f0ec4cefc3702e21b Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 14 Jun 2019 18:50:51 -0700 Subject: [PATCH 7/7] Removes reference to TIPPED_ARROW due to 1.14 incompatibility. Fixes https://github.com/BentoBoxWorld/addon-limits/issues/22 --- pom.xml | 4 ++-- src/main/java/bentobox/addon/limits/commands/LimitPanel.java | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index af5839e..cb8e032 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ org.spigotmc spigot-api - 1.13.2-R0.1-SNAPSHOT + 1.14.2-R0.1-SNAPSHOT provided @@ -71,7 +71,7 @@ world.bentobox bentobox - 1.4.0-SNAPSHOT + 1.5.0 provided diff --git a/src/main/java/bentobox/addon/limits/commands/LimitPanel.java b/src/main/java/bentobox/addon/limits/commands/LimitPanel.java index 7fb1470..ef7c48f 100644 --- a/src/main/java/bentobox/addon/limits/commands/LimitPanel.java +++ b/src/main/java/bentobox/addon/limits/commands/LimitPanel.java @@ -61,7 +61,6 @@ public class LimitPanel { E2M.put(EntityType.TRIDENT, null); E2M.put(EntityType.ARROW, null); E2M.put(EntityType.SPECTRAL_ARROW, null); - E2M.put(EntityType.TIPPED_ARROW, null); E2M.put(EntityType.SNOWBALL, null); E2M.put(EntityType.EGG, null); E2M.put(EntityType.LEASH_HITCH, null);