added creation of file

This commit is contained in:
Niklas 2019-12-07 17:01:31 +01:00
parent 54276dbab1
commit d94e5b4fdf

View File

@ -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();