java类org.bukkit.configuration.file.YamlConfiguration的实例源码

UtilFile.java 文件源码 项目:OnlineChecker-Spigot-SQL-Support 阅读 23 收藏 0 点赞 0 评论 0
public UtilFile(String dataFolder, String fileName) {
    this.dataFolder = dataFolder;
    this.name = fileName;

    file = new File(dataFolder, fileName+".yml");
    data = YamlConfiguration.loadConfiguration(file);
}
PVPAsWantedManager.java 文件源码 项目:PVPAsWantedManager 阅读 34 收藏 0 点赞 0 评论 0
static public Boolean isPlayerNovice(String player){
    YamlConfiguration PlayerData = onLoadData(player);
    if(PlayerData ==null) return false;
    int protectionValue = Integer.valueOf(onLoadData(player).getString("cumulativeOnlineTime"));
    int noviceProtectionTimes = Integer.valueOf(Config.getConfig("playerNoviceProtection.times").replace("min", "").replace("m",""));
    if(noviceProtectionTimes > protectionValue){
        if(InventoryManager.PVPList.contains(player))return false;
        return true;
    }
    return false;

}
ConfigAPI.java 文件源码 项目:mczone 阅读 29 收藏 0 点赞 0 评论 0
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);
 }
ConvertCommand.java 文件源码 项目:DogTags 阅读 25 收藏 0 点赞 0 评论 0
@Subcommand("DeluxeTags") @CommandCompletion("deluxetags")
public void onCommand(CommandSender sender){
    if(!sender.hasPermission("dogtags.convert")) {sender.sendMessage(TagLang.NO_PERMISSION.get()); return; }

    File f = new File(DogTags.getInstance().getDataFolder().getParentFile().getPath() + File.separator + "DeluxeTags", "config.yml");
    if(!f.exists()) return;

    FileConfiguration fc = YamlConfiguration.loadConfiguration(f);
    FileConfiguration config = YamlConfiguration.loadConfiguration(new File(DogTags.getInstance().getDataFolder(), "config.yml"));

    for(String tags : fc.getConfigurationSection("deluxetags").getKeys(false)){
        String prefix = fc.getString("deluxetags."+tags+".tag");
        String description = fc.getString("deluxetags."+tags+".description");
        if (DogTags.getStorage() == StorageEnum.FLATFILE) {
            config.set("dogtags."+tags+".prefix", prefix);
            config.set("dogtags."+tags+".description", description);
            config.set("dogtags."+tags+".permission", true);
        }else{
            DogTags.getConnection().insertTag(tags, prefix, description, true);
        }
        LogUtil.outputMsg("Converted "+tags+" with prefix "+prefix + " and description "+description);
    }

       // config.save(new File(DogTags.getInstance().getDataFolder(), "config.yml"));
        DogTags.getInstance().handleReload();
    if(sender instanceof Player) sender.sendMessage("§6[§eDogTags§6] §fCheck Console for Information.");
}
PVPAsWantedManager.java 文件源码 项目:PVPAsWantedManager 阅读 27 收藏 0 点赞 0 评论 0
@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"));

}
ConfigManager.java 文件源码 项目:GlobalPrefix 阅读 30 收藏 0 点赞 0 评论 0
public ConfigManager() {
    try {
        config=new YamlConfiguration();
        f=new File(plugin.getDataFolder(),"config.yml");
        if(!f.exists()) {
            plugin.saveResource("config.yml",false);
        }
        config.load(new BufferedReader(new InputStreamReader(new FileInputStream(f), Charsets.UTF_8)));
    } catch(Exception e) {
        e.printStackTrace();
    }
    instance=this;
}
Datafiles.java 文件源码 项目:RPGPlus 阅读 21 收藏 0 点赞 0 评论 0
public void createFile(Player p) {
    File pFileDir = new File(Main.getInstance().getDataFolder(), "Players");
    if (!pFileDir.exists()) {
        pFileDir.mkdir();
    }
    File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.getName().toLowerCase() + ".yml");
    if (!pFile.exists())
        try {
            pFile.createNewFile();
            List<String> combo = new ArrayList<String>();
            List<String> guilds = new ArrayList<String>();
            combo.add(0, "???");
            combo.add(1, "???");
            combo.add(2, "???");
            FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
            pConfig.set("User", p.getName());
            pConfig.set("Class", Default);
            pConfig.set("Race", Default);
            pConfig.set("Guilds", guilds);
            pConfig.set("Kills", Integer.valueOf(0));
            pConfig.set("Deaths", Integer.valueOf(0));

            pConfig.set("Counter", Integer.valueOf(1));
            pConfig.set("Combo", combo);

            // pConfig.set("Reader", Boolean[].class);
            /*
             * pConfig.set("ObservationHakiLevel", Integer.valueOf(0));
             * pConfig.set("ObservationHakiXP", Integer.valueOf(0));
             * pConfig.set("ConquerorsHaki", Boolean.valueOf(false));
             * pConfig.set("ConquerorHakiLevel", Integer.valueOf(0));
             * pConfig.set("ConquerorHakiXP", Integer.valueOf(0));
             */
            pConfig.save(pFile);
        } catch (Exception e) {
        }
}
PlayerManager.java 文件源码 项目:MT_Core 阅读 28 收藏 0 点赞 0 评论 0
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);
        // }
    }

}
Datafiles.java 文件源码 项目:RPGPlus 阅读 35 收藏 0 点赞 0 评论 0
public static void addDeath(String p) {
    File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
    FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
    pConfig.set("Deaths", Integer.valueOf(pConfig.getInt("Deaths") + 1));
    try {
        pConfig.save(pFile);
    } catch (Exception e) {
    }
}
Config.java 文件源码 项目:Minecordbot 阅读 98 收藏 0 点赞 0 评论 0
public Config(InputStream configStream, File configFile, int comments, JavaPlugin plugin) {
    this.comments = comments;
    this.manager = new ConfigManager(plugin);

    this.file = configFile;
    Reader reader = new InputStreamReader(configStream);
    this.config = YamlConfiguration.loadConfiguration(reader);
}


问题


面经


文章

微信
公众号

扫码关注公众号