mirror of
https://github.com/SimplexDevelopment/ToolAssist.git
synced 2024-12-22 07:57:37 +00:00
Removed Configuration Validator
Configuration validator was not working correctly, so it was removed until a working implementation can be provided.
This commit is contained in:
parent
805f765434
commit
813b710220
Binary file not shown.
@ -6,11 +6,9 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -22,45 +20,17 @@ public class Config extends YamlConfiguration {
|
|||||||
|
|
||||||
public Config(ToolAssist plugin) {
|
public Config(ToolAssist plugin) {
|
||||||
this.settings = new Settings(this);
|
this.settings = new Settings(this);
|
||||||
|
|
||||||
String fileName = "config.yml";
|
String fileName = "config.yml";
|
||||||
|
|
||||||
File dataFolder = plugin.getDataFolder();
|
File dataFolder = plugin.getDataFolder();
|
||||||
|
|
||||||
if (!dataFolder.exists()) dataFolder.mkdirs();
|
if (!dataFolder.exists()) dataFolder.mkdirs();
|
||||||
|
|
||||||
cf = new File(dataFolder, fileName);
|
cf = new File(dataFolder, fileName);
|
||||||
|
try {
|
||||||
InputStream stream = plugin.getResource(fileName);
|
if (cf.createNewFile()) {
|
||||||
assert stream != null;
|
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
|
|
||||||
if (!cf.exists()) {
|
|
||||||
cf.createNewFile();
|
|
||||||
plugin.saveResource(fileName, true);
|
plugin.saveResource(fileName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
oload();
|
|
||||||
|
|
||||||
reader.lines().filter(s -> s.contains(":"))
|
|
||||||
.map(s -> s.split(":")[0])
|
|
||||||
.filter(s -> !super.getValues(true).containsKey(s))
|
|
||||||
.forEach(s -> {
|
|
||||||
plugin.getLogger().severe("Configuration is missing an entry, attempting to replace...");
|
|
||||||
Optional<String> stringStream = reader.lines().filter(c -> c.contains(s)).findFirst();
|
|
||||||
if (stringStream.isEmpty())
|
|
||||||
throw new RuntimeException("Unable to fix your configuration file. Please delete the config.yml in the data folder and restart your server.");
|
|
||||||
String key = stringStream.get().split(":")[0].trim();
|
|
||||||
String value = stringStream.get().split(":")[1].trim();
|
|
||||||
super.addDefault(key, value);
|
|
||||||
osave();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
plugin.getLogger().severe(ex.getMessage());
|
plugin.getLogger().severe(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
oload();
|
oload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user