Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static{
- CLAN_DEFAULTS.put(".type", "hostile");
- CLAN_DEFAULTS.put(".Description", defDescription);
- CLAN_DEFAULTS.put(".users", null);
- }
- // later in the code
- private void loadClanFiles(){
- if(ClansFile.exists()){
- plugin.log.info("[PhantomClans] loading clan files");
- clans = new Configuration(ClansFile);
- clans.load();
- // for each clan in the original list
- for(String m_clans : plugin.getClans() ){
- // for each property in the static list above
- plugin.log.info("Writing for " + m_clans);
- for(String prop : CLAN_DEFAULTS.keySet()){
- plugin.log.info("Writing for " + prop);
- if (clans.getProperty("clans." + m_clans + prop) == null) {
- clans.setProperty("clans." + m_clans + prop, CLAN_DEFAULTS.get("clans." + m_clans + prop));
- }
- }
- }
- } else {
- plugin.log.info("[PhantomClans] creating default clan structures");
- try {
- plugin.getDataFolder().mkdir();
- ClansFile.createNewFile();
- clans = new Configuration(ClansFile);
- // default values TODO: make it so the default list isn't the only one used in the "for each"
- for(String m_clans : plugin.getClans()){
- // for each property in the static list above
- for(String prop : CLAN_DEFAULTS.keySet()){
- // this might be very ugly, but if it works, I like it
- clans.setProperty("clans." + m_clans + prop, CLAN_DEFAULTS.get("clans." + m_clans + prop));
- }
- }
- clans.save();
- } catch (IOException e) {
- plugin.log.warning(e.toString());
- }
- }
- }
Add Comment
Please, Sign In to add comment