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/TabooLib.iml b/TabooLib.iml
index 88212e0..e1d93e7 100644
--- a/TabooLib.iml
+++ b/TabooLib.iml
@@ -26,7 +26,6 @@
-
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 1a5371a..d1729d6 100644
--- a/src/main/java/com/ilummc/tlib/resources/TLocaleInstance.java
+++ b/src/main/java/com/ilummc/tlib/resources/TLocaleInstance.java
@@ -15,8 +15,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -24,9 +22,8 @@ import java.util.stream.Collectors;
@SuppressWarnings("rawtypes")
class TLocaleInstance {
- private final Map> map = new ConcurrentHashMap<>();
+ private final Map> map = new HashMap<>();
private final Plugin plugin;
- private final AtomicInteger updateNodes = new AtomicInteger();
TLocaleInstance(Plugin plugin) {
this.plugin = plugin;
@@ -49,10 +46,6 @@ class TLocaleInstance {
return plugin;
}
- public int getUpdateNodes() {
- return updateNodes.get();
- }
-
public void sendTo(String path, CommandSender sender, String... args) {
try {
map.getOrDefault(path, ImmutableList.of(TLocaleSerialize.getEmpty(path))).forEach(tSender -> {
@@ -77,34 +70,30 @@ class TLocaleInstance {
return map.getOrDefault(path, ImmutableList.of(TLocaleSerialize.getEmpty(path))).get(0).asStringList(args);
}
+ private static boolean isListString(List list) {
+ for (Object o : list) {
+ if (!(o instanceof String)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public void load(YamlConfiguration configuration) {
- updateNodes.set(0);
configuration.getKeys(true).forEach(s -> {
- boolean isCover = false;
Object object = configuration.get(s);
if (object instanceof TLocaleSerialize) {
- isCover = map.put(s, Collections.singletonList((TLocaleSerialize) object)) != null;
+ map.put(s, Collections.singletonList((TLocaleSerialize) object));
} else if (object instanceof List && !((List) object).isEmpty()) {
- isCover = map.put(s, ((List>) object).stream().map(TO_SERIALIZE).collect(Collectors.toList())) != null;
+ if (isListString((List) object)) {
+ map.put(s, Collections.singletonList(TLocaleText.of(object)));
+ } else {
+ map.put(s, ((List>) object).stream().map(o -> o instanceof TLocaleSerialize ? (TLocaleSerialize) o : TLocaleText.of(String.valueOf(o))).collect(Collectors.toList()));
+ }
} else if (!(object instanceof ConfigurationSection)) {
String str = String.valueOf(object);
- isCover = map.put(s, Collections.singletonList(str.length() == 0 ? TLocaleSerialize.getEmpty() : TLocaleText.of(str))) != null;
- }
- if (isCover) {
- updateNodes.getAndIncrement();
+ map.put(s, Collections.singletonList(str.length() == 0 ? TLocaleSerialize.getEmpty() : TLocaleText.of(str)));
}
});
}
-
- private static final Function