public void reloadDefaultLocalizedStrings() { String defaultLanguageFile = "default_lang.yml"; File defaultLocalizedStringsFile = new File(plugin.getDataFolder().getPath() + "/localization/" + defaultLanguageFile); CivLog.warning( "Configuration file:" + defaultLanguageFile + " in use. Updating to disk from Jar."); try { CivSettings.streamResourceToDisk("/localization/" + defaultLanguageFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } defaultLocalizedStrings = YamlConfiguration.loadConfiguration(defaultLocalizedStringsFile); CivLog.info("Loading Configuration file:" + defaultLanguageFile); // read the config.yml into memory YamlConfiguration cfg = new YamlConfiguration(); try { cfg.load(defaultLocalizedStringsFile); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (InvalidConfigurationException e1) { e1.printStackTrace(); } defaultLocalizedStrings.setDefaults(cfg); }
public void reloadLocalizedStrings() { File localizedStringsFile = new File(plugin.getDataFolder().getPath() + "/localization/" + languageFile); if (this.isDefault()) { if (defaultLocalizedStrings == null) { localizedStrings = defaultLocalizedStrings; } return; } else if (!localizedStringsFile.exists()) { CivLog.warning( "Configuration file:" + languageFile + " was missing. You must create this file in plugins/Civcraft/localization/"); CivLog.warning("Using default_lang.yml"); this.setLanguageFile(""); return; } localizedStrings = YamlConfiguration.loadConfiguration(localizedStringsFile); CivLog.info("Loading Configuration file:" + languageFile); // read the config.yml into memory YamlConfiguration cfg = new YamlConfiguration(); try { cfg.load(localizedStringsFile); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (InvalidConfigurationException e1) { e1.printStackTrace(); } localizedStrings.setDefaults(cfg); }
public static void loadConfig( FileConfiguration cfg, ArrayList<ConfigTempleSacrifice> temple_sacrifices) { List<Map<?, ?>> ts_list = cfg.getMapList("temple.sacrifices"); for (Map<?, ?> cl : ts_list) { ConfigTempleSacrifice config_ts = new ConfigTempleSacrifice(); List<?> entitiesList = (List<?>) cl.get("entities"); if (entitiesList != null) { ArrayList<String> entities = new ArrayList<String>(); for (Object obj : entitiesList) { if (obj instanceof String) { entities.add((String) obj); String split[] = ((String) obj).split(":"); validEntities.add(split[0].toUpperCase()); } } config_ts.entites = entities; } config_ts.reward = (Integer) cl.get("reward"); temple_sacrifices.add(config_ts); } CivLog.info("Loaded " + temple_sacrifices.size() + " temple sacrifices."); }
public static void loadConfig(FileConfiguration cfg, Map<String, ConfigTownUpgrade> upgrades) { upgrades.clear(); List<Map<?, ?>> culture_levels = cfg.getMapList("upgrades"); for (Map<?, ?> level : culture_levels) { ConfigTownUpgrade town_upgrade = new ConfigTownUpgrade(); town_upgrade.id = (String) level.get("id"); town_upgrade.name = (String) level.get("name"); town_upgrade.cost = (Double) level.get("cost"); town_upgrade.action = (String) level.get("action"); town_upgrade.require_upgrade = (String) level.get("require_upgrade"); town_upgrade.require_tech = (String) level.get("require_tech"); town_upgrade.require_structure = (String) level.get("require_structure"); town_upgrade.category = (String) level.get("category"); Integer categoryCount = categories.get(town_upgrade.category); if (categoryCount == null) { categories.put(town_upgrade.category.toLowerCase(), 1); } else { categories.put(town_upgrade.category.toLowerCase(), categoryCount + 1); } upgrades.put(town_upgrade.id, town_upgrade); } CivLog.info("Loaded " + upgrades.size() + " town upgrades."); }
public static void init() throws SQLException { if (!SQL.hasTable(TABLE_NAME)) { String table_create = "CREATE TABLE " + SQL.tb_prefix + TABLE_NAME + " (" + "`id` int(11) unsigned NOT NULL auto_increment," + "`town_id` int(11) unsigned DEFAULT 0," + "`target_id` int(11) unsigned DEFAULT 0," + "`time` long," + "`playerName` mediumtext," + "`missionName` mediumtext," + "`result` mediumtext," + "PRIMARY KEY (`id`)" + ")"; SQL.makeTable(table_create); CivLog.info("Created " + TABLE_NAME + " table"); } else { CivLog.info(TABLE_NAME + " table OK!"); } }
public static void init() throws SQLException { if (!SQL.hasTable(TABLE_NAME)) { String table_create = "CREATE TABLE " + SQL.tb_prefix + TABLE_NAME + " (" + "`id` int(11) unsigned NOT NULL auto_increment," + "`config_id` mediumtext," + "`town_id` int(11)," + "`start_date` long NOT NULL," + "`active` boolean DEFAULT false," + "`component_vars` mediumtext," + "`saved_messages` mediumtext," + "PRIMARY KEY (`id`)" + ")"; SQL.makeTable(table_create); CivLog.info("Created " + TABLE_NAME + " table"); } else { SQL.makeCol("active", "boolean", TABLE_NAME); } }
public static void loadConfig( FileConfiguration cfg, String path, Map<String, ConfigBuildableInfo> structureMap, boolean isWonder) { structureMap.clear(); List<Map<?, ?>> structures = cfg.getMapList(path); for (Map<?, ?> obj : structures) { ConfigBuildableInfo sinfo = new ConfigBuildableInfo(); sinfo.id = (String) obj.get("id"); sinfo.template_base_name = (String) obj.get("template"); sinfo.templateYShift = (Integer) obj.get("template_y_shift"); sinfo.displayName = (String) obj.get("displayName"); sinfo.require_tech = (String) obj.get("require_tech"); sinfo.require_upgrade = (String) obj.get("require_upgrade"); sinfo.require_structure = (String) obj.get("require_structure"); sinfo.check_event = (String) obj.get("check_event"); sinfo.effect_event = (String) obj.get("effect_event"); sinfo.update_event = (String) obj.get("update_event"); sinfo.onBuild_event = (String) obj.get("onBuild_event"); sinfo.limit = (Integer) obj.get("limit"); // TODO handle signs sinfo.cost = (Double) obj.get("cost"); sinfo.upkeep = (Double) obj.get("upkeep"); sinfo.hammer_cost = (Double) obj.get("hammer_cost"); sinfo.max_hitpoints = (Integer) obj.get("max_hitpoints"); sinfo.destroyable = (Boolean) obj.get("destroyable"); sinfo.allow_outside_town = (Boolean) obj.get("allow_outside_town"); sinfo.regenRate = (Integer) obj.get("regen_rate"); sinfo.isWonder = isWonder; sinfo.points = (Integer) obj.get("points"); @SuppressWarnings("unchecked") List<Map<?, ?>> comps = (List<Map<?, ?>>) obj.get("components"); if (comps != null) { for (Map<?, ?> compObj : comps) { HashMap<String, String> compMap = new HashMap<String, String>(); for (Object key : compObj.keySet()) { compMap.put((String) key, (String) compObj.get(key)); } sinfo.components.add(compMap); } } Boolean tileImprovement = (Boolean) obj.get("tile_improvement"); if (tileImprovement != null && tileImprovement == true) { sinfo.tile_improvement = true; } else { sinfo.tile_improvement = false; } Boolean allowDemolish = (Boolean) obj.get("allow_demolish"); if (allowDemolish == null || allowDemolish == true) { sinfo.allow_demolish = true; } else { sinfo.allow_demolish = false; } Boolean strategic = (Boolean) obj.get("strategic"); if (strategic == null || strategic == false) { sinfo.strategic = false; } else { sinfo.strategic = true; } Boolean ignore_floating = (Boolean) obj.get("ignore_floating"); if (ignore_floating != null) { sinfo.ignore_floating = ignore_floating; } Boolean has_template = (Boolean) obj.get("has_template"); if (has_template != null) { sinfo.has_template = has_template; } if (isWonder) { sinfo.strategic = true; } structureMap.put(sinfo.id, sinfo); } CivLog.info("Loaded " + structureMap.size() + " structures."); }