本文整理汇总了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.");
}
示例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);
}
示例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);
}
示例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();
}
示例5: onPreInit
import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
public void onPreInit(PreInitializationEvent event) {
Zephyr.setAPISingleton(this);
}
示例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 );
}
}
示例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 :)");
}
示例8: onPreInitialization
import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
public void onPreInitialization(PreInitializationEvent event) {
Interact.prepare(this, game);
}
示例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");
}
示例10: onInit
import org.spongepowered.api.event.state.PreInitializationEvent; //导入依赖的package包/类
@Subscribe
public void onInit(PreInitializationEvent event) {
sql = services.potentiallyProvide(SqlService.class);
configDir.mkdirs();
load();
}