Files
src
build.gradle
Code
12 838
src/main/java/com/example/livesplugin/LivesPlugin.java
package com.example.livesplugin;
import com.example.livesplugin.listener.PlayerListener;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
public class LivesPlugin extends JavaPlugin {
private LivesManager livesManager;
@Override
public void onEnable() {
saveDefaultConfig();
this.livesManager = new LivesManager(this);
registerListeners();
registerCommands();
registerPlaceholderAPI();
getLogger().info("LivesPlugin has been enabled!");
}
@Override
public void onDisable() {
if (livesManager != null) {
livesManager.saveAll();
}
getLogger().info("LivesPlugin has been disabled.");
}
public LivesManager getLivesManager() {
return livesManager;
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
}
private void registerCommands() {
getCommand("lives").setExecutor(new LivesCommand(this));
getCommand("livesadmin").setExecutor(new LivesAdminCommand(this));
getCommand("livesleaderboard").setExecutor(new LeaderboardCommand(this));
}
private void registerPlaceholderAPI() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new LivesExpansion(this).register();
getLogger().info("PlaceholderAPI expansion registered!");
} else {
getLogger().info("PlaceholderAPI not found - placeholders unavailable.");
}
}
public String color(String msg) {
return ChatColor.translateAlternateColorCodes('&', msg);
}
}