3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

consistency changes

Dieser Commit ist enthalten in:
MattBDev 2020-01-26 13:01:16 -05:00
Ursprung e0f6869573
Commit 8078cf077a
32 geänderte Dateien mit 296 neuen und 388 gelöschten Zeilen

Datei anzeigen

@ -89,8 +89,8 @@ public class Worldguard extends BukkitMaskManager implements Listener {
}
@Override
public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) {
final Player player = BukkitAdapter.adapt(fp);
public FaweMask getMask(com.sk89q.worldedit.entity.Player wePlayer, MaskType type) {
final Player player = BukkitAdapter.adapt(wePlayer);
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
final Location location = player.getLocation();
final ProtectedRegion myregion = this.getRegion(localplayer, location);

Datei anzeigen

@ -23,18 +23,18 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
private WorldGuardPlugin worldguard;
public WorldguardFlag(Plugin p2) {
public WorldguardFlag(Plugin plugin) {
super("worldguardflag");
this.worldguard = (WorldGuardPlugin) p2; // this.getWorldGuard();
this.worldguard = (WorldGuardPlugin) plugin; // this.getWorldGuard();
}
@Override
public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) {
final Player player = BukkitAdapter.adapt(fp);
public FaweMask getMask(com.sk89q.worldedit.entity.Player wePlayer, MaskType type) {
final Player player = BukkitAdapter.adapt(wePlayer);
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
final RegionContainer container = WorldGuard.getInstance().getPlatform()
.getRegionContainer();
final RegionManager manager = container.get(fp.getWorld());
final RegionManager manager = container.get(wePlayer.getWorld());
return new FaweMask(new ManagerRegion(manager, localplayer)) {
@Override

Datei anzeigen

@ -8,6 +8,7 @@ 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.jetbrains.annotations.Range;
public interface IChunkExtent<T extends IChunk> extends Extent {
/**
@ -20,7 +21,7 @@ public interface IChunkExtent<T extends IChunk> extends Extent {
T getOrCreateChunk(int chunkX, int chunkZ);
@Override
default <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B state) {
default <B extends BlockStateHolder<B>> boolean setBlock(int x, @Range(from = 0, to = 255) int y, int z, B state) {
final IChunk chunk = getOrCreateChunk(x >> 4, z >> 4);
return chunk.setBlock(x & 15, y, z & 15, state);
}

Datei anzeigen

@ -97,13 +97,13 @@ public abstract class CharBlocks implements IBlocks {
return BlockTypesCache.states[get(x, y, z)];
}
public char get(int x, int y, int z) {
public char get(int x, @Range(from = 0, to = 255) int y, int z) {
final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x;
return sections[layer].get(this, layer, index);
}
public void set(int x, int y, int z, char value) {
public void set(int x, @Range(from = 0, to = 255) int y, int z, char value) {
final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x;
try {
@ -130,13 +130,13 @@ public abstract class CharBlocks implements IBlocks {
public static abstract class Section {
public abstract char[] get(CharBlocks blocks, int layer);
public abstract char[] get(CharBlocks blocks, @Range(from = 0, to = 15) int layer);
public final char get(CharBlocks blocks, int layer, int index) {
public final char get(CharBlocks blocks, @Range(from = 0, to = 15) int layer, int index) {
return get(blocks, layer)[index];
}
public final void set(CharBlocks blocks, int layer, int index, char value) {
public final void set(CharBlocks blocks, @Range(from = 0, to = 15) int layer, int index, char value) {
get(blocks, layer)[index] = value;
}
}

Datei anzeigen

@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.IntStream;
import org.jetbrains.annotations.Range;
public class CharSetBlocks extends CharBlocks implements IChunkSet {
private static Pool<CharSetBlocks> POOL = FaweCache.INSTANCE.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL);
@ -82,7 +83,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T holder) {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, @Range(from = 0, to = 255) int y, int z, T holder) {
set(x, y, z, holder.getOrdinalChar());
holder.applyTileEntity(this, x, y, z);
return true;

Datei anzeigen

@ -23,6 +23,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Future;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Range;
/**
* An abstract {@link IChunk} class that implements basic get/set blocks
@ -208,7 +209,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(ChunkHolder chunk, int x, int y, int z, T block) {
public <B extends BlockStateHolder<B>> boolean setBlock(ChunkHolder chunk, int x, @Range(from = 0, to = 255) int y, int z, B block) {
return chunk.chunkSet.setBlock(x, y, z, block);
}

Datei anzeigen

@ -14,16 +14,16 @@ public class VisualQueue extends SingleThreadIntervalQueue<Player> {
}
@Override
public void operate(Player fp) {
LocalSession session = fp.getSession();
Tool tool = session.getTool(fp);
public void operate(Player player) {
LocalSession session = player.getSession();
Tool tool = session.getTool(player);
if (tool instanceof BrushTool) {
BrushTool brushTool = (BrushTool) tool;
if (brushTool.getVisualMode() != VisualMode.NONE) {
try {
brushTool.visualize(BrushTool.BrushAction.PRIMARY, fp);
brushTool.visualize(BrushTool.BrushAction.PRIMARY, player);
} catch (Throwable e) {
WorldEdit.getInstance().getPlatformManager().handleThrowable(e, fp);
WorldEdit.getInstance().getPlatformManager().handleThrowable(e, player);
}
}
}

Datei anzeigen

@ -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.extent.clipboard.BlockArrayClipboard.ClipboardEntity;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
@ -20,17 +21,13 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Nullable;
public class MemoryOptimizedClipboard extends LinearClipboard {
@ -310,7 +307,9 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
@Override
public void removeEntity(Entity entity) {
if (entity instanceof ClipboardEntity) {
this.entities.remove(entity);
}
}
}

Datei anzeigen

@ -12,7 +12,6 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.List;
import java.util.function.Supplier;
@ -81,7 +80,7 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard {
public abstract List<? extends Entity> getEntities();
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) {
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) {
throw new UnsupportedOperationException("Clipboard is immutable");
}

Datei anzeigen

@ -2,12 +2,10 @@ package com.boydti.fawe.object.clipboard;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
@ -65,8 +63,4 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
return hasBiomes;
}
@Override
public void close() {
}
}

Datei anzeigen

@ -1,55 +0,0 @@
package com.boydti.fawe.object.clipboard;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.Closeable;
import java.io.IOException;
import java.util.function.Supplier;
public class WorldCutClipboard extends WorldCopyClipboard {
public WorldCutClipboard(Supplier<Extent> supplier, Region region) {
super(supplier, region);
}
public WorldCutClipboard(Supplier<Extent> supplier, Region region, boolean hasEntities, boolean hasBiomes) {
super(supplier, region, hasEntities, hasBiomes);
}
@Override
public BaseBlock getFullBlock(int x, int y, int z) {
Extent extent = getExtent();
BaseBlock block = extent.getFullBlock(x, y, z);
extent.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
return block;
}
@Override
public BlockState getBlock(int x, int y, int z) {
Extent extent = getExtent();
BlockState block = extent.getBlock(x, y, z);
extent.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
return block;
}
@Override
public void close() {
Extent extent = getExtent();
if (extent instanceof EditSession) {
((EditSession) extent).flushQueue();
} else if (extent instanceof Closeable) {
try {
((Closeable) extent).close();
} catch (IOException e) {
e.printStackTrace();
}
} else {
extent.commit();
}
}
}

Datei anzeigen

@ -6,9 +6,9 @@ import java.io.FileNotFoundException;
public class CachedTextureUtil extends DelegateTextureUtil {
private final TextureUtil parent;
private transient Int2ObjectOpenHashMap<BlockType> colorBlockMap;
private transient Int2ObjectOpenHashMap<Integer> colorBiomeMap;
private transient Int2ObjectOpenHashMap<BlockType[]> colorLayerMap;
private final transient Int2ObjectOpenHashMap<BlockType> colorBlockMap;
private final transient Int2ObjectOpenHashMap<Integer> colorBiomeMap;
private final transient Int2ObjectOpenHashMap<BlockType[]> colorLayerMap;
public CachedTextureUtil(TextureUtil parent) throws FileNotFoundException {
super(parent);
@ -39,7 +39,7 @@ public class CachedTextureUtil extends DelegateTextureUtil {
}
BiomeColor result = parent.getNearestBiome(color);
if (result != null) {
colorBiomeMap.put((int) color, (Integer) result.id);
colorBiomeMap.put(color, (Integer) result.id);
}
return result;
}
@ -52,7 +52,7 @@ public class CachedTextureUtil extends DelegateTextureUtil {
}
BlockType result = parent.getNearestBlock(color);
if (result != null) {
colorBlockMap.put((int) color, result);
colorBlockMap.put(color, result);
}
return result;
}

Datei anzeigen

@ -14,9 +14,9 @@ public class RandomTextureUtil extends CachedTextureUtil {
}
private int index;
private int[] biomeMixBuffer = new int[3];
private Int2ObjectOpenHashMap<Integer> offsets = new Int2ObjectOpenHashMap<>();
private Int2ObjectOpenHashMap<int[]> biomeMixes = new Int2ObjectOpenHashMap<>();
private final int[] biomeMixBuffer = new int[3];
private final Int2ObjectOpenHashMap<Integer> offsets = new Int2ObjectOpenHashMap<>();
private final Int2ObjectOpenHashMap<int[]> biomeMixes = new Int2ObjectOpenHashMap<>();
protected int addRandomColor(int c1, int c2) {
int red1 = (c1 >> 16) & 0xFF;

Datei anzeigen

@ -1,11 +1,6 @@
package com.boydti.fawe.util;
import sun.reflect.ConstructorAccessor;
import sun.reflect.FieldAccessor;
import sun.reflect.ReflectionFactory;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@ -24,80 +19,11 @@ public class ReflectionUtils {
}
public static <T extends Enum<?>> T addEnum(Class<T> enumType, String enumName) {
try {
return addEnum(enumType, enumName, new Class<?>[]{}, new Object[]{});
} catch (Throwable ignore) {
return ReflectionUtils9.addEnum(enumType, enumName);
}
}
public static <T extends Enum<?>> T addEnum(Class<T> enumType, String enumName, Class<?>[] additionalTypes, Object[] additionalValues) {
// 0. Sanity checks
if (!Enum.class.isAssignableFrom(enumType)) {
throw new RuntimeException("class " + enumType + " is not an instance of Enum");
}
// 1. Lookup "$VALUES" holder in enum class and get previous enum instances
Field valuesField = null;
Field[] fields = enumType.getDeclaredFields();
for (Field field : fields) {
if (field.getName().contains("$VALUES")) {
valuesField = field;
break;
}
}
AccessibleObject.setAccessible(new Field[]{valuesField}, true);
try {
// 2. Copy it
T[] previousValues = (T[]) valuesField.get(enumType);
List<T> values = new ArrayList<>(Arrays.asList(previousValues));
// 3. build new enum
T newValue = (T) makeEnum(enumType, // The target enum class
enumName, // THE NEW ENUM INSTANCE TO BE DYNAMICALLY ADDED
values.size(),
additionalTypes, // can be used to pass values to the enum constructor
additionalValues); // can be used to pass values to the enum constructor
// 4. add new value
values.add(newValue);
// 5. Set new values field
setFailsafeFieldValue(valuesField, null,
values.toArray((T[]) Array.newInstance(enumType, 0)));
// 6. Clean enum cache
cleanEnumCache(enumType);
return newValue;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage(), e);
}
}
public static Object makeEnum(Class<?> enumClass, String value, int ordinal,
Class<?>[] additionalTypes, Object[] additionalValues) throws Exception {
Object[] parms = new Object[additionalValues.length + 2];
parms[0] = value;
parms[1] = ordinal;
System.arraycopy(additionalValues, 0, parms, 2, additionalValues.length);
return enumClass.cast(getConstructorAccessor(enumClass, additionalTypes).newInstance(parms));
}
private static ConstructorAccessor getConstructorAccessor(Class<?> enumClass,
Class<?>[] additionalParameterTypes) throws NoSuchMethodException {
Class<?>[] parameterTypes = new Class[additionalParameterTypes.length + 2];
parameterTypes[0] = String.class;
parameterTypes[1] = int.class;
System.arraycopy(additionalParameterTypes, 0,
parameterTypes, 2, additionalParameterTypes.length);
return ReflectionFactory.getReflectionFactory().newConstructorAccessor(enumClass.getDeclaredConstructor(parameterTypes));
}
public static void setAccessibleNonFinal(Field field)
throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
// let's make the field accessible
field.setAccessible(true);
@ -134,13 +60,8 @@ public class ReflectionUtils {
throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
setAccessibleNonFinal(field);
try {
FieldAccessor fa = ReflectionFactory.getReflectionFactory().newFieldAccessor(field, false);
fa.set(target, value);
} catch (NoSuchMethodError error) {
field.set(target,value);
}
}
private static void blankField(Class<?> enumClass, String fieldName)
throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {

Datei anzeigen

@ -141,6 +141,7 @@ import java.util.Map;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -865,7 +866,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) {
public <B extends BlockStateHolder<B>> boolean setBlock(int x, @Range(from = 0, to = 255) int y, int z, B block) {
this.changes++;
try {
return this.getExtent().setBlock(x, y, z, block);

Datei anzeigen

@ -153,6 +153,8 @@ public class LocalSession implements TextureHolder {
private transient VirtualWorld virtual;
private transient BlockVector3 cuiTemporaryBlock;
@SuppressWarnings("unused")
private transient EditSession.ReorderMode reorderMode = EditSession.ReorderMode.MULTI_STAGE;
private transient List<Countable<BlockState>> lastDistribution;
private transient World worldOverride;
private transient boolean tickingWatchdog = false;
@ -395,6 +397,9 @@ public class LocalSession implements TextureHolder {
public void remember(EditSession editSession) {
checkNotNull(editSession);
// Don't store anything if no changes were made
if (editSession.size() == 0) return;
Player player = editSession.getPlayer();
int limit = player == null ? Integer.MAX_VALUE : player.getLimit().MAX_HISTORY;
remember(editSession, true, limit);
@ -940,9 +945,9 @@ public class LocalSession implements TextureHolder {
}
/**
* Get the snapshot that has been selected.
* Get the legacy snapshot that has been selected.
*
* @return the snapshot
* @return the legacy snapshot
*/
@Nullable
public Snapshot getSnapshot() {

Datei anzeigen

@ -202,10 +202,6 @@ public class BiomeCommands {
"worldedit.setbiome.changed",
TextComponent.of(visitor.getAffected())
));
if (!player.hasPermission("fawe.tips")) {
System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.biome.pattern").or(TranslatableComponent.of("fawe.tips.tip.biome.mask")).send(player);
}
}
}

Datei anzeigen

@ -506,11 +506,11 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.scatter")
public void scatterBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill,
@Arg(desc = "Expression", def = "5")
@Arg(desc = "radius", def = "5")
Expression radius,
@Arg(desc = "double", def = "5")
@Arg(desc = "points", def = "5")
double points,
@Arg(desc = "double", def = "1")
@Arg(desc = "distance", def = "1")
double distance,
@Switch(name = 'o', desc = "Overlay the block") boolean overlay) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
@ -640,7 +640,7 @@ public class BrushCommands {
@Command(
name = "clipboard",
desc = "@Deprecated use instead: `/br copypaste`)",
descFooter = "Chooses the clipboard brush.\n" +
descFooter = "Choose the clipboard brush.\n" +
"Without the -p flag, the paste will appear centered at the target location. " +
"With the flag, then the paste will appear relative to where you had " +
"stood relative to the copied area when you copied it."
@ -652,8 +652,8 @@ public class BrushCommands {
boolean ignoreAir,
@Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it")
boolean usingOrigin,
@Switch(name = 'e', desc = "Skip paste entities if available")
boolean skipEntities,
@Switch(name = 'e', desc = "Paste entities if available")
boolean pasteEntities,
@Switch(name = 'b', desc = "Paste biomes if available")
boolean pasteBiomes,
@ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard", def = "")
@ -673,7 +673,7 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1);
set(context,
new ClipboardBrush(newHolder, ignoreAir, usingOrigin, !skipEntities, pasteBiomes, sourceMask));
new ClipboardBrush(newHolder, ignoreAir, usingOrigin, pasteEntities, pasteBiomes, sourceMask));
}
@Command(
@ -695,9 +695,7 @@ public class BrushCommands {
FaweLimit limit = Settings.IMP.getLimit(player);
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
set(context,
new SmoothBrush(iterations, maskOpt))
.setSize(radius);
set(context, new SmoothBrush(iterations, maskOpt)).setSize(radius);
}
@Command(
@ -865,9 +863,7 @@ public class BrushCommands {
@Arg(desc = "Command to run") List<String> input) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
String cmd = StringMan.join(input, " ");
set(context,
new CommandBrush(cmd))
.setSize(radius);
set(context, new CommandBrush(cmd)).setSize(radius);
}
@Command(

Datei anzeigen

@ -167,13 +167,14 @@ public class ChunkCommands {
actor.printDebug(String.format("%d chunks total marked for deletion. (May have overlaps).",
currentInfo.batches.stream().mapToInt(ChunkDeletionInfo.ChunkBatch::getChunkCount).sum()));
}
actor.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.GRAY)
actor.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.LIGHT_PURPLE)
.append(TextComponent.of("/stop", TextColor.AQUA)
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop"))));
}
private static class ChunkListPaginationBox extends PaginationBox.ListPaginationBox {
//private final Region region;
private final List<BlockVector2> chunks = null;
ChunkListPaginationBox(Region region) {
super("Selected Chunks", "/listchunks -p %page%", region.getChunks());

Datei anzeigen

@ -115,11 +115,11 @@ public class ClipboardCommands {
@Confirm(Confirm.Processor.REGION)
public void copy(Actor actor, LocalSession session, EditSession editSession,
@Selection Region region,
@Switch(name = 'e', desc = "Skip copy entities")
boolean skipEntities,
@Switch(name = 'e', desc = "Also copy entities")
boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
Mask mask) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
@ -134,11 +134,9 @@ public class ClipboardCommands {
Clipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId());
session.setClipboard(new ClipboardHolder(clipboard));
clipboard.setOrigin(session.getPlacementPosition(actor));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setCopyingEntities(!skipEntities);
copy.setCopyingEntities(copyEntities);
copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask();
@ -147,14 +145,11 @@ public class ClipboardCommands {
copy.setSourceMask(sourceMask);
editSession.setSourceMask(null);
}
if (mask != null && mask != Masks.alwaysTrue()) {
if (mask != null) {
copy.setSourceMask(mask);
}
Operations.completeLegacy(copy);
if (!actor.hasPermission("fawe.tips")) {
System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.paste").or(TranslatableComponent.of("fawe.tips.tip.download"), TranslatableComponent.of("fawe.tips.tip.rotate"), TranslatableComponent.of("fawe.tips.tip.copypaste"), TranslatableComponent.of("fawe.tips.tip.replace.marker"), TranslatableComponent.of("fawe.tips.tip.copy.pattern")).send(actor);
}
session.setClipboard(new ClipboardHolder(clipboard));
copy.getStatusMessages().forEach(actor::print);
}
@ -167,8 +162,6 @@ public class ClipboardCommands {
@Selection Region region,
@Switch(name = 'e', desc = "Skip copy entities")
boolean skipEntities,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
Mask maskOpt,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint();
@ -184,10 +177,6 @@ public class ClipboardCommands {
lazyClipboard.setOrigin(session.getPlacementPosition(actor));
session.setClipboard(new ClipboardHolder(lazyClipboard));
actor.print(Caption.of("fawe.worldedit.copy.command.copy" , region.getArea()));
if (!actor.hasPermission("fawe.tips")) {
System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.paste").or(TranslatableComponent.of("fawe.tips.tip.lazycopy"), TranslatableComponent.of("fawe.tips.tip.download"), TranslatableComponent.of("fawe.tips.tip.rotate"), TranslatableComponent.of("fawe.tips.tip.copypaste"), TranslatableComponent.of("fawe.tips.tip.replace.marker"), TranslatableComponent.of("fawe.tips.tip.copy.pattern")).send(actor);
}
}
// @Command(
@ -234,11 +223,11 @@ public class ClipboardCommands {
@Selection Region region,
@Arg(desc = "Pattern to leave in place of the selection", def = "air")
Pattern leavePattern,
@Switch(name = 'e', desc = "Skip cut entities")
boolean skipEntities,
@Switch(name = 'e', desc = "Also cut entities")
boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected")
boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
@ArgFlag(name = 'm', desc = "Set the exclude mask, non-matching blocks become air", def = "")
Mask mask) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
@ -258,7 +247,7 @@ public class ClipboardCommands {
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
copy.setCopyingEntities(!skipEntities);
copy.setCopyingEntities(copyEntities);
copy.setRemovingEntities(true);
copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask();
@ -442,7 +431,7 @@ public class ClipboardCommands {
ClipboardHolder holder = session.getClipboard();
if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) {
place(actor, world, session, editSession, ignoreAirBlocks, atOrigin, selectPasted);
place(actor, world, session, editSession, ignoreAirBlocks, atOrigin, selectPasted, pasteEntities, pasteBiomes);
return;
}
Clipboard clipboard = holder.getClipboard();
@ -473,10 +462,6 @@ public class ClipboardCommands {
session.setRegionSelector(world, selector);
selector.learnChanges();
selector.explainRegionAdjust(actor, session);
}
if (!actor.hasPermission("fawe.tips")) {
System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.copypaste").or(TranslatableComponent.of("fawe.tips.tip.source.mask"), TranslatableComponent.of("fawe.tips.tip.replace.marker")).send(actor, to);
}
if (onlySelect) {
actor.printInfo(TranslatableComponent.of("worldedit.paste.selected"));
@ -511,14 +496,18 @@ public class ClipboardCommands {
@Switch(name = 'o', desc = "Paste at the original position")
boolean atOrigin,
@Switch(name = 's', desc = "Select the region after pasting")
boolean selectPasted) throws WorldEditException {
boolean selectPasted,
@Switch(name = 'e', desc = "Paste entities if available")
boolean pasteEntities,
@Switch(name = 'b', desc = "Paste biomes if available")
boolean pasteBiomes) throws WorldEditException {
ClipboardHolder holder = session.getClipboard();
final Clipboard clipboard = holder.getClipboard();
final BlockVector3 origin = clipboard.getOrigin();
final BlockVector3 to = atOrigin ? origin : session.getPlacementPosition(actor);
checkPaste(actor, editSession, to, holder, clipboard);
clipboard.paste(editSession, to, !ignoreAirBlocks);
clipboard.paste(editSession, to, !ignoreAirBlocks, pasteEntities, pasteBiomes);
Region region = clipboard.getRegion().clone();
if (selectPasted) {
@ -539,7 +528,6 @@ public class ClipboardCommands {
@Command(
name = "/rotate",
aliases = {"/rt"},
desc = "Rotate the contents of the clipboard",
descFooter = "Non-destructively rotate the contents of the clipboard.\n" +
"Angles are provided in degrees and a positive angle will result in a clockwise rotation. " +
@ -560,10 +548,6 @@ public class ClipboardCommands {
transform = transform.rotateZ(-zRotate);
holder.setTransform(holder.getTransform().combine(transform));
actor.printInfo(TranslatableComponent.of("worldedit.rotate.rotated"));
if (!actor.hasPermission("fawe.tips")) {
System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.flip").or(TranslatableComponent.of("fawe.tips.tip.deform"), TranslatableComponent.of("fawe.tips.tip.transform")).send(actor);
}
}
@Command(

Datei anzeigen

@ -45,6 +45,7 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.internal.annotation.Radii;
import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.math.BlockVector2;
@ -182,14 +183,15 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT)
public void hcyl(Actor actor, LocalSession session, EditSession editSession,
public int hcyl(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to generate")
Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The radii of the cylinder. 1st is N/S, 2nd is E/W")
BlockVector2 radii,
@Radii(2)
List<Double> radii,
@Arg(desc = "The height of the cylinder", def = "1")
int height) throws WorldEditException {
cyl(actor, session, editSession, pattern, radii, height, true);
return cyl(actor, session, editSession, pattern, radii, height, true);
}
@Command(
@ -198,19 +200,40 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT)
public void cyl(Actor actor, LocalSession session, EditSession editSession,
public int cyl(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to generate")
Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The radii of the cylinder. Order is N/S, E/W") BlockVector2 radius,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The radii of the cylinder. 1st is N/S, 2nd is E/W")
@Radii(2)
List<Double> radii,
@Arg(desc = "The height of the cylinder", def = "1")
int height,
@Switch(name = 'h', desc = "Make a hollow cylinder")
boolean hollow) throws WorldEditException {
double max = Math.max(radius.getBlockX(), radius.getBlockZ());
worldEdit.checkMaxRadius(max);
final double radiusX, radiusZ;
switch (radii.size()) {
case 1:
radiusX = radiusZ = Math.max(1, radii.get(0));
break;
case 2:
radiusX = Math.max(1, radii.get(0));
radiusZ = Math.max(1, radii.get(1));
break;
default:
actor.printError(TranslatableComponent.of("worldedit.cyl.invalid-radius"));
return 0;
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusZ);
worldEdit.checkMaxRadius(height);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow);
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
actor.printInfo(TranslatableComponent.of("worldedit.cyl.created", TextComponent.of(affected)));
return affected;
}
@Command(
@ -219,13 +242,15 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT)
public void hsphere(Actor actor, LocalSession session, EditSession editSession,
public int hsphere(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to generate")
Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W") BlockVector3 radii,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W")
@Radii(3)
List<Double> radii,
@Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
boolean raised) throws WorldEditException {
sphere(actor, session, editSession, pattern, radii, raised, true);
return sphere(actor, session, editSession, pattern, radii, raised, true);
}
@Command(
@ -234,24 +259,47 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT)
public void sphere(Actor actor, LocalSession session, EditSession editSession,
public int sphere(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to generate")
Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W")
BlockVector3 radii,
@Radii(3)
List<Double> radii,
@Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
boolean raised,
@Switch(name = 'h', desc = "Make a hollow sphere")
boolean hollow) throws WorldEditException {
double max = MathMan.max(radii.getBlockX(), radii.getBlockY(), radii.getBlockZ());
worldEdit.checkMaxRadius(max);
final double radiusX, radiusY, radiusZ;
switch (radii.size()) {
case 1:
radiusX = radiusY = radiusZ = Math.max(0, radii.get(0));
break;
case 3:
radiusX = Math.max(0, radii.get(0));
radiusY = Math.max(0, radii.get(1));
radiusZ = Math.max(0, radii.get(2));
break;
default:
actor.printError(TranslatableComponent.of("worldedit.sphere.invalid-radius"));
return 0;
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusY);
worldEdit.checkMaxRadius(radiusZ);
BlockVector3 pos = session.getPlacementPosition(actor);
BlockVector3 finalPos = raised ? pos.add(0, radii.getY(), 0) : pos;
int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow);
if (raised) {
pos = pos.add(0, (int) radiusY, 0);
}
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
actor.printInfo(TranslatableComponent.of("worldedit.sphere.created", TextComponent.of(affected)));
return affected;
}
@Command(
@ -299,12 +347,12 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT)
public void hollowPyramid(Actor actor, LocalSession session, EditSession editSession,
public int hollowPyramid(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to set")
Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The size of the pyramid")
int size) throws WorldEditException {
pyramid(actor, session, editSession, pattern, size, true);
return pyramid(actor, session, editSession, pattern, size, true);
}
@Command(
@ -313,20 +361,21 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT)
public void pyramid(Actor actor, LocalSession session, EditSession editSession,
public int pyramid(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to set")
Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The size of the pyramid")
int size,
@Switch(name = 'h', desc = "Make a hollow pyramid")
boolean hollow) throws WorldEditException {
BlockVector3 pos = session.getPlacementPosition(actor);
worldEdit.checkMaxRadius(size);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
actor.printInfo(TranslatableComponent.of("worldedit.pyramid.created", TextComponent.of(affected)));
return affected;
}
@Command(
@ -338,7 +387,7 @@ public class GenerationCommands {
@CommandPermissions("worldedit.generation.shape")
@Logging(ALL)
@Confirm(Confirm.Processor.REGION)
public void generate(Actor actor, LocalSession session, EditSession editSession,
public int generate(Actor actor, LocalSession session, EditSession editSession,
@Selection Region region,
@Arg(desc = "The pattern of blocks to set")
Pattern pattern,
@ -388,8 +437,10 @@ public class GenerationCommands {
((Player) actor).findFreePosition();
}
actor.printInfo(TranslatableComponent.of("worldedit.generate.created", TextComponent.of(affected)));
return affected;
} catch (ExpressionException e) {
actor.printError(TextComponent.of(e.getMessage()));
return 0;
}
}
@ -404,7 +455,7 @@ public class GenerationCommands {
@CommandPermissions("worldedit.generation.shape.biome")
@Logging(ALL)
@Confirm(Confirm.Processor.REGION)
public void generateBiome(Actor actor, LocalSession session, EditSession editSession,
public int generateBiome(Actor actor, LocalSession session, EditSession editSession,
@Selection Region region,
@Arg(desc = "The biome type to set")
BiomeType target,
@ -449,8 +500,10 @@ public class GenerationCommands {
try {
final int affected = editSession.makeBiomeShape(region, zero, unit1, target, String.join(" ", expression), hollow, session.getTimeout());
actor.printInfo(TranslatableComponent.of("worldedit.generatebiome.changed", TextComponent.of(affected)));
return affected;
} catch (ExpressionException e) {
actor.printError(TextComponent.of(e.getMessage()));
return 0;
}
}

Datei anzeigen

@ -56,12 +56,12 @@ public class HistoryCommands {
}
@Command(
name = "/undo",
aliases = { "/un", "/ud", "undo" },
name = "undo",
aliases = { "/undo" },
desc = "Undoes the last action (from history)"
)
@CommandPermissions({"worldedit.history.undo", "worldedit.history.undo.self"})
public void undo(Actor actor, LocalSession session,
public void undo(Player player, LocalSession session,
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1")
int times,
@Arg(name = "player", desc = "Undo this player's operations", def = "")
@ -69,42 +69,41 @@ public class HistoryCommands {
times = Math.max(1, times);
LocalSession undoSession = session;
if (session.hasFastMode()) {
actor.print(TranslatableComponent.of("fawe.worldedit.history.command.undo.disabled"));
player.print(TranslatableComponent.of("fawe.worldedit.history.command.undo.disabled"));
return;
}
if (playerName != null) {
actor.checkPermission("worldedit.history.undo.other");
player.checkPermission("worldedit.history.undo.other");
undoSession = worldEdit.getSessionManager().findByName(playerName);
if (undoSession == null) {
actor.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
return;
}
}
int timesUndone = 0;
for (int i = 0; i < times; ++i) {
BlockBag bag = actor instanceof Player ? undoSession.getBlockBag((Player) actor) : null;
EditSession undone = undoSession.undo(bag, actor);
EditSession undone = undoSession.undo(undoSession.getBlockBag(player), player);
if (undone != null) {
timesUndone++;
worldEdit.flushBlockBag(actor, undone);
worldEdit.flushBlockBag(player, undone);
} else {
break;
}
}
if (timesUndone > 0) {
actor.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
player.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
} else {
actor.printError(TranslatableComponent.of("worldedit.undo.none"));
player.printError(TranslatableComponent.of("worldedit.undo.none"));
}
}
@Command(
name = "/redo",
aliases = { "/do", "/rd", "redo" },
name = "redo",
aliases = { "/redo" },
desc = "Redoes the last action (from history)"
)
@CommandPermissions({"worldedit.history.redo", "worldedit.history.redo.self"})
public void redo(Actor actor, LocalSession session,
public void redo(Player player, LocalSession session,
@Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1")
int times,
@Arg(name = "player", desc = "Redo this player's operations", def = "")
@ -112,28 +111,27 @@ public class HistoryCommands {
times = Math.max(1, times);
LocalSession redoSession = session;
if (playerName != null) {
actor.checkPermission("worldedit.history.redo.other");
player.checkPermission("worldedit.history.redo.other");
redoSession = worldEdit.getSessionManager().findByName(playerName);
if (redoSession == null) {
actor.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
return;
}
}
int timesRedone = 0;
for (int i = 0; i < times; ++i) {
BlockBag bag = actor instanceof Player ? redoSession.getBlockBag((Player) actor) : null;
EditSession redone = redoSession.redo(bag, actor);
EditSession redone = redoSession.redo(redoSession.getBlockBag(player), player);
if (redone != null) {
timesRedone++;
worldEdit.flushBlockBag(actor, redone);
worldEdit.flushBlockBag(player, redone);
} else {
break;
}
}
if (timesRedone > 0) {
actor.printInfo(TranslatableComponent.of("worldedit.redo.redone", TextComponent.of(timesRedone)));
player.printInfo(TranslatableComponent.of("worldedit.redo.redone", TextComponent.of(timesRedone)));
} else {
actor.printError(TranslatableComponent.of("worldedit.redo.none"));
player.printError(TranslatableComponent.of("worldedit.redo.none"));
}
}

Datei anzeigen

@ -224,8 +224,8 @@ public class RegionCommands {
@Command(
name = "/line",
desc = "Draws a line segment between cuboid selection corners",
descFooter = "Can only be used with a cuboid selection"
desc = "Draws line segments between cuboid selection corners or convex polyhedral selection vertices",
descFooter = "Can only be used with a cuboid selection or a convex polyhedral selection"
)
@CommandPermissions("worldedit.region.line")
@Logging(REGION)
@ -490,8 +490,8 @@ public class RegionCommands {
boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks,
@Switch(name = 'e', desc = "Skip copy entities")
boolean skipEntities,
@Switch(name = 'e', desc = "Also copy entities")
boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
@ -509,7 +509,7 @@ public class RegionCommands {
combinedMask = mask;
}
int affected = editSession.moveRegion(region, direction, count, !skipEntities, copyBiomes, combinedMask, replace);
int affected = editSession.moveRegion(region, direction, count, copyEntities, copyBiomes, combinedMask, replace);
if (moveSelection) {
try {
@ -561,8 +561,8 @@ public class RegionCommands {
boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks,
@Switch(name = 'e', desc = "Skip entities")
boolean skipEntities,
@Switch(name = 'e', desc = "Also copy entities")
boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
@ -579,7 +579,7 @@ public class RegionCommands {
combinedMask = mask;
}
int affected = editSession.stackCuboidRegion(region, direction, count, !skipEntities, copyBiomes, combinedMask);
int affected = editSession.stackCuboidRegion(region, direction, count, copyEntities, copyBiomes, combinedMask);
if (moveSelection) {
try {
@ -695,7 +695,7 @@ public class RegionCommands {
@Confirm(Confirm.Processor.REGION)
public int hollow(Actor actor, EditSession editSession,
@Selection Region region,
@Range(from = 0, to = Integer.MAX_VALUE) @Arg(desc = "Thickness of the shell to leave", def = "0")
@Arg(desc = "Thickness of the shell to leave", def = "0")
int thickness,
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
Pattern pattern,

Datei anzeigen

@ -572,7 +572,7 @@ public class SelectionCommands {
public void select(Actor actor, World world, LocalSession session,
@Arg(desc = "Selector to switch to", def = "")
SelectorChoice selector,
@Arg(desc = "Selector mask", def = "") Mask maskOpt,
@Arg(desc = "Selector mask") Mask maskOpt,
@Switch(name = 'd', desc = "Set default selector")
boolean setDefaultSelector) throws WorldEditException {
if (selector == null) {

Datei anzeigen

@ -66,7 +66,6 @@ public class ToolUtilCommands {
@Command(
name = "mask",
aliases = {"/mask"},
desc = "Set the brush destination mask"
)
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
@ -83,16 +82,18 @@ public class ToolUtilCommands {
return;
}
if (maskOpt == null) {
player.print(TranslatableComponent.of("worldedit.tool.mask.disabled"));
player.printInfo(TranslatableComponent.of("worldedit.tool.mask.disabled"));
tool.setMask(null);
return;
}
} else {
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get()))
.getSubstring();
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
settings.setMask(maskOpt);
tool.update();
player.print(TranslatableComponent.of("worldedit.tool.mask.set"));
player.printInfo(TranslatableComponent.of("worldedit.tool.mask.set"));
}
}
@Command(
@ -109,7 +110,7 @@ public class ToolUtilCommands {
Arguments arguments) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
player.printInfo(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
return;
}
if (pattern == null) {
@ -121,7 +122,7 @@ public class ToolUtilCommands {
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
tool.update();
}
player.print(TranslatableComponent.of("worldedit.tool.material.set"));
player.printInfo(TranslatableComponent.of("worldedit.tool.material.set"));
}
@Command(

Datei anzeigen

@ -81,6 +81,7 @@ import java.net.URI;
import java.nio.file.Files;
import java.text.NumberFormat;
import java.util.AbstractMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
@ -90,6 +91,7 @@ import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
@ -702,18 +704,19 @@ public class UtilityCommands {
desc = "Confirm a command"
)
@CommandPermissions(value = "fawe.confirm", queued = false)
public void confirm(Player fp) throws WorldEditException {
if (!fp.confirm()) {
fp.print(TranslatableComponent.of("fawe.worldedit.utility.nothing.confirmed"));
public void confirm(Player player) throws WorldEditException {
if (!player.confirm()) {
player.print(TranslatableComponent.of("fawe.worldedit.utility.nothing.confirmed"));
}
}
public static List<Map.Entry<URI, String>> filesToEntry(final File root, final List<File> files, final UUID uuid) {
return Lists.transform(files, input -> { // Keep this functional, as transform is evaluated lazily
return files.stream()
.map(input -> { // Keep this functional, as transform is evaluated lazily
URI uri = input.toURI();
String path = getPath(root, input, uuid);
return new AbstractMap.SimpleEntry<>(uri, path);
});
return new SimpleEntry<>(uri, path);
}).collect(Collectors.toList());
}
public static enum URIType {
@ -724,7 +727,7 @@ public class UtilityCommands {
}
public static List<Component> entryToComponent(File root, List<Map.Entry<URI, String>> entries, Function<URI, Boolean> isLoaded, QuadFunction<String, String, URIType, Boolean, Component> adapter) {
return Lists.transform(entries, input -> {
return entries.stream().map(input -> {
URI uri = input.getKey();
String path = input.getValue();
@ -741,11 +744,13 @@ public class UtilityCommands {
if (file.isDirectory()) {
type = URIType.DIRECTORY;
} else {
if (name.indexOf('.') != -1) name = name.substring(0, name.lastIndexOf('.'));
if (name.indexOf('.') != -1)
name = name.substring(0, name.lastIndexOf('.'));
}
try {
if (!MainUtil.isInSubDirectory(root, file)) {
throw new RuntimeException(new StopExecutionException(TextComponent.of("Invalid path")));
throw new RuntimeException(
new StopExecutionException(TextComponent.of("Invalid path")));
}
} catch (IOException ignore) {
}
@ -756,7 +761,7 @@ public class UtilityCommands {
}
return adapter.apply(name, path, type, loaded);
});
}).collect(Collectors.toList());
}
public static List<File> getFiles(File dir, Actor actor, List<String> args, String formatName, boolean playerFolder, boolean oldFirst, boolean newFirst) {
@ -806,8 +811,7 @@ public class UtilityCommands {
boolean listMine = false;
boolean listGlobal = !Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS;
if (len > 0) {
for (int i = 0; i < len; i++) {
String arg = args.get(i);
for (String arg : args) {
switch (arg.toLowerCase()) {
case "me":
case "mine":
@ -827,7 +831,10 @@ public class UtilityCommands {
if (arg.endsWith("/") || arg.endsWith(File.separator)) {
arg = arg.replace("/", File.separator);
String newDirFilter = dirFilter + arg;
boolean exists = new File(dir, newDirFilter).exists() || playerFolder && MainUtil.resolveRelative(new File(dir, actor.getUniqueId() + newDirFilter)).exists();
boolean exists =
new File(dir, newDirFilter).exists() || playerFolder && MainUtil
.resolveRelative(
new File(dir, actor.getUniqueId() + newDirFilter)).exists();
if (!exists) {
arg = arg.substring(0, arg.length() - File.separator.length());
if (arg.length() > 3 && arg.length() <= 16) {
@ -839,8 +846,7 @@ public class UtilityCommands {
}
}
dirFilter = newDirFilter;
}
else {
} else {
filters.add(arg);
}
break;

Datei anzeigen

@ -178,8 +178,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (free == 2) {
final BlockVector3 pos = mutablePos.setComponents(x, y - 2, z);
final BlockState state = world.getBlock(pos);
setPosition(new Location(world,
Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5)));
setPosition(Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5));
return;
}
@ -198,8 +197,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
final BlockVector3 pos = BlockVector3.at(x, y, z);
final BlockState id = world.getBlock(pos);
if (id.getBlockType().getMaterial().isMovementBlocker()) {
setPosition(new Location(world,
Vector3.at(x + 0.5, y + +BlockTypeUtil.centralTopLimit(id), z + 0.5)));
setPosition(Vector3.at(x + 0.5, y + +BlockTypeUtil.centralTopLimit(id), z + 0.5));
return;
}
@ -274,7 +272,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
public boolean descendLevel() {
final Location pos = getBlockLocation();
final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() - 1);
final int z = pos.getBlockZ();
final Extent world = pos.getExtent();
@ -472,22 +470,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
return getBlockTrace(range, false);
}
/**
* Advances the block target block until the current block is a free
* @return true if a free spot is found
*/
private boolean advanceToFree(TargetBlock hitBlox) {
Location curBlock;
while ((curBlock = hitBlox.getCurrentBlock()) != null) {
if (canPassThroughBlock(curBlock)) {
return true;
}
hitBlox.getNextBlock();
}
return false;
}
@Override
public Location getSolidBlockTrace(int range) {
@ -554,6 +536,22 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
return false;
}
/**
* Advances the block target block until the current block is a free
* @return true if a free spot is found
*/
private boolean advanceToFree(TargetBlock hitBlox) {
Location curBlock;
while ((curBlock = hitBlox.getCurrentBlock()) != null) {
if (canPassThroughBlock(curBlock)) {
return true;
}
hitBlox.getNextBlock();
}
return false;
}
@Override
public boolean passThroughForwardWall(int range) {
TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
@ -619,7 +617,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void checkPermission(String permission) throws AuthorizationException {
if (!hasPermission(permission)) {
throw new AuthorizationException(Caption.toString(Caption.of("fawe.error.no-perm", permission)));
throw new AuthorizationException();
}
}

Datei anzeigen

@ -45,6 +45,7 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.List;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Range;
/**
* A base class for {@link Extent}s that merely passes extents onto another.
@ -183,7 +184,7 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
public <T extends BlockStateHolder<T>> boolean setBlock(int x, @Range(from = 0, to = 255) int y, int z, T block)
throws WorldEditException {
return extent.setBlock(x, y, z, block);
}

Datei anzeigen

@ -116,11 +116,10 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
void setOrigin(BlockVector3 origin);
/**
* Returns true if the clipboard has biome data. This can be checked since {@link
* Extent#getBiome(BlockVector2)} strongly suggests returning {@link
* com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null} if biomes aren't
* present. However, it might not be desired to set areas to ocean if the clipboard is
* defaulting to ocean, instead of having biomes explicitly set.
* Returns true if the clipboard has biome data. This can be checked since {@link Extent#getBiome(BlockVector2)}
* strongly suggests returning {@link com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null}
* if biomes aren't present. However, it might not be desired to set areas to ocean if the clipboard is defaulting
* to ocean, instead of having biomes explicitly set.
*
* @return true if the clipboard has biome data set
*/
@ -298,9 +297,12 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
}
default void paste(Extent extent, BlockVector3 to, boolean pasteAir) {
paste(extent, to, pasteAir, false, false);
}
default void paste(Extent extent, BlockVector3 to, boolean pasteAir, boolean pasteEntities, boolean pasteBiomes) {
final BlockVector3 origin = this.getOrigin();
final boolean copyBiomes = this.hasBiomes();
// To must be relative to the clipboard origin ( player location - clipboard origin ) (as the locations supplied are relative to the world origin)
final int relx = to.getBlockX() - origin.getBlockX();
final int rely = to.getBlockY() - origin.getBlockY();
@ -312,10 +314,12 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
BaseBlock block = pos.getFullBlock(this);
int xx = pos.getX() + relx;
int zz = pos.getZ() + relz;
if (copyBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) {
if (hasBiomes()) {
if (pasteBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) {
mpos2d.setComponents(xx, zz);
extent.setBiome(mpos2d, Clipboard.this.getBiome(pos.toBlockVector2()));
}
}
if (!pasteAir && block.getBlockType().getMaterial().isAir()) {
continue;
}
@ -329,6 +333,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
final int entityOffsetY = to.getBlockY() - origin.getBlockY();
final int entityOffsetZ = to.getBlockZ() - origin.getBlockZ();
// entities
if (pasteEntities) {
for (Entity entity : this.getEntities()) {
// skip players on pasting schematic
if (entity.getState() != null && entity.getState().getType().getId()
@ -343,3 +348,4 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
}
}
}
}

Datei anzeigen

@ -19,12 +19,12 @@
package com.sk89q.worldedit.regions;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.extent.SingleRegionExtent;
import com.sk89q.worldedit.extent.Extent;
@ -32,7 +32,6 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.World;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
@ -80,9 +79,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
BlockVector3 min = getMinimumPoint();
BlockVector3 max = getMaximumPoint();
return (max.getX() - min.getX() + 1) *
(max.getY() - min.getY() + 1) *
(max.getZ() - min.getZ() + 1);
return (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1) * (max.getZ() - min.getZ() + 1);
}
/**

Datei anzeigen

@ -10,7 +10,6 @@ import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BlockRegistry;
import com.sk89q.worldedit.world.registry.Registries;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
@ -22,6 +21,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
public class BlockTypesCache {
@ -127,10 +127,7 @@ public class BlockTypesCache {
int[] result = new int[maxStateId];
Arrays.fill(result, -1);
int[] state = new int[props.size()];
int[] sizes = new int[props.size()];
for (int i = 0; i < props.size(); i++) {
sizes[i] = props.get(i).getValues().size();
}
int[] sizes = props.stream().mapToInt(prop -> prop.getValues().size()).toArray();
int index = 0;
outer:
while (true) {
@ -177,7 +174,11 @@ public class BlockTypesCache {
Registries registries = platform.getRegistries();
BlockRegistry blockReg = registries.getBlockRegistry();
Collection<String> blocks = blockReg.values();
Map<String, String> blockMap = blocks.stream().collect(Collectors.toMap(item -> item.charAt(item.length() - 1) == ']' ? item.substring(0, item.indexOf('[')) : item, item -> item));
Map<String, String> blockMap = blocks.stream().collect(Collectors.toMap(item -> {
return item.charAt(item.length() - 1) == ']' ? item.substring(0, item.indexOf('['))
: item;
},
Function.identity()));
int size = blockMap.size() + 1;
Field[] idFields = BlockID.class.getDeclaredFields();
@ -208,21 +209,22 @@ public class BlockTypesCache {
}
}
{ // Register new blocks
// Register new blocks
int internalId = 1;
for (Map.Entry<String, String> entry : blockMap.entrySet()) {
String defaultState = entry.getValue();
// Skip already registered ids
for (; values[internalId] != null; internalId++);
while (values[internalId] != null) {
internalId++;
}
BlockType type = register(defaultState, internalId, stateList);
values[internalId] = type;
}
}
for (int i = 0; i < values.length; i++) {
if (values[i] == null) values[i] = values[0];
}
states = stateList.toArray(new BlockState[stateList.size()]);
states = stateList.toArray(new BlockState[0]);
} catch (Throwable e) {

Datei anzeigen

@ -104,7 +104,7 @@ public final class LegacyMapper {
for (Map.Entry<String, String> blockEntry : dataFile.blocks.entrySet()) {
String id = blockEntry.getKey();
Integer combinedId = getCombinedId(blockEntry.getKey());
int combinedId = getCombinedId(blockEntry.getKey());
final String value = blockEntry.getValue();
blockEntries.put(id, value);
@ -143,8 +143,8 @@ public final class LegacyMapper {
}
if (state != null) {
blockArr[combinedId] = state.getInternalId();
blockStateToLegacyId4Data.put(state.getInternalId(), (Integer) combinedId);
blockStateToLegacyId4Data.putIfAbsent(state.getInternalBlockTypeId(), combinedId);
blockStateToLegacyId4Data.put(state.getInternalId(), Integer.valueOf(combinedId));
blockStateToLegacyId4Data.putIfAbsent(state.getInternalBlockTypeId(), Integer.valueOf(combinedId));
}
}
for (int id = 0; id < 256; id++) {
@ -168,6 +168,8 @@ public final class LegacyMapper {
if (type == null) {
log.debug("Unknown item: " + value);
} else {
itemToStringMap.put(type, id);
stringToItemMap.put(id, type);
try {
itemMap.put(getCombinedId(id), type);
} catch (Exception ignored) {
@ -214,10 +216,10 @@ public final class LegacyMapper {
@Nullable
public int[] getLegacyFromItem(ItemType itemType) {
Integer combinedId = getLegacyCombined(itemType);
if (combinedId == null) {
return null;
} else {
if (combinedId != null) {
return new int[]{combinedId >> 4, combinedId & 0xF};
} else {
return null;
}
}