diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/profile/Profile.java b/PlayWallCore/src/main/java/de/tobias/playpad/profile/Profile.java index 0da445bba994eb1a30931b8d2cff359bf202eeb4..c7e129bb30fa68e406aac41b575962194d0773e1 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/profile/Profile.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/profile/Profile.java @@ -1,5 +1,6 @@ package de.tobias.playpad.profile; +import de.thecodelabs.logger.Logger; import de.thecodelabs.utils.application.App; import de.thecodelabs.utils.application.ApplicationUtils; import de.thecodelabs.utils.application.container.PathType; @@ -108,19 +109,23 @@ public class Profile { public void save() throws IOException { ref.getRequestedModules().clear(); - PlayPadPlugin.getImplementation().getSettingsListener().forEach(l -> - { + App app = ApplicationUtils.getApplication(); + + Path root = app.getPath(PathType.CONFIGURATION, ref.getFileName()); + if (Files.notExists(root)) { + Files.createDirectories(root); + } + + PlayPadPlugin.getImplementation().getSettingsListener().forEach(l -> { try { l.onSave(this); } catch (Exception ex) { - ex.printStackTrace(); + Logger.error(ex); } }); - App app = ApplicationUtils.getApplication(); - Path root = app.getPath(PathType.CONFIGURATION, ref.getFileName()); - if (Files.notExists(root)) - Files.createDirectories(root); + // Add audio settings to module list + ref.addRequestedModule(PlayPadPlugin.getRegistryCollection().getAudioHandlers().getModule(profileSettings.getAudioClass())); profileSettings.save(getProfilePath(PROFILE_SETTINGS_XML)); mappings.save(getProfilePath(MAPPING_XML)); diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/profile/ProfileSettings.java b/PlayWallCore/src/main/java/de/tobias/playpad/profile/ProfileSettings.java index d65ddf19275d0e623b5359af8bf77bf8d6ced663..f0b4ec276236695899880d84a4ac105363551f25 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/profile/ProfileSettings.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/profile/ProfileSettings.java @@ -1,5 +1,6 @@ package de.tobias.playpad.profile; +import de.thecodelabs.logger.Logger; import de.thecodelabs.storage.settings.UserDefaults; import de.thecodelabs.storage.settings.annotation.Key; import de.tobias.playpad.PlayPadPlugin; @@ -24,11 +25,10 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; +import java.util.Map; public class ProfileSettings { - private static final long serialVersionUID = 1L; - @Key private BooleanProperty lockedProperty = new SimpleBooleanProperty(false); @@ -42,7 +42,7 @@ public class ProfileSettings { @Key private String audioClass = PlayPadPlugin.getRegistryCollection().getAudioHandlers().getDefaultID(); @Key - private HashMap<String, Object> audioUserInfo = new HashMap<>(); + private Map<String, Object> audioUserInfo = new HashMap<>(); // Layout @Key @@ -65,7 +65,7 @@ public class ProfileSettings { @Key private Fade fade = new Fade(); @Key - private TimeMode player_timeDisplayMode = TimeMode.REST; + private TimeMode playerTimeDisplayMode = TimeMode.REST; public boolean isLocked() { return lockedProperty.get(); @@ -113,14 +113,14 @@ public class ProfileSettings { } public TimeMode getPlayerTimeDisplayMode() { - return player_timeDisplayMode; + return playerTimeDisplayMode; } public String getAudioClass() { return audioClass; } - public HashMap<String, Object> getAudioUserInfo() { + public Map<String, Object> getAudioUserInfo() { return audioUserInfo; } @@ -161,8 +161,8 @@ public class ProfileSettings { this.fade = fade; } - public void setPlayerTimeDisplayMode(TimeMode player_timeDisplayMode) { - this.player_timeDisplayMode = player_timeDisplayMode; + public void setPlayerTimeDisplayMode(TimeMode playerTimeDisplayMode) { + this.playerTimeDisplayMode = playerTimeDisplayMode; } public void setAudioClass(String audioClass) { @@ -242,7 +242,7 @@ public class ProfileSettings { TimeMode timeMode = TimeMode.valueOf(root.element(TIME_DISPLAY_ELEMENT).getStringValue()); profileSettings.setPlayerTimeDisplayMode(timeMode); } catch (Exception e) { - e.printStackTrace(); + Logger.error(e); } } @@ -286,7 +286,7 @@ public class ProfileSettings { root.addElement(WARNING_ELEMENT).addText(warningTime.toString()); fade.save(root.addElement(FADE_ELEMENT)); - root.addElement(TIME_DISPLAY_ELEMENT).addText(player_timeDisplayMode.name()); + root.addElement(TIME_DISPLAY_ELEMENT).addText(playerTimeDisplayMode.name()); root.addElement(MULTIPLE_PLAYER_ELEMENT).addText(String.valueOf(multiplePlayer));