From 68a783bd4094b02e991429f3c7218139fd1945dc Mon Sep 17 00:00:00 2001 From: juanmuscaria Date: Thu, 16 Sep 2021 13:25:35 -0300 Subject: [PATCH] Use path directly for loading the proxy uuid --- .../fastlogin/velocity/FastLoginVelocity.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java index da524f47..a536e5a8 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java @@ -152,12 +152,12 @@ public class FastLoginVelocity implements PlatformPlugin { } private void loadOrGenerateProxyId() { - File idFile = new File(dataDirectory.toFile(), PROXY_ID_fILE); + Path idFile = dataDirectory.resolve(PROXY_ID_fILE); boolean shouldGenerate = false; - if (idFile.exists()) { + if (Files.exists(idFile)) { try { - List lines = Files.readAllLines(idFile.toPath(), StandardCharsets.UTF_8); + List lines = Files.readAllLines(idFile, StandardCharsets.UTF_8); if (lines.isEmpty()) { shouldGenerate = true; } else { @@ -165,10 +165,10 @@ public class FastLoginVelocity implements PlatformPlugin { } } catch (IOException e) { e.printStackTrace(); - logger.error("Unable to load proxy id from '{}'", idFile.getAbsolutePath()); + logger.error("Unable to load proxy id from '{}'", idFile.toAbsolutePath()); logger.error("Detailed exception:", e); } catch (IllegalArgumentException e) { - logger.error("'{}' contains an invalid uuid! FastLogin will not work without a valid id.", idFile.getAbsolutePath()); + logger.error("'{}' contains an invalid uuid! FastLogin will not work without a valid id.", idFile.toAbsolutePath()); } } else { shouldGenerate = true; @@ -177,10 +177,10 @@ public class FastLoginVelocity implements PlatformPlugin { if (shouldGenerate) { proxyId = UUID.randomUUID(); try { - Files.write(idFile.toPath(), Collections.singletonList(proxyId.toString()), + Files.write(idFile, Collections.singletonList(proxyId.toString()), StandardCharsets.UTF_8, StandardOpenOption.CREATE); } catch (IOException e) { - logger.error("Unable to save proxy id to '{}'", idFile.getAbsolutePath()); + logger.error("Unable to save proxy id to '{}'", idFile.toAbsolutePath()); logger.error("Detailed exception:", e); } }