From c5bbfcadf42dfead6c8787b212bdce8389d50a4d Mon Sep 17 00:00:00 2001 From: Wesley Egbertsen Date: Sat, 24 Nov 2018 22:16:07 +0100 Subject: [PATCH 1/3] Updated pom so plugin support 1.13.2 api --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 470bfe9..b1b2810 100644 --- a/pom.xml +++ b/pom.xml @@ -41,10 +41,10 @@ org.spigotmc spigot-api - 1.10-R0.1-SNAPSHOT + 1.13.2-R0.1-SNAPSHOT provided jar - \ No newline at end of file + From e771514a18ec563f37a567c4e27e761ae3c084a3 Mon Sep 17 00:00:00 2001 From: Wesley Egbertsen Date: Sat, 24 Nov 2018 22:18:22 +0100 Subject: [PATCH 2/3] Updated MapToolsPlugin, so it's not registering another task in the onDisable, as this threw an exception on server stop. --- .../me/m0r13/maptools/MapToolsPlugin.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/m0r13/maptools/MapToolsPlugin.java b/src/main/java/me/m0r13/maptools/MapToolsPlugin.java index f9a1c4b..afa2298 100644 --- a/src/main/java/me/m0r13/maptools/MapToolsPlugin.java +++ b/src/main/java/me/m0r13/maptools/MapToolsPlugin.java @@ -19,6 +19,11 @@ package me.m0r13.maptools; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + import java.util.Collection; import java.util.LinkedList; import java.util.logging.Logger; @@ -28,6 +33,8 @@ public class MapToolsPlugin extends JavaPlugin { private Logger log; + + private MarkerUpdateTask task; @Override public void onEnable() { @@ -38,15 +45,26 @@ public void onEnable() { getConfig().options().copyDefaults(true); saveConfig(); - MarkerUpdateTask task = new MarkerUpdateTask(this); + task = new MarkerUpdateTask(this); task.runTaskTimer(this, 20, 20 * getConfig().getInt("interval", 5)); } @Override public void onDisable() { - // write an empty json file - Collection players = new LinkedList(); - new MarkerUpdateTask(this).writePlayers(players); + // Making sure we cancel the task, so there are no aditional task registerings while the server is stopping/stopping plugin + if (task != null) { + task.cancel(); + } + + try { + // write an empty json file + File file = new File(getConfig().getString("markerFile")); + BufferedWriter output = new BufferedWriter(new FileWriter(file)); + output.write("{\"players\":[]}"); + output.close(); + } catch (IOException e) { + e.printStackTrace(); + } log.info("Plugin disabled!"); } From 87d4af553eca6545ab3baa6eff877d85eb2419ed Mon Sep 17 00:00:00 2001 From: Wesley Egbertsen Date: Sat, 24 Nov 2018 22:19:29 +0100 Subject: [PATCH 3/3] Fixed formatting --- .../me/m0r13/maptools/MapToolsPlugin.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/m0r13/maptools/MapToolsPlugin.java b/src/main/java/me/m0r13/maptools/MapToolsPlugin.java index afa2298..8470b2d 100644 --- a/src/main/java/me/m0r13/maptools/MapToolsPlugin.java +++ b/src/main/java/me/m0r13/maptools/MapToolsPlugin.java @@ -33,8 +33,7 @@ public class MapToolsPlugin extends JavaPlugin { private Logger log; - - private MarkerUpdateTask task; + private MarkerUpdateTask task; @Override public void onEnable() { @@ -51,20 +50,20 @@ public void onEnable() { @Override public void onDisable() { - // Making sure we cancel the task, so there are no aditional task registerings while the server is stopping/stopping plugin - if (task != null) { + // Making sure we cancel the task, so there are no aditional task registerings while the server is stopping/stopping plugin + if (task != null) { task.cancel(); } - try { - // write an empty json file - File file = new File(getConfig().getString("markerFile")); - BufferedWriter output = new BufferedWriter(new FileWriter(file)); - output.write("{\"players\":[]}"); - output.close(); - } catch (IOException e) { - e.printStackTrace(); - } + try { + // write an empty json file + File file = new File(getConfig().getString("markerFile")); + BufferedWriter output = new BufferedWriter(new FileWriter(file)); + output.write("{\"players\":[]}"); + output.close(); + } catch (IOException e) { + e.printStackTrace(); + } log.info("Plugin disabled!"); }