Files
src
build.gradle
Code
15 933
src/main/java/com/chaosvote/ChaosVote.java
package com.chaosvote;
import com.chaosvote.command.ChaosVoteCommand;
import com.chaosvote.config.ConfigManager;
import com.chaosvote.event.EventManager;
import com.chaosvote.inventory.gui.GUIListener;
import com.chaosvote.inventory.gui.GUIManager;
import com.chaosvote.vote.VoteManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
@Getter
public class ChaosVote extends JavaPlugin {
private ConfigManager configManager;
private GUIManager guiManager;
private VoteManager voteManager;
private EventManager eventManager;
private BukkitTask autoVoteTask;
@Override
public void onEnable() {
saveDefaultConfig();
this.configManager = new ConfigManager(this);
this.guiManager = new GUIManager();
this.eventManager = new EventManager(this);
this.voteManager = new VoteManager(this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
getCommand("chaosvote").setExecutor(new ChaosVoteCommand(this));
startAutoVoting();
getLogger().info("ChaosVote enabled successfully!");
}
@Override
public void onDisable() {
if (autoVoteTask != null) {
autoVoteTask.cancel();
}
eventManager.stopCurrentEvent();
getLogger().info("ChaosVote disabled!");
}
public void startAutoVoting() {
if (autoVoteTask != null) {
autoVoteTask.cancel();
}
long intervalTicks = configManager.getVoteInterval() * 60 * 20L;
autoVoteTask = Bukkit.getScheduler().runTaskTimer(this, () -> {
voteManager.startVote();
}, intervalTicks, intervalTicks);
}
public void forceVote() {
voteManager.startVote();
}
}