本文整理汇总了Java中org.bukkit.configuration.file.YamlConfiguration.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java YamlConfiguration.getInt方法的具体用法?Java YamlConfiguration.getInt怎么用?Java YamlConfiguration.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.configuration.file.YamlConfiguration
的用法示例。
在下文中一共展示了YamlConfiguration.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerExpChange
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@EventHandler
public void onPlayerExpChange(PlayerExpChangeEvent event){
Player player = event.getPlayer();
YamlConfiguration PlayerData = onLoadData(player.getName());
if(PlayerData ==null)return;
PlayerData.set("attribute.level", player.getLevel());
onSaveData(player.getName(), PlayerData);
if(Config.getConfig("extraExp.enabled").equals("true")){
int playerWantedPoints = PlayerData.getInt("wanted.points");
if(playerWantedPoints > 0){
int exp = event.getAmount();
int value = Integer.valueOf(Config.getConfig("extraExp.pointsValue").replaceAll("%", ""));
PlayerData.set("attribute.level", player.getLevel());
int addExp = Integer.valueOf(String.valueOf(exp*playerWantedPoints*value/100));
event.setAmount(addExp + exp);
if(getConfig().getBoolean("extraExp.message") == true)
player.sendMessage(Message.getMsg("player.expMessage", String.valueOf(addExp), String.valueOf(exp), String.valueOf(exp+addExp)));
onSaveData(player.getName(), PlayerData);
}
}
}
示例2: CheckAndDownloadPlugin
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void CheckAndDownloadPlugin() {
if (ConfigMain.AutoUpdate == true) {
try {
// 整体获取
File NetworkerFile = new File(EscapeLag.MainThis.getDataFolder(), "networkerlog");
DowloadFile("http://www.relatev.com/files/EscapeLag/NetWorker.yml", NetworkerFile);
YamlConfiguration URLLog = YamlConfiguration.loadConfiguration(NetworkerFile);
// 检查插件并下载新版本
EscapeLag.MainThis.getLogger().info("正在检查新版本插件,请稍等...");
int NewVersion = URLLog.getInt("UpdateVersion");
int NowVersion = Integer.valueOf("%BUILD_NUMBER%");
if (NewVersion > NowVersion) {
EscapeLag.MainThis.getLogger().info("插件检测到新版本 " + NewVersion + ",正在自动下载新版本插件...");
DowloadFile("https://www.relatev.com/files/EscapeLag/EscapeLag.jar", EscapeLag.getPluginsFile());
EscapeLag.MainThis.getLogger().info("插件更新版本下载完成!正在重启服务器!");
Bukkit.shutdown();
} else {
EscapeLag.MainThis.getLogger().info("EscapeLag插件工作良好,暂无新版本检测更新。");
}
// 完成提示
EscapeLag.MainThis.getLogger().info("全部网络工作都读取完毕了...");
} catch (IOException ex) {
}
}
}
示例3: load
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static FireCraftTableRecipe load(String name){
File f=new File(rs.getDataFolder()+File.separator+"SyntheticFormula"+File.separator+"FireCraftTable"+File.separator+name+".yml");
if(!f.exists())return null;
YamlConfiguration recipe=YamlConfiguration.loadConfiguration(f);
HashMap<Character,ItemStack> materials=new HashMap<>();
char c=' ';
for(String s:recipe.getStringList(name+".shape"))
for(char temp:s.toCharArray())
if(temp!=' '&&temp!=c){
c=temp;
materials.put(c, recipe.getItemStack(name+".material."+c));
}
ItemStack[] product=new ItemStack[4];
for(int i=0;i<3;i++)
product[i]=recipe.getItemStack(name+".product."+i);
return new FireCraftTableRecipe(recipe.getInt(name+".time"),recipe.getDouble(name+".temperature"),recipe.getInt(name+".maxTime"), name,
recipe.getStringList(name+".shape"), materials, product);
}
示例4: loadData
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public void loadData() {
file = new PluginFile(main, "data", FileType.YAML);
YamlConfiguration config = file.returnYaml();
checkDefaults();
// Supplydrops related.
for (String worldString : config.getStringList("supply-drops.enabled-worlds")) {
supplyDropWorlds.add(Bukkit.getWorld(worldString));
}
// Radiation related.
this.defaultRadiationDamage = config.getDouble("radiation.default-damage");
this.stormRadiationDamage = config.getDouble("radiation.storm-damage");
this.waterRadiationDamage = config.getDouble("radiation.water-damage");
this.radiationDamageDelay = config.getInt("radiation.seconds-delay");
}
示例5: isJailPlayer
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public Boolean isJailPlayer(Player player){
YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(player.getName());
if(PlayerData == null) return false;
int playerJaiTimes = PlayerData.getInt("jail.times");
if(playerJaiTimes > 0){
return true;
}
return false;
}
示例6: surrendPlayer
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void surrendPlayer(Player player){
YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(player.getName());
int value = PlayerData.getInt("jail.times");
int times = PlayerData.getInt("wanted.points")*Integer.valueOf(Config.getConfig("timeTick.jailPlayerTimes").replace("min", "").replace("m", ""));
if(value > 0){
player.sendMessage(Message.getMsg("player.isAlreadyInJailMessage"));
return;
}
if(times <1){
player.sendMessage(Message.getMsg("player.notSurrendMessage"));
return;
}
Location location = player.getLocation();
int playerX = location.getBlockX();
int playerY = location.getBlockY();
int playerZ = location.getBlockZ();
String playerWorld = location.getWorld().getName();
PlayerData.set("attribute.X", playerX);
PlayerData.set("attribute.Y", playerY);
PlayerData.set("attribute.Z", playerZ);
PlayerData.set("attribute.World", playerWorld);
PlayerData.set("wanted.points", Integer.valueOf(0));
PlayerData.set("jail.times", times);
PVPAsWantedManager.onDeleteList(player.getName(), "WantedList");
PVPAsWantedManager.onCreateList(player.getName(), "JailedList");
PVPAsWantedManager.onSaveData(player.getName(), PlayerData);
JailManager.playerJoinJail(player,location);
player.sendMessage(Message.getMsg("player.surrendMessage",String.valueOf(times)));
}
示例7: onSetJailTimes
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@PlayerCommand(cmd="setTime",arg = " <player> <times>")
public void onSetJailTimes(CommandSender sender,String args[]){
if(sender instanceof Player){
if(!sender.hasPermission("pvpaswantedmanager." + args[0])) {
sender.sendMessage(Message.getMsg("player.noPermissionMessage"));
return;
}
}
if(args.length <= 2 ){
sender.sendMessage(Message.getMsg("admin.setTimeCorrectionsMessage"));
return;
}
if(!Pattern.compile("[-0-9]*").matcher(args[2]).matches()){
sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
return;
}
String playerName = args[1];
YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(playerName);
if(PlayerData == null){
sender.sendMessage(Message.getMsg("admin.playerNullMessage"));
return;
}
int times = PlayerData.getInt("jail.times");
int value = times + Integer.valueOf(args[2]);
PlayerData.set("jail.times", value);
onSaveData(playerName, PlayerData);
sender.sendMessage(Message.getMsg("admin.EditPlayerJailTimesMessage", playerName,String.valueOf(value)));
}
示例8: onQuitJail
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@PlayerCommand(cmd="quitJail",arg = " <player>")
public void onQuitJail(CommandSender sender,String args[]){
if(sender instanceof Player){
if(!sender.hasPermission("pvpaswantedmanager." + args[0])) {
sender.sendMessage(Message.getMsg("player.noPermissionMessage"));
return;
}
}
if(args.length <=1){
sender.sendMessage(Message.getMsg("admin.quitJailCorrectionsMessage"));
return;
}
String playerName = args[1];
if(isPlayerOnline(playerName)){
Player player = Bukkit.getPlayer(playerName);
YamlConfiguration PlayerData = onLoadData(player.getName());
if(PlayerData ==null)return;
int value = PlayerData.getInt("jail.times");
if(value == 0){
sender.sendMessage(Message.getMsg("admin.playerIsNotInJailMessage"));
return;
}
PlayerData.set("jail.times", Integer.valueOf(0));
PlayerData.set("attribute.X", Integer.valueOf(0));
PlayerData.set("attribute.Y", Integer.valueOf(0));
PlayerData.set("attribute.Z", Integer.valueOf(0));
PlayerData.set("attribute.World", String.valueOf("world"));
JailManager.playerQuitJail(player);
onDeleteList(player.getName(),"JailedList");
PVPAsWantedManager.onSaveData(player.getName(), PlayerData);
sender.sendMessage(Message.getMsg("admin.quitJailPlayerMessage", args[1]));
player.sendMessage(Message.getMsg("player.jailedCancelMessage"));
}else{
sender.sendMessage(Message.getMsg("admin.playerOfflineMessage"));
}
}
示例9: onSetPoint
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@PlayerCommand(cmd="setPoint",arg = " <player> <value>")
public void onSetPoint(CommandSender sender,String args[]){
if(sender instanceof Player){
if(!sender.hasPermission("pvpaswantedmanager." + args[0])) {
sender.sendMessage(Message.getMsg("player.noPermissionMessage"));
return;
}
}
if(args.length <3){
sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
return;
}
YamlConfiguration PlayerData = onLoadData(args[1]);
if(PlayerData == null){
sender.sendMessage(Message.getMsg("admin.playerNullMessage"));
return;
}
if(!Pattern.compile("[0-9]*").matcher(args[2]).matches()){
sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
return;
}
int value = Integer.valueOf(args[2]);
if(PlayerData.getInt("wanted.points")==0&& value > 0){
PVPAsWantedManager.onCreateList(args[1], "WantedList");
}else if(PlayerData.getInt("wanted.points")>0 && value ==0){
PVPAsWantedManager.onDeleteList(args[1], "WantedList");
}
PlayerData.set("wanted.points", value);
PVPAsWantedManager.onSaveData(args[1], PlayerData);
sender.sendMessage(Message.getMsg("admin.EditPlayerDataMessage"));
}
示例10: 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");
}
示例11: 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);
// }
}
}
示例12: loadSupplyData
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public void loadSupplyData() {
file = new PluginFile(main, "supplyDrops", FileType.YAML);
YamlConfiguration config = file.returnYaml();
// Supply content
// If no content for supply drops is set in config, set a default one to
// avoid a NPE.
if (config.getConfigurationSection("supply-drops.items") == null) {
main.getLogger().info("No Supplydrop content found. Setting defaults.");
String path = "supply-drops.items.0";
config.set(path + ".material", "STONE");
config.set(path + ".chance", 75);
config.set(path + ".amount", 32);
file.save(config);
}
for (String key : config.getConfigurationSection("supply-drops.items").getKeys(false)) {
Material itemMaterial = Material
.valueOf(config.getString("supply-drops.items." + key + ".material").toUpperCase());
int itemChance = config.getInt("supply-drops.items." + key + ".chance");
int itemAmount = config.getInt("supply-drops.items." + key + ".amount");
supplyContent.add(new SupplyDropContent(itemMaterial, itemChance, itemAmount));
}
// Supply drops
for (String s : config.getStringList("supply-drops.objects")) {
Location loc = StringUtilities.stringToLocation(s);
loc.getBlock().setType(Material.CHEST);
Chest chest = (Chest) loc.getBlock().getState();
supplyDrops.add(new SupplyDropObject(loc, chest, chest.getInventory()));
}
}
示例13: onLoad
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@Override
public void onLoad() {
try {
Path data = getDataFolder().toPath();
Path resolve = data.resolve("config.yml");
if (!resolve.toFile().exists()) {
getLogger().warning("Configuration file does not exist! Recreating!");
List<String> lines = new ArrayList<>();
lines.add("# RManager configuration file");
lines.add("");
lines.add("# Server ID, used for identification purposes");
lines.add("server-id: 'foo_bar'");
lines.add("");
lines.add("# Database information, points to a valid Redis server");
lines.add("# Database-id selects the database number provided, if unsure, leave as 0");
lines.add("hostname: 'localhost'");
lines.add("password: 'password'");
lines.add("port: 6379");
lines.add("database-id: 0");
if (!data.toFile().exists())
Files.createDirectory(data);
Files.write(resolve, lines, StandardOpenOption.CREATE);
}
getLogger().info("Loading configuration file...");
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(resolve.toFile());
String serverID = configuration.getString("server-id");
String hostname = configuration.getString("hostname");
String password = configuration.getString("password");
int port = configuration.getInt("port");
int dbID = configuration.getInt("database-id");
getLogger().info("Success! Initializing database as '" + serverID + "'! (" + hostname + ":" + port + "/" + dbID + ")");
Database.initDatabase(serverID, hostname, password, port, dbID);
} catch (Exception e) {
throw new RuntimeException("Error loading configuration: ", e);
}
}
示例14: sanitizeConfig
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
private void sanitizeConfig(YamlConfiguration c) {
int lineStartsAt = c.getInt(CONFIG_LINE_STARTS_AT);
if (lineStartsAt < 0 || lineStartsAt > 1) setDefaultConfig(CONFIG_LINE_STARTS_AT);
String clicking = c.getString(CONFIG_CLICKING);
if (clicking == null ||
!(clicking.equalsIgnoreCase("true") ||
clicking.equalsIgnoreCase("false") ||
clicking.equalsIgnoreCase("auto"))) setDefaultConfig(CONFIG_CLICKING);
}
示例15: onJoinJail
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@PlayerCommand(cmd="joinJail",arg = " <player> <times>")
public void onJoinJail(CommandSender sender,String args[]){
if(sender instanceof Player){
if(!sender.hasPermission("pvpaswantedmanager." + args[0])) {
sender.sendMessage(Message.getMsg("player.noPermissionMessage"));
return;
}
}
if(args.length <=2 ){
sender.sendMessage(Message.getMsg("admin.joinJailCorrectionsMessage"));
return;
}
String playerName = args[1];
if(!Pattern.compile("[0-9]*").matcher(args[2]).matches()){
sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
return;
}
int times = Integer.valueOf(args[2]);
if(isPlayerOnline(playerName)){
Player player = Bukkit.getPlayer(playerName);
YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(player.getName());
if(PlayerData ==null)return;
int value = PlayerData.getInt("jail.times");
if(value > 0){
sender.sendMessage(Message.getMsg("admin.playerIsAlreadyInJailMessage"));
return;
}
Location location = player.getLocation();
int playerX = location.getBlockX();
int playerY = location.getBlockY();
int playerZ = location.getBlockZ();
String playerWorld = location.getWorld().getName();
PlayerData.set("attribute.X", playerX);
PlayerData.set("attribute.Y", playerY);
PlayerData.set("attribute.Z", playerZ);
PlayerData.set("attribute.World", playerWorld);
PlayerData.set("jail.times", times);
onDeleteList(player.getName(), "WantedList");
onCreateList(player.getName(), "JailedList");
onSaveData(player.getName(), PlayerData);
JailManager.playerJoinJail(player,location);
sender.sendMessage(Message.getMsg("admin.joinJailPlayerMessage", args[1],args[2]));
player.sendMessage(Message.getMsg("player.jailedJoinMessage",args[2]));
}else{
sender.sendMessage(Message.getMsg("admin.playerOfflineMessage"));
}
}