From 0bba99f1da56160ad66ded54b4bd48ec31cc69a9 Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sun, 25 Jul 2021 11:50:22 +0200 Subject: [PATCH] Cleanup Config.java --- .../Minepacks/Bukkit/Database/Config.java | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java index 728c8dd..017dca1 100644 --- a/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java +++ b/Minepacks/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java @@ -43,6 +43,7 @@ import java.io.FileNotFoundException; import java.util.*; +import java.util.logging.Level; import java.util.stream.Collectors; public class Config extends Configuration implements DatabaseConnectionConfiguration, IUnCacheStrategyConfig, ILanguageConfiguration @@ -171,7 +172,7 @@ public boolean getUseUUIDSeparators() public String getBPTitleOther() { - return ChatColor.translateAlternateColorCodes('&', getConfigE().getString("BackpackTitleOther", "{OwnerName} Backpack").replaceAll("%", "%%").replaceAll("\\{OwnerName}", "%s")); + return ChatColor.translateAlternateColorCodes('&', getConfigE().getString("BackpackTitleOther", "{OwnerName} Backpack").replace("%", "%%").replace("{OwnerName}", "%s")); } public String getBPTitle() @@ -228,7 +229,10 @@ public String getUpdateChannel() { return channel; } - else logger.info("Unknown update Channel: " + channel); + else + { + logger.log(Level.INFO, "Unknown update Channel: {0}", channel); + } return null; } @@ -291,9 +295,9 @@ public Collection getAllowedGameModes() gameModes.add(gm); } } - if(gameModes.size() < 1) + if(gameModes.isEmpty()) { - logger.info("No game-mode's allowed, allowing: " + GameMode.SURVIVAL.name()); + logger.log(Level.INFO, "No game-mode's allowed, allowing: {0}", GameMode.SURVIVAL); gameModes.add(GameMode.SURVIVAL); } return gameModes; @@ -332,14 +336,19 @@ public boolean isShulkerboxesDisable() return MCVersion.isNewerOrEqualThan(MCVersion.MC_1_11) && getConfigE().getBoolean("Shulkerboxes.DisableShulkerboxes", false); } + private String getShulkerboxesExisting() + { + return getConfigE().getString("Shulkerboxes.Existing", "Ignore"); + } + public boolean isShulkerboxesExistingDropEnabled() { - return getConfigE().getString("Shulkerboxes.Existing", "Ignore").equalsIgnoreCase("Destroy"); + return getShulkerboxesExisting().equalsIgnoreCase("Destroy"); } public boolean isShulkerboxesExistingDestroyEnabled() { - return getConfigE().getString("Shulkerboxes.Existing", "Ignore").equalsIgnoreCase("Destroy") || getConfigE().getString("Shulkerboxes.Existing", "Ignore").equalsIgnoreCase("Remove"); + return getShulkerboxesExisting().equalsIgnoreCase("Destroy") || getShulkerboxesExisting().equalsIgnoreCase("Remove"); } //endregion @@ -488,12 +497,18 @@ public boolean isItemShortcutPlayerDisableItemEnabled() public @Nullable Sound getOpenSound() { - return getSound("OpenSound", MCVersion.isNewerOrEqualThan(MCVersion.MC_1_11) ? "BLOCK_SHULKER_BOX_OPEN" : (MCVersion.isNewerOrEqualThan(MCVersion.MC_1_9_2) ? "BLOCK_CHEST_OPEN" : "CHEST_OPEN")); + String defaultSound = "CHEST_OPEN"; + if (MCVersion.isNewerOrEqualThan(MCVersion.MC_1_11)) defaultSound = "BLOCK_SHULKER_BOX_OPEN"; + else if (MCVersion.isNewerOrEqualThan(MCVersion.MC_1_9_2)) defaultSound = "BLOCK_CHEST_OPEN"; + return getSound("OpenSound", defaultSound); } public @Nullable Sound getCloseSound() { - return getSound("CloseSound", MCVersion.isNewerOrEqualThan(MCVersion.MC_1_11) ? "BLOCK_SHULKER_BOX_CLOSE" : (MCVersion.isNewerOrEqualThan(MCVersion.MC_1_9_2) ? "BLOCK_CHEST_CLOSE" : "CHEST_CLOSE")); + String defaultSound = "CHEST_CLOSE"; + if (MCVersion.isNewerOrEqualThan(MCVersion.MC_1_11)) defaultSound = "BLOCK_SHULKER_BOX_CLOSE"; + else if (MCVersion.isNewerOrEqualThan(MCVersion.MC_1_9_2)) defaultSound = "BLOCK_CHEST_CLOSE"; + return getSound("CloseSound", defaultSound); } public @Nullable Sound getAutoCollectSound()