Files
gradle
src
.gitignore
build.gradle
settings.gradle
Code
21 1,962
src/main/java/pl/plotmanager/PlotManager.java
package pl.plotmanager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
import pl.plotmanager.commands.PlotCommand;
import pl.plotmanager.config.ConfigManager;
import pl.plotmanager.gui.GuiListener;
import pl.plotmanager.listeners.PlotProtectionListener;
import pl.plotmanager.managers.*;
import pl.plotmanager.placeholders.PlotPlaceholders;
@Getter
public class PlotManager extends JavaPlugin {
private ConfigManager configManager;
private PlotDataManager plotDataManager;
private PlotCreationManager plotCreationManager;
private PlotMemberManager plotMemberManager;
private PlotTeleportManager plotTeleportManager;
private PlotProtectionManager plotProtectionManager;
private CooldownManager cooldownManager;
private ConfirmationManager confirmationManager;
private GuiManager guiManager;
@Override
public void onEnable() {
initializeManagers();
registerCommands();
registerListeners();
registerPlaceholders();
startAutoSave();
getLogger().info("PlotManager został włączony!");
}
@Override
public void onDisable() {
if (plotDataManager != null) {
plotDataManager.saveAllPlots();
}
getLogger().info("PlotManager został wyłączony!");
}
private void initializeManagers() {
this.configManager = new ConfigManager(this);
this.plotDataManager = new PlotDataManager(this);
this.cooldownManager = new CooldownManager();
this.confirmationManager = new ConfirmationManager();
this.plotCreationManager = new PlotCreationManager(this);
this.plotMemberManager = new PlotMemberManager(this);
this.plotTeleportManager = new PlotTeleportManager(this);
this.plotProtectionManager = new PlotProtectionManager(this);
this.guiManager = new GuiManager(this);
plotDataManager.loadAllPlots();
}
private void registerCommands() {
PlotCommand plotCommand = new PlotCommand(this);
getCommand("dzialka").setExecutor(plotCommand);
getCommand("dzialka").setTabCompleter(plotCommand);
}
private void registerListeners() {
getServer().getPluginManager().registerEvents(new PlotProtectionListener(this), this);
getServer().getPluginManager().registerEvents(new GuiListener(this), this);
}
private void registerPlaceholders() {
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlotPlaceholders(this).register();
getLogger().info("PlaceholderAPI wykryte - placeholdery zarejestrowane!");
}
}
private void startAutoSave() {
int interval = configManager.getAutoSaveInterval() * 20;
getServer().getScheduler().runTaskTimerAsynchronously(this, () -> {
plotDataManager.saveAllPlots();
}, interval, interval);
}
public void reload() {
configManager.reload();
plotDataManager.loadAllPlots();
}
}