Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
NeumimTo committed Sep 26, 2016
1 parent d788ae9 commit bf19543
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,9 @@ private AffineTransform doOffset(AffineTransform trans, Vector off) {
public void onEnable(GameInitializationEvent event) {


Optional<PluginContainer> 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();
}
Expand All @@ -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"));
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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<Map<String, SchematicDef>>(){}.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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit bf19543

Please sign in to comment.