diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index eedb1cb4e..91bcb10af 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -38,9 +38,7 @@ dependencies { compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false } compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false } // logging - implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.13.3') - implementation('org.apache.logging.log4j:log4j-core:2.13.3') - implementation('org.apache.logging.log4j:log4j-api:2.13.3') + implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1') } sourceCompatibility = 1.8 @@ -99,19 +97,18 @@ shadowJar { include(dependency("org.bstats:bstats-bukkit:1.7")) include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT")) include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT")) - include(dependency("org.slf4j:slf4j-jdk14:2.0.0-alpha1")) - include(dependency('org.apache.logging.log4j:log4j-slf4j-impl:2.13.3')) - include(dependency('org.apache.logging.log4j:log4j-core:2.13.3')) - include(dependency('org.apache.logging.log4j:log4j-api:2.13.3')) - include(dependency('org.slf4j:slf4j-api:1.7.26')) + include(dependency('org.apache.logging.log4j:log4j-slf4j-impl')) + include(dependency('org.slf4j:slf4j-api')) } relocate('net.kyori.text', 'com.plotsquared.formatting.text') relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib") relocate("org.bstats", "com.plotsquared.metrics") relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid') relocate('org.khelekore.prtree', 'com.plotsquared.prtree') - // relocate('org.apache.logging', 'com.plotsquared.logging.apache') - // relocate('org.slf4j', 'com.plotsquared.logging.slf4j') + relocate('org.apache.logging.slf4j', 'com.plotsquared.logging.apache') + relocate('org.slf4j', 'com.plotsquared.logging.slf4j') + + archiveFileName = "${project.name}-${parent.version}.jar" destinationDirectory = file "../target" } diff --git a/Bukkit/pom.xml b/Bukkit/pom.xml index 81b4e9cf2..f06146a52 100644 --- a/Bukkit/pom.xml +++ b/Bukkit/pom.xml @@ -167,19 +167,7 @@ org.apache.logging.log4j log4j-slf4j-impl - 2.13.3 - runtime - - - org.apache.logging.log4j - log4j-core - 2.13.3 - runtime - - - org.apache.logging.log4j - log4j-api - 2.13.3 + 2.8.1 runtime diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 1c9588b90..ca3406018 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -101,7 +101,6 @@ import com.plotsquared.core.util.ReflectionUtils; import com.plotsquared.core.util.RegionManager; import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SetupUtils; -import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.uuid.CacheUUIDService; @@ -161,7 +160,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass; public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { - private static final Logger logger = LoggerFactory.getLogger(BukkitMain.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitMain.class.getSimpleName()); private static final int BSTATS_ID = 1404; @Getter private static WorldEdit worldEdit; @@ -195,8 +194,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain< } } catch (NumberFormatException e) { e.printStackTrace(); - logger.debug(StringMan.getString(Bukkit.getBukkitVersion())); - logger.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\."))); return new int[] {1, 13, 0}; } } @@ -445,7 +442,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain< final Chunk[] chunks = world.getLoadedChunks(); if (chunks.length == 0) { if (!Bukkit.unloadWorld(world, true)) { - logger.debug("Failed to unload {}", world.getName()); + logger.warn("Failed to unload {}", world.getName()); } return; } else { @@ -536,7 +533,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain< uuidList.clear(); // Print progress final double percentage = ((double) read / (double) totalSize) * 100.0D; - logger.debug("(UUID) PlotSquared has cached {} of UUIDs", String.format("%.1f%%", percentage)); + if (Settings.DEBUG) { + logger.info("(UUID) PlotSquared has cached {} of UUIDs", String.format("%.1f%%", percentage)); + } } catch (final InterruptedException | ExecutionException e) { logger.error("(UUID) Failed to retrieve last batch. Will try again", e); e.printStackTrace(); @@ -897,7 +896,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain< return econ; } } catch (Throwable ignored) { - logger.debug("No economy handler detected"); } return null; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java index 9320fa39e..253de36ae 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java @@ -25,6 +25,7 @@ */ package com.plotsquared.bukkit.entity; +import com.plotsquared.core.configuration.Settings; import org.bukkit.Art; import org.bukkit.DyeColor; import org.bukkit.Location; @@ -61,7 +62,7 @@ import java.util.List; public final class ReplicatingEntityWrapper extends EntityWrapper { - private static final Logger logger = LoggerFactory.getLogger(ReplicatingEntityWrapper.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + ReplicatingEntityWrapper.class.getSimpleName()); private final short depth; private final int hash; @@ -331,10 +332,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { this.dataByte = (byte) 0; } storeLiving((LivingEntity) entity); - return; // END LIVING // - default: - logger.debug("Could not identify entity: {}", entity.getType()); } } @@ -733,7 +731,9 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { restoreLiving((LivingEntity) entity); return entity; default: - logger.debug("Could not identify entity: {}", entity.getType()); + if (Settings.DEBUG) { + logger.info("Could not identify entity: {}", entity.getType()); + } return entity; // END LIVING } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java index feab438f6..39384ad0f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java @@ -62,7 +62,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass; @SuppressWarnings("unused") public class ChunkListener implements Listener { - private static final Logger logger = LoggerFactory.getLogger(ChunkListener.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + ChunkListener.class.getSimpleName()); private RefMethod methodGetHandleChunk; private RefField mustSave; @@ -294,12 +294,9 @@ public class ChunkListener implements Listener { toRemove--; } } - - logger.debug("PlotSquared detected chunk and processed it: {},{}", chunk.getX() << 4, chunk.getZ() << 4); } if (tiles.length > Settings.Chunk_Processor.MAX_TILES) { if (unload) { - logger.debug("PlotSquared detected chunk: {},{}", chunk.getX() << 4, chunk.getZ() << 4); cleanChunk(chunk); return true; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java index f54cedccf..0c1bd798b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java @@ -76,7 +76,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE; public class BukkitRegionManager extends RegionManager { - private static final Logger logger = LoggerFactory.getLogger(BukkitRegionManager.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitRegionManager.class.getSimpleName()); public static boolean isIn(CuboidRegion region, int x, int z) { return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX() @@ -93,8 +93,6 @@ public class BukkitRegionManager extends RegionManager { } else { final Semaphore semaphore = new Semaphore(1); try { - logger.debug("Attempting to make an asynchronous call to getLoadedChunks." - + " Will halt the calling thread until completed."); semaphore.acquire(); Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () -> { for (Chunk chunk : Objects.requireNonNull(Bukkit.getWorld(world)) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index 373dac19a..286458614 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -112,7 +112,7 @@ import java.util.stream.Stream; @SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil { - private static final Logger logger = LoggerFactory.getLogger(BukkitUtil.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitUtil.class.getSimpleName()); private static String lastString = null; private static World lastWorld = null; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java index 3563b125b..78d941808 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java @@ -47,7 +47,7 @@ import java.util.Set; public class ContentMap { - private static final Logger logger = LoggerFactory.getLogger(ContentMap.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + ContentMap.class.getSimpleName()); final Set entities; final Map allBlocks; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/UpdateUtility.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/UpdateUtility.java index d3ed81cb8..c28fe8740 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/UpdateUtility.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/UpdateUtility.java @@ -45,7 +45,7 @@ import java.net.URL; public class UpdateUtility implements Listener { - private static final Logger logger = LoggerFactory.getLogger(UpdateUtility.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + UpdateUtility.class.getSimpleName()); public static PlotVersion internalVersion; public static String spigotVersion; diff --git a/Core/build.gradle b/Core/build.gradle index 0f3e54412..3b3779868 100644 --- a/Core/build.gradle +++ b/Core/build.gradle @@ -19,9 +19,7 @@ dependencies { implementation("org.jetbrains:annotations:19.0.0") implementation("org.khelekore:prtree:1.7.0-SNAPSHOT") // logging - implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.13.3') - implementation('org.apache.logging.log4j:log4j-core:2.13.3') - implementation('org.apache.logging.log4j:log4j-api:2.13.3') + implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") } sourceCompatibility = 1.8 diff --git a/Core/pom.xml b/Core/pom.xml index 75d0d059e..f69929bfa 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -101,19 +101,7 @@ org.apache.logging.log4j log4j-slf4j-impl - 2.13.3 - runtime - - - org.apache.logging.log4j - log4j-core - 2.13.3 - runtime - - - org.apache.logging.log4j - log4j-api - 2.13.3 + 2.8.1 runtime diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index f8f38e963..4c50026e4 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -27,7 +27,6 @@ package com.plotsquared.core; import com.plotsquared.core.command.WE_Anywhere; import com.plotsquared.core.components.ComponentPresetManager; -import com.plotsquared.core.configuration.Caption; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationUtil; @@ -137,7 +136,8 @@ import java.util.zip.ZipInputStream; @SuppressWarnings({"unused", "WeakerAccess"}) public class PlotSquared { - private static final Logger logger = LoggerFactory.getLogger(PlotSquared.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotSquared.class.getSimpleName()); + private static final Set EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet()); private static PlotSquared instance; // Implementation @@ -196,9 +196,9 @@ public class PlotSquared { try { new ReflectionUtils(this.IMP.getNMSPackage()); try { - URL url = PlotSquared.class.getProtectionDomain().getCodeSource().getLocation(); + URL logurl = PlotSquared.class.getProtectionDomain().getCodeSource().getLocation(); this.jarFile = new File( - new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")) + new URL(logurl.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")) .toURI().getPath()); } catch (MalformedURLException | URISyntaxException | SecurityException e) { e.printStackTrace(); @@ -329,11 +329,11 @@ public class PlotSquared { continue; } if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) { - logger.debug("`{}` was not properly loaded - {} will now try to load it properly", + logger.warn("`{}` was not properly loaded - {} will now try to load it properly", world, imp().getPluginName()); - logger.debug(" - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml"); - logger.debug(" - Your world management plugin may be faulty (or non existent)"); - logger.debug(" This message may also be a false positive and could be ignored."); + logger.warn(" - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml"); + logger.warn(" - Your world management plugin may be faulty (or non existent)"); + logger.warn(" This message may also be a false positive and could be ignored."); PlotSquared.this.IMP.setGenerator(world); } } @@ -364,7 +364,6 @@ public class PlotSquared { e.printStackTrace(); } - logger.debug("{} is now enabled!", imp().getPluginName()); } /** @@ -511,8 +510,8 @@ public class PlotSquared { chunkInts.forEach(l -> chunks.add(BlockVector2.at(l[0], l[1]))); int height = (int) list.get(2); logger.info("Incomplete road regeneration found. Restarting in world {} with height {}", plotArea.getWorldName(), height); - logger.debug(" Regions: {}", regions.size()); - logger.debug(" Chunks: {}", chunks.size()); + logger.info(" - Regions: {}", regions.size()); + logger.info(" - Chunks: {}", chunks.size()); HybridUtils.UPDATE = true; HybridUtils.manager.scheduleRoadUpdate(plotArea, regions, height, chunks); } catch (IOException | ClassNotFoundException e) { @@ -1079,7 +1078,6 @@ public class PlotSquared { } if (type == PlotAreaType.NORMAL) { if (plotAreaManager.getPlotAreas(world, null).length != 0) { - logger.debug("Would possibly already loaded: {}", world); return; } IndependentPlotGenerator plotGenerator; @@ -1132,7 +1130,6 @@ public class PlotSquared { ConfigurationSection areasSection = worldSection.getConfigurationSection("areas"); if (areasSection == null) { if (plotAreaManager.getPlotAreas(world, null).length != 0) { - logger.debug("World possibly already loaded: {}", world); return; } logger.info("Detected world load for '{}'", world); @@ -1765,7 +1762,7 @@ public class PlotSquared { if (Settings.DEBUG) { Map components = Settings.getFields(Settings.Enabled_Components.class); for (Entry component : components.entrySet()) { - logger.debug("Key: {} | Value: {}", component.getKey(), component.getValue()); + logger.info("Key: {} | Value: {}", component.getKey(), component.getValue()); } } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java index 02990a107..6dcda8c43 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -56,7 +56,7 @@ import org.slf4j.LoggerFactory; usage = "/plot claim") public class Claim extends SubCommand { - private static final Logger logger = LoggerFactory.getLogger(Claim.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + Claim.class.getSimpleName()); @Override public boolean onCommand(final PlotPlayer player, String[] args) { String schematic = null; diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java index 677003483..c395f09d8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -50,7 +50,7 @@ import java.util.Map; permission = "plots.admin") public class Debug extends SubCommand { - private static final Logger logger = LoggerFactory.getLogger(Debug.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + Debug.class.getSimpleName()); @Override public boolean onCommand(PlotPlayer player, String[] args) { if (args.length > 0) { diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java index 91b9fbf91..842d403b7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -84,7 +84,7 @@ import java.util.concurrent.CompletableFuture; category = CommandCategory.DEBUG) public class DebugExec extends SubCommand { - private static final Logger logger = LoggerFactory.getLogger(DebugExec.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + DebugExec.class.getSimpleName()); private ScriptEngine engine; private Bindings scope; diff --git a/Core/src/main/java/com/plotsquared/core/command/Purge.java b/Core/src/main/java/com/plotsquared/core/command/Purge.java index 8c155fff5..7d714a224 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Purge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Purge.java @@ -55,7 +55,7 @@ import java.util.concurrent.atomic.AtomicBoolean; confirmation = true) public class Purge extends SubCommand { - private static final Logger logger = LoggerFactory.getLogger(Purge.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + Purge.class.getSimpleName()); @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length == 0) { @@ -174,7 +174,9 @@ public class Purge extends SubCommand { "/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)"; boolean finalClear = clear; Runnable run = () -> { - logger.debug("Calculating plots to purge, please wait..."); + if (Settings.DEBUG) { + logger.info("Calculating plots to purge, please wait..."); + } HashSet ids = new HashSet<>(); Iterator iterator = toDelete.iterator(); AtomicBoolean cleared = new AtomicBoolean(true); @@ -187,8 +189,11 @@ public class Purge extends SubCommand { try { ids.add(plot.temp); if (finalClear) { - plot.clear(false, true, () -> - logger.debug("Plot {} cleared by purge", plot.getId())); + plot.clear(false, true, () -> { + if (Settings.DEBUG) { + logger.info("Plot {} cleared by purge", plot.getId()); + } + }); } else { plot.removeSign(); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Trim.java b/Core/src/main/java/com/plotsquared/core/command/Trim.java index d90277602..cd8e14434 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Trim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Trim.java @@ -64,7 +64,7 @@ import java.util.Set; category = CommandCategory.ADMINISTRATION) public class Trim extends SubCommand { - private static final Logger logger = LoggerFactory.getLogger(Trim.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + Trim.class.getSimpleName()); public static ArrayList expired = null; private static volatile boolean TASK = false; diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java index d6e13a278..76b4d8ab2 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java @@ -59,7 +59,7 @@ import java.util.stream.Collectors; public class ComponentPresetManager { - private static final Logger logger = LoggerFactory.getLogger(ComponentPresetManager.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + ComponentPresetManager.class.getSimpleName()); private final List presets; private final String guiName; diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Config.java b/Core/src/main/java/com/plotsquared/core/configuration/Config.java index 139e0dffd..3f75eb56f 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Config.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Config.java @@ -47,7 +47,7 @@ import java.util.Map; public class Config { - private static final Logger logger = LoggerFactory.getLogger(Config.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + Config.class.getSimpleName()); /** * Get the value for a node
@@ -71,7 +71,6 @@ public class Config { } } } - logger.debug("Failed to get config option: {}", key); return null; } @@ -99,12 +98,12 @@ public class Config { field.set(instance, value); return; } catch (final Throwable e) { - logger.debug("Invalid configuration value '{}: {}' in {}", key, value, root.getSimpleName()); + logger.error("Invalid configuration value '{}: {}' in {}", key, value, root.getSimpleName()); e.printStackTrace(); } } } - logger.debug("Failed to set config option '{}: {}' | {}", key, value, instance); + logger.error("Failed to set config option '{}: {}' | {}", key, value, instance); } public static boolean load(File file, Class root) { @@ -290,7 +289,7 @@ public class Config { setAccessible(field); return field; } catch (final Throwable e) { - logger.debug("Invalid config field: {} for {}", + logger.error("Invalid config field: {} for {}", StringMan.join(split, "."), toNodeName(instance.getClass().getSimpleName())); e.printStackTrace(); return null; diff --git a/Core/src/main/java/com/plotsquared/core/configuration/file/YamlConfiguration.java b/Core/src/main/java/com/plotsquared/core/configuration/file/YamlConfiguration.java index ee1dec7d5..027ee7d4c 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/file/YamlConfiguration.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/file/YamlConfiguration.java @@ -25,10 +25,10 @@ */ package com.plotsquared.core.configuration.file; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Configuration; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.InvalidConfigurationException; +import com.plotsquared.core.configuration.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.DumperOptions; @@ -48,7 +48,7 @@ import java.util.Map; */ public class YamlConfiguration extends FileConfiguration { - private static final Logger logger = LoggerFactory.getLogger(YamlConfiguration.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + YamlConfiguration.class.getSimpleName()); private static final String COMMENT_PREFIX = "# "; private static final String BLANK_CONFIG = "{}\n"; @@ -81,11 +81,13 @@ public class YamlConfiguration extends FileConfiguration { dest = new File(file.getAbsolutePath() + "_broken_" + i++); } Files.copy(file.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); - logger.debug("Could not read: {}", file); - logger.debug("Renamed to: {}", file); - logger.debug("============ Full stacktrace ============"); - ex.printStackTrace(); - logger.debug("========================================="); + if (Settings.DEBUG) { + logger.error("Could not read: {}", file); + logger.error("Renamed to: {}", file); + logger.error("============ Full stacktrace ============"); + ex.printStackTrace(); + logger.error("========================================="); + } } catch (IOException e) { e.printStackTrace(); } diff --git a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java index a58eec7f9..c2a363d6b 100644 --- a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java +++ b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java @@ -80,7 +80,7 @@ import java.util.concurrent.atomic.AtomicInteger; @SuppressWarnings("SqlDialectInspection") public class SQLManager implements AbstractDB { - private static final Logger logger = LoggerFactory.getLogger(SQLManager.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + SQLManager.class.getSimpleName()); // Public final public final String SET_OWNER; @@ -358,12 +358,12 @@ public class SQLManager implements AbstractDB { try { task.run(); } catch (Throwable e) { - logger.debug("============ DATABASE ERROR ============"); - logger.debug("============ DATABASE ERROR ============"); - logger.debug("There was an error updating the database."); - logger.debug(" - It will be corrected on shutdown"); + logger.error("============ DATABASE ERROR ============"); + logger.error("============ DATABASE ERROR ============"); + logger.error("There was an error updating the database."); + logger.error(" - It will be corrected on shutdown"); e.printStackTrace(); - logger.debug("========================================"); + logger.error("========================================"); } } commit(); @@ -413,12 +413,12 @@ public class SQLManager implements AbstractDB { } lastTask = task; } catch (Throwable e) { - logger.debug("============ DATABASE ERROR ============"); - logger.debug("There was an error updating the database."); - logger.debug(" - It will be corrected on shutdown"); - logger.debug("========================================"); + logger.error("============ DATABASE ERROR ============"); + logger.error("There was an error updating the database."); + logger.error(" - It will be corrected on shutdown"); + logger.error("========================================"); e.printStackTrace(); - logger.debug("========================================"); + logger.error("========================================"); } } if (statement != null && task != null) { @@ -458,12 +458,12 @@ public class SQLManager implements AbstractDB { } lastTask = task; } catch (Throwable e) { - logger.debug("============ DATABASE ERROR ============"); - logger.debug("There was an error updating the database."); - logger.debug(" - It will be corrected on shutdown"); - logger.debug("========================================"); + logger.error("============ DATABASE ERROR ============"); + logger.error("There was an error updating the database."); + logger.error(" - It will be corrected on shutdown"); + logger.error("========================================"); e.printStackTrace(); - logger.debug("========================================"); + logger.error("========================================"); } } if (statement != null && task != null) { @@ -504,12 +504,12 @@ public class SQLManager implements AbstractDB { } lastTask = task; } catch (Throwable e) { - logger.debug("============ DATABASE ERROR ============"); - logger.debug("There was an error updating the database."); - logger.debug(" - It will be corrected on shutdown"); - logger.debug("========================================"); + logger.error("============ DATABASE ERROR ============"); + logger.error("There was an error updating the database."); + logger.error(" - It will be corrected on shutdown"); + logger.error("========================================"); e.printStackTrace(); - logger.debug("========================================"); + logger.error("========================================"); } } if (statement != null && task != null) { @@ -533,12 +533,12 @@ public class SQLManager implements AbstractDB { this.plotTasks.clear(); } } catch (Throwable e) { - logger.debug("============ DATABASE ERROR ============"); - logger.debug("There was an error updating the database."); - logger.debug(" - It will be corrected on shutdown"); - logger.debug("========================================"); + logger.error("============ DATABASE ERROR ============"); + logger.error("There was an error updating the database."); + logger.error(" - It will be corrected on shutdown"); + logger.error("========================================"); e.printStackTrace(); - logger.debug("========================================"); + logger.error("========================================"); } return false; } @@ -626,7 +626,7 @@ public class SQLManager implements AbstractDB { } }))))); } catch (SQLException e) { - logger.error("Failed to set all flags and member tiers for plots", e); + logger.warn("Failed to set all flags and member tiers for plots", e); try { SQLManager.this.connection.commit(); } catch (SQLException e1) { @@ -635,7 +635,7 @@ public class SQLManager implements AbstractDB { } }); } catch (Exception e) { - logger.debug("Warning! Failed to set all helper for plots", e); + logger.warn("Warning! Failed to set all helper for plots", e); try { SQLManager.this.connection.commit(); } catch (SQLException e1) { @@ -704,10 +704,14 @@ public class SQLManager implements AbstractDB { try { preparedStatement.executeBatch(); } catch (final Exception e) { - logger.error("Failed to store flag values for plot with entry ID: {}", e); + logger.error("Failed to store flag values for plot with entry ID: {}", plot); + e.printStackTrace(); continue; } - logger.debug("- Finished converting flag values for plot with entry ID: {}", plot.getId()); + if (Settings.DEBUG) { + logger.info("- Finished converting flag values for plot with entry ID: {}", + plot.getId()); + } } } catch (final Exception e) { logger.error("Failed to store flag values", e); @@ -820,7 +824,6 @@ public class SQLManager implements AbstractDB { last = subList.size(); preparedStmt.addBatch(); } - logger.debug("Batch 1: {} | {}", count, objList.get(0).getClass().getCanonicalName()); preparedStmt.executeBatch(); preparedStmt.clearParameters(); preparedStmt.close(); @@ -863,7 +866,6 @@ public class SQLManager implements AbstractDB { last = subList.size(); preparedStmt.addBatch(); } - logger.debug("Batch 2: {} | {}", count, objList.get(0).getClass().getCanonicalName()); preparedStmt.executeBatch(); preparedStmt.clearParameters(); preparedStmt.close(); @@ -877,7 +879,6 @@ public class SQLManager implements AbstractDB { mod.setSQL(preparedStmt, obj); preparedStmt.addBatch(); } - logger.debug("Batch 3"); preparedStmt.executeBatch(); } catch (SQLException e3) { logger.error("Failed to save all", e); @@ -1129,7 +1130,6 @@ public class SQLManager implements AbstractDB { return; } boolean addConstraint = create == tables.length; - logger.debug("Creating tables"); try (Statement stmt = this.connection.createStatement()) { if (this.mySQL) { stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" @@ -1369,8 +1369,6 @@ public class SQLManager implements AbstractDB { * @param plot */ @Override public void delete(final Plot plot) { - logger.debug("Deleting plot. ID: {} | World: {} | Owner: {} | Index: {}", - plot.getId(), plot.getWorldName(), plot.getOwnerAbs(), plot.temp); deleteSettings(plot); deleteDenied(plot); deleteHelpers(plot); @@ -1396,8 +1394,6 @@ public class SQLManager implements AbstractDB { * @param plot */ @Override public void createPlotSettings(final int id, Plot plot) { - logger.debug("Creating plot plot. ID: {} | World: {} | Owner: {} | Index: {}", - plot.getId(), plot.getWorldName(), plot.getOwnerAbs(), plot.temp); addPlotTask(plot, new UniqueStatement("createPlotSettings") { @Override public void set(PreparedStatement statement) throws SQLException { statement.setInt(1, id); @@ -1555,7 +1551,6 @@ public class SQLManager implements AbstractDB { "SELECT plot_plot_id, user_uuid, COUNT(*) FROM " + this.prefix + table + " GROUP BY plot_plot_id, user_uuid HAVING COUNT(*) > 1"); if (result.next()) { - logger.debug("Backing up {}", this.prefix + table); result.close(); statement.executeUpdate( "CREATE TABLE " + this.prefix + table + "_tmp AS SELECT * FROM " @@ -1565,7 +1560,6 @@ public class SQLManager implements AbstractDB { "CREATE TABLE " + this.prefix + table + " AS SELECT * FROM " + this.prefix + table + "_tmp"); statement.executeUpdate("DROP TABLE " + this.prefix + table + "_tmp"); - logger.debug("Restoring {}", this.prefix + table); } } } catch (SQLException e2) { @@ -1682,7 +1676,10 @@ public class SQLManager implements AbstractDB { String.format("%.1f", ((float) flagsProcessed / totalFlags) * 100)); } - logger.debug("- Finished converting flags for plot with entry ID: {}", plotFlagEntry.getKey()); + if (Settings.DEBUG) { + logger.info("- Finished converting flags for plot with entry ID: {}", + plotFlagEntry.getKey()); + } } } catch (final Exception e) { logger.error("Failed to store flag values", e); @@ -1791,8 +1788,8 @@ public class SQLManager implements AbstractDB { if (last != null) { if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(last.temp); - } else { - logger.debug("Plot #{}({}) in `{}plot` is a duplicate." + } else if (Settings.DEBUG) { + logger.info("Plot #{}({}) in `{}plot` is a duplicate." + " Delete this plot or set `database-purger: true` in the settings.yml", id, last, this.prefix); } } @@ -1823,8 +1820,8 @@ public class SQLManager implements AbstractDB { plot.getSettings().getRatings().put(user, r.getInt("rating")); } else if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(id); - } else { - logger.debug("Entry #{}({}) in `plot_rating` does not exist." + } else if (Settings.DEBUG) { + logger.info("Entry #{}({}) in `plot_rating` does not exist." + " Create this plot or set `database-purger: true` in settings.yml", id, plot); } } @@ -1851,8 +1848,8 @@ public class SQLManager implements AbstractDB { plot.getTrusted().add(user); } else if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(id); - } else { - logger.debug("Entry #{}({}) in `plot_helpers` does not exist." + } else if (Settings.DEBUG) { + logger.info("Entry #{}({}) in `plot_helpers` does not exist." + " Create this plot or set `database-purger: true` in settings.yml", id, plot); } } @@ -1878,8 +1875,8 @@ public class SQLManager implements AbstractDB { plot.getMembers().add(user); } else if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(id); - } else { - logger.debug("Entry #{}({}) in `plot_trusted` does not exist." + } else if (Settings.DEBUG) { + logger.info("Entry #{}({}) in `plot_trusted` does not exist." + " Create this plot or set `database-purger: true` in settings.yml", id, plot); } } @@ -1905,8 +1902,8 @@ public class SQLManager implements AbstractDB { plot.getDenied().add(user); } else if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(id); - } else { - logger.debug("Entry #{}({}) in `plot_denied` does not exist." + } else if (Settings.DEBUG) { + logger.info("Entry #{}({}) in `plot_denied` does not exist." + " Create this plot or set `database-purger: true` in settings.yml", id, plot); } } @@ -1928,15 +1925,14 @@ public class SQLManager implements AbstractDB { final PlotFlag plotFlag = GlobalFlagContainer.getInstance().getFlagFromString(flag); if (plotFlag == null) { - logger.debug("Adding unknown flag {} to plot with ID {}", flag, id); plot.getFlagContainer().addUnknownFlag(flag, value); } else { try { plot.getFlagContainer().addFlag(plotFlag.parse(value)); } catch (final FlagParseException e) { e.printStackTrace(); - logger.debug("Plot with ID {} has an invalid value:", id); - logger.debug("Failed to parse flag '{}', value '{}': {}", + logger.error("Plot with ID {} has an invalid value:", id); + logger.error("Failed to parse flag '{}', value '{}': {}", plotFlag.getName(), e.getValue(), e.getErrorMessage()); if (!invalidFlags.containsKey(plot)) { invalidFlags.put(plot, new ArrayList<>()); @@ -1946,8 +1942,8 @@ public class SQLManager implements AbstractDB { } } else if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(id); - } else { - logger.debug("Entry #{}({}) in `plot_flags` does not exist." + } else if (Settings.DEBUG) { + logger.info("Entry #{}({}) in `plot_flags` does not exist." + " Create this plot or set `database-purger: true` in settings.yml", id, plot); } } @@ -1957,8 +1953,11 @@ public class SQLManager implements AbstractDB { for (final Map.Entry>> plotFlagEntry : invalidFlags .entrySet()) { for (final PlotFlag flag : plotFlagEntry.getValue()) { - logger.debug("Plot {} has an invalid flag ({}). A fix has been attempted", - plotFlagEntry.getKey(), flag.getName()); + if (Settings.DEBUG) { + logger.info( + "Plot {} has an invalid flag ({}). A fix has been attempted", + plotFlagEntry.getKey(), flag.getName()); + } removeFlag(plotFlagEntry.getKey(), flag); } } @@ -1999,8 +1998,8 @@ public class SQLManager implements AbstractDB { plot.getSettings().setMerged(merged); } else if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(id); - } else { - logger.debug("Entry #{}({}) in `plot_settings` does not exist." + } else if (Settings.DEBUG) { + logger.info("Entry #{}({}) in `plot_settings` does not exist." + " Create this plot or set `database-purger: true` in settings.yml", id, plot); } } @@ -2017,11 +2016,13 @@ public class SQLManager implements AbstractDB { for (Entry entry : noExist.entrySet()) { String worldName = entry.getKey(); invalidPlot = true; - logger.debug("Warning! Found {} plots in DB for non existent world: '{}'", - entry.getValue().intValue(), worldName); + if (Settings.DEBUG) { + logger.info("Warning! Found {} plots in DB for non existent world: '{}'", + entry.getValue().intValue(), worldName); + } } - if (invalidPlot) { - logger.debug("Warning! Please create the world(s) or remove the plots using the purge command"); + if (invalidPlot && Settings.DEBUG) { + logger.info("Warning! Please create the world(s) or remove the plots using the purge command"); } } catch (SQLException e) { logger.error("Failed to load plots", e); @@ -2163,8 +2164,6 @@ public class SQLManager implements AbstractDB { int count = 0; int last = -1; for (int j = 0; j <= amount; j++) { - int purging = Math.max(j * packet, size); - logger.debug("Purging {}/{}", purging, size); List subList = uniqueIdsList.subList(j * packet, Math.min(size, (j + 1) * packet)); if (subList.isEmpty()) { @@ -2214,7 +2213,9 @@ public class SQLManager implements AbstractDB { return; } } - logger.debug("Successfully purged {} plots", uniqueIds.size()); + if (Settings.DEBUG) { + logger.info("Successfully purged {} plots", uniqueIds.size()); + } } }); } @@ -2714,8 +2715,8 @@ public class SQLManager implements AbstractDB { cluster = clusters.get(id); if (cluster != null) { cluster.helpers.add(user); - } else { - logger.debug("Cluster #{}({}) in cluster_helpers does not exist." + } else if (Settings.DEBUG) { + logger.warn("Cluster #{}({}) in cluster_helpers does not exist." + " Please create the cluster or remove this entry", id, cluster); } } @@ -2733,8 +2734,8 @@ public class SQLManager implements AbstractDB { cluster = clusters.get(id); if (cluster != null) { cluster.invited.add(user); - } else { - logger.debug("Cluster #{}({}) in cluster_helpers does not exist." + } else if (Settings.DEBUG) { + logger.warn("Cluster #{}({}) in cluster_helpers does not exist." + " Please create the cluster or remove this entry", id, cluster); } } @@ -2768,8 +2769,8 @@ public class SQLManager implements AbstractDB { merged[3 - i] = (m & 1 << i) != 0; } cluster.settings.setMerged(merged); - } else { - logger.debug("Cluster #{}({}) in cluster_helpers does not exist." + } else if (Settings.DEBUG) { + logger.warn("Cluster #{}({}) in cluster_helpers does not exist." + " Please create the cluster or remove this entry", id, cluster); } } @@ -2779,10 +2780,10 @@ public class SQLManager implements AbstractDB { for (Entry entry : noExist.entrySet()) { String a = entry.getKey(); invalidPlot = true; - logger.debug("Warning! Found {} clusters in DB for non existent area; '{}'", noExist.get(a), a); + logger.warn("Warning! Found {} clusters in DB for non existent area; '{}'", noExist.get(a), a); } if (invalidPlot) { - logger.debug("Warning! Please create the world(s) or remove the clusters using the purge command"); + logger.warn("Warning! Please create the world(s) or remove the clusters using the purge command"); } } catch (SQLException e) { logger.error("Failed to load clusters", e); @@ -2977,7 +2978,7 @@ public class SQLManager implements AbstractDB { if (!isValid()) { reconnect(); } - logger.debug("All DB transactions during this session are being validated (This may take a while if corrections need to be made)"); + logger.info("All DB transactions during this session are being validated (This may take a while if corrections need to be made)"); commit(); while (true) { if (!sendBatch()) { @@ -3009,19 +3010,16 @@ public class SQLManager implements AbstractDB { } HashMap worldPlots = database.get(plot.getArea().toString()); if (worldPlots == null) { - logger.debug(" - Creating plot (1): {}", plot); toCreate.add(plot); continue; } Plot dataPlot = worldPlots.remove(plot.getId()); if (dataPlot == null) { - logger.debug(" - Creating plot (2): {}", plot); toCreate.add(plot); continue; } // owner if (!plot.getOwnerAbs().equals(dataPlot.getOwnerAbs())) { - logger.debug(" - Setting owner: {} -> {}", plot, MainUtil.getName(plot.getOwnerAbs())); setOwner(plot, plot.getOwnerAbs()); } // trusted @@ -3030,7 +3028,6 @@ public class SQLManager implements AbstractDB { HashSet toRemove = (HashSet) dataPlot.getTrusted().clone(); toRemove.removeAll(plot.getTrusted()); toAdd.removeAll(dataPlot.getTrusted()); - logger.debug(" - Correcting {} trusted for: {}", toAdd.size() + toRemove.size(), plot); if (!toRemove.isEmpty()) { for (UUID uuid : toRemove) { removeTrusted(plot, uuid); @@ -3047,7 +3044,6 @@ public class SQLManager implements AbstractDB { HashSet toRemove = (HashSet) dataPlot.getMembers().clone(); toRemove.removeAll(plot.getMembers()); toAdd.removeAll(dataPlot.getMembers()); - logger.debug(" - Correcting {} members for: {}", toAdd.size() + toRemove.size()); if (!toRemove.isEmpty()) { for (UUID uuid : toRemove) { removeMember(plot, uuid); @@ -3064,7 +3060,6 @@ public class SQLManager implements AbstractDB { HashSet toRemove = (HashSet) dataPlot.getDenied().clone(); toRemove.removeAll(plot.getDenied()); toAdd.removeAll(dataPlot.getDenied()); - logger.debug(" - Correcting {} denied for: {}", toAdd.size() + toRemove.size()); if (!toRemove.isEmpty()) { for (UUID uuid : toRemove) { removeDenied(plot, uuid); @@ -3079,7 +3074,6 @@ public class SQLManager implements AbstractDB { boolean[] pm = plot.getMerged(); boolean[] dm = dataPlot.getMerged(); if (pm[0] != dm[0] || pm[1] != dm[1]) { - logger.debug(" - Correcting merge for: {}", plot); setMerged(dataPlot, plot.getMerged()); } Set> pf = plot.getFlags(); diff --git a/Core/src/main/java/com/plotsquared/core/database/SQLite.java b/Core/src/main/java/com/plotsquared/core/database/SQLite.java index eb12a4672..fd9ba5027 100644 --- a/Core/src/main/java/com/plotsquared/core/database/SQLite.java +++ b/Core/src/main/java/com/plotsquared/core/database/SQLite.java @@ -42,7 +42,7 @@ import java.sql.Statement; */ public class SQLite extends Database { - private static final Logger logger = LoggerFactory.getLogger(SQLite.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + SQLite.class.getSimpleName()); private final String dbLocation; private Connection connection; diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java index 4e1b2157d..496acc747 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java @@ -60,7 +60,7 @@ import java.util.Locale; public class HybridPlotWorld extends ClassicPlotWorld { - private static final Logger logger = LoggerFactory.getLogger(HybridPlotWorld.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + HybridPlotWorld.class.getSimpleName()); private static final AffineTransform transform = new AffineTransform().rotateY(90); public boolean ROAD_SCHEMATIC_ENABLED; public boolean PLOT_SCHEMATIC = false; @@ -160,12 +160,11 @@ public class HybridPlotWorld extends ClassicPlotWorld { setupSchematics(); } catch (Exception event) { event.printStackTrace(); - logger.debug("- road schematics are disabled for this world"); } // Dump world settings if (Settings.DEBUG) { - logger.debug("- Dumping settings for ClassicPlotWorld with name {}", this.getWorldName()); + logger.info("- Dumping settings for ClassicPlotWorld with name {}", this.getWorldName()); final Field[] fields = this.getClass().getFields(); for (final Field field : fields) { final String name = field.getName().toLowerCase(Locale.ENGLISH); @@ -181,7 +180,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { } catch (final IllegalAccessException e) { value = String.format("Failed to parse: %s", e.getMessage()); } - logger.debug("-- {} = {}", name, value); + logger.info("-- {} = {}", name, value); } } } @@ -282,10 +281,14 @@ public class HybridPlotWorld extends ClassicPlotWorld { } } - logger.debug(" - plot schematic: {}", schematic3File.getPath()); + if (Settings.DEBUG) { + logger.info(" - plot schematic: {}", schematic3File.getPath()); + } } if (schematic1 == null || schematic2 == null || this.ROAD_WIDTH == 0) { - logger.debug(" - schematic: false"); + if (Settings.DEBUG) { + logger.info(" - schematic: false"); + } return; } this.ROAD_SCHEMATIC_ENABLED = true; diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java index 084e0a33b..209eddec1 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java @@ -78,7 +78,7 @@ import java.util.concurrent.atomic.AtomicInteger; public abstract class HybridUtils { - private static final Logger logger = LoggerFactory.getLogger(HybridUtils.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + HybridUtils.class.getSimpleName()); public static HybridUtils manager; public static Set regions; @@ -412,12 +412,14 @@ public abstract class HybridUtils { BlockVector2 chunk = iter.next(); iter.remove(); boolean regenedRoad = regenerateRoad(area, chunk, extend); - if (!regenedRoad) { - logger.debug("Failed to regenerate roads"); + if (!regenedRoad && Settings.DEBUG) { + logger.info("Failed to regenerate roads"); } ChunkManager.manager.unloadChunk(area.getWorldName(), chunk, true); } - logger.debug("Cancelled road task"); + if (Settings.DEBUG) { + logger.info("Cancelled road task"); + } return; } count.incrementAndGet(); @@ -425,7 +427,6 @@ public abstract class HybridUtils { logger.info("Progress: {}%", 100 * (2048 - chunks.size()) / 2048); } if (HybridUtils.regions.isEmpty() && chunks.isEmpty()) { - logger.debug("Regenerating plot walls"); regeneratePlotWalls(area); HybridUtils.UPDATE = false; @@ -441,8 +442,11 @@ public abstract class HybridUtils { HybridUtils.regions.iterator(); BlockVector2 loc = iterator.next(); iterator.remove(); - logger.debug("Updating .mcr: {}, {} (approx 1024 chunks)", loc.getX(), loc.getZ()); - logger.debug("- Remaining: {}", HybridUtils.regions.size()); + if (Settings.DEBUG) { + logger.info("Updating .mcr: {}, {} (approx 1024 chunks)", + loc.getX(), loc.getZ()); + logger.info("- Remaining: {}", HybridUtils.regions.size()); + } chunks.addAll(getChunks(loc)); System.gc(); } @@ -458,8 +462,8 @@ public abstract class HybridUtils { iterator.remove(); boolean regenedRoads = regenerateRoad(area, chunk, extend); - if (!regenedRoads) { - logger.debug("Failed to regenerate road"); + if (!regenedRoads && Settings.DEBUG) { + logger.info("Failed to regenerate road"); } } } @@ -470,7 +474,7 @@ public abstract class HybridUtils { Iterator iterator = HybridUtils.regions.iterator(); BlockVector2 loc = iterator.next(); iterator.remove(); - logger.debug("Error! Could not update '{}/region/r.{}.{}.mca' (Corrupt chunk?)", + logger.error("Error! Could not update '{}/region/r.{}.{}.mca' (Corrupt chunk?)", area.getWorldHash(), loc.getX(), loc.getZ()); int sx = loc.getX() << 5; int sz = loc.getZ() << 5; @@ -481,7 +485,6 @@ public abstract class HybridUtils { true); } } - logger.debug("- Potentially skipping 1024 chunks"); } GlobalBlockQueue.IMP.addEmptyTask(() -> TaskManager.runTaskLater(task, 20)); }); diff --git a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java index 531d2de92..1da8d0ed3 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java @@ -44,7 +44,7 @@ import java.util.Set; */ public abstract class SquarePlotManager extends GridPlotManager { - private static final Logger logger = LoggerFactory.getLogger(SquarePlotManager.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + SquarePlotManager.class.getSimpleName()); private final SquarePlotWorld squarePlotWorld; @@ -229,7 +229,7 @@ public abstract class SquarePlotManager extends GridPlotManager { return plot.getMerged(Direction.NORTHWEST) ? id : null; } } catch (Exception ignored) { - logger.debug( "Invalid plot / road width in settings.yml for world: {}", squarePlotWorld + logger.error( "Invalid plot / road width in settings.yml for world: {}", squarePlotWorld .getWorldName()); } return null; diff --git a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java index a7270105e..f2a6b2284 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java @@ -26,6 +26,7 @@ package com.plotsquared.core.generator; import com.plotsquared.core.configuration.ConfigurationSection; +import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.plot.PlotId; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory; public abstract class SquarePlotWorld extends GridPlotWorld { - private static final Logger logger = LoggerFactory.getLogger(SquarePlotWorld.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + SquarePlotWorld.class.getSimpleName()); public int PLOT_WIDTH = 42; public int ROAD_WIDTH = 7; @@ -47,7 +48,10 @@ public abstract class SquarePlotWorld extends GridPlotWorld { @Override public void loadConfiguration(ConfigurationSection config) { if (!config.contains("plot.height")) { - logger.debug(" - Configuration is null? ({})", config.getCurrentPath()); + if (Settings.DEBUG) { + logger.info(" - Configuration is null? ({})", config.getCurrentPath()); + } + } this.PLOT_WIDTH = config.getInt("plot.size"); this.ROAD_WIDTH = config.getInt("road.width"); diff --git a/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java b/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java index 191309c99..3e52f8a95 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java +++ b/Core/src/main/java/com/plotsquared/core/listener/ProcessedWEExtent.java @@ -52,7 +52,7 @@ import java.util.Set; public class ProcessedWEExtent extends AbstractDelegateExtent { - private static final Logger logger = LoggerFactory.getLogger(ProcessedWEExtent.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + ProcessedWEExtent.class.getSimpleName()); private final Set mask; private final String world; @@ -103,7 +103,6 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { return false; } else { tileEntityCount[0]++; - logger.debug("Detected unsafe WorldEdit: {},{},{}", location.getX(), location.getY(), location.getZ()); } } if (WEManager.maskContains(this.mask, location.getX(), location.getY(), location.getZ())) { @@ -134,7 +133,6 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { this.Ecount++; if (this.Ecount > Settings.Chunk_Processor.MAX_ENTITIES) { this.Eblocked = true; - logger.debug("Detected unsafe WorldEdit: {},{},{}", location.getX(), location.getY(), location.getZ()); } if (WEManager.maskContains(this.mask, location.getBlockX(), location.getBlockY(), location.getBlockZ())) { diff --git a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java index 970aad919..410b20925 100644 --- a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java @@ -45,7 +45,7 @@ import java.util.UUID; public class ConsolePlayer extends PlotPlayer { - private static final Logger logger = LoggerFactory.getLogger(ConsolePlayer.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + ConsolePlayer.class.getSimpleName()); private static ConsolePlayer instance; private ConsolePlayer() { diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index 56a32e328..304317c10 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -75,7 +75,7 @@ import java.util.stream.Collectors; */ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer { - private static final Logger logger = LoggerFactory.getLogger(PlotPlayer.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotPlayer.class.getSimpleName()); public static final String META_LAST_PLOT = "lastplot"; public static final String META_LOCATION = "location"; @@ -584,8 +584,9 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer if (Settings.Enabled_Components.BAN_DELETER && isBanned()) { for (Plot owned : getPlots()) { owned.deletePlot(null); - logger.debug("Plot {} was deleted + cleared due to {} getting banned", - owned.getId(), getName()); + if (Settings.DEBUG) { + logger.info("Plot {} was deleted + cleared due to {} getting banned", owned.getId(), getName()); + } } } if (ExpireManager.IMP != null) { diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 621c9ee6f..be1efa86e 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -119,7 +119,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE; */ public class Plot { - private static final Logger logger = LoggerFactory.getLogger(Plot.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + Plot.class.getSimpleName()); public static final int MAX_HEIGHT = 256; @@ -1735,8 +1735,6 @@ public class Plot { public boolean claim(@NotNull final PlotPlayer player, boolean teleport, String schematic) { if (!canClaim(player)) { - logger.debug("Player {} attempted to claim plot {}, but was not allowed", - player.getName(), this.getId().toCommaSeparatedString()); return false; } return claim(player, teleport, schematic, true); @@ -1747,7 +1745,7 @@ public class Plot { if (updateDB) { if (!create(player.getUUID(), true)) { - logger.debug("Player {} attempted to claim plot {}, but the database failed to update", + logger.error("Player {} attempted to claim plot {}, but the database failed to update", player.getName(), this.getId().toCommaSeparatedString()); return false; } @@ -1934,12 +1932,10 @@ public class Plot { */ public boolean moveData(Plot plot, Runnable whenDone) { if (!this.hasOwner()) { - logger.debug("{} is unowned (single)", plot); TaskManager.runTask(whenDone); return false; } if (plot.hasOwner()) { - logger.debug("{} is unowned (multi)", plot); TaskManager.runTask(whenDone); return false; } @@ -2647,7 +2643,6 @@ public class Plot { tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH)); if (!tmp.getMerged(Direction.SOUTH)) { // invalid merge - logger.debug("Fixing invalid merge: {}", this); if (tmp.isOwnerAbs(this.getOwnerAbs())) { tmp.getSettings().setMerged(Direction.SOUTH, true); DBFunc.setMerged(tmp, tmp.getSettings().getMerged()); @@ -2664,7 +2659,6 @@ public class Plot { assert tmp != null; if (!tmp.getMerged(Direction.WEST)) { // invalid merge - logger.debug("Fixing invalid merge: {}", this); if (tmp.isOwnerAbs(this.getOwnerAbs())) { tmp.getSettings().setMerged(Direction.WEST, true); DBFunc.setMerged(tmp, tmp.getSettings().getMerged()); @@ -2681,7 +2675,6 @@ public class Plot { assert tmp != null; if (!tmp.getMerged(Direction.NORTH)) { // invalid merge - logger.debug("Fixing invalid merge: {}", this); if (tmp.isOwnerAbs(this.getOwnerAbs())) { tmp.getSettings().setMerged(Direction.NORTH, true); DBFunc.setMerged(tmp, tmp.getSettings().getMerged()); @@ -2697,7 +2690,6 @@ public class Plot { tmp = this.area.getPlotAbs(this.id.getRelative(Direction.WEST)); if (!tmp.getMerged(Direction.EAST)) { // invalid merge - logger.debug("Fixing invalid merge: {}", this); if (tmp.isOwnerAbs(this.getOwnerAbs())) { tmp.getSettings().setMerged(Direction.EAST, true); DBFunc.setMerged(tmp, tmp.getSettings().getMerged()); @@ -2712,7 +2704,6 @@ public class Plot { Plot current; while ((current = frontier.poll()) != null) { if (!current.hasOwner() || current.settings == null) { - logger.debug("Ignoring invalid merged plot: {} | {}", current, current.getOwnerAbs()); continue; } tmpSet.add(current); diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index e74e51d2c..32b650a2a 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -87,7 +87,7 @@ import java.util.function.Consumer; */ public abstract class PlotArea { - private static final Logger logger = LoggerFactory.getLogger(PlotArea.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotArea.class.getSimpleName()); protected final ConcurrentHashMap plots = new ConcurrentHashMap<>(); @Getter @NotNull private final String worldName; diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java b/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java index d52536e22..814aba558 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java @@ -25,7 +25,6 @@ */ package com.plotsquared.core.plot; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.util.InventoryUtil; import lombok.NonNull; @@ -34,7 +33,7 @@ import org.slf4j.LoggerFactory; public class PlotInventory { - private static final Logger logger = LoggerFactory.getLogger(PlotInventory.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotInventory.class.getSimpleName()); private static final String META_KEY = "inventory"; public final PlotPlayer player; @@ -82,10 +81,7 @@ public class PlotInventory { if (this.title == null) { return; } - if (hasPlotInventoryOpen(player)) { - logger.debug("Failed to open plot inventory for {} because" - + " the player already has an open plot inventory", player.getName()); - } else { + if (!hasPlotInventoryOpen(player)) { this.open = true; setPlotInventoryOpen(player, this); InventoryUtil.manager.open(this); diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java index 96499df87..b697db52c 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java @@ -43,7 +43,6 @@ import com.plotsquared.core.plot.flag.implementations.AnalysisFlag; import com.plotsquared.core.plot.flag.implementations.KeepFlag; import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.util.MainUtil; -import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.TaskManager; @@ -57,14 +56,13 @@ import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Objects; -import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedDeque; public class ExpireManager { - private final Logger logger = LoggerFactory.getLogger(ExpireManager.class); + private final Logger logger = LoggerFactory.getLogger("P2/" + ExpireManager.class); public static ExpireManager IMP; private final ConcurrentHashMap dates_cache; @@ -83,7 +81,6 @@ public class ExpireManager { } public void addTask(ExpiryTask task) { - logger.debug("Adding new expiry task!"); this.tasks.add(task); } @@ -424,19 +421,7 @@ public class ExpireManager { MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString()); } } - Set plots = plot.getConnectedPlots(); plot.deletePlot(whenDone); - PlotAnalysis changed = plot.getComplexity(null); - int changes = changed == null ? 0 : changed.changes_sd; - int modified = changed == null ? 0 : changed.changes; - logger.debug("Deleted expired plot: {} | User: {} | Delta: {}/{} | Connected: {}", - plot, plot.getOwner(), changes, modified, StringMan.getString(plots)); - logger.debug(" - Area: {}", plot.getArea()); - if (plot.hasOwner()) { - logger.debug(" - Owner: {}", plot.getOwner()); - } else { - logger.debug(" - Owner: Unowned"); - } } public long getAge(UUID uuid) { diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java index ed4b1453f..d3e9e956e 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java +++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/PlotAnalysis.java @@ -46,7 +46,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class PlotAnalysis { - private static final Logger logger = LoggerFactory.getLogger(PlotAnalysis.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotAnalysis.class.getSimpleName()); public static boolean running = false; public int changes; @@ -96,20 +96,26 @@ public class PlotAnalysis { */ public static void calcOptimalModifiers(final Runnable whenDone, final double threshold) { if (running) { - logger.debug("Calibration task already in progress!"); + if (Settings.DEBUG) { + logger.info("Calibration task already in progress!"); + } return; } if (threshold <= 0 || threshold >= 1) { - logger.debug("Invalid threshold provided! (Cannot be 0 or 100 as then there's no point in calibrating)"); + if (Settings.DEBUG) { + logger.info( + "Invalid threshold provided! (Cannot be 0 or 100 as then there's no point in calibrating)"); + } return; } running = true; - logger.debug("- Fetching all plots"); final ArrayList plots = new ArrayList<>(PlotSquared.get().getPlots()); TaskManager.runTaskAsync(new Runnable() { @Override public void run() { Iterator iterator = plots.iterator(); - logger.debug("- Reducing {} plots to those with sufficient data", plots.size()); + if (Settings.DEBUG) { + logger.info("- Reducing {} plots to those with sufficient data", plots.size()); + } while (iterator.hasNext()) { Plot plot = iterator.next(); if (plot.getSettings().getRatings() == null || plot.getSettings().getRatings() @@ -119,10 +125,12 @@ public class PlotAnalysis { plot.addRunning(); } } - logger.debug("- | Reduced to {} plots", plots.size()); if (plots.size() < 3) { - logger.debug("Calibration cancelled due to insufficient comparison data, please try again later"); + if (Settings.DEBUG) { + logger.info( + "Calibration cancelled due to insufficient comparison data, please try again later"); + } running = false; for (Plot plot : plots) { plot.removeRunning(); @@ -130,7 +138,9 @@ public class PlotAnalysis { return; } - logger.debug("- Analyzing plot contents (this may take a while)"); + if (Settings.DEBUG) { + logger.info("- Analyzing plot contents (this may take a while)"); + } int[] changes = new int[plots.size()]; int[] faces = new int[plots.size()]; @@ -156,7 +166,9 @@ public class PlotAnalysis { ratings[i] = (int) ( (plot.getAverageRating() + plot.getSettings().getRatings().size()) * 100); - logger.debug(" | {} (rating) {}", plot, ratings[i]); + if (Settings.DEBUG) { + logger.info(" | {} (rating) {}", plot, ratings[i]); + } } } }); @@ -168,7 +180,9 @@ public class PlotAnalysis { if (queuePlot == null) { break; } - logger.debug(" | {}", queuePlot); + if (Settings.DEBUG) { + logger.info(" | {}", queuePlot); + } final Object lock = new Object(); TaskManager.runTask(new Runnable() { @Override public void run() { @@ -198,7 +212,9 @@ public class PlotAnalysis { } } - logger.debug(" - Waiting on plot rating thread: {}%", mi.intValue() * 100 / plots.size()); + if (Settings.DEBUG) { + logger.info(" - Waiting on plot rating thread: {}%", mi.intValue() * 100 / plots.size()); + } try { ratingAnalysis.join(); @@ -206,10 +222,15 @@ public class PlotAnalysis { e.printStackTrace(); } - logger.debug(" - Processing and grouping single plot analysis for bulk processing"); + if (Settings.DEBUG) { + logger.info( + " - Processing and grouping single plot analysis for bulk processing"); + } for (int i = 0; i < plots.size(); i++) { Plot plot = plots.get(i); - logger.debug(" | {}", plot); + if (Settings.DEBUG) { + logger.info(" | {}", plot); + } PlotAnalysis analysis = plot.getComplexity(null); changes[i] = analysis.changes; @@ -225,16 +246,22 @@ public class PlotAnalysis { variety_sd[i] = analysis.variety_sd; } - logger.debug(" - Calculating rankings"); + if (Settings.DEBUG) { + logger.info(" - Calculating rankings"); + } int[] rankRatings = rank(ratings); int n = rankRatings.length; int optimalIndex = (int) Math.round((1 - threshold) * (n - 1)); - logger.debug(" - Calculating rank correlation: "); - logger.debug(" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking"); - logger.debug(" - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing"); + if (Settings.DEBUG) { + logger.info(" - Calculating rank correlation: "); + logger.info( + " - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking"); + logger.info( + " - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing"); + } Settings.Auto_Clear settings = new Settings.Auto_Clear(); @@ -246,7 +273,10 @@ public class PlotAnalysis { settings.CALIBRATION.CHANGES = factorChanges == 1 ? 0 : (int) (factorChanges * 1000 / MathMan.getMean(changes)); - logger.debug(" - | changes {}", factorChanges); + + if (Settings.DEBUG) { + logger.info(" - | changes {}", factorChanges); + } int[] rankFaces = rank(faces); int[] sdFaces = getSD(rankFaces, rankRatings); @@ -255,7 +285,10 @@ public class PlotAnalysis { double factorFaces = getCC(n, sumFaces); settings.CALIBRATION.FACES = factorFaces == 1 ? 0 : (int) (factorFaces * 1000 / MathMan.getMean(faces)); - logger.debug(" - | faces {}", factorFaces); + + if (Settings.DEBUG) { + logger.info(" - | faces {}", factorFaces); + } int[] rankData = rank(data); int[] sdData = getSD(rankData, rankRatings); @@ -264,7 +297,10 @@ public class PlotAnalysis { double factor_data = getCC(n, sum_data); settings.CALIBRATION.DATA = factor_data == 1 ? 0 : (int) (factor_data * 1000 / MathMan.getMean(data)); - logger.debug(" - | data {}", factor_data); + + if (Settings.DEBUG) { + logger.info(" - | data {}", factor_data); + } int[] rank_air = rank(air); int[] sd_air = getSD(rank_air, rankRatings); @@ -273,7 +309,10 @@ public class PlotAnalysis { double factor_air = getCC(n, sum_air); settings.CALIBRATION.AIR = factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(air)); - logger.debug("- | air {}", factor_air); + + if (Settings.DEBUG) { + logger.info("- | air {}", factor_air); + } int[] rank_variety = rank(variety); int[] sd_variety = getSD(rank_variety, rankRatings); @@ -283,7 +322,10 @@ public class PlotAnalysis { settings.CALIBRATION.VARIETY = factor_variety == 1 ? 0 : (int) (factor_variety * 1000 / MathMan.getMean(variety)); - logger.debug("- | variety {}", factor_variety); + + if (Settings.DEBUG) { + logger.info("- | variety {}", factor_variety); + } int[] rank_changes_sd = rank(changes_sd); int[] sd_changes_sd = getSD(rank_changes_sd, rankRatings); @@ -293,7 +335,10 @@ public class PlotAnalysis { settings.CALIBRATION.CHANGES_SD = factor_changes_sd == 1 ? 0 : (int) (factor_changes_sd * 1000 / MathMan.getMean(changes_sd)); - logger.debug(" - | changed_sd {}", factor_changes_sd); + + if (Settings.DEBUG) { + logger.info(" - | changed_sd {}", factor_changes_sd); + } int[] rank_faces_sd = rank(faces_sd); int[] sd_faces_sd = getSD(rank_faces_sd, rankRatings); @@ -303,7 +348,10 @@ public class PlotAnalysis { settings.CALIBRATION.FACES_SD = factor_faces_sd == 1 ? 0 : (int) (factor_faces_sd * 1000 / MathMan.getMean(faces_sd)); - logger.debug(" - | faced_sd {}", factor_faces_sd); + + if (Settings.DEBUG) { + logger.info(" - | faced_sd {}", factor_faces_sd); + } int[] rank_data_sd = rank(data_sd); int[] sd_data_sd = getSD(rank_data_sd, rankRatings); @@ -313,7 +361,10 @@ public class PlotAnalysis { settings.CALIBRATION.DATA_SD = factor_data_sd == 1 ? 0 : (int) (factor_data_sd * 1000 / MathMan.getMean(data_sd)); - logger.debug(" - | data_sd {}", factor_data_sd); + + if (Settings.DEBUG) { + logger.info(" - | data_sd {}", factor_data_sd); + } int[] rank_air_sd = rank(air_sd); int[] sd_air_sd = getSD(rank_air_sd, rankRatings); @@ -322,7 +373,10 @@ public class PlotAnalysis { double factor_air_sd = getCC(n, sum_air_sd); settings.CALIBRATION.AIR_SD = factor_air_sd == 1 ? 0 : (int) (factor_air_sd * 1000 / MathMan.getMean(air_sd)); - logger.debug(" - | air_sd {}", factor_air_sd); + + if (Settings.DEBUG) { + logger.info(" - | air_sd {}", factor_air_sd); + } int[] rank_variety_sd = rank(variety_sd); int[] sd_variety_sd = getSD(rank_variety_sd, rankRatings); @@ -332,11 +386,17 @@ public class PlotAnalysis { settings.CALIBRATION.VARIETY_SD = factor_variety_sd == 1 ? 0 : (int) (factor_variety_sd * 1000 / MathMan.getMean(variety_sd)); - logger.debug(" - | variety_sd {}", factor_variety_sd); + + if (Settings.DEBUG) { + logger.info(" - | variety_sd {}", factor_variety_sd); + } int[] complexity = new int[n]; - logger.debug(" Calculating threshold"); + if (Settings.DEBUG) { + logger.info(" Calculating threshold"); + } + int max = 0; int min = 0; for (int i = 0; i < n; i++) { @@ -365,7 +425,10 @@ public class PlotAnalysis { logln("Correlation: "); logln(getCC(n, sum(square(getSD(rankComplexity, rankRatings))))); if (optimalComplexity == Integer.MAX_VALUE) { - logger.debug("Insufficient data to determine correlation! {} | {}", optimalIndex, n); + if (Settings.DEBUG) { + logger.info("Insufficient data to determine correlation! {} | {}", + optimalIndex, n); + } running = false; for (Plot plot : plots) { plot.removeRunning(); @@ -383,21 +446,27 @@ public class PlotAnalysis { } // Save calibration - logger.debug(" Saving calibration"); + if (Settings.DEBUG) { + logger.info(" Saving calibration"); + } Settings.AUTO_CLEAR.put("auto-calibrated", settings); Settings.save(PlotSquared.get().worldsFile); - logger.debug("Done!"); running = false; for (Plot plot : plots) { plot.removeRunning(); } + if (Settings.DEBUG) { + logger.info(" Done!"); + } whenDone.run(); } }); } public static void logln(Object obj) { - logger.debug(log(obj)); + if (Settings.DEBUG) { + logger.info(log(obj)); + } } public static String log(Object obj) { diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java index b55c6a96d..2c398d1c7 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java @@ -45,7 +45,7 @@ import java.util.Map; */ @EqualsAndHashCode(of = "flagMap") public class FlagContainer { - private static final Logger logger = LoggerFactory.getLogger(FlagContainer.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + FlagContainer.class.getSimpleName()); private final Map unknownFlags = new HashMap<>(); private final Map, PlotFlag> flagMap = new HashMap<>(); diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java b/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java index 6197327a6..a2d4d4a94 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java @@ -27,6 +27,7 @@ package com.plotsquared.core.plot.flag.types; import com.google.common.base.Objects; import com.google.common.base.Preconditions; +import com.plotsquared.core.configuration.Settings; import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -45,7 +46,7 @@ import java.util.Map; */ public class BlockTypeWrapper { - private static final Logger logger = LoggerFactory.getLogger(BlockTypeWrapper.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + BlockTypeWrapper.class.getSimpleName()); private static final Map blockTypes = new HashMap<>(); private static final Map blockCategories = new HashMap<>(); @@ -132,7 +133,9 @@ public class BlockTypeWrapper { && this.blockCategoryId != null) { // only if name is available this.blockCategory = BlockCategory.REGISTRY.get(this.blockCategoryId); if (this.blockCategory == null && !BlockCategory.REGISTRY.values().isEmpty()) { - logger.debug("- Block category #{} does not exist", this.blockCategoryId); + if (Settings.DEBUG) { + logger.info("- Block category #{} does not exist", this.blockCategoryId); + } this.blockCategory = new NullBlockCategory(this.blockCategoryId); } } diff --git a/Core/src/main/java/com/plotsquared/core/plot/message/PlotMessage.java b/Core/src/main/java/com/plotsquared/core/plot/message/PlotMessage.java index 7e192dbe8..f72dc9aef 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/message/PlotMessage.java +++ b/Core/src/main/java/com/plotsquared/core/plot/message/PlotMessage.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; public class PlotMessage { - private static final Logger logger = LoggerFactory.getLogger(PlotMessage.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotMessage.class.getSimpleName()); private Object builder; diff --git a/Core/src/main/java/com/plotsquared/core/queue/LocationOffsetDelegateLocalBlockQueue.java b/Core/src/main/java/com/plotsquared/core/queue/LocationOffsetDelegateLocalBlockQueue.java index d3ad4e36e..eefae99d3 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/LocationOffsetDelegateLocalBlockQueue.java +++ b/Core/src/main/java/com/plotsquared/core/queue/LocationOffsetDelegateLocalBlockQueue.java @@ -37,7 +37,7 @@ import javax.annotation.Nullable; public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQueue { - private static final Logger logger = LoggerFactory.getLogger(LocationOffsetDelegateLocalBlockQueue.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + LocationOffsetDelegateLocalBlockQueue.class.getSimpleName()); private final boolean[][] canPlace; private final int blockX; @@ -64,9 +64,6 @@ public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQue return super.setBlock(x, y, z, id); } } catch (final Exception e) { - logger.debug("Failed set block at {},{},{} (to = {}) with offset {};{}. Translated to: {}, {}", - x, y, z, id, blockX, blockZ, x - blockX, - z - blockZ); throw e; } return false; diff --git a/Core/src/main/java/com/plotsquared/core/util/Expression.java b/Core/src/main/java/com/plotsquared/core/util/Expression.java index da25e4ed1..40b3d1c78 100644 --- a/Core/src/main/java/com/plotsquared/core/util/Expression.java +++ b/Core/src/main/java/com/plotsquared/core/util/Expression.java @@ -25,9 +25,9 @@ */ package com.plotsquared.core.util; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.command.DebugExec; import com.plotsquared.core.command.MainCommand; +import com.plotsquared.core.configuration.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ import javax.script.ScriptException; public abstract class Expression { - private static final Logger logger = LoggerFactory.getLogger(Expression.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + Expression.class.getSimpleName()); public static Expression constant(final U value) { return new Expression() { @@ -71,7 +71,9 @@ public abstract class Expression { try { return (Double) exec.getEngine().eval(expression.replace("{arg}", "" + arg)); } catch (ScriptException e) { - logger.debug("Invalid expression: {}", expression); + if (Settings.DEBUG) { + logger.info("Invalid expression: {}", expression); + } e.printStackTrace(); } return 0d; diff --git a/Core/src/main/java/com/plotsquared/core/util/LegacyConverter.java b/Core/src/main/java/com/plotsquared/core/util/LegacyConverter.java index 7fbdc4fd4..70e46e406 100644 --- a/Core/src/main/java/com/plotsquared/core/util/LegacyConverter.java +++ b/Core/src/main/java/com/plotsquared/core/util/LegacyConverter.java @@ -46,7 +46,7 @@ import java.util.Map; @SuppressWarnings("unused") public final class LegacyConverter { - private static final Logger logger = LoggerFactory.getLogger(LegacyConverter.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + LegacyConverter.class.getSimpleName()); public static final String CONFIGURATION_VERSION = "post_flattening"; private static final HashMap TYPE_MAP = new HashMap<>(); diff --git a/Core/src/main/java/com/plotsquared/core/util/MainUtil.java b/Core/src/main/java/com/plotsquared/core/util/MainUtil.java index 11b17cc02..5c5799c78 100644 --- a/Core/src/main/java/com/plotsquared/core/util/MainUtil.java +++ b/Core/src/main/java/com/plotsquared/core/util/MainUtil.java @@ -99,7 +99,7 @@ import java.util.stream.IntStream; */ public class MainUtil { - private static final Logger logger = LoggerFactory.getLogger(MainUtil.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + MainUtil.class.getSimpleName()); private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0"); static { @@ -156,7 +156,6 @@ public class MainUtil { public static void upload(UUID uuid, String file, String extension, final RunnableVal writeTask, final RunnableVal whenDone) { if (writeTask == null) { - logger.debug("Write task cannot be null"); TaskManager.runTask(whenDone); return; } @@ -897,8 +896,6 @@ public class MainUtil { for (File file : files) { if (file.isDirectory()) { deleteDirectory(file); - } else { - logger.debug("Deleting file: {} | {}", file, file.delete()); } } } diff --git a/Core/src/main/java/com/plotsquared/core/util/RegionManager.java b/Core/src/main/java/com/plotsquared/core/util/RegionManager.java index 238f8345b..eae87a02b 100644 --- a/Core/src/main/java/com/plotsquared/core/util/RegionManager.java +++ b/Core/src/main/java/com/plotsquared/core/util/RegionManager.java @@ -46,7 +46,7 @@ import java.util.Set; public abstract class RegionManager { - private static final Logger logger = LoggerFactory.getLogger(RegionManager.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + RegionManager.class.getSimpleName()); public static RegionManager manager = null; diff --git a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java index d16ecbe7b..c79e680a8 100644 --- a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java +++ b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java @@ -96,7 +96,7 @@ import java.util.zip.GZIPOutputStream; public abstract class SchematicHandler { - private static final Logger logger = LoggerFactory.getLogger(SchematicHandler.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + SchematicHandler.class.getSimpleName()); public static SchematicHandler manager; private boolean exportAll = false; @@ -151,17 +151,12 @@ public abstract class SchematicHandler { final Runnable THIS = this; SchematicHandler.manager.getCompoundTag(plot, new RunnableVal() { @Override public void run(final CompoundTag value) { - if (value == null) { - logger.debug("Skipped plot {}", plot.getId()); - } else { + if (value != null) { TaskManager.runTaskAsync(() -> { - logger.debug("ID: {}", plot.getId()); boolean result = SchematicHandler.manager .save(value, directory + File.separator + name + ".schem"); if (!result) { logger.error("Failed to save {}", plot.getId()); - } else { - logger.debug("success: {}", plot.getId()); } TaskManager.runTask(THIS); }); @@ -205,7 +200,6 @@ public abstract class SchematicHandler { + 1) < WIDTH) || ( (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT > 256)) { - logger.debug("Schematic is too large"); TaskManager.runTask(whenDone); return; } diff --git a/Core/src/main/java/com/plotsquared/core/util/net/IncendoPaster.java b/Core/src/main/java/com/plotsquared/core/util/net/IncendoPaster.java index 1189bc5cb..8c8359865 100644 --- a/Core/src/main/java/com/plotsquared/core/util/net/IncendoPaster.java +++ b/Core/src/main/java/com/plotsquared/core/util/net/IncendoPaster.java @@ -48,7 +48,7 @@ import java.util.Locale; @SuppressWarnings({"unused", "WeakerAccess"}) public final class IncendoPaster { - private static Logger logger = LoggerFactory.getLogger(IncendoPaster.class); + private static Logger logger = LoggerFactory.getLogger("P2/" + IncendoPaster.class); /** * Upload service URL @@ -161,7 +161,7 @@ public final class IncendoPaster { if (!httpURLConnection.getResponseMessage().contains("OK")) { if (httpURLConnection.getResponseCode() == 413) { final long size = content.length; - logger.debug("Paste too big > size: {}MB", size / 1_000_000); + logger.error("Paste too big > size: {}MB", size / 1_000_000); } throw new IllegalStateException(String .format("Server returned status: %d %s", httpURLConnection.getResponseCode(), diff --git a/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java b/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java index 88dfaeb11..8d1e38337 100644 --- a/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java +++ b/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java @@ -64,7 +64,7 @@ import java.util.function.Function; */ public class UUIDPipeline { - private static final Logger logger = LoggerFactory.getLogger(UUIDPipeline.class); + private static final Logger logger = LoggerFactory.getLogger("P2/" + UUIDPipeline.class.getSimpleName()); private final Executor executor; private final List serviceList; @@ -325,7 +325,7 @@ public class UUIDPipeline { this.consume(mappings); return mappings; } else if (Settings.DEBUG) { - logger.debug("(UUID) Failed to find all usernames"); + logger.info("(UUID) Failed to find all usernames"); } if (Settings.UUID.UNKNOWN_AS_DEFAULT) { @@ -388,7 +388,7 @@ public class UUIDPipeline { this.consume(mappings); return mappings; } else if (Settings.DEBUG) { - logger.debug("(UUID) Failed to find all UUIDs"); + logger.info("(UUID) Failed to find all UUIDs"); } throw new ServiceError("End of pipeline"); diff --git a/Core/src/main/resources/log4j.xml b/Core/src/main/resources/log4j.xml deleted file mode 100644 index b450c1eca..000000000 --- a/Core/src/main/resources/log4j.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - -