/* This file is a part of the SteamWar software. Copyright (C) 2020 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package de.steamwar.fightsystem; import de.steamwar.fightsystem.commands.*; import de.steamwar.fightsystem.countdown.*; import de.steamwar.fightsystem.event.HellsBells; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightWorld; import de.steamwar.fightsystem.listener.Shutdown; import de.steamwar.fightsystem.listener.*; import de.steamwar.fightsystem.record.*; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.utils.*; import de.steamwar.fightsystem.winconditions.*; import de.steamwar.message.Message; import de.steamwar.sql.EventFight; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; public class FightSystem extends JavaPlugin { private static FightSystem plugin; private static EventFight eventFight; private static Player eventLeiter; private Message message; private FightTeam lastWinner; private String lastWinreason; @Override public void onLoad() { plugin = this; } @Override public void onEnable() { message = new Message("de.steamwar.fightsystem.FightSystem", FightSystem.class.getClassLoader()); new EntityDamage(); new WaterRemover(); new Permanent(); new PistonListener(); new Chat(); new HotbarGUI(); new ArenaBorder(); new TeamArea(); new IngameDeath(); new InFightDamage(); new InFightInventory(); new DenyWorldInteraction(); new DenyInventoryMovement(); new EventJoin(); new Recording(); //new ResourcePack(); new Check(); new Shutdown(); new SetupQuit(); new PrepareSchem(); new TestJoin(); new NormalJoin(); new RankedJoin(); new RunningWorldInteraction(); new PersonalKitCreator(); new ArrowStopper(); new ArrowPickup(); new EnterHandler(); new TechHider(); new FightWorld(); new FightUI(); new FightStatistics(); new BungeeFightInfo(); new WinconditionAllDead(); new WinconditionCaptainDead(); new WinconditionPumpkinTechKO(); new WinconditionWaterTechKO(); new WinconditionPercentSystem(); new WinconditionBlacklistPercent(); new WinconditionWhitelistPercent(); new WinconditionPoints(); new WinconditionTimeout(); new WinconditionHeartRatioTimeout(); new WinconditionTimeTechKO(); new EventTeamOffWincondition(); new RankedPlayerLeftWincondition(); new WinconditionPercentTimeout(); new HellsBells(); new NoPlayersOnlineCountdown(); new PreSchemCountdown(); new PostSchemCountdown(); new PreRunningCountdown(); new SpectateOverCountdown(); new EventSpectateCountdown(); new LeaveCommand(); new KitCommand(); new RemoveCommand(); new AcceptCommand(); new DeclineCommand(); new GamemodeCommand(); new InviteCommand(); new ReadyCommand(); new AkCommand(); new LeaderCommand(); new LockschemCommand(); new ReplayCommand(); new StateCommand(); new SkipCommand(); new WinCommand(); new LiveRecorder(); new FileRecorder(); REntity.initWatchers(); if(Config.mode == ArenaMode.EVENT) { setPreSchemState(); }else if(Config.mode == ArenaMode.CHECK){ Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.CheckSchemID)); }else if(Config.mode == ArenaMode.PREPARE) { Fight.getUnrotated().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID)); }else if(Config.mode == ArenaMode.REPLAY) { FightWorld.forceLoad(); FileSource.startReplay(); } } @Override public void onDisable() { ProtocolAPI.tinyProtocol.close(); GlobalRecorder.getInstance().close(); } public static void setPreLeaderState() { FightState.setFightState(FightState.PRE_LEADER_SETUP); } public static void setPreSchemState() { FightState.setFightState(FightState.PRE_SCHEM_SETUP); } public static void setPostSchemState() { FightState.setFightState(FightState.POST_SCHEM_SETUP); } public static void setPreRunningState() { FightState.setFightState(FightState.PRE_RUNNING); } public static void setRunningState() { FightState.setFightState(FightState.RUNNING); } public static void setSpectateState(FightTeam winFightTeam, String winreason, String subtitle, Object... params) { plugin.lastWinner = winFightTeam; plugin.lastWinreason = winreason; FightUI.printWin(winFightTeam, subtitle, params); FightState.setFightState(FightState.SPECTATE); } public static void setEventLeiter(Player el){ eventLeiter = el; } public static Player getEventLeiter(){ return eventLeiter; } public static EventFight getEventFight(){ return eventFight; } public static void setEventFight(EventFight ef){ eventFight = ef; } public static FightSystem getPlugin() { return plugin; } public static void broadcast(String msg, Object... params) { getMessage().broadcast(msg, params); GlobalRecorder.getInstance().system(msg, params); } public static Message getMessage() { return plugin.message; } public static FightTeam getLastWinner() { return plugin.lastWinner; } public static String getLastWinreason() { return plugin.lastWinreason; } public static void shutdown() { //Staggered kick to prevent lobby overloading if(Bukkit.getOnlinePlayers().isEmpty()){ Bukkit.shutdown(); return; } Bukkit.getOnlinePlayers().iterator().next().kickPlayer(null); Bukkit.getScheduler().runTaskLater(plugin, FightSystem::shutdown, 10); } }