Files
src
build.gradle
Code
14 792
src/main/java/com/example/combatlogguard/CombatLogGuard.java
package com.example.combatlogguard;
import com.example.combatlogguard.command.CombatCommand;
import com.example.combatlogguard.listener.EntityListener;
import com.example.combatlogguard.listener.PlayerCombatListener;
import com.example.combatlogguard.listener.PlayerCommandListener;
import com.example.combatlogguard.listener.PlayerConnectionListener;
import com.example.combatlogguard.listener.PlayerMovementListener;
import com.example.combatlogguard.manager.CombatManager;
import com.example.combatlogguard.manager.CombatZombieManager;
import com.example.combatlogguard.task.ActionBarTask;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class CombatLogGuard extends JavaPlugin {
private CombatManager combatManager;
private CombatZombieManager zombieManager;
private ActionBarTask actionBarTask;
@Override
public void onEnable() {
saveDefaultConfig();
this.combatManager = new CombatManager(this);
this.zombieManager = new CombatZombieManager(this);
registerListeners();
registerCommands();
this.actionBarTask = new ActionBarTask(this);
this.actionBarTask.runTaskTimer(this, 0L, 20L);
getLogger().info("CombatLogGuard has been enabled!");
}
@Override
public void onDisable() {
if (actionBarTask != null) {
actionBarTask.cancel();
}
if (zombieManager != null) {
zombieManager.cleanup();
}
getLogger().info("CombatLogGuard has been disabled!");
}
private void registerListeners() {
getServer().getPluginManager().registerEvents(new PlayerCombatListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerCommandListener(this), this);
getServer().getPluginManager().registerEvents(new EntityListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerMovementListener(this), this);
}
private void registerCommands() {
getCommand("combatlog").setExecutor(new CombatCommand(this));
}
public void reload() {
reloadConfig();
getLogger().info("Configuration reloaded!");
}
}