From 669dbbeb785f892c575906b23314fc720c969d6b Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 2 May 2020 02:08:43 +1200 Subject: [PATCH] Fix FileUtils being referenced when it's not compatible with 1.12 and other alternatives exist --- src/main/java/me/libraryaddict/disguise/DisguiseConfig.java | 4 +--- .../disguise/utilities/updates/UpdateChecker.java | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index 4cb8d872..62a13f3f 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -27,7 +27,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.craftbukkit.libs.org.apache.commons.io.FileUtils; import org.bukkit.entity.Entity; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; @@ -528,8 +527,7 @@ public class DisguiseConfig { try { if (config.exists()) { - FileUtils.copyFile(config, new File(config.getParentFile(), "config-old.yml")); - config.delete(); + config.renameTo(new File(config.getParentFile(), "config-old.yml")); DisguiseUtilities.getLogger().info("Old config has been copied to config-old.yml"); } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/updates/UpdateChecker.java b/src/main/java/me/libraryaddict/disguise/utilities/updates/UpdateChecker.java index f79c7542..0485c1bd 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/updates/UpdateChecker.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/updates/UpdateChecker.java @@ -9,7 +9,6 @@ import me.libraryaddict.disguise.utilities.plugin.PluginInformation; import me.libraryaddict.disguise.utilities.translations.LibsMsg; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import org.bukkit.craftbukkit.libs.org.apache.commons.io.FileUtils; import org.bukkit.entity.Player; import java.io.BufferedReader; @@ -19,6 +18,8 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; import java.util.Date; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -232,7 +233,7 @@ public class UpdateChecker { // Get the input stream, what we receive try (InputStream input = con.getInputStream()) { - FileUtils.copyInputStreamToFile(input, dest); + Files.copy(input, dest.toPath(), StandardCopyOption.REPLACE_EXISTING); } DisguiseUtilities.getLogger().info("Download success!");