refactor: replace concatenation log with parameterized

This commit is contained in:
Breno A. 2024-06-09 09:35:38 -03:00
parent 77e246213f
commit 6e7418a89d
34 changed files with 120 additions and 221 deletions

View File

@ -312,7 +312,7 @@ public final class Grasscutter {
public static void updateDayOfWeek() { public static void updateDayOfWeek() {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
Grasscutter.currentDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); Grasscutter.currentDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
logger.debug("Set day of week to " + currentDayOfWeek); logger.debug("Set day of week to {}", currentDayOfWeek);
} }
public static void startConsole() { public static void startConsole() {

View File

@ -53,7 +53,7 @@ public final class CommandMap {
* @return Instance chaining. * @return Instance chaining.
*/ */
public CommandMap registerCommand(String label, CommandHandler command) { public CommandMap registerCommand(String label, CommandHandler command) {
Grasscutter.getLogger().trace("Registered command: " + label); Grasscutter.getLogger().trace("Registered command: {}", label);
label = label.toLowerCase(); label = label.toLowerCase();
// Get command data. // Get command data.
@ -76,7 +76,7 @@ public final class CommandMap {
* @return Instance chaining. * @return Instance chaining.
*/ */
public CommandMap unregisterCommand(String label) { public CommandMap unregisterCommand(String label) {
Grasscutter.getLogger().trace("Un-registered command: " + label); Grasscutter.getLogger().trace("Un-registered command: {}", label);
CommandHandler handler = this.commands.get(label); CommandHandler handler = this.commands.get(label);
if (handler == null) return this; if (handler == null) return this;
@ -230,15 +230,9 @@ public final class CommandMap {
if (SERVER.logCommands) { if (SERVER.logCommands) {
if (player != null) { if (player != null) {
Grasscutter.getLogger() Grasscutter.getLogger()
.info( .info("Command used by [{} (Player UID: {})]: {}", player.getAccount().getUsername(), player.getUid(), rawMessage);
"Command used by ["
+ player.getAccount().getUsername()
+ " (Player UID: "
+ player.getUid()
+ ")]: "
+ rawMessage);
} else { } else {
Grasscutter.getLogger().info("Command used by server console: " + rawMessage); Grasscutter.getLogger().info("Command used by server console: {}", rawMessage);
} }
} }
@ -350,12 +344,10 @@ public final class CommandMap {
this.registerCommand(cmdData.label(), (CommandHandler) object); this.registerCommand(cmdData.label(), (CommandHandler) object);
else else
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Class " + annotated.getName() + " is not a CommandHandler!"); .error("Class {} is not a CommandHandler!", annotated.getName());
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error("Failed to register command handler for {}", annotated.getSimpleName(), exception);
"Failed to register command handler for " + annotated.getSimpleName(),
exception);
} }
}); });
} }

View File

@ -88,7 +88,7 @@ public class DataLoader {
public static <T> List<T> loadTableToList(String resourcePath, Class<T> classType) throws IOException { public static <T> List<T> loadTableToList(String resourcePath, Class<T> classType) throws IOException {
val path = FileUtils.getDataPathTsjJsonTsv(resourcePath); val path = FileUtils.getDataPathTsjJsonTsv(resourcePath);
Grasscutter.getLogger().trace("Loading data table from: " + path); Grasscutter.getLogger().trace("Loading data table from: {}", path);
return switch (FileUtils.getFileExtension(path)) { return switch (FileUtils.getFileExtension(path)) {
case "json" -> JsonUtils.loadToList(path, classType); case "json" -> JsonUtils.loadToList(path, classType);
case "tsj" -> TsvUtils.loadTsjToListSetField(path, classType); case "tsj" -> TsvUtils.loadTsjToListSetField(path, classType);
@ -119,9 +119,9 @@ public class DataLoader {
if (!Files.exists(filePath)) { if (!Files.exists(filePath)) {
var root = filePath.getParent(); var root = filePath.getParent();
if (root.toFile().mkdirs()) Grasscutter.getLogger().info("Created data folder '" + root + "'"); if (root.toFile().mkdirs()) Grasscutter.getLogger().info("Created data folder '{}'", root);
Grasscutter.getLogger().debug("Creating default '" + name + "' data"); Grasscutter.getLogger().debug("Creating default '{}' data", name);
FileUtils.copyResource("/defaults/data/" + name, filePath.toString()); FileUtils.copyResource("/defaults/data/" + name, filePath.toString());
} }
} }

View File

@ -655,7 +655,7 @@ public final class GameData {
field.setAccessible(false); field.setAccessible(false);
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error fetching resource map for " + resourceDefinition.getSimpleName(), e); .error("Error fetching resource map for {}", resourceDefinition.getSimpleName(), e);
} }
return map; return map;

View File

@ -63,7 +63,7 @@ public final class ResourceLoader {
private static List<Set<Class<?>>> getResourceDefClassesPrioritySets() { private static List<Set<Class<?>>> getResourceDefClassesPrioritySets() {
val classes = Grasscutter.reflector.getSubTypesOf(GameResource.class); val classes = Grasscutter.reflector.getSubTypesOf(GameResource.class);
val priorities = ResourceType.LoadPriority.getInOrder(); val priorities = ResourceType.LoadPriority.getInOrder();
Grasscutter.getLogger().debug("Priorities are " + priorities); Grasscutter.getLogger().debug("Priorities are {}", priorities);
val map = new LinkedHashMap<ResourceType.LoadPriority, Set<Class<?>>>(priorities.size()); val map = new LinkedHashMap<ResourceType.LoadPriority, Set<Class<?>>>(priorities.size());
priorities.forEach(p -> map.put(p, new HashSet<>())); priorities.forEach(p -> map.put(p, new HashSet<>()));
@ -159,11 +159,11 @@ public final class ResourceLoader {
})); }));
errors.forEach( errors.forEach(
pair -> pair ->
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading resource file: " + pair.left(), pair.right())); .error("Error loading resource file: {}", pair.left(), pair.right()));
long endTime = System.nanoTime(); long endTime = System.nanoTime();
long ns = (endTime - startTime); // divide by 1000000 to get milliseconds. long ns = (endTime - startTime); // divide by 1000000 to get milliseconds.
Grasscutter.getLogger().debug("Loading resources took " + ns + "ns == " + ns / 1000000 + "ms"); Grasscutter.getLogger().debug("Loading resources took {}ns == {}ms", ns, ns / 1000000);
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -281,7 +281,7 @@ public final class ResourceLoader {
} }
}); });
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded " + GameData.getSceneNpcBornData().size() + " SceneRouteDatas."); .debug("Loaded {} SceneRouteDatas.", GameData.getSceneNpcBornData().size());
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().error("Failed to load SceneRouteData folder."); Grasscutter.getLogger().error("Failed to load SceneRouteData folder.");
} }
@ -402,7 +402,7 @@ public final class ResourceLoader {
.forEach(data -> loadAbilityData(data.Default)); .forEach(data -> loadAbilityData(data.Default));
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading ability modifiers from path " + path.toString() + ": ", e); .error("Error loading ability modifiers from path {}: ", path.toString(), e);
} }
} }
@ -464,7 +464,7 @@ public final class ResourceLoader {
path, String.class, new TypeToken<List<TalentData>>() {}.getType())); path, String.class, new TypeToken<List<TalentData>>() {}.getType()));
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading ability modifiers from path " + path.toString() + ": ", e); .error("Error loading ability modifiers from path {}: ", path.toString(), e);
} }
} }
@ -531,7 +531,7 @@ public final class ResourceLoader {
}); });
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading open config: no files found in " + folderName); .error("Error loading open config: no files found in {}", folderName);
return; return;
} }
} }
@ -587,7 +587,7 @@ public final class ResourceLoader {
} }
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded " + GameData.getMainQuestDataMap().size() + " MainQuestDatas."); .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size());
} }
public static void loadScriptSceneData() { public static void loadScriptSceneData() {
@ -605,7 +605,7 @@ public final class ResourceLoader {
} }
}); });
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded " + GameData.getScriptSceneDataMap().size() + " ScriptSceneDatas."); .debug("Loaded {} ScriptSceneDatas.", GameData.getScriptSceneDataMap().size());
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().debug("ScriptSceneData folder missing or empty."); Grasscutter.getLogger().debug("ScriptSceneData folder missing or empty.");
} }
@ -629,10 +629,7 @@ public final class ResourceLoader {
} }
}); });
Grasscutter.getLogger() Grasscutter.getLogger()
.debug( .debug("Loaded {} HomeworldDefaultSaveDatas.", GameData.getHomeworldDefaultSaveData().size());
"Loaded "
+ GameData.getHomeworldDefaultSaveData().size()
+ " HomeworldDefaultSaveDatas.");
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().error("Failed to load HomeworldDefaultSave folder."); Grasscutter.getLogger().error("Failed to load HomeworldDefaultSave folder.");
} }
@ -657,7 +654,7 @@ public final class ResourceLoader {
} }
}); });
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded " + GameData.getSceneNpcBornData().size() + " SceneNpcBornDatas."); .debug("Loaded {} SceneNpcBornDatas.", GameData.getSceneNpcBornData().size());
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().error("Failed to load SceneNpcBorn folder."); Grasscutter.getLogger().error("Failed to load SceneNpcBorn folder.");
} }

View File

@ -550,7 +550,7 @@ public final class DatabaseHelper {
.first(); .first();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Error occurred while getting uid " + uid + "'s achievement data", e); .debug("Error occurred while getting uid {}'s achievement data", uid, e);
DatabaseManager.getGameDatabase().getCollection("achievements").deleteMany(eq("uid", uid)); DatabaseManager.getGameDatabase().getCollection("achievements").deleteMany(eq("uid", uid));
return null; return null;
} }

View File

@ -177,15 +177,7 @@ public final class AbilityManager extends BasePlayerManager {
public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception { public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception {
Grasscutter.getLogger() Grasscutter.getLogger()
.trace( .trace("Ability invoke: {} {} ({}): {}", invoke, invoke.getArgumentType(), invoke.getArgumentTypeValue(), this.player.getScene().getEntityById(invoke.getEntityId()));
"Ability invoke: "
+ invoke
+ " "
+ invoke.getArgumentType()
+ " ("
+ invoke.getArgumentTypeValue()
+ "): "
+ this.player.getScene().getEntityById(invoke.getEntityId()));
var entity = this.player.getScene().getEntityById(invoke.getEntityId()); var entity = this.player.getScene().getEntityById(invoke.getEntityId());
if (entity != null) { if (entity != null) {
Grasscutter.getLogger() Grasscutter.getLogger()
@ -212,7 +204,7 @@ public final class AbilityManager extends BasePlayerManager {
if (invoke.getHead().getTargetId() != 0) { if (invoke.getHead().getTargetId() != 0) {
Grasscutter.getLogger() Grasscutter.getLogger()
.trace("Target: " + this.player.getScene().getEntityById(invoke.getHead().getTargetId())); .trace("Target: {}", this.player.getScene().getEntityById(invoke.getHead().getTargetId()));
} }
if (invoke.getHead().getLocalId() != 0) { if (invoke.getHead().getLocalId() != 0) {
this.handleServerInvoke(invoke); this.handleServerInvoke(invoke);

View File

@ -96,12 +96,7 @@ public class GachaBanner {
private void warnDeprecated(String name, String replacement) { private void warnDeprecated(String name, String replacement) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error("Deprecated field found in Banners config: {} was replaced back in early May 2022, use {} instead. You MUST remove this field from your config.", name, replacement);
"Deprecated field found in Banners config: "
+ name
+ " was replaced back in early May 2022, use "
+ replacement
+ " instead. You MUST remove this field from your config.");
this.deprecated = true; this.deprecated = true;
} }

View File

@ -322,10 +322,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
case MATERIAL_COSTUME: case MATERIAL_COSTUME:
case MATERIAL_NAMECARD: case MATERIAL_NAMECARD:
Grasscutter.getLogger() Grasscutter.getLogger()
.warn( .warn("Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", item.getItemData().getMaterialType().name());
"Attempted to add a "
+ item.getItemData().getMaterialType().name()
+ " to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.");
return null; return null;
default: default:
if (tab == null) { if (tab == null) {

View File

@ -35,12 +35,7 @@ public class MailHandler extends BasePlayerManager {
this.mail.add(message); this.mail.add(message);
Grasscutter.getLogger() Grasscutter.getLogger()
.debug( .debug("Mail sent to user [{}:{}]!", this.getPlayer().getUid(), this.getPlayer().getNickname());
"Mail sent to user ["
+ this.getPlayer().getUid()
+ ":"
+ this.getPlayer().getNickname()
+ "]!");
if (this.getPlayer().isOnline()) { if (this.getPlayer().isOnline()) {
this.getPlayer().sendPacket(new PacketMailChangeNotify(this.getPlayer(), message)); this.getPlayer().sendPacket(new PacketMailChangeNotify(this.getPlayer(), message));

View File

@ -104,7 +104,7 @@ public class SotSManager extends BasePlayerManager {
if (isAlive) { if (isAlive) {
return; return;
} }
logger.trace("Reviving avatar " + entity.getAvatar().getAvatarData().getName()); logger.trace("Reviving avatar {}", entity.getAvatar().getAvatarData().getName());
player.getTeamManager().reviveAvatar(entity.getAvatar()); player.getTeamManager().reviveAvatar(entity.getAvatar());
player.getTeamManager().healAvatar(entity.getAvatar(), 30, 0); player.getTeamManager().healAvatar(entity.getAvatar(), 30, 0);
}); });
@ -130,8 +130,7 @@ public class SotSManager extends BasePlayerManager {
setCurrentVolume(0); setCurrentVolume(0);
} }
if (needHP > 0) { if (needHP > 0) {
logger.trace( logger.trace("Healing avatar {} +{}", entity.getAvatar().getAvatarData().getName(), needHP);
"Healing avatar " + entity.getAvatar().getAvatarData().getName() + " +" + needHP);
player.getTeamManager().healAvatar(entity.getAvatar(), 0, needHP); player.getTeamManager().healAvatar(entity.getAvatar(), 0, needHP);
player player
.getSession() .getSession()
@ -168,9 +167,9 @@ public class SotSManager extends BasePlayerManager {
int secondsSinceLastUsed = (int) (now - getLastUsed()); int secondsSinceLastUsed = (int) (now - getLastUsed());
// 15s = 1% max volume // 15s = 1% max volume
int volumeRefilled = secondsSinceLastUsed * maxVolume / 15 / 100; int volumeRefilled = secondsSinceLastUsed * maxVolume / 15 / 100;
logger.trace("Statue has refilled HP volume: " + volumeRefilled); logger.trace("Statue has refilled HP volume: {}", volumeRefilled);
currentVolume = Math.min(currentVolume + volumeRefilled, maxVolume); currentVolume = Math.min(currentVolume + volumeRefilled, maxVolume);
logger.trace("Statue remaining HP volume: " + currentVolume); logger.trace("Statue remaining HP volume: {}", currentVolume);
setCurrentVolume(currentVolume); setCurrentVolume(currentVolume);
} }
} }
@ -181,11 +180,7 @@ public class SotSManager extends BasePlayerManager {
public void run() { public void run() {
refillSpringVolume(); refillSpringVolume();
logger.trace( logger.trace("isAutoRecoveryEnabled: {}\tautoRecoverPercentage: {}", getIsAutoRecoveryEnabled(), getAutoRecoveryPercentage());
"isAutoRecoveryEnabled: "
+ getIsAutoRecoveryEnabled()
+ "\tautoRecoverPercentage: "
+ getAutoRecoveryPercentage());
if (getIsAutoRecoveryEnabled()) { if (getIsAutoRecoveryEnabled()) {
List<EntityAvatar> activeTeam = player.getTeamManager().getActiveTeam(); List<EntityAvatar> activeTeam = player.getTeamManager().getActiveTeam();

View File

@ -101,7 +101,7 @@ public class BlossomManager {
} }
} }
Grasscutter.getLogger().info("Blossom Monsters:" + monsters); Grasscutter.getLogger().info("Blossom Monsters:{}", monsters);
activity = new BlossomActivity(entityGadget, monsters, -1, worldLevel); activity = new BlossomActivity(entityGadget, monsters, -1, worldLevel);
blossomActivities.add(activity); blossomActivities.add(activity);
@ -203,7 +203,7 @@ public class BlossomManager {
RewardPreviewData blossomRewards = getRewardList(type, worldLevel); RewardPreviewData blossomRewards = getRewardList(type, worldLevel);
if (blossomRewards == null) { if (blossomRewards == null) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Blossom could not support world level : " + worldLevel); .error("Blossom could not support world level : {}", worldLevel);
return null; return null;
} }
var rewards = blossomRewards.getPreviewItems(); var rewards = blossomRewards.getPreviewItems();

View File

@ -229,8 +229,7 @@ public class StaminaManager extends BasePlayerManager {
float diffX = currentCoordinates.getX() - previousCoordinates.getX(); float diffX = currentCoordinates.getX() - previousCoordinates.getX();
float diffY = currentCoordinates.getY() - previousCoordinates.getY(); float diffY = currentCoordinates.getY() - previousCoordinates.getY();
float diffZ = currentCoordinates.getZ() - previousCoordinates.getZ(); float diffZ = currentCoordinates.getZ() - previousCoordinates.getZ();
logger.trace("isPlayerMoving: " + previousCoordinates + ", " + currentCoordinates + logger.trace("isPlayerMoving: {}, {}, {}, {}, {}", previousCoordinates, currentCoordinates, diffX, diffY, diffZ);
", " + diffX + ", " + diffY + ", " + diffZ);
return Math.abs(diffX) > 0.3 || Math.abs(diffY) > 0.2 || Math.abs(diffZ) > 0.3; return Math.abs(diffX) > 0.3 || Math.abs(diffY) > 0.2 || Math.abs(diffZ) > 0.3;
} }
@ -244,17 +243,13 @@ public class StaminaManager extends BasePlayerManager {
for (Map.Entry<String, BeforeUpdateStaminaListener> listener : beforeUpdateStaminaListeners.entrySet()) { for (Map.Entry<String, BeforeUpdateStaminaListener> listener : beforeUpdateStaminaListeners.entrySet()) {
Consumption overriddenConsumption = listener.getValue().onBeforeUpdateStamina(consumption.type.toString(), consumption, isCharacterStamina); Consumption overriddenConsumption = listener.getValue().onBeforeUpdateStamina(consumption.type.toString(), consumption, isCharacterStamina);
if ((overriddenConsumption.type != consumption.type) && (overriddenConsumption.amount != consumption.amount)) { if ((overriddenConsumption.type != consumption.type) && (overriddenConsumption.amount != consumption.amount)) {
logger.debug("Stamina update relative(" + logger.debug("Stamina update relative({}, {}) overridden to relative({}, {}) by: {}", consumption.type.toString(), consumption.amount, consumption.type.toString(), consumption.amount, listener.getKey());
consumption.type.toString() + ", " + consumption.amount + ") overridden to relative(" +
consumption.type.toString() + ", " + consumption.amount + ") by: " + listener.getKey());
return currentStamina; return currentStamina;
} }
} }
int maxStamina = isCharacterStamina ? getMaxCharacterStamina() : getMaxVehicleStamina(); int maxStamina = isCharacterStamina ? getMaxCharacterStamina() : getMaxVehicleStamina();
logger.trace((isCharacterStamina ? "C " : "V ") + currentStamina + "/" + maxStamina + "\t" + currentState + "\t" + logger.trace("{}{}/{}\t{}\t{}\t({},{})", isCharacterStamina ? "C " : "V ", currentStamina, maxStamina, currentState, isPlayerMoving() ? "moving" : " ", consumption.type, consumption.amount);
(isPlayerMoving() ? "moving" : " ") + "\t(" + consumption.type + "," +
consumption.amount + ")");
int newStamina = currentStamina + consumption.amount; int newStamina = currentStamina + consumption.amount;
if (newStamina < 0) { if (newStamina < 0) {
@ -272,9 +267,7 @@ public class StaminaManager extends BasePlayerManager {
for (Map.Entry<String, BeforeUpdateStaminaListener> listener : beforeUpdateStaminaListeners.entrySet()) { for (Map.Entry<String, BeforeUpdateStaminaListener> listener : beforeUpdateStaminaListeners.entrySet()) {
int overriddenNewStamina = listener.getValue().onBeforeUpdateStamina(reason, newStamina, isCharacterStamina); int overriddenNewStamina = listener.getValue().onBeforeUpdateStamina(reason, newStamina, isCharacterStamina);
if (overriddenNewStamina != newStamina) { if (overriddenNewStamina != newStamina) {
logger.debug("Stamina update absolute(" + logger.debug("Stamina update absolute({}, {}) overridden to absolute({}, {}) by: {}", reason, newStamina, reason, newStamina, listener.getKey());
reason + ", " + newStamina + ") overridden to absolute(" +
reason + ", " + newStamina + ") by: " + listener.getKey());
return currentStamina; return currentStamina;
} }
} }
@ -450,8 +443,7 @@ public class StaminaManager extends BasePlayerManager {
int currentVehicleStamina = getCurrentVehicleStamina(); int currentVehicleStamina = getCurrentVehicleStamina();
int maxVehicleStamina = getMaxVehicleStamina(); int maxVehicleStamina = getMaxVehicleStamina();
if (moving || (currentCharacterStamina < maxCharacterStamina) || (currentVehicleStamina < maxVehicleStamina)) { if (moving || (currentCharacterStamina < maxCharacterStamina) || (currentVehicleStamina < maxVehicleStamina)) {
logger.trace("Player moving: " + moving + ", stamina full: " + logger.trace("Player moving: {}, stamina full: {}, recalculate stamina", moving, currentCharacterStamina >= maxCharacterStamina);
(currentCharacterStamina >= maxCharacterStamina) + ", recalculate stamina");
boolean isCharacterStamina = true; boolean isCharacterStamina = true;
Consumption consumption; Consumption consumption;
@ -499,7 +491,7 @@ public class StaminaManager extends BasePlayerManager {
// For others recover after 1 seconds (5 ticks) - as official server does. // For others recover after 1 seconds (5 ticks) - as official server does.
staminaRecoverDelay++; staminaRecoverDelay++;
consumption.amount = 0; consumption.amount = 0;
logger.trace("Delaying recovery: " + staminaRecoverDelay); logger.trace("Delaying recovery: {}", staminaRecoverDelay);
} }
} }
updateStaminaRelative(cachedSession, consumption, isCharacterStamina); updateStaminaRelative(cachedSession, consumption, isCharacterStamina);
@ -514,8 +506,7 @@ public class StaminaManager extends BasePlayerManager {
// TODO: fix drowning waverider entity // TODO: fix drowning waverider entity
int stamina = getCurrentCharacterStamina(); int stamina = getCurrentCharacterStamina();
if (stamina < 10) { if (stamina < 10) {
logger.trace(getCurrentCharacterStamina() + "/" + logger.trace("{}/{}\t{}", getCurrentCharacterStamina(), getMaxCharacterStamina(), currentState);
getMaxCharacterStamina() + "\t" + currentState);
if (currentState != MotionState.MOTION_STATE_SWIM_IDLE) { if (currentState != MotionState.MOTION_STATE_SWIM_IDLE) {
killAvatar(cachedSession, cachedEntity, PlayerDieType.PLAYER_DIE_TYPE_DRAWN); killAvatar(cachedSession, cachedEntity, PlayerDieType.PLAYER_DIE_TYPE_DRAWN);
} }

View File

@ -93,7 +93,7 @@ public class ShopSystem extends BaseGameSystem {
} }
this.shopChestData.put((int) chestId, list); this.shopChestData.put((int) chestId, list);
}); });
Grasscutter.getLogger().debug("Loaded " + chestMap.size() + " ShopChest entries."); Grasscutter.getLogger().debug("Loaded {} ShopChest entries.", chestMap.size());
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger().error("Unable to load ShopChest data.", e); Grasscutter.getLogger().error("Unable to load ShopChest data.", e);
} }

View File

@ -82,12 +82,7 @@ public class InventorySystem extends BaseGameSystem {
val avatarData = avatar.getSkillDepot(); val avatarData = avatar.getSkillDepot();
if (avatarData == null) { if (avatarData == null) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error("Attempted to check constellation level for UID{}'s avatar {} but avatar has no skillDepot!", player.getUid(), avatarId);
"Attempted to check constellation level for UID"
+ player.getUid()
+ "'s avatar "
+ avatarId
+ " but avatar has no skillDepot!");
return 0; return 0;
} }
int constItemId = avatarData.getTalentCostItemId(); int constItemId = avatarData.getTalentCostItemId();

View File

@ -30,7 +30,7 @@ public abstract class Plugin {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void initializePlugin(PluginIdentifier identifier, URLClassLoader classLoader) { private void initializePlugin(PluginIdentifier identifier, URLClassLoader classLoader) {
if (this.identifier != null) { if (this.identifier != null) {
Grasscutter.getLogger().warn(this.identifier.name + " had a reinitialization attempt."); Grasscutter.getLogger().warn("{} had a reinitialization attempt.", this.identifier.name);
return; return;
} }
@ -45,7 +45,7 @@ public abstract class Plugin {
if (!this.dataFolder.exists() && !this.dataFolder.mkdirs()) { if (!this.dataFolder.exists() && !this.dataFolder.mkdirs()) {
Grasscutter.getLogger() Grasscutter.getLogger()
.warn("Failed to create plugin data folder for " + this.identifier.name); .warn("Failed to create plugin data folder for {}", this.identifier.name);
} }
} }

View File

@ -887,7 +887,7 @@ public class SceneScriptManager {
} }
} catch (Throwable throwable) { } catch (Throwable throwable) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Condition Trigger " + params.type + " triggered exception", throwable); .error("Condition Trigger {} triggered exception", params.type, throwable);
} finally { } finally {
// make sure it is removed // make sure it is removed
ScriptLoader.getScriptLib().removeSceneScriptManager(); ScriptLoader.getScriptLib().removeSceneScriptManager();
@ -913,7 +913,7 @@ public class SceneScriptManager {
return false; return false;
} catch (Throwable ex) { } catch (Throwable ex) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Condition Trigger " + trigger.getName() + " triggered exception", ex); .error("Condition Trigger {} triggered exception", trigger.getName(), ex);
return false; return false;
} finally { } finally {
ScriptLoader.getScriptLib().removeCurrentGroup(); ScriptLoader.getScriptLib().removeCurrentGroup();

View File

@ -73,9 +73,7 @@ public class SceneBlock {
SceneIndexManager.buildIndex(3, this.groups.values(), g -> g.pos.toPoint()); SceneIndexManager.buildIndex(3, this.groups.values(), g -> g.pos.toPoint());
} catch (ScriptException exception) { } catch (ScriptException exception) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error("An error occurred while loading block {} in scene {}", this.id, sceneId, exception);
"An error occurred while loading block " + this.id + " in scene " + sceneId,
exception);
} }
Grasscutter.getLogger().trace("Successfully loaded block {} in scene {}.", this.id, sceneId); Grasscutter.getLogger().trace("Successfully loaded block {} in scene {}.", this.id, sceneId);
return this; return this;

View File

@ -168,8 +168,7 @@ public final class SceneGroup {
this.suites.forEach(i -> i.init(this)); this.suites.forEach(i -> i.init(this));
} catch (ScriptException e) { } catch (ScriptException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error("An error occurred while loading group {} in scene {}.", this.id, sceneId, e);
"An error occurred while loading group " + this.id + " in scene " + sceneId + ".", e);
} catch (LuaError luaError) { } catch (LuaError luaError) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error(

View File

@ -29,7 +29,7 @@ public class SceneMeta {
CompiledScript cs = ScriptLoader.getScript("Scene/" + sceneId + "/scene" + sceneId + ".lua"); CompiledScript cs = ScriptLoader.getScript("Scene/" + sceneId + "/scene" + sceneId + ".lua");
if (cs == null) { if (cs == null) {
Grasscutter.getLogger().warn("No script found for scene " + sceneId); Grasscutter.getLogger().warn("No script found for scene {}", sceneId);
return null; return null;
} }

View File

@ -41,7 +41,7 @@ public final class GameServerPacketHandler {
// Debug // Debug
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Registered " + this.handlers.size() + " " + handlerClass.getSimpleName() + "s"); .debug("Registered {} {}s", this.handlers.size(), handlerClass.getSimpleName());
} }
public void handle(GameSession session, int opcode, byte[] header, byte[] payload) { public void handle(GameSession session, int opcode, byte[] header, byte[] payload) {
@ -91,11 +91,7 @@ public final class GameServerPacketHandler {
if (GAME_INFO.logPackets == ServerDebugMode.MISSING if (GAME_INFO.logPackets == ServerDebugMode.MISSING
|| GAME_INFO.logPackets == ServerDebugMode.ALL) { || GAME_INFO.logPackets == ServerDebugMode.ALL) {
Grasscutter.getLogger() Grasscutter.getLogger()
.info( .info("Unhandled packet ({}): {}", opcode, PacketOpcodesUtils.getOpcodeName(opcode));
"Unhandled packet ("
+ opcode
+ "): "
+ emu.grasscutter.net.packet.PacketOpcodesUtils.getOpcodeName(opcode));
} }
} }
} }

View File

@ -99,7 +99,7 @@ public class GameSession implements GameSessionManager.KcpChannel {
public void logPacket(String sendOrRecv, int opcode, byte[] payload) { public void logPacket(String sendOrRecv, int opcode, byte[] payload) {
Grasscutter.getLogger() Grasscutter.getLogger()
.info(sendOrRecv + ": " + PacketOpcodesUtils.getOpcodeName(opcode) + " (" + opcode + ")"); .info("{}: {} ({})", sendOrRecv, PacketOpcodesUtils.getOpcodeName(opcode), opcode);
if (GAME_INFO.isShowPacketPayload) System.out.println(Utils.bytesToHex(payload)); if (GAME_INFO.isShowPacketPayload) System.out.println(Utils.bytesToHex(payload));
} }

View File

@ -66,8 +66,7 @@ public final class HttpServer {
this.javalin.exception(Exception.class, (exception, ctx) -> { this.javalin.exception(Exception.class, (exception, ctx) -> {
ctx.status(500).result("Internal server error. %s" ctx.status(500).result("Internal server error. %s"
.formatted(exception.getMessage())); .formatted(exception.getMessage()));
Grasscutter.getLogger().debug("Exception thrown: " + Grasscutter.getLogger().debug("Exception thrown: {}", exception.getMessage(), exception);
exception.getMessage(), exception);
}); });
} }

View File

@ -18,7 +18,7 @@ final class RootRequestHandler implements DocumentationHandler {
try { try {
t = Files.readString(templatePath); t = Files.readString(templatePath);
} catch (IOException ignored) { } catch (IOException ignored) {
Grasscutter.getLogger().warn("File does not exist: " + templatePath); Grasscutter.getLogger().warn("File does not exist: {}", templatePath);
} }
this.template = t; this.template = t;
} }

View File

@ -22,7 +22,7 @@ public final class AnnouncementsHandler implements Router {
data = FileUtils.readToString(DataLoader.load("GameAnnouncement.json")); data = FileUtils.readToString(DataLoader.load("GameAnnouncement.json"));
} catch (Exception e) { } catch (Exception e) {
if (e.getClass() == IOException.class) { if (e.getClass() == IOException.class) {
Grasscutter.getLogger().info("Unable to read file 'GameAnnouncementList.json'. \n" + e); Grasscutter.getLogger().info("Unable to read file 'GameAnnouncementList.json'. \n{}", e);
} }
} }
} else if (Objects.equals( } else if (Objects.equals(
@ -31,7 +31,7 @@ public final class AnnouncementsHandler implements Router {
data = FileUtils.readToString(DataLoader.load("GameAnnouncementList.json")); data = FileUtils.readToString(DataLoader.load("GameAnnouncementList.json"));
} catch (Exception e) { } catch (Exception e) {
if (e.getClass() == IOException.class) { if (e.getClass() == IOException.class) {
Grasscutter.getLogger().info("Unable to read file 'GameAnnouncementList.json'. \n" + e); Grasscutter.getLogger().info("Unable to read file 'GameAnnouncementList.json'. \n{}", e);
} }
} }
} else { } else {
@ -77,7 +77,7 @@ public final class AnnouncementsHandler implements Router {
ctx.contentType(fromExtension != null ? fromExtension : ContentType.APPLICATION_OCTET_STREAM); ctx.contentType(fromExtension != null ? fromExtension : ContentType.APPLICATION_OCTET_STREAM);
ctx.result(filestream.readAllBytes()); ctx.result(filestream.readAllBytes());
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger().warn("File does not exist: " + ctx.path()); Grasscutter.getLogger().warn("File does not exist: {}", ctx.path());
ctx.status(404); ctx.status(404);
} }
} }

View File

@ -38,13 +38,11 @@ public final class HttpJsonResponse implements Handler {
&& Arrays.stream(missingRoutes) && Arrays.stream(missingRoutes)
.anyMatch(x -> Objects.equals(x, ctx.endpointHandlerPath()))) { .anyMatch(x -> Objects.equals(x, ctx.endpointHandlerPath()))) {
Grasscutter.getLogger() Grasscutter.getLogger()
.info( .info("{}{}", translate(
translate( "messages.dispatch.request",
"messages.dispatch.request", Utils.address(ctx),
Utils.address(ctx), ctx.method(),
ctx.method(), ctx.endpointHandlerPath()), DISPATCH_INFO.logRequests == ServerDebugMode.MISSING ? "(MISSING)" : "");
ctx.endpointHandlerPath())
+ (DISPATCH_INFO.logRequests == ServerDebugMode.MISSING ? "(MISSING)" : ""));
} }
ctx.result(response); ctx.result(response);
} }

View File

@ -17,7 +17,7 @@ public class WebStaticVersionResponse implements Handler {
ctx.result(filestream.readAllBytes()); ctx.result(filestream.readAllBytes());
} catch (Exception e) { } catch (Exception e) {
if (DISPATCH_INFO.logRequests == Grasscutter.ServerDebugMode.MISSING) { if (DISPATCH_INFO.logRequests == Grasscutter.ServerDebugMode.MISSING) {
Grasscutter.getLogger().warn("Webstatic File Missing: " + path); Grasscutter.getLogger().warn("Webstatic File Missing: {}", path);
} }
ctx.status(404); ctx.status(404);
} }

View File

@ -129,13 +129,7 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
int maxDelay = 200; int maxDelay = 200;
long actualDelay = System.currentTimeMillis() - cachedLandingTimeMillisecond; long actualDelay = System.currentTimeMillis() - cachedLandingTimeMillisecond;
Grasscutter.getLogger() Grasscutter.getLogger()
.trace( .trace("MOTION_FALL_ON_GROUND received after {}/{}ms.{}", actualDelay, maxDelay, actualDelay > maxDelay ? " Discard" : "");
"MOTION_FALL_ON_GROUND received after "
+ actualDelay
+ "/"
+ maxDelay
+ "ms."
+ (actualDelay > maxDelay ? " Discard" : ""));
if (actualDelay > maxDelay) { if (actualDelay > maxDelay) {
return; return;
} }
@ -161,20 +155,9 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
} }
if (damageFactor > 0) { if (damageFactor > 0) {
Grasscutter.getLogger() Grasscutter.getLogger()
.debug( .debug("{}/{}\tLandingSpeed: {}\tDamageFactor: {}\tDamage: {}\tNewHP: {}", currentHP, maxHP, cachedLandingSpeed, damageFactor, damage, newHP);
currentHP
+ "/"
+ maxHP
+ "\tLandingSpeed: "
+ cachedLandingSpeed
+ "\tDamageFactor: "
+ damageFactor
+ "\tDamage: "
+ damage
+ "\tNewHP: "
+ newHP);
} else { } else {
Grasscutter.getLogger().trace(currentHP + "/" + maxHP + "\tLandingSpeed: 0\tNo damage"); Grasscutter.getLogger().trace("{}/{}\tLandingSpeed: 0\tNo damage", currentHP, maxHP);
} }
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, newHP); entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, newHP);
entity entity

View File

@ -155,12 +155,11 @@ public final class TaskMap {
} }
} else { } else {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Class " + annotated.getName() + " is not a TaskHandler!"); .error("Class {} is not a TaskHandler!", annotated.getName());
} }
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error("Failed to register task handler for {}", annotated.getSimpleName(), exception);
"Failed to register task handler for " + annotated.getSimpleName(), exception);
} }
}); });
try { try {

View File

@ -314,10 +314,10 @@ public final class Tools {
var path = GachaHandler.getGachaMappingsPath(); var path = GachaHandler.getGachaMappingsPath();
if (!Files.exists(path)) { if (!Files.exists(path)) {
try { try {
Grasscutter.getLogger().debug("Creating default '" + path + "' data"); Grasscutter.getLogger().debug("Creating default '{}' data", path);
Tools.createGachaMappings(path); Tools.createGachaMappings(path);
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger().warn("Failed to create gacha mappings. \n" + exception); Grasscutter.getLogger().warn("Failed to create gacha mappings. \n{}", exception);
} }
} }
} }
@ -342,7 +342,7 @@ public final class Tools {
Files.createDirectories(location.getParent()); Files.createDirectories(location.getParent());
Files.writeString(location, sb); Files.writeString(location, sb);
Grasscutter.getLogger().debug("Mappings generated to " + location); Grasscutter.getLogger().debug("Mappings generated to {}", location);
} }
public static List<String> getAvailableLanguage() { public static List<String> getAvailableLanguage() {

View File

@ -41,7 +41,7 @@ public final class FileUtils {
break; break;
default: default:
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Invalid URI scheme for class resources: " + uri.getScheme()); .error("Invalid URI scheme for class resources: {}", uri.getScheme());
break; break;
} }
} catch (URISyntaxException | IOException e) { } catch (URISyntaxException | IOException e) {
@ -49,7 +49,7 @@ public final class FileUtils {
Grasscutter.getLogger().error("Failed to load jar?!"); Grasscutter.getLogger().error("Failed to load jar?!");
} finally { } finally {
DATA_DEFAULT_PATH = path; DATA_DEFAULT_PATH = path;
Grasscutter.getLogger().debug("Setting path for default data: " + path.toAbsolutePath()); Grasscutter.getLogger().debug("Setting path for default data: {}", path.toAbsolutePath());
} }
// Setup Resources path // Setup Resources path
@ -82,10 +82,10 @@ public final class FileUtils {
path = excelBinOutput.get().getParent(); path = excelBinOutput.get().getParent();
if (path == null) path = root; if (path == null) path = root;
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Resources will be loaded from \"" + resources + "/" + path + "\""); .debug("Resources will be loaded from \"" + resources + "/{}\"", path);
} else { } else {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Failed to find ExcelBinOutput in resources zip \"" + resources + "\""); .error("Failed to find ExcelBinOutput in resources zip \"" + resources + "\"");
} }
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().error("Failed to scan resources zip \"" + resources + "\""); Grasscutter.getLogger().error("Failed to scan resources zip \"" + resources + "\"");
@ -176,7 +176,7 @@ public final class FileUtils {
try { try {
Files.write(path, bytes); Files.write(path, bytes);
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().warn("Failed to write file: " + dest); Grasscutter.getLogger().warn("Failed to write file: {}", dest);
} }
} }
@ -188,7 +188,7 @@ public final class FileUtils {
try { try {
return Files.readAllBytes(path); return Files.readAllBytes(path);
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().warn("Failed to read file: " + path); Grasscutter.getLogger().warn("Failed to read file: {}", path);
} }
return new byte[0]; return new byte[0];
@ -202,8 +202,8 @@ public final class FileUtils {
try (InputStream is = Grasscutter.class.getResourceAsStream(resourcePath)) { try (InputStream is = Grasscutter.class.getResourceAsStream(resourcePath)) {
return is.readAllBytes(); return is.readAllBytes();
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger().warn("Failed to read resource: " + resourcePath); Grasscutter.getLogger().warn("Failed to read resource: {}", resourcePath);
Grasscutter.getLogger().debug("Failed to load resource: " + resourcePath, exception); Grasscutter.getLogger().debug("Failed to load resource: {}", resourcePath, exception);
} }
return new byte[0]; return new byte[0];
@ -218,7 +218,7 @@ public final class FileUtils {
byte[] resource = FileUtils.readResource(resourcePath); byte[] resource = FileUtils.readResource(resourcePath);
FileUtils.write(destination, resource); FileUtils.write(destination, resource);
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger().warn("Failed to copy resource: " + resourcePath + "\n" + exception); Grasscutter.getLogger().warn("Failed to copy resource: {}\n{}", resourcePath, exception);
} }
} }

View File

@ -228,12 +228,10 @@ public final class TsvUtils {
return tree.toClass(classType, null); return tree.toClass(classType, null);
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.warn( .warn("Error deserializing an instance of class {}", classType.getCanonicalName());
"Error deserializing an instance of class " Grasscutter.getLogger().warn("At token #{} of #{}", t, m);
+ classType.getCanonicalName()); Grasscutter.getLogger().warn("Header names are: {}", headerNames);
Grasscutter.getLogger().warn("At token #" + t + " of #" + m); Grasscutter.getLogger().warn("Tokens are: {}", tokens);
Grasscutter.getLogger().warn("Header names are: " + headerNames);
Grasscutter.getLogger().warn("Tokens are: " + tokens);
Grasscutter.getLogger().warn("Stacktrace is: ", e); Grasscutter.getLogger().warn("Stacktrace is: ", e);
// System.out.println("Error deserializing an instance of class // System.out.println("Error deserializing an instance of class
// "+classType.getCanonicalName()); // "+classType.getCanonicalName());
@ -247,7 +245,7 @@ public final class TsvUtils {
}) })
.toList(); .toList();
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger().error("Error loading file '" + filename + "' - Stacktrace is: ", e); Grasscutter.getLogger().error("Error loading file '{}' - Stacktrace is: ", filename, e);
return null; return null;
} }
} }
@ -285,12 +283,10 @@ public final class TsvUtils {
return obj; return obj;
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.warn( .warn("Error deserializing an instance of class {}", classType.getCanonicalName());
"Error deserializing an instance of class " Grasscutter.getLogger().warn("At token #{} of #{}", t, m);
+ classType.getCanonicalName()); Grasscutter.getLogger().warn("Header names are: {}", headerNames);
Grasscutter.getLogger().warn("At token #" + t + " of #" + m); Grasscutter.getLogger().warn("Tokens are: {}", tokens);
Grasscutter.getLogger().warn("Header names are: " + headerNames);
Grasscutter.getLogger().warn("Tokens are: " + tokens);
Grasscutter.getLogger().warn("Stacktrace is: ", e); Grasscutter.getLogger().warn("Stacktrace is: ", e);
return null; return null;
} }
@ -298,17 +294,14 @@ public final class TsvUtils {
.toList(); .toList();
} catch (NoSuchFileException e) { } catch (NoSuchFileException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error("Error loading file '{}' - File does not exist. You are missing resources. Note that this file may exist in JSON, TSV, or TSJ format, any of which are suitable.", filename);
"Error loading file '"
+ filename
+ "' - File does not exist. You are missing resources. Note that this file may exist in JSON, TSV, or TSJ format, any of which are suitable.");
return null; return null;
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().error("Error loading file '" + filename + "' - Stacktrace is: ", e); Grasscutter.getLogger().error("Error loading file '{}' - Stacktrace is: ", filename, e);
return null; return null;
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading file '" + filename + "' - Class is missing NoArgsConstructor"); .error("Error loading file '{}' - Class is missing NoArgsConstructor", filename);
return null; return null;
} }
} }
@ -336,7 +329,7 @@ public final class TsvUtils {
throws Exception { throws Exception {
val pair = getAllArgsConstructor(classType); val pair = getAllArgsConstructor(classType);
if (pair == null) { if (pair == null) {
Grasscutter.getLogger().error("No AllArgsContructor found for class: " + classType); Grasscutter.getLogger().error("No AllArgsContructor found for class: {}", classType);
return null; return null;
} }
val constructor = pair.left(); val constructor = pair.left();
@ -405,27 +398,21 @@ public final class TsvUtils {
return constructor.newInstance(args); return constructor.newInstance(args);
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.warn( .warn("Error deserializing an instance of class {} : {}", classType.getCanonicalName(), constructor.getName());
"Error deserializing an instance of class " Grasscutter.getLogger().warn("At token #{} of #{}", t, m);
+ classType.getCanonicalName()
+ " : "
+ constructor.getName());
Grasscutter.getLogger().warn("At token #" + t + " of #" + m);
Grasscutter.getLogger() Grasscutter.getLogger()
.warn("Arg names are: " + Arrays.toString(conArgNames)); .warn("Arg names are: {}", Arrays.toString(conArgNames));
Grasscutter.getLogger() Grasscutter.getLogger()
.warn("Arg types are: " + Arrays.toString(argTypes)); .warn("Arg types are: {}", Arrays.toString(argTypes));
Grasscutter.getLogger() Grasscutter.getLogger()
.warn("Default Args are: " + Arrays.toString(defaultArgs)); .warn("Default Args are: {}", Arrays.toString(defaultArgs));
Grasscutter.getLogger().warn("Args are: " + Arrays.toString(args)); Grasscutter.getLogger().warn("Args are: {}", Arrays.toString(args));
Grasscutter.getLogger().warn("Header names are: " + headerNames); Grasscutter.getLogger().warn("Header names are: {}", headerNames);
Grasscutter.getLogger() Grasscutter.getLogger()
.warn( .warn("Header types are: {}", IntStream.of(argPositions)
"Header types are: " .mapToObj(i -> (i >= 0) ? argTypes[i] : null)
+ IntStream.of(argPositions) .toList());
.mapToObj(i -> (i >= 0) ? argTypes[i] : null) Grasscutter.getLogger().warn("Tokens are: {}", tokens);
.toList());
Grasscutter.getLogger().warn("Tokens are: " + tokens);
Grasscutter.getLogger().warn("Stacktrace is: ", e); Grasscutter.getLogger().warn("Stacktrace is: ", e);
return null; return null;
} }
@ -433,7 +420,7 @@ public final class TsvUtils {
.toList(); .toList();
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading file '" + filename + "' - Stacktrace is: ", e); .error("Error loading file '{}' - Stacktrace is: ", filename, e);
return null; return null;
} }
}) })
@ -582,23 +569,14 @@ public final class TsvUtils {
// System.out.println("Exception while setting field "+name+" for class "+objClass+" // System.out.println("Exception while setting field "+name+" for class "+objClass+"
// - "+e); // - "+e);
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error("Exception while setting field {} ({}) for class {} - ", name, field.classType, objClass, e);
"Exception while setting field "
+ name
+ " ("
+ field.classType
+ ")"
+ " for class "
+ objClass
+ " - ",
e);
} }
}); });
return obj; return obj;
} catch (Exception e) { } catch (Exception e) {
// System.out.println("Exception while creating object of class "+objClass+" - "+e); // System.out.println("Exception while creating object of class "+objClass+" - "+e);
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Exception while creating object of class " + objClass + " - ", e); .error("Exception while creating object of class {} - ", objClass, e);
return null; return null;
} }
} }

View File

@ -69,7 +69,7 @@ public final class Utils {
public static void logByteArray(byte[] array) { public static void logByteArray(byte[] array) {
ByteBuf b = Unpooled.wrappedBuffer(array); ByteBuf b = Unpooled.wrappedBuffer(array);
Grasscutter.getLogger().info("\n" + ByteBufUtil.prettyHexDump(b)); Grasscutter.getLogger().info("\n{}", ByteBufUtil.prettyHexDump(b));
b.release(); b.release();
} }
@ -143,7 +143,7 @@ public final class Utils {
public static boolean copyFromResources(String resource, String destination) { public static boolean copyFromResources(String resource, String destination) {
try (InputStream stream = Grasscutter.class.getResourceAsStream(resource)) { try (InputStream stream = Grasscutter.class.getResourceAsStream(resource)) {
if (stream == null) { if (stream == null) {
Grasscutter.getLogger().warn("Could not find resource: " + resource); Grasscutter.getLogger().warn("Could not find resource: {}", resource);
return false; return false;
} }
@ -151,7 +151,7 @@ public final class Utils {
return true; return true;
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger() Grasscutter.getLogger()
.warn("Unable to copy resource " + resource + " to " + destination, exception); .warn("Unable to copy resource {} to {}", resource, destination, exception);
return false; return false;
} }
} }

View File

@ -44,7 +44,7 @@ public final class Language {
.forEach(entry -> putFlattenedKey(translations, entry.getKey(), entry.getValue())); .forEach(entry -> putFlattenedKey(translations, entry.getKey(), entry.getValue()));
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger() Grasscutter.getLogger()
.warn("Failed to load language file: " + description.getLanguageCode(), exception); .warn("Failed to load language file: {}", description.getLanguageCode(), exception);
} }
} }
@ -99,7 +99,7 @@ public final class Language {
try { try {
return translated.formatted(args); return translated.formatted(args);
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger().error("Failed to format string: " + key, exception); Grasscutter.getLogger().error("Failed to format string: {}", key, exception);
return translated; return translated;
} }
} }
@ -134,7 +134,7 @@ public final class Language {
try { try {
return translated.formatted(args); return translated.formatted(args);
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger().error("Failed to format string: " + key, exception); Grasscutter.getLogger().error("Failed to format string: {}", key, exception);
return translated; return translated;
} }
} }
@ -194,7 +194,7 @@ public final class Language {
if (file == null) { // Provided fallback language. if (file == null) { // Provided fallback language.
Grasscutter.getLogger() Grasscutter.getLogger()
.warn("Failed to load language file: " + fileName + ", falling back to: " + fallback); .warn("Failed to load language file: {}, falling back to: {}", fileName, fallback);
actualLanguageCode = fallbackLanguageCode; actualLanguageCode = fallbackLanguageCode;
if (cachedLanguages.containsKey(actualLanguageCode)) { if (cachedLanguages.containsKey(actualLanguageCode)) {
return new LanguageStreamDescription(actualLanguageCode, null); return new LanguageStreamDescription(actualLanguageCode, null);
@ -205,7 +205,7 @@ public final class Language {
if (file == null) { // Fallback the fallback language. if (file == null) { // Fallback the fallback language.
Grasscutter.getLogger() Grasscutter.getLogger()
.warn("Failed to load language file: " + fallback + ", falling back to: en-US.json"); .warn("Failed to load language file: {}, falling back to: en-US.json", fallback);
actualLanguageCode = "en-US"; actualLanguageCode = "en-US";
if (cachedLanguages.containsKey(actualLanguageCode)) { if (cachedLanguages.containsKey(actualLanguageCode)) {
return new LanguageStreamDescription(actualLanguageCode, null); return new LanguageStreamDescription(actualLanguageCode, null);
@ -241,7 +241,7 @@ public final class Language {
m -> (int) Long.parseLong(m.group(1)), m -> (int) Long.parseLong(m.group(1)),
m -> m.group(2).replace("\\\"", "\"")))); m -> m.group(2).replace("\\\"", "\""))));
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger().error("Error loading textmap: " + language); Grasscutter.getLogger().error("Error loading textmap: {}", language);
Grasscutter.getLogger().error(e.toString()); Grasscutter.getLogger().error(e.toString());
} }
return output; return output;
@ -361,7 +361,7 @@ public final class Language {
} catch (NoSuchFileException ignored) { } catch (NoSuchFileException ignored) {
// Cache doesn't exist, generate it. // Cache doesn't exist, generate it.
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger().error("Error loading textmaps cache: " + exception); Grasscutter.getLogger().error("Error loading textmaps cache: {}", exception);
} }
// Regenerate cache // Regenerate cache