Adds support for EpicSpawners

This commit is contained in:
tastybento 2019-05-18 09:40:58 -07:00
parent ffeb4a7386
commit 448229892c
2 changed files with 216 additions and 194 deletions

13
pom.xml
View File

@ -1,8 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>world.bentobox</groupId> <groupId>world.bentobox</groupId>
<artifactId>limits</artifactId> <artifactId>limits</artifactId>
<version>0.2.0-SNAPSHOT</version> <version>0.2.1-SNAPSHOT</version>
<name>addon-limits</name> <name>addon-limits</name>
<description>An add-on for BentoBox that limits blocks and entities on islands.</description> <description>An add-on for BentoBox that limits blocks and entities on islands.</description>
<url>https://github.com/BentoBoxWorld/addon-level</url> <url>https://github.com/BentoBoxWorld/addon-level</url>
@ -35,6 +37,7 @@
<id>codemc</id> <id>codemc</id>
<url>https://repo.codemc.org/repository/maven-snapshots/</url> <url>https://repo.codemc.org/repository/maven-snapshots/</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -68,6 +71,12 @@
<version>1.4.0-SNAPSHOT</version> <version>1.4.0-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>EpicSpawners-API</artifactId>
<version>5.2</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -12,6 +12,7 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; 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.database.Database;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
import com.songoda.epicspawners.api.events.SpawnerBreakEvent;
/** /**
* @author tastybento * @author tastybento
* *
@ -142,22 +145,32 @@ public class BlockLimitsListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlock(BlockBreakEvent e) { 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 // 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) { 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(e.getBlock().getRelative(BlockFace.UP), false); process(b.getRelative(BlockFace.UP), false);
} }
if (e.getBlock().getRelative(BlockFace.EAST).getType() == Material.REDSTONE_WALL_TORCH) { if (b.getRelative(BlockFace.EAST).getType() == Material.REDSTONE_WALL_TORCH) {
process(e.getBlock().getRelative(BlockFace.EAST), false); process(b.getRelative(BlockFace.EAST), false);
} }
if (e.getBlock().getRelative(BlockFace.WEST).getType() == Material.REDSTONE_WALL_TORCH) { if (b.getRelative(BlockFace.WEST).getType() == Material.REDSTONE_WALL_TORCH) {
process(e.getBlock().getRelative(BlockFace.WEST), false); process(b.getRelative(BlockFace.WEST), false);
} }
if (e.getBlock().getRelative(BlockFace.SOUTH).getType() == Material.REDSTONE_WALL_TORCH) { if (b.getRelative(BlockFace.SOUTH).getType() == Material.REDSTONE_WALL_TORCH) {
process(e.getBlock().getRelative(BlockFace.SOUTH), false); process(b.getRelative(BlockFace.SOUTH), false);
} }
if (e.getBlock().getRelative(BlockFace.NORTH).getType() == Material.REDSTONE_WALL_TORCH) { if (b.getRelative(BlockFace.NORTH).getType() == Material.REDSTONE_WALL_TORCH) {
process(e.getBlock().getRelative(BlockFace.NORTH), false); process(b.getRelative(BlockFace.NORTH), false);
} }
} }