Skip to content

Commit

Permalink
Fix some bug that make i18n and confige manager not work.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gk0Wk committed Feb 23, 2021
1 parent a340b05 commit ac04bf1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 20 deletions.
2 changes: 0 additions & 2 deletions NewNanKits.iml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains:annotations:20.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.mojang:authlib:1.5.21" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" />
Expand Down
9 changes: 1 addition & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>city.newnan</groupId>
<artifactId>NewNanKits</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>
<name>NewNanKits</name>
<url>https://www.newnan.city</url>
Expand Down Expand Up @@ -34,13 +34,6 @@
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<!--https://hub.spigotmc.org/nexus/#welcome-->
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/city/newnan/api/config/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public ConfigurationNode get(String configFile) throws IOException, UnknownConfi
}

protected static ConfigFileType getType(String filePath) {
String[] splits = ".".split(filePath);
String[] splits = filePath.split("\\.");
switch (splits[splits.length - 1].toUpperCase()) {
case "YML":
case "YAML":
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/city/newnan/api/i18n/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Language(File languageFile, Locale language) throws IOException, ConfigMa
public Locale getLanguage() {return language;}

public void reload() throws IOException, ConfigManager.UnknownConfigFileFormatException {
String[] splits = ".".split(languageFile.getPath());
String[] splits = languageFile.getPath().split("\\.");
switch (splits[splits.length - 1].toUpperCase()) {
case "YML":
case "YAML":
Expand All @@ -45,7 +45,7 @@ public void reload() throws IOException, ConfigManager.UnknownConfigFileFormatEx
public String getNodeString(String path) {
String str = pathCache.get(path);
if (str == null) {
str = languageRoot.getNode((Object) ".".split(path)).getString();
str = languageRoot.getNode((Object[]) path.split("\\.")).getString();
pathCache.put(path, str);
}
return str;
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/city/newnan/api/i18n/LanguageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ public LanguageManager register(Locale locale, String filePath) throws FileNotFo
if (file.exists() || file.isFile()) {
Language language = new Language(file, locale);
languageMap.put(locale, language);
if (majorLanguage == null) {
majorLanguage = language;
}
else if (fallbackLanguage == null) {
fallbackLanguage = language;
}
} else {
throw new FileNotFoundException(filePath);
}
Expand Down Expand Up @@ -85,7 +79,7 @@ public LanguageManager reloadAll() {
return this;
}

private static final Pattern pattern = Pattern.compile("[$]([^$]+?)[$]");
private static final Pattern pattern = Pattern.compile("[$][^$]+[$]");

@Override
public String provideLanguage(String rawText) {
Expand Down

0 comments on commit ac04bf1

Please sign in to comment.