From dfa3f457d68e2f7b95fe3b8d72b6c7245d20bdd6 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Fri, 3 Jan 2020 12:30:46 -0500 Subject: [PATCH] New debugging to generate less console messages. --- .../implementation/blocks/CharBlocks.java | 11 ++++-- .../worldedit/command/GenerationCommands.java | 34 ++++++++----------- .../worldedit/command/HistorySubCommands.java | 29 ++++++++-------- 3 files changed, 37 insertions(+), 37 deletions(-) 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 76156ecaa..1b2aa0039 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 @@ -104,10 +104,15 @@ public abstract class CharBlocks implements IBlocks { } public void set(int x, int y, int z, char value) { - Fawe.imp().debug("Setting Block at x:" + x + ", y:" + y + " , z:" + z); final int layer = y >> 4; final int index = (y & 15) << 8 | z << 4 | x; - set(layer, index, value); + try { + set(layer, index, value); + } catch (ArrayIndexOutOfBoundsException exception) { + Fawe.imp().debug("Tried Setting Block at x:" + x + ", y:" + y + " , z:" + z); + Fawe.imp().debug("Layer variable was = " + layer); + exception.printStackTrace(); + } } /* @@ -118,7 +123,7 @@ public abstract class CharBlocks implements IBlocks { return sections[layer].get(this, layer, index); } - public final void set(@Range(from = 0, to = 15) int layer, int index, char value) { + public final void set(@Range(from = 0, to = 15) int layer, int index, char value) throws ArrayIndexOutOfBoundsException { sections[layer].set(this, layer, index, value); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index 201ad394f..77fe4b5c2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -18,6 +18,7 @@ */ package com.sk89q.worldedit.command; +import static com.google.common.base.Preconditions.checkNotNull; import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; @@ -25,7 +26,6 @@ import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgum import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Caption; -import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TextureUtil; @@ -41,8 +41,6 @@ import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.function.generator.CavesGen; - -import java.util.List; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; @@ -53,23 +51,21 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.TreeGenerator.TreeType; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockType; - import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; +import java.util.List; 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.Switch; - -import static com.google.common.base.Preconditions.checkNotNull; - import org.jetbrains.annotations.Range; /** @@ -98,17 +94,17 @@ public class GenerationCommands { @Logging(PLACEMENT) @Confirm(Confirm.Processor.REGION) public void caves(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, - @Arg(name = "size", desc = "TODO", def = "8") int sizeOpt, - @Arg(name = "frequency", desc = "TODO", def = "40") int frequencyOpt, - @Arg(name = "rarity", desc = "TODO", def = "7") int rarityOpt, - @Arg(name = "minY", desc = "TODO", def = "8") int minYOpt, - @Arg(name = "maxY", desc = "TODO", def = "127") int maxYOpt, - @Arg(name = "systemFrequency", desc = "TODO", def = "1") int systemFrequencyOpt, - @Arg(name = "individualRarity", desc = "TODO", def = "25") int individualRarityOpt, - @Arg(name = "pocketChance", desc = "TODO", def = "0") int pocketChanceOpt, - @Arg(name = "pocketMin", desc = "TODO", def = "0") int pocketMinOpt, - @Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt) throws WorldEditException { - CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt); + @Arg(name = "size", desc = "TODO", def = "8") int size, + @Arg(name = "frequency", desc = "TODO", def = "40") int frequency, + @Arg(name = "rarity", desc = "TODO", def = "7") int rarity, + @Arg(name = "minY", desc = "TODO", def = "8") int minY, + @Arg(name = "maxY", desc = "TODO", def = "127") int maxY, + @Arg(name = "systemFrequency", desc = "TODO", def = "1") int systemFrequency, + @Arg(name = "individualRarity", desc = "TODO", def = "25") int individualRarity, + @Arg(name = "pocketChance", desc = "TODO", def = "0") int pocketChance, + @Arg(name = "pocketMin", desc = "TODO", def = "0") int pocketMin, + @Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMax) throws WorldEditException { + CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax); editSession.generate(region, gen); actor.print(Caption.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount())); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java index b9fa1743b..284f66488 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java @@ -1,5 +1,7 @@ package com.sk89q.worldedit.command; +import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; + import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.Caption; @@ -37,14 +39,6 @@ import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; -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.jetbrains.annotations.Range; - -import javax.annotation.Nullable; import java.io.File; import java.lang.ref.Reference; import java.lang.ref.SoftReference; @@ -54,8 +48,14 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.LongAdder; import java.util.function.Supplier; - -import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; +import javax.annotation.Nullable; +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.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Range; @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class HistorySubCommands { @@ -79,7 +79,7 @@ public class HistorySubCommands { @AllowedRegion Region[] allowedRegions, @ArgFlag(name = 'u', desc = "String user", def="me") UUID other, @ArgFlag(name = 'r', def = "0", desc = "radius") - @Range(from = 0, to=Integer.MAX_VALUE) int radius, + @Range(from = 0, to = Integer.MAX_VALUE) int radius, @ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @Time long timeDiff) throws WorldEditException { rollback(player, world, database, allowedRegions, other, radius, timeDiff, true); @@ -96,7 +96,7 @@ public class HistorySubCommands { @AllowedRegion Region[] allowedRegions, @ArgFlag(name = 'u', desc = "String user", def = "") UUID other, @ArgFlag(name = 'r', def = "0", desc = "radius") - @Range(from = 0, to=Integer.MAX_VALUE) int radius, + @Range(from = 0, to = Integer.MAX_VALUE) int radius, @ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @Time long timeDiff, @Switch(name = 'f', desc = "Restore instead of rollback") boolean restore) throws WorldEditException { if (!Settings.IMP.HISTORY.USE_DATABASE) { @@ -277,8 +277,7 @@ public class HistorySubCommands { @CommandPermissions("worldedit.history.find") public synchronized void find(Player player, World world, RollbackDatabase database, Arguments arguments, @ArgFlag(name = 'u', desc = "String user") UUID other, - @ArgFlag(name = 'r', def = "0", desc = "radius") - @Range(from = 0, to=Integer.MAX_VALUE) int radius, + @ArgFlag(name = 'r', def = "0", desc = "radius") int radius, @ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @Time long timeDiff, @ArgFlag(name = 'p', desc = "Page to view.", def = "1") int page) throws WorldEditException { @@ -318,7 +317,7 @@ public class HistorySubCommands { } PaginationBox pages = PaginationBox.fromStrings("Edits:", pageCommand, list, new Function, Component>() { - @Nullable + @NotNull @Override public Component apply(@Nullable Supplier input) { RollbackOptimizedHistory edit = input.get();