From 2994b2c1588ef4829ff3e4b494d7aba0652c6301 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 26 Mar 2020 20:55:27 +0000 Subject: [PATCH] Use try with resource to close ClipboardReader and stop adding "atic" to schematic files or not reason --- .../plot/util/SchematicHandler.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) 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 3883192c2..7492644d3 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 @@ -282,7 +282,7 @@ public abstract class SchematicHandler { Settings.Paths.SCHEMATICS + File.separator + name); if (!file.exists()) { file = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), - Settings.Paths.SCHEMATICS + File.separator + name + "atic"); + Settings.Paths.SCHEMATICS + File.separator + name); } return getSchematic(file); } @@ -319,18 +319,17 @@ public abstract class SchematicHandler { if (!file.exists()) { return null; } - try { - ClipboardFormat format = ClipboardFormats.findByFile(file); - if (format != null) { - ClipboardReader reader = format.getReader(new FileInputStream(file)); + ClipboardFormat format = ClipboardFormats.findByFile(file); + if (format != null) { + try (ClipboardReader reader = format.getReader(new FileInputStream(file))) { Clipboard clip = reader.read(); return new Schematic(clip); - } else { - throw new UnsupportedFormatException( - "This schematic format is not recognised or supported."); + } catch (IOException e) { + e.printStackTrace(); } - } catch (IOException e) { - e.printStackTrace(); + } else { + throw new UnsupportedFormatException( + "This schematic format is not recognised or supported."); } return null; }