I'm trying to write an OnlineTime plugin right now and I set +1 min every 60 secs but the config does not save i also did "saveConfig".
Would be nice if someone can help me
package Main;
import java.util.Timer;
import java.util.TimerTask;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import Util.OnlineTimeCMD;
import Util.TimeManager;
public class main123 extends JavaPlugin {
public static main123 getPlugin () {
return plugin;
}
private static main123 plugin;
@Override
public void onEnable () {
plugin = this;
this.getCommand ("onlinetime"). SetExecutor (new OnlineTimeCMD ());
Timer count;
count = new Timer ();
count.scheduleAtFixedRate (new TimerTask () {
@Override
public void run () {
for (Player all: Bukkit.getOnlinePlayers ()) {
FileConfiguration config = plugin.getConfig ();
int newMins = TimeManager.getMinutes (all) +1;
config.set ("time." + all.getName (), newMins);
. ReloadConfig (main123.getPlugin ());
all.sendMessage ("§5 [§dOnlineTime§5] §d" + newMins);
. SaveConfig (main123.getPlugin ());
}
}
}, 0, 1000 * 60);
}
@Override
public void onDisable () {
Well. So first use the "BukkitRunnable" instead of a timer.
Also, you reload the config before saving… Why?
I do not know I just got used to it but my problem is already solved.