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


Java ConfigurationSection.getLong方法代码示例

本文整理汇总了Java中org.bukkit.configuration.ConfigurationSection.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationSection.getLong方法的具体用法?Java ConfigurationSection.getLong怎么用?Java ConfigurationSection.getLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.configuration.ConfigurationSection的用法示例。


在下文中一共展示了ConfigurationSection.getLong方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureData

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
private boolean configureData(ConfigurationSection config) {
	String host = config.getString("host", "localhost");
	int port = config.getInt("port", 3306);
	String dbname = config.getString("database", "cropcontrol");
	String username = config.getString("user");
	String password = config.getString("password");
	int poolsize = config.getInt("poolsize", 5);
	long connectionTimeout = config.getLong("connection_timeout", 10000l);
	long idleTimeout = config.getLong("idle_timeout", 600000l);
	long maxLifetime = config.getLong("max_lifetime", 7200000l);
	try {
		data = new ManagedDatasource(CropControl.getPlugin(), username, password, host, port, dbname,
				poolsize, connectionTimeout, idleTimeout, maxLifetime);
		data.getConnection().close();
	} catch (Exception se) {
		CropControl.getPlugin().info("Failed to initialize Database connection");
		return false;
	}

	initializeTables();		
	stageUpdates();
	
	long begin_time = System.currentTimeMillis();

	try {
		CropControl.getPlugin().info("Update prepared, starting database update.");
		if (!data.updateDatabase()) {
			CropControl.getPlugin().info( "Update failed, disabling plugin.");
			return false;
		}
	} catch (Exception e) {
		CropControl.getPlugin().severe("Update failed, disabling plugin. Cause:", e);
		return false;
	}

	CropControl.getPlugin().info(String.format("Database update took %d seconds", (System.currentTimeMillis() - begin_time) / 1000));
	
	activateDirtySave(config.getConfigurationSection("dirtysave"));
	return true;
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:41,代码来源:CropControlDatabaseHandler.java

示例2: activateDirtySave

import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
private void activateDirtySave(ConfigurationSection config) {
	long period = 5*60*1000l;
	long delay = 5*60*1000l;
	if (config != null) {
		period = config.getLong("period", period);
		delay = config.getLong("delay", delay);
	}
	
	Bukkit.getScheduler().runTaskTimerAsynchronously(CropControl.getPlugin(), new Runnable() {
		@Override
		public void run() {
			Crop.saveDirty();
		}
	}, delay, period);

	Bukkit.getScheduler().runTaskTimerAsynchronously(CropControl.getPlugin(), new Runnable() {
		@Override
		public void run() {
			Sapling.saveDirty();
		}
	}, delay + (period / 5), period);
	
	Bukkit.getScheduler().runTaskTimerAsynchronously(CropControl.getPlugin(), new Runnable() {
		@Override
		public void run() {
			Tree.saveDirty();
		}
	}, delay + ((period * 2) / 5), period);

	Bukkit.getScheduler().runTaskTimerAsynchronously(CropControl.getPlugin(), new Runnable() {
		@Override
		public void run() {
			TreeComponent.saveDirty();
		}
	}, delay + ((period * 3) / 5), period);

	Bukkit.getScheduler().runTaskTimerAsynchronously(CropControl.getPlugin(), new Runnable() {
		@Override
		public void run() {
			WorldChunk.doUnloads();
		}
	}, delay + ((period * 4) / 5), period);

	CropControl.getPlugin().info("Dirty save tasks started.");
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:46,代码来源:CropControlDatabaseHandler.java


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