Check multiblock placement

This commit is contained in:
Fabrizio La Rosa 2020-07-12 12:46:23 +02:00
parent 51bb15a4f0
commit a6035254b3

View File

@ -199,7 +199,6 @@ public class Block implements Listener {
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
@ -215,14 +214,26 @@ public class Block implements Listener {
Island island = islandManager.getIslandAtLocation(blockLoc);
// Check permissions.
if (!plugin.getPermissionManager().processPermission(event, player, island))
if (!plugin.getPermissionManager().processPermission(event, player, island)){
return;
}
if (island == null) {
event.setCancelled(true);
return;
}
if(ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) {
if(event instanceof BlockMultiPlaceEvent) {
for(BlockState blockState : ((BlockMultiPlaceEvent) event).getReplacedBlockStates()) {
if(!island.equals(islandManager.getIslandAtLocation(blockState.getLocation()))) {
event.setCancelled(true);
return;
}
}
}
}
if (islandLevelManager.isScanning(island)) {
plugin.getMessageManager().sendMessage(player,
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));