org.bukkit.configuration.InvalidConfigurationException Java Examples

The following examples show how to use org.bukkit.configuration.InvalidConfigurationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KettleConfig.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static void init(File configFile) {
    CONFIG_FILE = configFile;
    config = new YamlConfiguration();

    try {
        config.load(CONFIG_FILE);
    } catch (IOException ignored) {
    } catch (InvalidConfigurationException ex) {
        Bukkit.getLogger().log(Level.SEVERE, "Could not load kettle.yml, please correct your syntax errors", ex);
        throw Throwables.propagate(ex);
    }

    config.options().header(HEADER);
    config.options().copyDefaults(true);
    verbose = getBoolean("verbose", false);

    commands = new HashMap<>();
    commands.put("kettle", new KettleCommand("kettle"));

    version = getInt("config-version", 1);
    set("config-version", 1);
    readConfig(KettleConfig.class, null);
}
 
Example #2
Source File: ConfigurationManager.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
/**
 * creates a config file in the specified folder
 *
 * @param folder The name of the folder
 * @param file   The name of the file
 */
public static void loadConfig(String folder, String file) {
	File customConfigFile = new File(MineTinker.getPlugin().getDataFolder(), folder + file);
	FileConfiguration fileConfiguration = configs.getOrDefault(file, new YamlConfiguration());

	configsFolder.put(fileConfiguration, customConfigFile);
	configs.put(file, fileConfiguration);

	if (customConfigFile.exists()) {
		try {
			fileConfiguration.load(customConfigFile);
		} catch (IOException | InvalidConfigurationException e) {
			e.printStackTrace();
		}
	}
}
 
Example #3
Source File: CivSettings.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
private static void loadConfigFiles() throws FileNotFoundException, IOException, InvalidConfigurationException {
	townConfig = loadCivConfig("town.yml");
	civConfig = loadCivConfig("civ.yml");
	cultureConfig = loadCivConfig("culture.yml");
	structureConfig = loadCivConfig("structures.yml");
	techsConfig = loadCivConfig("techs.yml");
	goodsConfig = loadCivConfig("goods.yml");
	buffConfig = loadCivConfig("buffs.yml");
	governmentConfig = loadCivConfig("governments.yml");
	warConfig = loadCivConfig("war.yml");
	wonderConfig = loadCivConfig("wonders.yml");
	unitConfig = loadCivConfig("units.yml");
	espionageConfig = loadCivConfig("espionage.yml");
	scoreConfig = loadCivConfig("score.yml");
	perkConfig = loadCivConfig("perks.yml");
	enchantConfig = loadCivConfig("enchantments.yml");
	campConfig = loadCivConfig("camp.yml");
	marketConfig = loadCivConfig("market.yml");
	happinessConfig = loadCivConfig("happiness.yml");
	materialsConfig = loadCivConfig("materials.yml");
	randomEventsConfig = loadCivConfig("randomevents.yml");
	nocheatConfig = loadCivConfig("nocheat.yml");
	arenaConfig = loadCivConfig("arena.yml");
	fishingConfig = loadCivConfig("fishing.yml");
}
 
Example #4
Source File: PluginConfig.java    From ChestCommands with GNU General Public License v3.0 6 votes vote down vote up
public void load() throws IOException, InvalidConfigurationException {

		if (!file.isFile()) {
			if (plugin.getResource(file.getName()) != null) {
				plugin.saveResource(file.getName(), false);
			} else {
				if (file.getParentFile() != null) {
					file.getParentFile().mkdirs();
				}
				file.createNewFile();
			}
		}

		// To reset all the values when loading
		for (String section : this.getKeys(false)) {
			set(section, null);
		}
		load(file);
	}
 
Example #5
Source File: YamlParseTest.java    From NovaGuilds with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testTranslations() throws NullPointerException, InvalidConfigurationException, IOException {
	File langDir = new File(resourcesDirectory, "/lang");

	if(langDir.isDirectory()) {
		File[] list = langDir.listFiles();

		if(list != null) {
			for(File lang : list) {
				try {
					Lang.loadConfiguration(lang);
				}
				catch(NullPointerException e) {
					throw new InvalidConfigurationException("Invalid YAML file (" + lang.getPath() + ")");
				}
			}
		}
	}
	else {
		throw new FileNotFoundException("Lang dir does not exist.");
	}
}
 
Example #6
Source File: CommentedYaml.java    From ScoreboardStats with MIT License 6 votes vote down vote up
/**
 * Gets the YAML file configuration from the disk while loading it
 * explicit with UTF-8. This allows umlauts and other UTF-8 characters
 * for all Bukkit versions.
 * <p>
 * Bukkit add also this feature since
 * https://github.com/Bukkit/Bukkit/commit/24883a61704f78a952e948c429f63c4a2ab39912
 * To be allow the same feature for all Bukkit version, this method was
 * created.
 *
 * @return the loaded file configuration
 */
public FileConfiguration getConfigFromDisk() {
    Path file = dataFolder.resolve(FILE_NAME);

    YamlConfiguration newConf = new YamlConfiguration();
    newConf.setDefaults(getDefaults());
    try {
        //UTF-8 should be available on all java running systems
        List<String> lines = Files.readAllLines(file);
        load(lines, newConf);
    } catch (InvalidConfigurationException | IOException ex) {
        logger.error("Couldn't load the configuration", ex);
    }

    return newConf;
}
 
Example #7
Source File: SpigotConfig.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static void init(File configFile) {
    CONFIG_FILE = configFile;
    config = new YamlConfiguration();
    try {
        config.load(CONFIG_FILE);
    } catch (IOException ignored) {
    } catch (InvalidConfigurationException ex) {
        Bukkit.getLogger().log(Level.SEVERE, "Could not load spigot.yml, please correct your syntax errors", ex);
        throw Throwables.propagate(ex);
    }

    config.options().header(HEADER);
    config.options().copyDefaults(true);

    commands = new HashMap<>();

    version = getInt("config-version", 11);
    set("config-version", 11);
    readConfig(SpigotConfig.class, null);
}
 
Example #8
Source File: FileConfiguration.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Loads this {@link FileConfiguration} from the specified reader.
 * <p>
 * All the values contained within this configuration will be removed,
 * leaving only settings and defaults, and the new values will be loaded
 * from the given stream.
 *
 * @param reader the reader to load from
 * @throws IOException                   thrown when underlying reader throws an IOException
 * @throws InvalidConfigurationException thrown when the reader does not
 *                                       represent a valid Configuration
 * @throws IllegalArgumentException      thrown when reader is null
 */
public void load(Reader reader) throws IOException, InvalidConfigurationException {
    BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);

    StringBuilder builder = new StringBuilder();

    try {
        String line;

        while ((line = input.readLine()) != null) {
            builder.append(line);
            builder.append('\n');
        }
    } finally {
        input.close();
    }

    loadFromString(builder.toString());
}
 
Example #9
Source File: LanguageConfiguration.java    From ShopChest with MIT License 6 votes vote down vote up
@Override
public void load(File file) throws IOException, InvalidConfigurationException {
    this.file = file;

    FileInputStream fis = new FileInputStream(file);
    InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
    BufferedReader br = new BufferedReader(isr);

    StringBuilder sb = new StringBuilder();

    String line = br.readLine();
    while (line != null) {
        sb.append(line);
        sb.append("\n");
        line = br.readLine();
    }

    fis.close();
    isr.close();
    br.close();

    loadFromString(sb.toString());
}
 
Example #10
Source File: HeadDropsModule.java    From UHC with MIT License 6 votes vote down vote up
@Override
public void initialize() throws InvalidConfigurationException {
    if (!config.contains(DROP_CHANCE_KEY)) {
        config.set(DROP_CHANCE_KEY, DEFAULT_DROP_CHANCE);
    }

    if (!config.isDouble(DROP_CHANCE_KEY) && !config.isInt(DROP_CHANCE_KEY)) {
        throw new InvalidConfigurationException(
                "Invalid value at " + config.getCurrentPath() + ".drop chance (" + config.get(DROP_CHANCE_KEY)
        );
    }

    dropRate = config.getDouble(DROP_CHANCE_KEY) / PERCENT_MULTIPLIER;

    super.initialize();
}
 
Example #11
Source File: ModifiedDeathMessagesModule.java    From UHC with MIT License 6 votes vote down vote up
@Override
public void initialize() throws InvalidConfigurationException {
    if (!config.contains(FORMAT_KEY)) {
        config.set(FORMAT_KEY, "&c{{original}} at {{player.world}},{{player.blockCoords}}");
    }

    if (!config.contains(FORMAT_EXPLANATION_KEY)) {
        config.set(FORMAT_EXPLANATION_KEY, "<message> at <coords>");
    }

    final String format = config.getString(FORMAT_KEY);
    formatExplanation = config.getString(FORMAT_EXPLANATION_KEY);

    final MustacheFactory mf = new DefaultMustacheFactory();
    try {
        template = mf.compile(
                new StringReader(ChatColor.translateAlternateColorCodes('&', format)),
                "death-message"
        );
    } catch (Exception ex) {
        throw new InvalidConfigurationException("Error parsing death message template", ex);
    }

    super.initialize();
}
 
Example #12
Source File: NerfQuartzXPModule.java    From UHC with MIT License 6 votes vote down vote up
@Override
public void initialize() throws InvalidConfigurationException {
    if (!config.contains(DROP_COUNT_LOWER_KEY)) {
        config.set(DROP_COUNT_LOWER_KEY, DEFAULT_LOWER_RANGE);
    }

    if (!config.contains(DROP_COUNT_HIGHER_KEY)) {
        config.set(DROP_COUNT_HIGHER_KEY, DEFAULT_HIGHER_RANGE);
    }

    lower = config.getInt(DROP_COUNT_LOWER_KEY);
    higher = config.getInt(DROP_COUNT_HIGHER_KEY);

    Preconditions.checkArgument(lower >= 0, "Min value must be >= 0");
    Preconditions.checkArgument(higher >= 0, "Max value must be >= 0");
    Preconditions.checkArgument(higher >= lower, "Max but be >= min");

    super.initialize();
}
 
Example #13
Source File: CommentYamlConfiguration.java    From QualityArmory with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void load(Reader reader) throws IOException, InvalidConfigurationException {
    StringBuilder builder = new StringBuilder();
 
    String line;
    try (BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader)) {
        int index = 0;
        while ((line = input.readLine()) != null) {
            if (line.startsWith("#") || line.trim().isEmpty()) {
                comments.put(index, line);
            }
            builder.append(line);
            builder.append(System.lineSeparator());
            index++;
        }
    }
    this.loadFromString(builder.toString());
}
 
Example #14
Source File: CommentYamlConfiguration.java    From QualityArmory with GNU General Public License v3.0 6 votes vote down vote up
public static YamlConfiguration loadConfiguration(File file) {
     Validate.notNull(file, "File cannot be null");
     YamlConfiguration config = new CommentYamlConfiguration();
     if(!file.exists())
try {
	file.createNewFile();
} catch (IOException e1) {
	e1.printStackTrace();
}
     try {
         config.load(file);
     } catch (FileNotFoundException e) {
         e.printStackTrace();
     } catch (IOException | InvalidConfigurationException var4) {
         Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, var4);
     }
 
     return config;
 }
 
Example #15
Source File: ExtendedSaturationModule.java    From UHC with MIT License 6 votes vote down vote up
@Override
public void initialize() throws InvalidConfigurationException {
    if (!config.contains(MULTIPLIER_KEY)) {
        config.set(MULTIPLIER_KEY, DEFAULT_MULTIPLIER);
    }

    if (!config.isDouble(MULTIPLIER_KEY) && !config.isInt(MULTIPLIER_KEY)) {
        throw new InvalidConfigurationException(
                "Invalid value at " + config.getCurrentPath() + ".multiplier (" + config.get(MULTIPLIER_KEY) + ")"
        );
    }

    multiplier = config.getDouble(MULTIPLIER_KEY);

    super.initialize();
}
 
Example #16
Source File: Expansion.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
public final void reloadConfig(String fileName) {
    try {
        File dataFolder = getDataFolder();
        File file = new File(dataFolder, fileName);

        File realFile = file.getCanonicalFile();
        String realName = realFile.getName();

        YamlConfiguration config = new YamlConfiguration();
        config.load(realFile);

        InputStream jarStream = getResource(fileName);
        if(jarStream != null) {
            InputStreamReader reader = new InputStreamReader(jarStream, StandardCharsets.UTF_8);
            YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(reader);
            config.setDefaults(defaultConfig);
        }

        fileNameToConfigMap.put(realName, config);
    } catch(IOException | InvalidConfigurationException ex) {
        Logger logger = getLogger();
        logger.log(Level.SEVERE, "An error ocurred while loading a config named '" + fileName + "'.", ex);
    }
}
 
Example #17
Source File: Serialization.java    From Guilds with MIT License 6 votes vote down vote up
/**
 * Deserialize the inventory from JSON
 * @param jsons the JSON string
 * @param title the name of the inventory
 * @return the deserialized string
 * @throws InvalidConfigurationException
 */
public static Inventory deserializeInventory(String jsons, String title, SettingsManager settingsManager) throws InvalidConfigurationException {
    try {
        JsonConfiguration json = new JsonConfiguration();
        json.loadFromString(jsons);

        int size = json.getInt("size", 54);
        title = StringUtils.color(settingsManager.getProperty(GuildVaultSettings.VAULT_NAME));

        Inventory inventory = Bukkit.createInventory(null, size, title);
        Map<String, Object> items = json.getConfigurationSection("items").getValues(false);
        for (Map.Entry<String, Object> item : items.entrySet()) {
            ItemStack itemstack = (ItemStack) item.getValue();
            int idx = Integer.parseInt(item.getKey());
            inventory.setItem(idx, itemstack);
        }
        return inventory;

    } catch (InvalidConfigurationException e) {
        return null;
    }
}
 
Example #18
Source File: ScenarioManager.java    From UhcCore with GNU General Public License v3.0 6 votes vote down vote up
private void loadScenarioOptions(Scenario scenario, ScenarioListener listener) throws ReflectiveOperationException, IOException, InvalidConfigurationException{
    List<Field> optionFields = NMSUtils.getAnnotatedFields(listener.getClass(), Option.class);

    if (optionFields.isEmpty()){
        return;
    }

    YamlFile cfg = FileUtils.saveResourceIfNotAvailable("scenarios.yml");

    for (Field field : optionFields){
        Option option = field.getAnnotation(Option.class);
        String key = option.key().isEmpty() ? field.getName() : option.key();
        Object value = cfg.get(scenario.name().toLowerCase() + "." + key, field.get(listener));
        field.set(listener, value);
    }

    if (cfg.addedDefaultValues()){
        cfg.saveWithComments();
    }
}
 
Example #19
Source File: ScoreboardLayout.java    From UhcCore with GNU General Public License v3.0 6 votes vote down vote up
public void loadFile(){
    YamlFile cfg;

    try{
        cfg = FileUtils.saveResourceIfNotAvailable("scoreboard.yml");
    }catch (InvalidConfigurationException ex){
        ex.printStackTrace();

        // Set default values.
        waiting = new ArrayList<>();
        playing = new ArrayList<>();
        deathmatch = new ArrayList<>();
        spectating = new ArrayList<>();
        title = ChatColor.RED + "Error";
        return;
    }

    waiting = getOpsideDownLines(cfg.getStringList("waiting"));
    playing = getOpsideDownLines(cfg.getStringList("playing"));
    deathmatch = getOpsideDownLines(cfg.getStringList("deathmatch"));
    spectating = getOpsideDownLines(cfg.getStringList("spectating"));
    title = ChatColor.translateAlternateColorCodes('&', cfg.getString("title", ""));
}
 
Example #20
Source File: PetMaster.java    From PetMaster with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Updates configuration file from older plugin versions by adding missing parameters. Upgrades from versions prior
 * to 1.2 are not supported.
 */
private void updateOldConfiguration() {
	updatePerformed = false;

	updateSetting(config, "languageFileName", "lang.yml", "Name of the language file.");
	updateSetting(config, "checkForUpdate", true,
			"Check for update on plugin launch and notify when an OP joins the game.");
	updateSetting(config, "changeOwnerPrice", 0, "Price of the /petm setowner command (requires Vault).");
	updateSetting(config, "displayDog", true, "Take dogs into account.");
	updateSetting(config, "displayCat", true, "Take cats into account.");
	updateSetting(config, "displayHorse", true, "Take horses into account.");
	updateSetting(config, "displayLlama", true, "Take llamas into account.");
	updateSetting(config, "displayParrot", true, "Take parrots into account.");
	updateSetting(config, "actionBarMessage", false,
			"Enable or disable action bar messages when right-clicking on a pet.");
	updateSetting(config, "displayToOwner", false,
			"Enable or disable showing ownership information for a player's own pets.");
	updateSetting(config, "freePetPrice", 0, "Price of the /petm free command (requires Vault).");
	updateSetting(config, "showHealth", true,
			"Show health next to owner in chat and action bar messages (not holograms).");
	updateSetting(config, "disablePlayerDamage", false, "Protect pets to avoid being hurt by other player.");
	updateSetting(config, "enableAngryMobPlayerDamage", true,
			"Allows players to defend themselves against angry tamed mobs (e.g. dogs) even if disablePlayerDamage is true.");

	if (updatePerformed) {
		// Changes in the configuration: save and do a fresh load.
		try {
			config.saveConfiguration();
			config.loadConfiguration();
		} catch (IOException | InvalidConfigurationException e) {
			getLogger().log(Level.SEVERE, "Error while saving changes to the configuration file: ", e);
		}
	}
}
 
Example #21
Source File: CommentedYaml.java    From ScoreboardStats with MIT License 5 votes vote down vote up
private void load(Iterable<String> lines, YamlConfiguration newConf) throws InvalidConfigurationException {
    StringBuilder builder = new StringBuilder();
    for (String line : lines) {
        //remove the silly tab error from yaml
        builder.append(line.replace("\t", "    "));
        //indicates a new line
        builder.append('\n');
    }

    newConf.loadFromString(builder.toString());
}
 
Example #22
Source File: TeamModule.java    From UHC with MIT License 5 votes vote down vote up
@Override
public void initialize() throws InvalidConfigurationException {
    if (!config.contains(REMOVED_COMBOS_KEY)) {
        config.set(REMOVED_COMBOS_KEY, Lists.newArrayList(
                "RESET",
                "STRIKETHROUGH",
                "MAGIC",
                "BLACK",
                "WHITE",
                "=GRAY+ITALIC" // spectator styling in tab
        ));
    }

    Predicate<Prefix> isFiltered;
    try {
        final List<String> removedCombos = config.getStringList(REMOVED_COMBOS_KEY);
        final List<Predicate<Prefix>> temp = Lists.newArrayListWithCapacity(removedCombos.size());

        final PrefixColourPredicateConverter converter = new PrefixColourPredicateConverter();
        for (final String combo : removedCombos) {
            temp.add(converter.convert(combo));
        }

        isFiltered = Predicates.or(temp);
    } catch (Exception ex) {
        ex.printStackTrace();
        plugin.getLogger().severe("Failed to parse filtered team combos, allowing all combos to be used instead");
        isFiltered = Predicates.alwaysFalse();
    }

    setupTeams(Predicates.not(isFiltered));
    this.icon.setLore(messages.evalTemplates("lore", ImmutableMap.of("count", teams.size())));
}
 
Example #23
Source File: LukkitPlugin.java    From Lukkit with MIT License 5 votes vote down vote up
@Override
public void reloadConfig() {
    if (this.pluginConfig != null) {
        try {
            this.config.load(this.dataFolder);
        } catch (IOException | InvalidConfigurationException e) {
            e.printStackTrace();
        }
    }
}
 
Example #24
Source File: YamlStorage.java    From Lukkit with MIT License 5 votes vote down vote up
public YamlStorage(LukkitPlugin plugin, String path) {
    super(plugin, path, Storage.YAML);
    this.yamlConfiguration = new YamlConfiguration();

    try {
        this.yamlConfiguration.load(new FileReader(this.getStorageFile()));
    } catch (IOException | InvalidConfigurationException e) {
        e.printStackTrace();
    }
}
 
Example #25
Source File: ExpansionManager.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private YamlConfiguration getExpansionDescription(JarFile jarFile) throws IllegalStateException, IOException, InvalidConfigurationException {
    JarEntry entry = jarFile.getJarEntry("expansion.yml");
    if(entry == null) {
        String errorMessage = ("Expansion file '" + jarFile.getName() + "' does not contain an expansion.yml file.");
        throw new IllegalStateException(errorMessage);
    }
    
    InputStream inputStream = jarFile.getInputStream(entry);
    InputStreamReader reader = new InputStreamReader(inputStream);
    BufferedReader buffer = new BufferedReader(reader);
    
    YamlConfiguration description = new YamlConfiguration();
    description.load(buffer);
    return description;
}
 
Example #26
Source File: DiscordMC.java    From DiscordMC with GNU General Public License v2.0 5 votes vote down vote up
private static void loadUserFormats() {
    try {
        userFormats.load(userFormatsFile);
    } catch (IOException | InvalidConfigurationException e) {
        e.printStackTrace();
    }
}
 
Example #27
Source File: ConfigurationSerializer.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Deprecated
@Nullable
public static <T extends ConfigurationSerializable> T deserializeCSOld(final String s, final Class<T> c) {
	final YamlConfiguration y = new YamlConfiguration();
	try {
		y.loadFromString(s.replace("\uFEFF", "\n"));
	} catch (final InvalidConfigurationException e) {
		return null;
	}
	final Object o = y.get("value");
	if (!c.isInstance(o))
		return null;
	return (T) o;
}
 
Example #28
Source File: ConfigurationSerializer.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Nullable
public static <T extends ConfigurationSerializable> T deserializeCS(final String s, final Class<T> c) {
	final YamlConfiguration y = new YamlConfiguration();
	try {
		y.loadFromString(s);
	} catch (final InvalidConfigurationException e) {
		return null;
	}
	final Object o = y.get("value");
	if (!c.isInstance(o))
		return null;
	return (T) o;
}
 
Example #29
Source File: PetMaster.java    From PetMaster with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Updates language file from older plugin versions by adding missing parameters. Upgrades from versions prior to
 * 1.2 are not supported.
 */
private void updateOldLanguage() {
	updatePerformed = false;

	updateSetting(lang, "petmaster-command-setowner-hover",
			"You can only change the ownership of your own pets, unless you're admin!");
	updateSetting(lang, "petmaster-command-disable-hover",
			"The plugin will not work until next reload or /petm enable.");
	updateSetting(lang, "petmaster-command-enable-hover",
			"Plugin enabled by default. Use this if you entered /petm disable before!");
	updateSetting(lang, "petmaster-command-reload-hover", "Reload most settings in config.yml and lang.yml files.");
	updateSetting(lang, "petmaster-command-info-hover", "Some extra info about the plugin and its awesome author!");
	updateSetting(lang, "petmaster-tip", "&lHINT&r &8You can &7&n&ohover&r &8or &7&n&oclick&r &8on the commands!");
	updateSetting(lang, "change-owner-price", "You payed: AMOUNT!");
	updateSetting(lang, "petmaster-action-bar", "Pet owned by ");
	updateSetting(lang, "petmaster-command-free", "Free a pet.");
	updateSetting(lang, "petmaster-command-free-hover", "You can only free your own pets, unless you're admin!");
	updateSetting(lang, "pet-freed", "Say goodbye: this pet returned to the wild!");
	updateSetting(lang, "not-enough-money", "You do not have the required amount: AMOUNT!");
	updateSetting(lang, "currently-disabled", "PetMaster is currently disabled, you cannot use this command.");
	updateSetting(lang, "petmaster-health", "Health: ");

	if (updatePerformed) {
		// Changes in the language file: save and do a fresh load.
		try {
			lang.saveConfiguration();
			lang.loadConfiguration();
		} catch (IOException | InvalidConfigurationException e) {
			getLogger().log(Level.SEVERE, "Error while saving changes to the language file: ", e);
		}
	}
}
 
Example #30
Source File: BukkitTranslateContainer.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BukkitTranslateContainer(String key, Plugin plugin, ITranslateContainer fallback) {
	this.key = key;
	this.fallback = fallback;

       InputStream in = plugin.getResource("languages/language_" + key + ".yml");
       if (in != null) {
           try {
               config.load(new InputStreamReader(in, StandardCharsets.UTF_8));
           } catch (IOException | InvalidConfigurationException e) {
               e.printStackTrace();
           }
       }
}