Search in sources :

Example 26 with FileConfiguration

use of org.bukkit.configuration.file.FileConfiguration in project Denizen-For-Bukkit by DenizenScript.

the class ViewerCommand method reloadViewers.

@EventHandler
public static void reloadViewers(SavesReloadEvent event) {
    for (Viewer viewer : viewers.values()) {
        Bukkit.getScheduler().cancelTask(viewer.getTask());
    }
    viewers.clear();
    FileConfiguration saves = DenizenAPI.getCurrentInstance().getSaves();
    if (saves.contains("Viewers")) {
        for (final String id : saves.getConfigurationSection("Viewers").getKeys(false)) {
            Viewer viewer = new Viewer(id, saves.getString("Viewers." + CoreUtilities.toLowerCase(id) + ".content"), dLocation.valueOf(saves.getString("Viewers." + CoreUtilities.toLowerCase(id) + ".location")));
            viewers.put(id, viewer);
            if (viewer.getContent().startsWith("LOCATION")) {
                int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(DenizenAPI.getCurrentInstance(), new Runnable() {

                    public void run() {
                        Player player = Bukkit.getPlayer(UUID.fromString(viewers.get(id).getContent().split("; ")[1]));
                        if (player == null) {
                            Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[] { "", viewers.get(id).getContent().split("; ")[1], "is offline.", "" });
                        } else {
                            Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[] { String.valueOf((int) player.getLocation().getX()), String.valueOf((int) player.getLocation().getY()), String.valueOf((int) player.getLocation().getZ()), player.getWorld().getName() });
                        }
                    }
                }, 0, 20);
                viewer.setTask(task);
            }
        }
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Player(org.bukkit.entity.Player) net.aufdemrand.denizen.objects.dPlayer(net.aufdemrand.denizen.objects.dPlayer) Sign(org.bukkit.block.Sign) EventHandler(org.bukkit.event.EventHandler)

Example 27 with FileConfiguration

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

the class MessagesFileConsistencyTest method shouldHaveAllMessages.

@Test
public void shouldHaveAllMessages() {
    File file = TestHelper.getJarFile(MESSAGES_FILE);
    FileConfiguration configuration = YamlConfiguration.loadConfiguration(file);
    List<String> errors = new ArrayList<>();
    for (MessageKey messageKey : MessageKey.values()) {
        validateMessage(messageKey, configuration, errors);
    }
    if (!errors.isEmpty()) {
        fail("Validation errors in " + MESSAGES_FILE + ":\n- " + String.join("\n- ", errors));
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 28 with FileConfiguration

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

the class HelpMessageConsistencyTest method shouldHaveRequiredEntries.

@Test
public void shouldHaveRequiredEntries() {
    for (File file : helpFiles) {
        // given
        FileConfiguration configuration = YamlConfiguration.loadConfiguration(file);
        // when / then
        assertHasAllHelpSectionEntries(file.getName(), configuration);
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) File(java.io.File) Test(org.junit.Test)

Example 29 with FileConfiguration

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

the class MinigameData method saveRewardSign.

public void saveRewardSign(String id, boolean save) {
    RewardsFlag reward = rewardSigns.get(id);
    if (rewardSignsSave == null)
        loadRewardSignsFile();
    FileConfiguration cfg = rewardSignsSave.getConfig();
    cfg.set(id, null);
    reward.saveValue("", cfg);
    if (save) {
        rewardSignsSave.saveConfig();
        rewardSignsSave = null;
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) RewardsFlag(au.com.mineauz.minigames.config.RewardsFlag)

Example 30 with FileConfiguration

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

the class MinigamePlayer method saveClaimedRewards.

public void saveClaimedRewards() {
    if (!claimedRewards.isEmpty()) {
        MinigameSave save = new MinigameSave("playerdata/data/" + getUUID().toString());
        FileConfiguration cfg = save.getConfig();
        cfg.set("claims", claimedRewards);
        save.saveConfig();
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration)

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