Eclipse Compiler

This commit is contained in:
Izzel_Aliz
2018-05-13 22:42:02 +08:00
parent 23643d7333
commit 4a60cb75de
12 changed files with 44 additions and 415 deletions

View File

@@ -25,17 +25,21 @@ public class TConfigWatcher {
private final Map<WatchService, Triple<File, Object, Consumer<Object>>> map = new HashMap<>();
public TConfigWatcher() {
service.scheduleAtFixedRate(() -> map.forEach((service, triple) -> {
WatchKey key;
while ((key = service.poll()) != null) {
for (WatchEvent<?> watchEvent : key.pollEvents()) {
if (triple.getLeft().getName().equals(Objects.toString(watchEvent.context()))) {
triple.getRight().accept(triple.getMiddle());
service.scheduleAtFixedRate(() -> {
synchronized (map) {
map.forEach((service, triple) -> {
WatchKey key;
while ((key = service.poll()) != null) {
for (WatchEvent<?> watchEvent : key.pollEvents()) {
if (triple.getLeft().getName().equals(Objects.toString(watchEvent.context()))) {
triple.getRight().accept(triple.getMiddle());
}
}
key.reset();
}
}
key.reset();
});
}
}), 1000, 100, TimeUnit.MILLISECONDS);
}, 1000, 100, TimeUnit.MILLISECONDS);
}
public void addOnListen(File file, Object obj, Consumer<Object> consumer) {

View File

@@ -162,15 +162,19 @@ public class TLocaleLoader {
private static int compareAndSet(Map<String, Object> origin, Map<String, Object> current, File file) {
int i = compareMaps(origin, current);
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setAllowUnicode(false);
Yaml yaml = new Yaml(options);
String dump = yaml.dump(current);
try {
Files.write(dump.getBytes(Charset.forName("utf-8")), file);
} catch (IOException ignored) {
/*
if (i > 0) {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setAllowUnicode(false);
Yaml yaml = new Yaml(options);
String dump = yaml.dump(current);
try {
Files.write(dump.getBytes(Charset.forName("utf-8")), file);
} catch (IOException ignored) {
}
}
*/
return i;
}
@@ -191,7 +195,7 @@ public class TLocaleLoader {
Map<String, Object> currentMap = currentLocaleMap(localeFile);
int update = compareAndSet(originMap, currentMap, localeFile);
TLocaleInstance localeInstance = getLocaleInstance(plugin);
YamlConfiguration localeConfiguration = ConfigUtils.loadYaml(plugin, localeFile);
YamlConfiguration localeConfiguration = (YamlConfiguration) ConfigUtils.mapToConf(currentMap);
localeInstance.load(localeConfiguration);
if (update == 0) {
infoLogger("SUCCESS-LOADING-LANG-NORMAL", plugin.getName(), localeFile.getName().split("\\.")[0], String.valueOf(localeInstance.size()));