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) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -215,14 +214,26 @@ public class Block implements Listener {
Island island = islandManager.getIslandAtLocation(blockLoc); Island island = islandManager.getIslandAtLocation(blockLoc);
// Check permissions. // Check permissions.
if (!plugin.getPermissionManager().processPermission(event, player, island)) if (!plugin.getPermissionManager().processPermission(event, player, island)){
return; return;
}
if (island == null) { if (island == null) {
event.setCancelled(true); event.setCancelled(true);
return; 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)) { if (islandLevelManager.isScanning(island)) {
plugin.getMessageManager().sendMessage(player, plugin.getMessageManager().sendMessage(player,
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message")); plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));