Files
src
build.gradle
Code
29 2,583
src/main/java/com/sleepcompanion/SleepCompanion.java
package com.sleepcompanion;
import com.sleepcompanion.listeners.*;
import com.sleepcompanion.managers.CompanionManager;
import com.sleepcompanion.managers.ConfigManager;
import com.sleepcompanion.managers.GalaxyStickManager;
import com.sleepcompanion.commands.CompanionCommand;
import com.sleepcompanion.tasks.ParticleTask;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class SleepCompanion extends JavaPlugin {
private ConfigManager configManager;
private CompanionManager companionManager;
private GalaxyStickManager galaxyStickManager;
@Override
public void onEnable() {
saveDefaultConfig();
this.configManager = new ConfigManager(this);
this.companionManager = new CompanionManager(this);
this.galaxyStickManager = new GalaxyStickManager(this);
getServer().getPluginManager().registerEvents(new TameListener(this), this);
getServer().getPluginManager().registerEvents(new SleepListener(this), this);
getServer().getPluginManager().registerEvents(new CompanionProtectionListener(this), this);
getServer().getPluginManager().registerEvents(new HostileListener(this), this);
getServer().getPluginManager().registerEvents(new CombatListener(this), this);
getServer().getPluginManager().registerEvents(new CraftingListener(this), this);
getServer().getPluginManager().registerEvents(new GalaxyStickListener(this), this);
getServer().getPluginManager().registerEvents(new GUIListener(this), this);
getServer().getPluginManager().registerEvents(new InteractionListener(this), this);
getCommand("companion").setExecutor(new CompanionCommand(this));
new ParticleTask(this).runTaskTimer(this, 0L, configManager.getParticleInterval());
getLogger().info("SleepCompanion enabled!");
}
@Override
public void onDisable() {
if (companionManager != null) {
companionManager.removeAllCompanions();
}
getLogger().info("SleepCompanion disabled!");
}
public void reload() {
reloadConfig();
configManager = new ConfigManager(this);
}
}