diff --git a/.gitignore b/.gitignore
index 3e757f6..6136bf5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,4 +21,4 @@
hs_err_pid*
.gradle/4.3.1/
.idea
-target
+target
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 7653b83..c21d414 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,12 +72,6 @@
activejdbc
2.0
-
- javax.servlet
- servlet-api
- 2.5
- provided
-
com.h2database
h2
diff --git a/src/main/java/com/ilummc/tlib/inject/TConfigWatcher.java b/src/main/java/com/ilummc/tlib/inject/TConfigWatcher.java
index 34d67b0..c33e1d6 100644
--- a/src/main/java/com/ilummc/tlib/inject/TConfigWatcher.java
+++ b/src/main/java/com/ilummc/tlib/inject/TConfigWatcher.java
@@ -19,7 +19,8 @@ import java.util.function.Consumer;
*/
public class TConfigWatcher {
- private final ScheduledExecutorService service = Executors.newScheduledThreadPool(1, new BasicThreadFactory.Builder().namingPattern("tconfig-watcher-schedule-pool-%d").daemon(true).build());
+ private final ScheduledExecutorService service = Executors.newScheduledThreadPool(1,
+ new BasicThreadFactory.Builder().namingPattern("TConfigWatcherService-%d").build());
private final Map>> map = new HashMap<>();
@@ -54,7 +55,16 @@ public class TConfigWatcher {
public void removeListener(File file) {
synchronized (map) {
- map.entrySet().removeIf(entry -> entry.getValue().getLeft().equals(file));
+ map.entrySet().removeIf(entry -> {
+ if (entry.getValue().getLeft().equals(file)) {
+ try {
+ entry.getKey().close();
+ } catch (IOException ignored) {
+ }
+ return true;
+ }
+ return false;
+ });
}
}
diff --git a/src/main/java/com/ilummc/tlib/resources/TLocaleInstance.java b/src/main/java/com/ilummc/tlib/resources/TLocaleInstance.java
index fe384f8..5664243 100644
--- a/src/main/java/com/ilummc/tlib/resources/TLocaleInstance.java
+++ b/src/main/java/com/ilummc/tlib/resources/TLocaleInstance.java
@@ -24,7 +24,6 @@ class TLocaleInstance {
private final Map> map = new HashMap<>();
private final Plugin plugin;
- private int updateNodes;
TLocaleInstance(Plugin plugin) {
this.plugin = plugin;
@@ -47,10 +46,6 @@ class TLocaleInstance {
return plugin;
}
- public int getUpdateNodes() {
- return updateNodes;
- }
-
public void sendTo(String path, CommandSender sender, String... args) {
try {
map.getOrDefault(path, ImmutableList.of(TLocaleSendable.getEmpty(path))).forEach(sendable -> {
@@ -75,32 +70,34 @@ class TLocaleInstance {
return map.getOrDefault(path, ImmutableList.of(TLocaleSendable.getEmpty(path))).get(0).asStringList(args);
}
- public void load(YamlConfiguration configuration) {
- updateNodes = 0;
- configuration.getKeys(true).forEach(s -> {
- boolean isCover = false;
- Object object = configuration.get(s);
- if (object instanceof TLocaleSendable) {
- isCover = map.put(s, Collections.singletonList((TLocaleSendable) object)) != null;
- } else if (object instanceof List && !((List) object).isEmpty()) {
- isCover = map.put(s, ((List>) object).stream().map(TO_SENDABLE).collect(Collectors.toList())) != null;
- } else if (!(object instanceof ConfigurationSection)) {
- String str = String.valueOf(object);
- isCover = map.put(s, Collections.singletonList(str.length() == 0 ? TLocaleSendable.getEmpty() : TLocaleText.of(str))) != null;
- }
- if (isCover) {
- updateNodes++;
- }
- });
- }
-
private static final Function