From a2480c04584b470c073c0a747692a7c77bd49ac8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 6 Jun 2015 16:59:46 +1000 Subject: [PATCH] Added bukkit.yml to conversion --- PlotSquared/pom.xml | 2 +- .../plotme/ClassicPlotMeConnector.java | 6 ++++++ .../database/plotme/LikePlotMeConverter.java | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 63c836f3b..2accbf031 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.11.11 + 2.11.13 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java index b7fdab3e9..468886f41 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java @@ -1,6 +1,12 @@ package com.intellectualcrafters.plot.database.plotme; import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/LikePlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/LikePlotMeConverter.java index b02104e23..88167032c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/LikePlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/LikePlotMeConverter.java @@ -22,6 +22,11 @@ package com.intellectualcrafters.plot.database.plotme; import java.io.File; import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.sql.Connection; import java.util.ArrayList; import java.util.Arrays; @@ -85,6 +90,17 @@ public class LikePlotMeConverter { return plotConfig.getConfigurationSection("worlds").getKeys(false); } + public void updateBukkitYml(String plugin) { + try { + Path path = Paths.get("bukkit.yml"); + Charset charset = StandardCharsets.UTF_8; + String content = new String(Files.readAllBytes(path), charset); + content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared"); + content = content.replaceAll(plugin, "PlotSquared"); + Files.write(path, content.getBytes(charset)); + } catch (Exception e) {}; + } + public boolean run(final APlotMeConnector connector) { try { String dataFolder = getPlotMePath(); @@ -113,6 +129,9 @@ public class LikePlotMeConverter { sendMessage(" - " + dbPrefix + "Plots"); final Set worlds = getPlotMeWorlds(plotConfig); + sendMessage("Updating bukkit.yml"); + updateBukkitYml(plugin); + for (final String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) { sendMessage("Copying config for: " + world); try {