Files
src
pom.xml
Code
34 3,432
src/main/java/com/totem/smp/TotemSMP.java
package com.totem.smp;
import com.totem.smp.command.AbilityCommand;
import com.totem.smp.command.TotemCommand;
import com.totem.smp.inventory.gui.GUIListener;
import com.totem.smp.inventory.gui.GUIManager;
import com.totem.smp.listener.PlayerJoinListener;
import com.totem.smp.listener.TotemDeathListener;
import com.totem.smp.listener.TotemInteractListener;
import com.totem.smp.listener.TotemProtectionListener;
import com.totem.smp.manager.AbilityManager;
import com.totem.smp.manager.CooldownManager;
import com.totem.smp.manager.StartManager;
import com.totem.smp.manager.TotemManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
@Getter
public class TotemSMP extends JavaPlugin {
private TotemManager totemManager;
private AbilityManager abilityManager;
private CooldownManager cooldownManager;
private StartManager startManager;
private GUIManager guiManager;
private File dataFile;
private FileConfiguration dataConfig;
@Override
public void onEnable() {
saveDefaultConfig();
this.dataFile = new File(getDataFolder(), "data.yml");
if (!dataFile.exists()) {
saveResource("data.yml", false);
}
this.dataConfig = YamlConfiguration.loadConfiguration(dataFile);
this.totemManager = new TotemManager(this);
this.abilityManager = new AbilityManager(this);
this.cooldownManager = new CooldownManager();
this.startManager = new StartManager(this);
this.guiManager = new GUIManager();
registerCommands();
registerListeners();
getLogger().info("TotemSMP has been enabled!");
}
@Override
public void onDisable() {
totemManager.saveData();
getLogger().info("TotemSMP has been disabled!");
}
private void registerCommands() {
getCommand("totem").setExecutor(new TotemCommand(this));
getCommand("ability").setExecutor(new AbilityCommand(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new TotemInteractListener(this), this);
Bukkit.getPluginManager().registerEvents(new TotemProtectionListener(this), this);
Bukkit.getPluginManager().registerEvents(new TotemDeathListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
}
public void reloadConfigs() {
reloadConfig();
this.dataConfig = YamlConfiguration.loadConfiguration(dataFile);
totemManager.loadData();
}
public String getMessage(String path) {
String message = getConfig().getString("messages." + path, "&cMessage not found: " + path);
return message.replace("&", "§");
}
public String getPrefix() {
return getMessage("prefix");
}
}