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 139a22916..ff45fc80a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Backup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java @@ -203,6 +203,8 @@ public final class Backup extends Command { TranslatableCaption.of("backup_impossible"), Template.of("plot", "generic.generic_merged") ); + } else if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); } else if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { player.sendMessage( @@ -272,10 +274,8 @@ public final class Backup extends Command { TranslatableCaption.of("backup_impossible"), Template.of("plot", "generic.generic_merged") ); - player.sendMessage( - TranslatableCaption.of("backup_impossible"), - Template.of("plot", "generic.generic_merged") - ); + } else if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); } else if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { player.sendMessage( diff --git a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java index b8eb8f2a4..da67d1e76 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java +++ b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java @@ -58,6 +58,10 @@ public class CreateRoadSchematic extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } + if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); + return false; + } if (!(location.getPlotArea() instanceof HybridPlotWorld)) { player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java index 2223db91f..611e3c6bc 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -50,8 +50,11 @@ import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.Comparator; +import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; @CommandDeclaration(command = "debug", category = CommandCategory.DEBUG, @@ -195,4 +198,12 @@ public class Debug extends SubCommand { return true; } + @Override + public Collection tab(final PlotPlayer player, String[] args, boolean space) { + return Stream.of("loadedchunks", "debug-players", "logging", "entitytypes", "msg") + .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH))) + .map(value -> new Command(null, false, value, "plots.admin", RequiredType.NONE, null) { + }).collect(Collectors.toList()); + } + } diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java index 97a4b0e7d..2211c8446 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java @@ -58,6 +58,8 @@ public class DebugRoadRegen extends SubCommand { @Override public boolean onCommand(PlotPlayer player, String[] args) { + Location location = player.getLocation(); + Plot plot = location.getPlotAbs(); if (args.length < 1) { player.sendMessage( TranslatableCaption.of("commandconfig.command_syntax"), @@ -65,6 +67,11 @@ public class DebugRoadRegen extends SubCommand { ); return false; } + + if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); + return false; + } String kind = args[0].toLowerCase(); switch (kind) { case "plot": diff --git a/Core/src/main/java/com/plotsquared/core/command/Merge.java b/Core/src/main/java/com/plotsquared/core/command/Merge.java index ac41b1f8c..b76b56995 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -105,6 +105,10 @@ public class Merge 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; + } Direction direction = null; if (args.length == 0) { switch (direction(player.getLocationFull().getYaw())) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Save.java b/Core/src/main/java/com/plotsquared/core/command/Save.java index 78179e109..a49f8fa57 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Save.java +++ b/Core/src/main/java/com/plotsquared/core/command/Save.java @@ -79,6 +79,10 @@ public class Save 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; + } if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SAVE)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); diff --git a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java index 4b73fdf4d..8b7677ac5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java @@ -116,6 +116,10 @@ public class SchematicCmd extends SubCommand { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } + if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); + return false; + } if (this.running) { player.sendMessage(TranslatableCaption.of("error.task_in_process")); return false; @@ -179,6 +183,8 @@ public class SchematicCmd extends SubCommand { } case "saveall": case "exportall": { + Location loc = player.getLocation(); + final Plot plot = loc.getPlotAbs(); if (!(player instanceof ConsolePlayer)) { player.sendMessage(TranslatableCaption.of("console.not_console")); return false; @@ -191,6 +197,10 @@ public class SchematicCmd extends SubCommand { ); return false; } + if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); + return false; + } PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]); if (area == null) { player.sendMessage( @@ -246,6 +256,10 @@ public class SchematicCmd 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; + } if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, "plots.admin.command.schematic.save")) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); diff --git a/Core/src/main/java/com/plotsquared/core/command/Set.java b/Core/src/main/java/com/plotsquared/core/command/Set.java index 88991fc27..47086f8c2 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -230,6 +230,10 @@ public class Set extends SubCommand { player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } + if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); + return false; + } // components HashSet components = new HashSet<>(Arrays.asList(plot.getManager().getPlotComponents(plot.getId()))); diff --git a/Core/src/main/java/com/plotsquared/core/command/Unlink.java b/Core/src/main/java/com/plotsquared/core/command/Unlink.java index 1b5a63d3a..c3a61b5e3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Unlink.java +++ b/Core/src/main/java/com/plotsquared/core/command/Unlink.java @@ -67,6 +67,10 @@ public class Unlink 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; + } if (!plot.isMerged()) { player.sendMessage(TranslatableCaption.of("merge.unlink_impossible")); } diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java index 7419761d8..16ed7d9b1 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java @@ -162,6 +162,9 @@ public class ComponentPresetManager { } else if (!plot.isOwner(player.getUUID()) && !plot.getTrusted().contains(player.getUUID())) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return null; + } else if (plot.getVolume() > Integer.MAX_VALUE) { + player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); + return null; } final List allowedPresets = new ArrayList<>(this.presets.size()); diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index e83452510..584ccfc3e 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -8,7 +8,7 @@ "move.requires_unowned": "The location specified is already occupied.", "debug.requires_unmerged": "The plot cannot be merged.", "debug.debug_header": " Debug Information\n", - "debug.debug_section": ">> &l", + "debug.debug_section": ">> ", "debug.debug_line": ">> : \n", "debug.plot_debug": "[Plot Debug] (): ", "debug.fetching_loaded_chunks": "Fetching loaded chunks...",