From 1577ef61d44be5244446d5818a2088918fd9a551 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Mon, 23 Mar 2020 20:56:13 -0400 Subject: [PATCH] Upstream merge --- .../sk89q/worldedit/entity/BaseEntity.java | 3 --- .../extension/factory/BlockFactory.java | 1 + .../internal/block/BlockStateIdAccess.java | 26 ++++++++++--------- .../sk89q/worldedit/registry/Registry.java | 1 + .../worldedit/util/collection/BlockMap.java | 4 +-- .../util/collection/Int2BaseBlockMap.java | 9 +++---- .../util/formatting/WorldEditText.java | 4 --- .../formatting/component/CommandUsageBox.java | 14 ++++------ .../util/paste/ActorCallbackPaste.java | 2 +- 9 files changed, 28 insertions(+), 36 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java index 2151bc33f..642565ef8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java @@ -22,10 +22,7 @@ package com.sk89q.worldedit.entity; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.ListTag; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.NbtValued; import com.sk89q.worldedit.world.entity.EntityType; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java index 7d17467a4..4f5a4fdbc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java @@ -26,6 +26,7 @@ import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.internal.registry.AbstractFactory; import com.sk89q.worldedit.world.block.BaseBlock; + import java.util.HashSet; import java.util.Set; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java index e0caaedc0..5447b944a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java @@ -20,8 +20,14 @@ package com.sk89q.worldedit.internal.block; import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.registry.BlockRegistry; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + import javax.annotation.Nullable; +import java.util.BitSet; +import java.util.OptionalInt; + +import static com.google.common.base.Preconditions.checkState; public final class BlockStateIdAccess { @@ -29,7 +35,7 @@ public final class BlockStateIdAccess { private static final int EXPECTED_BLOCK_COUNT = 2 << 13; private static final Int2ObjectOpenHashMap TO_STATE = new Int2ObjectOpenHashMap<>(EXPECTED_BLOCK_COUNT); - + static { TO_STATE.defaultReturnValue(null); } @@ -38,9 +44,9 @@ public final class BlockStateIdAccess { int getInternalId(BlockState blockState); void setInternalId(BlockState blockState, int internalId); } - + private static BlockStateInternalId blockStateInternalId; - + public static void setBlockStateInternalId(BlockStateInternalId blockStateInternalId) { BlockStateIdAccess.blockStateInternalId = blockStateInternalId; } @@ -55,14 +61,14 @@ public final class BlockStateIdAccess { public static boolean isValidInternalId(int internalId) { return internalId != INVALID_ID; } + public static int getBlockStateId(BlockState holder) { return holder.getOrdinal(); //return blockStateInternalId.getInternalId(holder); } - /* public static @Nullable BlockState getBlockStateById(int id) { - return TO_STATE.get(id); + return BlockState.getFromOrdinal(id); } /** @@ -70,8 +76,9 @@ public final class BlockStateIdAccess { * {@link BlockRegistry#getInternalBlockStateId(BlockState)} will return * {@link OptionalInt#empty()}. In those cases, we will use our own ID system, * since it's useful for other entries as well. + * * @return an unused ID in WorldEdit's ID tracker - / + */ private static int provideUnusedWorldEditId() { return usedIds.nextClearBit(0); } @@ -97,12 +104,7 @@ public final class BlockStateIdAccess { usedIds.clear(); } - */ - private BlockStateIdAccess() { } - - public static @Nullable BlockState getBlockStateById(int id) { - return BlockState.getFromOrdinal(id); - } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java index e77a04659..f5e02aee6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/Registry.java @@ -29,6 +29,7 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Set; + import javax.annotation.Nullable; public class Registry implements Iterable { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/BlockMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/BlockMap.java index 563c13de6..3074a4aa7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/BlockMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/BlockMap.java @@ -58,7 +58,7 @@ public class BlockMap extends AbstractMap { ========================= */ public static BlockMap create() { - return create(() -> new Int2ObjectOpenHashMap<>(64, 1f)); + return create(() -> new Int2ObjectOpenHashMap<>(64, 0.9f)); } public static BlockMap createForBaseBlock() { @@ -118,7 +118,7 @@ public class BlockMap extends AbstractMap { return BlockVector3.at(x, y, z); } - private final Long2ObjectMap> maps = new Long2ObjectOpenHashMap<>(4, 1f); + private final Long2ObjectMap> maps = new Long2ObjectOpenHashMap<>(4, 0.75f); private final Supplier> subMapSupplier; private Set> entrySet; private Collection values; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/Int2BaseBlockMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/Int2BaseBlockMap.java index c06a69387..7120c68e2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/Int2BaseBlockMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/Int2BaseBlockMap.java @@ -33,9 +33,9 @@ import it.unimi.dsi.fastutil.objects.AbstractObjectSet; import it.unimi.dsi.fastutil.objects.ObjectIterator; import it.unimi.dsi.fastutil.objects.ObjectSet; +import javax.annotation.Nonnull; import java.util.NoSuchElementException; import java.util.function.BiFunction; -import javax.annotation.Nonnull; /** * Int-to-BaseBlock map, but with optimizations for common cases. @@ -52,8 +52,7 @@ class Int2BaseBlockMap extends AbstractInt2ObjectMap { private static int optimizedInternalId(BaseBlock block) { if (block.hasNbtData()) { return BlockStateIdAccess.invalidId(); - } - + } return BlockStateIdAccess.getBlockStateId(block.toImmutableState()); } @@ -68,8 +67,8 @@ class Int2BaseBlockMap extends AbstractInt2ObjectMap { return state.toBaseBlock(); } - private final Int2IntMap commonMap = new Int2IntOpenHashMap(64, 1f); - private final Int2ObjectMap uncommonMap = new Int2ObjectOpenHashMap<>(1, 1f); + private final Int2IntMap commonMap = new Int2IntOpenHashMap(64, 0.9f); + private final Int2ObjectMap uncommonMap = new Int2ObjectOpenHashMap<>(1, 0.75f); { commonMap.defaultReturnValue(BlockStateIdAccess.invalidId()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java index 58b37f3a4..3698ca881 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/WorldEditText.java @@ -19,11 +19,9 @@ package com.sk89q.worldedit.util.formatting; -import com.boydti.fawe.util.StringMan; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.util.formatting.text.Component; -import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import org.enginehub.piston.config.Config; import org.enginehub.piston.config.ConfigHolder; @@ -31,8 +29,6 @@ import org.enginehub.piston.config.TextConfig; import org.enginehub.piston.util.TextHelper; import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Iterator; import java.util.List; import java.util.Locale; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java index d1152e85f..ed5ab2db2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/CommandUsageBox.java @@ -20,24 +20,20 @@ package com.sk89q.worldedit.util.formatting.component; import com.google.common.collect.Iterables; -import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands; - -import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.format.TextDecoration; -import java.util.List; import org.enginehub.piston.Command; import org.enginehub.piston.CommandParameters; -import org.enginehub.piston.NoInputCommandParameters; import org.enginehub.piston.config.ColorConfig; -import org.enginehub.piston.inject.InjectedValueAccess; -import org.enginehub.piston.part.CommandPart; +import org.enginehub.piston.util.HelpGenerator; + +import javax.annotation.Nullable; +import java.util.List; import static com.google.common.base.Preconditions.checkNotNull; -import javax.annotation.Nullable; -import org.enginehub.piston.util.HelpGenerator; +import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands; /** * A box to describe usage of a command. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java index 0cdd7c43d..09f05ef4e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java @@ -54,7 +54,7 @@ public final class ActorCallbackPaste { AsyncCommandBuilder.wrap(task, sender) .registerWithSupervisor(supervisor, "Submitting content to a pastebin service.") .sendMessageAfterDelay("(Please wait... sending output to pastebin...)") - .onSuccess((String) null, url -> sender.print(TextComponent.of(String.format(successMessage, url)))) + .onSuccess((String) null, url -> sender.print(String.format(successMessage, url))) .onFailure("Failed to submit paste", null) .buildAndExec(Pasters.getExecutor()); }