Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<!-- Bukkit API Version, change if out dated -->
<version>1.10-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<type>jar</type>
</dependency>
</dependencies>

</project>
</project>
25 changes: 21 additions & 4 deletions src/main/java/me/m0r13/maptools/MapToolsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,6 +33,7 @@

public class MapToolsPlugin extends JavaPlugin {
private Logger log;
private MarkerUpdateTask task;

@Override
public void onEnable() {
Expand All @@ -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<Player> players = new LinkedList<Player>();
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!");
}
Expand Down