Files
src
build.gradle
manifest.kod
Code
25 1,764
src/main/java/com/atheron/visionlog/AtheronVisionLog.java
package com.atheron.visionlog;
import com.atheron.visionlog.combat.CombatManager;
import com.atheron.visionlog.commands.VTrustCommand;
import com.atheron.visionlog.commands.VUntrustCommand;
import com.atheron.visionlog.config.ConfigManager;
import com.atheron.visionlog.hooks.WorldGuardHook;
import com.atheron.visionlog.listeners.CombatListener;
import com.atheron.visionlog.listeners.CommandBlockListener;
import com.atheron.visionlog.listeners.ItemUseListener;
import com.atheron.visionlog.listeners.PlayerConnectionListener;
import com.atheron.visionlog.listeners.VisionListener;
import com.atheron.visionlog.tasks.ActionBarTask;
import com.atheron.visionlog.tasks.VisionCheckTask;
import com.atheron.visionlog.trust.TrustManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class AtheronVisionLog extends JavaPlugin {
private CombatManager combatManager;
private TrustManager trustManager;
private WorldGuardHook worldGuardHook;
private VisionCheckTask visionCheckTask;
private ActionBarTask actionBarTask;
private ConfigManager configManager;
private ItemUseListener itemUseListener;
@Override
public void onLoad() {
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
this.worldGuardHook = new WorldGuardHook(this);
}
}
@Override
public void onEnable() {
saveDefaultConfig();
this.configManager = new ConfigManager(this);
this.combatManager = new CombatManager(this);
this.trustManager = new TrustManager(this);
this.itemUseListener = new ItemUseListener(this);
getServer().getPluginManager().registerEvents(new CombatListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(this), this);
getServer().getPluginManager().registerEvents(new VisionListener(this), this);
getServer().getPluginManager().registerEvents(new CommandBlockListener(this), this);
getServer().getPluginManager().registerEvents(itemUseListener, this);
getCommand("visionlog").setExecutor(new com.atheron.visionlog.commands.VisionLogCommand(this));
getCommand("vtrust").setExecutor(new VTrustCommand(this));
getCommand("vuntrust").setExecutor(new VUntrustCommand(this));
this.visionCheckTask = new VisionCheckTask(this);
this.visionCheckTask.runTaskTimer(this, 0L, getConfig().getLong("vision-check-interval", 10L));
this.actionBarTask = new ActionBarTask(this);
this.actionBarTask.runTaskTimer(this, 0L, 20L);
getLogger().info("AtheronVisionLog has been enabled!");
}
@Override
public void onDisable() {
if (visionCheckTask != null) {
visionCheckTask.cancel();
}
if (actionBarTask != null) {
actionBarTask.cancel();
}
getLogger().info("AtheronVisionLog has been disabled!");
}
public void reload() {
configManager.reloadConfigs();
combatManager.clearAll();
if (itemUseListener != null) {
itemUseListener.loadDisabledItems();
}
if (visionCheckTask != null) {
visionCheckTask.cancel();
}
if (actionBarTask != null) {
actionBarTask.cancel();
}
this.visionCheckTask = new VisionCheckTask(this);
this.visionCheckTask.runTaskTimer(this, 0L, getConfig().getLong("vision-check-interval", 10L));
this.actionBarTask = new ActionBarTask(this);
this.actionBarTask.runTaskTimer(this, 0L, 20L);
}
}