本文整理汇总了Java中org.bukkit.configuration.file.YamlConfiguration.getBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java YamlConfiguration.getBoolean方法的具体用法?Java YamlConfiguration.getBoolean怎么用?Java YamlConfiguration.getBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.configuration.file.YamlConfiguration
的用法示例。
在下文中一共展示了YamlConfiguration.getBoolean方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPlayerData
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
* ��ȡPlayerData
* @param rs ����·��
* @param p Player����
* @return PlayerData����
*/
public static PlayerData getPlayerData(Player p){
File data=new File(rs.getDataFolder()+File.separator+"PlayerDatas"+File.separator+p.getUniqueId().toString()+".yml");
PlayerData pd;
if(!data.exists()){
try {data.createNewFile();} catch (IOException e) {}
pd=new PlayerData(p.getUniqueId(),p.getWorld().getName(), rs.getSleepMax(),
rs.getThirstMax(), 0, 37,0, rs.getPhysical_strength());
return pd;
}
YamlConfiguration dataC=YamlConfiguration.loadConfiguration(data);
HashMap<String,Object[]> sickKind=new HashMap<String,Object[]>();
for(String temp:dataC.getStringList("rSickKind")){
List<String> l=dataC.getStringList("sickKind."+temp);
sickKind.put(temp,new Object[]{l.get(0),l.get(1),l.get(2),l.get(3)} );
}
pd=new PlayerData( p.getUniqueId(),dataC.getString("world"), dataC.getDouble("sleep"),
dataC.getDouble("thirst"), dataC.getDouble("temperature"), dataC.getDouble("weight"),
dataC.getDouble("physical_strength"),dataC.getBoolean("sick"),
dataC.getBoolean("isSleep"),Byte.parseByte(dataC.getString("light")),sickKind);
return pd;
}
示例2: BMetrics
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
* Class constructor.
*
* @param plugin The plugin which stats should be submitted.
*/
public BMetrics() {
// Get the config file
File bStatsFolder = new File(getConfigFile(), "bStats");
File configFile = new File(bStatsFolder, "config.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
// Check if the config file exists
if (!config.isSet("serverUuid")) {
// Add default values
config.addDefault("enabled", true);
// Every server gets it's unique random id.
config.addDefault("serverUuid", UUID.randomUUID().toString());
// Should failed request be logged?
config.addDefault("logFailedRequests", false);
// Inform the server owners about bStats
config.options().header(
"bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
"To honor their work, you should not disable it.\n" +
"This has nearly no effect on the server performance!\n" +
"Check out https://bStats.org/ to learn more :)"
).copyDefaults(true);
try {
config.save(configFile);
} catch (IOException ignored) { }
}
// Load the data
serverUUID = config.getString("serverUuid");
logFailedRequests = config.getBoolean("logFailedRequests", false);
if (config.getBoolean("enabled", true)) {
startSubmitting();
}
}
示例3: reloadConfigs
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
static void reloadConfigs()
{
YamlConfiguration mainConfig = load(configFolder + "/" + MAIN_CONFIG);
WORLDGUARD_DEFAULT = mainConfig.getBoolean("worldguard_flag_enable");
PRISON_PICK_FLAG = new StateFlag("prison-picks", WORLDGUARD_DEFAULT);
EXPLOSIVE_COLOR = ChatColor.getByChar(mainConfig.getString("explosive_color").charAt(1));
PICK_O_PLENTY_COLOR = ChatColor.getByChar(mainConfig.getString("pick_o_plenty_color").charAt(1));
FAKE_EXPLOSIVE_PICK_O_PLENTY_COLOR = ChatColor.getByChar(mainConfig.getString("fake_xpop_color").charAt(1));
CHAT_SUCCESS_COLOR = ChatColor.getByChar(mainConfig.getString("success_color").charAt(1));
CHAT_FAIL_COLOR = ChatColor.getByChar(mainConfig.getString("fail_color").charAt(1));
CHAT_PICK_BREAK = ChatColor.getByChar(mainConfig.getString("pick_break_color").charAt(1));
CHAT_EXPLOSIVE_REPAIR = ChatColor.getByChar(mainConfig.getString("explosive_repair_msg").charAt(1));
CHAT_POP_REPAIR = ChatColor.getByChar(mainConfig.getString("pop_repair_msg").charAt(1));
CHAT_XPOP_REPAIR = ChatColor.getByChar(mainConfig.getString("xpop_repair_msg").charAt(1));
COAL_PRIORITY = mainConfig.getInt("coal_priority");
IRON_PRIORITY = mainConfig.getInt("iron_priority");
REDSTONE_PRIORITY = mainConfig.getInt("redstone_priority");
LAPIS_PRIORITY = mainConfig.getInt("lapis_priority");
GOLD_PRIORITY = mainConfig.getInt("gold_priority");
QUARTZ_PRIORITY = mainConfig.getInt("quartz_priority");
DIAMOND_PRIORITY = mainConfig.getInt("diamond_priority");
DIAMOND_BLOCK_PRIORITY = mainConfig.getInt("diamond_block_priority");
EMERALD_PRIORITY = mainConfig.getInt("emerald_priority");
}
示例4: loadPlayersFromDisk
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public void loadPlayersFromDisk() {
file = new PluginFile(main, "players", FileType.YAML);
YamlConfiguration config = file.returnYaml();
for (String key : config.getConfigurationSection("").getKeys(false)) {
// Only convert online players to PlayerObject and add to Map.
// for (Player online : Bukkit.getOnlinePlayers()) {
UUID uuid = UUID.fromString(key);
// if (!online.getUniqueId().equals(uuid))
// continue;
PlayerObject p = new PlayerObject(uuid);
PKStates state = PKStates.getStateByString(config.getString(key + ".pk-state"));
boolean inGeckRange = config.getBoolean(key + ".in-geck-range");
long lastPlayerKill = config.getLong(key + ".last-player-kill");
int playerKills = config.getInt(key + ".kills");
p.setPkState(state);
p.setPlayerKills(playerKills);
p.setPlayerInRangeOfGeck(inGeckRange);
p.setLastPlayerKillTime(lastPlayerKill);
mtPlayers.put(uuid, p);
// }
}
}
示例5: enable
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@Override
protected void enable() {
SqlProvider sqlProvider = getService(SqlProvider.class);
if (sqlProvider == null) {
throw new RuntimeException("Unable to obtain SqlProvider!");
}
// load sql instance
YamlConfiguration config = loadConfig("config.yml");
if (config.getBoolean("use-global-credentials", true)) {
sql = sqlProvider.getDataSource();
} else {
sql = sqlProvider.getDataSource(DatabaseCredentials.fromConfig(config));
}
// init the table
tableName = config.getString("table-name", "helper_profiles");
try (Connection c = sql.getConnection()) {
try (Statement s = c.createStatement()) {
s.execute(replaceTableName(CREATE));
}
} catch (SQLException e) {
e.printStackTrace();
}
// preload data
int preloadAmount = config.getInt("preload-amount", 2000);
if (preloadAmount > 0) {
getLogger().info("Preloading the most recent " + preloadAmount + " entries...");
long start = System.currentTimeMillis();
int found = preload(preloadAmount);
long time = System.currentTimeMillis() - start;
getLogger().info("Preloaded " + found + " profiles into the cache! - took " + time + "ms");
}
// observe logins
Events.subscribe(PlayerLoginEvent.class, EventPriority.MONITOR)
.filter(e -> e.getResult() == PlayerLoginEvent.Result.ALLOWED)
.handler(e -> {
ImmutableProfile profile = new ImmutableProfile(e.getPlayer().getUniqueId(), e.getPlayer().getName());
updateCache(profile);
Scheduler.runAsync(() -> saveProfile(profile));
})
.bindWith(this);
// provide the ProfileRepository service
provideService(ProfileRepository.class, this);
}
示例6: Updater
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public Updater(Main plugin, int resourceID, boolean log)
throws IOException
{
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
if (resourceID == 0) {
throw new IllegalArgumentException("Resource ID cannot be null (0)");
}
m = plugin;
this.id = resourceID;
this.log = log;
this.url = new URL("https://api.inventivetalent.org/spigot/resource-simple/" + resourceID);
File configDir = new File(plugin.getDataFolder().getParentFile(), "HeadUpdater");
File config = new File(configDir, "config.yml");
YamlConfiguration yamlConfig = new YamlConfiguration();
if (!configDir.exists()) {
configDir.mkdirs();
}
if (!config.exists())
{
config.createNewFile();
yamlConfig.options().header("Configuration for the HeadUpdater system\nit will inform you about new versions of all plugins which use this updater\n'enabled' specifies whether the system is enabled (affects all plugins)");
yamlConfig.options().copyDefaults(true);
yamlConfig.addDefault("enabled", Boolean.valueOf(true));
yamlConfig.addDefault("enabledingame", Boolean.valueOf(true));
yamlConfig.save(config);
}
try
{
yamlConfig.load(config);
}
catch (InvalidConfigurationException e)
{
e.printStackTrace();
return;
}
this.enabled = yamlConfig.getBoolean("enabled");
this.enabledingame = yamlConfig.getBoolean("enabledingame");
super.start();
}