org.spongepowered.api.event.game.state.GamePreInitializationEvent Java Examples

The following examples show how to use org.spongepowered.api.event.game.state.GamePreInitializationEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Metrics2.java    From bStats-Metrics with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Listener
public void startup(GamePreInitializationEvent event) {
    try {
        loadConfig();
    } catch (IOException e) {
        // Failed to load configuration
        logger.warn("Failed to load bStats config!", e);
        return;
    }

    if (Sponge.getServiceManager().isRegistered(Metrics.class)) {
        Metrics provider = Sponge.getServiceManager().provideUnchecked(Metrics.class);
        provider.linkMetrics(this);
    } else {
        Sponge.getServiceManager().setProvider(plugin.getInstance().get(), Metrics.class, this);
        this.linkMetrics(this);
        startSubmitting();
    }
}
 
Example #2
Source File: MetricsLite2.java    From bStats-Metrics with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Listener
public void startup(GamePreInitializationEvent event) {
    try {
        loadConfig();
    } catch (IOException e) {
        // Failed to load configuration
        logger.warn("Failed to load bStats config!", e);
        return;
    }

    if (Sponge.getServiceManager().isRegistered(Metrics.class)) {
        Metrics provider = Sponge.getServiceManager().provideUnchecked(Metrics.class);
        provider.linkMetrics(this);
    } else {
        Sponge.getServiceManager().setProvider(plugin.getInstance().get(), Metrics.class, this);
        this.linkMetrics(this);
        startSubmitting();
    }
}
 
Example #3
Source File: Metrics2.java    From GriefPrevention with MIT License 6 votes vote down vote up
@Listener
public void startup(GamePreInitializationEvent event) {
    if (!validateSpongeVersion()) {
        return;
    }

    try {
        loadConfig();
    } catch (IOException e) {
        // Failed to load configuration
        logger.warn("Failed to load bStats config!", e);
        return;
    }

    if (Sponge.getServiceManager().isRegistered(Metrics.class)) {
        Metrics provider = Sponge.getServiceManager().provideUnchecked(Metrics.class);
        provider.linkMetrics(this);
    } else {
        Sponge.getServiceManager().setProvider(plugin.getInstance().get(), Metrics.class, this);
        this.linkMetrics(this);
        startSubmitting();
    }
}
 
Example #4
Source File: ChangeSkinSponge.java    From ChangeSkin with MIT License 5 votes vote down vote up
@Listener
public void onPreInit(GamePreInitializationEvent preInitEvent) {
    //load config and database
    try {
        core.load(true);
        initialized = true;
    } catch (Exception ex) {
        logger.error("Error initializing plugin. Disabling...", ex);
    }
}
 
Example #5
Source File: LPSpongeBootstrap.java    From LuckPerms with MIT License 5 votes vote down vote up
@Listener(order = Order.FIRST)
public void onEnable(GamePreInitializationEvent event) {
    this.startTime = Instant.now();
    try {
        this.plugin.load();
    } finally {
        this.loadLatch.countDown();
    }

    try {
        this.plugin.enable();
    } finally {
        this.enableLatch.countDown();
    }
}
 
Example #6
Source File: SubPlugin.java    From SubServers-2 with Apache License 2.0 5 votes vote down vote up
@Listener
public void setup(GamePreInitializationEvent event) {
    if (plugin.getVersion().isPresent()) {
        version = Version.fromString(plugin.getVersion().get());
    } else version = new Version("Custom");
    subdata.put(0, null);
}
 
Example #7
Source File: LPSpongeBootstrap.java    From LuckPerms with MIT License 4 votes vote down vote up
@Listener(order = Order.LATE)
public void onLateEnable(GamePreInitializationEvent event) {
    this.plugin.lateEnable();
}
 
Example #8
Source File: Prism.java    From Prism with MIT License 4 votes vote down vote up
@Listener
public void onPreInitialization(GamePreInitializationEvent event) {
    getConfiguration().loadConfiguration();
}
 
Example #9
Source File: FlexibleLogin.java    From FlexibleLogin with MIT License 4 votes vote down vote up
@Listener //During this state, the plugin gets ready for initialization. Logger and config
public void onPreInit(GamePreInitializationEvent preInitEvent) {
    protectionManager = injector.getInstance(ProtectionManager.class);

    init();
}
 
Example #10
Source File: EconomyLite.java    From EconomyLite with MIT License 4 votes vote down vote up
@Listener
public void onServerInitialize(GamePreInitializationEvent event) {
    logger.info("EconomyLite " + PluginInfo.VERSION + " is initializing!");
    instance = this;
    // File setup
    configManager = ConfigManager.create(configDir, "config.conf", logger);
    currencyManager = ConfigManager.create(configDir, "currencies.conf", logger);
    initializeFiles();
    initializeCurrencies();
    // Load Message Storage
    messageStorage = MessageStorage.create(configDir, "messages", logger);
    // Load modules
    List<Module> postInitModules = new ArrayList<>();
    getModules().forEach(m -> {
        m.initializeConfig();
        if (m.isEnabled()) {
            if (m.initialize(logger, instance)) {
                logger.info("Loaded the " + m.getName() + " module!");
                postInitModules.add(m);
            } else {
                logger.error("Failed to load the " + m.getName() + " module!");
            }
        } else {
            logger.info("The " + m.getName() + " module is disabled!");
        }
    });
    // If the services have not been set, set them to default.
    if (playerEconService == null || virtualEconService == null) {
        playerEconService = new PlayerDataService();
        virtualEconService = new VirtualDataService();
    }
    // Load the economy service
    economyService = new LiteEconomyService();
    // Register the Economy Service
    game.getServiceManager().setProvider(this, EconomyService.class, economyService);
    // Post-initialize modules
    postInitModules.forEach(module -> {
        module.postInitialization(logger, instance);
    });
    // Register commands
    CommandLoader.registerCommands(this, TextSerializers.FORMATTING_CODE.serialize(messageStorage.getMessage("command.invalidsource")),
            new CurrencyCommand(),
            new CurrencySetCommand(),
            new CurrencyDeleteCommand(),
            new CurrencyCreateCommand(),
            new BalanceCommand(),
            new EconCommand(),
            new SetCommand(),
            new SetAllCommand(),
            new RemoveCommand(),
            new AddCommand(),
            new PayCommand(),
            new BalTopCommand(),
            new VirtualBalanceCommand(),
            new VirtualEconCommand(),
            new VirtualAddCommand(),
            new VirtualSetCommand(),
            new VirtualRemoveCommand(),
            new VirtualPayCommand(),
            new PayVirtualCommand(),
            new MigrateCommand(),
            new RefreshCommand()
    );
    // Register currency registry
    game.getRegistry().registerModule(Currency.class, new CurrencyRegistryModule());
}
 
Example #11
Source File: SpongeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Listener(order = Order.PRE)
public void onGamePreInit(GamePreInitializationEvent event) {
    this.server = this.game.getServer();
    new FaweSponge(this);
    Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
}
 
Example #12
Source File: SpongeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Listener(order = Order.PRE)
public void onGamePreInit(GamePreInitializationEvent event) {
    this.server = this.game.getServer();
    new FaweSponge(this);
    Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
}
 
Example #13
Source File: GDBootstrap.java    From GriefDefender with MIT License 4 votes vote down vote up
@Listener(order = Order.LAST)
public void onPreInit(GamePreInitializationEvent event) {
    instance = this;
    final JSONParser parser = new JSONParser();
    String bukkitJsonVersion = null;
    this.getLogger().info("Loading libraries...");
    final MinecraftVersion version = Sponge.getPlatform().getMinecraftVersion();
    if (Sponge.getPlatform().getMinecraftVersion().getName().contains("1.12.2")) {
        bukkitJsonVersion = "1.12.2";
    } else {
        this.getLogger().error("Detected unsupported version '" + version.getName() + "'. GriefDefender only supports 1.12.2 on Sponge. GriefDefender will NOT load.");
        return;
    }
    try {
        final InputStream in = getClass().getResourceAsStream("/" + bukkitJsonVersion + ".json");
        final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        final JSONObject a = (JSONObject) parser.parse(reader);
        final JSONArray libraries = (JSONArray) a.get("libraries");
        if (libraries == null) {
            this.getLogger().error("Resource " + bukkitJsonVersion + ".json is corrupted!. Please contact author for assistance.");
            return;
        }
        final Path LIB_ROOT_PATH = instance.configPath.resolve("lib");
        final Iterator<JSONObject> iterator = libraries.iterator();
        while (iterator.hasNext()) {
            JSONObject lib = iterator.next();
            final String name = (String) lib.get("name");
            final String sha1 = (String) lib.get("sha1");
            final String path = (String) lib.get("path");
            final String relocate = (String) lib.get("relocate");
            final String url = (String) lib.get("url");
            final Path libPath = LIB_ROOT_PATH.resolve(path);
            downloadLibrary(name, relocate, sha1, url, libPath);
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
    // Inject jar-relocator and asm debug
    injectRelocatorDeps();
    // Relocate all GD dependencies and inject
    GDRelocator.getInstance().relocateJars(this.jarMap);
    // Boot GD
    GriefDefenderPlugin.getInstance().onPreInit(event, this.logger, this.configPath, this.pluginContainer);
    //Sponge.getEventManager().registerListeners(GriefDefenderPlugin.getInstance(), GriefDefenderPlugin.getInstance());
}
 
Example #14
Source File: ChatUI.java    From ChatUI with MIT License 4 votes vote down vote up
@Listener
public void onPreInit(GamePreInitializationEvent event) {
    instance = this;
}
 
Example #15
Source File: ChatUILib.java    From ChatUI with MIT License 4 votes vote down vote up
@Listener
public void onPreInit(GamePreInitializationEvent event) {
    instance = this;
}
 
Example #16
Source File: VirtualChestPlugin.java    From VirtualChest with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Listener
public void onPreInitialization(GamePreInitializationEvent event)
{
    DataManager dataManager = Sponge.getDataManager();
    dataManager.registerBuilder(VirtualChestInventory.class, new VirtualChestInventoryBuilder(this));
}
 
Example #17
Source File: GriefDefenderPlugin.java    From GriefDefender with MIT License 4 votes vote down vote up
public void onPreInit(GamePreInitializationEvent event, Logger logger, Path path, PluginContainer pluginContainer) {
    this.logger = logger;
    this.configPath = path;
    this.pluginContainer = pluginContainer;
    if (!validateSpongeVersion() || Sponge.getPlatform().getType().isClient()) {
        return;
    }

    this.permissionService = Sponge.getServiceManager().provide(PermissionService.class).orElse(null);
    if (this.permissionService == null) {
        this.logger.error("Unable to initialize plugin. GriefPrevention requires a permissions plugin such as LuckPerms.");
        return;
    }
    this.permissionProvider = new LuckPermsProvider();

    instance = this;
    this.getLogger().info("GriefDefender boot start.");
    this.getLogger().info("Finished loading configuration.");
    DEFAULT_HOLDER = new GDPermissionHolder("default");
    PUBLIC_USER = new GDPermissionUser(PUBLIC_UUID, PUBLIC_NAME);
    WORLD_USER = new GDPermissionUser(WORLD_USER_UUID, WORLD_USER_NAME);
    this.getLogger().info("Registering GriefDefender API...");
    Guice.createInjector(Stage.PRODUCTION, new GriefDefenderImplModule());

    ChatTypeRegistryModule.getInstance().registerDefaults();
    ClaimTypeRegistryModule.getInstance().registerDefaults();
    ClaimVisualTypeRegistryModule.getInstance().registerDefaults();
    ShovelTypeRegistryModule.getInstance().registerDefaults();
    TrustTypeRegistryModule.getInstance().registerDefaults();
    FlagRegistryModule.getInstance().registerDefaults();
    ResultTypeRegistryModule.getInstance().registerDefaults();
    CreateModeTypeRegistryModule.getInstance().registerDefaults();
    GameModeTypeRegistryModule.getInstance().registerDefaults();
    WeatherTypeRegistryModule.getInstance().registerDefaults();
    OptionRegistryModule.getInstance().registerDefaults();
    GriefDefender.getRegistry().registerBuilderSupplier(PaymentTransaction.Builder.class, GDPaymentTransaction.PaymentTransactionBuilder::new);
    GriefDefender.getRegistry().registerBuilderSupplier(Claim.Builder.class, GDClaim.ClaimBuilder::new);
    GriefDefender.getRegistry().registerBuilderSupplier(FlagData.Builder.class, GDFlagData.FlagDataBuilder::new);
    GriefDefender.getRegistry().registerBuilderSupplier(FlagDefinition.Builder.class, GDFlagDefinition.FlagDefinitionBuilder::new);
    Sponge.getEventManager().registerListeners(GDBootstrap.getInstance(), GriefDefenderPlugin.getInstance());
}