Skip to content

Commit 64f54fb

Browse files
committed
1 parent cda3b09 commit 64f54fb

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

src/main/java/org/maxgamer/quickshop/listener/PlayerListener.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,23 @@ private void postTrade(PlayerInteractEvent e) {
196196
final double money = plugin.getEconomy().getBalance(p.getUniqueId(), shop.getLocation().getWorld(), shop.getCurrency());
197197
final Inventory playerInventory = p.getInventory();
198198
if (shop.isSelling()) {
199+
if (shop.getRemainingStock() == 0) {
200+
plugin.text().of(p, "purchase-out-of-stock", shop.ownerName()).send();
201+
return;
202+
}
203+
199204
int itemAmount = getPlayerCanBuy(shop, money, price, playerInventory);
200205
if (shop.isStackingShop()) {
201206
plugin.text().of(p, "how-many-buy-stack", Integer.toString(shop.getItem().getAmount()), Integer.toString(itemAmount)).send();
202207
} else {
203208
plugin.text().of(p, "how-many-buy", Integer.toString(itemAmount)).send();
204209
}
205210
} else {
211+
if (shop.getRemainingSpace() == 0) {
212+
plugin.text().of(p, "purchase-out-of-space", shop.ownerName()).send();
213+
return;
214+
}
215+
206216
int items = getPlayerCanSell(shop, money, price, playerInventory);
207217
if (shop.isStackingShop()) {
208218
plugin.text().of(p, "how-many-sell-stack", Integer.toString(shop.getItem().getAmount()), Integer.toString(items)).send();

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ private List<String> postProcess(@NotNull List<String> text) {
395395
public List<String> forLocale(@NotNull String locale) {
396396
JsonConfiguration index = mapping.get(locale);
397397
if (index == null) {
398+
Util.debugLog("Fallback " + locale + " to default game-language locale caused by QuickShop doesn't support this locale");
398399
if (MsgUtil.processGameLanguageCode(plugin.getConfiguration().getOrDefault("game-language", "default")).equals(locale)) {
399400
List<String> str = fallbackLocal();
400401
if (str.isEmpty()) {
@@ -407,12 +408,15 @@ public List<String> forLocale(@NotNull String locale) {
407408
} else {
408409
List<String> str = index.getStringList(path);
409410
if (str.isEmpty()) {
410-
return Collections.singletonList("Missing Language Key: " + path);
411-
} else {
412-
return postProcess(str);
411+
// Fallback
412+
Util.debugLog("Fallback " + path + " to bundle translation caused OTA & User's override file doesn't contains this key");
413+
str = fallbackLocal();
414+
if (str.isEmpty()) {
415+
return Collections.singletonList("Fallback Missing Language Key: " + path + ", report to QuickShop!");
416+
}
413417
}
418+
return postProcess(str);
414419
}
415-
416420
}
417421

418422
/**
@@ -512,6 +516,7 @@ private String postProcess(@NotNull String text) {
512516
public String forLocale(@NotNull String locale) {
513517
JsonConfiguration index = mapping.get(locale);
514518
if (index == null) {
519+
Util.debugLog("Fallback " + locale + " to default game-language locale caused by QuickShop doesn't support this locale");
515520
if (MsgUtil.processGameLanguageCode(plugin.getConfiguration().getOrDefault("game-language", "default")).equals(locale)) {
516521
String str = fallbackLocal();
517522
if (str == null) {
@@ -524,7 +529,12 @@ public String forLocale(@NotNull String locale) {
524529
} else {
525530
String str = index.getString(path);
526531
if (str == null) {
527-
return "Missing Language Key: " + path;
532+
// Fallback
533+
Util.debugLog("Fallback " + path + " to bundle translation caused OTA & User's override file doesn't contains this key");
534+
str = fallbackLocal();
535+
if (str == null) {
536+
return "Fallback Missing Language Key: " + path + ", report to QuickShop!";
537+
}
528538
}
529539
return postProcess(str);
530540
}

src/main/resources/lang/messages.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,5 +345,7 @@
345345
"taxaccount-invalid": "&cTarget account not invalid, please enter a valid player name or uuid(with dashes).",
346346
"display-turn-on": "&aSuccessfully turn on the shop display.",
347347
"display-turn-off": "&aSuccessfully turn off the shop display.",
348-
"shop-purged-start": "&aShop purge started, check the console for details."
348+
"shop-purged-start": "&aShop purge started, check the console for details.",
349+
"purchase-out-of-stock": "&cThis shop run out of the stock, Contact shop owner or staffs to refill the stock.",
350+
"purchase-out-of-space": "&cThis shop run out of the space, Contact shop owner or staffs to empty the shop."
349351
}

0 commit comments

Comments
 (0)