當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。