Makes the protectEntrance option protect the entrance from all block placement
This commit is contained in:
parent
22bb75d4df
commit
6e7ac5dbb9
@ -25,6 +25,7 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
@ -96,6 +97,22 @@ public class BlockEventListener implements Listener {
|
||||
portal::drawSign, 1);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.isCancelled() || !Stargate.getGateConfig().protectEntrance()) {
|
||||
return;
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Portal portal = PortalHandler.getByEntrance(block);
|
||||
if (portal != null) {
|
||||
//Prevent blocks from being placed in the entrance, if protectEntrance is enabled, as breaking the block
|
||||
// would destroy the portal
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects block breaking to detect if the user is destroying a gate
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user