61 lines
1.7 KiB
Java
61 lines
1.7 KiB
Java
package net.crankedpvp.factionlogs;
|
|
|
|
import lombok.Getter;
|
|
import net.crankedpvp.factionlogs.commands.FactionLogsCommand;
|
|
import net.crankedpvp.factionlogs.data.FactionLogsData;
|
|
import net.crankedpvp.factionlogs.data.FactionLogsManager;
|
|
import net.crankedpvp.factionlogs.listeners.FactionListeners;
|
|
import net.crankedpvp.factionlogs.struct.typeadapters.FactionLogDeserializer;
|
|
import net.crankedpvp.storageutils.StorageUtils;
|
|
import net.crankedpvp.storageutils.gson.Gson;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
@Getter
|
|
public class FactionLogsPlugin extends JavaPlugin {
|
|
|
|
public FactionLogsManager logManager;
|
|
private static FactionLogsPlugin instance;
|
|
private Gson gson;
|
|
|
|
|
|
public void onEnable() {
|
|
instance = this;
|
|
|
|
this.gson = StorageUtils.getInstance()
|
|
.getGson()
|
|
.newBuilder()
|
|
.registerTypeAdapter(FactionLogsData.class, new FactionLogDeserializer()).setLenient()
|
|
.create();
|
|
|
|
this.logManager = new FactionLogsManager();
|
|
this.logManager.loadAll();
|
|
loadListeners();
|
|
loadCommands();
|
|
Bukkit.getScheduler().runTaskTimer(this, () -> {
|
|
this.logManager.saveAll();
|
|
}, 100L, 20 * 60 * 15);
|
|
}
|
|
|
|
public void onDisable() {
|
|
//this.logManager.purge();
|
|
this.logManager.saveAll();
|
|
instance = null;
|
|
}
|
|
|
|
|
|
public void loadListeners() {
|
|
Bukkit.getPluginManager().registerEvents(new FactionListeners(), this);
|
|
}
|
|
|
|
public void loadCommands() {
|
|
Bukkit.getPluginManager().registerEvents(new FactionLogsCommand(), this);
|
|
|
|
}
|
|
|
|
public static FactionLogsPlugin getInstance() {
|
|
return instance;
|
|
}
|
|
}
|