Skip to content

Commit d62c265

Browse files
committed
Allow storage logs to local file
1 parent 4bf6e93 commit d62c265

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ public class QuickShop extends JavaPlugin implements QuickShopAPI {
256256
@Nullable
257257
private NBTAPI nbtapi = null;
258258

259+
private int loggingLocation = 0;
260+
259261
/**
260262
* Use for mock bukkit
261263
*/
@@ -520,7 +522,15 @@ public boolean loadEcon() {
520522
// }
521523

522524
public void logEvent(@NotNull Object eventObject) {
523-
getDatabaseHelper().insertHistoryRecord(eventObject);
525+
if (this.getLogWatcher() == null) {
526+
return;
527+
}
528+
if (loggingLocation == 0) {
529+
this.getLogWatcher().log(JsonUtil.getGson().toJson(eventObject));
530+
} else {
531+
getDatabaseHelper().insertHistoryRecord(eventObject);
532+
}
533+
524534
}
525535

526536
@Override
@@ -565,6 +575,7 @@ public void reloadConfiguration() {
565575
this.displayItemCheckTicks = this.getConfiguration().getInt("shop.display-items-check-ticks");
566576
this.allowStack = this.getConfiguration().getBoolean("shop.allow-stacks");
567577
this.currency = this.getConfiguration().getString("currency");
578+
this.loggingLocation = this.getConfiguration().getInt("logging.location");
568579
if (StringUtils.isEmpty(this.currency)) {
569580
this.currency = null;
570581
}
@@ -1955,6 +1966,12 @@ private void updateConfig(int selectedVersion) throws IOException {
19551966
getConfiguration().set("language", null);
19561967
getConfiguration().set("config-version", ++selectedVersion);
19571968
}
1969+
if (selectedVersion == 145) {
1970+
// Updater set it to true because plugin upgrading
1971+
// Default configuration disable it cause probably fresh install
1972+
getConfiguration().set("logger.location", 0);
1973+
getConfiguration().set("config-version", ++selectedVersion);
1974+
}
19581975
if (getConfiguration().getInt("matcher.work-type") != 0 && GameVersion.get(ReflectFactory.getServerVersion()).name().contains("1_16")) {
19591976
getLogger().warning("You are not using QS Matcher, it may meeting item comparing issue mentioned there: https://hub.spigotmc.org/jira/browse/SPIGOT-5063");
19601977
}

src/main/resources/config.yml

Lines changed: 5 additions & 1 deletion
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: 145
4+
config-version: 146
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.
@@ -63,6 +63,8 @@ logging:
6363
log-balance: true
6464
#The target size (in MB) to split log files to the "plugins\QuickShop\logs" folder.
6565
file-size: 10.0
66+
#Log data storage location (0 to file, 1 to database)
67+
location: 0
6668
#Some economy plugins cache player balances, this sometimes causes insufficient balance when trying to use a shop
6769
#This workaround uses getBalance to refresh it, but its time costing.
6870
#So ONLY turn this on when you have this problem!
@@ -767,6 +769,8 @@ debug:
767769
legacy-updater:
768770
shop-sign: false
769771

772+
773+
770774
custom-commands:
771775
- shop
772776
- chestshop

0 commit comments

Comments
 (0)