switch to use enhanced logger

This commit is contained in:
Ghost_chu committed 2021-09-03 19:57:19 +08:00
1 parent 850683f544
commit c31da8a875
9 files changed
+44 -54

No files matched your search

@@ -58,7 +58,7 @@ public class ConfigurationFixer {
Object value = plugin.getConfig().get(key);
Object buildInValue = builtInConfig.get(key);
if (value == null || !value.getClass().getTypeName().equals(Objects.requireNonNull(buildInValue).getClass().getTypeName())) {
plugin.getLogger().warning("Fixing configuration use default value: " + key);
plugin.getLogger().warning("Fixing configuration use default value: {0}", key);
plugin.getConfig().set(key, buildInValue);
}
}
@@ -584,7 +584,7 @@ public class QuickShop extends JavaPlugin {
this.integrationHelper.callIntegrationsLoad(IntegrateStage.onLoadAfter);
getLogger().info("QuickShop " + getFork() + " - Early boot step - Booted up...");
getLogger().info("QuickShop {0} - Early boot step - Booted up...", getFork());
}
@Override
@@ -774,10 +774,10 @@ public class QuickShop extends JavaPlugin {
getLogger().info("Reading the configuration...");
this.initConfiguration();
getLogger().info("Developers: " + Util.list2String(this.getDescription().getAuthors()));
getLogger().info("Developers: {0}", Util.list2String(this.getDescription().getAuthors()));
getLogger().info("Original author: Netherfoam, Timtower, KaiNoMood");
getLogger().info("Let's start loading the plugin");
getLogger().info("Chat processor selected: " + this.quickChatType.name());
getLogger().info("Chat processor selected: {0}", this.quickChatType.name());
/* Process Metrics and Sentry error reporter. */
metrics = new Metrics(this, 3320);
@@ -789,7 +789,7 @@ public class QuickShop extends JavaPlugin {
sentryErrorReporter = new RollbarErrorReporter(this);
}
} catch (Throwable th) {
getLogger().warning("Cannot load the Sentry Error Reporter: " + th.getMessage());
getLogger().warning("Cannot load the Sentry Error Reporter: {0}", th.getMessage());
getLogger().warning("Because our error reporter doesn't work, please report this error to developer, thank you!");
}
@@ -852,9 +852,6 @@ public class QuickShop extends JavaPlugin {
limits.put(key, limitCfg.getInt(key));
}
}
if (getConfig().getInt("shop.finding.distance") > 100) {
getLogger().severe("Shop find distance is too high! It may cause lag! Pick a number under 100!");
}
if (getConfig().getBoolean("use-caching")) {
this.shopCache = new Cache(this);
@@ -947,8 +944,8 @@ public class QuickShop extends JavaPlugin {
}
calendarWatcher = new CalendarWatcher(this);
calendarWatcher.start();
Util.debugLog("Now using display-type: " + DisplayItem.getNowUsing().name());
getLogger().info("QuickShop Loaded! " + enableTimer.stopAndGetTimePassed() + " ms.");
Util.debugLog("Now using display-type: {0}", DisplayItem.getNowUsing().name());
getLogger().info("QuickShop Loaded! {0} ms.", enableTimer.stopAndGetTimePassed());
}
private void loadItemMatcher() {
@@ -31,6 +31,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.util.JsonUtil;
import org.maxgamer.quickshop.util.MsgUtil;
import org.maxgamer.quickshop.util.Util;
import java.util.logging.Level;
@@ -146,10 +147,9 @@ public abstract class DisplayItem {
}
//noinspection ConstantConditions
for (String lore : iMeta.getLore()) {
try {
if (!lore.startsWith("{")) {
continue;
}
if (!MsgUtil.isJson(lore)) {
continue;
}
ShopProtectionFlag shopProtectionFlag = gson.fromJson(lore, ShopProtectionFlag.class);
if (shopProtectionFlag == null) {
continue;
@@ -161,9 +161,7 @@ public abstract class DisplayItem {
|| shopProtectionFlag.getShopLocation().equals(attachedShopLocation)) {
return true;
}
} catch (JsonSyntaxException e) {
// Ignore
}
}
return false;
}
@@ -117,7 +117,7 @@ public class ShopLoader {
shopsInDatabase.add(shop);
if (shopNullCheck(shop)) {
if (plugin.getConfig().getBoolean("debug.delete-corrupt-shops", false)) {
plugin.getLogger().warning("Deleting shop " + shop + " caused by corrupted.");
plugin.getLogger().warning("Deleting shop {0} caused by corrupted.", shop);
plugin.getDatabaseHelper().removeShop(origin.getWorld(), origin.getX(), origin.getY(), origin.getZ());
} else {
Util.debugLog("Trouble database loading debug: " + data);
@@ -161,10 +161,10 @@ public class ShopLoader {
+ pendingLoadShops.size()
+ " shops!");
}, 1);
this.plugin.getLogger().info("Scheduled " + pendingLoadShops.size() + " shops to load in next tick, " + loadAfterChunkLoaded
+ " shops will load after chunk have loaded, "
+ loadAfterWorldLoaded
+ " shops will load after the world has loaded.");
this.plugin.getLogger().info("Scheduled {0} shops to load in next tick, " +
"{1} shops will load after chunk have loaded, " +
"{2} shops will load after the world has loaded.",
pendingLoadShops.size(), loadAfterChunkLoaded, loadAfterWorldLoaded);
} catch (Exception e) {
exceptionHandler(e, null);
}
@@ -271,7 +271,7 @@ public class ShopLoader {
logger.warning(" >> Error Trace");
ex.printStackTrace();
logger.warning(" >> Target Location Info");
logger.warning("Location: " + ((shopLocation == null) ? "NULL" : shopLocation.toString()));
logger.warning("Location: {0}" + ((shopLocation == null) ? "NULL" : shopLocation.toString()));
logger.warning(
"Block: " + ((shopLocation == null) ? "NULL" : shopLocation.getBlock().getType().name()));
logger.warning("#######################################");
@@ -317,7 +317,8 @@ public class ShopLoader {
success = true;
} catch (JsonSyntaxException ignore) {
}
plugin.getLogger().info("Processed " + i + "/" + total + " - [" + success + "]");
//plugin.getLogger().info("Processed " + i + "/" + total + " - [" + success + "]");
plugin.getLogger().info("Processed {0}/{1} - [{3}]", i, total, success);
}
}
@@ -240,9 +240,7 @@ public class ShopManager {
}
} else {
plugin.getLogger().warning(
"Sign material "
+ signBlockState.getType().name()
+ " not a WallSign, make sure you using correct sign material.");
"Sign material {0} not a WallSign, make sure you using correct sign material.", signBlockState.getType().name());
}
signBlockState.update(true);
}
@@ -689,8 +687,8 @@ public class ShopManager {
shop.getCurrency()), shop.getLocation().getWorld(), shop.getCurrency())));
} else {
MsgUtil.sendMessage(buyer, "purchase-failed");
plugin.getLogger().severe("EconomyTransaction Failed, last error:" + transaction.getLastError());
QuickShop.getInstance().log("EconomyTransaction Failed, last error:" + transaction.getLastError());
plugin.getLogger().severe("EconomyTransaction Failed, last error: {0}", transaction.getLastError());
QuickShop.getInstance().log("EconomyTransaction Failed, last error: " + transaction.getLastError());
}
return;
}
@@ -754,7 +752,7 @@ public class ShopManager {
}
}
if (tax >= 1.0) {
plugin.getLogger().warning("Disable tax due to is invalid, it should be in 0.0-1.0 (current value is " + tax + ")");
plugin.getLogger().warning("Disable tax due to is invalid, it should be in 0.0-1.0 (current value is {0})", tax);
tax = 0;
}
if (tax < 0) {
@@ -943,8 +941,8 @@ public class ShopManager {
shop.getCurrency())));
} else {
MsgUtil.sendMessage(p, "purchase-failed");
plugin.getLogger().severe("EconomyTransaction Failed, last error:" + economyTransaction.getLastError());
plugin.log("EconomyTransaction Failed, last error:" + economyTransaction.getLastError());
plugin.getLogger().severe("EconomyTransaction Failed, last error: {0}", economyTransaction.getLastError());
plugin.log("EconomyTransaction Failed, last error: " + economyTransaction.getLastError());
}
return;
}
@@ -1053,8 +1051,8 @@ public class ShopManager {
shop.getCurrency())));
} else {
MsgUtil.sendMessage(seller, "purchase-failed");
plugin.getLogger().severe("EconomyTransaction Failed, last error:" + transaction.getLastError());
QuickShop.getInstance().log("EconomyTransaction Failed, last error:" + transaction.getLastError());
plugin.getLogger().severe("EconomyTransaction Failed, last error: ", transaction.getLastError());
QuickShop.getInstance().log("EconomyTransaction Failed, last error: " + transaction.getLastError());
}
return;
}
@@ -1279,7 +1277,7 @@ public class ShopManager {
actionSell(p.getUniqueId(), p.getInventory(), eco, info, shop, amount);
} else {
MsgUtil.sendMessage(p, "shop-purchase-cancelled");
plugin.getLogger().warning("Shop data broken? Loc:" + shop.getLocation());
plugin.getLogger().warning("Shop data broken? Loc: {0}", shop.getLocation());
}
}
@@ -392,9 +392,7 @@ public class MsgUtil {
}
String itemName = gameLanguage.getItem(material);
itemi18n.set("itemi18n." + material.name(), itemName);
plugin
.getLogger()
.info("Found new items/blocks [" + itemName + "] , adding it to the config...");
plugin.getLogger().info("Found new items/blocks [{0}] , adding it to the config...", itemName);
}
try {
itemi18n.save(itemi18nFile);
@@ -427,7 +425,7 @@ public class MsgUtil {
continue;
}
String potionName = gameLanguage.getPotion(potion);
plugin.getLogger().info("Found new potion [" + potionName + "] , adding it to the config...");
plugin.getLogger().info("Found new potion [{0}] , adding it to the config...", potionName);
potioni18n.set("potioni18n." + potion.getName(), potionName);
}
try {
@@ -739,7 +737,7 @@ public class MsgUtil {
String format = plugin.getConfig().getString("decimal-format");
decimalFormat = format == null ? new DecimalFormat() : new DecimalFormat(format);
} catch (Exception e) {
QuickShop.getInstance().getLogger().log(Level.WARNING, "Error when processing decimal format, using system default: " + e.getMessage());
QuickShop.getInstance().getLogger().log(Level.WARNING, "Error when processing decimal format, using system default: {0}", e.getMessage());
decimalFormat = new DecimalFormat();
}
}
@@ -274,11 +274,11 @@ public class Util {
// Try load the itemDataVersion to do some checks.
//noinspection deprecation
if (itemDataVersion > Bukkit.getUnsafe().getDataVersion()) {
Util.debugLog("WARNING: DataVersion not matched with ItemStack: " + config);
Util.debugLog("WARNING: DataVersion not matched with ItemStack: {0}", config);
// okay we need some things to do
if (plugin.getConfig().getBoolean("shop.force-load-downgrade-items.enable")) {
// okay it enabled
Util.debugLog("QuickShop is trying force loading " + config);
Util.debugLog("QuickShop is trying force loading {0}", config);
if (plugin.getConfig().getInt("shop.force-load-downgrade-items.method") == 0) { // Mode 0
//noinspection deprecation
item.put("v", Bukkit.getUnsafe().getDataVersion() - 1);
@@ -289,14 +289,12 @@ public class Util {
// Okay we have hacked the dataVersion, now put it back
root.put("item", item);
config = yaml.dump(root);
Util.debugLog("Updated, we will try load as hacked ItemStack: " + config);
Util.debugLog("Updated, we will try load as hacked ItemStack: {0}", config);
} else {
plugin
.getLogger()
.warning(
"Cannot load ItemStack "
+ config
+ " because it saved from higher Minecraft server version, the action will fail and you will receive a exception, PLELASE DON'T REPORT TO QUICKSHOP!");
"Cannot load ItemStack {0} because it saved from higher Minecraft server version, the action will fail and you will receive a exception, PLELASE DON'T REPORT TO QUICKSHOP!", config);
plugin
.getLogger()
.warning(
@@ -344,7 +342,7 @@ public class Util {
final int codeLine = stackTraceElement.getLineNumber();
for (String log : logs) {
debugLogs.add("[DEBUG] [" + className + "] [" + methodName + "] (" + codeLine + ") " + log);
QuickShop.getInstance().getLogger().info("[DEBUG] [" + className + "] [" + methodName + "] (" + codeLine + ") " + log);
QuickShop.getInstance().getLogger().info("[DEBUG] [{0}] [{1}] ({2}) {3}", className, methodName, codeLine, log);
}
lock.writeLock().unlock();
}
@@ -650,12 +648,12 @@ public class Util {
try {
Material mat = Material.matchMaterial(sp[0]);
if (mat == null) {
plugin.getLogger().warning("Material " + sp[0] + " in config.yml can't match with a valid Materials, check your config.yml!");
plugin.getLogger().warning("Material {0} in config.yml can't match with a valid Materials, check your config.yml!", sp[0]);
continue;
}
restrictedPrices.put(mat, new SimpleEntry<>(Double.valueOf(sp[1]), Double.valueOf(sp[2])));
} catch (Exception e) {
plugin.getLogger().warning("Invalid price restricted material: " + s);
plugin.getLogger().warning("Invalid price restricted material: {0}", s);
}
}
}
@@ -670,7 +668,7 @@ public class Util {
}
Material mat = Material.matchMaterial(data[0]);
if (mat == null || mat == Material.AIR) {
plugin.getLogger().warning(material + " not a valid material type in custom-item-stacksize section.");
plugin.getLogger().warning("{0} not a valid material type in custom-item-stacksize section.", material);
continue;
}
customStackSize.put(mat, Integer.parseInt(data[1]));
@@ -692,7 +690,7 @@ public class Util {
symbols.forEach(entry -> {
String[] splits = entry.split(";", 2);
if (splits.length < 2) {
plugin.getLogger().warning("Invalid entry in alternate-currency-symbol-list: " + entry);
plugin.getLogger().warning("Invalid entry in alternate-currency-symbol-list: {0}", entry);
}
currency2Symbol.put(splits[0], splits[1]);
});
@@ -155,8 +155,8 @@ public class RollbarErrorReporter {
.warning(
"A exception was thrown, QuickShop already caught this exception and reported it. This error will only shown once before next restart.");
plugin.getLogger().warning("====QuickShop Error Report BEGIN===");
plugin.getLogger().warning("Description: " + throwable.getMessage());
plugin.getLogger().warning("Server ID: " + plugin.getServerUniqueID());
plugin.getLogger().warning("Description: {0}", throwable.getMessage());
plugin.getLogger().warning("Server ID: {0}", plugin.getServerUniqueID());
plugin.getLogger().warning("Exception : ");
ignoreThrows();
throwable.printStackTrace();
@@ -58,7 +58,7 @@ public class UpdateWatcher implements Listener {
QuickShop.getInstance()
.getLogger()
.info(
"A new version of QuickShop has been released! [" + updater.getRemoteServerVersion() + "]");
"A new version of QuickShop has been released! [{0}]", updater.getRemoteServerVersion());
QuickShop.getInstance()
.getLogger()
.info("Update here: https://www.spigotmc.org/resources/62575/");