From b96cea75b842169cca230902bce64234b6b2814e Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 29 Mar 2021 15:29:16 +0200 Subject: [PATCH] Update Upstream 609c7b8 Scrapped Logging Framework 4 Java Closes #997 Closes #998 Closes #999 Closes #1000 Closes #1001 Closes #1002 --- buildSrc/build.gradle.kts | 3 - buildSrc/src/main/kotlin/CommonConfig.kt | 25 +++---- buildSrc/src/main/kotlin/LibsConfig.kt | 2 +- buildSrc/src/main/kotlin/Versions.kt | 3 +- settings.gradle.kts | 3 - worldedit-bukkit/build.gradle.kts | 60 +++++---------- .../com/boydti/fawe/bukkit/FaweBukkit.java | 20 ++--- .../bukkit/adapter/BukkitQueueHandler.java | 9 ++- .../mc1_15_2/BukkitGetBlocks_1_15_2.java | 14 ++-- .../mc1_16_1/BukkitGetBlocks_1_16_1.java | 15 ++-- .../mc1_16_2/BukkitGetBlocks_1_16_2.java | 15 ++-- .../mc1_16_5/BukkitGetBlocks_1_16_5.java | 15 ++-- .../fawe/bukkit/filter/WorldGuardFilter.java | 8 +- .../fawe/bukkit/listener/ChunkListener.java | 13 ++-- .../regions/GriefPreventionFeature.java | 8 +- .../fawe/bukkit/regions/ResidenceFeature.java | 9 ++- .../fawe/bukkit/regions/TownyFeature.java | 9 ++- .../fawe/bukkit/regions/Worldguard.java | 14 ++-- .../plotsquared/PlotSquaredFeature.java | 14 ++-- .../plotsquaredv4/PlotSquaredFeature.java | 14 ++-- .../fawe/bukkit/util/JavaVersionCheck.java | 44 +++++------ .../wepif/FlatFilePermissionsResolver.java | 11 ++- .../sk89q/wepif/NijiPermissionsResolver.java | 16 ++-- .../wepif/PermissionsResolverManager.java | 23 +++--- .../bukkit/BukkitCommandInspector.java | 12 +-- .../worldedit/bukkit/BukkitConfiguration.java | 14 ++-- .../sk89q/worldedit/bukkit/BukkitWorld.java | 18 ++--- .../worldedit/bukkit/WorldEditPlugin.java | 32 ++++---- .../bukkit/adapter/BukkitImplLoader.java | 14 ++-- .../worldedit/bukkit/adapter/Regenerator.java | 9 ++- .../adapter/impl/FAWE_Spigot_v1_15_R2.java | 12 +-- .../adapter/impl/FAWE_Spigot_v1_16_R1.java | 12 +-- .../adapter/impl/FAWE_Spigot_v1_16_R2.java | 12 +-- .../adapter/impl/FAWE_Spigot_v1_16_R3.java | 12 +-- worldedit-cli/build.gradle.kts | 16 ++-- .../sk89q/worldedit/cli/CLICommandSender.java | 3 +- .../com/sk89q/worldedit/cli/CLIWorldEdit.java | 6 +- worldedit-core/build.gradle.kts | 14 ++-- .../src/main/java/com/boydti/fawe/Fawe.java | 16 ++-- .../main/java/com/boydti/fawe/FaweCache.java | 7 +- .../com/boydti/fawe/beta/IBatchProcessor.java | 2 +- .../implementation/blocks/CharBlocks.java | 10 +-- .../implementation/lighting/NMSRelighter.java | 14 ++-- .../processors/MultiBatchProcessor.java | 4 - .../queue/SingleThreadQueueExtent.java | 21 +++--- .../java/com/boydti/fawe/config/Config.java | 12 +-- .../configuration/file/YamlConfiguration.java | 11 +-- .../ConfigurationSerialization.java | 20 ++--- .../com/boydti/fawe/database/DBHandler.java | 9 +-- .../fawe/database/RollbackDatabase.java | 8 +- .../com/boydti/fawe/jnbt/anvil/MCAChunk.java | 9 ++- .../com/boydti/fawe/jnbt/anvil/MCAFile.java | 8 +- .../fawe/jnbt/streamer/StreamDelegate.java | 11 ++- .../rollback/RollbackOptimizedHistory.java | 9 ++- .../fawe/object/brush/InspectBrush.java | 12 +-- .../cfi/HeightMapMCAGenerator.java | 8 +- .../boydti/fawe/object/change/CFIChange.java | 8 +- .../object/change/MutableEntityChange.java | 10 ++- .../object/changeset/AbstractChangeSet.java | 2 +- .../clipboard/DiskOptimizedClipboard.java | 8 +- .../object/schematic/MinecraftStructure.java | 9 ++- .../boydti/fawe/util/EditSessionBuilder.java | 16 ++-- .../java/com/boydti/fawe/util/MainUtil.java | 12 +-- .../com/boydti/fawe/util/TaskManager.java | 8 +- .../com/boydti/fawe/util/TextureUtil.java | 24 +++--- .../boydti/fawe/util/ThirdPartyManager.java | 15 ++-- .../java/com/boydti/fawe/util/WEManager.java | 14 ++-- .../util/commands/CommandsManager.java | 11 ++- .../util/commands/SimpleInjector.java | 8 +- .../java/com/sk89q/worldedit/EditSession.java | 10 +-- .../sk89q/worldedit/LocalConfiguration.java | 6 +- .../java/com/sk89q/worldedit/WorldEdit.java | 9 ++- .../worldedit/command/SchematicCommands.java | 16 ++-- .../worldedit/command/tool/SelectionWand.java | 10 +-- .../command/util/AsyncCommandBuilder.java | 8 +- .../command/util/annotation/Confirm.java | 3 - .../platform/PlatformCommandManager.java | 16 ++-- .../extension/platform/PlatformManager.java | 16 ++-- .../extension/platform/binding/Bindings.java | 8 +- .../extent/AbstractDelegateExtent.java | 20 ++--- .../clipboard/io/FastSchematicReader.java | 12 +-- .../clipboard/io/MCEditSchematicReader.java | 10 +-- .../clipboard/io/SpongeSchematicReader.java | 20 ++--- .../transform/BlockTransformExtent.java | 11 ++- .../function/mask/MaskIntersection.java | 9 ++- .../internal/SchematicsEventListener.java | 6 +- .../internal/anvil/ChunkDeleter.java | 26 +++---- .../internal/util/LogManagerCompat.java | 44 +++++++++++ .../ReparametrisingInterpolation.java | 8 +- .../MinecraftHidingClassShutter.java | 4 - .../worldedit/session/SessionManager.java | 10 +-- .../session/storage/JsonFileSessionStore.java | 16 ++-- .../util/PropertiesConfiguration.java | 10 +-- .../worldedit/util/YAMLConfiguration.java | 2 +- .../worldedit/util/eventbus/EventBus.java | 8 +- .../com/sk89q/worldedit/util/io/Closer.java | 8 +- .../util/io/file/ArchiveNioSupports.java | 5 -- .../io/file/TrueVfsArchiveNioSupport.java | 73 ------------------- .../util/report/ShallowObjectReport.java | 8 +- .../world/block/BlockTypesCache.java | 2 - .../world/registry/BundledBlockData.java | 10 +-- .../world/registry/BundledItemData.java | 10 +-- .../world/registry/LegacyMapper.java | 12 +-- .../worldedit/world/snapshot/Snapshot.java | 10 +-- .../util/commands/CommandContextTest.java | 22 +++--- .../fs/FileSystemSnapshotDatabaseTest.java | 3 +- worldedit-fabric/build.gradle.kts | 7 +- .../worldedit/fabric/FabricWorldEdit.java | 4 +- worldedit-forge/build.gradle.kts | 12 +-- .../sk89q/worldedit/forge/ForgeWorldEdit.java | 4 +- worldedit-libs/bukkit/build.gradle.kts | 4 - worldedit-libs/core/ap/build.gradle.kts | 4 +- worldedit-libs/core/build.gradle.kts | 8 +- worldedit-sponge/build.gradle.kts | 8 +- .../worldedit/sponge/SpongeWorldEdit.java | 2 +- .../sponge/adapter/SpongeImplLoader.java | 16 ++-- .../config/ConfigurateConfiguration.java | 2 +- .../sponge/config/SpongeConfiguration.java | 2 +- 118 files changed, 700 insertions(+), 743 deletions(-) create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/LogManagerCompat.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/io/file/TrueVfsArchiveNioSupport.java diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 777fce05a..618f271fa 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -11,9 +11,6 @@ repositories { maven { name = "EngineHub" url = uri("https://maven.enginehub.org/repo/") - content { - includeGroupByRegex("com.sk89q.*") - } } } diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt index a2e39f17a..06174b3ee 100644 --- a/buildSrc/src/main/kotlin/CommonConfig.kt +++ b/buildSrc/src/main/kotlin/CommonConfig.kt @@ -2,6 +2,7 @@ import org.gradle.api.Project import org.gradle.api.plugins.JavaPluginExtension import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.repositories import org.gradle.kotlin.dsl.the @@ -14,19 +15,10 @@ fun Project.applyCommonConfiguration() { maven { name = "IntellectualSites" url = uri("https://mvn.intellectualsites.com/content/groups/public/") - content { - includeGroup("com.plotsquared") - includeGroup("com.intellectualsites.paster") - includeGroup("com.github.intellectualsites.plotsquared") - } } maven { name = "EngineHub" url = uri("https://maven.enginehub.org/repo/") - content { - includeGroupByRegex("org.enginehub.*") - includeGroupByRegex("com.sk89q.*") - } } maven { name = "OSS Sonatype Snapshots" @@ -39,13 +31,6 @@ fun Project.applyCommonConfiguration() { maven { name = "Athion" url = uri("https://ci.athion.net/plugin/repository/tools/") - content { - includeGroup("com.massivecraft") - includeGroup("com.thevoxelbox.voxelsniper") - includeGroup("com.palmergames.bukkit") - includeGroup("net.fabiozumbi12") - includeGroupByRegex("com.destroystokyo.*") - } } } @@ -55,6 +40,14 @@ fun Project.applyCommonConfiguration() { } } + configurations.findByName("compileClasspath")?.apply { + resolutionStrategy.componentSelection { + withModule("org.slf4j:slf4j-api") { + reject("No SLF4J allowed on compile classpath") + } + } + } + plugins.withId("java") { the().toolchain { languageVersion.set(JavaLanguageVersion.of(8)) diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt index 6ab5396d8..eac7e6746 100644 --- a/buildSrc/src/main/kotlin/LibsConfig.kt +++ b/buildSrc/src/main/kotlin/LibsConfig.kt @@ -38,7 +38,7 @@ fun Project.applyLibrariesConfiguration() { exclude(dependency("com.google.guava:guava")) exclude(dependency("com.google.code.gson:gson")) exclude(dependency("org.checkerframework:checker-qual")) - exclude(dependency("org.slf4j:slf4j-api")) + exclude(dependency("org.apache.logging.log4j:log4j-api")) } relocations.forEach { (from, to) -> diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 503e7622a..3b7edee56 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -3,11 +3,10 @@ import org.gradle.api.Project object Versions { const val TEXT = "3.0.4" const val TEXT_EXTRAS = "3.0.6" - const val PISTON = "0.5.6" + const val PISTON = "0.5.7" const val AUTO_VALUE = "1.7.4" const val JUNIT = "5.7.0" const val MOCKITO = "3.8.0" - const val SLF4J = "1.7.30" const val LOGBACK = "1.2.3" const val FAST_UTIL = "8.2.1" const val GUAVA = "21.0" diff --git a/settings.gradle.kts b/settings.gradle.kts index 5b51b8170..3d6d30469 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -15,9 +15,6 @@ dependencyResolutionManagement { maven { name = "EngineHub" url = uri("https://maven.enginehub.org/repo/") - content { - includeGroupByRegex("com.sk89q.*") - } } } } diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index b0a143481..a23640ad6 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -11,26 +11,15 @@ repositories { maven { name = "SpigotMC" url = uri("https://hub.spigotmc.org/nexus/content/groups/public") - content { - includeGroup("org.bukkit") - includeGroup("org.spigotmc") - } } maven { name = "PaperMC" url = uri("https://papermc.io/repo/repository/maven-public/") - content { - includeGroup("io.papermc") - includeGroup("com.destroystokyo.paper") - } - } + } maven { name = "EngineHub" url = uri("https://maven.enginehub.org/repo/") - content { - includeGroupByRegex("com.sk89q.*") - } - } + } maven { name = "Athion" url = uri("https://ci.athion.net/plugin/repository/tools/") @@ -38,45 +27,26 @@ repositories { maven { name = "JitPack" url = uri("https://jitpack.io") - content { - includeGroup("com.github.MilkBowl") - includeGroup("com.github.TechFortress") - } - } + } maven { name = "ProtocolLib" url = uri("https://repo.dmulloy2.net/nexus/repository/public/") - content { - includeGroup("com.comphenix.protocol") - } - } + } maven { name = "Inventivetalent" url = uri("https://repo.inventivetalent.org/content/groups/public/") - content { - includeGroupByRegex("org.inventivetalent.*") - } - } + } maven { name = "IntellectualSites 3rd Party" url = uri("https://mvn.intellectualsites.com/content/repositories/thirdparty") - content { - includeGroup("de.notmyfault") - } - } + } maven { name = "OSS Sonatype Snapshots" url = uri("https://oss.sonatype.org/content/repositories/snapshots/") - content { - includeGroup("net.kyori") - } - } + } maven { name = "OSS Sonatype Releases" url = uri("https://oss.sonatype.org/content/repositories/releases/") - content { - includeGroup("net.kyori") - } } flatDir { dir(File("src/main/resources")) } } @@ -105,7 +75,13 @@ dependencies { api("com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT") { exclude("junit", "junit") isTransitive = false + exclude(group = "org.slf4j", module = "slf4j-api") } + implementation(enforcedPlatform("org.apache.logging.log4j:log4j-bom:2.8.1") { + // Note: Paper will bump to 2.11.2, but we should only depend on 2.8 APIs for compatibility. + because("Spigot provides Log4J (sort of, not in API, implicitly part of server)") + }) + implementation("org.apache.logging.log4j:log4j-api") compileOnly("org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT") compileOnly("org.jetbrains:annotations:20.1.0") testCompileOnly("org.jetbrains:annotations:20.1.0") @@ -113,7 +89,6 @@ dependencies { compileOnly("com.sk89q:dummypermscompat:1.10") { exclude("com.github.MilkBowl", "VaultAPI") } - implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") testImplementation("org.mockito:mockito-core:3.8.0") compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.4") { exclude("com.sk89q.worldedit", "worldedit-bukkit") @@ -162,13 +137,14 @@ tasks.named("shadowJar") { }) archiveFileName.set("FastAsyncWorldEdit-Bukkit-${project.version}.jar") dependencies { - relocate("org.slf4j", "com.sk89q.worldedit.slf4j") - relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge") + // In tandem with not bundling log4j, we shouldn't relocate base package here. + // relocate("org.apache.logging", "com.sk89q.worldedit.log4j") relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4") include(dependency(":worldedit-core")) include(dependency(":worldedit-libs:bukkit")) - include(dependency("org.slf4j:slf4j-api")) - include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) + // Purposefully not included, we assume (even though no API exposes it) that Log4J will be present at runtime + // If it turns out not to be true for Spigot/Paper, our only two official platforms, this can be uncommented. + // include(dependency("org.apache.logging.log4j:log4j-api")) include(dependency("org.antlr:antlr4-runtime")) relocate("org.bstats", "com.sk89q.worldedit.bstats") { include(dependency("org.bstats:")) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index ad8584343..77f2b5883 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -28,7 +28,9 @@ import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.image.ImageViewer; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitPlayer; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import io.papermc.lib.PaperLib; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -38,8 +40,6 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.File; import java.io.FileOutputStream; @@ -50,7 +50,7 @@ import java.util.function.Supplier; public class FaweBukkit implements IFawe, Listener { - private static final Logger log = LoggerFactory.getLogger(FaweBukkit.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final Plugin plugin; private ItemUtil itemUtil; @@ -70,7 +70,7 @@ public class FaweBukkit implements IFawe, Listener { try { new BrushListener(plugin); } catch (Throwable e) { - log.error("Brush Listener Failed", e); + LOGGER.error("Brush Listener Failed", e); } if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) { new RenderListener(plugin); @@ -162,7 +162,7 @@ public class FaweBukkit implements IFawe, Listener { this.itemUtil = tmp = new ItemUtil(); } catch (Throwable e) { Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES = false; - log.error("Persistent Brushes Failed", e); + LOGGER.error("Persistent Brushes Failed", e); } } return tmp; @@ -208,7 +208,7 @@ public class FaweBukkit implements IFawe, Listener { if (worldguardPlugin != null && worldguardPlugin.isEnabled()) { try { managers.add(new Worldguard(worldguardPlugin)); - log.debug("Attempting to use plugin 'WorldGuard'"); + LOGGER.info("Attempting to use plugin 'WorldGuard'"); } catch (Throwable ignored) { } } @@ -216,7 +216,7 @@ public class FaweBukkit implements IFawe, Listener { if (townyPlugin != null && townyPlugin.isEnabled()) { try { managers.add(new TownyFeature(townyPlugin)); - log.debug("Attempting to use plugin 'Towny'"); + LOGGER.info("Attempting to use plugin 'Towny'"); } catch (Throwable ignored) { } } @@ -224,7 +224,7 @@ public class FaweBukkit implements IFawe, Listener { if (residencePlugin != null && residencePlugin.isEnabled()) { try { managers.add(new ResidenceFeature(residencePlugin, this)); - log.debug("Attempting to use plugin 'Residence'"); + LOGGER.info("Attempting to use plugin 'Residence'"); } catch (Throwable ignored) { } } @@ -233,7 +233,7 @@ public class FaweBukkit implements IFawe, Listener { if (griefpreventionPlugin != null && griefpreventionPlugin.isEnabled()) { try { managers.add(new GriefPreventionFeature(griefpreventionPlugin)); - log.debug("Attempting to use plugin 'GriefPrevention'"); + LOGGER.debug("Attempting to use plugin 'GriefPrevention'"); } catch (Throwable ignored) { } } @@ -307,6 +307,6 @@ public class FaweBukkit implements IFawe, Listener { WEManager.IMP.managers .add(new com.boydti.fawe.bukkit.regions.plotsquared.PlotSquaredFeature()); } - log.info("Plugin 'PlotSquared' found. Using it now."); + LOGGER.info("Plugin 'PlotSquared' found. Using it now."); } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java index c4a539179..1abc98c2c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java @@ -3,13 +3,16 @@ package com.boydti.fawe.bukkit.adapter; import co.aikar.timings.Timings; import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.bukkit.listener.ChunkListener; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import org.spigotmc.AsyncCatcher; import java.lang.reflect.Method; -import static org.slf4j.LoggerFactory.getLogger; - public class BukkitQueueHandler extends QueueHandler { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private volatile boolean timingsEnabled; private static boolean alertTimingsChange = true; @@ -32,7 +35,7 @@ public class BukkitQueueHandler extends QueueHandler { if (timingsEnabled) { if (alertTimingsChange) { alertTimingsChange = false; - getLogger(BukkitQueueHandler.class).debug("Having `parallel-threads` > 1 interferes with the timings."); + LOGGER.debug("Having `parallel-threads` > 1 interferes with the timings."); } Timings.setTimingsEnabled(false); methodCheck.invoke(null); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java index 6dc7e81f5..f7c41d278 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_15_R2; import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -50,14 +51,13 @@ import net.minecraft.server.v1_15_R1.NibbleArray; import net.minecraft.server.v1_15_R1.SectionPosition; import net.minecraft.server.v1_15_R1.TileEntity; import net.minecraft.server.v1_15_R1.WorldServer; +import org.apache.logging.log4j.Logger; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock; import org.bukkit.event.entity.CreatureSpawnEvent; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.AbstractSet; import java.util.Arrays; @@ -74,11 +74,9 @@ import java.util.concurrent.Future; import java.util.function.Function; import javax.annotation.Nullable; -import static org.slf4j.LoggerFactory.getLogger; - public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBlocks { - private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_15_2.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final Function posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ()); private static final Function nmsTile2We = tileEntity -> new LazyCompoundTag_1_15_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); @@ -438,7 +436,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl } else { existingSection = sections[layer]; if (existingSection == null) { - log.error("Skipping invalid null section. chunk:" + chunkX + "," + LOGGER.error("Skipping invalid null section. chunk:" + chunkX + "," + chunkZ + " layer: " + layer); continue; } @@ -466,7 +464,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl } newSection = BukkitAdapter_1_15_2.newChunkSection(layer, this::loadPrivately, setArr, fastmode); if (!BukkitAdapter_1_15_2.setSectionAtomic(sections, existingSection, newSection, layer)) { - log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); + LOGGER.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); } else { updateGet(this, nmsChunk, sections, newSection, setArr, layer); } @@ -546,7 +544,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl final ListTag posTag = (ListTag) entityTagMap.get("Pos"); final ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); if (idTag == null || posTag == null || rotTag == null) { - getLogger(BukkitGetBlocks_1_15_2.class).debug("Unknown entity tag: " + nativeTag); + LOGGER.debug("Unknown entity tag: " + nativeTag); continue; } final double x = posTag.getDouble(0); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java index 9288ff4c9..3c236dd77 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R1; import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -50,14 +51,13 @@ import net.minecraft.server.v1_16_R1.NibbleArray; import net.minecraft.server.v1_16_R1.SectionPosition; import net.minecraft.server.v1_16_R1.TileEntity; import net.minecraft.server.v1_16_R1.WorldServer; +import org.apache.logging.log4j.Logger; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.v1_16_R1.CraftWorld; import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock; import org.bukkit.event.entity.CreatureSpawnEvent; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.AbstractSet; import java.util.Arrays; @@ -74,11 +74,9 @@ import java.util.concurrent.Future; import java.util.function.Function; import javax.annotation.Nullable; -import static org.slf4j.LoggerFactory.getLogger; - public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBlocks { - private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_1.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final Function posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ()); private static final Function nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); @@ -438,7 +436,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl } else { existingSection = sections[layer]; if (existingSection == null) { - log.error("Skipping invalid null section. chunk:" + chunkX + "," + + LOGGER.error("Skipping invalid null section. chunk:" + chunkX + "," + chunkZ + " layer: " + layer); continue; } @@ -468,7 +466,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl .newChunkSection(layer, this::loadPrivately, setArr, fastmode); if (!BukkitAdapter_1_16_1 .setSectionAtomic(sections, existingSection, newSection, layer)) { - log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); + LOGGER.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); } else { updateGet(this, nmsChunk, sections, newSection, setArr, layer); } @@ -548,8 +546,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl final ListTag posTag = (ListTag) entityTagMap.get("Pos"); final ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); if (idTag == null || posTag == null || rotTag == null) { - getLogger( - BukkitGetBlocks_1_16_1.class).debug("Unknown entity tag: " + nativeTag); + LOGGER.debug("Unknown entity tag: " + nativeTag); continue; } final double x = posTag.getDouble(0); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java index 9a16e1b73..ca173b940 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R2; import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -51,14 +52,13 @@ import net.minecraft.server.v1_16_R2.NibbleArray; import net.minecraft.server.v1_16_R2.SectionPosition; import net.minecraft.server.v1_16_R2.TileEntity; import net.minecraft.server.v1_16_R2.WorldServer; +import org.apache.logging.log4j.Logger; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.v1_16_R2.CraftWorld; import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock; import org.bukkit.event.entity.CreatureSpawnEvent; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.annotation.Nullable; import java.util.AbstractSet; @@ -75,11 +75,9 @@ import java.util.concurrent.Callable; import java.util.concurrent.Future; import java.util.function.Function; -import static org.slf4j.LoggerFactory.getLogger; - public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBlocks { - private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_2.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final Function posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ()); private static final Function nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_2(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); @@ -441,7 +439,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl } else { existingSection = sections[layer]; if (existingSection == null) { - log.error("Skipping invalid null section. chunk:" + chunkX + "," + LOGGER.error("Skipping invalid null section. chunk:" + chunkX + "," + chunkZ + " layer: " + layer); continue; } @@ -471,7 +469,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl .newChunkSection(layer, this::loadPrivately, setArr, fastmode); if (!BukkitAdapter_1_16_2 .setSectionAtomic(sections, existingSection, newSection, layer)) { - log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); + LOGGER.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); } else { updateGet(this, nmsChunk, sections, newSection, setArr, layer); } @@ -551,8 +549,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl final ListTag posTag = (ListTag) entityTagMap.get("Pos"); final ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); if (idTag == null || posTag == null || rotTag == null) { - getLogger( - BukkitGetBlocks_1_16_2.class).debug("Unknown entity tag: " + nativeTag); + LOGGER.debug("Unknown entity tag: " + nativeTag); continue; } final double x = posTag.getDouble(0); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_5/BukkitGetBlocks_1_16_5.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_5/BukkitGetBlocks_1_16_5.java index 0d1d84c02..848758437 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_5/BukkitGetBlocks_1_16_5.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_5/BukkitGetBlocks_1_16_5.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R3; import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -51,14 +52,13 @@ import net.minecraft.server.v1_16_R3.NibbleArray; import net.minecraft.server.v1_16_R3.SectionPosition; import net.minecraft.server.v1_16_R3.TileEntity; import net.minecraft.server.v1_16_R3.WorldServer; +import org.apache.logging.log4j.Logger; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; import org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock; import org.bukkit.event.entity.CreatureSpawnEvent; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.annotation.Nullable; import java.util.AbstractSet; @@ -75,11 +75,9 @@ import java.util.concurrent.Callable; import java.util.concurrent.Future; import java.util.function.Function; -import static org.slf4j.LoggerFactory.getLogger; - public class BukkitGetBlocks_1_16_5 extends CharGetBlocks implements BukkitGetBlocks { - private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_5.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final Function posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ()); private static final Function nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_5(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); @@ -441,7 +439,7 @@ public class BukkitGetBlocks_1_16_5 extends CharGetBlocks implements BukkitGetBl } else { existingSection = sections[layer]; if (existingSection == null) { - log.error("Skipping invalid null section. chunk:" + chunkX + "," + LOGGER.error("Skipping invalid null section. chunk:" + chunkX + "," + chunkZ + " layer: " + layer); continue; } @@ -471,7 +469,7 @@ public class BukkitGetBlocks_1_16_5 extends CharGetBlocks implements BukkitGetBl .newChunkSection(layer, this::loadPrivately, setArr, fastmode); if (!BukkitAdapter_1_16_5 .setSectionAtomic(sections, existingSection, newSection, layer)) { - log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); + LOGGER.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); } else { updateGet(this, nmsChunk, sections, newSection, setArr, layer); } @@ -551,8 +549,7 @@ public class BukkitGetBlocks_1_16_5 extends CharGetBlocks implements BukkitGetBl final ListTag posTag = (ListTag) entityTagMap.get("Pos"); final ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); if (idTag == null || posTag == null || rotTag == null) { - getLogger( - BukkitGetBlocks_1_16_5.class).debug("Unknown entity tag: " + nativeTag); + LOGGER.debug("Unknown entity tag: " + nativeTag); continue; } final double x = posTag.getDouble(0); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java index 678270aba..ba5f2281f 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/WorldGuardFilter.java @@ -3,18 +3,22 @@ package com.boydti.fawe.bukkit.filter; import com.boydti.fawe.Fawe; import com.boydti.fawe.regions.general.CuboidRegionFilter; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import org.apache.logging.log4j.Logger; import org.bukkit.World; import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; public class WorldGuardFilter extends CuboidRegionFilter { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final World world; private boolean large; private RegionManager manager; @@ -33,7 +37,7 @@ public class WorldGuardFilter extends CuboidRegionFilter { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); if (max.getBlockX() - min.getBlockX() > 1024 || max.getBlockZ() - min.getBlockZ() > 1024) { - getLogger(WorldGuardFilter.class).debug("Large or complex region shapes cannot be optimized. Filtering will be slower"); + LOGGER.debug("Large or complex region shapes cannot be optimized. Filtering will be slower"); large = true; break; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java index 4c597c5bf..9b8225e50 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ChunkListener.java @@ -6,8 +6,10 @@ import com.boydti.fawe.config.Settings; import com.boydti.fawe.util.FaweTimer; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TaskManager; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -42,13 +44,10 @@ import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.util.Vector; -import org.slf4j.Logger; - -import static org.slf4j.LoggerFactory.getLogger; public abstract class ChunkListener implements Listener { - private final Logger logger = getLogger(ChunkListener.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); protected int rateLimit = 0; protected Location lastCancelPos; private int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS, @@ -62,7 +61,7 @@ public abstract class ChunkListener implements Listener { TaskManager.IMP.repeat(() -> { Location tmpLoc = lastCancelPos; if (tmpLoc != null) { - logger.debug("[FAWE Tick Limiter] Detected and cancelled physics lag source at " + LOGGER.debug("[FAWE Tick Limiter] Detected and cancelled physics lag source at " + tmpLoc); } rateLimit--; @@ -378,7 +377,7 @@ public abstract class ChunkListener implements Listener { double vertical = Math.abs(velocity.getY()); if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) { - logger.warn( + LOGGER.warn( "[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation()); ent.remove(); @@ -409,7 +408,7 @@ public abstract class ChunkListener implements Listener { cancelNearby(cx, cz); if (rateLimit <= 0) { rateLimit = 20; - logger.warn( + LOGGER.warn( "[FAWE `tick-limiter`] Detected and cancelled item lag source at " + loc); } event.setCancelled(true); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java index c5a3705d4..e253922ff 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java @@ -4,23 +4,25 @@ import com.boydti.fawe.bukkit.filter.GriefPreventionFilter; import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.general.RegionFilter; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.GriefPrevention; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import static org.slf4j.LoggerFactory.getLogger; - public class GriefPreventionFeature extends BukkitMaskManager implements Listener { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + public GriefPreventionFeature(final Plugin griefpreventionPlugin) { super(griefpreventionPlugin.getName()); - getLogger(GriefPreventionFeature.class).debug("Plugin 'GriefPrevention' found. Using it now."); + LOGGER.debug("Plugin 'GriefPrevention' found. Using it now."); } public boolean isAllowed(Player player, Claim claim, MaskType type) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java index 6b834233a..3c46a4c7c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java @@ -6,15 +6,18 @@ import com.bekvon.bukkit.residence.protection.CuboidArea; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.regions.FaweMask; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.regions.CuboidRegion; +import org.apache.logging.log4j.Logger; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import static org.slf4j.LoggerFactory.getLogger; - public class ResidenceFeature extends BukkitMaskManager implements Listener { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private FaweBukkit plugin; private Plugin residence; @@ -22,7 +25,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { super(residencePlugin.getName()); this.residence = residencePlugin; this.plugin = p3; - getLogger(ResidenceFeature.class).debug("Plugin 'Residence' found. Using it now."); + LOGGER.debug("Plugin 'Residence' found. Using it now."); } public boolean isAllowed(Player player, ClaimedResidence residence, MaskType type) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java index b735701ac..723f4b011 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java @@ -10,25 +10,26 @@ import com.palmergames.bukkit.towny.object.TownBlock; import com.palmergames.bukkit.towny.object.TownyUniverse; import com.palmergames.bukkit.towny.object.WorldCoord; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; +import org.apache.logging.log4j.Logger; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import static org.slf4j.LoggerFactory.getLogger; - public class TownyFeature extends BukkitMaskManager implements Listener { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final Plugin towny; public TownyFeature(Plugin townyPlugin) { super(townyPlugin.getName()); this.towny = townyPlugin; - getLogger(TownyFeature.class).debug("Plugin 'Towny' found. Using it now."); - + LOGGER.debug("Plugin 'Towny' found. Using it now."); } public boolean isAllowed(Player player, TownBlock block) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java index 5676e3973..a395dfb42 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java @@ -5,6 +5,7 @@ import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.general.RegionFilter; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.CuboidRegion; @@ -21,20 +22,17 @@ import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.RegionContainer; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import org.slf4j.Logger; - import java.util.Locale; -import static org.slf4j.LoggerFactory.getLogger; - public class Worldguard extends BukkitMaskManager implements Listener { private final WorldGuardPlugin worldguard; - private static final Logger logger = getLogger(Worldguard.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private WorldGuardPlugin getWorldGuard() { final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard"); @@ -50,19 +48,19 @@ public class Worldguard extends BukkitMaskManager implements Listener { public Worldguard(Plugin p2) { super(p2.getName()); this.worldguard = this.getWorldGuard(); - logger.debug("Plugin 'WorldGuard' found. Using it now."); + LOGGER.debug("Plugin 'WorldGuard' found. Using it now."); } public ProtectedRegion getRegion(LocalPlayer player, Location location) { RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); if (container == null) { - logger.info("Region capability is not enabled for WorldGuard."); + LOGGER.info("Region capability is not enabled for WorldGuard."); return null; } RegionManager manager = container.get(BukkitAdapter.adapt(location.getWorld())); if (manager == null) { - logger.info("Region capability is not enabled for that world."); + LOGGER.info("Region capability is not enabled for that world."); return null; } final ProtectedRegion global = manager.getRegion("__global__"); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java index 5b28a0c4a..8f9ec5071 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java @@ -18,13 +18,13 @@ import com.plotsquared.core.util.RegionManager; import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.WEManager; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionIntersection; import com.sk89q.worldedit.world.World; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.util.List; import java.util.Locale; @@ -34,11 +34,11 @@ import java.util.stream.Collectors; public class PlotSquaredFeature extends FaweMaskManager { - private static final Logger log = LoggerFactory.getLogger(PlotSquaredFeature.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public PlotSquaredFeature() { super("PlotSquared"); - log.debug("Optimizing PlotSquared"); + LOGGER.debug("Optimizing PlotSquared"); if (com.boydti.fawe.config.Settings.IMP.ENABLED_COMPONENTS.PLOTSQUARED_HOOK) { Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS = false; try { @@ -46,7 +46,7 @@ public class PlotSquaredFeature extends FaweMaskManager { setupSchematicHandler(); setupRegionManager(); } catch (Throwable ignored) { - log.debug("Please update PlotSquared: https://www.spigotmc.org/resources/plotsquared-v5.77506/"); + LOGGER.debug("Please update PlotSquared: https://www.spigotmc.org/resources/77506/"); } if (Settings.PLATFORM.toLowerCase(Locale.ROOT).startsWith("bukkit")) { new FaweTrim(); @@ -82,12 +82,12 @@ public class PlotSquaredFeature extends FaweMaskManager { private void setupRegionManager() throws RuntimeException { RegionManager.manager = new FaweRegionManager(RegionManager.manager); - log.debug(" - RegionManager: " + RegionManager.manager); + LOGGER.debug(" - RegionManager: " + RegionManager.manager); } private void setupSchematicHandler() throws RuntimeException { SchematicHandler.manager = new FaweSchematicHandler(); - log.debug(" - SchematicHandler: " + SchematicHandler.manager); + LOGGER.debug(" - SchematicHandler: " + SchematicHandler.manager); } public boolean isAllowed(Player player, Plot plot, MaskType type) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java index e7b105bb1..e85f89c8a 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquaredv4/PlotSquaredFeature.java @@ -18,13 +18,13 @@ import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionIntersection; import com.sk89q.worldedit.world.World; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.util.HashSet; import java.util.List; @@ -35,11 +35,11 @@ import java.util.stream.Collectors; public class PlotSquaredFeature extends FaweMaskManager { - private static final Logger log = LoggerFactory.getLogger(PlotSquaredFeature.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public PlotSquaredFeature() { super("PlotSquared"); - log.debug("Optimizing PlotSquared"); + LOGGER.debug("Optimizing PlotSquared"); if (com.boydti.fawe.config.Settings.IMP.ENABLED_COMPONENTS.PLOTSQUARED_HOOK) { Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS = false; try { @@ -47,7 +47,7 @@ public class PlotSquaredFeature extends FaweMaskManager { setupSchematicHandler(); setupChunkManager(); } catch (Throwable ignored) { - log.debug("Please update PlotSquared: https://www.spigotmc.org/resources/77506/"); + LOGGER.debug("Please update PlotSquared: https://www.spigotmc.org/resources/77506/"); } if (Settings.PLATFORM.toLowerCase(Locale.ROOT).startsWith("bukkit")) { new FaweTrim(); @@ -83,12 +83,12 @@ public class PlotSquaredFeature extends FaweMaskManager { private void setupChunkManager() throws RuntimeException { ChunkManager.manager = new FaweChunkManager(ChunkManager.manager); - log.debug(" - ChunkManager: " + ChunkManager.manager); + LOGGER.debug(" - ChunkManager: " + ChunkManager.manager); } private void setupSchematicHandler() throws RuntimeException { SchematicHandler.manager = new FaweSchematicHandler(); - log.debug(" - SchematicHandler: " + SchematicHandler.manager); + LOGGER.debug(" - SchematicHandler: " + SchematicHandler.manager); } public boolean isAllowed(Player player, Plot plot, MaskType type) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/JavaVersionCheck.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/JavaVersionCheck.java index b0fe317e2..1e8d5c62e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/JavaVersionCheck.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/JavaVersionCheck.java @@ -1,20 +1,20 @@ package com.boydti.fawe.bukkit.util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; public class JavaVersionCheck { - public static final Logger logger = LoggerFactory.getLogger(JavaVersionCheck.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static int checkJavaVersion() { String javaVersion = System.getProperty("java.version"); final Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(javaVersion); if (!matcher.find()) { - logger.warn("Failed to determine Java version; Could not parse: {}", javaVersion); + LOGGER.warn("Failed to determine Java version; Could not parse: {}", javaVersion); return -1; } @@ -22,32 +22,32 @@ public class JavaVersionCheck { try { return Integer.parseInt(version); } catch (final NumberFormatException e) { - logger.warn("Failed to determine Java version; Could not parse {} from {}", version, javaVersion, e); + LOGGER.warn("Failed to determine Java version; Could not parse {} from {}", version, javaVersion, e); return -1; } } public static void checkJvm() { if (checkJavaVersion() < 11) { - logger.warn("************************************************************"); - logger.warn("* WARNING - YOU ARE RUNNING AN OUTDATED VERSION OF JAVA."); - logger.warn("* FASTASYNCWORLDEDIT WILL STOP BEING COMPATIBLE WITH THIS VERSION OF"); - logger.warn("* JAVA WHEN MINECRAFT 1.17 IS RELEASED."); - logger.warn("*"); - logger.warn("* Please update the version of Java to 11. When Minecraft 1.17"); - logger.warn("* is released, support for versions of Java prior to 11 will"); - logger.warn("* be dropped."); - logger.warn("*"); - logger.warn("* Current Java version: {}", System.getProperty("java.version")); - logger.warn("************************************************************"); + LOGGER.warn("************************************************************"); + LOGGER.warn("* WARNING - YOU ARE RUNNING AN OUTDATED VERSION OF JAVA."); + LOGGER.warn("* FASTASYNCWORLDEDIT WILL STOP BEING COMPATIBLE WITH THIS VERSION OF"); + LOGGER.warn("* JAVA WHEN MINECRAFT 1.17 IS RELEASED."); + LOGGER.warn("*"); + LOGGER.warn("* Please update the version of Java to 11. When Minecraft 1.17"); + LOGGER.warn("* is released, support for versions of Java prior to 11 will"); + LOGGER.warn("* be dropped."); + LOGGER.warn("*"); + LOGGER.warn("* Current Java version: {}", System.getProperty("java.version")); + LOGGER.warn("************************************************************"); } if (checkJavaVersion() >= 15) { - logger.warn("************************************************************"); - logger.warn("* FastAsyncWorldEdit uses Nashorn for the craftscript engine."); - logger.warn("* Within Java 15, Nashorn has been removed from Java."); - logger.warn("* Until we add a suitable workaround, you should stick to Java 11"); - logger.warn("* to use all features of FastAsyncWorldEdit."); - logger.warn("************************************************************"); + LOGGER.warn("************************************************************"); + LOGGER.warn("* FastAsyncWorldEdit uses Nashorn for the craftscript engine."); + LOGGER.warn("* Within Java 15, Nashorn has been removed from Java."); + LOGGER.warn("* Until we add a suitable workaround, you should stick to Java 11"); + LOGGER.warn("* to use all features of FastAsyncWorldEdit."); + LOGGER.warn("************************************************************"); } } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java index 8938ae018..9c30f8715 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java @@ -22,9 +22,8 @@ package com.sk89q.wepif; import com.sk89q.util.yaml.YAMLProcessor; import org.bukkit.OfflinePlayer; import org.bukkit.Server; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -38,7 +37,7 @@ import java.util.Set; public class FlatFilePermissionsResolver implements PermissionsResolver { - private static final Logger log = LoggerFactory.getLogger(FlatFilePermissionsResolver.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private Map> userPermissionsCache; private Set defaultPermissionsCache; @@ -99,7 +98,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { } } } catch (IOException e) { - log.warn("Failed to load permissions", e); + LOGGER.warn("Failed to load permissions", e); } finally { try { if (buff != null) { @@ -165,7 +164,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { } } } catch (IOException e) { - log.warn("Failed to load permissions", e); + LOGGER.warn("Failed to load permissions", e); } finally { try { if (buff != null) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java index 29c9f3c11..7c20c88b2 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java @@ -21,6 +21,8 @@ package com.sk89q.wepif; import com.nijikokun.bukkit.Permissions.Permissions; import com.sk89q.util.yaml.YAMLProcessor; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.Server; @@ -28,12 +30,10 @@ import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class NijiPermissionsResolver implements PermissionsResolver { - private static final Logger log = LoggerFactory.getLogger(NijiPermissionsResolver.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final Server server; private final Permissions api; @@ -85,7 +85,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { return api.Security.permission(player, permission); } } catch (Throwable t) { - log.warn("Failed to check permissions", t); + LOGGER.warn("Failed to check permissions", t); return false; } } @@ -99,7 +99,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { return api.getHandler().has(server.getPlayerExact(name), permission); } } catch (Throwable t) { - log.warn("Failed to check permissions", t); + LOGGER.warn("Failed to check permissions", t); return false; } } @@ -118,7 +118,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { return api.Security.inGroup(name, group); } } catch (Throwable t) { - log.warn("Failed to check groups", t); + LOGGER.warn("Failed to check groups", t); return false; } } @@ -137,7 +137,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { } catch (Throwable t) { String group = api.Security.getGroup(player.getWorld().getName(), player.getName()); if (group != null) { - groups = new String[] { group }; + groups = new String[]{group}; } } if (groups == null) { @@ -146,7 +146,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { return groups; } } catch (Throwable t) { - log.warn("Failed to get groups", t); + LOGGER.warn("Failed to get groups", t); return new String[0]; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java index 3d684c8fb..d9a80dd53 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java @@ -21,14 +21,14 @@ package com.sk89q.wepif; import com.sk89q.util.yaml.YAMLFormat; import com.sk89q.util.yaml.YAMLProcessor; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.event.EventHandler; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.plugin.Plugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -59,6 +59,8 @@ public class PermissionsResolverManager implements PermissionsResolver { + "# - Lines starting with # are comments and so they are ignored.\r\n" + "\r\n"; + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private static PermissionsResolverManager instance; public static void initialize(Plugin plugin) { @@ -81,7 +83,6 @@ public class PermissionsResolverManager implements PermissionsResolver { private final Server server; private PermissionsResolver permissionResolver; private YAMLProcessor config; - private final Logger logger = LoggerFactory.getLogger(getClass()); private final List> enabledResolvers = new ArrayList<>(); @SuppressWarnings("unchecked") @@ -115,7 +116,7 @@ public class PermissionsResolverManager implements PermissionsResolver { break; } } catch (Throwable e) { - logger.warn("Error in factory method for " + resolverClass.getSimpleName(), e); + LOGGER.warn("Error in factory method for " + resolverClass.getSimpleName(), e); continue; } } @@ -123,7 +124,7 @@ public class PermissionsResolverManager implements PermissionsResolver { permissionResolver = new ConfigurationPermissionsResolver(config); } permissionResolver.load(); - logger.info("WEPIF: " + permissionResolver.getDetectionMessage()); + LOGGER.info("WEPIF: " + permissionResolver.getDetectionMessage()); } public void setPluginPermissionsResolver(Plugin plugin) { @@ -132,7 +133,7 @@ public class PermissionsResolverManager implements PermissionsResolver { } permissionResolver = new PluginPermissionsResolver((PermissionsProvider) plugin, plugin); - logger.info("WEPIF: " + permissionResolver.getDetectionMessage()); + LOGGER.info("WEPIF: " + permissionResolver.getDetectionMessage()); } @Override @@ -191,14 +192,14 @@ public class PermissionsResolverManager implements PermissionsResolver { try { file.createNewFile(); } catch (IOException e) { - logger.warn("Failed to create new configuration file", e); + LOGGER.warn("Failed to create new configuration file", e); } } config = new YAMLProcessor(file, false, YAMLFormat.EXTENDED); try { config.load(); } catch (IOException e) { - logger.warn("Error loading WEPIF configuration", e); + LOGGER.warn("Error loading WEPIF configuration", e); } List keys = config.getKeys(null); config.setHeader(CONFIG_HEADER); @@ -229,7 +230,7 @@ public class PermissionsResolverManager implements PermissionsResolver { } if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) { - logger.warn("WEPIF: Invalid or unknown class found in enabled resolvers: " + LOGGER.warn("WEPIF: Invalid or unknown class found in enabled resolvers: " + nextName + ". Moving to disabled resolvers list."); i.remove(); disabledResolvers.add(nextName); @@ -243,7 +244,7 @@ public class PermissionsResolverManager implements PermissionsResolver { if (!stagedEnabled.contains(clazz.getSimpleName()) && !disabledResolvers.contains(clazz.getSimpleName())) { disabledResolvers.add(clazz.getSimpleName()); - logger.info("New permissions resolver: " + LOGGER.info("New permissions resolver: " + clazz.getSimpleName() + " detected. " + "Added to disabled resolvers list."); isUpdated = true; @@ -264,7 +265,7 @@ public class PermissionsResolverManager implements PermissionsResolver { isUpdated = true; } if (isUpdated) { - logger.info("WEPIF: Updated config file"); + LOGGER.info("WEPIF: Updated config file"); config.save(); } return isUpdated; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java index 8fbdbea5e..b192b3ac0 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java @@ -22,14 +22,14 @@ package com.sk89q.worldedit.bukkit; import com.sk89q.bukkit.util.CommandInspector; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.enginehub.piston.CommandManager; import org.enginehub.piston.inject.InjectedValueStore; import org.enginehub.piston.inject.Key; import org.enginehub.piston.inject.MapBackedValueStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Optional; @@ -38,7 +38,7 @@ import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText; class BukkitCommandInspector implements CommandInspector { - private static final Logger logger = LoggerFactory.getLogger(BukkitCommandInspector.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final WorldEditPlugin plugin; private final CommandManager dispatcher; @@ -55,7 +55,7 @@ class BukkitCommandInspector implements CommandInspector { if (mapping.isPresent()) { return reduceToText(mapping.get().getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale); } else { - logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); + LOGGER.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); return "Help text not available"; } } @@ -66,7 +66,7 @@ class BukkitCommandInspector implements CommandInspector { if (mapping.isPresent()) { return reduceToText(mapping.get().getFullHelp(), WorldEdit.getInstance().getConfiguration().defaultLocale); } else { - logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); + LOGGER.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); return "Help text not available"; } } @@ -80,7 +80,7 @@ class BukkitCommandInspector implements CommandInspector { Optional.of(plugin.wrapCommandSender(sender))); return mapping.get().getCondition().satisfied(store); } else { - logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); + LOGGER.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); return false; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java index cbca361b0..7fff0a8d7 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java @@ -20,9 +20,11 @@ package com.sk89q.worldedit.bukkit; import com.sk89q.util.yaml.YAMLProcessor; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.YAMLConfiguration; import com.sk89q.worldedit.util.report.Unreported; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.File; import java.nio.file.Path; @@ -32,12 +34,14 @@ import java.nio.file.Path; */ public class BukkitConfiguration extends YAMLConfiguration { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + public boolean noOpPermissions = false; public boolean commandBlockSupport = false; @Unreported private final WorldEditPlugin plugin; public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) { - super(config, LoggerFactory.getLogger(plugin.getLogger().getName())); + super(config, LogManager.getLogger(plugin.getLogger().getName())); this.plugin = plugin; } @@ -60,10 +64,10 @@ public class BukkitConfiguration extends YAMLConfiguration { File toDir = new File(getWorkingDirectory(), file); if (fromDir.exists() & !toDir.exists()) { if (fromDir.renameTo(toDir)) { - plugin.getLogger().info("Migrated " + name + " folder '" + file - + "' from server root to plugin data folder."); + LOGGER.info("Migrated " + name + " folder '" + file + + "' from server root to plugin data folder."); } else { - plugin.getLogger().warning("Error while migrating " + name + " folder!"); + LOGGER.warn("Error while migrating " + name + " folder!"); } } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 2e5b56167..14d703213 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -26,13 +26,13 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.internal.wna.WorldNativeAccess; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; @@ -50,6 +50,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherTypes; import io.papermc.lib.PaperLib; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.TreeType; @@ -61,7 +62,6 @@ import org.bukkit.entity.Entity; import org.bukkit.inventory.DoubleChestInventory; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; -import org.slf4j.Logger; import java.lang.ref.WeakReference; import java.nio.file.Path; @@ -77,7 +77,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class BukkitWorld extends AbstractWorld { - private static final Logger logger = WorldEdit.logger; + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final boolean HAS_3D_BIOMES; @@ -213,7 +213,7 @@ public class BukkitWorld extends AbstractWorld { throw new UnsupportedOperationException("Missing BukkitImplAdapater for this version."); } } catch (Exception e) { - logger.warn("Regeneration via adapter failed.", e); + LOGGER.warn("Regeneration via adapter failed.", e); return false; } } @@ -292,9 +292,9 @@ public class BukkitWorld extends AbstractWorld { treeTypeMapping.put(TreeGenerator.TreeType.RANDOM_MUSHROOM, TreeType.BROWN_MUSHROOM); for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) { if (treeTypeMapping.get(type) == null) { - WorldEdit.logger.error("No TreeType mapping for TreeGenerator.TreeType." + type); + LOGGER.error("No TreeType mapping for TreeGenerator.TreeType." + type); // FAWE start - WorldEdit.logger.warn("Your FAWE version is newer than " + Bukkit.getVersion() + " and contains features of future minecraft versions which do not exist in " + Bukkit.getVersion() + ", hence the tree type " + type + " is not available."); + LOGGER.warn("Your FAWE version is newer than " + Bukkit.getVersion() + " and contains features of future minecraft versions which do not exist in " + Bukkit.getVersion() + ", hence the tree type " + type + " is not available."); // FAWE end } } @@ -449,7 +449,7 @@ public class BukkitWorld extends AbstractWorld { } catch (Exception e) { if (!hasWarnedImplError) { hasWarnedImplError = true; - logger.warn("Unable to retrieve block via impl adapter", e); + LOGGER.warn("Unable to retrieve block via impl adapter", e); } } } @@ -464,10 +464,10 @@ public class BukkitWorld extends AbstractWorld { return worldNativeAccess.setBlock(position, block, sideEffects); } catch (Exception e) { if (block instanceof BaseBlock && ((BaseBlock) block).getNbtData() != null) { - logger.warn("Tried to set a corrupt tile entity at " + position.toString() + LOGGER.warn("Tried to set a corrupt tile entity at " + position.toString() + ": " + ((BaseBlock) block).getNbtData(), e); } else { - logger.warn("Failed to set block via adapter, falling back to generic", e); + LOGGER.warn("Failed to set block via adapter, falling back to generic", e); } } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 17c22d8c9..f8578e967 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -43,6 +43,7 @@ import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.internal.anvil.ChunkDeleter; import com.sk89q.worldedit.internal.command.CommandUtil; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.entity.EntityType; @@ -51,6 +52,7 @@ import com.sk89q.worldedit.world.item.ItemCategory; import com.sk89q.worldedit.world.weather.WeatherTypes; import de.notmyfault.serverlib.ServerLib; import io.papermc.lib.PaperLib; +import org.apache.logging.log4j.Logger; import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -68,8 +70,6 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.File; import java.io.FileNotFoundException; @@ -93,7 +93,7 @@ import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAM */ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter - private static final Logger log = LoggerFactory.getLogger(WorldEditPlugin.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui"; private static WorldEditPlugin INSTANCE; @@ -129,7 +129,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter } return false; }).length > 0) { - getLogger().warning("DummyFawe detected and automatically deleted! This file is no longer necessary."); + LOGGER.warn("DummyFawe detected and automatically deleted! This file is no longer necessary."); } } @@ -162,8 +162,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // register this so we can load world-dependent data right as the first world is loading getServer().getPluginManager().registerEvents(new WorldInitListener(), this); } else { - getLogger().warning("Server reload detected. This may cause various issues with FastAsyncWorldEdit and dependent plugins."); - getLogger().warning("For more information, see https://matthewmiller.dev/blog/problem-with-reload/"); + LOGGER.warn("Server reload detected. This may cause various issues with FastAsyncWorldEdit and dependent plugins."); + LOGGER.warn("For more information, see https://matthewmiller.dev/blog/problem-with-reload/"); try { setupPreWorldData(); // since worlds are loaded already, we can do this now @@ -226,7 +226,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter } return defaultState; } catch (InputParseException e) { - getLogger().log(Level.WARNING, "Error loading block state for " + material.getKey(), e); + LOGGER.warn("Error loading block state for " + material.getKey(), e); return blockState; } })); @@ -260,7 +260,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString())); } } catch (NoSuchMethodError ignored) { - getLogger().warning("The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update."); + LOGGER.warn("The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update."); } } @@ -301,23 +301,23 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter try { adapterLoader.addFromPath(getClass().getClassLoader()); } catch (IOException e) { - log.warn("Failed to search path for Bukkit adapters"); + LOGGER.warn("Failed to search path for Bukkit adapters"); } try { adapterLoader.addFromJar(getFile()); } catch (IOException e) { - log.warn("Failed to search " + getFile() + " for Bukkit adapters", e); + LOGGER.warn("Failed to search " + getFile() + " for Bukkit adapters", e); } try { bukkitAdapter = adapterLoader.loadAdapter(); - log.info("Using " + bukkitAdapter.getClass().getCanonicalName() + " as the Bukkit adapter"); + LOGGER.info("Using " + bukkitAdapter.getClass().getCanonicalName() + " as the Bukkit adapter"); } catch (AdapterLoadException e) { Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING); if (platform instanceof BukkitServerInterface) { - log.warn(e.getMessage()); + LOGGER.warn(e.getMessage()); } else { - log.info("WorldEdit could not find a Bukkit adapter for this MC version, " + LOGGER.info("WorldEdit could not find a Bukkit adapter for this MC version, " + "but it seems that you have another implementation of WorldEdit installed (" + platform.getPlatformName() + ") " + "that handles the world editing."); } @@ -365,7 +365,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter } copyDefaultConfig(stream, actual, name); } catch (IOException e) { - getLogger().severe("Unable to read default configuration: " + name); + LOGGER.error("Unable to read default configuration: " + name); } } } @@ -378,9 +378,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter output.write(buf, 0, length); } - getLogger().info("Default configuration file written: " + name); + LOGGER.info("Default configuration file written: " + name); } catch (IOException e) { - getLogger().log(Level.WARNING, "Failed to write default config file", e); + LOGGER.warn("Failed to write default config file", e); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java index 5b11d7fc0..0398801b6 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java @@ -19,9 +19,9 @@ package com.sk89q.worldedit.bukkit.adapter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.io.Closer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -37,7 +37,7 @@ import java.util.jar.JarFile; */ public class BukkitImplLoader { - private static final Logger log = LoggerFactory.getLogger(BukkitImplLoader.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final List adapterCandidates = new ArrayList<>(); private String customCandidate; @@ -72,7 +72,7 @@ public class BukkitImplLoader { if (className != null) { customCandidate = className; adapterCandidates.add(className); - log.info("-Dworldedit.bukkit.adapter used to add " + className + " to the list of available Bukkit adapters"); + LOGGER.info("-Dworldedit.bukkit.adapter used to add " + className + " to the list of available Bukkit adapters"); } } @@ -165,14 +165,14 @@ public class BukkitImplLoader { return (BukkitImplAdapter) cls.newInstance(); } } catch (ClassNotFoundException e) { - log.warn("Failed to load the Bukkit adapter class '" + className + LOGGER.warn("Failed to load the Bukkit adapter class '" + className + "' that is not supposed to be missing", e); } catch (IllegalAccessException e) { - log.warn("Failed to load the Bukkit adapter class '" + className + LOGGER.warn("Failed to load the Bukkit adapter class '" + className + "' that is not supposed to be raising this error", e); } catch (Throwable e) { if (className.equals(customCandidate)) { - log.warn("Failed to load the Bukkit adapter class '" + className + "'", e); + LOGGER.warn("Failed to load the Bukkit adapter class '" + className + "'", e); } } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/Regenerator.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/Regenerator.java index 4bf5f1a7f..fcfecf57a 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/Regenerator.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/Regenerator.java @@ -6,6 +6,7 @@ import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; @@ -28,9 +29,9 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.stream.Collectors; + +import org.apache.logging.log4j.Logger; import org.bukkit.generator.BlockPopulator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Represents an abstract regeneration handler. @@ -41,7 +42,7 @@ import org.slf4j.LoggerFactory; */ public abstract class Regenerator> { - public static final Logger logger = LoggerFactory.getLogger(Regenerator.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); protected final org.bukkit.World originalBukkitWorld; protected final Region region; @@ -492,7 +493,7 @@ public abstract class Regenerator { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final Spigot_v1_15_R2 parent; private char[] ibdToStateOrdinal; private int[] ordinalToIbdID; @@ -343,9 +346,8 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I init(); return adaptToChar(ibd); } catch (ArrayIndexOutOfBoundsException e1) { - getLogger(FAWE_Spigot_v1_15_R2.class) - .error("Attempted to convert {} with ID {} to char. ibdToStateOrdinal length: {}. Defaulting to air!", - ibd.getBlock(), Block.REGISTRY_ID.getId(ibd), ibdToStateOrdinal.length, e1); + LOGGER.error("Attempted to convert {} with ID {} to char. ibdToStateOrdinal length: {}. Defaulting to air!", + ibd.getBlock(), Block.REGISTRY_ID.getId(ibd), ibdToStateOrdinal.length, e1); return 0; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R1.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R1.java index f0a82bfab..9a1a96a56 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R1.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R1.java @@ -42,6 +42,7 @@ import com.sk89q.worldedit.bukkit.adapter.impl.regen.Regen_v1_16_R1; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.LazyBaseEntity; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.internal.wna.WorldNativeAccess; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.registry.state.Property; @@ -80,6 +81,7 @@ import net.minecraft.server.v1_16_R1.PlayerChunk; import net.minecraft.server.v1_16_R1.TileEntity; import net.minecraft.server.v1_16_R1.World; import net.minecraft.server.v1_16_R1.WorldServer; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.data.BlockData; @@ -101,9 +103,10 @@ import java.util.Set; import java.util.function.Supplier; import java.util.stream.Stream; -import static org.slf4j.LoggerFactory.getLogger; - public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final Spigot_v1_16_R1 parent; private char[] ibdToStateOrdinal; private int[] ordinalToIbdID; @@ -343,9 +346,8 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I init(); return adaptToChar(ibd); } catch (ArrayIndexOutOfBoundsException e1) { - getLogger(FAWE_Spigot_v1_16_R1.class) - .error("Attempted to convert {} with ID {} to char. ibdToStateOrdinal length: {}. Defaulting to air!", - ibd.getBlock(), Block.REGISTRY_ID.getId(ibd), ibdToStateOrdinal.length, e1); + LOGGER.error("Attempted to convert {} with ID {} to char. ibdToStateOrdinal length: {}. Defaulting to air!", + ibd.getBlock(), Block.REGISTRY_ID.getId(ibd), ibdToStateOrdinal.length, e1); return 0; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R2.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R2.java index 690d8e2a7..ab32a7091 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R2.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R2.java @@ -42,6 +42,7 @@ import com.sk89q.worldedit.bukkit.adapter.impl.regen.Regen_v1_16_R2; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.LazyBaseEntity; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.internal.wna.WorldNativeAccess; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.registry.state.Property; @@ -81,6 +82,7 @@ import net.minecraft.server.v1_16_R2.PlayerChunk; import net.minecraft.server.v1_16_R2.TileEntity; import net.minecraft.server.v1_16_R2.World; import net.minecraft.server.v1_16_R2.WorldServer; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.data.BlockData; @@ -102,9 +104,10 @@ import java.util.Set; import java.util.function.Supplier; import java.util.stream.Stream; -import static org.slf4j.LoggerFactory.getLogger; - public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final Spigot_v1_16_R2 parent; private char[] ibdToStateOrdinal; private int[] ordinalToIbdID; @@ -345,9 +348,8 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I init(); return adaptToChar(ibd); } catch (ArrayIndexOutOfBoundsException e1) { - getLogger(FAWE_Spigot_v1_16_R2.class) - .error("Attempted to convert {} with ID {} to char. ibdToStateOrdinal length: {}. Defaulting to air!", - ibd.getBlock(), Block.REGISTRY_ID.getId(ibd), ibdToStateOrdinal.length, e1); + LOGGER.error("Attempted to convert {} with ID {} to char. ibdToStateOrdinal length: {}. Defaulting to air!", + ibd.getBlock(), Block.REGISTRY_ID.getId(ibd), ibdToStateOrdinal.length, e1); return 0; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R3.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R3.java index bad4e7b68..776af597d 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R3.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_16_R3.java @@ -42,6 +42,7 @@ import com.sk89q.worldedit.bukkit.adapter.impl.regen.Regen_v1_16_R3; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.LazyBaseEntity; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.internal.wna.WorldNativeAccess; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.registry.state.Property; @@ -81,6 +82,7 @@ import net.minecraft.server.v1_16_R3.PlayerChunk; import net.minecraft.server.v1_16_R3.TileEntity; import net.minecraft.server.v1_16_R3.World; import net.minecraft.server.v1_16_R3.WorldServer; +import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.data.BlockData; @@ -102,9 +104,10 @@ import java.util.Set; import java.util.function.Supplier; import java.util.stream.Stream; -import static org.slf4j.LoggerFactory.getLogger; - public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final Spigot_v1_16_R3 parent; private char[] ibdToStateOrdinal; private int[] ordinalToIbdID; @@ -345,9 +348,8 @@ public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements I init(); return adaptToChar(ibd); } catch (ArrayIndexOutOfBoundsException e1) { - getLogger(FAWE_Spigot_v1_16_R3.class) - .error("Attempted to convert {} with ID {} to char. ibdToStateOrdinal length: {}. Defaulting to air!", - ibd.getBlock(), Block.REGISTRY_ID.getId(ibd), ibdToStateOrdinal.length, e1); + LOGGER.error("Attempted to convert {} with ID {} to char. ibdToStateOrdinal length: {}. Defaulting to air!", + ibd.getBlock(), Block.REGISTRY_ID.getId(ibd), ibdToStateOrdinal.length, e1); return 0; } } diff --git a/worldedit-cli/build.gradle.kts b/worldedit-cli/build.gradle.kts index 4dd986639..8214f693b 100644 --- a/worldedit-cli/build.gradle.kts +++ b/worldedit-cli/build.gradle.kts @@ -10,13 +10,15 @@ applyShadowConfiguration() addJarManifest(WorldEditKind.Standalone("com.sk89q.worldedit.cli.CLIWorldEdit")) dependencies { - "api"(project(":worldedit-core")) - "implementation"(platform("org.apache.logging.log4j:log4j-bom:2.14.0")) - "implementation"("org.apache.logging.log4j:log4j-core") - "implementation"("org.apache.logging.log4j:log4j-slf4j-impl") - "implementation"("commons-cli:commons-cli:1.4") - "implementation"("com.google.guava:guava") - "implementation"("com.google.code.gson:gson") + api(project(":worldedit-core")) + implementation(platform("org.apache.logging.log4j:log4j-bom:2.14.1") { + because("We control Log4J on this platform") + }) + implementation("org.apache.logging.log4j:log4j-api") + implementation("org.apache.logging.log4j:log4j-core") + implementation("commons-cli:commons-cli:1.4") + implementation("com.google.guava:guava") + implementation("com.google.code.gson:gson") } tasks.named("shadowJar") { diff --git a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java index 10e1fe7b3..912172564 100644 --- a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java +++ b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java @@ -28,8 +28,7 @@ import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.serializer.plain.PlainComponentSerializer; -import org.slf4j.Logger; - +import org.apache.logging.log4j.Logger; import java.io.File; import java.util.Locale; import java.util.Map; diff --git a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java index bd0d968b3..5e3638beb 100644 --- a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java +++ b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java @@ -31,6 +31,7 @@ import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.biome.BiomeType; @@ -44,8 +45,7 @@ import com.sk89q.worldedit.world.item.ItemType; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.Options; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.ByteArrayInputStream; import java.io.File; @@ -67,7 +67,7 @@ import java.util.Scanner; */ public class CLIWorldEdit { - private static final Logger LOGGER = LoggerFactory.getLogger(CLIWorldEdit.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public static CLIWorldEdit inst; diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 7b462f0e9..579cfd575 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -12,11 +12,6 @@ repositories { maven { name = "IntellectualSites" url = uri("https://mvn.intellectualsites.com/content/groups/public/") - content { - includeGroup("com.plotsquared") - includeGroup("com.intellectualsites.paster") - includeGroup("com.github.intellectualsites.plotsquared") - } } } @@ -32,13 +27,14 @@ dependencies { api(project(":worldedit-libs:core")) implementation("de.schlichtherle:truezip:6.8.4") - implementation("net.java.truevfs:truevfs-profile-default_2.13:0.12.2") implementation("org.mozilla:rhino-runtime:1.7.13") implementation("org.yaml:snakeyaml") implementation("com.google.guava:guava") implementation("com.google.code.findbugs:jsr305:3.0.2") implementation("com.google.code.gson:gson") - implementation("org.slf4j:slf4j-api:${Versions.SLF4J}") + implementation("org.apache.logging.log4j:log4j-api:2.8.1") { + because("Mojang provides Log4J 2.8.1") + } implementation("it.unimi.dsi:fastutil") val antlrVersion = "4.9.1" @@ -54,7 +50,7 @@ dependencies { annotationProcessor("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}") testImplementation("ch.qos.logback:logback-core:${Versions.LOGBACK}") testImplementation("ch.qos.logback:logback-classic:${Versions.LOGBACK}") - implementation("com.github.luben:zstd-jni:1.4.8-6") + implementation("com.github.luben:zstd-jni:1.4.9-2") compileOnly("net.fabiozumbi12:redprotect:1.9.6") api("com.github.intellectualsites.plotsquared:PlotSquared-API:4.514") { isTransitive = false } api("com.plotsquared:PlotSquared-Core:5.13.3") { isTransitive = false } @@ -109,7 +105,7 @@ tasks.named("processResources") { } tasks.named("shadowJar") { dependencies { - include(dependency("com.github.luben:zstd-jni:1.4.8-6")) + include(dependency("com.github.luben:zstd-jni:1.4.9-2")) } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index 41104b552..514de4a33 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -14,8 +14,8 @@ import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.WEManager; import com.github.luben.zstd.util.Native; import com.sk89q.worldedit.WorldEdit; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.io.BufferedReader; import java.io.File; @@ -73,7 +73,7 @@ import javax.management.NotificationEmitter; */ public class Fawe { - private static final Logger log = LoggerFactory.getLogger(Fawe.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static Fawe instance; @@ -250,7 +250,7 @@ public class Fawe { try { Settings.IMP.reload(file); } catch (Throwable e) { - log.error("Failed to load config.", e); + LOGGER.error("Failed to load config.", e); } } @@ -272,14 +272,14 @@ public class Fawe { if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.IMP.HISTORY.COMPRESSION_LEVEL > 6) { Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL); Settings.IMP.HISTORY.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.HISTORY.COMPRESSION_LEVEL); - log.error("ZSTD Compression Binding Not Found.\n" + LOGGER.error("ZSTD Compression Binding Not Found.\n" + "FAWE will still work but compression won't work as well.\n", e); } } try { net.jpountz.util.Native.load(); } catch (Throwable e) { - log.error("LZ4 Compression Binding Not Found.\n" + LOGGER.error("LZ4 Compression Binding Not Found.\n" + "FAWE will still work but compression will be slower.\n", e); } } @@ -288,7 +288,7 @@ public class Fawe { boolean x86OS = System.getProperty("sun.arch.data.model").contains("32"); boolean x86JVM = System.getProperty("os.arch").contains("32"); if (x86OS != x86JVM) { - log.info("You are running 32-bit Java on a 64-bit machine. Please upgrade to 64-bit Java."); + LOGGER.info("You are running 32-bit Java on a 64-bit machine. Please upgrade to 64-bit Java."); } } @@ -322,7 +322,7 @@ public class Fawe { } } } catch (Throwable ignored) { - log.error("FAWE encountered an error trying to listen to JVM memory.\n" + LOGGER.error("FAWE encountered an error trying to listen to JVM memory.\n" + "Please change your Java security settings or disable this message by" + "changing 'max-memory-percent' in the config files to '-1'."); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java index 178dfd3f8..a2461c55f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -30,10 +30,12 @@ import com.sk89q.jnbt.LongTag; import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.block.BlockTypesCache; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -56,12 +58,13 @@ import java.util.function.Function; import java.util.function.Supplier; import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; public enum FaweCache implements Trimable { IMP ; // singleton + private static final Logger LOGGER = LogManagerCompat.getLogger(); + public final int BLOCKS_PER_LAYER = 4096; public final int CHUNK_LAYERS = 16; public final int WORLD_HEIGHT = CHUNK_LAYERS << 4; @@ -503,7 +506,7 @@ public enum FaweCache implements Trimable { } else if (value instanceof Boolean) { return asTag((byte) ((boolean) value ? 1 : 0)); } - getLogger(FaweCache.class).error("Invalid nbt: {}", value); + LOGGER.error("Invalid nbt: {}", value); return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java index 802bec530..1c36d53a4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java @@ -14,7 +14,7 @@ import java.util.Set; import java.util.concurrent.Future; import java.util.function.Function; -import static org.slf4j.LoggerFactory.getLogger; +import static org.apache.logging.log4j.LogManager.getLogger; public interface IBatchProcessor { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java index d146043aa..7f19b2da3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharBlocks.java @@ -3,15 +3,15 @@ package com.boydti.fawe.beta.implementation.blocks; import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IChunkSet; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypesCache; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Range; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public abstract class CharBlocks implements IBlocks { - public static final Logger logger = LoggerFactory.getLogger(CharBlocks.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); protected static final Section FULL = new Section() { @Override @@ -139,9 +139,9 @@ public abstract class CharBlocks implements IBlocks { try { set(layer, index, value); } catch (ArrayIndexOutOfBoundsException exception) { - logger.error("Tried setting block at coordinates (" + x + "," + y + "," + z + ")"); + LOGGER.error("Tried setting block at coordinates (" + x + "," + y + "," + z + ")"); assert Fawe.imp() != null; - logger.error("Layer variable was = {}", layer, exception); + LOGGER.error("Layer variable was = {}", layer, exception); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/lighting/NMSRelighter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/lighting/NMSRelighter.java index 87f368f06..ecde93ef5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/lighting/NMSRelighter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/lighting/NMSRelighter.java @@ -10,6 +10,7 @@ import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.collection.BlockVectorSet; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TaskManager; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.registry.state.BooleanProperty; import com.sk89q.worldedit.registry.state.DirectionalProperty; @@ -20,8 +21,7 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.util.ArrayDeque; import java.util.ArrayList; @@ -41,7 +41,7 @@ import java.util.stream.Collectors; public class NMSRelighter implements Relighter { - private static final Logger log = LoggerFactory.getLogger(NMSRelighter.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final int DISPATCH_SIZE = 64; private static final DirectionalProperty stairDirection; private static final EnumProperty stairHalf; @@ -1028,8 +1028,8 @@ public class NMSRelighter implements Relighter { heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] = y + 1; } } catch (Exception ignored) { - log.debug("Error calculating waterlogged state for BlockState: " + state.getBlockType().getId() + ". States:"); - log.debug(states.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()) + LOGGER.debug("Error calculating waterlogged state for BlockState: " + state.getBlockType().getId() + ". States:"); + LOGGER.debug(states.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()) .collect(Collectors.joining(", ", "{", "}"))); } try { @@ -1039,8 +1039,8 @@ public class NMSRelighter implements Relighter { heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] = y + 1; } } catch (Exception ignored) { - log.debug("Error calculating waterlogged state for BlockState: " + state.getBlockType().getId() + ". States:"); - log.debug(states.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()) + LOGGER.debug("Error calculating waterlogged state for BlockState: " + state.getBlockType().getId() + ". States:"); + LOGGER.debug(states.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()) .collect(Collectors.joining(", ", "{", "}"))); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java index a75b6e51c..dd144b03c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java @@ -10,8 +10,6 @@ import com.boydti.fawe.util.StringMan; import com.google.common.cache.LoadingCache; import com.sk89q.worldedit.extent.Extent; import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Arrays; @@ -28,8 +26,6 @@ import java.util.function.Supplier; public class MultiBatchProcessor implements IBatchProcessor { - private static final Logger log = LoggerFactory.getLogger(MultiBatchProcessor.class); - private IBatchProcessor[] processors; private final LoadingCache, Map> classToThreadIdToFilter = FaweCache.IMP.createCache((Supplier>) ConcurrentHashMap::new); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java index 94ba81200..4b0e7b2ab 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java @@ -21,9 +21,9 @@ import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MemUtil; import com.google.common.util.concurrent.Futures; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutionException; @@ -38,8 +38,7 @@ import java.util.concurrent.locks.ReentrantLock; */ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent { - // Don't bother with the full classpath. - private static final Logger log = LoggerFactory.getLogger("SingleThreadQueueExtent"); + private static final Logger LOGGER = LogManagerCompat.getLogger(); // Pool discarded chunks for reuse (can safely be cleared by another thread) // private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>(); @@ -302,10 +301,10 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen future = (Future) future.get(); } } catch (FaweException messageOnly) { - log.warn(messageOnly.getMessage()); + LOGGER.warn(messageOnly.getMessage()); } catch (ExecutionException e) { if (e.getCause() instanceof FaweException) { - log.warn(e.getCause().getClass().getCanonicalName() + ": " + e.getCause().getMessage()); + LOGGER.warn(e.getCause().getClass().getCanonicalName() + ": " + e.getCause().getMessage()); } else { e.printStackTrace(); } @@ -321,10 +320,10 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen first = (Future) first.get(); } } catch (FaweException messageOnly) { - log.warn(messageOnly.getMessage()); + LOGGER.warn(messageOnly.getMessage()); } catch (ExecutionException e) { if (e.getCause() instanceof FaweException) { - log.warn(e.getCause().getClass().getCanonicalName() + ": " + e.getCause().getMessage()); + LOGGER.warn(e.getCause().getClass().getCanonicalName() + ": " + e.getCause().getMessage()); } else { e.printStackTrace(); } @@ -340,14 +339,14 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen try { next = (Future) next.get(); } catch (FaweException messageOnly) { - log.warn(messageOnly.getMessage()); + LOGGER.warn(messageOnly.getMessage()); } catch (ExecutionException e) { if (e.getCause() instanceof FaweException) { - log.warn(e.getCause().getClass().getCanonicalName() + ": " + e.getCause().getMessage()); + LOGGER.warn(e.getCause().getClass().getCanonicalName() + ": " + e.getCause().getMessage()); } else { e.printStackTrace(); } - log.error("Please report this error on our issue tracker"); + LOGGER.error("Please report this error on our issue tracker: https://github.com/IntellectualSites/FastAsyncWorldEdit/issues"); e.getCause().printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java index 79265525f..20966fdd0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java @@ -3,8 +3,8 @@ package com.boydti.fawe.config; import com.boydti.fawe.configuration.MemorySection; import com.boydti.fawe.configuration.file.YamlConfiguration; import com.boydti.fawe.util.StringMan; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.io.ByteArrayOutputStream; import java.io.File; @@ -26,7 +26,7 @@ import java.util.Map; public class Config { - private final Logger log = LoggerFactory.getLogger(Config.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public Config() { save(new PrintWriter(new ByteArrayOutputStream(0)), getClass(), this, 0); @@ -48,7 +48,7 @@ public class Config { } } } - log.debug("Failed to get config option: " + key); + LOGGER.debug("Failed to get config option: " + key); return null; } @@ -79,7 +79,7 @@ public class Config { } } } - log.debug("Failed to set config option: " + key + ": " + value + " | " + instance + " | " + root.getSimpleName() + ".yml"); + LOGGER.debug("Failed to set config option: " + key + ": " + value + " | " + instance + " | " + root.getSimpleName() + ".yml"); } public boolean load(File file) { @@ -333,7 +333,7 @@ public class Config { setAccessible(field); return field; } catch (Throwable ignored) { - log.debug("Invalid config field: " + StringMan.join(split, ".") + " for " + toNodeName(instance.getClass().getSimpleName())); + LOGGER.debug("Invalid config field: " + StringMan.join(split, ".") + " for " + toNodeName(instance.getClass().getSimpleName())); return null; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfiguration.java b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfiguration.java index 2f49b9d0f..bfda6e19c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfiguration.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/configuration/file/YamlConfiguration.java @@ -3,7 +3,9 @@ package com.boydti.fawe.configuration.file; import com.boydti.fawe.configuration.Configuration; import com.boydti.fawe.configuration.ConfigurationSection; import com.boydti.fawe.configuration.InvalidConfigurationException; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.YAMLConfiguration; +import org.apache.logging.log4j.Logger; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; @@ -16,13 +18,13 @@ import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.Map; -import static org.slf4j.LoggerFactory.getLogger; - /** * An implementation of {@link com.boydti.fawe.configuration.Configuration} which saves all files in Yaml. * Note that this implementation is not synchronized. */ public class YamlConfiguration extends FileConfiguration { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); protected static final String COMMENT_PREFIX = "# "; protected static final String BLANK_CONFIG = "{}\n"; private final DumperOptions yamlOptions = new DumperOptions(); @@ -64,8 +66,7 @@ public class YamlConfiguration extends FileConfiguration { dest = new File(file.getAbsolutePath() + "_broken_" + i++); } Files.copy(file.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); - getLogger(YamlConfiguration.class).error("Could not read: {}\n" - + "Renamed to: {}", file, dest.getName(), ex); + LOGGER.error("Could not read {}\n" + "Renamed to {}", file, dest.getAbsolutePath(), ex); } catch (final IOException e) { e.printStackTrace(); } @@ -97,7 +98,7 @@ public class YamlConfiguration extends FileConfiguration { try { config.load(reader); } catch (final IOException | InvalidConfigurationException ex) { - getLogger(YAMLConfiguration.class).error("Cannot load configuration from stream", ex); + LOGGER.error("Cannot load configuration from stream", ex); } return config; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/configuration/serialization/ConfigurationSerialization.java b/worldedit-core/src/main/java/com/boydti/fawe/configuration/serialization/ConfigurationSerialization.java index f3249bbbf..38f8559d0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/configuration/serialization/ConfigurationSerialization.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/configuration/serialization/ConfigurationSerialization.java @@ -1,7 +1,8 @@ package com.boydti.fawe.configuration.serialization; import com.boydti.fawe.configuration.Configuration; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; @@ -14,6 +15,8 @@ import java.util.Map; */ public class ConfigurationSerialization { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + public static final String SERIALIZED_TYPE_KEY = "=="; private static final Map> aliases = new HashMap<>(); @@ -196,15 +199,14 @@ public class ConfigurationSerialization { ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args); if (result == null) { - LoggerFactory.getLogger(ConfigurationSerialization.class).error( - "Could not call method '" + method.toString() + "' of " + this.clazz + " for deserialization: method returned null"); + LOGGER.error("Could not call method '" + method.toString() + "' of " + this.clazz + " for deserialization: method returned null"); } else { return result; } } catch (Throwable ex) { - LoggerFactory.getLogger(ConfigurationSerialization.class).error("Could not call method '" + method.toString() + "' of " + this.clazz - + " for deserialization", - ex instanceof InvocationTargetException ? ex.getCause() : ex); + LOGGER.error("Could not call method '" + method.toString() + "' of " + this.clazz + + " for deserialization", + ex instanceof InvocationTargetException ? ex.getCause() : ex); } return null; @@ -214,9 +216,9 @@ public class ConfigurationSerialization { try { return ctor.newInstance(args); } catch (Throwable ex) { - LoggerFactory.getLogger(ConfigurationSerialization.class).error("Could not call constructor '" + ctor.toString() + "' of " + this.clazz - + " for deserialization", - ex instanceof InvocationTargetException ? ex.getCause() : ex); + LOGGER.error("Could not call constructor '" + ctor.toString() + "' of " + this.clazz + + " for deserialization", + ex instanceof InvocationTargetException ? ex.getCause() : ex); } return null; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/database/DBHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/database/DBHandler.java index c362be76b..fad5fde28 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/database/DBHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/database/DBHandler.java @@ -1,16 +1,15 @@ package com.boydti.fawe.database; -import com.boydti.fawe.config.Config; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.world.World; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class DBHandler { - private final Logger log = LoggerFactory.getLogger(Config.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public static final DBHandler IMP = new DBHandler(); @@ -26,7 +25,7 @@ public class DBHandler { databases.put(world, database); return database; } catch (Throwable e) { - log.error("No JDBC driver found!", e); + LOGGER.error("No JDBC driver found!", e); return null; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/database/RollbackDatabase.java b/worldedit-core/src/main/java/com/boydti/fawe/database/RollbackDatabase.java index f358498e7..8543e434d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/database/RollbackDatabase.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/database/RollbackDatabase.java @@ -6,13 +6,13 @@ import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; import com.boydti.fawe.object.collection.YieldIterable; import com.boydti.fawe.object.task.AsyncNotifyQueue; import com.boydti.fawe.util.MainUtil; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; +import org.apache.logging.log4j.Logger; import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -32,7 +32,7 @@ import java.util.stream.IntStream; public class RollbackDatabase extends AsyncNotifyQueue { - private static final Logger log = LoggerFactory.getLogger(RollbackDatabase.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final String prefix; private final File dbLocation; @@ -309,7 +309,7 @@ public class RollbackDatabase extends AsyncNotifyQueue { dbLocation.createNewFile(); } catch (IOException e) { e.printStackTrace(); - log.debug("Unable to create the database!"); + LOGGER.error("Unable to create the database!"); } } Class.forName("org.sqlite.JDBC"); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java index 96cf60469..8b55fa318 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java @@ -17,6 +17,7 @@ import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.NBTConstants; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTOutputStream; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.registry.state.Property; @@ -30,6 +31,7 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.util.ArrayList; @@ -44,9 +46,10 @@ import java.util.UUID; import java.util.concurrent.Future; import javax.annotation.Nullable; -import static org.slf4j.LoggerFactory.getLogger; - public class MCAChunk implements IChunk { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + public final boolean[] hasSections = new boolean[16]; public boolean hasBiomes = false; @@ -310,7 +313,7 @@ public class MCAChunk implements IChunk { Object value = state.getState(property); String valueStr = value.toString(); if (Character.isUpperCase(valueStr.charAt(0))) { - getLogger(MCAChunk.class).warn("Invalid uppercase value {}", value); + LOGGER.warn("Invalid uppercase value {}", value); valueStr = valueStr.toLowerCase(Locale.ROOT); } out.writeNamedTag(key, valueStr); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java index bcda322c3..2825b1c5f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java @@ -12,11 +12,13 @@ import com.boydti.fawe.util.MathMan; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream; +import org.apache.logging.log4j.Logger; import java.io.BufferedInputStream; import java.io.File; @@ -38,8 +40,6 @@ import java.util.zip.Deflater; import java.util.zip.Inflater; import java.util.zip.InflaterInputStream; -import static org.slf4j.LoggerFactory.getLogger; - /** * Chunk format: http://minecraft.gamepedia.com/Chunk_format#Entity_format * e.g., `.Level.Entities.#` (Starts with a . as the root tag is unnamed) @@ -47,6 +47,8 @@ import static org.slf4j.LoggerFactory.getLogger; */ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, IChunkExtent { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private static Field fieldBuf2; static { @@ -294,7 +296,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh if (offset < offsets.length) { offsets[offset] = i; } else { - getLogger(MCAFile.class).debug("Ignoring invalid offset " + offset); + LOGGER.debug("Ignoring invalid offset " + offset); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/streamer/StreamDelegate.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/streamer/StreamDelegate.java index eea8b8545..fe3f9dbdf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/streamer/StreamDelegate.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/streamer/StreamDelegate.java @@ -2,13 +2,16 @@ package com.boydti.fawe.jnbt.streamer; import com.sk89q.jnbt.NBTConstants; import com.sk89q.jnbt.NBTInputStream; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.io.DataInputStream; import java.io.IOException; -import static org.slf4j.LoggerFactory.getLogger; - public class StreamDelegate { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private static final byte[][] ZERO_KEYS = new byte[0][]; private static final StreamDelegate[] ZERO_VALUES = new StreamDelegate[0]; @@ -41,7 +44,7 @@ public class StreamDelegate { private StreamDelegate add(String name, StreamDelegate scope) { if (valueReader != null) { - getLogger(StreamDelegate.class).warn("Scope {} | {} may not run, as the stream is only read once, and a value reader is already set", name, scope); + LOGGER.warn("Scope {} | {} may not run, as the stream is only read once, and a value reader is already set", name, scope); } byte[] bytes = name.getBytes(NBTConstants.CHARSET); int maxSize = bytes.length; @@ -169,7 +172,7 @@ public class StreamDelegate { public StreamDelegate withValue(ValueReader valueReader) { if (keys.length != 0) { - getLogger(StreamDelegate.class).warn("Reader {} may not run, as the stream is only read once, and a value reader is already set", valueReader); + LOGGER.warn("Reader {} may not run, as the stream is only read once, and a value reader is already set", valueReader); } this.valueReader = valueReader; return this; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java b/worldedit-core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java index b18795a43..7a8075852 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java @@ -4,17 +4,20 @@ import com.boydti.fawe.database.DBHandler; import com.boydti.fawe.database.RollbackDatabase; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.SimpleChangeSetSummary; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.io.OutputStream; import java.util.UUID; -import static org.slf4j.LoggerFactory.getLogger; - public class RollbackOptimizedHistory extends DiskStorageHistory { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private long time; private int minX; @@ -47,7 +50,7 @@ public class RollbackOptimizedHistory extends DiskStorageHistory { this.blockSize = (int) size; this.command = command; this.closed = true; - getLogger(RollbackOptimizedHistory.class).debug("Size {}", size); + LOGGER.debug("Size: {}", size); } public long getTime() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java index 0ad63a830..0898724d2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/InspectBrush.java @@ -14,6 +14,7 @@ import com.sk89q.worldedit.command.tool.BrushTool; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; @@ -24,16 +25,17 @@ import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.util.Iterator; import java.util.UUID; import java.util.function.Supplier; -import static org.slf4j.LoggerFactory.getLogger; - public class InspectBrush extends BrushTool { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + /** * Construct the tool. */ @@ -64,13 +66,13 @@ public class InspectBrush extends BrushTool { public boolean perform(final Player player, LocalSession session, boolean rightClick) { if (!player.hasPermission("worldedit.tool.inspect")) { player.print(Caption.of("", "worldedit.tool.inspect")); - getLogger(InspectBrush.class).debug("No tool control"); + LOGGER.debug("No tool control"); return false; } if (!Settings.IMP.HISTORY.USE_DATABASE) { player.print(Caption.of("fawe.error.setting.disable", "history.use-database (Import with /history import )")); - getLogger(InspectBrush.class).debug("No db"); + LOGGER.debug("No db"); return false; } try { @@ -113,7 +115,7 @@ public class InspectBrush extends BrushTool { } catch (IOException e) { throw new RuntimeException(e); } catch (Throwable e) { - getLogger(InspectBrush.class).error("E throw", e); + LOGGER.error("E throw", e); } return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java index f7e143db1..80ba36633 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java @@ -37,6 +37,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; @@ -60,6 +61,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; +import org.apache.logging.log4j.Logger; import java.awt.image.BufferedImage; import java.io.File; @@ -75,10 +77,10 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.function.Supplier; import javax.annotation.Nullable; -import static org.slf4j.LoggerFactory.getLogger; - public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final MutableBlockVector3 mutable = new MutableBlockVector3(); private final DifferentialBlockBuffer blocks; @@ -2128,7 +2130,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr @Override public IChunkGet get(int x, int z) { - getLogger(HeightMapMCAGenerator.class).debug("Should not be using buffering with HMMG"); + LOGGER.debug("Should not be using buffering with HMMG"); return new FallbackChunkGet(this, x, z); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/CFIChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/CFIChange.java index 9c791fffa..ecbb55dc8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/CFIChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/CFIChange.java @@ -5,14 +5,18 @@ import com.boydti.fawe.util.ExtentTraverser; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.change.Change; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; public class CFIChange implements Change { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final File file; public CFIChange(File file) { @@ -25,7 +29,7 @@ public class CFIChange implements Change { if (found != null) { return found.get(); } - getLogger(CFIChange.class).debug("FAWE does not support: " + context.getExtent() + " for " + getClass() + " (bug Empire92)"); + LOGGER.debug("FAWE does not support: " + context.getExtent() + " for " + getClass() + " (bug Empire92)"); return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java index 0cee1cb6c..1b3cfaa42 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableEntityChange.java @@ -10,18 +10,20 @@ import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.change.Change; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; +import org.apache.logging.log4j.Logger; import java.util.List; import java.util.Map; import java.util.UUID; -import static org.slf4j.LoggerFactory.getLogger; - public class MutableEntityChange implements Change { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + public CompoundTag tag; public boolean create; @@ -59,7 +61,7 @@ public class MutableEntityChange implements Change { most = ((LongTag) map.get("PersistentIDMSB")).getValue(); least = ((LongTag) map.get("PersistentIDLSB")).getValue(); } else { - getLogger(MutableEntityChange.class).debug("Skipping entity without uuid."); + LOGGER.debug("Skipping entity without uuid."); return; } List pos = (List) map.get("Pos").getValue(); @@ -74,7 +76,7 @@ public class MutableEntityChange implements Change { Map map = tag.getValue(); Tag posTag = map.get("Pos"); if (posTag == null) { - getLogger(MutableEntityChange.class).debug("Missing pos tag: " + tag); + LOGGER.debug("Missing pos tag: " + tag); return; } List pos = (List) posTag.getValue(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java index 9de6569be..d70791e63 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java @@ -38,7 +38,7 @@ import java.util.UUID; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicInteger; -import static org.slf4j.LoggerFactory.getLogger; +import static org.apache.logging.log4j.LogManager.getLogger; public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java index 38914a944..d75330581 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java @@ -11,6 +11,7 @@ import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; @@ -21,8 +22,7 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.io.Closeable; @@ -53,7 +53,7 @@ import java.util.stream.Collectors; */ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable { - private static final Logger log = LoggerFactory.getLogger(DiskOptimizedClipboard.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final int HEADER_SIZE = 14; @@ -80,7 +80,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable if (HEADER_SIZE + ((long) getVolume() << 1) >= Integer.MAX_VALUE) { throw new IllegalArgumentException("Dimensions too large for this clipboard format. Use //lazycopy for large selections."); } else if (HEADER_SIZE + ((long) getVolume() << 1) + (long) ((getHeight() >> 2) + 1) * ((getLength() >> 2) + 1) * ((getWidth() >> 2) + 1) >= Integer.MAX_VALUE) { - log.error("Dimensions are too large for biomes to be stored in a DiskOptimizedClipboard"); + LOGGER.error("Dimensions are too large for biomes to be stored in a DiskOptimizedClipboard"); canHaveBiomes = false; } nbtMap = new HashMap<>(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java index ac253155c..059c4100e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/MinecraftStructure.java @@ -15,6 +15,7 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; @@ -29,6 +30,7 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.storage.NBTConversions; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -39,9 +41,10 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import static org.slf4j.LoggerFactory.getLogger; - public class MinecraftStructure implements ClipboardReader, ClipboardWriter { + + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private static final int WARN_SIZE = 32; private NBTInputStream inputStream; @@ -160,7 +163,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { int height = region.getHeight(); int length = region.getLength(); if (width > WARN_SIZE || height > WARN_SIZE || length > WARN_SIZE) { - getLogger(MinecraftStructure.class).debug("A structure longer than 32 is unsupported by minecraft (but probably still works)"); + LOGGER.info("A structure longer than 32 is unsupported by minecraft (but probably still works)"); } Map structure = FaweCache.IMP.asMap("version", 1, "author", owner); // ignored: version / owner diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java index 1ba46a53a..88e02a877 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java @@ -36,14 +36,14 @@ import com.sk89q.worldedit.event.extent.EditSessionEvent; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.inventory.BlockBag; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.util.eventbus.EventBus; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Locale; import java.util.UUID; @@ -53,7 +53,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class EditSessionBuilder { - private static final Logger logger = LoggerFactory.getLogger(AbstractDelegateExtent.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); @NotNull private World world; @@ -246,11 +246,11 @@ public class EditSessionBuilder { event.getActor().printDebug(" - To allow this plugin add it to the FAWE `allowed-plugins` list"); event.getActor().printDebug(" - To hide this message set `debug` to false in the FAWE config.yml"); } else { - logger.debug("Potentially unsafe extent blocked: " + toReturn.getClass().getName()); - logger.debug(" - For area restrictions, it is recommended to use the FaweAPI"); - logger.debug(" - For block logging, it is recommended to use BlocksHub"); - logger.debug(" - To allow this plugin add it to the FAWE `allowed-plugins` list"); - logger.debug(" - To hide this message set `debug` to false in the FAWE config.yml"); + LOGGER.debug("Potentially unsafe extent blocked: " + toReturn.getClass().getName()); + LOGGER.debug(" - For area restrictions, it is recommended to use the FaweAPI"); + LOGGER.debug(" - For block logging, it is recommended to use BlocksHub"); + LOGGER.debug(" - To allow this plugin add it to the FAWE `allowed-plugins` list"); + LOGGER.debug(" - To hide this message set `debug` to false in the FAWE config.yml"); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java index ec054018c..c53fe0f29 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java @@ -21,6 +21,7 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.history.changeset.ChangeSet; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; @@ -32,6 +33,7 @@ import net.jpountz.lz4.LZ4Factory; import net.jpountz.lz4.LZ4FastDecompressor; import net.jpountz.lz4.LZ4InputStream; import net.jpountz.lz4.LZ4Utils; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; @@ -89,10 +91,10 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import static java.lang.System.arraycopy; -import static org.slf4j.LoggerFactory.getLogger; - public class MainUtil { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + public static List filter(String prefix, List suggestions) { if (prefix.isEmpty()) { return suggestions; @@ -438,7 +440,7 @@ public class MainUtil { content = scanner.next().trim(); } if (!content.startsWith("<")) { - getLogger(MainUtil.class).debug(content); + LOGGER.debug(content); } if (responseCode == 200) { return url; @@ -638,7 +640,7 @@ public class MainUtil { return newFile; } } catch (IOException e) { - getLogger(MainUtil.class).debug("Could not save " + resource, e); + LOGGER.debug("Could not save " + resource, e); } return null; } @@ -880,7 +882,7 @@ public class MainUtil { pool.submit(file::delete); Component msg = TranslatableComponent.of("worldedit.schematic.delete.deleted"); if (printDebug) { - getLogger(MainUtil.class).debug(msg.toString()); + LOGGER.debug(msg.toString()); } } }); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java index cad8fc63f..47ff2b0d9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java @@ -4,6 +4,8 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.RunnableVal; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -15,10 +17,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; import javax.annotation.Nullable; -import static org.slf4j.LoggerFactory.getLogger; - public abstract class TaskManager { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + public static TaskManager IMP; private final ForkJoinPool pool = new ForkJoinPool(); @@ -257,7 +259,7 @@ public abstract class TaskManager { running.wait(timeout); if (running.get() && System.currentTimeMillis() - start > Settings.IMP.QUEUE.DISCARD_AFTER_MS) { new RuntimeException("FAWE is taking a long time to execute a task (might just be a symptom): ").printStackTrace(); - getLogger(TaskManager.class).debug("For full debug information use: /fawe threads"); + LOGGER.info("For full debug information use: /fawe threads"); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java index 4ed958171..5ece687e1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java @@ -9,6 +9,7 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.PropertiesConfiguration; import com.sk89q.worldedit.util.report.Unreported; @@ -20,8 +21,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.IntArraySet; import it.unimi.dsi.fastutil.longs.LongArrayList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; @@ -51,12 +51,12 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import javax.imageio.ImageIO; -import static org.slf4j.LoggerFactory.getLogger; +import static org.apache.logging.log4j.LogManager.getLogger; // TODO FIXME public class TextureUtil implements TextureHolder { - private static final Logger log = LoggerFactory.getLogger(TextureUtil.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final int[] FACTORS = new int[766]; @@ -355,7 +355,7 @@ public class TextureUtil implements TextureHolder { this.folder = folder; if (!folder.exists()) { try { - log.info("Downloading asset jar from Mojang, please wait..."); + LOGGER.info("Downloading asset jar from Mojang, please wait..."); new File(Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/" + "/.minecraft/versions/").mkdirs(); try (BufferedInputStream in = new BufferedInputStream(new URL("https://launcher.mojang.com/v1/objects/37fd3c903861eeff3bc24b71eed48f828b5269c8/client.jar").openStream()); FileOutputStream fileOutputStream = new FileOutputStream(Fawe.imp().getDirectory() + "/" + Settings.IMP.PATHS.TEXTURES + "/" + "/.minecraft/versions/1.16.5.jar")) { @@ -364,14 +364,14 @@ public class TextureUtil implements TextureHolder { while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { fileOutputStream.write(dataBuffer, 0, bytesRead); } - log.info("Asset jar down has been downloaded successfully."); + LOGGER.info("Asset jar down has been downloaded successfully."); } catch (IOException e) { - log.error("Could not download version jar. Please do so manually by creating a `FastAsyncWorldEdit/textures` folder with `.minecraft/versions` jar in it."); - log.error("If the file exists, please make sure the server has read access to the directory."); + LOGGER.error("Could not download version jar. Please do so manually by creating a `FastAsyncWorldEdit/textures` folder with `.minecraft/versions` jar in it."); + LOGGER.error("If the file exists, please make sure the server has read access to the directory."); } } catch (AccessControlException e) { - log.error("Could not download asset jar. It's likely your file permission are setup improperly and do not allow fetching data from the Mojang servers."); - log.error("Please create the following folder manually: `FastAsyncWorldEdit/textures` with `.minecraft/versions` jar in it."); + LOGGER.error("Could not download asset jar. It's likely your file permission are setup improperly and do not allow fetching data from the Mojang servers."); + LOGGER.error("Please create the following folder manually: `FastAsyncWorldEdit/textures` with `.minecraft/versions` jar in it."); } } @@ -643,8 +643,8 @@ public class TextureUtil implements TextureHolder { fileOutputStream.write(dataBuffer, 0, bytesRead); } } catch (IOException e) { - log.error("Could not download version jar. Please do so manually by creating a `FastAsyncWorldEdit/textures` folder with `.minecraft/versions` jar or mods in it."); - log.error("If the file exists, please make sure the server has read access to the directory."); + LOGGER.error("Could not download version jar. Please do so manually by creating a `FastAsyncWorldEdit/textures` folder with `.minecraft/versions` jar or mods in it."); + LOGGER.error("If the file exists, please make sure the server has read access to the directory."); } } else { for (File file : files) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/ThirdPartyManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/ThirdPartyManager.java index 19e8ecddc..331e95de4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/ThirdPartyManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/ThirdPartyManager.java @@ -1,5 +1,8 @@ package com.boydti.fawe.util; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; + import java.io.DataInputStream; import java.io.IOException; import java.net.URL; @@ -7,8 +10,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Base64; -import static org.slf4j.LoggerFactory.getLogger; - /** An internal FAWE class not meant for public use. **/ public enum ThirdPartyManager { @@ -22,6 +23,8 @@ public enum ThirdPartyManager { ; + private static final Logger LOGGER = LogManagerCompat.getLogger(); + public final String url; public final int fileSize; public final String digest; @@ -54,12 +57,12 @@ public enum ThirdPartyManager { String jarDigest = Base64.getEncoder().encodeToString(jarDigestBytes); if (this.digest.equals(jarDigest)) { - getLogger(ThirdPartyManager.class).debug("++++ HASH CHECK ++++"); - getLogger(ThirdPartyManager.class).debug(this.url); - getLogger(ThirdPartyManager.class).debug(this.digest); + LOGGER.debug("++++ HASH CHECK ++++"); + LOGGER.debug(this.url); + LOGGER.debug(this.digest); return jarBytes; } else { - getLogger(ThirdPartyManager.class).debug(jarDigest + " | " + url); + LOGGER.debug(jarDigest + " | " + url); throw new IllegalStateException("The downloaded jar does not match the hash"); } } catch (NoSuchAlgorithmException e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java index d15ed95eb..338c49297 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/WEManager.java @@ -10,12 +10,12 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.text.TextComponent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.util.ArrayDeque; import java.util.HashSet; @@ -24,14 +24,14 @@ import java.util.Set; public class WEManager { - private static final Logger log = LoggerFactory.getLogger(WEManager.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public static final WEManager IMP = new WEManager(); public final ArrayDeque managers = new ArrayDeque<>(); public void cancelEditSafe(AbstractDelegateExtent parent, FaweException reason) throws FaweException { - log.warn("CancelEditSafe was hit. Please ignore this message."); + LOGGER.warn("CancelEditSafe was hit. Please ignore this message."); Extent currentExtent = parent.getExtent(); if (!(currentExtent instanceof NullExtent)) { parent.extent = new NullExtent(parent.extent, reason); @@ -123,10 +123,10 @@ public class WEManager { player.printError(TextComponent.of("Missing permission " + "fawe." + manager.getKey())); } } - log.debug("Region info for " + player.getName()); - log.debug("There are " + backupRegions.size() + " backupRegions being added to Regions. Regions has " + regions.size() + " before backupRegions are added"); + LOGGER.debug("Region info for " + player.getName()); + LOGGER.debug("There are " + backupRegions.size() + " backupRegions being added to Regions. Regions has " + regions.size() + " before backupRegions are added"); regions.addAll(backupRegions); - log.debug("Finished adding regions for " + player.getName()); + LOGGER.debug("Finished adding regions for " + player.getName()); if (!masks.isEmpty()) { player.setMeta("lastMask", masks); } else { diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java index 1abb91e18..faf6b3938 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java @@ -20,8 +20,8 @@ package com.sk89q.minecraft.util.commands; import com.sk89q.util.StringUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -64,8 +64,7 @@ import java.util.Set; @Deprecated public abstract class CommandsManager { - protected static final Logger logger = - LoggerFactory.getLogger(CommandsManager.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); /** * Mapping of commands (including aliases) with a description. Root @@ -144,7 +143,7 @@ public abstract class CommandsManager { return registerMethods(cls, parent, obj); } } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) { - logger.error("Failed to register commands", e); + LOGGER.error("Failed to register commands", e); } return null; } @@ -525,7 +524,7 @@ public abstract class CommandsManager { try { method.invoke(instance, methodArgs); } catch (IllegalArgumentException | IllegalAccessException e) { - logger.error("Failed to execute command", e); + LOGGER.error("Failed to execute command", e); } catch (InvocationTargetException e) { if (e.getCause() instanceof CommandException) { throw (CommandException) e.getCause(); diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java index 2804612da..c8781e44a 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java @@ -19,15 +19,15 @@ package com.sk89q.minecraft.util.commands; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; public class SimpleInjector implements Injector { - private static final Logger log = LoggerFactory.getLogger(SimpleInjector.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private Object[] args; private Class[] argClasses; @@ -46,7 +46,7 @@ public class SimpleInjector implements Injector { ctr.setAccessible(true); return ctr.newInstance(args); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { - log.error("Error initializing commands class " + clazz, e); + LOGGER.error("Error initializing commands class " + clazz, e); return null; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 194eb697a..33807746b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -95,6 +95,7 @@ import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionTimeoutException; import com.sk89q.worldedit.internal.expression.LocalSlot.Variable; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MathUtils; @@ -134,10 +135,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; @@ -170,7 +170,7 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY; @SuppressWarnings({"FieldCanBeLocal"}) public class EditSession extends PassthroughExtent implements AutoCloseable { - private static final Logger log = LoggerFactory.getLogger(EditSession.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); /** * Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to @@ -2555,7 +2555,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { timedOut[0] = timedOut[0] + 1; return null; } catch (Exception e) { - log.warn("Failed to create shape", e); + LOGGER.warn("Failed to create shape", e); return null; } } @@ -3091,7 +3091,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { timedOut.getAndIncrement(); return null; } catch (Exception e) { - log.warn("Failed to create shape", e); + LOGGER.warn("Failed to create shape", e); return null; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index a672be22f..fdc54a887 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.BlockMaskBuilder; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.formatting.component.TextUtils; import com.sk89q.worldedit.util.io.file.ArchiveNioSupports; import com.sk89q.worldedit.util.logging.LogFormat; @@ -33,8 +34,7 @@ import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import com.sk89q.worldedit.world.snapshot.experimental.SnapshotDatabase; import com.sk89q.worldedit.world.snapshot.experimental.fs.FileSystemSnapshotDatabase; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -51,7 +51,7 @@ import java.util.Set; */ public abstract class LocalConfiguration { - private static final Logger LOGGER = LoggerFactory.getLogger(LocalConfiguration.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public boolean profile = false; public boolean traceUnflushedSessions = false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java index 1d6334ae5..86f435d3f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -46,6 +46,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.SchematicsEventListener; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.invoke.ReturnException; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.scripting.CraftScriptContext; import com.sk89q.worldedit.scripting.CraftScriptEngine; @@ -71,8 +72,7 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.registry.BundledBlockData; import com.sk89q.worldedit.world.registry.BundledItemData; import com.sk89q.worldedit.world.registry.LegacyMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.DataInputStream; import java.io.File; @@ -109,7 +109,10 @@ import static com.sk89q.worldedit.event.platform.Interaction.OPEN; */ public final class WorldEdit { - public static final Logger logger = LoggerFactory.getLogger(WorldEdit.class); + /** + * This is for internal use only. + */ + public static final Logger logger = LogManagerCompat.getLogger(); private static final WorldEdit instance = new WorldEdit(); private static String version; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 36f3721d6..1f01293ba 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -45,6 +45,7 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import com.sk89q.worldedit.function.operation.Operations; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.formatting.component.ErrorFormat; @@ -58,14 +59,13 @@ import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.io.Closer; import com.sk89q.worldedit.util.io.file.FilenameException; +import org.apache.logging.log4j.Logger; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.Switch; import org.enginehub.piston.exception.StopExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -102,7 +102,7 @@ import static com.google.common.base.Preconditions.checkNotNull; @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class SchematicCommands { - private static final Logger log = LoggerFactory.getLogger(SchematicCommands.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final WorldEdit worldEdit; /** @@ -304,7 +304,7 @@ public class SchematicCommands { actor.printError("Unknown filename: " + filename); } catch (URISyntaxException | IOException e) { actor.printError("File could not be read or it does not exist: " + e.getMessage()); - log.warn("Failed to load a saved clipboard", e); + LOGGER.warn("Failed to load a saved clipboard", e); } finally { if (in != null) { try { @@ -701,7 +701,7 @@ public class SchematicCommands { ClipboardReader reader = closer.register(format.getReader(bis)); Clipboard clipboard = reader.read(); - log.info(actor.getName() + " loaded " + file.getCanonicalPath()); + LOGGER.info(actor.getName() + " loaded " + file.getCanonicalPath()); return new ClipboardHolder(clipboard); } } @@ -785,7 +785,7 @@ public class SchematicCommands { TextComponent noSlotsErr = TextComponent.of( //TODO - to be moved into captions/translatablecomponents String.format("You have " + numFiles + "/" + limit + " saved schematics. Delete some to save this one!", TextColor.RED)); - log.info(actor.getName() + " failed to save " + file.getCanonicalPath() + " - too many schematics!"); + LOGGER.info(actor.getName() + " failed to save " + file.getCanonicalPath() + " - too many schematics!"); throw new WorldEditException(noSlotsErr) { }; } @@ -838,7 +838,7 @@ public class SchematicCommands { "You're about to be at " + String.format("%.1f", curKb) + "kb of schematics. (" + String.format("%dkb", allocatedKb) + " available) Delete some first to save this one!", TextColor.RED); - log.info(actor.getName() + " failed to save " + SCHEMATIC_NAME + " - not enough space!"); + LOGGER.info(actor.getName() + " failed to save " + SCHEMATIC_NAME + " - not enough space!"); throw new WorldEditException(notEnoughKbErr) { }; } @@ -860,7 +860,7 @@ public class SchematicCommands { + " schematic file slots left.", TextColor.GRAY); actor.print(slotsRemainingNotif); } - log.info(actor.getName() + " saved " + file.getCanonicalPath()); + LOGGER.info(actor.getName() + " saved " + file.getCanonicalPath()); } else { actor.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual")); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java index 3e7486c5f..ec3ee090c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SelectionWand.java @@ -26,16 +26,16 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.util.Location; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; public enum SelectionWand implements DoubleActionBlockTool { INSTANCE; - private static final Logger logger = LoggerFactory.getLogger(SelectionWand.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); @Override public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { @@ -43,7 +43,7 @@ public enum SelectionWand implements DoubleActionBlockTool { BlockVector3 blockPoint = clicked.toVector().toBlockPoint(); if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) { if (Settings.IMP.EXPERIMENTAL.OTHER) { - logger.info("actSecondary Hit and about to explain with explainPrimarySelection"); + LOGGER.info("actSecondary Hit and about to explain with explainPrimarySelection"); } selector.explainPrimarySelection(player, session, blockPoint); } @@ -57,7 +57,7 @@ public enum SelectionWand implements DoubleActionBlockTool { if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) { if (Settings.IMP.EXPERIMENTAL.OTHER) { - logger.info("actPrimary Hit and about to explain with explainSecondarySelection"); + LOGGER.info("actPrimary Hit and about to explain with explainSecondarySelection"); } selector.explainSecondarySelection(player, session, blockPoint); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java index 67f51a7b0..9d8971903 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java @@ -25,17 +25,17 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.command.exception.ExceptionConverter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.formatting.component.ErrorFormat; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.task.FutureForwardingTask; import com.sk89q.worldedit.util.task.Supervisor; +import org.apache.logging.log4j.Logger; import org.enginehub.piston.exception.CommandException; import org.enginehub.piston.exception.CommandExecutionException; import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.concurrent.Callable; import java.util.function.Consumer; @@ -45,7 +45,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public final class AsyncCommandBuilder { - private static final Logger logger = LoggerFactory.getLogger(AsyncCommandBuilder.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final Callable callable; private final Actor sender; @@ -174,7 +174,7 @@ public final class AsyncCommandBuilder { } } catch (Throwable unknown) { sender.printError(failure.append(TextComponent.of(": Unknown error. Please see console."))); - logger.error("Uncaught exception occurred in task: " + description, orig); + LOGGER.error("Uncaught exception occurred in task: " + description, orig); } } return result; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java index 974167c82..cf712a476 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java @@ -20,8 +20,6 @@ import org.enginehub.piston.inject.InjectAnnotation; import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.Key; import org.enginehub.piston.inject.MemoizingValueAccess; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -160,7 +158,6 @@ public @interface Confirm { final MemoizingValueAccess memoizingValueAccess; if (!(context instanceof MemoizingValueAccess)) { if (!context.getClass().getSimpleName().contains("AutoValue_CommandParametersImpl")) { - LoggerFactory.getLogger(Confirm.class).warn("InjectedValueAccess " + context.getClass().getName() + " given to Confirm"); return true; } memoizingValueAccess = (MemoizingValueAccess) Reflect.injectedValues.get(context); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 78416a905..9b1dd7bfe 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -121,6 +121,7 @@ import com.sk89q.worldedit.internal.command.ConfirmHandler; import com.sk89q.worldedit.internal.command.MethodInjector; import com.sk89q.worldedit.internal.command.exception.ExceptionConverter; import com.sk89q.worldedit.internal.command.exception.WorldEditExceptionConverter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.internal.util.Substring; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.SessionKey; @@ -133,6 +134,7 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.logging.DynamicStreamHandler; import com.sk89q.worldedit.util.logging.LogFormat; import com.sk89q.worldedit.world.World; +import org.apache.logging.log4j.Logger; import org.enginehub.piston.Command; import org.enginehub.piston.CommandManager; import org.enginehub.piston.converter.ArgumentConverter; @@ -155,8 +157,6 @@ import org.enginehub.piston.suggestion.Suggestion; import org.enginehub.piston.util.HelpGenerator; import org.enginehub.piston.util.ValueProvider; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -185,7 +185,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public final class PlatformCommandManager { public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+"); - private static final Logger log = LoggerFactory.getLogger(PlatformCommandManager.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final java.util.logging.Logger COMMAND_LOG = java.util.logging.Logger.getLogger("com.sk89q.worldedit.CommandLog"); @@ -567,7 +567,7 @@ public final class PlatformCommandManager { } void registerCommandsWith(Platform platform) { - log.info("Registering commands with " + platform.getClass().getCanonicalName()); + LOGGER.info("Registering commands with " + platform.getClass().getCanonicalName()); LocalConfiguration config = platform.getConfiguration(); @@ -582,12 +582,12 @@ public final class PlatformCommandManager { File file = new File(config.getWorkingDirectory(), path); COMMAND_LOG.setLevel(Level.ALL); - log.info("Logging WorldEdit commands to " + file.getAbsolutePath()); + LOGGER.info("Logging WorldEdit commands to " + file.getAbsolutePath()); try { dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true)); } catch (IOException e) { - log.warn("Could not use command log file " + path + ": " + e.getMessage()); + LOGGER.warn("Could not use command log file " + path + ": " + e.getMessage()); } dynamicHandler.setFormatter(new LogFormat(config.logFormat)); @@ -828,7 +828,7 @@ public final class PlatformCommandManager { private void handleUnknownException(Actor actor, Throwable t) { actor.printError(TranslatableComponent.of("worldedit.command.error.report")); actor.print(TextComponent.of(t.getClass().getName() + ": " + t.getMessage())); - log.error("An unexpected error while handling a WorldEdit command", t); + LOGGER.error("An unexpected error while handling a WorldEdit command", t); } @Subscribe @@ -848,7 +848,7 @@ public final class PlatformCommandManager { suggestions = commandManager.getSuggestions(access, argStrings); } catch (Throwable t) { // catch errors which are *not* command exceptions generated by parsers/suggesters if (!(t instanceof CommandException)) { - log.debug("Unexpected error occurred while generating suggestions for input: " + arguments, t); + LOGGER.debug("Unexpected error occurred while generating suggestions for input: " + arguments, t); return; } throw t; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 62910011c..89e4fa69a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -41,6 +41,7 @@ import com.sk89q.worldedit.event.platform.Interaction; import com.sk89q.worldedit.event.platform.PlatformInitializeEvent; import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.event.platform.PlayerInputEvent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Location; @@ -48,8 +49,7 @@ import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.util.ArrayList; import java.util.Collection; @@ -71,7 +71,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class PlatformManager { - private static final Logger logger = LoggerFactory.getLogger(PlatformManager.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final WorldEdit worldEdit; private final PlatformCommandManager platformCommandManager; @@ -104,7 +104,7 @@ public class PlatformManager { public synchronized void register(Platform platform) { checkNotNull(platform); - logger.info("Got request to register " + platform.getClass() + " with WorldEdit [" + super.toString() + "]"); + LOGGER.info("Got request to register " + platform.getClass() + " with WorldEdit [" + super.toString() + "]"); // Just add the platform to the list of platforms: we'll pick favorites // once all the platforms have been loaded @@ -113,7 +113,7 @@ public class PlatformManager { // Make sure that versions are in sync if (firstSeenVersion != null) { if (!firstSeenVersion.equals(platform.getVersion())) { - logger.warn("Multiple ports of WorldEdit are installed but they report different versions ({} and {}). " + LOGGER.warn("Multiple ports of WorldEdit are installed but they report different versions ({} and {}). " + "If these two versions are truly different, then you may run into unexpected crashes and errors.", firstSeenVersion, platform.getVersion()); } } else { @@ -135,7 +135,7 @@ public class PlatformManager { boolean removed = platforms.remove(platform); if (removed) { - logger.info("Unregistering " + platform.getClass().getCanonicalName() + " from WorldEdit"); + LOGGER.info("Unregistering " + platform.getClass().getCanonicalName() + " from WorldEdit"); boolean choosePreferred = false; @@ -349,7 +349,7 @@ public class PlatformManager { VirtualWorld virtual = session.getVirtualWorld(); if (virtual != null) { if (Settings.IMP.EXPERIMENTAL.OTHER) { - logger.info("virtualWorld was not null in handlePlayerInput()"); + LOGGER.info("virtualWorld was not null in handlePlayerInput()"); } virtual.handleBlockInteract(player, vector.toBlockPoint(), event); @@ -423,7 +423,7 @@ public class PlatformManager { VirtualWorld virtual = session.getVirtualWorld(); if (virtual != null) { if (Settings.IMP.EXPERIMENTAL.OTHER) { - logger.info("virtualWorld was not null in handlePlayerInput()"); + LOGGER.info("virtualWorld was not null in handlePlayerInput()"); } virtual.handlePlayerInput(player, event); if (event.isCancelled()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/Bindings.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/Bindings.java index 38f31c4a3..71b15aebd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/Bindings.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/Bindings.java @@ -2,8 +2,10 @@ package com.sk89q.worldedit.extension.platform.binding; import com.boydti.fawe.util.StringMan; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; +import org.apache.logging.log4j.Logger; import org.enginehub.piston.CommandManager; import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ConversionResult; @@ -20,10 +22,10 @@ import java.lang.reflect.Method; import java.util.Optional; import java.util.function.Function; -import static org.slf4j.LoggerFactory.getLogger; - public class Bindings { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final WorldEdit worldEdit; public Bindings(WorldEdit worldEdit) { @@ -57,7 +59,7 @@ public class Bindings { Annotation annotation = annotations[0] == binding ? annotations[1] : annotations[0]; key = Key.of(ret, annotation); } else { - getLogger(Bindings.class).debug("Cannot annotate: " + method + " with " + StringMan.getString(annotations)); + LOGGER.debug("Cannot annotate: " + method + " with " + StringMan.getString(annotations)); return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index 5daf419b1..38dc4f4a4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -32,6 +32,7 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.OperationQueue; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; @@ -39,23 +40,22 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Range; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.List; import java.util.UUID; import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; +import static org.apache.logging.log4j.LogManager.getLogger; /** * A base class for {@link Extent}s that merely passes extents onto another. */ public class AbstractDelegateExtent implements Extent { - private static final Logger logger = LoggerFactory.getLogger(AbstractDelegateExtent.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); //Not safe for public usage public Extent extent; @@ -298,11 +298,11 @@ public class AbstractDelegateExtent implements Extent { @Override public Extent addProcessor(IBatchProcessor processor) { if (Settings.IMP.EXPERIMENTAL.OTHER) { - logger.info("addProcessor Info: \t " + processor.getClass().getName()); - logger.info("The following is not an error or a crash:"); + LOGGER.info("addProcessor Info: \t " + processor.getClass().getName()); + LOGGER.info("The following is not an error or a crash:"); StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); for (StackTraceElement stackTraceElement : stackTrace) { - logger.info(stackTraceElement.toString()); + LOGGER.info(stackTraceElement.toString()); } } @@ -316,11 +316,11 @@ public class AbstractDelegateExtent implements Extent { @Override public Extent addPostProcessor(IBatchProcessor processor) { if (Settings.IMP.EXPERIMENTAL.OTHER) { - logger.info("addPostProcessor Info: \t " + processor.getClass().getName()); - logger.info("The following is not an error or a crash:"); + LOGGER.info("addPostProcessor Info: \t " + processor.getClass().getName()); + LOGGER.info("The following is not an error or a crash:"); StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); for (StackTraceElement stackTraceElement : stackTrace) { - logger.info(stackTraceElement.toString()); + LOGGER.info(stackTraceElement.toString()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java index 86edbbeb5..4b9fbe494 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/FastSchematicReader.java @@ -40,6 +40,7 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.DataFixer; @@ -52,8 +53,7 @@ import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; import net.jpountz.lz4.LZ4BlockInputStream; import net.jpountz.lz4.LZ4BlockOutputStream; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.util.ArrayList; @@ -71,7 +71,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class FastSchematicReader extends NBTSchematicReader { - private static final Logger log = LoggerFactory.getLogger(FastSchematicReader.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final NBTInputStream inputStream; private DataFixer fixer; private int dataVersion = -1; @@ -183,7 +183,7 @@ public class FastSchematicReader extends NBTSchematicReader { try { state = BlockState.get(palettePart); } catch (InputParseException ignored) { - log.warn("Invalid BlockState in palette: " + palettePart + ". Block will be replaced with air."); + LOGGER.warn("Invalid BlockState in palette: " + palettePart + ". Block will be replaced with air."); state = BlockTypes.AIR.getDefaultState(); } int index = (int) entry.getValue(); @@ -395,14 +395,14 @@ public class FastSchematicReader extends NBTSchematicReader { for (Entity e : clipboard.getEntities()) { clipboard.removeEntity(e); } - log.error("Detected schematic entity outside clipboard region. FAWE will not load entities. " + LOGGER.error("Detected schematic entity outside clipboard region. FAWE will not load entities. " + "Please try loading the schematic with the format \"legacyentity\""); break; } } clipboard.createEntity(loc.setPosition(loc.subtract(min.toVector3())), state); } else { - log.debug("Invalid entity: " + id); + LOGGER.debug("Invalid entity: " + id); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java index 619c30037..e9f9631ad 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java @@ -42,6 +42,7 @@ import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NoteBlockCompatibili import com.sk89q.worldedit.extent.clipboard.io.legacycompat.Pre13HangingCompatibilityHandler; import com.sk89q.worldedit.extent.clipboard.io.legacycompat.SignCompatibilityHandler; import com.sk89q.worldedit.extent.clipboard.io.legacycompat.SkullBlockCompatibilityHandler; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; @@ -52,8 +53,7 @@ import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.storage.NBTConversions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.util.ArrayList; @@ -71,7 +71,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class MCEditSchematicReader extends NBTSchematicReader { - private static final Logger log = LoggerFactory.getLogger(MCEditSchematicReader.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final NBTInputStream inputStream; private final DataFixer fixer; private static final ImmutableList COMPATIBILITY_HANDLERS @@ -253,7 +253,7 @@ public class MCEditSchematicReader extends NBTSchematicReader { byte data = blockData[index]; int combined = block << 8 | data; if (unknownBlocks.add(combined)) { - log.warn("Unknown block when loading schematic: " + LOGGER.warn("Unknown block when loading schematic: " + block + ":" + data + ". This is most likely a bad schematic."); } } @@ -289,7 +289,7 @@ public class MCEditSchematicReader extends NBTSchematicReader { BaseEntity state = new BaseEntity(entityType, compound); clipboard.createEntity(location, state); } else { - log.warn("Unknown entity when pasting schematic: " + id.toLowerCase(Locale.ROOT)); + LOGGER.warn("Unknown entity when pasting schematic: " + id.toLowerCase(Locale.ROOT)); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index 67aff76b3..adb7df3ac 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -40,6 +40,7 @@ import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; @@ -52,8 +53,7 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.storage.NBTConversions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.util.HashMap; @@ -70,7 +70,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class SpongeSchematicReader extends NBTSchematicReader { - private static final Logger log = LoggerFactory.getLogger(SpongeSchematicReader.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final NBTInputStream inputStream; private DataFixer fixer = null; private int schematicVersion = -1; @@ -102,21 +102,21 @@ public class SpongeSchematicReader extends NBTSchematicReader { } else if (schematicVersion == 2) { dataVersion = requireTag(schematic, "DataVersion", IntTag.class).getValue(); if (dataVersion < 0) { - log.warn("Schematic has an unknown data version ({}). Data may be incompatible.", + LOGGER.warn("Schematic has an unknown data version ({}). Data may be incompatible.", dataVersion); // Do not DFU unknown data dataVersion = liveDataVersion; } if (dataVersion > liveDataVersion) { - log.warn("Schematic was made in a newer Minecraft version ({} > {}). Data may be incompatible.", + LOGGER.warn("Schematic was made in a newer Minecraft version ({} > {}). Data may be incompatible.", dataVersion, liveDataVersion); } else if (dataVersion < liveDataVersion) { fixer = platform.getDataFixer(); if (fixer != null) { - log.debug("Schematic was made in an older Minecraft version ({} < {}), will attempt DFU.", + LOGGER.debug("Schematic was made in an older Minecraft version ({} < {}), will attempt DFU.", dataVersion, liveDataVersion); } else { - log.info("Schematic was made in an older Minecraft version ({} < {}), but DFU is not available. Data may be incompatible.", + LOGGER.info("Schematic was made in an older Minecraft version ({} < {}), but DFU is not available. Data may be incompatible.", dataVersion, liveDataVersion); } } @@ -217,7 +217,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { try { state = WorldEdit.getInstance().getBlockFactory().parseFromInput(palettePart, parserContext).toImmutableState(); } catch (InputParseException e) { - log.warn("Invalid BlockState in palette: " + palettePart + ". Block will be replaced with air."); + LOGGER.warn("Invalid BlockState in palette: " + palettePart + ". Block will be replaced with air."); state = BlockTypes.AIR.getDefaultState(); } palette.put(id, state); @@ -327,7 +327,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { } BiomeType biome = BiomeTypes.get(key); if (biome == null) { - log.warn("Unknown biome type :" + key + LOGGER.warn("Unknown biome type :" + key + " in palette. Are you missing a mod or using a schematic made in a newer version of Minecraft?"); } Tag idTag = palettePart.getValue(); @@ -396,7 +396,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { BaseEntity state = new BaseEntity(entityType, entityTag); clipboard.createEntity(location, state); } else { - log.warn("Unknown entity when pasting schematic: " + id); + LOGGER.warn("Unknown entity when pasting schematic: " + id); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index 095c9f1a0..fe896d102 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -27,6 +27,7 @@ import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.helper.MCDirections; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; @@ -43,6 +44,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -73,7 +75,6 @@ import static com.sk89q.worldedit.util.Direction.UP; import static com.sk89q.worldedit.util.Direction.WEST; import static com.sk89q.worldedit.util.Direction.findClosest; import static com.sk89q.worldedit.util.Direction.values; -import static org.slf4j.LoggerFactory.getLogger; /** * Transforms blocks themselves (but not their position) according to a @@ -81,6 +82,8 @@ import static org.slf4j.LoggerFactory.getLogger; */ public class BlockTransformExtent extends ResettableExtent { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private static final Set directional = PropertyKeySet.of( PropertyKey.HALF, PropertyKey.ROTATION, @@ -174,7 +177,7 @@ public class BlockTransformExtent extends ResettableExtent { case 2: return adapt(combine(EAST, WEST), combine(SOUTH, NORTH)); default: - getLogger(BlockTransformExtent.class).error("Invalid {} {}", property.getName(), property.getValues()); + LOGGER.error("Invalid {} {}", property.getName(), property.getValues()); return null; } } @@ -207,7 +210,7 @@ public class BlockTransformExtent extends ResettableExtent { result.add(notIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right"))); continue; default: - getLogger(BlockTransformExtent.class).warn("Unknown direction {}", value); + LOGGER.warn("Unknown direction {}", value); result.add(0L); } } @@ -247,7 +250,7 @@ public class BlockTransformExtent extends ResettableExtent { directions.add(combine(NORTHEAST)); break; default: - getLogger(BlockTransformExtent.class).warn("Unknown direction {}", value); + LOGGER.warn("Unknown direction {}", value); directions.add(0L); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java index 6351653e7..1c78d7e30 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java @@ -19,7 +19,9 @@ package com.sk89q.worldedit.function.mask; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; +import org.apache.logging.log4j.Logger; import java.util.AbstractMap; import java.util.ArrayList; @@ -37,7 +39,6 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; -import static org.slf4j.LoggerFactory.getLogger; /** * Combines several masks and requires that all masks return true @@ -46,6 +47,8 @@ import static org.slf4j.LoggerFactory.getLogger; */ public class MaskIntersection extends AbstractMask { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + protected final Set masks; protected Mask[] masksArray; protected boolean defaultReturn; @@ -160,9 +163,9 @@ public class MaskIntersection extends AbstractMask { while (combineMasks(pairingFunction(), failedCombines) && --maxIteration > 0); if (maxIteration == 0) { - getLogger(MaskIntersection.class).error("Failed optimize MaskIntersection"); + LOGGER.error("Failed optimize MaskIntersection"); for (Mask mask : masks) { - getLogger(MaskIntersection.class).error(mask.getClass() + " / " + mask); + LOGGER.error(mask.getClass() + " / " + mask); } } // Return result diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/SchematicsEventListener.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/SchematicsEventListener.java index b3f89128f..388953dc0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/SchematicsEventListener.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/SchematicsEventListener.java @@ -20,9 +20,9 @@ package com.sk89q.worldedit.internal; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.eventbus.Subscribe; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.nio.file.FileAlreadyExistsException; @@ -31,7 +31,7 @@ import java.nio.file.Path; public class SchematicsEventListener { - private static final Logger LOGGER = LoggerFactory.getLogger(SchematicsEventListener.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); @Subscribe public void onConfigLoad(ConfigurationLoadEvent event) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java index 8e3bde30b..dbfdd8008 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java @@ -27,9 +27,9 @@ import com.google.gson.TypeAdapter; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector2; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.BufferedWriter; import java.io.IOException; @@ -52,7 +52,7 @@ import java.util.stream.Stream; public final class ChunkDeleter { public static final String DELCHUNKS_FILE_NAME = "delete_chunks.json"; - private static final Logger logger = LoggerFactory.getLogger(ChunkDeleter.class); + private static final Logger LOGGER = LogManagerCompat.getLogger();; private static final Comparator chunkSorter = Comparator.comparing( pos -> (pos.getBlockX() & 31) + (pos.getBlockZ() & 31) * 32 @@ -80,13 +80,13 @@ public final class ChunkDeleter { try { chunkDeleter = createFromFile(chunkFile); } catch (JsonSyntaxException | IOException e) { - logger.error("Could not parse chunk deletion file. Invalid file?", e); + LOGGER.error("Could not parse chunk deletion file. Invalid file?", e); return; } - logger.info("Found chunk deletions. Proceeding with deletion..."); + LOGGER.info("Found chunk deletions. Proceeding with deletion..."); long start = System.currentTimeMillis(); if (chunkDeleter.runDeleter()) { - logger.info("Successfully deleted {} matching chunks (out of {}, taking {} ms).", + LOGGER.info("Successfully deleted {} matching chunks (out of {}, taking {} ms).", chunkDeleter.getDeletedChunkCount(), chunkDeleter.getDeletionsRequested(), System.currentTimeMillis() - start); if (deleteOnSuccess) { @@ -96,12 +96,12 @@ public final class ChunkDeleter { } catch (IOException ignored) { } if (!deletedFile) { - logger.warn("Chunk deletion file could not be cleaned up. This may have unintended consequences" + LOGGER.warn("Chunk deletion file could not be cleaned up. This may have unintended consequences" + " on next startup, or if /delchunks is used again."); } } } else { - logger.error("Error occurred while deleting chunks. " + LOGGER.error("Error occurred while deleting chunks. " + "If world errors occur, stop the server and restore the *.bak backup files."); } } @@ -131,7 +131,7 @@ public final class ChunkDeleter { private boolean runBatch(ChunkDeletionInfo.ChunkBatch chunkBatch) { int chunkCount = chunkBatch.getChunkCount(); - logger.debug("Processing deletion batch with {} chunks.", chunkCount); + LOGGER.debug("Processing deletion batch with {} chunks.", chunkCount); final Map> regionToChunkList = groupChunks(chunkBatch); BiPredicate predicate = createPredicates(chunkBatch.deletionPredicates); shouldPreload = chunkBatch.chunks == null; @@ -147,7 +147,7 @@ public final class ChunkDeleter { try { backupRegion(regionPath); } catch (IOException e) { - logger.warn("Error backing up region file: " + regionPath + ". Aborting the process.", e); + LOGGER.warn("Error backing up region file: " + regionPath + ". Aborting the process.", e); return false; } } @@ -263,15 +263,15 @@ public final class ChunkDeleter { region.deleteChunk(chunk); totalChunksDeleted++; if (debugRate != 0 && totalChunksDeleted % debugRate == 0) { - logger.debug("Deleted {} chunks so far.", totalChunksDeleted); + LOGGER.debug("Deleted {} chunks so far.", totalChunksDeleted); } } else { - logger.debug("Chunk did not match predicates: " + chunk); + LOGGER.debug("Chunk did not match predicates: " + chunk); } } return true; } catch (IOException e) { - logger.warn("Error deleting chunks from region: " + regionFile + ". Aborting the process.", e); + LOGGER.warn("Error deleting chunks from region: " + regionFile + ". Aborting the process.", e); return false; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/LogManagerCompat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/LogManagerCompat.java new file mode 100644 index 000000000..e94ae6ec8 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/LogManagerCompat.java @@ -0,0 +1,44 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.internal.util; + +import com.google.common.base.Throwables; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.List; + +public class LogManagerCompat { + + public static Logger getLogger() { + return LogManager.getLogger(getCallerCallerClassName()); + } + + private static String getCallerCallerClassName() { + List lazyStack = Throwables.lazyStackTrace(new Throwable()); + // 0 - this method + // 1 - caller + // 2 - caller caller + return lazyStack.get(2).getClassName(); + } + + private LogManagerCompat() { + } +} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java index be299b249..8620934d6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.math.interpolation; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.Vector3; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.util.List; import java.util.Map.Entry; @@ -39,7 +39,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class ReparametrisingInterpolation implements Interpolation { - private static final Logger log = LoggerFactory.getLogger(ReparametrisingInterpolation.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final Interpolation baseInterpolation; private double totalArcLength; @@ -108,7 +108,7 @@ public class ReparametrisingInterpolation implements Interpolation { Entry ceilingEntry = cache.ceilingEntry(arc); if (ceilingEntry == null) { - log.warn("Error in arcToParameter: no ceiling entry for " + arc + " found!"); + LOGGER.warn("Error in arcToParameter: no ceiling entry for " + arc + " found!"); return 0; } final double rightArc = ceilingEntry.getKey(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/MinecraftHidingClassShutter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/MinecraftHidingClassShutter.java index e9c6c5a69..4e59775bc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/MinecraftHidingClassShutter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/MinecraftHidingClassShutter.java @@ -20,16 +20,12 @@ package com.sk89q.worldedit.scripting; import org.mozilla.javascript.ClassShutter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Hides Minecraft's obfuscated & de-obfuscated names from scripts. */ class MinecraftHidingClassShutter implements ClassShutter { - private static final Logger LOGGER = LoggerFactory.getLogger(MinecraftHidingClassShutter.class); - @Override public boolean visibleToScripts(String fullClassName) { if (!fullClassName.contains(".")) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java index f3f610094..4f98906c7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java @@ -31,6 +31,7 @@ import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; import com.sk89q.worldedit.extension.platform.Locatable; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.storage.JsonFileSessionStore; import com.sk89q.worldedit.session.storage.SessionStore; @@ -40,8 +41,7 @@ import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -69,7 +69,7 @@ public class SessionManager { private static final int FLUSH_PERIOD = 1000 * 30; private static final ListeningExecutorService executorService = MoreExecutors.listeningDecorator( EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 5, "WorldEdit Session Saver - %s")); - private static final Logger log = LoggerFactory.getLogger(SessionManager.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static boolean warnedInvalidTool; private final Timer timer = new Timer("WorldEdit Session Manager"); @@ -157,7 +157,7 @@ public class SessionManager { session = store.load(getKey(sessionKey)); session.postLoad(); } catch (IOException e) { - log.warn("Failed to load saved session", e); + LOGGER.warn("Failed to load saved session", e); session = new LocalSession(); } Request.request().setSession(session); @@ -252,7 +252,7 @@ public class SessionManager { try { store.save(getKey(key), entry.getValue()); } catch (IOException e) { - log.warn("Failed to write session for UUID " + getKey(key), e); + LOGGER.warn("Failed to write session for UUID " + getKey(key), e); exception = e; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/storage/JsonFileSessionStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/storage/JsonFileSessionStore.java index b4f105c2b..b383bda21 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/storage/JsonFileSessionStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/storage/JsonFileSessionStore.java @@ -24,10 +24,10 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonIOException; import com.google.gson.JsonParseException; import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.gson.GsonUtil; import com.sk89q.worldedit.util.io.Closer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -47,7 +47,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class JsonFileSessionStore implements SessionStore { - private static final Logger log = LoggerFactory.getLogger(JsonFileSessionStore.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final Gson gson; private final File dir; @@ -61,7 +61,7 @@ public class JsonFileSessionStore implements SessionStore { if (!dir.isDirectory()) { if (!dir.mkdirs()) { - log.warn("Failed to create directory '" + dir.getPath() + "' for sessions"); + LOGGER.warn("Failed to create directory '" + dir.getPath() + "' for sessions"); } } @@ -90,9 +90,9 @@ public class JsonFileSessionStore implements SessionStore { BufferedReader br = closer.register(new BufferedReader(fr)); LocalSession session = gson.fromJson(br, LocalSession.class); if (session == null) { - log.warn("Loaded a null session from {}, creating new session", file); + LOGGER.warn("Loaded a null session from {}, creating new session", file); if (!file.delete()) { - log.warn("Failed to delete corrupted session {}", file); + LOGGER.warn("Failed to delete corrupted session {}", file); } session = new LocalSession(); } @@ -120,7 +120,7 @@ public class JsonFileSessionStore implements SessionStore { if (finalFile.exists()) { if (!finalFile.delete()) { - log.warn("Failed to delete " + finalFile.getPath() + " so the .tmp file can replace it"); + LOGGER.warn("Failed to delete " + finalFile.getPath() + " so the .tmp file can replace it"); } } @@ -129,7 +129,7 @@ public class JsonFileSessionStore implements SessionStore { } if (!tempFile.renameTo(finalFile)) { - log.warn("Failed to rename temporary session file to " + finalFile.getPath()); + LOGGER.warn("Failed to rename temporary session file to " + finalFile.getPath()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index 5a4b4cadb..d4c2f9f7d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -24,10 +24,10 @@ package com.sk89q.worldedit.util; import com.sk89q.util.StringUtil; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.report.Unreported; import com.sk89q.worldedit.world.registry.LegacyMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.FileInputStream; @@ -49,7 +49,7 @@ import java.util.Set; */ public class PropertiesConfiguration extends LocalConfiguration { - @Unreported private static final Logger log = LoggerFactory.getLogger(PropertiesConfiguration.class); + @Unreported private static final Logger LOGGER = LogManagerCompat.getLogger(); @Unreported protected Properties properties; @Unreported protected File path; @@ -82,7 +82,7 @@ public class PropertiesConfiguration extends LocalConfiguration { properties.load(stream); } catch (FileNotFoundException ignored) { } catch (IOException e) { - log.warn("Failed to read configuration", e); + LOGGER.warn("Failed to read configuration", e); } loadExtra(); @@ -147,7 +147,7 @@ public class PropertiesConfiguration extends LocalConfiguration { try (OutputStream output = new FileOutputStream(path)) { properties.store(output, "Don't put comments; they get removed"); } catch (IOException e) { - log.warn("Failed to write configuration", e); + LOGGER.warn("Failed to write configuration", e); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index cbcc64475..a1bd10721 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -25,7 +25,7 @@ import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.session.SessionManager; import com.sk89q.worldedit.util.report.Unreported; -import org.slf4j.Logger; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.util.HashSet; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java index 2c3ba5125..b3a753318 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java @@ -22,8 +22,8 @@ package com.sk89q.worldedit.util.eventbus; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.SetMultimap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -47,7 +47,7 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public final class EventBus { - private final Logger logger = LoggerFactory.getLogger(EventBus.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final ReadWriteLock lock = new ReentrantReadWriteLock(); @@ -192,7 +192,7 @@ public final class EventBus { try { handler.handleEvent(event); } catch (InvocationTargetException e) { - logger.error("Could not dispatch event: " + event + " to handler " + handler, e); + LOGGER.error("Could not dispatch event: " + event + " to handler " + handler, e); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java index 001c60f3f..b9600ca04 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java @@ -21,8 +21,8 @@ package com.sk89q.worldedit.util.io; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Throwables; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.io.Closeable; import java.io.IOException; @@ -35,7 +35,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public final class Closer implements Closeable { - private static final Logger logger = LoggerFactory.getLogger(Closer.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); /** * The suppressor implementation to use for the current Java version. @@ -239,7 +239,7 @@ public final class Closer implements Closeable { @Override public void suppress(Object closeable, Throwable thrown, Throwable suppressed) { // log to the same place as Closeables - logger.warn("Suppressing exception thrown when closing " + closeable, suppressed); + LOGGER.warn("Suppressing exception thrown when closing " + closeable, suppressed); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/file/ArchiveNioSupports.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/file/ArchiveNioSupports.java index 39ac0158f..512f887eb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/file/ArchiveNioSupports.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/file/ArchiveNioSupports.java @@ -35,11 +35,6 @@ public class ArchiveNioSupports { static { ImmutableList.Builder builder = ImmutableList.builder(); - try { - builder.add(TrueVfsArchiveNioSupport.getInstance()); - } catch (NoClassDefFoundError ignored) { - // No TrueVFS available. That's OK. - } SUPPORTS = builder.add(ZipArchiveNioSupport.getInstance()) .addAll(ServiceLoader.load(ArchiveNioSupport.class)) .build(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/file/TrueVfsArchiveNioSupport.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/file/TrueVfsArchiveNioSupport.java deleted file mode 100644 index fc174dd11..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/file/TrueVfsArchiveNioSupport.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.util.io.file; - -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableSet; -import net.java.truevfs.access.TArchiveDetector; -import net.java.truevfs.access.TFileSystem; -import net.java.truevfs.access.TPath; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; -import java.util.Set; - -public final class TrueVfsArchiveNioSupport implements ArchiveNioSupport { - - private static final TrueVfsArchiveNioSupport INSTANCE = new TrueVfsArchiveNioSupport(); - - public static TrueVfsArchiveNioSupport getInstance() { - return INSTANCE; - } - - private static final Set ALLOWED_EXTENSIONS = ImmutableSet.copyOf( - Splitter.on('|').split(TArchiveDetector.ALL.getExtensions()) - ); - - private TrueVfsArchiveNioSupport() { - } - - @Override - public Optional tryOpenAsDir(Path archive) throws IOException { - String fileName = archive.getFileName().toString(); - int dot = fileName.indexOf('.'); - if (dot < 0 || dot >= fileName.length() || !ALLOWED_EXTENSIONS - .contains(fileName.substring(dot + 1))) { - return Optional.empty(); - } - TFileSystem fileSystem = new TPath(archive).getFileSystem(); - TPath root = fileSystem.getPath("/"); - Path realRoot = ArchiveNioSupports.skipRootSameName( - root, fileName.substring(0, dot) - ); - return Optional.of(new ArchiveDir() { - @Override - public Path getPath() { - return realRoot; - } - - @Override - public void close() throws IOException { - fileSystem.close(); - } - }); - } -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java index c5413d787..7f6bc2715 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java @@ -19,8 +19,8 @@ package com.sk89q.worldedit.util.report; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -29,7 +29,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class ShallowObjectReport extends DataReport { - private static final Logger log = LoggerFactory.getLogger(ShallowObjectReport.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public ShallowObjectReport(String title, Object object) { super(title); @@ -53,7 +53,7 @@ public class ShallowObjectReport extends DataReport { Object value = field.get(object); append(field.getName(), String.valueOf(value)); } catch (IllegalAccessException e) { - log.warn("Failed to get value of '" + field.getName() + "' on " + type); + LOGGER.warn("Failed to get value of '" + field.getName() + "' on " + type); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypesCache.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypesCache.java index 65d633345..c9cba3384 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypesCache.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypesCache.java @@ -25,8 +25,6 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import static org.slf4j.LoggerFactory.getLogger; - public class BlockTypesCache { /* ----------------------------------------------------- diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java index 46680c61f..27f697551 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java @@ -28,11 +28,11 @@ import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.gson.VectorAdapter; import com.sk89q.worldedit.util.io.ResourceLoader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.net.URL; @@ -55,7 +55,7 @@ import javax.annotation.Nullable; */ public final class BundledBlockData { - private static final Logger log = LoggerFactory.getLogger(BundledBlockData.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static BundledBlockData INSTANCE; private final ResourceLoader resourceLoader; @@ -70,7 +70,7 @@ public final class BundledBlockData { try { loadFromResource(); } catch (Throwable e) { - log.warn("Failed to load the built-in block registry", e); + LOGGER.warn("Failed to load the built-in block registry", e); } } @@ -107,7 +107,7 @@ public final class BundledBlockData { if (url == null) { throw new IOException("Could not find blocks.json"); } - log.debug("Using {} for bundled block data.", url); + LOGGER.debug("Using {} for bundled block data.", url); String data = Resources.toString(url, Charset.defaultCharset()); List entries = gson.fromJson(data, new TypeToken>() {}.getType()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java index bb3fb599b..b5aad4280 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java @@ -26,11 +26,11 @@ import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.gson.VectorAdapter; import com.sk89q.worldedit.util.io.ResourceLoader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.net.URL; @@ -53,7 +53,7 @@ import javax.annotation.Nullable; */ public final class BundledItemData { - private static final Logger log = LoggerFactory.getLogger(BundledItemData.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static BundledItemData INSTANCE; private final ResourceLoader resourceLoader; @@ -68,7 +68,7 @@ public final class BundledItemData { try { loadFromResource(); } catch (Throwable e) { - log.warn("Failed to load the built-in item registry", e); + LOGGER.warn("Failed to load the built-in item registry", e); } } @@ -94,7 +94,7 @@ public final class BundledItemData { if (url == null) { throw new IOException("Could not find items.json"); } - log.debug("Using {} for bundled item data.", url); + LOGGER.debug("Using {} for bundled item data.", url); String data = Resources.toString(url, Charset.defaultCharset()); List entries = gson.fromJson(data, new TypeToken>() {}.getType()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java index 89cda0206..4362d1140 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java @@ -33,6 +33,7 @@ import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.util.gson.VectorAdapter; @@ -44,8 +45,7 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.net.URL; @@ -56,7 +56,7 @@ import javax.annotation.Nullable; public final class LegacyMapper { - private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static LegacyMapper INSTANCE; private final ResourceLoader resourceLoader; @@ -79,7 +79,7 @@ public final class LegacyMapper { try { loadFromResource(); } catch (Throwable e) { - log.warn("Failed to load the built-in legacy id registry", e); + LOGGER.warn("Failed to load the built-in legacy id registry", e); } } @@ -140,7 +140,7 @@ public final class LegacyMapper { // if it's still null, both fixer and default failed if (state == null) { - log.debug("Unknown block: " + value); + LOGGER.debug("Unknown block: " + value); } else { // it's not null so one of them succeeded, now use it blockToStringMap.put(state, id); @@ -174,7 +174,7 @@ public final class LegacyMapper { type = ItemTypes.get(value); } if (type == null) { - log.debug("Unknown item: " + value); + LOGGER.debug("Unknown item: " + value); } else { try { itemMap.put(getCombinedId(id), type); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java index c3cee3b6e..a157197b5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.world.snapshot; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.storage.ChunkStore; import com.sk89q.worldedit.world.storage.FileLegacyChunkStore; @@ -29,8 +30,7 @@ import com.sk89q.worldedit.world.storage.TrueZipLegacyChunkStore; import com.sk89q.worldedit.world.storage.TrueZipMcRegionChunkStore; import com.sk89q.worldedit.world.storage.ZippedLegacyChunkStore; import com.sk89q.worldedit.world.storage.ZippedMcRegionChunkStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -43,7 +43,7 @@ import java.util.zip.ZipFile; */ public class Snapshot implements Comparable { - protected static Logger logger = LoggerFactory.getLogger(Snapshot.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); protected File file; protected String name; @@ -70,7 +70,7 @@ public class Snapshot implements Comparable { public ChunkStore getChunkStore() throws IOException, DataException { ChunkStore chunkStore = internalGetChunkStore(); - logger.info("WorldEdit: Using " + chunkStore.getClass().getCanonicalName() + LOGGER.info("WorldEdit: Using " + chunkStore.getClass().getCanonicalName() + " for loading snapshot '" + file.getAbsolutePath() + "'"); return chunkStore; @@ -156,7 +156,7 @@ public class Snapshot implements Comparable { } } catch (IOException ex) { // Skip the file, but print an error - logger.info("Could not load snapshot: " + LOGGER.info("Could not load snapshot: " + file.getPath()); } catch (DataException ex) { // No truezip, so tar file not supported. diff --git a/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java b/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java index e8b405961..838e743d1 100644 --- a/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java +++ b/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java @@ -19,10 +19,10 @@ package com.sk89q.minecraft.util.commands; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Arrays; import java.util.HashSet; @@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.fail; public class CommandContextTest { - private static final Logger log = LoggerFactory.getLogger(CommandContextTest.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final String firstCmdString = "herpderp -opw testers \"mani world\" 'another thing' because something"; CommandContext firstCommand; @@ -45,7 +45,7 @@ public class CommandContextTest { try { firstCommand = new CommandContext(firstCmdString, new HashSet<>(Arrays.asList('o', 'w'))); } catch (CommandException e) { - log.warn("Error", e); + LOGGER.warn("Error", e); fail("Unexpected exception when creating CommandContext"); } } @@ -86,7 +86,7 @@ public class CommandContextTest { new CommandContext(cmd); new CommandContext(cmd2); } catch (CommandException e) { - log.warn("Error", e); + LOGGER.warn("Error", e); fail("Error creating CommandContext"); } } @@ -97,7 +97,7 @@ public class CommandContextTest { try { new CommandContext(cmd); } catch (CommandException e) { - log.warn("Error", e); + LOGGER.warn("Error", e); fail("Error creating CommandContext"); } } @@ -108,7 +108,7 @@ public class CommandContextTest { try { new CommandContext(cmd); } catch (CommandException e) { - log.warn("Error", e); + LOGGER.warn("Error", e); fail("Error creating CommandContext"); } } @@ -122,7 +122,7 @@ public class CommandContextTest { CommandContext context2 = new CommandContext("r hello -f world"); assertTrue(context2.hasFlag('f')); } catch (CommandException e) { - log.warn("Error", e); + LOGGER.warn("Error", e); fail("Error creating CommandContext"); } } @@ -138,7 +138,7 @@ public class CommandContextTest { CommandContext context2 = new CommandContext("pm name \"hello world\" foo bar"); assertEquals("\"hello world\" foo bar", context2.getJoinedStrings(1)); } catch (CommandException e) { - log.warn("Error", e); + LOGGER.warn("Error", e); fail("Error creating CommandContext"); } } @@ -150,7 +150,7 @@ public class CommandContextTest { assertArrayEquals(new String[] { "foo", "bar", "baz" }, context.getSlice(0)); } catch (CommandException e) { - log.warn("Error", e); + LOGGER.warn("Error", e); fail("Error creating CommandContext"); } } @@ -161,7 +161,7 @@ public class CommandContextTest { CommandContext context = new CommandContext("region flag xmas blocked-cmds \"\""); assertEquals(context.argsLength(), 3); } catch (CommandException e) { - log.warn("Error", e); + LOGGER.warn("Error", e); fail("Error creating CommandContext"); } } diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FileSystemSnapshotDatabaseTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FileSystemSnapshotDatabaseTest.java index 2181ca367..a89994864 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FileSystemSnapshotDatabaseTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/world/snapshot/experimental/fs/FileSystemSnapshotDatabaseTest.java @@ -26,7 +26,6 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.io.file.ArchiveNioSupport; import com.sk89q.worldedit.util.io.file.ArchiveNioSupports; -import com.sk89q.worldedit.util.io.file.TrueVfsArchiveNioSupport; import com.sk89q.worldedit.util.io.file.ZipArchiveNioSupport; import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.storage.ChunkStoreHelper; @@ -161,7 +160,7 @@ class FileSystemSnapshotDatabaseTest { @TestFactory Stream withSpecificNioSupport() { return Stream.of( - ZipArchiveNioSupport.getInstance(), TrueVfsArchiveNioSupport.getInstance() + ZipArchiveNioSupport.getInstance() ) .map(nioSupport -> { Stream nodes = Stream.of(FSSDTestType.values()) diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index 7208f83d4..80ab916d4 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -20,9 +20,8 @@ configurations.all { dependencies { "api"(project(":worldedit-core")) "implementation"(enforcedPlatform("org.apache.logging.log4j:log4j-bom:2.8.1") { - because("Mojang provides Log4J, we bump to match Forge") + because("Mojang provides Log4J at 2.8.1") }) - "implementation"("org.apache.logging.log4j:log4j-slf4j-impl") "minecraft"("com.mojang:minecraft:$minecraftVersion") "mappings"("net.fabricmc:yarn:$yarnMappings") @@ -75,12 +74,8 @@ tasks.named("jar") { tasks.named("shadowJar") { archiveClassifier.set("dist-dev") dependencies { - relocate("org.slf4j", "com.sk89q.worldedit.slf4j") - relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.l4j") relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4") - include(dependency("org.slf4j:slf4j-api")) - include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) include(dependency("org.antlr:antlr4-runtime")) } } diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorldEdit.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorldEdit.java index 54b243d8d..79f28ab0e 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorldEdit.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorldEdit.java @@ -28,6 +28,7 @@ import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.fabric.net.handler.WECUIPacketHandler; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockType; @@ -56,7 +57,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.registry.Registry; import net.minecraft.world.World; -import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.File; @@ -70,7 +70,7 @@ import java.nio.file.Path; */ public class FabricWorldEdit implements ModInitializer { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public static final String MOD_ID = "worldedit"; public static final String CUI_PLUGIN_CHANNEL = "cui"; diff --git a/worldedit-forge/build.gradle.kts b/worldedit-forge/build.gradle.kts index 65481cf23..305b2e10d 100644 --- a/worldedit-forge/build.gradle.kts +++ b/worldedit-forge/build.gradle.kts @@ -27,10 +27,8 @@ configurations.all { dependencies { "api"(project(":worldedit-core")) - "implementation"(enforcedPlatform("org.apache.logging.log4j:log4j-bom:2.8.1") { - because("Forge provides Log4J (Mojang provides a lower version, but Forge bumps)") - }) - "implementation"("org.apache.logging.log4j:log4j-slf4j-impl") + "implementation"(enforcedPlatform("org.apache.logging.log4j:log4j-bom:2.11.2") { + because("Forge provides Log4J at 2.11.2 (Mojang provides 2.8.1, but Forge bumps)") "minecraft"("net.minecraftforge:forge:$minecraftVersion-$forgeVersion") } @@ -95,15 +93,9 @@ addJarManifest(WorldEditKind.Mod, includeClasspath = false) tasks.named("shadowJar") { dependencies { - relocate("org.slf4j", "com.sk89q.worldedit.slf4j") - relocate("org.apache.logging.slf4j", "com.sk89q.worldedit.l4j") relocate("org.antlr.v4", "com.sk89q.worldedit.antlr4") - include(dependency("org.slf4j:slf4j-api")) - include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) include(dependency("org.antlr:antlr4-runtime")) - include(dependency("de.schlichtherle:truezip")) - include(dependency("net.java.truevfs:truevfs-profile-default_2.13")) include(dependency("org.mozilla:rhino-runtime")) } minimize { diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java index 90eb9f2f5..e6153b114 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java @@ -32,6 +32,7 @@ import com.sk89q.worldedit.forge.proxy.ClientProxy; import com.sk89q.worldedit.forge.proxy.CommonProxy; import com.sk89q.worldedit.forge.proxy.ServerProxy; import com.sk89q.worldedit.internal.anvil.ChunkDeleter; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockCategory; @@ -64,7 +65,6 @@ import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.registries.ForgeRegistries; -import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.File; @@ -83,7 +83,7 @@ import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAM @Mod(ForgeWorldEdit.MOD_ID) public class ForgeWorldEdit { - private static final Logger LOGGER = LogManager.getLogger(); + private static final Logger LOGGER = LogManagerCompat.getLogger(); public static final String MOD_ID = "worldedit"; public static final String CUI_PLUGIN_CHANNEL = "cui"; diff --git a/worldedit-libs/bukkit/build.gradle.kts b/worldedit-libs/bukkit/build.gradle.kts index 3db476966..1a08c7935 100644 --- a/worldedit-libs/bukkit/build.gradle.kts +++ b/worldedit-libs/bukkit/build.gradle.kts @@ -5,10 +5,6 @@ repositories { maven { name = "SpigotMC" url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") - content { - includeGroup("org.bukkit") - includeGroup("org.spigotmc") - } } } diff --git a/worldedit-libs/core/ap/build.gradle.kts b/worldedit-libs/core/ap/build.gradle.kts index 266d18fa2..44374359b 100644 --- a/worldedit-libs/core/ap/build.gradle.kts +++ b/worldedit-libs/core/ap/build.gradle.kts @@ -1,6 +1,6 @@ applyLibrariesConfiguration() dependencies { - "shade"("org.enginehub.piston.core-ap:annotations:0.5.6") - "shade"("org.enginehub.piston.core-ap:processor:0.5.6") + "shade"("org.enginehub.piston.core-ap:annotations:${Versions.PISTON}") + "shade"("org.enginehub.piston.core-ap:processor:${Versions.PISTON}") } diff --git a/worldedit-libs/core/build.gradle.kts b/worldedit-libs/core/build.gradle.kts index 1100bade3..6ebb27ec4 100644 --- a/worldedit-libs/core/build.gradle.kts +++ b/worldedit-libs/core/build.gradle.kts @@ -9,9 +9,9 @@ dependencies { exclude(group = "junit", module = "junit") } "shade"("com.thoughtworks.paranamer:paranamer:2.8") - "shade"("com.github.luben:zstd-jni:1.4.8-6") + "shade"("com.github.luben:zstd-jni:1.4.9-2") "shade"("com.sk89q.lib:jlibnoise:1.0.0") - "shade"("org.enginehub.piston:core:0.5.6") - "shade"("org.enginehub.piston.core-ap:runtime:0.5.6") - "shade"("org.enginehub.piston:default-impl:0.5.6") + "shade"("org.enginehub.piston:core:${Versions.PISTON}") + "shade"("org.enginehub.piston.core-ap:runtime:${Versions.PISTON}") + "shade"("org.enginehub.piston:default-impl:${Versions.PISTON}") } diff --git a/worldedit-sponge/build.gradle.kts b/worldedit-sponge/build.gradle.kts index 479faffa0..326f83bd3 100644 --- a/worldedit-sponge/build.gradle.kts +++ b/worldedit-sponge/build.gradle.kts @@ -20,7 +20,13 @@ repositories { dependencies { api(project(":worldedit-core")) api(project(":worldedit-libs:sponge")) - api("org.spongepowered:spongeapi:7.1.0") + api("org.spongepowered:spongeapi:7.1.0") { + exclude(group = "org.slf4j", module = "slf4j-api") + } + implementation(enforcedPlatform("org.apache.logging.log4j:log4j-bom:2.8.1") { + because("Sponge 8 provides Log4J at 2.8.1") + }) + api("org.apache.logging.log4j:log4j-api") api("org.bstats:bstats-sponge:1.7") testImplementation("org.mockito:mockito-core:1.9.0-rc1") } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java index 7c96077f1..41afcc804 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java @@ -36,7 +36,7 @@ import com.sk89q.worldedit.sponge.adapter.SpongeImplAdapter; import com.sk89q.worldedit.sponge.adapter.SpongeImplLoader; import com.sk89q.worldedit.sponge.config.SpongeConfiguration; import org.bstats.sponge.Metrics2; -import org.slf4j.Logger; +import org.apache.logging.log4j.Logger; import org.spongepowered.api.Sponge; import org.spongepowered.api.block.BlockSnapshot; import org.spongepowered.api.block.BlockType; diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplLoader.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplLoader.java index 2e9a342ba..100d2eb42 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplLoader.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplLoader.java @@ -21,8 +21,8 @@ package com.sk89q.worldedit.sponge.adapter; import com.google.common.collect.Lists; import com.sk89q.worldedit.util.io.Closer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.sk89q.worldedit.internal.util.LogManagerCompat; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -38,7 +38,7 @@ import java.util.jar.JarFile; */ public class SpongeImplLoader { - private static final Logger log = LoggerFactory.getLogger(SpongeImplLoader.class); + private static final Logger LOGGER = LogManagerCompat.getLogger(); private final List adapterCandidates = new ArrayList<>(); private String customCandidate; @@ -71,7 +71,7 @@ public class SpongeImplLoader { if (className != null) { customCandidate = className; adapterCandidates.add(className); - log.info("-Dworldedit.sponge.adapter used to add " + className + " to the list of available Sponge adapters"); + LOGGER.info("-Dworldedit.sponge.adapter used to add " + className + " to the list of available Sponge adapters"); } } @@ -157,18 +157,18 @@ public class SpongeImplLoader { if (SpongeImplAdapter.class.isAssignableFrom(cls)) { suitableAdapters.add((SpongeImplAdapter) cls.newInstance()); } else { - log.warn("Failed to load the Sponge adapter class '" + className + + LOGGER.warn("Failed to load the Sponge adapter class '" + className + "' because it does not implement " + SpongeImplAdapter.class.getCanonicalName()); } } catch (ClassNotFoundException e) { - log.warn("Failed to load the Sponge adapter class '" + className + + LOGGER.warn("Failed to load the Sponge adapter class '" + className + "' that is not supposed to be missing", e); } catch (IllegalAccessException e) { - log.warn("Failed to load the Sponge adapter class '" + className + + LOGGER.warn("Failed to load the Sponge adapter class '" + className + "' that is not supposed to be raising this error", e); } catch (Throwable e) { if (className.equals(customCandidate)) { - log.warn("Failed to load the Sponge adapter class '" + className + "'", e); + LOGGER.warn("Failed to load the Sponge adapter class '" + className + "'", e); } } } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java index 140fee30f..fc308bcb0 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java @@ -30,7 +30,7 @@ import ninja.leaping.configurate.ConfigurationOptions; import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.loader.ConfigurationLoader; import ninja.leaping.configurate.objectmapping.ObjectMappingException; -import org.slf4j.Logger; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.util.HashSet; diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/SpongeConfiguration.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/SpongeConfiguration.java index 0159b46a9..8b363f8be 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/SpongeConfiguration.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/SpongeConfiguration.java @@ -23,7 +23,7 @@ import com.google.inject.Inject; import com.sk89q.worldedit.sponge.SpongeWorldEdit; import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.loader.ConfigurationLoader; -import org.slf4j.Logger; +import org.apache.logging.log4j.Logger; import org.spongepowered.api.config.DefaultConfig; import java.io.File;