72 lines
2.5 KiB
Java
72 lines
2.5 KiB
Java
package com.alttd.hunger_games;
|
|
|
|
import com.alttd.hunger_games.commands.BaseCommand;
|
|
import com.alttd.hunger_games.config.Config;
|
|
import com.alttd.hunger_games.config.Messages;
|
|
import com.alttd.hunger_games.event_listeners.ChestListener;
|
|
import com.alttd.hunger_games.event_listeners.PlayerDamageListener;
|
|
import com.alttd.hunger_games.event_listeners.PlayerDisconnectListener;
|
|
import com.alttd.hunger_games.event_listeners.PlayerJoinListener;
|
|
import com.alttd.hunger_games.services.LootService;
|
|
import com.alttd.hunger_games.services.PlayerService;
|
|
import com.alttd.hunger_games.services.PlayerTeleporterService;
|
|
import com.alttd.hunger_games.services.Round;
|
|
import com.alttd.hunger_games.services.RoundService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.bukkit.plugin.PluginManager;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
@Slf4j
|
|
public final class Main extends JavaPlugin {
|
|
|
|
private Round round;
|
|
private RoundService roundService;
|
|
private PlayerService playerService;
|
|
private PlayerTeleporterService playerTeleporterService;
|
|
private LootService lootService;
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
log.info("Starting HungerGames");
|
|
reloadConfigs();
|
|
registerServices();
|
|
registerCommands();
|
|
registerEvents();
|
|
registerSchedulers();
|
|
}
|
|
|
|
private void registerServices() {
|
|
round = Round.createSingletonInstance();
|
|
lootService = new LootService();
|
|
roundService = RoundService.createSingletonInstance(round, this, lootService);
|
|
playerTeleporterService = PlayerTeleporterService.createSingletonInstance();
|
|
playerService = PlayerService.createSingletonInstance(round, roundService, playerTeleporterService);
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
log.info("Disabling HungerGames");
|
|
}
|
|
|
|
private void registerCommands() {
|
|
BaseCommand command = new BaseCommand(this, roundService, playerService, round);
|
|
}
|
|
|
|
private void registerEvents() {
|
|
PluginManager pluginManager = getServer().getPluginManager();
|
|
pluginManager.registerEvents(new PlayerDisconnectListener(playerService), this);
|
|
pluginManager.registerEvents(new PlayerJoinListener(playerService), this);
|
|
pluginManager.registerEvents(new PlayerDamageListener(roundService, playerService), this);
|
|
pluginManager.registerEvents(new ChestListener(roundService, lootService), this);
|
|
}
|
|
|
|
public void reloadConfigs() {
|
|
Config.reload();
|
|
Messages.reload();
|
|
}
|
|
|
|
private void registerSchedulers() {
|
|
|
|
}
|
|
}
|