Files
src
build.gradle
manifest.kod
Code
26 1,812
src/main/java/com/frenzy/points/FrenzyPoints.java
package com.frenzy.points;
import com.frenzy.points.command.PointsCommand;
import com.frenzy.points.command.TaskCommand;
import com.frenzy.points.config.ConfigManager;
import com.frenzy.points.config.MessageManager;
import com.frenzy.points.database.DatabaseManager;
import com.frenzy.points.inventory.gui.GUIListener;
import com.frenzy.points.inventory.gui.GUIManager;
import com.frenzy.points.listener.PlayerListener;
import com.frenzy.points.manager.NameTagManager;
import com.frenzy.points.manager.PointsManager;
import com.frenzy.points.manager.TaskManager;
import com.frenzy.points.placeholder.FrenzyExpansion;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.SQLException;
@Getter
public class FrenzyPoints extends JavaPlugin {
private DatabaseManager databaseManager;
private PointsManager pointsManager;
private TaskManager taskManager;
private GUIManager guiManager;
private ConfigManager configManager;
private MessageManager messageManager;
private NameTagManager nameTagManager;
@Override
public void onEnable() {
saveDefaultConfig();
saveResource("messages.yml", false);
configManager = new ConfigManager(this);
messageManager = new MessageManager(this);
databaseManager = new DatabaseManager(this);
try {
databaseManager.init();
} catch (SQLException e) {
getLogger().severe("Failed to initialize database: " + e.getMessage());
Bukkit.getPluginManager().disablePlugin(this);
return;
}
pointsManager = new PointsManager(this);
taskManager = new TaskManager(this);
guiManager = new GUIManager();
nameTagManager = new NameTagManager(this);
// Load any players already online (reload scenario)
Bukkit.getOnlinePlayers().forEach(player -> {
pointsManager.loadPlayer(player.getUniqueId(), player.getName());
taskManager.loadTask(player.getUniqueId());
});
Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
PointsCommand pointsCommand = new PointsCommand(this);
TaskCommand taskCommand = new TaskCommand(this);
getCommand("frenzypoints").setExecutor(pointsCommand);
getCommand("frenzypoints").setTabCompleter(pointsCommand);
getCommand("frenzytask").setExecutor(taskCommand);
getCommand("frenzytask").setTabCompleter(taskCommand);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new FrenzyExpansion(this).register();
getLogger().info("Hooked into PlaceholderAPI.");
}
getLogger().info("FrenzyPoints v" + getDescription().getVersion() + " enabled!");
}
@Override
public void onDisable() {
if (pointsManager != null) pointsManager.saveAll();
if (taskManager != null) taskManager.saveAll();
if (nameTagManager != null) nameTagManager.clearAll();
if (databaseManager != null) databaseManager.close();
getLogger().info("FrenzyPoints disabled.");
}
}