Java 类org.bukkit.configuration.file.YamlConfiguration 实例源码

项目:VanillaPlus    文件:ConfigUtils.java   
public static void copyDefaultNode(YamlConfiguration configFile, Plugin plugin, String path, String nodPath){
    configFile.createSection(nodPath);
    path = fixPath(path);
    InputStream file = plugin.getResource(path.replace(File.separatorChar, '/'));
    if(file!=null){
        YamlConfiguration defaultFile = YamlConfiguration.loadConfiguration(new InputStreamReader(file));
        if(defaultFile.contains(nodPath))
            configFile.set(nodPath, defaultFile.get(path));
        else
            configFile.set(nodPath, Error.MISSING_NODE.getMessage());
    }
    File temp = new File(plugin.getDataFolder(), path);
    try {
        configFile.save(temp);
    } catch (IOException e) {
        e.printStackTrace();
        ErrorLogger.addError("I/O Exception for file : " + temp.getAbsolutePath());
    }
}
项目:CraftyProfessions    文件:ConfigController.java   
/**
 * This method essentially imitates the getConfig method within the JavaPlugin class
 * but is used to create or grab special config files pertaining to the Wage Tables of
 * the plugin
 *
 * @param resource The file or resource to grab the Configuration for.
 *
 * @return The configuration of the resource.
 */
public YamlConfiguration getSpecialConfig (String resource)
{
    YamlConfiguration config = mWageConfigs.get (resource);

    if (config == null)
    {
        InputStream configStream = mPlugin.getResource (resource);
        config = YamlConfiguration.loadConfiguration (mWageFiles.get (resource));

        if (configStream != null)
        {
            config.setDefaults (YamlConfiguration.loadConfiguration (new InputStreamReader (configStream, Charsets.UTF_8)));
        }

        mWageConfigs.put (resource, config);
    }

    return config;
}
项目:AsgardAscension    文件:GodFoodFile.java   
public void createConfig() {
    (new File("plugins" + File.separator + "AsgardAscension" + File.separator
            + "")).mkdirs();
    file = new File("plugins" + File.separator + "AsgardAscension",
            "food.yml");
    config = YamlConfiguration.loadConfiguration(file);
    if(!file.exists()){
        config.options().header("Potion Effect Types: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html");
        config.addDefault("1.name", "Nidhogg�s Heart");
        config.addDefault("1.item", 372);
        config.addDefault("1.amount", 1);
        List<String> effects = new ArrayList<String>();
        effects.add("SPEED, 120, 2");
        config.addDefault("1.effects", effects);
        config.options().copyDefaults(true);
    }
    saveConfig();
}
项目:VanillaPlus    文件:Menu.java   
public Menu(MessageManager messageManager, YamlConfiguration section) {
    ConfigurationSection settings = section.getConfigurationSection(Node.SETTINGS.get());
    if(settings == null){
        Error.MISSING_NODE.add(Node.SETTINGS.get());
        title = new MComponent(VanillaPlusCore.getDefaultLang(), " ");
        icons = new Icon[37];
        type = InventoryType.CHEST;
        refresh = 0;
        return;
    }else{
        title = messageManager.getComponentManager().get(settings.getString(Node.NAME_PATH.get()));
        type = InventoryType.valueOf(settings.getString(Node.TYPE.get(), "CHEST"));
        if(type == InventoryType.CHEST) {
            int size = settings.getInt("ROWS");
            if(size < 0 || size > 12)
                ErrorLogger.addError("ROWS must be between 0 and 12 inclulsive !");
            icons = new Icon[9*size+1];
        }
        else
            icons = new Icon[type.getDefaultSize()+1];
        refresh = (byte) settings.getInt("REFRESH", 0);

    }
}
项目:Minecordbot    文件:ConfigurationBuilder.java   
private static Object build(Class clazz) {
    Object object;

    try {
        object = clazz.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
        Logger.err("Failed to build a configuration - couldn't access the class!");
        return null;
    }

    String name = object.getClass().getDeclaredAnnotation(Configuration.class).value();
    File file = new File(JavaPlugin.getProvidingPlugin(clazz).getDataFolder(), String.format("%s.yml", name));
    FileConfiguration configFile = YamlConfiguration.loadConfiguration(file);

    buildFromConfig(configFile, clazz, object);

    return object;
}
项目:UltimateSpawn    文件:ConfigGGM.java   
public static void loadConfig(Plugin plugin) {
    pl = plugin;

    file = new File(pl.getDataFolder(), "Config/Global/OnJoin/Gamemode-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));
    }
}
项目:MT_Core    文件:PlayerManager.java   
public void savePlayersToDisk() {
    YamlConfiguration config = file.returnYaml();
    if (mtPlayers.isEmpty())
        return;

    for (PlayerObject p : mtPlayers.values()) {
        String uuid = p.getUuid().toString();

        config.set(uuid + ".pk-state", p.getPkState().name());
        config.set(uuid + ".kills", p.getPlayerKills());
        config.set(uuid + ".ingame-name", p.getCurrentIngameName());
        config.set(uuid + ".in-geck-range", p.isPlayerInRangeOfGeck());
        config.set(uuid + ".last-player-kill", p.getLastPlayerKillTime());

        // if (config.get(uuid + ".first-join-time") == null)
        // config.set(uuid + ".first-join-time", p.getJoinTime());
    }
    mtPlayers.clear();
    file.save(config);
}
项目:Uranium    文件:Metrics.java   
public Metrics() throws IOException {
    // load the config
    configurationFile = getConfigFile();
    configuration = YamlConfiguration.loadConfiguration(configurationFile);

    // add some defaults
    configuration.addDefault("opt-out", false);
    configuration.addDefault("guid", UUID.randomUUID().toString());
    configuration.addDefault("debug", false);

    // Do we need to create the file?
    if (configuration.get("guid", null) == null) {
        configuration.options().header("http://mcstats.org").copyDefaults(true);
        configuration.save(configurationFile);
    }

    // Load the guid then
    guid = configuration.getString("guid");
    debug = configuration.getBoolean("debug", false);
}
项目:mczone    文件:Map.java   
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);
}
项目:BlockBall    文件:BungeeCordController.java   
public void add(String server, Location location) {
    final BungeeCordSignInfo info = new BungeeCordSignInfo.Container(location, server);
    this.signs.add(info);
    final BungeeCordSignInfo[] signInfos = this.signs.toArray(new BungeeCordSignInfo[this.signs.size()]);
    this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> {
        try {
            final FileConfiguration configuration = new YamlConfiguration();
            final File file = new File(BungeeCordController.this.plugin.getDataFolder(), "bungeecord_signs.yml");
            if (file.exists()) {
                if (!file.delete()) {
                    Bukkit.getLogger().log(Level.WARNING, "File cannot get deleted.");
                }
            }
            for (int i = 0; i < signInfos.length; i++) {
                configuration.set("signs." + i, signInfos[i].serialize());
            }
            configuration.save(file);
        } catch (final IOException e) {
            Bukkit.getLogger().log(Level.WARNING, "Save sign location.", e);
        }
    });
}
项目:EscapeLag    文件:NetWorker.java   
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) {
        }
    }
}
项目:PetBlocks    文件:PlayerMetaSQLiteControllerIT.java   
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    if (Bukkit.getServer() == null) {
        final Server server = mock(Server.class);
        when(server.getLogger()).thenReturn(Logger.getGlobal());
        Bukkit.setServer(server);
    }
    new File("PetBlocks.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("PetBlocks"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
项目:DungeonGen    文件:Module.java   
/**Static method to get a modules config alone, returns null if failed.
 * The loading is tested during the initial yml test and should therefore work during DunGen runtime.
 * @param parent    The parent plugin
 * @param name      The modules name for witch the config should be loaded (file 'name'.yml)
 * @return          The config object. Returns null if errors occured and sets plugin state to ERROR.
 */
public static YamlConfiguration getConfig(DunGen parent, String name) {
    File confFile = new File(parent.getDataFolder(),name+".yml");
    if (!confFile.exists()) {
        parent.setStateAndNotify(State.ERROR, "Config file for module " + name + " could not be found!");
        return null;
    }

    YamlConfiguration conf = new YamlConfiguration();
    try {
        conf.load(confFile);
    }catch (IOException | InvalidConfigurationException e) {
        parent.setStateAndNotify(State.ERROR, "Loading of config file for module " + name + " failed:");
        e.printStackTrace();
        return null;
    }
    // everything ok, if code reached here.
    parent.getLogger().info("YML file for module " + name + " loaded.");
    return conf;
}
项目:RealSurvival    文件:FireCraftTableRecipe.java   
public boolean save(){
    YamlConfiguration recipe;
     File f=new File(rs.getDataFolder()+File.separator+"SyntheticFormula"+File.separator+"FireCraftTable"+File.separator+name+".yml");
    if(!f.exists())try {f.createNewFile();} catch (IOException e1) {return false;}

    recipe=YamlConfiguration.loadConfiguration(f);
    recipe.set(name+".name", name);
    recipe.set(name+".time", time);
    recipe.set(name+".temperature", temperature);
    recipe.set(name+".maxTime", maxTime);
    recipe.set(name+".shape", shape);
    for(Character c:materials.keySet())
        recipe.set(name+".material."+c,materials.get(c) );
    for(int i=0;i<3;i++)
        recipe.set(name+".product."+i, product[i]);
    try {recipe.save(f);} catch (IOException e) {return false;}
    return true;
}
项目:CaulCrafting    文件:CraftStorage.java   
public void removeCraft(int nb) {
try {
    //replacing in the file
    File craftfile = new File(plugin.getDataFolder(), "crafts.yml");
    craftfile.createNewFile();
    FileConfiguration craftconfig = YamlConfiguration.loadConfiguration(craftfile);
    int count = 0;
    for(String craftuuid : craftconfig.getConfigurationSection("Crafts").getKeys(false)) {
        if(nb == count) {
            craftconfig.set("Crafts." + craftuuid, null);
        }
        count++;
    }
    craftconfig.save(craftfile);
    } catch (Exception e) {
        //
    }
  }
项目:OpenUHC    文件:LobbyModule.java   
@Override
public void onEnable() {
  world = Bukkit.createWorld(new WorldCreator(OpenUHC.WORLD_DIR_PREFIX + "lobby"));
  // Read lobby yml if it exists
  File lobbyFile = new File(OpenUHC.WORLD_DIR_PREFIX + "lobby/lobby.yml");
  if (lobbyFile.exists()) {
    FileConfiguration lobbyConfig = YamlConfiguration.loadConfiguration(lobbyFile);
    ConfigurationSection spawn = lobbyConfig.getConfigurationSection("spawn");
    if (spawn != null) {
      double x = spawn.getDouble("x", 0);
      double y = spawn.getDouble("y", 64);
      double z = spawn.getDouble("z", 0);
      double r = spawn.getDouble("r", 1);
      this.spawn = new Vector(x, y, z);
      radius = (float) r;
    }
  }
  OpenUHC.registerEvents(this);
}
项目:MT_Core    文件:GeneratorListener.java   
public void loadFile() {
    file = new PluginFile(main, "generators", FileType.YAML);
    for (World w : Bukkit.getWorlds()) {
        powerable.put(w.getName(), new ManyMap<>());
        generators.put(w.getName(), new ManyMap<>());
    }

    YamlConfiguration config = file.returnYaml();

    for (String locString : config.getStringList("gens")) {
        Location loc = StringUtilities.stringToLocation(locString);

        ManyMap<String, Location> mm = generators.get(loc.getWorld().getName());
        mm.addValue(loc.getChunk().getX() + ";" + loc.getChunk().getZ(), loc);
        generators.put(loc.getWorld().getName(), mm);

        for (Block bloc : getNearbyBlocks(loc.getBlock(), 15)) {
            Location ploc = bloc.getLocation();
            ManyMap<String, Location> pmm = powerable.get(ploc.getWorld().getName());
            pmm.addValue(ploc.getChunk().getX() + ";" + ploc.getChunk().getZ(), ploc);
            powerable.put(ploc.getWorld().getName(), pmm);
        }
    }

}
项目:PlayerStevesBattleGrounds    文件:PlayerStevesBattleGrounds.java   
@Override
public void onEnable() {
    saveResource("lang.yml", false);
    saveResource("config.yml", false);

    Lang.lang = YamlConfiguration.loadConfiguration(new java.io.File(getDataFolder(), "lang.yml"));
    config = YamlConfiguration.loadConfiguration(new java.io.File(getDataFolder(), "config.yml"));

    waitTimer.init();

    getServer().getPluginManager().registerEvents(new StaticWorldListener(this), this);
    getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
    getServer().getPluginManager().registerEvents(waitTimer, this);

    waitTimer.startTiming();
}
项目:SkyWarsReloaded    文件:GameController.java   
public void signJoinLoad() {
     File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");

     if (!signJoinFile.exists()) {
         SkyWarsReloaded.get().saveResource("signJoinGames.yml", false);
     }

     if (signJoinFile.exists()) {
         FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
         try {
             for (String gameNumber : storage.getConfigurationSection("games.").getKeys(false)) {
                 String mapName = storage.getString("games." + gameNumber + ".map");
                 String world = storage.getString("games." + gameNumber + ".world");
                 if (mapName != null && world != null) {
                     GameSign gs = new GameSign(storage.getInt("games." + gameNumber + ".x"), storage.getInt("games." + gameNumber + ".y"), storage.getInt("games." + gameNumber + ".z"), world, mapName);
                     signJoinGames.put(Integer.valueOf(gameNumber), gs);
                     createGame(Integer.valueOf(gameNumber), gs);
                 }
             }
         } catch (NullPointerException e) {
         }
     }
}
项目:MT_Communication    文件:PlayerManager.java   
public void savePlayersToDisk() {
        YamlConfiguration config = file.returnYaml();

        for (PlayerObject p : players.values()) {
            String uuid = p.getUuid().toString();
            config.set(uuid + ".current-cellphone-recipient", p.getCurrentCellPhoneRecipient());
//          config.set(uuid + ".walkie-talkie.current-channel", p.getCurrentWalkieTalkieFrequency().getChannel());
//          config.set(uuid + ".walkie-talkie.current-frequency", p.getCurrentWalkieTalkieFrequency().getFrequency());
            config.set(uuid + ".notification-sound", p.receiveNotificationSound());
            config.set(uuid + ".contacts", p.getContacts());
        }

        players.clear();
        file.save(config);
    }
项目:MT_Communication    文件:TextMessageManager.java   
public void saveMessagessToDisk() {
    YamlConfiguration config = file.returnYaml();
    List<String> messageStrings = new ArrayList<>();

    for (TextMessage m : textMessages) {
        messageStrings.add(m.getConfigFormat());
    }

    config.set("messages", messageStrings);

    file.save(config);
}
项目:mczone    文件:Map.java   
public static void load() {
      list.clear();
      File maps = new File(SurvivalGames.getInstance().getDataFolder(), "maps");
      for (File yml : Files.getFiles(maps)) {
          if (!yml.getName().endsWith(".yml"))
              continue;

          ConfigAPI api = new ConfigAPI(YamlConfiguration.loadConfiguration(yml));
          FileConfiguration config = api.getConfig();
          String title = config.getString("info.title");
          String worldName = config.getString("info.worldName");
          if (title == null || worldName == null) {
              Chat.log(Level.SEVERE, "Error with map file: " + yml.getName() + " (no title and/or world name)");
              continue;
          }
          List<Location> spawns = new ArrayList<Location>();
          for (String s : config.getConfigurationSection("spawns").getKeys(false)) {
            if (api.getString("spawns." + s + ".team") != null && api.getString("spawns." + s + ".team").equals("spec"))
                continue;
            Location l = api.getLocation("spawns." + s);
                spawns.add(l);
          }
          Location specSpawn = api.getLocation("spawns.spec");

          new Map(title, worldName, spawns, specSpawn);
      }

Comparator<Map> comp = new Comparator<Map>() {
    public int compare(Map m1, Map m2) {
        return m1.getTitle().compareTo(m2.getTitle());
    }
};

Collections.sort(list, comp);

      Chat.log("Loaded a total of " + Map.getList().size() + " maps!");
  }
项目:UltimateSpawn    文件:ConfigServer.java   
public static void loadConfig(Plugin plugin) {
    pl = plugin;

    file = new File(pl.getDataFolder(), "Config/Server.yml");
    Config = YamlConfiguration.loadConfiguration(file);

    if (!pl.getDataFolder().exists()) {
        pl.getDataFolder().mkdir();
    }

    create();
}
项目:ViperBot    文件:DDoSManager.java   
public FileConfiguration getConfig(){
    FileConfiguration config = new YamlConfiguration();
    File userFile = new File(mainFolder, "AllowedUsers.yml");
    if(userFile.exists()){
        try {
            config.load(userFile);
        } catch (IOException | InvalidConfigurationException e) {
            e.printStackTrace();
            config.set("Data", allowedUsers);
        }
    }
    return config;      
}
项目:MT_Communication    文件:TextMessageManager.java   
public void saveMessagessToDisk() {
    YamlConfiguration config = file.returnYaml();
    List<String> messageStrings = new ArrayList<>();

    for (TextMessage m : textMessages) {
        messageStrings.add(m.getConfigFormat());
    }

    config.set("messages", messageStrings);

    file.save(config);
}
项目:MT_Communication    文件:TextMessageManager.java   
public void loadMessagesFromDisk() {
    file = new PluginFile("textMessages", FileType.YAML);
    YamlConfiguration config = file.returnYaml();

    for (String s : config.getStringList("messages")) {
        String[] split = s.split("-");

        textMessages.add(new TextMessage(split[0], split[1], split[2]));
    }

}
项目:SkyWarsReloaded    文件:SignListener.java   
@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");
                        }
                    }
                    } 
             }
           }
}
  }
项目:uppercore    文件:ScriptManager.java   
public void reloadConfig(File configFile) {
    extensionsToEngineName = new HashMap<>();

    FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
    ConfigurationSection section = config.getConfigurationSection("engines");
    for (Map.Entry<String, Object> obj : section.getValues(false).entrySet())
        extensionsToEngineName.put(obj.getKey(), obj.getValue().toString());
}
项目:SkyWarsReloaded    文件:ParticleController.java   
public void load() {
    particleMap.clear();
    File particleFile = new File(SkyWarsReloaded.get().getDataFolder(), "particleeffects.yml");

    if (!particleFile.exists()) {
        SkyWarsReloaded.get().saveResource("particleeffects.yml", false);
    }

    if (particleFile.exists()) {
        FileConfiguration storage = YamlConfiguration.loadConfiguration(particleFile);

        if (storage.contains("effects")) {
            for (String item : storage.getStringList("effects")) {
                List<String> itemData = new LinkedList<String>(Arrays.asList(item.split(" ")));

                int cost = Integer.parseInt(itemData.get(1));

                String effect = itemData.get(0).toLowerCase();
                String name = null;

                if (effects.contains(effect)) {
                    name = new Messaging.MessageFormatter().format("effects." + effect);
                }

                if (name != null) {
                    particleMap.put(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', name)), new ParticleItem(effect, name, cost));
                }
            }
        }
    }
}
项目:Peach    文件:FriendlyConfiguration.java   
/**
 * @param source original {@link YamlConfiguration} file.
 * @throws NullPointerException if source is null.
 */
public FriendlyConfiguration(YamlConfiguration source) {
    if (source == null) {
        throw new NullPointerException("yaml cannot be null!");
    }

    this.source = source;
}
项目:OnlineChecker-Spigot-SQL-Support    文件:UtilFile.java   
public UtilFile(String dataFolder, String fileName) {
    this.dataFolder = dataFolder;
    this.name = fileName;

    file = new File(dataFolder, fileName+".yml");
    data = YamlConfiguration.loadConfiguration(file);
}
项目:PVPAsWantedManager    文件:PVPAsWantedManager.java   
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;

}
项目:mczone    文件:ConfigAPI.java   
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);
 }
项目:DogTags    文件:ConvertCommand.java   
@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    文件:PVPAsWantedManager.java   
@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"));

}
项目:GlobalPrefix    文件:ConfigManager.java   
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;
}
项目:RPGPlus    文件:Datafiles.java   
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) {
        }
}
项目:MT_Core    文件:PlayerManager.java   
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);
        // }
    }

}
项目:RPGPlus    文件:Datafiles.java   
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) {
    }
}
项目:Minecordbot    文件:Config.java   
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);
}