Search in sources :

Example 31 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project Minigames by AddstarMC.

the class ScoreboardData method loadDisplays.

public void loadDisplays(MinigameSave save, Minigame mgm) {
    FileConfiguration con = save.getConfig();
    ConfigurationSection root = con.getConfigurationSection(mgm.getName(false) + ".scoreboards");
    if (root == null) {
        return;
    }
    for (String key : root.getKeys(false)) {
        ConfigurationSection displayConf = root.getConfigurationSection(key);
        ScoreboardDisplay display = ScoreboardDisplay.load(mgm, displayConf);
        if (display != null) {
            addDisplay(display);
        }
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 32 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project Prism-Bukkit by prism.

the class RadiusParameter method defaultTo.

/**
	 * 
	 */
@Override
public void defaultTo(QueryParameters query, CommandSender sender) {
    if (query.getProcessType().equals(PrismProcessType.DELETE))
        return;
    if (sender != null && sender instanceof Player) {
        if (query.allowsNoRadius()) {
        // We'll allow no radius.
        } else {
            final FileConfiguration config = Bukkit.getPluginManager().getPlugin("Prism").getConfig();
            query.setRadius(config.getInt("prism.queries.default-radius"));
            query.addDefaultUsed("r:" + query.getRadius());
        }
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Player(org.bukkit.entity.Player)

Example 33 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project Prism-Bukkit by prism.

the class SinceParameter method defaultTo.

/**
	 * 
	 */
@Override
public void defaultTo(QueryParameters query, CommandSender sender) {
    if (query.getProcessType().equals(PrismProcessType.DELETE))
        return;
    if (!query.getFoundArgs().contains("before") && !query.getFoundArgs().contains("since")) {
        final FileConfiguration config = Bukkit.getPluginManager().getPlugin("Prism").getConfig();
        Long date = DateUtil.translateTimeStringToDate(config.getString("prism.queries.default-time-since"));
        if (date == 0) {
            Prism.log("Error - date range configuration for prism.time-since is not valid");
            date = DateUtil.translateTimeStringToDate("3d");
        }
        query.setSinceTime(date);
        query.addDefaultUsed("t:" + config.getString("prism.queries.default-time-since"));
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration)

Example 34 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project AuthMeReloaded by AuthMe.

the class HelpMessagesConsistencyTest method shouldHaveIdenticalTexts.

@Test
public void shouldHaveIdenticalTexts() {
    // given
    CommandDescription description = getAuthMeRegisterDescription();
    FileConfiguration configuration = YamlConfiguration.loadConfiguration(DEFAULT_MESSAGES_FILE);
    final String path = "commands.authme.register.";
    // when / then
    assertThat(configuration.get(path + "description"), equalTo(description.getDescription()));
    assertThat(configuration.get(path + "detailedDescription"), equalTo(description.getDetailedDescription()));
    assertThat(configuration.get(path + "arg1.label"), equalTo(description.getArguments().get(0).getName()));
    assertThat(configuration.get(path + "arg1.description"), equalTo(description.getArguments().get(0).getDescription()));
    assertThat(configuration.get(path + "arg2.label"), equalTo(description.getArguments().get(1).getName()));
    assertThat(configuration.get(path + "arg2.description"), equalTo(description.getArguments().get(1).getDescription()));
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) CommandDescription(fr.xephi.authme.command.CommandDescription) Test(org.junit.Test)

Example 35 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project AuthMeReloaded by AuthMe.

the class HelpMessagesConsistencyTest method shouldOnlyHaveDescriptionForOneCommand.

/**
     * Since CommandInitializer contains all descriptions for commands in English, the help_en.yml file
     * only contains an entry for one command as to provide an example.
     */
@Test
public void shouldOnlyHaveDescriptionForOneCommand() {
    // given
    FileConfiguration configuration = YamlConfiguration.loadConfiguration(DEFAULT_MESSAGES_FILE);
    // when
    Object commands = configuration.get("commands");
    // then
    assertThat(commands, instanceOf(MemorySection.class));
    assertThat(((MemorySection) commands).getKeys(false), contains("authme"));
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) MemorySection(org.bukkit.configuration.MemorySection) Test(org.junit.Test)

Aggregations

FileConfiguration (org.bukkit.configuration.file.FileConfiguration)36 File (java.io.File)11 IOException (java.io.IOException)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)5 MinigameSave (au.com.mineauz.minigames.MinigameSave)4 HashMap (java.util.HashMap)4 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)4 Map (java.util.Map)3 MemorySection (org.bukkit.configuration.MemorySection)3 Player (org.bukkit.entity.Player)3 RewardsFlag (au.com.mineauz.minigames.config.RewardsFlag)2 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)2 MinigameModule (au.com.mineauz.minigames.minigame.modules.MinigameModule)2 DefaultInfo (de.Keyle.MyPet.api.entity.DefaultInfo)2 MyPetType (de.Keyle.MyPet.api.entity.MyPetType)2 ConfigurationYAML (de.Keyle.MyPet.api.util.configuration.ConfigurationYAML)2 InputStreamReader (java.io.InputStreamReader)2 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)2