Files
src
build.gradle
manifest.kod
Code
27 1,815
src/main/java/com/bondsmp/BondSMP.java
package com.bondsmp;
import com.bondsmp.commands.BondCommand;
import com.bondsmp.hooks.BondPlaceholderExpansion;
import com.bondsmp.inventory.gui.GUIListener;
import com.bondsmp.inventory.gui.GUIManager;
import com.bondsmp.listeners.DamageListener;
import com.bondsmp.listeners.DeathListener;
import com.bondsmp.listeners.PlayerJoinListener;
import com.bondsmp.listeners.QuitListener;
import com.bondsmp.managers.*;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class BondSMP extends JavaPlugin {
private ConfigManager cfg;
private StorageManager storage;
private BondManager bonds;
private DamageManager damage;
private InstabilityManager instability;
private TraceManager trace;
private GUIManager guiManager;
@Override
public void onEnable() {
this.cfg = new ConfigManager(this);
this.storage = new StorageManager(this);
this.bonds = new BondManager(this);
this.damage = new DamageManager(this);
this.instability = new InstabilityManager(this);
this.trace = new TraceManager(this);
this.guiManager = new GUIManager();
registerListeners();
registerCommands();
instability.startInstabilityTicker();
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new BondPlaceholderExpansion(this).register();
getLogger().info("PlaceholderAPI hook registered!");
}
getLogger().info("BondSMP has been enabled!");
}
@Override
public void onDisable() {
if (instability != null) {
instability.stopInstabilityTicker();
}
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
bonds.saveBond(player.getUniqueId());
}
if (storage != null) {
storage.close();
}
getLogger().info("BondSMP has been disabled!");
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
Bukkit.getPluginManager().registerEvents(new QuitListener(this), this);
Bukkit.getPluginManager().registerEvents(new DamageListener(this), this);
Bukkit.getPluginManager().registerEvents(new DeathListener(this), this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
}
private void registerCommands() {
BondCommand bondCommand = new BondCommand(this);
getCommand("bond").setExecutor(bondCommand);
getCommand("bond").setTabCompleter(bondCommand);
}
}