From 31e60448c35196afac4ea52366077d1d1f119781 Mon Sep 17 00:00:00 2001 From: soloturn Date: Mon, 12 Feb 2024 09:36:48 +0100 Subject: [PATCH] review feedback pr introduce local varaible where necessary, otherwise ignore warning for the sake of shorter log message line. --- .../engine/audio/openAL/OpenALManager.java | 16 ++++++++-------- .../persistence/internal/GlobalStoreLoader.java | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java b/engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java index 4396de68e60..2778f95fc3d 100644 --- a/engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java +++ b/engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java @@ -52,6 +52,7 @@ public class OpenALManager implements AudioManager { private final Map, AudioEndListener> endListeners = Maps.newHashMap(); + @SuppressWarnings("PMD.GuardLogStatement") public OpenALManager(AudioConfig config) throws OpenALException { logger.info("Initializing OpenAL audio manager"); @@ -66,14 +67,13 @@ public OpenALManager(AudioConfig config) throws OpenALException { logger.atInfo().addArgument(() -> AL10.alGetString(AL10.AL_VERSION)).log("OpenAL {} initialized!"); - logger.atInfo().addArgument(() -> AL10.alGetString(AL10.AL_RENDERER)).addArgument(() -> AL10.alGetString(AL10.AL_VENDOR)). - log("Using OpenAL: {} by {}"); - logger.atInfo().addArgument(() -> ALC10.alcGetString(device, ALC10.ALC_DEVICE_SPECIFIER)).log("Using device: {}"); - logger.atInfo().addArgument(() -> AL10.alGetString(AL10.AL_EXTENSIONS)).log("Available AL extensions: {}"); - logger.atInfo().addArgument(() -> ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS)).log("Available ALC extensions: {}"); - logger.atInfo().addArgument(() -> ALC10.alcGetInteger(device, ALC11.ALC_MONO_SOURCES)).log("Max mono sources: {}"); - logger.atInfo().addArgument(() -> ALC10.alcGetInteger(device, ALC11.ALC_STEREO_SOURCES)).log("Max stereo sources: {}"); - logger.atInfo().addArgument(() -> ALC10.alcGetInteger(device, ALC10.ALC_FREQUENCY)).log("Mixer frequency: {}"); + logger.info("Using OpenAL: {} by {}", AL10.alGetString(AL10.AL_RENDERER), AL10.alGetString(AL10.AL_VENDOR)); + logger.info("Using device: {}", ALC10.alcGetString(device, ALC10.ALC_DEVICE_SPECIFIER)); + logger.info("Available AL extensions: {}", AL10.alGetString(AL10.AL_EXTENSIONS)); + logger.info("Available ALC extensions: {}", ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS)); + logger.info("Max mono sources: {}", ALC10.alcGetInteger(device, ALC11.ALC_MONO_SOURCES)); + logger.info("Max stereo sources: {}", ALC10.alcGetInteger(device, ALC11.ALC_STEREO_SOURCES)); + logger.info("Mixer frequency: {}", ALC10.alcGetInteger(device, ALC10.ALC_FREQUENCY)); AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED); diff --git a/engine/src/main/java/org/terasology/engine/persistence/internal/GlobalStoreLoader.java b/engine/src/main/java/org/terasology/engine/persistence/internal/GlobalStoreLoader.java index 998a88d16e7..c2fdbe89e6d 100644 --- a/engine/src/main/java/org/terasology/engine/persistence/internal/GlobalStoreLoader.java +++ b/engine/src/main/java/org/terasology/engine/persistence/internal/GlobalStoreLoader.java @@ -16,6 +16,7 @@ import org.terasology.engine.persistence.serializers.EntitySerializer; import org.terasology.engine.persistence.serializers.PersistenceComponentSerializeCheck; import org.terasology.engine.persistence.serializers.PrefabSerializer; +import org.terasology.engine.persistence.typeHandling.extensionTypes.ComponentClassTypeHandler; import org.terasology.engine.utilities.Assets; import org.terasology.gestalt.assets.ResourceUrn; import org.terasology.gestalt.entitysystem.component.Component; @@ -108,11 +109,12 @@ private Prefab createPrefab(EntityData.Prefab prefabData) { private void loadComponentMapping(EntityData.GlobalStore globalStore) { Map, Integer> componentIdTable = Maps.newHashMap(); for (int index = 0; index < globalStore.getComponentClassCount(); ++index) { - ComponentMetadata componentMetadata = componentLibrary.resolve(globalStore.getComponentClass(index)); + String componentClass = globalStore.getComponentClass(index); + ComponentMetadata componentMetadata = componentLibrary.resolve(componentClass); if (componentMetadata != null) { componentIdTable.put(componentMetadata.getType(), index); } else { - logger.atWarn().addArgument(globalStore.getComponentClass(index)).log("Unable to resolve component '{}'"); + logger.warn("Unable to resolve component '{}'", componentClass); } }