use of br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper in project RedProtect by FabioZumbi12.
the class RedProtect method startLoad.
private void startLoad() throws Exception {
redProtectUtil = new RedProtectUtil(this);
config = new ConfigManager();
lang = new LangManager();
blockConfig = new BlockConfig();
if (config.configRoot().purge.regen.enable_whitelist_regen && Bukkit.getServer().hasWhitelist()) {
Bukkit.getServer().setWhitelist(false);
RedProtect.get().logger.success("Whitelist disabled!");
}
logger.info("Registering commands...");
cmdHandler = new CommandHandler(this);
logger.info("Registering listeners...");
getServer().getPluginManager().registerEvents(cmdHandler, this);
getServer().getPluginManager().registerEvents(new GlobalListener(), this);
getServer().getPluginManager().registerEvents(new BlockListener(), this);
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
getServer().getPluginManager().registerEvents(new EntityListener(), this);
getServer().getPluginManager().registerEvents(new WorldListener(), this);
// Register hooks
hooks.registerHooksFirst();
rm = new RegionManager();
rm.loadAll();
redProtectUtil.ReadAllDB(rm.getAllRegions());
rm.saveAll(false);
if (!config.configRoot().file_type.equalsIgnoreCase("mysql")) {
startAutoSave();
}
logger.info("There are " + rm.getTotalRegionsNum() + " regions on (" + config.configRoot().file_type + ") database!");
// Register hooks
hooks.registerHooksLast();
// Load Gui lang file
guiLang = new LangGuiManager();
// Update Manager
if (updater != null) {
Bukkit.getScheduler().cancelTask(updater.getTaskId());
updater = null;
}
if (config.configRoot().update.enable) {
updater = new SpigetUpdater(this);
updater.setCurrentJarFile(this.getFile().getName());
updater.hourlyUpdateCheck(getServer().getConsoleSender(), config.configRoot().update.enable, false);
}
bukkitVersion = getBukkitVersion();
logger.debug(LogLevel.DEFAULT, "Version String: " + bukkitVersion);
if (bukkitVersion >= 180) {
getServer().getPluginManager().registerEvents(new Compat18(), this);
}
if (bukkitVersion >= 190) {
getServer().getPluginManager().registerEvents(new Compat19(), this);
}
if (bukkitVersion >= 1110) {
getServer().getPluginManager().registerEvents(new Compat111(), this);
}
if (bukkitVersion >= 1140) {
getServer().getPluginManager().registerEvents(new Compat114(), this);
}
if (bukkitVersion <= 189) {
rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper18").newInstance();
}
if (bukkitVersion >= 190) {
rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper112").newInstance();
}
if (bukkitVersion >= 1130) {
rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper113").newInstance();
}
if (bukkitVersion >= 1140) {
rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelperLatest").newInstance();
}
// Register as listener
getServer().getPluginManager().registerEvents(rpvHelper, this);
// Print helper version
logger.info("Helper version: " + rpvHelper.getVersion());
// Load gui items for Minecraft version
config.setGuiRoot(rpvHelper.setGuiItems(config.guiRoot()));
// Load mob permissions
modListener = new ModListener(this);
// Metrics
try {
Metrics metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SingleLineChart("server_regions", () -> rm.getAllRegions().size()));
if (metrics.isEnabled())
logger.info("Metrics enabled! See our stats here: https://bstats.org/plugin/bukkit/RedProtect");
} catch (Exception ex) {
logger.info("Metrics not enabled due errors: " + ex.getLocalizedMessage());
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper in project RedProtect by FabioZumbi12.
the class RedProtect method onServerStart.
@Listener
public void onServerStart(GameStartedServerEvent event) {
try {
String v = Sponge.getGame().getPlatform().getContainer(Component.API).getVersion().orElse("0");
instance = this;
commandManager = Sponge.getGame().getCommandManager();
ph = new PermissionHandler();
rm = new RegionManager();
// Init schematic
schematic = new RPSchematics();
// Init config, lang, listeners and flags
startLoad();
if (v.startsWith("7")) {
rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.VersionHelper7").newInstance();
Sponge.getGame().getEventManager().registerListeners(container, Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener7").newInstance());
} else /*else if (v.startsWith("8")) {
Sponge.getGame().getEventManager().registerListeners(container, Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener8").newInstance());
rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.VersionHelper8").newInstance();
}*/
{
Sponge.getGame().getEventManager().registerListeners(container, Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.listeners.BlockListenerCompat56").newInstance());
rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.helpers.VersionHelper56").newInstance();
}
logger.info("Loading API...");
this.redProtectAPI = new RedProtectAPI();
logger.info("API Loaded!");
logger.info("Sponge version: " + v);
logger.clear("\n" + "&4 _ _ _ &c _ _ _ _ _ _ _ _ _ __\n" + "&4|_| |_ | \\ &c|_| |_| | | | |_ | | / \n" + "&4| \\ |_ |_/ &c| | \\ |_| | |_ |_ | /\n" + "&a¯ Redprotect " + container.getVersion().get() + " enabled\n" + "");
} catch (Exception e) {
CoreUtil.printJarVersion();
e.printStackTrace();
Sponge.getGame().getServer().setHasWhitelist(true);
Sponge.getGame().getServer().getOnlinePlayers().forEach(Player::kick);
logger.severe("Error enabling RedProtect, plugin will shut down.");
logger.severe("Due to an error in RedProtect loading, the whitelist has been turned on and every player has been kicked.");
logger.severe("DO NOT LET ANYONE ENTER before fixing the problem, otherwise you risk losing protected regions.");
}
}
Aggregations