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
+
diff --git a/src/main/java/me/m0r13/maptools/MapToolsPlugin.java b/src/main/java/me/m0r13/maptools/MapToolsPlugin.java
index f9a1c4b..8470b2d 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,7 @@
public class MapToolsPlugin extends JavaPlugin {
private Logger log;
+ private MarkerUpdateTask task;
@Override
public void onEnable() {
@@ -38,15 +44,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!");
}