Files
src
build.gradle
Code
7 632
src/main/java/com/playercapacitytest/PlayerCapacityTest.java
package com.playercapacitytest;
import com.playercapacitytest.commands.TestCommand;
import com.playercapacitytest.managers.PerformanceMonitor;
import com.playercapacitytest.managers.TestManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class PlayerCapacityTest extends JavaPlugin {
private TestManager testManager;
private PerformanceMonitor performanceMonitor;
@Override
public void onEnable() {
saveDefaultConfig();
if (getServer().getPluginManager().getPlugin("Citizens") == null) {
getLogger().severe("Citizens not found! This plugin requires Citizens to function.");
getLogger().severe("Download it from: https://www.spigotmc.org/resources/citizens.13811/");
getServer().getPluginManager().disablePlugin(this);
return;
}
this.testManager = new TestManager(this);
this.testManager.initialize();
this.performanceMonitor = new PerformanceMonitor(this);
getCommand("capacitytest").setExecutor(new TestCommand(this));
if (getConfig().getBoolean("monitoring.enabled", true)) {
performanceMonitor.startMonitoring();
}
getLogger().info("PlayerCapacityTest has been enabled!");
getLogger().info("Use /capacitytest to manage fake players");
}
@Override
public void onDisable() {
if (getConfig().getBoolean("cleanup.on-disable", true)) {
testManager.clearAllFakePlayers();
}
if (performanceMonitor != null) {
performanceMonitor.stopMonitoring();
}
getLogger().info("PlayerCapacityTest has been disabled!");
}
public String formatMessage(String key) {
String prefix = getConfig().getString("messages.prefix", "&8[&bCapTest&8]&r");
String message = getConfig().getString("messages." + key, key);
return colorize(prefix + " " + message);
}
public String colorize(String message) {
return message.replace("&", "§");
}
}