本文整理汇总了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;
}
示例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.");
}