Replace java File API with the newer NIO API
This commit is contained in:
parent
4ae4cb9f41
commit
f473188f1d
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
|||
|
||||
<name>ColorConsole</name>
|
||||
<version>2.3.3</version>
|
||||
<inceptionYear>2016</inceptionYear>
|
||||
|
||||
<url>https://dev.bukkit.org/bukkit-plugins/colorconsole/</url>
|
||||
<description>
|
||||
Print colorful console messages depending on the logging level
|
||||
|
|
|
@ -70,15 +70,17 @@ public class ColorConsoleBungee extends Plugin {
|
|||
}
|
||||
|
||||
private void saveDefaultConfig() {
|
||||
getDataFolder().mkdir();
|
||||
try {
|
||||
Files.createDirectories(getDataFolder().toPath());
|
||||
|
||||
Path configFile = getDataFolder().toPath().resolve("config.yml");
|
||||
if (Files.notExists(configFile)) {
|
||||
try (InputStream in = getResourceAsStream("config.yml")) {
|
||||
Files.copy(in, configFile);
|
||||
} catch (IOException ioExc) {
|
||||
getLogger().log(Level.SEVERE, "Error saving default config", ioExc);
|
||||
Path configFile = getDataFolder().toPath().resolve("config.yml");
|
||||
if (Files.notExists(configFile)) {
|
||||
try (InputStream in = getResourceAsStream("config.yml")) {
|
||||
Files.copy(in, configFile);
|
||||
}
|
||||
}
|
||||
} catch (IOException ioExc) {
|
||||
getLogger().log(Level.SEVERE, "Error saving default config", ioExc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class CommonFormatter {
|
|||
|
||||
//copied from AnsiEscape in order to provide compatibility with older minecraft versions
|
||||
private static final String CSI = "\u001b[";
|
||||
private static final String SUFFIX = "m";
|
||||
private static final char SUFFIX = 'm';
|
||||
private final String reset = Ansi.ansi().a(Ansi.Attribute.RESET).toString();
|
||||
|
||||
private final Set<String> ignoreMessages;
|
||||
|
|
|
@ -30,10 +30,6 @@ public class ColorConsoleSponge {
|
|||
|
||||
private final Logger logger;
|
||||
|
||||
@Inject
|
||||
@DefaultConfig(sharedRoot = true)
|
||||
private Path configFile;
|
||||
|
||||
@Inject
|
||||
@DefaultConfig(sharedRoot = true)
|
||||
private ConfigurationLoader<CommentedConfigurationNode> configManager;
|
||||
|
@ -55,18 +51,15 @@ public class ColorConsoleSponge {
|
|||
logger.info("Setting up config");
|
||||
|
||||
rootNode = configManager.createEmptyNode();
|
||||
ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder()
|
||||
.setPath(configFile).build();
|
||||
try {
|
||||
configMapper = ObjectMapper
|
||||
.forClass(ColorConsoleConfig.class).bindToNew();
|
||||
configMapper = ObjectMapper.forClass(ColorConsoleConfig.class).bindToNew();
|
||||
|
||||
rootNode = configManager.load();
|
||||
configMapper.populate(rootNode);
|
||||
|
||||
//add and save missing values
|
||||
configMapper.serialize(rootNode);
|
||||
configLoader.save(rootNode);
|
||||
configManager.save(rootNode);
|
||||
} catch (IOException | ObjectMappingException ioEx) {
|
||||
logger.error("Cannot save default config", ioEx);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue