Skip to content

Commit

Permalink
Make mcMMO quieter by moving most log messages to debug only
Browse files Browse the repository at this point in the history
  • Loading branch information
nossr50 committed Jun 19, 2023
1 parent e39022c commit 019d22d
Show file tree
Hide file tree
Showing 46 changed files with 175 additions and 125 deletions.
4 changes: 4 additions & 0 deletions Changelog.txt
@@ -1,3 +1,7 @@
Version 2.1.222
A lot of mcMMO logging was moved from INFO to DEBUG, this should reduce the amount of noise in your logs and console

NOTES: If you want to see all logging messages, modify config.yml and set General.Verbose_Logging to true
Version 2.1.221
PAPI Support is now built into mcMMO and loads when mcMMO loads (as long as you have PAPI running)
Fixed blast mining bonus drops not working (Thanks warriiorrrr)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.221</version>
<version>2.1.222-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>
Expand Down
@@ -1,10 +1,8 @@
package com.gmail.nossr50.api;

import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeEvent;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.jetbrains.annotations.NotNull;

public class TreeFellerBlockBreakEvent extends FakeBlockBreakEvent {
Expand Down
@@ -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;
Expand Down Expand Up @@ -31,7 +32,7 @@ public AutoUpdateLegacyConfigLoader(String fileName) {

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) {
Expand All @@ -58,9 +59,9 @@ protected void loadFile() {
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);
}
}

Expand All @@ -73,7 +74,7 @@ protected void loadFile() {
}

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));
}

Expand Down
19 changes: 10 additions & 9 deletions src/main/java/com/gmail/nossr50/config/BukkitConfig.java
@@ -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;
Expand All @@ -22,15 +23,15 @@ 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;
configFile = new File(dataFolder, fileName);
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) {
Expand Down Expand Up @@ -81,10 +82,10 @@ private void copyMissingDefaultsFromResource() {
* 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;
}

Expand All @@ -109,11 +110,11 @@ YamlConfiguration saveDefaultConfigToDisk() {

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);

Expand Down Expand Up @@ -151,7 +152,7 @@ protected boolean noErrorsInConfig(List<String> issues) {

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);
Expand All @@ -160,8 +161,8 @@ protected void validate() {
}

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"));

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/gmail/nossr50/config/GeneralConfig.java
Expand Up @@ -1005,4 +1005,8 @@ public int getPowerLevelUpBroadcastInterval() {
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);
}
}
@@ -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;

Expand Down Expand Up @@ -46,15 +47,15 @@ public LegacyConfigLoader(String fileName) {

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
} catch (IllegalArgumentException ex) {
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);
Expand All @@ -76,7 +77,7 @@ protected boolean noErrorsInConfig(List<String> issues) {

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);
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/gmail/nossr50/config/RankConfig.java
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down Expand Up @@ -130,7 +131,7 @@ private void resetRankValue(@NotNull SubSkillType subSkillType, int rank, boolea
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);
}

/**
Expand All @@ -147,10 +148,10 @@ private void checkKeys(@NotNull List<String> reasons) {
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);
}
}
Expand Down Expand Up @@ -178,7 +179,7 @@ private void checkConfig(@NotNull List<String> reasons, @NotNull HashSet<SubSkil

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);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/gmail/nossr50/config/SoundConfig.java
@@ -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 {
Expand Down Expand Up @@ -28,14 +29,14 @@ protected void loadKeys() {
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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/gmail/nossr50/config/WorldBlacklist.java
Expand Up @@ -73,7 +73,8 @@ private void loadBlacklist(File blackListFile) {
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) {
Expand Down
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down Expand Up @@ -100,7 +101,7 @@ private void loadPotionMap() {
}
}

mcMMO.p.debug("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
LogUtils.debug(mcMMO.p.getLogger(), "Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
}

/**
Expand Down
Expand Up @@ -7,6 +7,7 @@
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;
Expand Down Expand Up @@ -48,7 +49,7 @@ protected void loadKeys() {
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;
}
Expand Down Expand Up @@ -160,8 +161,8 @@ protected void loadKeys() {
}
}

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.");
}
}

Expand Down
Expand Up @@ -8,13 +8,15 @@
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;
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;
Expand All @@ -41,17 +43,17 @@ protected void loadKeys() {
//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
}

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();
}
}
Expand Down Expand Up @@ -178,8 +180,8 @@ protected void loadKeys() {
}
}

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.");
}
}

Expand Down
Expand Up @@ -4,6 +4,7 @@
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;
Expand Down Expand Up @@ -332,7 +333,7 @@ private void matchAndFillSet(@NotNull List<String> enchantListStr, @NotNull Set<
}

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);
}
}
}
Expand Down

0 comments on commit 019d22d

Please sign in to comment.