mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2025-01-20 21:11:48 +01:00
Fixed loaders can be moved with pistons
This commit is contained in:
parent
17f8e72b2a
commit
96856729a7
@ -14,6 +14,8 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -89,6 +91,30 @@ public final class BlocksListener implements Listener {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onLoaderPistonRetract(BlockPistonRetractEvent e) {
|
||||
try {
|
||||
for (Block block : e.getBlocks()) {
|
||||
if(plugin.getLoaders().getChunkLoader(block.getLocation()).isPresent()) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onLoaderPistonExtend(BlockPistonExtendEvent e) {
|
||||
try {
|
||||
for (Block block : e.getBlocks()) {
|
||||
if(plugin.getLoaders().getChunkLoader(block.getLocation()).isPresent()) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
private boolean handleLoaderBreak(Block block, boolean dropItem){
|
||||
Location blockLoc = block.getLocation();
|
||||
Optional<ChunkLoader> optionalChunkLoader = plugin.getLoaders().getChunkLoader(blockLoc);
|
||||
|
Loading…
Reference in New Issue
Block a user