Search in sources :

Example 1 with PermissionHandler

use of br.net.fabiozumbi12.RedProtect.Sponge.helpers.PermissionHandler in project RedProtect by FabioZumbi12.

the class RedProtect method onEnable.

public void onEnable() {
    try {
        plugin = this;
        ph = new PermissionHandler();
        rm = new RegionManager();
        // Init schematic
        schematic = new RPSchematics();
        // Init config, lang, listeners and flags
        startLoad();
        logger.info("Loading API...");
        this.redProtectAPI = new RedProtectAPI();
        logger.info("API Loaded!");
        logger.clear("&4 _   _  _  &c _   _   _  _ _  _  _ _ _  __");
        logger.clear("&4|_| |_ | \\ &c|_| |_| | |  |  |_ |   |    /");
        logger.clear("&4| \\ |_ |_/ &c|   | \\ |_|  |  |_ |_  |   /");
        logger.clear("&a» " + getDescription().getFullName() + " enabled");
        logger.clear("");
    } catch (Exception e) {
        CoreUtil.printJarVersion();
        e.printStackTrace();
        getServer().setWhitelist(true);
        getServer().getOnlinePlayers().forEach(p -> p.kickPlayer("The server has been whitelisted due to an error while loading plugins!"));
        this.setEnabled(false);
        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.");
    }
}
Also used : PermissionHandler(br.net.fabiozumbi12.RedProtect.Bukkit.helpers.PermissionHandler) HandlerList(org.bukkit.event.HandlerList) java.util(java.util) Player(org.bukkit.entity.Player) Bukkit.listeners(br.net.fabiozumbi12.RedProtect.Bukkit.listeners) CoreUtil(br.net.fabiozumbi12.RedProtect.Core.helpers.CoreUtil) VersionHelper(br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper) Location(org.bukkit.Location) Metrics(br.net.fabiozumbi12.RedProtect.Bukkit.metrics.Metrics) RegionManager(br.net.fabiozumbi12.RedProtect.Bukkit.region.RegionManager) LangManager(br.net.fabiozumbi12.RedProtect.Bukkit.config.LangManager) LogLevel(br.net.fabiozumbi12.RedProtect.Core.helpers.LogLevel) RedProtectUtil(br.net.fabiozumbi12.RedProtect.Bukkit.helpers.RedProtectUtil) LangGuiManager(br.net.fabiozumbi12.RedProtect.Bukkit.config.LangGuiManager) Bukkit(org.bukkit.Bukkit) Economy(net.milkbowl.vault.economy.Economy) SpigetUpdater(br.net.fabiozumbi12.RedProtect.Bukkit.updater.SpigetUpdater) RPSchematics(br.net.fabiozumbi12.RedProtect.Bukkit.schematics.RPSchematics) CommandHandler(br.net.fabiozumbi12.RedProtect.Bukkit.commands.CommandHandler) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) ObjectMappingException(ninja.leaping.configurate.objectmapping.ObjectMappingException) HooksManager(br.net.fabiozumbi12.RedProtect.Bukkit.hooks.HooksManager) RedProtectLogger(br.net.fabiozumbi12.RedProtect.Bukkit.helpers.RedProtectLogger) RedProtectAPI(br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI) ConfigManager(br.net.fabiozumbi12.RedProtect.Bukkit.config.ConfigManager) BlockConfig(br.net.fabiozumbi12.RedProtect.Bukkit.config.BlockConfig) Permission(net.milkbowl.vault.permission.Permission) RedProtectAPI(br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI) PermissionHandler(br.net.fabiozumbi12.RedProtect.Bukkit.helpers.PermissionHandler) RPSchematics(br.net.fabiozumbi12.RedProtect.Bukkit.schematics.RPSchematics) RegionManager(br.net.fabiozumbi12.RedProtect.Bukkit.region.RegionManager) ObjectMappingException(ninja.leaping.configurate.objectmapping.ObjectMappingException)

Example 2 with PermissionHandler

use of br.net.fabiozumbi12.RedProtect.Sponge.helpers.PermissionHandler 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.");
    }
}
Also used : RedProtectAPI(br.net.fabiozumbi12.RedProtect.Sponge.API.RedProtectAPI) PermissionHandler(br.net.fabiozumbi12.RedProtect.Sponge.helpers.PermissionHandler) RPSchematics(br.net.fabiozumbi12.RedProtect.Sponge.schematics.RPSchematics) RegionManager(br.net.fabiozumbi12.RedProtect.Sponge.region.RegionManager) ObjectMappingException(ninja.leaping.configurate.objectmapping.ObjectMappingException) Listener(org.spongepowered.api.event.Listener)

Aggregations

ObjectMappingException (ninja.leaping.configurate.objectmapping.ObjectMappingException)2 RedProtectAPI (br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI)1 CommandHandler (br.net.fabiozumbi12.RedProtect.Bukkit.commands.CommandHandler)1 BlockConfig (br.net.fabiozumbi12.RedProtect.Bukkit.config.BlockConfig)1 ConfigManager (br.net.fabiozumbi12.RedProtect.Bukkit.config.ConfigManager)1 LangGuiManager (br.net.fabiozumbi12.RedProtect.Bukkit.config.LangGuiManager)1 LangManager (br.net.fabiozumbi12.RedProtect.Bukkit.config.LangManager)1 PermissionHandler (br.net.fabiozumbi12.RedProtect.Bukkit.helpers.PermissionHandler)1 RedProtectLogger (br.net.fabiozumbi12.RedProtect.Bukkit.helpers.RedProtectLogger)1 RedProtectUtil (br.net.fabiozumbi12.RedProtect.Bukkit.helpers.RedProtectUtil)1 VersionHelper (br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper)1 HooksManager (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.HooksManager)1 Bukkit.listeners (br.net.fabiozumbi12.RedProtect.Bukkit.listeners)1 Metrics (br.net.fabiozumbi12.RedProtect.Bukkit.metrics.Metrics)1 RegionManager (br.net.fabiozumbi12.RedProtect.Bukkit.region.RegionManager)1 RPSchematics (br.net.fabiozumbi12.RedProtect.Bukkit.schematics.RPSchematics)1 SpigetUpdater (br.net.fabiozumbi12.RedProtect.Bukkit.updater.SpigetUpdater)1 CoreUtil (br.net.fabiozumbi12.RedProtect.Core.helpers.CoreUtil)1 LogLevel (br.net.fabiozumbi12.RedProtect.Core.helpers.LogLevel)1 RedProtectAPI (br.net.fabiozumbi12.RedProtect.Sponge.API.RedProtectAPI)1