本文整理汇总了Java中org.bukkit.configuration.file.YamlConfiguration.loadConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java YamlConfiguration.loadConfiguration方法的具体用法?Java YamlConfiguration.loadConfiguration怎么用?Java YamlConfiguration.loadConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.configuration.file.YamlConfiguration
的用法示例。
在下文中一共展示了YamlConfiguration.loadConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateConfig
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
/**
* Update the configuration file
*
* @param currentVersion the version of the configuration file
*/
public void updateConfig(int currentVersion) {
InputStream in = plugin.getResource("config.yml");
try (InputStreamReader inReader = new InputStreamReader(in)) {
FileConfiguration defaultConfig = YamlConfiguration.loadConfiguration(inReader);
if (defaultConfig.getInt("version") == currentVersion) {
return;
}
Set<String> newKeys = defaultConfig.getKeys(false);
for (String key : plugin.getConfig().getKeys(false)) {
if (key.equalsIgnoreCase("version")) {
continue;
}
if (newKeys.contains(key)) {
defaultConfig.set(key, plugin.getConfig().get(key));
}
}
defaultConfig.save(new File(plugin.getDataFolder() + "/config.yml"));
} catch (IOException e) { e.printStackTrace(); }
}
示例2: FileConfig
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public FileConfig(String fileName) {
this.fileName = fileName;
this.configFile = new File(PracticePlugin.getInstance().getDataFolder(), fileName);
if (!this.configFile.exists()) {
this.configFile.getParentFile().mkdirs();
if (PracticePlugin.getInstance().getResource(fileName) == null) {
try {
this.configFile.createNewFile();
}
catch (IOException e) {
PracticePlugin.getInstance().getLogger().severe("Failed to create new file " + fileName);
}
}
else {
PracticePlugin.getInstance().saveResource(fileName, false);
}
}
this.config = YamlConfiguration.loadConfiguration(this.configFile);
}
示例3: getYaml
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static YamlConfiguration getYaml(Plugin p, String path, boolean create){
path = fixPath(path);
File temp = new File(p.getDataFolder(), path);
if(!temp.exists()){
copyFile(path, p);
if(!temp.exists()){
if(create)
try {
temp.createNewFile();
} catch (IOException e) {
ErrorLogger.addError("Can't create " + path + " IO Exception !");
e.printStackTrace();
}
else
return null;
}
}
YamlConfiguration file = YamlConfiguration.loadConfiguration(temp);
return file;
}
示例4: setup
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public void setup() {
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdir();
}
ranksFile = new File(plugin.getDataFolder(), "ranks.yml");
if (!ranksFile.exists()) {
try {
ranksFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
ranksCFG = YamlConfiguration.loadConfiguration(ranksFile);
}
示例5: loadConfig
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void loadConfig(Plugin plugin) {
pl = plugin;
file = new File(pl.getDataFolder(), "config.yml");
Config = YamlConfiguration.loadConfiguration(file);
if (!pl.getDataFolder().exists()) {
pl.getDataFolder().mkdir();
}
create();
int gamemode = Config.getInt("On-Join.Spawn.Gamemode.Gamemode");
if ((gamemode != 0) && (gamemode != 1) && (gamemode != 2) && (gamemode != 3)) {
Config.set("On-Join.Spawn.Gamemode.Gamemode", Integer.valueOf(0));
}
}
示例6: Map
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public Map(String title, String worldName, List<Location> spawns, Location specSpawn) {
list.add(this);
this.id = list.size();
this.title = title;
this.worldName = worldName;
this.spawns = spawns;
this.specSpawn = specSpawn;
File file = new File(SurvivalGames.getInstance().getDataFolder() + File.separator + "maps", worldName + ".yml");
if (!file.exists()) {
try {
file.createNewFile();
}
catch (IOException e) {
e.printStackTrace();
}
}
config = YamlConfiguration.loadConfiguration(file);
}
示例7: loadConfig
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void loadConfig(Plugin plugin) {
pl = plugin;
file = new File(pl.getDataFolder(), "Config/Global/OnJoin/Cosmetics-OnJoin.yml");
Config = YamlConfiguration.loadConfiguration(file);
if (!pl.getDataFolder().exists()) {
pl.getDataFolder().mkdir();
}
create();
int gamemode = Config.getInt("On-Join.Spawn.Gamemode.Gamemode");
if ((gamemode != 0) && (gamemode != 1) && (gamemode != 2) && (gamemode != 3)) {
Config.set("Gamemode.Value", Integer.valueOf(0));
}
}
示例8: signRemoved
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@EventHandler
public void signRemoved(BlockBreakEvent event) {
Location blockLocation = event.getBlock().getLocation();
World w = blockLocation.getWorld();
Block b = w.getBlockAt(blockLocation);
if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST){
Sign sign = (Sign) b.getState();
String line1 = ChatColor.stripColor(sign.getLine(0));
if (line1.equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', new Messaging.MessageFormatter().format("signJoinSigns.line1"))))) {
String world = blockLocation.getWorld().getName().toString();
int x = blockLocation.getBlockX();
int y = blockLocation.getBlockY();
int z = blockLocation.getBlockZ();
File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
if (signJoinFile.exists()) {
FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
for (String gameNumber : storage.getConfigurationSection("games.").getKeys(false)) {
String world1 = storage.getString("games." + gameNumber + ".world");
int x1 = storage.getInt("games." + gameNumber + ".x");
int y1 = storage.getInt("games." + gameNumber + ".y");
int z1 = storage.getInt("games." + gameNumber + ".z");
if (x1 == x && y1 == y && z1 == z && world.equalsIgnoreCase(world1)) {
if (event.getPlayer().hasPermission("swr.signs")) {
SkyWarsReloaded.getGC().removeSignJoinGame(gameNumber);
} else {
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "YOU DO NOT HAVE PERMISSION TO DESTROY SWR SIGNS");
}
}
}
}
}
}
}
示例9: KingdomFactionsFile
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public KingdomFactionsFile(String name) {
ConfigModule.getInstance().getFiles().add(this);
this.name = name;
file = new File(KingdomFactionsPlugin.getInstance().getDataFolder(), name);
this.config = YamlConfiguration.loadConfiguration(file);
if (this.file.exists()) {
try {
this.file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
示例10: DataFile
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public DataFile(JavaPlugin plugin, String name) {
file = new File(plugin.getDataFolder(), name + ".yml");
if (!file.getParentFile().exists()) {
file.getParentFile().mkdir();
}
plugin.saveResource(name + ".yml", false);
configuration = YamlConfiguration.loadConfiguration(file);
}
示例11: ConfigAPI
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public ConfigAPI(File file, JavaPlugin plugin) {
if (!file.exists()) {
try {
file.getParentFile().mkdirs();
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
this.config = YamlConfiguration.loadConfiguration(file);
}
示例12: setRating
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void setRating(UUID uuid, Ladder ladder, Integer rating, GenericCallback callback) {
if (Bukkit.getPlayer(uuid) != null) {
ManagerHandler.getPlayerManager().getPlayerProfile(uuid).setRating(ladder, 1000);
ManagerHandler.getPlayerManager().getPlayerProfile(uuid).save(null);
callback.call(true);
return;
}
try {
File file = new File(PracticePlugin.getInstance().getDataFolder() + "/playerdata/" + uuid.toString() + ".yml");
if (!file.exists()) {
callback.call(false);
return;
}
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
yml.set("ratings." + ladder.getName(), rating);
yml.save(file);
callback.call(true);
}
catch (Exception e) {
callback.call(false);
System.out.println("DataAccessor -> Failed method setRating");
System.out.println(" * " + uuid.toString());
System.out.println(" * " + ladder.getName());
System.out.println(" * " + rating);
}
}
示例13: onEnable
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
@Override
public void onEnable()
{
instance = this;
getDataFolder().mkdirs();
cfgFile = new File(getDataFolder(), "cfg.yml");
cfg = YamlConfiguration.loadConfiguration(cfgFile);
setIf("lang", "en");
setIf("bag_small_size", 27);
setIf("bag_big_size", 54);
try
{
cfg.save(cfgFile);
}
catch (IOException e)
{
e.printStackTrace();
}
Translation.initLangFiles();
smallBag = new BagSmall();
bigBag = new BagBig();
craftingBag = new BagCrafting();
enderBag = new BagEnder();
enchantBag = new BagEnchant();
anvilBag = new BagAnvil();
recipesFile = new File(getDataFolder(), "recipes.yml");
recipes = YamlConfiguration.loadConfiguration(recipesFile);
Bukkit.getPluginManager().registerEvents(new CraftListener(), this);
RecipeManager.initRecipes();
CustomRegistry.registerItem(smallBag, this);
CustomRegistry.registerItem(bigBag, this);
CustomRegistry.registerItem(craftingBag, this);
CustomRegistry.registerItem(enderBag, this);
CustomRegistry.registerItem(enchantBag, this);
CustomRegistry.registerItem(anvilBag, this);
CustomRegistry.registerGUI(bagGUI, this);
}
示例14: getKills
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static Integer getKills(String p) {
File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
int kills = pConfig.getInt("Kills");
return Integer.valueOf(kills);
}
示例15: getStone
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public YamlConfiguration getStone() {
return YamlConfiguration.loadConfiguration(fileStone);
}