Skip to content

Commit 3b960e4

Browse files
authored
Merge pull request Ghost-chu#1534 from Ghost-chu/master
5.0.0.2
2 parents 9313dbb + f0423be commit 3b960e4

File tree

6 files changed

+63
-18
lines changed

6 files changed

+63
-18
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<artifactId>QuickShop</artifactId>
2626

2727
<properties>
28-
<pluginver>5.0.0.1</pluginver>
28+
<pluginver>5.0.0.2</pluginver>
2929
<package>org.maxgamer.quickshop</package>
3030
<developer>Ghost-chu</developer>
3131
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/org/maxgamer/quickshop/QuickShop.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,6 @@ private void updateConfig(int selectedVersion) throws IOException {
19321932
getConfiguration().set("config-version", ++selectedVersion);
19331933
}
19341934
if (selectedVersion == 143) {
1935-
getConfiguration().set("language", null);
19361935
// if (getConfiguration().get("language") == null) {
19371936
// getConfiguration().set("language", "en-US");
19381937
// }
@@ -1943,7 +1942,6 @@ private void updateConfig(int selectedVersion) throws IOException {
19431942
// Updater set it to true because plugin upgrading
19441943
// Default configuration disable it cause probably fresh install
19451944
getConfiguration().getOrDefault("legacy-updater.shop-sign", true);
1946-
getConfiguration().set("language", null);
19471945
getConfiguration().set("config-version", ++selectedVersion);
19481946
}
19491947
if (selectedVersion == 145) {
@@ -1952,6 +1950,12 @@ private void updateConfig(int selectedVersion) throws IOException {
19521950
getConfiguration().set("logger.location", 0);
19531951
getConfiguration().set("config-version", ++selectedVersion);
19541952
}
1953+
if (selectedVersion == 146) {
1954+
// Updater set it to true because plugin upgrading
1955+
// Default configuration disable it cause probably fresh install
1956+
getConfiguration().set("language", null);
1957+
getConfiguration().set("config-version", ++selectedVersion);
1958+
}
19551959
if (getConfiguration().getInt("matcher.work-type") != 0 && GameVersion.get(ReflectFactory.getServerVersion()).name().contains("1_16")) {
19561960
getLogger().warning("You are not using QS Matcher, it may meeting item comparing issue mentioned there: https://hub.spigotmc.org/jira/browse/SPIGOT-5063");
19571961
}

src/main/java/org/maxgamer/quickshop/localization/text/SimpleTextManager.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public SimpleTextManager(QuickShop plugin) {
6666
plugin.getLogger().info("Translation over-the-air platform selected: Crowdin");
6767
this.distribution = new CrowdinOTA(plugin);
6868
load();
69-
7069
}
7170

7271
/**
@@ -83,8 +82,10 @@ private File getOverrideFilesFolder(@NotNull String path) {
8382
File moduleFolder = new File(new File(plugin.getDataFolder(), "overrides"), module);
8483
moduleFolder.mkdirs();
8584
File fileFolder = new File(moduleFolder, file.getName());
86-
fileFolder.mkdirs();
87-
return file;
85+
if (fileFolder.isDirectory())
86+
fileFolder.delete();
87+
// fileFolder.mkdirs();
88+
return moduleFolder;
8889
}
8990

9091
/**
@@ -227,8 +228,9 @@ private JsonConfiguration getDistributionConfiguration(@NotNull String distribut
227228
* @throws InvalidConfigurationException File invalid
228229
*/
229230
private JsonConfiguration getOverrideConfiguration(@NotNull String overrideFile, @NotNull String locale) throws IOException, InvalidConfigurationException {
230-
File localOverrideFile = new File(getOverrideFilesFolder(overrideFile.replace("%locale%", locale)), locale + ".json");
231+
File localOverrideFile = new File(getOverrideFilesFolder(overrideFile.replace("%locale%", locale)), new File(overrideFile.replace("%locale%", locale)).getName());
231232
if (!localOverrideFile.exists()) {
233+
Util.debugLog("Creating locale override file: " + localOverrideFile);
232234
localOverrideFile.getParentFile().mkdirs();
233235
localOverrideFile.createNewFile();
234236
}
@@ -389,14 +391,14 @@ private List<String> postProcess(@NotNull List<String> text) {
389391
public List<String> forLocale(@NotNull String locale) {
390392
JsonConfiguration index = mapping.get(locale);
391393
if (index == null) {
392-
if ("en_us".equals(locale)) {
394+
if (MsgUtil.processGameLanguageCode(plugin.getConfiguration().getOrDefault("game-language", "default")).equals(locale)) {
393395
List<String> str = fallbackLocal();
394396
if (str.isEmpty()) {
395397
return Collections.singletonList("Fallback Missing Language Key: " + path + ", report to QuickShop!");
396398
}
397399
return postProcess(str);
398400
} else {
399-
return forLocale("en_us");
401+
return forLocale(MsgUtil.processGameLanguageCode(plugin.getConfiguration().getOrDefault("game-language", "default")));
400402
}
401403
} else {
402404
List<String> str = index.getStringList(path);
@@ -420,7 +422,7 @@ public List<String> forLocale() {
420422
if (sender instanceof Player) {
421423
return forLocale(((Player) sender).getLocale());
422424
} else {
423-
return forLocale("en_us");
425+
return forLocale(MsgUtil.processGameLanguageCode(plugin.getConfiguration().getOrDefault("game-language", "default")));
424426
}
425427
}
426428

@@ -506,14 +508,14 @@ private String postProcess(@NotNull String text) {
506508
public String forLocale(@NotNull String locale) {
507509
JsonConfiguration index = mapping.get(locale);
508510
if (index == null) {
509-
if ("en_us".equals(locale)) {
511+
if (MsgUtil.processGameLanguageCode(plugin.getConfiguration().getOrDefault("game-language", "default")).equals(locale)) {
510512
String str = fallbackLocal();
511513
if (str == null) {
512514
return "Fallback Missing Language Key: " + path + ", report to QuickShop!";
513515
}
514516
return postProcess(str);
515517
} else {
516-
return forLocale("en_us");
518+
return forLocale(MsgUtil.processGameLanguageCode(plugin.getConfiguration().getOrDefault("game-language", "default")));
517519
}
518520
} else {
519521
String str = index.getString(path);
@@ -535,7 +537,7 @@ public String forLocale() {
535537
if (sender instanceof Player) {
536538
return forLocale(((Player) sender).getLocale());
537539
} else {
538-
return forLocale("en_us");
540+
return forLocale(MsgUtil.processGameLanguageCode(plugin.getConfiguration().getOrDefault("game-language", "default")));
539541
}
540542
}
541543

src/main/java/org/maxgamer/quickshop/localization/text/TextMapper.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* This file is a part of project QuickShop, the name is TextMapper.java
3+
* Copyright (C) PotatoCraft Studio and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License as published by the
7+
* Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
* for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
*/
19+
120
package org.maxgamer.quickshop.localization.text;
221

322
import com.dumptruckman.bukkit.configuration.json.JsonConfiguration;
@@ -7,10 +26,11 @@
726
import java.util.Collections;
827
import java.util.HashMap;
928
import java.util.Map;
29+
import java.util.concurrent.ConcurrentHashMap;
1030

1131
public class TextMapper {
12-
private final Map<String, Map<String, JsonConfiguration>> locale2ContentMapping = new HashMap<>();
13-
private final Map<String, JsonConfiguration> bundledFile2ContentMapping = new HashMap<>();
32+
private final Map<String, Map<String, JsonConfiguration>> locale2ContentMapping = new ConcurrentHashMap<>();
33+
private final Map<String, JsonConfiguration> bundledFile2ContentMapping = new ConcurrentHashMap<>();
1434

1535
/**
1636
* Reset TextMapper

src/main/java/org/maxgamer/quickshop/localization/text/distributions/crowdin/CrowdinOTA.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* This file is a part of project QuickShop, the name is CrowdinOTA.java
3+
* Copyright (C) PotatoCraft Studio and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License as published by the
7+
* Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
* for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*
18+
*/
19+
120
package org.maxgamer.quickshop.localization.text.distributions.crowdin;
221

322
import com.google.common.cache.Cache;
@@ -177,7 +196,8 @@ public String getFile(String fileCrowdinPath, String crowdinLocale, boolean forc
177196
// force flush required OR local cache not exists OR outdated
178197
if (forceFlush || data == null || localeTimestamp != manifest.getTimestamp()) {
179198
String url = CROWDIN_OTA_HOST + "content" + fileCrowdinPath.replace("%locale%", crowdinLocale);
180-
Util.debugLog("Reading data from remote server: " + url);
199+
//Util.debugLog("Reading data from remote server: " + url);
200+
plugin.getLogger().info("Downloading translation " + crowdinLocale + " from: " + url);
181201
try (Response response = HttpUtil.create().getClient().newCall(new Request.Builder().get().url(url).build()).execute()) {
182202
val body = response.body();
183203
if (body == null) {

src/main/resources/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# QuickShop-Reremake Plugin Configuration
22

33
#Do not touch this if you don't know what you're doing!
4-
config-version: 146
4+
config-version: 147
55

66
#This language will used by Item Name, Enchantment Name,
77
#and Potion Effect Name or the text on the shop info sign (nbtapi not installed) and other them related position.
@@ -284,7 +284,6 @@ shop:
284284
#This setting is for multi-currency setups.
285285
#If nothing matches in this list, it falls back to the name of currency itself.
286286
alternate-currency-symbol-list:
287-
- CNY;¥
288287
- USD;$
289288

290289
#This should fix Vault or an economy plugin incorrectly processing the price and returning a "0" result.

0 commit comments

Comments
 (0)