/* 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.core; import de.steamwar.core.events.ChattingEvent; import de.steamwar.core.events.ChunkListener; import de.steamwar.core.events.PlayerJoinedEvent; import de.steamwar.core.events.WorldLoadEvent; import de.steamwar.sql.SQL; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; public class Core extends JavaPlugin{ private static Core instance; private static final int version; static{ String packageName = Bukkit.getServer().getClass().getPackage().getName(); if(packageName.contains("1_15")) version = 15; else if(packageName.contains("1_14")) version = 14; else if(packageName.contains("1_10")) version = 10; else if(packageName.contains("1_9")) version = 9; else if(packageName.contains("1_8")) version = 8; else version = 12; } @Override public void onLoad() { setInstance(this); } @Override public void onEnable() { Bukkit.getPluginManager().registerEvents(new PlayerJoinedEvent(), this); Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this); Bukkit.getPluginManager().registerEvents(new WorldLoadEvent(), this); ChunkListener.init(); if(version >= 12) ErrorLogger.init(); } @Override public void onDisable(){ SQL.closeConnection(); } public static Core getInstance() { return instance; } public static int getVersion(){ return version; } private static void setInstance(Core instance) { Core.instance = instance; } }