Files
src
build.gradle
INSTRUCCIONES.md
settings.gradle
Code
16 3,024
src/main/java/com/kodari/elhoyo/ElHoyoPlugin.java
package com.kodari.elhoyo;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public final class ElHoyoPlugin extends JavaPlugin {
private RecoveryStore recoveryStore;
private WeaponManager weaponManager;
private GameManager gameManager;
private NamespacedKey matchEntityKey;
@Override
public void onEnable() {
saveDefaultConfig();
matchEntityKey = new NamespacedKey(this, "partida");
try {
recoveryStore = new RecoveryStore(this);
} catch (RuntimeException exception) {
getLogger().severe("No se pudo cargar el archivo de recuperación: " + exception.getMessage());
getServer().getPluginManager().disablePlugin(this);
return;
}
weaponManager = new WeaponManager(this);
gameManager = new GameManager(this);
HoyoCommand command = new HoyoCommand(this);
PluginCommand registered = getCommand("elhoyo");
if (registered == null) {
getLogger().severe("El comando elhoyo no está declarado en plugin.yml.");
getServer().getPluginManager().disablePlugin(this);
return;
}
registered.setExecutor(command);
registered.setTabCompleter(command);
getServer().getPluginManager().registerEvents(new GameListener(this), this);
Bukkit.getScheduler().runTask(this, () -> {
gameManager.recoverAfterRestart();
for (Player player : Bukkit.getOnlinePlayers()) {
if (!player.isDead() && !gameManager.isAlive(player.getUniqueId())) {
recoveryStore.restore(player);
}
}
});
}
@Override
public void onDisable() {
if (gameManager != null) {
gameManager.shutdown();
}
}
}