From f5a42c63a758075a2353a730cd92396add19b848 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Tue, 6 Oct 2020 14:44:33 -0400 Subject: [PATCH] Better logger support --- .../com/boydti/fawe/bukkit/FaweBukkit.java | 9 +--- .../regions/GriefPreventionFeature.java | 3 ++ .../fawe/bukkit/regions/ResidenceFeature.java | 4 +- .../fawe/bukkit/regions/TownyFeature.java | 4 ++ .../fawe/bukkit/regions/Worldguard.java | 10 +++- .../adapter/impl/FAWE_Spigot_v1_15_R2.java | 5 +- .../adapter/impl/FAWE_Spigot_v1_16_R1.java | 44 +++++++++++++--- .../adapter/impl/FAWE_Spigot_v1_16_R2.java | 6 ++- .../src/main/java/com/boydti/fawe/Fawe.java | 52 ++----------------- .../main/java/com/boydti/fawe/FaweCache.java | 3 +- .../src/main/java/com/boydti/fawe/IFawe.java | 2 - .../com/boydti/fawe/beta/IBatchProcessor.java | 7 ++- .../implementation/blocks/CharBlocks.java | 11 ++-- .../configuration/file/YamlConfiguration.java | 19 +++---- .../com/boydti/fawe/jnbt/anvil/MCAChunk.java | 4 +- .../com/boydti/fawe/jnbt/anvil/MCAFile.java | 2 +- .../fawe/jnbt/streamer/StreamDelegate.java | 6 ++- .../rollback/RollbackOptimizedHistory.java | 6 ++- .../fawe/object/brush/InspectBrush.java | 9 ++-- .../cfi/HeightMapMCAGenerator.java | 1 - .../boydti/fawe/util/EditSessionBuilder.java | 8 +-- .../java/com/boydti/fawe/util/MainUtil.java | 2 +- .../com/boydti/fawe/util/TextureUtil.java | 4 +- .../transform/BlockTransformExtent.java | 7 +-- .../function/mask/MaskIntersection.java | 4 +- .../worldedit/regions/EllipsoidRegion.java | 2 +- .../world/block/BlockTypesCache.java | 4 +- 27 files changed, 124 insertions(+), 114 deletions(-) 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 9357e693f..d8006bbc6 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 @@ -18,7 +18,6 @@ import com.boydti.fawe.bukkit.regions.TownyFeature; import com.boydti.fawe.bukkit.regions.Worldguard; import com.boydti.fawe.bukkit.util.BukkitTaskMan; import com.boydti.fawe.bukkit.util.ItemUtil; -import com.boydti.fawe.bukkit.util.VaultUtil; import com.boydti.fawe.bukkit.util.image.BukkitImageViewer; import com.boydti.fawe.config.Settings; import com.boydti.fawe.regions.FaweMaskManager; @@ -69,7 +68,7 @@ public class FaweBukkit implements IFawe, Listener { try { new BrushListener(plugin); } catch (Throwable e) { - log.debug("Brush Listener Failed", e); + log.error("Brush Listener Failed", e); } if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) { new RenderListener(plugin); @@ -147,10 +146,6 @@ public class FaweBukkit implements IFawe, Listener { return null; } - @Override public void debug(final String message) { - Bukkit.getConsoleSender().sendMessage(message); - } - @Override public File getDirectory() { return plugin.getDataFolder(); } @@ -163,7 +158,7 @@ public class FaweBukkit implements IFawe, Listener { this.itemUtil = tmp = new ItemUtil(); } catch (Throwable e) { Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES = false; - log.debug("Persistent Brushes Failed", e); + log.error("Persistent Brushes Failed", e); } } return tmp; 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 0371ec6cd..c5a3705d4 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 @@ -14,10 +14,13 @@ 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 { public GriefPreventionFeature(final Plugin griefpreventionPlugin) { super(griefpreventionPlugin.getName()); + getLogger(GriefPreventionFeature.class).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 eb89edfdd..6b834233a 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 @@ -12,6 +12,8 @@ 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 FaweBukkit plugin; private Plugin residence; @@ -20,7 +22,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."); } 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 554be7c7e..b735701ac 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 @@ -18,6 +18,8 @@ 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 final Plugin towny; @@ -25,6 +27,8 @@ public class TownyFeature extends BukkitMaskManager implements Listener { public TownyFeature(Plugin townyPlugin) { super(townyPlugin.getName()); this.towny = townyPlugin; + getLogger(TownyFeature.class).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 27425aa9d..5676e3973 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 @@ -26,11 +26,15 @@ 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 WorldGuardPlugin getWorldGuard() { final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard"); @@ -46,17 +50,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."); + } public ProtectedRegion getRegion(LocalPlayer player, Location location) { RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); if (container == null) { - System.out.println("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) { - System.out.println("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/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_15_R2.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_15_R2.java index 363dd3a83..232e22c51 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_15_R2.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/FAWE_Spigot_v1_15_R2.java @@ -114,6 +114,7 @@ import java.util.stream.Stream; import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter { private final Spigot_v1_15_R2 parent; @@ -339,7 +340,9 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I init(); return adaptToChar(ibd); } catch (ArrayIndexOutOfBoundsException e1) { - Fawe.debug("Attempted to convert " + ibd.getBlock() + " with ID " + Block.REGISTRY_ID.getId(ibd) + " to char. ibdToStateOrdinal length: " + ibdToStateOrdinal.length + ". Defaulting to air!"); + 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); 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 8272d3b29..44e42d099 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 @@ -19,13 +19,17 @@ package com.sk89q.worldedit.bukkit.adapter.impl; -import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.implementation.packet.ChunkPacket; -import com.boydti.fawe.bukkit.adapter.mc1_16_1.*; +import com.boydti.fawe.bukkit.adapter.mc1_16_1.BlockMaterial_1_16_1; +import com.boydti.fawe.bukkit.adapter.mc1_16_1.BukkitAdapter_1_16_1; +import com.boydti.fawe.bukkit.adapter.mc1_16_1.BukkitGetBlocks_1_16_1; +import com.boydti.fawe.bukkit.adapter.mc1_16_1.FAWEWorldNativeAccess_1_16; +import com.boydti.fawe.bukkit.adapter.mc1_16_1.MapChunkUtil_1_16_1; import com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt.LazyCompoundTag_1_16_1; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.blocks.BaseItemStack; @@ -42,11 +46,35 @@ import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.SideEffectSet; 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.*; +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 com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.registry.BlockMaterial; -import net.minecraft.server.v1_16_R1.*; +import net.minecraft.server.v1_16_R1.BiomeBase; +import net.minecraft.server.v1_16_R1.Block; +import net.minecraft.server.v1_16_R1.BlockPosition; +import net.minecraft.server.v1_16_R1.Chunk; +import net.minecraft.server.v1_16_R1.ChunkCoordIntPair; +import net.minecraft.server.v1_16_R1.ChunkSection; +import net.minecraft.server.v1_16_R1.Entity; +import net.minecraft.server.v1_16_R1.EntityPlayer; +import net.minecraft.server.v1_16_R1.EntityTypes; +import net.minecraft.server.v1_16_R1.IBlockData; +import net.minecraft.server.v1_16_R1.IRegistry; +import net.minecraft.server.v1_16_R1.ItemStack; +import net.minecraft.server.v1_16_R1.MinecraftKey; +import net.minecraft.server.v1_16_R1.NBTBase; +import net.minecraft.server.v1_16_R1.NBTTagCompound; +import net.minecraft.server.v1_16_R1.NBTTagInt; +import net.minecraft.server.v1_16_R1.PacketPlayOutMapChunk; +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.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.data.BlockData; @@ -59,16 +87,16 @@ import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack; import org.bukkit.entity.Player; -import javax.annotation.Nullable; import java.lang.ref.WeakReference; import java.util.Map; import java.util.OptionalInt; import java.util.Set; import java.util.function.Supplier; import java.util.stream.Stream; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.jnbt.StringTag; +import static org.slf4j.LoggerFactory.getLogger; public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter { private final Spigot_v1_16_R1 parent; @@ -294,7 +322,9 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I init(); return adaptToChar(ibd); } catch (ArrayIndexOutOfBoundsException e1) { - Fawe.debug("Attempted to convert " + ibd.getBlock() + " with ID " + Block.REGISTRY_ID.getId(ibd) + " to char. ibdToStateOrdinal length: " + ibdToStateOrdinal.length + ". Defaulting to air!"); + 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); 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 9a9c0fbe2..303c405d7 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 @@ -19,7 +19,6 @@ package com.sk89q.worldedit.bukkit.adapter.impl; -import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.implementation.packet.ChunkPacket; @@ -98,6 +97,7 @@ import java.util.stream.Stream; import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter { private final Spigot_v1_16_R2 parent; @@ -321,7 +321,9 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I init(); return adaptToChar(ibd); } catch (ArrayIndexOutOfBoundsException e1) { - Fawe.debug("Attempted to convert " + ibd.getBlock() + " with ID " + Block.REGISTRY_ID.getId(ibd) + " to char. ibdToStateOrdinal length: " + ibdToStateOrdinal.length + ". Defaulting to air!"); + 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); return 0; } } 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 99c5d4206..cf2f9485b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -14,10 +14,6 @@ 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 com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.session.request.Request; -import com.sk89q.worldedit.util.formatting.text.Component; -import com.sk89q.worldedit.util.formatting.text.TextComponent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -120,40 +116,6 @@ public class Fawe { instance = new Fawe(implementation); } - public static void debugPlain(String s) { - if (instance != null) { - instance.implementation.debug(s); - } else { - log.debug(s); - } - } - - /** - * Write something to the console. - */ - public static void debug(String s) { - Actor actor = Request.request().getActor(); - if (actor != null && actor.isPlayer()) { - actor.printInfo(TextComponent.of(s)); - return; - } - debugPlain(s); - } - - /** - * Write something to the console. - * - * @param c The Component to be printed - */ - public static void debug(Component c) { - Actor actor = Request.request().getActor(); - if (actor != null && actor.isPlayer()) { - actor.printDebug(c); - return; - } - debugPlain(c.toString()); - } - /** * The platform specific implementation. */ @@ -311,7 +273,7 @@ public class Fawe { 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" - + "FAWE will still work but compression won't work as well.\n", e); + + "FAWE will still work but compression won't work as well.\n", e); } } try { @@ -326,9 +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) { - debug("====== UPGRADE TO 64-BIT JAVA ======"); - debug("You are running 32-bit Java on a 64-bit machine"); - debug("===================================="); + log.info("You are running 32-bit Java on a 64-bit machine. Please upgrade to 64-bit Java."); } } @@ -362,11 +322,9 @@ public class Fawe { } } } catch (Throwable ignored) { - debug("====== MEMORY LISTENER ERROR ======"); - debug("FAWE needs access to the JVM memory system:"); - debug(" - Change your Java security settings"); - debug(" - Disable this with `max-memory-percent: -1`"); - debug("==================================="); + log.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 31ce66af6..178dfd3f8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -56,6 +56,7 @@ 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 @@ -502,7 +503,7 @@ public enum FaweCache implements Trimable { } else if (value instanceof Boolean) { return asTag((byte) ((boolean) value ? 1 : 0)); } - System.out.println("Invalid nbt: " + value); + getLogger(FaweCache.class).error("Invalid nbt: {}", value); return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java index 2d65517cf..1ff8a7566 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java @@ -13,8 +13,6 @@ import java.util.UUID; public interface IFawe { - void debug(final String s); - File getDirectory(); TaskManager getTaskManager(); 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 25f8e6146..1159000d6 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 @@ -1,6 +1,5 @@ package com.boydti.fawe.beta; -import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor; import com.boydti.fawe.beta.implementation.processors.MultiBatchProcessor; @@ -14,6 +13,8 @@ import java.util.Set; import java.util.concurrent.Future; import java.util.function.Function; +import static org.slf4j.LoggerFactory.getLogger; + public interface IBatchProcessor { /** @@ -79,9 +80,7 @@ public interface IBatchProcessor { layer++; } } catch (ArrayIndexOutOfBoundsException exception) { - Fawe.imp().debug("minY = " + minY); - Fawe.imp().debug("layer = " + ((minY - 15) >> 4)); - exception.printStackTrace(); + getLogger(IBatchProcessor.class).error("minY = {} , layer = {}", minY, ((minY - 15) >> 4), exception); } return false; } 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 834fca3ae..c62207a1a 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 @@ -6,9 +6,13 @@ import com.boydti.fawe.beta.IChunkSet; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypesCache; 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); + public static final Section FULL = new Section() { @Override public final char[] get(CharBlocks blocks, int layer) { @@ -17,7 +21,7 @@ public abstract class CharBlocks implements IBlocks { }; public static final Section EMPTY = new Section() { @Override - public synchronized final char[] get(CharBlocks blocks, int layer) { + public final synchronized char[] get(CharBlocks blocks, int layer) { char[] arr = blocks.blocks[layer]; if (arr == null) { arr = blocks.blocks[layer] = blocks.update(layer, null); @@ -120,10 +124,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 + ")"); assert Fawe.imp() != null; - Fawe.imp().debug("Tried Setting Block at x:" + x + ", y:" + y + " , z:" + z); - Fawe.imp().debug("Layer variable was = " + layer); - exception.printStackTrace(); + logger.error("Layer variable was = {}", layer, exception); } } 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 e42b2ebcd..2f49b9d0f 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 @@ -30,7 +30,7 @@ public class YamlConfiguration extends FileConfiguration { private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions); /** - * Creates a new {@link com.boydti.fawe.configuration.file.YamlConfiguration}, loading from the given file. + * Creates a new {@link YamlConfiguration}, loading from the given file. * *

* Any errors loading the Configuration will be logged and then ignored. @@ -46,12 +46,12 @@ public class YamlConfiguration extends FileConfiguration { * @return Resulting configuration * @throws IllegalArgumentException Thrown if file is null */ - public static com.boydti.fawe.configuration.file.YamlConfiguration loadConfiguration(final File file) { + public static YamlConfiguration loadConfiguration(final File file) { if (file == null) { throw new NullPointerException("File cannot be null"); } - final com.boydti.fawe.configuration.file.YamlConfiguration config = new com.boydti.fawe.configuration.file.YamlConfiguration(); + final YamlConfiguration config = new YamlConfiguration(); try { config.load(file); @@ -64,11 +64,8 @@ public class YamlConfiguration extends FileConfiguration { dest = new File(file.getAbsolutePath() + "_broken_" + i++); } Files.copy(file.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); - System.out.println("&dCould not read: &7" + file); - System.out.println("&dRenamed to: &7" + dest.getName()); - System.out.println("&c============ Full stacktrace ============"); - ex.printStackTrace(); - System.out.println("&c========================================="); + getLogger(YamlConfiguration.class).error("Could not read: {}\n" + + "Renamed to: {}", file, dest.getName(), ex); } catch (final IOException e) { e.printStackTrace(); } @@ -78,7 +75,7 @@ public class YamlConfiguration extends FileConfiguration { } /** - * Creates a new {@link com.boydti.fawe.configuration.file.YamlConfiguration}, loading from the given reader. + * Creates a new {@link YamlConfiguration}, loading from the given reader. * *

* Any errors loading the Configuration will be logged and then ignored. @@ -90,12 +87,12 @@ public class YamlConfiguration extends FileConfiguration { * @return resulting configuration * @throws IllegalArgumentException Thrown if stream is null */ - public static com.boydti.fawe.configuration.file.YamlConfiguration loadConfiguration(final Reader reader) { + public static YamlConfiguration loadConfiguration(final Reader reader) { if (reader == null) { throw new NullPointerException("Reader cannot be null"); } - final com.boydti.fawe.configuration.file.YamlConfiguration config = new com.boydti.fawe.configuration.file.YamlConfiguration(); + final YamlConfiguration config = new YamlConfiguration(); try { config.load(reader); 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 6bc7cf282..e2cecd706 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 @@ -44,6 +44,8 @@ import java.util.UUID; import java.util.concurrent.Future; import javax.annotation.Nullable; +import static org.slf4j.LoggerFactory.getLogger; + public class MCAChunk implements IChunk { public final boolean[] hasSections = new boolean[16]; @@ -308,7 +310,7 @@ public class MCAChunk implements IChunk { Object value = state.getState(property); String valueStr = value.toString(); if (Character.isUpperCase(valueStr.charAt(0))) { - System.out.println("Invalid uppercase value " + value); + getLogger(MCAChunk.class).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 1ff28d5ac..bcda322c3 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 @@ -272,7 +272,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh try (NBTInputStream nis = getChunkIS(offset)) { chunk.read(nis, false); } - System.out.println("TODO multithreaded"); // TODO + //TODO multithreaded return chunk; } 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 0bf7db2eb..a404c8956 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 @@ -6,6 +6,8 @@ import com.sk89q.jnbt.NBTInputStream; import java.io.DataInputStream; import java.io.IOException; +import static org.slf4j.LoggerFactory.getLogger; + public class StreamDelegate { private static final byte[][] ZERO_KEYS = new byte[0][]; private static final StreamDelegate[] ZERO_VALUES = new StreamDelegate[0]; @@ -39,7 +41,7 @@ public class StreamDelegate { private StreamDelegate add(String name, StreamDelegate scope) { if (valueReader != null) { - System.out.println("Scope " + name + " | " + scope + " may not run, as the stream is only read once, and a value reader is already set"); + getLogger(StreamDelegate.class).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; @@ -167,7 +169,7 @@ public class StreamDelegate { public StreamDelegate withValue(ValueReader valueReader) { if (keys.length != 0) { - System.out.println("Reader " + valueReader + " may not run, as the stream is only read once, and a value reader is already set"); + getLogger(StreamDelegate.class).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 36e657ba1..b18795a43 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 @@ -12,6 +12,8 @@ import java.io.IOException; import java.io.OutputStream; import java.util.UUID; +import static org.slf4j.LoggerFactory.getLogger; + public class RollbackOptimizedHistory extends DiskStorageHistory { private long time; @@ -32,7 +34,7 @@ public class RollbackOptimizedHistory extends DiskStorageHistory { super(world, uuid); this.time = System.currentTimeMillis(); } - + public RollbackOptimizedHistory(World world, UUID uuid, int index, long time, long size, CuboidRegion region, String command) { super(world, uuid, index); this.time = time; @@ -45,7 +47,7 @@ public class RollbackOptimizedHistory extends DiskStorageHistory { this.blockSize = (int) size; this.command = command; this.closed = true; - System.out.println("Size " + size); + getLogger(RollbackOptimizedHistory.class).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 2e786bc9b..0ad63a830 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 @@ -30,6 +30,8 @@ import java.util.Iterator; import java.util.UUID; import java.util.function.Supplier; +import static org.slf4j.LoggerFactory.getLogger; + public class InspectBrush extends BrushTool { /** @@ -62,13 +64,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")); - System.out.println("No tool control"); + getLogger(InspectBrush.class).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 )")); - System.out.println("No db"); + getLogger(InspectBrush.class).debug("No db"); return false; } try { @@ -109,10 +111,9 @@ public class InspectBrush extends BrushTool { } player.print(Caption.of("fawe.worldedit.tool.tool.inspect.info.footer", count)); } catch (IOException e) { - System.out.println("IOE"); throw new RuntimeException(e); } catch (Throwable e) { - System.out.println("E throw"); + getLogger(InspectBrush.class).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 ccebad451..ca30959d7 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 @@ -352,7 +352,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr public IChunkSet getChunk(int chunkX, int chunkZ) { // TODO don't generate new Writeable MCA chunk - System.out.println("TODO don't generate new Writeable MCA chunk"); MCAChunk tmp = new MCAChunk(); int bx = chunkX << 4; int bz = chunkZ << 4; 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 a892f5384..d83539820 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 @@ -38,9 +38,9 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.World; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nullable; import java.util.Locale; import java.util.UUID; +import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; @@ -333,7 +333,7 @@ public class EditSessionBuilder { // changeSet = new CPUOptimizedChangeSet(world); } else { if (combineStages && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0) { - System.out.println("TODO add CPUOptimizedChangeSet"); + //TODO add CPUOptimizedChangeSet } changeSet = new MemoryOptimizedHistory(world); } @@ -346,7 +346,7 @@ public class EditSessionBuilder { } if (!(changeSet instanceof NullChangeSet)) { if (this.blockBag != null) { - System.out.println("TODO implement block bag as IBatchProcessor"); + //TODO implement block bag as IBatchProcessor changeSet = new BlockBagChangeSet(changeSet, blockBag, limit.INVENTORY_MODE == 1); } if (combineStages) { @@ -387,7 +387,7 @@ public class EditSessionBuilder { this.extent = regionExtent; } if (this.limit != null && this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) { - System.out.println("TODO add batch processor for strip nbt"); + //TODO add batch processor for strip nbt this.extent = new StripNBTExtent(this.extent, this.limit.STRIP_NBT); } this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY); 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 5cbad4b7f..5993104a8 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 @@ -858,7 +858,7 @@ public class MainUtil { pool.submit(file::delete); Component msg = TranslatableComponent.of("worldedit.schematic.delete.deleted"); if (printDebug) { - Fawe.debug(msg); + getLogger(MainUtil.class).debug(msg.toString()); } } }); 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 1c961db99..6c112c83f 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 @@ -652,7 +652,7 @@ public class TextureUtil implements TextureHolder { String modelFileName = String.format(modelsDir, nameSpace, name); ZipEntry entry = getEntry(zipFile, modelFileName); if (entry == null) { - System.out.println("Cannot find " + modelFileName + " in " + file); + getLogger(TextureUtil.class).error("Cannot find {} in {}", modelFileName, file); continue; } @@ -690,7 +690,7 @@ public class TextureUtil implements TextureHolder { BufferedImage image = readImage(zipFile, textureFileName); if (image == null) { - System.out.println("Cannot find " + textureFileName); + getLogger(TextureUtil.class).error("Cannot find {}", textureFileName); continue; } int color = ImageUtil.getColor(image); 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 30e3b0c46..7a1d67ec9 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 @@ -69,6 +69,7 @@ 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 @@ -149,7 +150,7 @@ public class BlockTransformExtent extends ResettableExtent { case 2: return adapt(combine(EAST, WEST), combine(SOUTH, NORTH)); default: - System.out.println("Invalid " + property.getName() + " " + property.getValues()); + getLogger(BlockTransformExtent.class).error("Invalid {} {}", property.getName(), property.getValues()); return null; } case FACING: { @@ -181,7 +182,7 @@ public class BlockTransformExtent extends ResettableExtent { result.add(notIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right"))); continue; default: - System.out.println("Unknown direction " + value); + getLogger(BlockTransformExtent.class).warn("Unknown direction {}", value); result.add(0L); } } @@ -221,7 +222,7 @@ public class BlockTransformExtent extends ResettableExtent { directions.add(combine(NORTHEAST)); break; default: - System.out.println("Unknown direction " + value); + getLogger(BlockTransformExtent.class).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 7ce86998f..2b3968744 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 @@ -160,9 +160,9 @@ public class MaskIntersection extends AbstractMask { while (combineMasks(pairingFunction(), failedCombines) && --maxIteration > 0); if (maxIteration == 0) { - getLogger(MaskIntersection.class).debug("Failed optimize MaskIntersection"); + getLogger(MaskIntersection.class).error("Failed optimize MaskIntersection"); for (Mask mask : masks) { - System.out.println(mask.getClass() + " / " + mask); + getLogger(MaskIntersection.class).error(mask.getClass() + " / " + mask); } } // Return result diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index 6c36764da..ddce343c3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -409,7 +409,7 @@ public class EllipsoidRegion extends AbstractRegion { int yTopFull = Math.min(255, cy + diffYFull); if (yBotFull == yTopFull || yBotFull > yTopFull) { - System.out.println("aa"); + System.out.println("aa"); //why do we print "aa" here? } // Set those layers filter(chunk, filter, block, get, set, yBotFull, yTopFull, full); 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 f37067989..f17e68e55 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,6 +25,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import static org.slf4j.LoggerFactory.getLogger; + public class BlockTypesCache { /* ----------------------------------------------------- @@ -203,7 +205,7 @@ public class BlockTypesCache { String defaultState = blockMap.remove(id); if (defaultState == null) { if (internalId != 0) { - System.out.println("Ignoring invalid block " + id); + getLogger(BlockTypesCache.class).info("Ignoring invalid block {}", id); continue; } defaultState = id;