Make mcMMO quieter by moving most log messages to debug only

This commit is contained in:
nossr50
2023-06-19 16:26:30 -07:00
parent e39022cc64
commit 019d22d92a
46 changed files with 175 additions and 125 deletions

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -31,7 +32,7 @@ public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader {
protected void saveConfig() {
try {
mcMMO.p.getLogger().info("Saving changes to config file - " + fileName);
LogUtils.debug(mcMMO.p.getLogger(), "Saving changes to config file - " + fileName);
config.options().indent(2);
config.save(configFile);
} catch (IOException e) {
@@ -58,9 +59,9 @@ public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader {
oldKeys.removeAll(internalConfigKeys);
if (!oldKeys.isEmpty()) {
mcMMO.p.debug("old key(s) in \"" + fileName + "\"");
LogUtils.debug(mcMMO.p.getLogger(), "old key(s) in \"" + fileName + "\"");
for (String key : oldKeys) {
mcMMO.p.debug(" old-key:" + key);
LogUtils.debug(mcMMO.p.getLogger(), " old-key:" + key);
}
}
@@ -73,7 +74,7 @@ public abstract class AutoUpdateLegacyConfigLoader extends LegacyConfigLoader {
}
for (String key : newKeys) {
mcMMO.p.debug("Adding new key: " + key + " = " + internalConfig.get(key));
LogUtils.debug(mcMMO.p.getLogger(), "Adding new key: " + key + " = " + internalConfig.get(key));
config.set(key, internalConfig.get(key));
}

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -22,7 +23,7 @@ public abstract class BukkitConfig {
private boolean savedDefaults = false;
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder, boolean copyDefaults) {
mcMMO.p.getLogger().info("[config] Initializing config: " + fileName);
LogUtils.debug(mcMMO.p.getLogger(), "Initializing config: " + fileName);
this.copyDefaults = copyDefaults;
this.fileName = fileName;
this.dataFolder = dataFolder;
@@ -30,7 +31,7 @@ public abstract class BukkitConfig {
this.defaultYamlConfig = saveDefaultConfigToDisk();
this.config = initConfig();
updateFile();
mcMMO.p.getLogger().info("[config] Config initialized: " + fileName);
LogUtils.debug(mcMMO.p.getLogger(), "Config initialized: " + fileName);
}
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) {
@@ -81,10 +82,10 @@ public abstract class BukkitConfig {
* Copies the config from the JAR to defaults/<fileName>
*/
YamlConfiguration saveDefaultConfigToDisk() {
mcMMO.p.getLogger().info("[config] Copying default config to disk: " + fileName + " to defaults/" + fileName);
LogUtils.debug(mcMMO.p.getLogger(), "Copying default config to disk: " + fileName + " to defaults/" + fileName);
try(InputStream inputStream = mcMMO.p.getResource(fileName)) {
if(inputStream == null) {
mcMMO.p.getLogger().severe("[config] Unable to copy default config: " + fileName);
mcMMO.p.getLogger().severe("Unable to copy default config: " + fileName);
return null;
}
@@ -109,11 +110,11 @@ public abstract class BukkitConfig {
YamlConfiguration initConfig() {
if (!configFile.exists()) {
mcMMO.p.getLogger().info("[config] User config file not found, copying a default config to disk: " + fileName);
LogUtils.debug(mcMMO.p.getLogger(), "User config file not found, copying a default config to disk: " + fileName);
mcMMO.p.saveResource(fileName, false);
}
mcMMO.p.getLogger().info("[config] Loading config from disk: " + fileName);
LogUtils.debug(mcMMO.p.getLogger(), "Loading config from disk: " + fileName);
YamlConfiguration config = new YamlConfiguration();
config.options().indent(4);
@@ -151,7 +152,7 @@ public abstract class BukkitConfig {
protected void validate() {
if (validateKeys()) {
mcMMO.p.debug("No errors found in " + fileName + "!");
LogUtils.debug(mcMMO.p.getLogger(), "No errors found in " + fileName + "!");
} else {
mcMMO.p.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
mcMMO.p.getServer().getPluginManager().disablePlugin(mcMMO.p);
@@ -160,8 +161,8 @@ public abstract class BukkitConfig {
}
public void backup() {
mcMMO.p.getLogger().info("You are using an old version of the " + fileName + " file.");
mcMMO.p.getLogger().info("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
LogUtils.debug(mcMMO.p.getLogger(), "You are using an old version of the " + fileName + " file.");
LogUtils.debug(mcMMO.p.getLogger(), "Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
configFile.renameTo(new File(configFile.getPath() + ".old"));

View File

@@ -1005,4 +1005,8 @@ public class GeneralConfig extends BukkitConfig {
public boolean isGreenThumbReplantableCrop(@NotNull Material material) {
return config.getBoolean("Green_Thumb_Replanting_Crops." + StringUtils.getCapitalized(material.toString()), true);
}
public boolean useVerboseLogging() {
return config.getBoolean("General.Verbose_Logging", false);
}
}

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
@@ -46,7 +47,7 @@ public abstract class LegacyConfigLoader {
protected void loadFile() {
if (!configFile.exists()) {
mcMMO.p.getLogger().info("Creating mcMMO " + fileName + " File...");
LogUtils.debug(mcMMO.p.getLogger(), "Creating mcMMO " + fileName + " File...");
try {
mcMMO.p.saveResource(fileName, false); // Normal files
@@ -54,7 +55,7 @@ public abstract class LegacyConfigLoader {
mcMMO.p.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
}
} else {
mcMMO.p.getLogger().info("Loading mcMMO " + fileName + " File...");
LogUtils.debug(mcMMO.p.getLogger(), "Loading mcMMO " + fileName + " File...");
}
config = YamlConfiguration.loadConfiguration(configFile);
@@ -76,7 +77,7 @@ public abstract class LegacyConfigLoader {
protected void validate() {
if (validateKeys()) {
mcMMO.p.debug("No errors found in " + fileName + "!");
LogUtils.debug(mcMMO.p.getLogger(), "No errors found in " + fileName + "!");
} else {
mcMMO.p.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
mcMMO.p.getServer().getPluginManager().disablePlugin(mcMMO.p);

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@@ -130,7 +131,7 @@ public class RankConfig extends BukkitConfig {
String key = getRankAddressKey(subSkillType, rank, retroMode);
int defaultValue = defaultYamlConfig.getInt(key);
config.set(key, defaultValue);
mcMMO.p.getLogger().info(key + " SET -> " + defaultValue);
LogUtils.debug(mcMMO.p.getLogger(), key + " SET -> " + defaultValue);
}
/**
@@ -147,10 +148,10 @@ public class RankConfig extends BukkitConfig {
if (badSkillSetup.isEmpty())
return;
mcMMO.p.getLogger().info("(FIXING CONFIG) mcMMO is correcting a few mistakes found in your skill rank config setup");
LogUtils.debug(mcMMO.p.getLogger(), "(FIXING CONFIG) mcMMO is correcting a few mistakes found in your skill rank config setup");
for (SubSkillType subSkillType : badSkillSetup) {
mcMMO.p.getLogger().info("(FIXING CONFIG) Resetting rank config settings for skill named - " + subSkillType.toString());
LogUtils.debug(mcMMO.p.getLogger(), "(FIXING CONFIG) Resetting rank config settings for skill named - " + subSkillType.toString());
fixBadEntries(subSkillType);
}
}
@@ -178,7 +179,7 @@ public class RankConfig extends BukkitConfig {
if (prevRank > curRank) {
//We're going to allow this but we're going to warn them
mcMMO.p.getLogger().info("(CONFIG ISSUE) You have the ranks for the subskill " + subSkillType + " set up poorly, sequential ranks should have ascending requirements");
LogUtils.debug(mcMMO.p.getLogger(), "(CONFIG ISSUE) You have the ranks for the subskill " + subSkillType + " set up poorly, sequential ranks should have ascending requirements");
badSkillSetup.add(subSkillType);
}
}

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.sounds.SoundType;
public class SoundConfig extends BukkitConfig {
@@ -28,14 +29,14 @@ public class SoundConfig extends BukkitConfig {
protected boolean validateKeys() {
for (SoundType soundType : SoundType.values()) {
if (config.getDouble("Sounds." + soundType.toString() + ".Volume") < 0) {
mcMMO.p.getLogger().info("[mcMMO] Sound volume cannot be below 0 for " + soundType);
LogUtils.debug(mcMMO.p.getLogger(), "[mcMMO] Sound volume cannot be below 0 for " + soundType);
return false;
}
//Sounds with custom pitching don't use pitch values
if (!soundType.usesCustomPitch()) {
if (config.getDouble("Sounds." + soundType + ".Pitch") < 0) {
mcMMO.p.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for " + soundType);
LogUtils.debug(mcMMO.p.getLogger(), "[mcMMO] Sound pitch cannot be below 0 for " + soundType);
return false;
}
}

View File

@@ -73,7 +73,8 @@ public class WorldBlacklist {
closeRead(fileReader);
}
plugin.getLogger().info(blacklist.size() + " entries in mcMMO World Blacklist");
if(blacklist.size() > 0)
plugin.getLogger().info(blacklist.size() + " entries in mcMMO World Blacklist");
}
private void closeRead(Reader reader) {

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.config.skills.alchemy;
import com.gmail.nossr50.config.LegacyConfigLoader;
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
@@ -100,7 +101,7 @@ public class PotionConfig extends LegacyConfigLoader {
}
}
mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
LogUtils.debug(mcMMO.p.getLogger(), "Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
}
/**

View File

@@ -7,6 +7,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.LogUtils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
@@ -48,7 +49,7 @@ public class RepairConfig extends BukkitConfig {
Material itemMaterial = Material.matchMaterial(key);
if (itemMaterial == null) {
//mcMMO.p.getLogger().info("No support for repair item "+key+ " in this version of Minecraft, skipping.");
//LogUtils.debug(mcMMO.p.getLogger(), "No support for repair item "+key+ " in this version of Minecraft, skipping.");
notSupported.add(key); //Collect names of unsupported items
continue;
}
@@ -160,8 +161,8 @@ public class RepairConfig extends BukkitConfig {
}
}
mcMMO.p.getLogger().info(stringBuilder.toString());
mcMMO.p.getLogger().info("Items using materials that are not supported will simply be skipped.");
LogUtils.debug(mcMMO.p.getLogger(), stringBuilder.toString());
LogUtils.debug(mcMMO.p.getLogger(), "Items using materials that are not supported will simply be skipped.");
}
}

View File

@@ -8,6 +8,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@@ -15,6 +16,7 @@ import org.bukkit.inventory.ItemStack;
import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
public class SalvageConfig extends BukkitConfig {
private final HashSet<String> notSupported;
@@ -41,7 +43,7 @@ public class SalvageConfig extends BukkitConfig {
//Original version of 1.16 support had maximum quantities that were bad, this fixes it
if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES)) {
mcMMO.p.getLogger().info("Fixing incorrect Salvage quantities on Netherite gear, this will only run once...");
mcMMO.p.getLogger().log(Level.INFO, "Fixing incorrect Salvage quantities on Netherite gear, this will only run once...");
for (String namespacedkey : mcMMO.getMaterialMapStore().getNetheriteArmor()) {
config.set("Salvageables." + namespacedkey.toUpperCase() + ".MaximumQuantity", 4); //TODO: Doesn't make sense to default to 4 for everything
}
@@ -49,9 +51,9 @@ public class SalvageConfig extends BukkitConfig {
try {
config.save(getFile());
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES);
mcMMO.p.getLogger().info("Fixed incorrect Salvage quantities for Netherite gear!");
LogUtils.debug(mcMMO.p.getLogger(), "Fixed incorrect Salvage quantities for Netherite gear!");
} catch (IOException e) {
mcMMO.p.getLogger().info("Unable to fix Salvage config, please delete the salvage yml file to generate a new one.");
LogUtils.debug(mcMMO.p.getLogger(), "Unable to fix Salvage config, please delete the salvage yml file to generate a new one.");
e.printStackTrace();
}
}
@@ -178,8 +180,8 @@ public class SalvageConfig extends BukkitConfig {
}
}
mcMMO.p.getLogger().info(stringBuilder.toString());
mcMMO.p.getLogger().info("Items using materials that are not supported will simply be skipped.");
LogUtils.debug(mcMMO.p.getLogger(), stringBuilder.toString());
LogUtils.debug(mcMMO.p.getLogger(), "Items using materials that are not supported will simply be skipped.");
}
}

View File

@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.BukkitConfig;
import com.gmail.nossr50.datatypes.treasure.*;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EnchantmentUtils;
import com.gmail.nossr50.util.LogUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@@ -332,7 +333,7 @@ public class FishingTreasureConfig extends BukkitConfig {
}
if (!foundMatch) {
mcMMO.p.getLogger().info("[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: " + str);
LogUtils.debug(mcMMO.p.getLogger(), "[Fishing Treasure Init] Could not find any enchantments which matched the user defined enchantment named: " + str);
}
}
}

View File

@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.BukkitConfig;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -272,14 +273,14 @@ public class TreasureConfig extends BukkitConfig {
case LEGACY:
int legacyDropLevel = getWrongKeyValue(type, treasureName, conversionType); //Legacy only had one value, Retro Mode didn't have a setting
//Config needs to be updated to be more specific
mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: Legacy] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
LogUtils.debug(mcMMO.p.getLogger(), "(" + treasureName + ") [Fixing bad address: Legacy] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
config.set(type + "." + treasureName + LEGACY_DROP_LEVEL, null); //Remove legacy entry
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, legacyDropLevel * 10); //Multiply by 10 for Retro
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, legacyDropLevel);
shouldWeUpdateTheFile = true;
break;
case WRONG_KEY_STANDARD:
mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: STANDARD] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
LogUtils.debug(mcMMO.p.getLogger(), "(" + treasureName + ") [Fixing bad address: STANDARD] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
int wrongKeyValueStandard = getWrongKeyValue(type, treasureName, conversionType);
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed
@@ -291,7 +292,7 @@ public class TreasureConfig extends BukkitConfig {
shouldWeUpdateTheFile = true;
break;
case WRONG_KEY_RETRO:
mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: RETRO] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
LogUtils.debug(mcMMO.p.getLogger(), "(" + treasureName + ") [Fixing bad address: RETRO] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
int wrongKeyValueRetro = getWrongKeyValue(type, treasureName, conversionType);
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed