Skip to content

Commit 6b47223

Browse files
Fix a bug for got NPE when eco plugin not installed
1 parent d8a53a4 commit 6b47223

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ public class QuickShop extends JavaPlugin implements QuickShopAPI {
229229
* The economy we hook into for transactions
230230
*/
231231
@Getter
232+
@Nullable
232233
private AbstractEconomy economy;
233234
/**
234235
* Whether or not to limit players shop amounts

src/main/java/org/maxgamer/quickshop/util/economyformatter/EconomyFormatter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.jetbrains.annotations.NotNull;
2525
import org.jetbrains.annotations.Nullable;
2626
import org.maxgamer.quickshop.QuickShop;
27+
import org.maxgamer.quickshop.api.economy.AbstractEconomy;
2728
import org.maxgamer.quickshop.api.shop.Shop;
2829
import org.maxgamer.quickshop.util.MsgUtil;
2930
import org.maxgamer.quickshop.util.Util;
@@ -99,11 +100,12 @@ public String format(double n, boolean internalFormat, @NotNull World world, @Nu
99100

100101
@NotNull
101102
public String format(double n, boolean internalFormat, @NotNull World world, @Nullable String currency) {
102-
if (internalFormat) {
103+
AbstractEconomy economy = QuickShop.getInstance().getEconomy();
104+
if (internalFormat || economy == null) {
103105
return getInternalFormat(n, currency);
104106
}
105107
try {
106-
String formatted = QuickShop.getInstance().getEconomy().format(n, world, currency);
108+
String formatted = economy.format(n, world, currency);
107109
if (StringUtils.isEmpty(formatted)) {
108110
Util.debugLog(
109111
"Use alternate-currency-symbol to formatting, Cause economy plugin returned null");

0 commit comments

Comments
 (0)