Files
src
build.gradle
Code
33 3,867
src/main/java/com/proteams/ProTeams.java
package com.proteams;
import com.proteams.command.TeamCommand;
import com.proteams.command.TMenuCommand;
import com.proteams.hook.PlaceholderAPIHook;
import com.proteams.hook.VaultHook;
import com.proteams.inventory.gui.GUIListener;
import com.proteams.inventory.gui.GUIManager;
import com.proteams.listener.PlaytimeListener;
import com.proteams.manager.*;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class ProTeams extends JavaPlugin {
private StorageManager storageManager;
private TeamManager teamManager;
private GUIManager guiManager;
private VaultHook vaultHook;
private BankManager bankManager;
private LevelManager levelManager;
private TeamStorageManager teamStorageManager;
private TeamHomeManager teamHomeManager;
private PlaytimeManager playtimeManager;
private TeleportManager teleportManager;
@Override
public void onEnable() {
this.storageManager = new StorageManager(this);
this.storageManager.loadConfigs();
this.playtimeManager = new PlaytimeManager(this);
this.playtimeManager.loadPlaytime();
this.playtimeManager.startTracking();
this.teamManager = new TeamManager(this);
this.teamManager.loadTeams();
this.teamManager.loadInvites();
this.guiManager = new GUIManager();
this.vaultHook = new VaultHook();
if (this.vaultHook.isEnabled()) {
this.getLogger().info("Vault hooked successfully!");
} else {
this.getLogger().warning("Vault not found - economy features disabled!");
}
this.bankManager = new BankManager(this);
this.levelManager = new LevelManager(this);
this.teamStorageManager = new TeamStorageManager(this);
this.teamHomeManager = new TeamHomeManager(this);
this.teleportManager = new TeleportManager(this);
this.getCommand("team").setExecutor(new TeamCommand(this));
this.getCommand("tmenu").setExecutor(new TMenuCommand(this));
Bukkit.getPluginManager().registerEvents(new GUIListener(this.guiManager), this);
Bukkit.getPluginManager().registerEvents(new PlaytimeListener(this), this);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderAPIHook(this).register();
this.getLogger().info("PlaceholderAPI hooked successfully!");
}
this.startAutoSave();
this.getLogger().info("ProTeams has been enabled!");
}
@Override
public void onDisable() {
if (this.playtimeManager != null) {
this.playtimeManager.stopTracking();
this.playtimeManager.savePlaytime();
}
if (this.teamManager != null) {
this.teamManager.saveTeams();
this.teamManager.saveInvites();
}
this.getLogger().info("ProTeams has been disabled!");
}
private void startAutoSave() {
int interval = this.storageManager.getConfig().getInt("storage.auto-save-interval", 300) * 20;
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
if (this.teamManager != null) {
this.teamManager.saveTeams();
this.teamManager.saveInvites();
}
if (this.playtimeManager != null) {
this.playtimeManager.savePlaytime();
}
}, interval, interval);
}
}