From 8cb2bdc846fe7183e3457245d85fbc445271738d Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 26 Dec 2018 16:44:39 +0000 Subject: [PATCH] Nice code to handle schematic loading and remove the ability to debugroadregen a specific chunk, as it uses a completely different method to actual road generation. --- .../plot/commands/DebugRoadRegen.java | 19 +------------------ .../plot/util/SchematicHandler.java | 12 +++--------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugRoadRegen.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugRoadRegen.java index 7b070e20f..cf8c76c6a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugRoadRegen.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugRoadRegen.java @@ -20,24 +20,7 @@ public class DebugRoadRegen extends SubCommand { } Plot plot = player.getCurrentPlot(); if (plot == null) { - ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); - int extend = 0; - if (args.length == 1) { - if (MathMan.isInteger(args[0])) { - try { - extend = Integer.parseInt(args[0]); - } catch (NumberFormatException ignored) { - C.NOT_VALID_NUMBER.send(player, "(0, )"); - return false; - } - } - } - boolean result = HybridUtils.manager.regenerateRoad(plotArea, chunk, extend); - MainUtil.sendMessage(player, - "&6Regenerating chunk: " + chunk.x + ',' + chunk.z + "\n&6 - Result: " + (result ? - "&aSuccess" : - "&cFailed")); - MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads"); + C.NOT_IN_PLOT.send(player); } else { HybridPlotManager manager = (HybridPlotManager) plotArea.getPlotManager(); manager.createRoadEast(plotArea, plot); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/SchematicHandler.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/SchematicHandler.java index 8cec91d30..f1ca31b4d 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/SchematicHandler.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/SchematicHandler.java @@ -291,15 +291,9 @@ public abstract class SchematicHandler { } try { ClipboardFormat format = ClipboardFormats.findByFile(file); - if (format == BuiltInClipboardFormat.SPONGE_SCHEMATIC) { - SpongeSchematicReader ssr = new SpongeSchematicReader( - new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))); - BlockArrayClipboard clip = (BlockArrayClipboard) ssr.read(); - return new Schematic(clip); - } else if (format == BuiltInClipboardFormat.MCEDIT_SCHEMATIC) { - MCEditSchematicReader msr = new MCEditSchematicReader( - new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))); - BlockArrayClipboard clip = (BlockArrayClipboard) msr.read(); + if (format != null) { + ClipboardReader reader = format.getReader(new FileInputStream(file)); + BlockArrayClipboard clip = (BlockArrayClipboard) reader.read(); return new Schematic(clip); } else { throw new UnsupportedFormatException(