use of dev.frankheijden.insights.api.config.parser.YamlParseException in project Insights by InsightsPlugin.
the class Insights method reloadLimits.
@Override
public void reloadLimits() {
limits = new Limits();
Path limitsPath = getDataFolder().toPath().resolve(LIMITS_FOLDER_NAME);
if (!Files.exists(limitsPath)) {
try {
Files.createDirectory(limitsPath);
IOUtils.copyResources(limitsPath, getClassLoader(), Arrays.asList("bed-limit.yml", "redstone-limit.yml", "tile-limit.yml"));
} catch (IOException ex) {
ex.printStackTrace();
}
}
try (DirectoryStream<Path> stream = Files.newDirectoryStream(limitsPath, p -> !Files.isDirectory(p))) {
for (Path child : stream) {
String fileName = child.getFileName().toString();
if (!fileName.toLowerCase(Locale.ENGLISH).endsWith(".yml"))
continue;
try {
Limit limit = Limit.parse(child.toFile());
getLogger().info("Loaded limit '" + fileName + "'");
limits.addLimit(limit);
} catch (YamlParseException ex) {
getLogger().severe("Limit '" + fileName + "' could not be loaded:");
getLogger().severe(ex.getMessage());
}
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
Aggregations