Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Upstream merge
Dieser Commit ist enthalten in:
Ursprung
b2e3d40be2
Commit
1577ef61d4
@ -22,10 +22,7 @@ package com.sk89q.worldedit.entity;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.ListTag;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
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.util.Location;
|
||||||
import com.sk89q.worldedit.world.NbtValued;
|
import com.sk89q.worldedit.world.NbtValued;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
|
@ -26,6 +26,7 @@ import com.sk89q.worldedit.extension.input.InputParseException;
|
|||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -20,8 +20,14 @@
|
|||||||
package com.sk89q.worldedit.internal.block;
|
package com.sk89q.worldedit.internal.block;
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.BitSet;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
public final class BlockStateIdAccess {
|
public final class BlockStateIdAccess {
|
||||||
|
|
||||||
@ -55,14 +61,14 @@ public final class BlockStateIdAccess {
|
|||||||
public static boolean isValidInternalId(int internalId) {
|
public static boolean isValidInternalId(int internalId) {
|
||||||
return internalId != INVALID_ID;
|
return internalId != INVALID_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getBlockStateId(BlockState holder) {
|
public static int getBlockStateId(BlockState holder) {
|
||||||
return holder.getOrdinal();
|
return holder.getOrdinal();
|
||||||
//return blockStateInternalId.getInternalId(holder);
|
//return blockStateInternalId.getInternalId(holder);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
|
||||||
public static @Nullable BlockState getBlockStateById(int id) {
|
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 BlockRegistry#getInternalBlockStateId(BlockState)} will return
|
||||||
* {@link OptionalInt#empty()}. In those cases, we will use our own ID system,
|
* {@link OptionalInt#empty()}. In those cases, we will use our own ID system,
|
||||||
* since it's useful for other entries as well.
|
* since it's useful for other entries as well.
|
||||||
|
*
|
||||||
* @return an unused ID in WorldEdit's ID tracker
|
* @return an unused ID in WorldEdit's ID tracker
|
||||||
/
|
*/
|
||||||
private static int provideUnusedWorldEditId() {
|
private static int provideUnusedWorldEditId() {
|
||||||
return usedIds.nextClearBit(0);
|
return usedIds.nextClearBit(0);
|
||||||
}
|
}
|
||||||
@ -97,12 +104,7 @@ public final class BlockStateIdAccess {
|
|||||||
usedIds.clear();
|
usedIds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
private BlockStateIdAccess() {
|
private BlockStateIdAccess() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @Nullable BlockState getBlockStateById(int id) {
|
|
||||||
return BlockState.getFromOrdinal(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class Registry<V extends Keyed> implements Iterable<V> {
|
public class Registry<V extends Keyed> implements Iterable<V> {
|
||||||
|
@ -58,7 +58,7 @@ public class BlockMap<V> extends AbstractMap<BlockVector3, V> {
|
|||||||
========================= */
|
========================= */
|
||||||
|
|
||||||
public static <V> BlockMap<V> create() {
|
public static <V> BlockMap<V> create() {
|
||||||
return create(() -> new Int2ObjectOpenHashMap<>(64, 1f));
|
return create(() -> new Int2ObjectOpenHashMap<>(64, 0.9f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockMap<BaseBlock> createForBaseBlock() {
|
public static BlockMap<BaseBlock> createForBaseBlock() {
|
||||||
@ -118,7 +118,7 @@ public class BlockMap<V> extends AbstractMap<BlockVector3, V> {
|
|||||||
return BlockVector3.at(x, y, z);
|
return BlockVector3.at(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Long2ObjectMap<Int2ObjectMap<V>> maps = new Long2ObjectOpenHashMap<>(4, 1f);
|
private final Long2ObjectMap<Int2ObjectMap<V>> maps = new Long2ObjectOpenHashMap<>(4, 0.75f);
|
||||||
private final Supplier<Int2ObjectMap<V>> subMapSupplier;
|
private final Supplier<Int2ObjectMap<V>> subMapSupplier;
|
||||||
private Set<Entry<BlockVector3, V>> entrySet;
|
private Set<Entry<BlockVector3, V>> entrySet;
|
||||||
private Collection<V> values;
|
private Collection<V> values;
|
||||||
|
@ -33,9 +33,9 @@ import it.unimi.dsi.fastutil.objects.AbstractObjectSet;
|
|||||||
import it.unimi.dsi.fastutil.objects.ObjectIterator;
|
import it.unimi.dsi.fastutil.objects.ObjectIterator;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Int-to-BaseBlock map, but with optimizations for common cases.
|
* Int-to-BaseBlock map, but with optimizations for common cases.
|
||||||
@ -53,7 +53,6 @@ class Int2BaseBlockMap extends AbstractInt2ObjectMap<BaseBlock> {
|
|||||||
if (block.hasNbtData()) {
|
if (block.hasNbtData()) {
|
||||||
return BlockStateIdAccess.invalidId();
|
return BlockStateIdAccess.invalidId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return BlockStateIdAccess.getBlockStateId(block.toImmutableState());
|
return BlockStateIdAccess.getBlockStateId(block.toImmutableState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +67,8 @@ class Int2BaseBlockMap extends AbstractInt2ObjectMap<BaseBlock> {
|
|||||||
return state.toBaseBlock();
|
return state.toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Int2IntMap commonMap = new Int2IntOpenHashMap(64, 1f);
|
private final Int2IntMap commonMap = new Int2IntOpenHashMap(64, 0.9f);
|
||||||
private final Int2ObjectMap<BaseBlock> uncommonMap = new Int2ObjectOpenHashMap<>(1, 1f);
|
private final Int2ObjectMap<BaseBlock> uncommonMap = new Int2ObjectOpenHashMap<>(1, 0.75f);
|
||||||
|
|
||||||
{
|
{
|
||||||
commonMap.defaultReturnValue(BlockStateIdAccess.invalidId());
|
commonMap.defaultReturnValue(BlockStateIdAccess.invalidId());
|
||||||
|
@ -19,11 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.util.formatting;
|
package com.sk89q.worldedit.util.formatting;
|
||||||
|
|
||||||
import com.boydti.fawe.util.StringMan;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
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 com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import org.enginehub.piston.config.Config;
|
import org.enginehub.piston.config.Config;
|
||||||
import org.enginehub.piston.config.ConfigHolder;
|
import org.enginehub.piston.config.ConfigHolder;
|
||||||
@ -31,8 +29,6 @@ import org.enginehub.piston.config.TextConfig;
|
|||||||
import org.enginehub.piston.util.TextHelper;
|
import org.enginehub.piston.util.TextHelper;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -20,24 +20,20 @@
|
|||||||
package com.sk89q.worldedit.util.formatting.component;
|
package com.sk89q.worldedit.util.formatting.component;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
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.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
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.event.HoverEvent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration;
|
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration;
|
||||||
import java.util.List;
|
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.CommandParameters;
|
import org.enginehub.piston.CommandParameters;
|
||||||
import org.enginehub.piston.NoInputCommandParameters;
|
|
||||||
import org.enginehub.piston.config.ColorConfig;
|
import org.enginehub.piston.config.ColorConfig;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
import org.enginehub.piston.util.HelpGenerator;
|
||||||
import org.enginehub.piston.part.CommandPart;
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import javax.annotation.Nullable;
|
import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands;
|
||||||
import org.enginehub.piston.util.HelpGenerator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A box to describe usage of a command.
|
* A box to describe usage of a command.
|
||||||
|
@ -54,7 +54,7 @@ public final class ActorCallbackPaste {
|
|||||||
AsyncCommandBuilder.wrap(task, sender)
|
AsyncCommandBuilder.wrap(task, sender)
|
||||||
.registerWithSupervisor(supervisor, "Submitting content to a pastebin service.")
|
.registerWithSupervisor(supervisor, "Submitting content to a pastebin service.")
|
||||||
.sendMessageAfterDelay("(Please wait... sending output to pastebin...)")
|
.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)
|
.onFailure("Failed to submit paste", null)
|
||||||
.buildAndExec(Pasters.getExecutor());
|
.buildAndExec(Pasters.getExecutor());
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren