From f13f7ce1291befeb8e866f2c9f355dc7ce59dd7b Mon Sep 17 00:00:00 2001 From: N0tMyFaultOG Date: Fri, 8 Jan 2021 16:06:15 +0100 Subject: [PATCH] Disable destructive operations for plot world plots --- Core/src/main/java/com/plotsquared/core/command/Backup.java | 2 ++ Core/src/main/java/com/plotsquared/core/command/Biome.java | 4 ++++ Core/src/main/java/com/plotsquared/core/command/Clear.java | 4 ++++ Core/src/main/java/com/plotsquared/core/command/Delete.java | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/Core/src/main/java/com/plotsquared/core/command/Backup.java b/Core/src/main/java/com/plotsquared/core/command/Backup.java index b6354a1a7..508a6fe83 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Backup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java @@ -137,6 +137,8 @@ public final class Backup extends Command { TranslatableCaption.of("backup_impossible"), Template.of("plot", "generic.generic_unowned") ); + } else if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); } else if (plot.isMerged()) { player.sendMessage( TranslatableCaption.of("backup_impossible"), diff --git a/Core/src/main/java/com/plotsquared/core/command/Biome.java b/Core/src/main/java/com/plotsquared/core/command/Biome.java index 54e13dae4..342301bfb 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Biome.java +++ b/Core/src/main/java/com/plotsquared/core/command/Biome.java @@ -65,6 +65,10 @@ public class Biome extends SetCommand { player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); return false; } + if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); + return false; + } plot.addRunning(); plot.getPlotModificationManager().setBiome(biome, () -> { plot.removeRunning(); diff --git a/Core/src/main/java/com/plotsquared/core/command/Clear.java b/Core/src/main/java/com/plotsquared/core/command/Clear.java index 992c1f340..4eae46a2a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Clear.java +++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java @@ -82,6 +82,10 @@ public class Clear extends Command { Template.of("value", "Clear")); return CompletableFuture.completedFuture(true); } + if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); + return CompletableFuture.completedFuture(true); + } boolean force = eventResult == Result.FORCE; checkTrue(force || plot.isOwner(player.getUUID()) || Permissions .hasPermission(player, "plots.admin.command.clear"), diff --git a/Core/src/main/java/com/plotsquared/core/command/Delete.java b/Core/src/main/java/com/plotsquared/core/command/Delete.java index 419e00710..432ef7947 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Delete.java +++ b/Core/src/main/java/com/plotsquared/core/command/Delete.java @@ -74,6 +74,10 @@ public class Delete extends SubCommand { player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } + if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); + return false; + } Result eventResult = this.eventDispatcher.callDelete(plot).getEventResult(); if (eventResult == Result.DENY) { player.sendMessage(