当前位置: 首页>>代码示例>>Java>>正文


Java PreInitializationEvent类代码示例

本文整理汇总了Java中org.spongepowered.api.event.state.PreInitializationEvent的典型用法代码示例。如果您正苦于以下问题:Java PreInitializationEvent类的具体用法?Java PreInitializationEvent怎么用?Java PreInitializationEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PreInitializationEvent类属于org.spongepowered.api.event.state包,在下文中一共展示了PreInitializationEvent类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInit

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
public void onInit(PreInitializationEvent event) {
    log = event.getPluginLog();
    log.info("Plugin loading.");
    instance = this;
    exceptionMap = new HashMap<String, Config>();
    File pluginDirectory = event.getConfigurationDirectory();
    config = new Config(new File(pluginDirectory, "config.yml"));
    exceptionConfig = new Config(new File(pluginDirectory, "exceptions.yml"));

    try {
        config.load();
        exceptionConfig.load();

        for(String s : exceptionConfig.getMap().keySet()) {
            exceptionMap.put(s, new Config(new File(pluginDirectory, exceptionConfig.getMap().get(s))));
        }
    } catch(IOException e) {
        e.printStackTrace();
    }

    log.info("Plugin enabled.");
}
 
开发者ID:MrMysteri0us,项目名称:DBManager,代码行数:24,代码来源:DBManagerPlugin.java

示例2: onPreInitialization

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
private void onPreInitialization(PreInitializationEvent event) {
    this.logger.info("Boilerplate plugin loaded! Now add your own code :)");

    this.logger.info("Registering sample service...");

    this.provider = new SimpleNotificationService();
    this.provider.setNotification("Welcome to the server!");

    try {
        // Try to register this service
        this.game.getServiceManager().setProvider(this,
                NotificationService.class, this.provider);

    } catch (ProviderExistsException e) {
        this.logger.info("Sample service was already registered by another plugin :(");

        // Remove reference to free up memory
        this.provider = null;

        // Shut down
        return;
    }

    this.logger.info("Successfully registered sample service!");

    this.logger.info("Subscribing to events...");
    this.game.getEventManager().register(this, this.provider);
}
 
开发者ID:spbp,项目名称:api-plugin-boilerplate,代码行数:30,代码来源:NotifierPlugin.java

示例3: onPreInitialization

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
public void onPreInitialization (PreInitializationEvent event) {
    if (!this.configDir.exists()) {
        if (!this.configDir.mkdir()) {
            this.logger.error("Unable to create configuration folder");
        }
    }

    this.mainConfig = new SpongeConfig(new File(this.configDir, "config.yml"), this.logger);
}
 
开发者ID:TheArchives,项目名称:ArchBlock,代码行数:11,代码来源:SpongePlugin.java

示例4: onPreInit

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
   public void onPreInit(PreInitializationEvent event) {
	// Create a new DirectiveHandler with the plugin object (this) and the game
	DirectiveHandler handler = new DirectiveHandler(this, event.getGame());
	
	// Add all of your directive commands through the addDirectives method
	handler.addDirectives(DemoPlugin.class);
	
	// After you have added all of the directives, register them
	handler.registerDirectives();
}
 
开发者ID:mcardy,项目名称:Directive,代码行数:12,代码来源:DemoPlugin.java

示例5: onPreInit

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
public void onPreInit(PreInitializationEvent event) {
	Zephyr.setAPISingleton(this);
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:5,代码来源:ZephyrPlugin.java

示例6: onPreInitialization

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
public void onPreInitialization( PreInitializationEvent event )
{
    this.server = this.game.getServer();
    try
    {
        if ( !this.configFile.exists() )
        {
            Files.createFile( this.configFile.toPath() );
            this.config = this.configManager.load();

            this.config.getNode( "ConfigVersion" ).setValue( 1 );

            this.config.getNode( "database", "type" ).setValue( "mysql" );
            this.config.getNode( "database", "host" ).setValue( "localhost" );
            this.config.getNode( "database", "port" ).setValue( 3306 );
            this.config.getNode( "database", "user" ).setValue( "root" );
            this.config.getNode( "database", "pass" ).setValue( "password" );
            this.config.getNode( "database", "data" ).setValue( "database" );

            this.config.getNode( "protection", "material" ).setValue( "SPONGE" );
            this.config.getNode( "protection", "metadata" ).setValue( "protector" );

            this.configManager.save( config );
            this.logger.info(
                    "Created default configuration, " +
                            "OglofusProtection will not run until you have edited this file!"
            );
        }
    } catch ( IOException exception )
    {
        this.logger.error( "Couldn't create default configuration file!" );
    }

    if ( this.config.getNode( "database", "type" ).getString().equalsIgnoreCase( "sqlite" ) )
    {
        this.connector = new DatabaseConnector(
                new SQLiteDatabaseDriver(
                        Paths.get(
                                this.config.getNode(
                                        "database", "host"
                                ).getString()
                        )
                )
        );
    } else
    {
        this.connector = new DatabaseConnector(
                new MySQLDatabaseDriver(
                        this.config.getNode( "database", "user" ).getString(),
                        this.config.getNode( "database", "data" ).getString(),
                        this.config.getNode( "database", "pass" ).getString(),
                        this.config.getNode( "database", "host" ).getString(),
                        this.config.getNode( "database", "port" ).getInt()
                )
        );
    }

    this.connector.openConnection();

    if ( this.connector.checkConnection() )
    {
        this.regionManager = new OglofusRegionManager( this );
        this.invitationManager = new OglofusInvitationManager( this );
    }
}
 
开发者ID:nikosgram13,项目名称:OglofusProtection,代码行数:67,代码来源:OglofusSponge.java

示例7: onPreInitialization

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
private void onPreInitialization(PreInitializationEvent event) {
    this.logger.info("Boilerplate plugin loaded! Now add your own code :)");
}
 
开发者ID:spbp,项目名称:simple-boilerplate,代码行数:5,代码来源:WelcomePlugin.java

示例8: onPreInitialization

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
public void onPreInitialization(PreInitializationEvent event) {
    Interact.prepare(this, game);
}
 
开发者ID:DSH105,项目名称:Interact,代码行数:5,代码来源:SpongeInteractPlugin.java

示例9: onConstruction

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@SpongeEventHandler
public void onConstruction(PreInitializationEvent event) {
    game = event.getGame();
    log.info("Kiedys sie okaze czy pojawi sie ta wiadomosc na czacie xd");
    game.broadcastMessage("Ten event wykonuje sie przy pre inicjacji");
}
 
开发者ID:grzegorz2047,项目名称:TestSpongePlugin,代码行数:7,代码来源:TestPlugin.java

示例10: onInit

import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
public void onInit(PreInitializationEvent event) {
    sql = services.potentiallyProvide(SqlService.class);
    configDir.mkdirs();
    load();
}
 
开发者ID:WorldCretornica,项目名称:PlotMe-Core,代码行数:7,代码来源:PlotMe_Sponge.java


注:本文中的org.spongepowered.api.event.state.PreInitializationEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。