diff --git a/src/main/java/com/mikeprimm/bukkit/SchematicBrush/SchematicBrush.java b/src/main/java/com/mikeprimm/bukkit/SchematicBrush/SchematicBrush.java index 144d9a9..4ba9360 100644 --- a/src/main/java/com/mikeprimm/bukkit/SchematicBrush/SchematicBrush.java +++ b/src/main/java/com/mikeprimm/bukkit/SchematicBrush/SchematicBrush.java @@ -328,11 +328,9 @@ private AffineTransform doOffset(AffineTransform trans, Vector off) { public void onEnable(GameInitializationEvent event) { - Optional pl = Sponge.getPluginManager().getPlugin("WorldEdit"); - if (pl.isPresent()) { - if (!Files.exists(Paths.get(config.getAbsolutePath()+"/config.conf"))) { + if (!Files.exists(Paths.get(config.getAbsolutePath()))) { try { - new File(Paths.get(config.getAbsolutePath() + "/config.conf").toUri()).createNewFile(); + new File(Paths.get(config.getAbsolutePath()).toUri()).createNewFile(); } catch (IOException e) { e.printStackTrace(); } @@ -359,13 +357,9 @@ public void onEnable(GameInitializationEvent event) { .arguments(GenericArguments.remainingJoinedStrings(Text.of("args"))) .executor(this::handleSCHLISTCommand) .build(), "/schlist"); - } else { - throw new RuntimeException("WorldEdit not installed"); } - } - private CommandResult handleSCHBRCommand(CommandSource commandSource, CommandContext commandContext) { if (!(commandSource instanceof Player)) { commandSource.sendMessage(Text.of("This can only be used by players")); @@ -709,7 +703,7 @@ private File getDirectoryForFormat(String fmt) { if (fmt.equals("schematic")) { // Get from worldedit directory return WorldEdit.getInstance().getWorkingDirectoryFile(WorldEdit.getInstance().getConfiguration().saveDir); } else { // Else, our own type specific directory - return new File(config, fmt); + return new File(config.getParent(), fmt); } } @@ -879,9 +873,10 @@ private SchematicDef parseSchematic(Actor player, String sch) { private void loadSchematicSets() { Gson g = new Gson(); try { - String s = new String(Files.readAllBytes(Paths.get(config.getAbsolutePath()+"/config.conf"))); + String s = new String(Files.readAllBytes(Paths.get(config.getAbsolutePath()))); Type type = new TypeToken>(){}.getType(); - sets = new HashMap<>(g.fromJson(s, type)); + LinkedHashMap obj = g.fromJson(s, type); + sets = new HashMap<>(obj == null ? Collections.EMPTY_MAP : obj); } catch (IOException e) { e.printStackTrace(); } @@ -892,7 +887,7 @@ private void saveSchematicSets() { String s = g.toJson(sets); try { - Files.write(Paths.get(config.getAbsolutePath()+"/config.conf"),s.getBytes(), StandardOpenOption.CREATE); + Files.write(Paths.get(config.getAbsolutePath()),s.getBytes(), StandardOpenOption.CREATE); } catch (IOException e) { e.printStackTrace(); }