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);
}
}
}
}
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));
}
}
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);
}
}
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;
}
}
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();
}
}
Aggregations