I drank a shit load of monster and pulled two all-nighters, I have no idea what all i did to be honest

This commit is contained in:
BuildTools
2020-04-08 07:29:10 -05:00
parent 95a5f4cd1d
commit 2f2754cab8
17 changed files with 568 additions and 14 deletions
@@ -0,0 +1,53 @@
package dev.astridlabs.playtimerewardsplus;
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
import dev.astridlabs.playtimerewardsplus.Plugin;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.logging.Level;
public class MasterClock extends BukkitRunnable {
private final Plugin plugin;
private Integer clockTicks = 0;
public MasterClock(Plugin plugin){
this.plugin = plugin;
}
@Override
public void run() {
clockTicks++;
if((clockTicks/72000) > 1){
this.plugin.config.savePlayers();
this.plugin.getServer().getLogger().log(Level.INFO, "Hourly save completed! Data loss avoided");
}
// What you want to schedule goes here
for(Player p : plugin.getServer().getOnlinePlayers()) {
updatePlaytime(p);
updatePlayerLocations(p);
}
}
public void updatePlaytime(Player pl){
PlayerData player = plugin.db.getPlayer(pl.getUniqueId());
Integer playtime = player.getPlaytime();
Integer newplaytime = playtime+1;
player.setPlaytime(newplaytime);
}
public void updatePlayerLocations(Player pl){
PlayerData player = plugin.db.getPlayer(pl.getUniqueId());
if(player.getCurrentLocation() == null){
player.setCurrentLocation(pl.getLocation());
}else{
player.setLastLocation(player.getCurrentLocation());
player.setCurrentLocation(pl.getLocation());
}
}
}