From d94e5b4fdfaf8f1a122cf86f62f78bac358500c6 Mon Sep 17 00:00:00 2001 From: Niklas Date: Sat, 7 Dec 2019 17:01:31 +0100 Subject: [PATCH] added creation of file --- src/pid/Main.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pid/Main.java b/src/pid/Main.java index b5299ae..f380a48 100644 --- a/src/pid/Main.java +++ b/src/pid/Main.java @@ -9,7 +9,7 @@ import java.util.logging.Level; public class Main extends JavaPlugin { @Override public void onEnable() { - getConfig().addDefault("PIDFile", "~/bukkit.pid"); + getConfig().addDefault("PIDFile", "bukkit.pid"); saveConfig(); String pid = getPid(); savePid(pid); @@ -28,6 +28,12 @@ public class Main extends JavaPlugin { private void savePid(String pid) { String pidLocation = getPidFileLocation(); try { + File file = new File(pidLocation); + if(file.exists()){ + file.delete(); + } + file.createNewFile(); + PrintWriter writer = new PrintWriter(pidLocation, StandardCharsets.UTF_8); writer.print(pid); writer.close();