@Test public void testUpdateConfigurationAllUpdate() throws Exception { whenNew(YamlConfiguration.class).withAnyArguments().thenReturn(mock(YamlConfiguration.class)); when(configuration.isSet(anyString())).thenReturn(false); when(configuration.isSet("general.messaging.reportList")).thenReturn(true); when(configuration.isSet("general.messaging.broadcast")).thenReturn(true); when(configuration.isSet("general.locale")).thenReturn(true); when(configuration.isSet("general.localeAutoDownload")).thenReturn(true); when(configuration.isSet("general.checkForUpdates")).thenReturn(true); when(configuration.isSet("general.checkForDevUpdates")).thenReturn(true); when(configuration.isSet("locale.localeAutoDownload")).thenReturn(true); when(configuration.isSet("locale.keepLocaleBackupFile")).thenReturn(true); when(configuration.isSet("general.reporting.alerts.limitReached")).thenReturn(true); when(configuration.isSet("general.reporting.alerts.allowedToReportAgain")).thenReturn(true); when(configuration.options()).thenReturn(mock(FileConfigurationOptions.class)); assertTrue(ReporterConfigurationUtil.updateConfiguration(configuration)); verify(configuration, atLeastOnce()).set(anyString(), any(Object.class)); }
public void saveConfig() { if (config == null || configFile == null) { return; } try { FileConfigurationOptions opt = config.options(); opt.header(header); getConfig().save(configFile); } catch (IOException ex) {} }
/** * @author xize * @param creates the configuration, if the configuration already exists we skip this. */ @SuppressWarnings("deprecation") public void createConfiguration() { try { this.f = new File(pl.getDataFolder() + File.separator + "config.yml"); if(f.exists()) { this.con = YamlConfiguration.loadConfiguration(f); ManCo.log(LogType.INFO, "Configuration file found!"); } else { ManCo.log(LogType.INFO, "Configuration file is not found, generating a new one!"); File dir = new File(pl.getDataFolder() + File.separator + "schematics"); if(!dir.isDirectory()) { dir.mkdir(); } con = YamlConfiguration.loadConfiguration(f); FileConfigurationOptions opt = con.options(); opt.header("this plugin has been created by xize."); con.set("crate.dropsPerSchedule", 5); con.set("crate.rareCrateChance", 10); con.set("crate.schedule", 10); con.set("crate.protectChestAgainstOthers", true); con.set("crate.spawnRandom", false); con.set("crate.messages.enable", true); con.set("crate.messages.normalDropMessage", "&2an %crate crate has been dropped close to %p"); con.set("crate.messages.rareDropMessage", "&5a rare crate %crate has been spawned near %p"); ItemStack item1 = new ItemStack(Material.STONE_SWORD, 1); item1.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2); ItemStack item2 = new ItemStack(Material.BREAD, 4); ItemStack item3 = new ItemStack(Material.IRON_SPADE, 1); item3.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 3); List<ItemStack> items = new ArrayList<ItemStack>(); items.add(item1); items.add(item2); items.add(item3); //a reminder for the crate system //the new chest inventory system will work with ItemMeta and enchants //however since its almost impossible to make it good configurable //we decided to mirror fake inventorys which will save and load on inventory open and close. con.set("crates.crate.serie51.isEnabled", true); con.set("crates.crate.serie51.isRare", false); con.set("crates.crate.serie51.rareEffects", false); con.set("crates.crate.serie51.keyEnable", true); con.set("crates.crate.serie51.keyItem", Material.BLAZE_ROD.name()); con.set("crates.crate.serie51.keyPrice", 3.0); con.set("crates.crate.serie51.miniumSlotsFilled", 10); con.set("crates.crate.serie51.items", items.toArray()); ItemStack item4 = new ItemStack(Material.GOLD_SWORD, 1); item2.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 1); ItemStack item5 = new ItemStack(Material.APPLE, 4); ItemStack item6 = new ItemStack(Material.IRON_AXE, 1); item3.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); List<ItemStack> items2 = new ArrayList<ItemStack>(); items2.add(item4); items2.add(item5); items2.add(item6); con.set("crates.crate.serie61.isEnabled", true); con.set("crates.crate.serie61.isRare", true); con.set("crates.crate.serie61.rareEffects", true); con.set("crates.crate.serie61.keyEnable", true); con.set("crates.crate.serie61.keyItem", Material.STICK.getId()); con.set("crates.crate.serie61.keyPrice", 1.0); con.set("crates.crate.serie61.miniumSlotsFilled", 10); con.set("crates.crate.serie61.items", items2.toArray()); con.save(f); } } catch(Exception e) { e.printStackTrace(); } loadCrates(); }
public FileConfigurationOptions options() { return null; }
protected FileConfigurationOptions(MemoryConfiguration configuration) { super(configuration); }
public FileConfigurationOptions copyDefaults(boolean value) { return null; }
public FileConfigurationOptions pathSeparator(char value) { return null; }
public FileConfigurationOptions header(String value) { return null; }
public FileConfigurationOptions copyHeader(boolean value) { return null; }