3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 04:20:06 +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 @Override
public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) { public FaweMask getMask(com.sk89q.worldedit.entity.Player wePlayer, MaskType type) {
final Player player = BukkitAdapter.adapt(fp); final Player player = BukkitAdapter.adapt(wePlayer);
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
final Location location = player.getLocation(); final Location location = player.getLocation();
final ProtectedRegion myregion = this.getRegion(localplayer, location); final ProtectedRegion myregion = this.getRegion(localplayer, location);

Datei anzeigen

@ -23,18 +23,18 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
private WorldGuardPlugin worldguard; private WorldGuardPlugin worldguard;
public WorldguardFlag(Plugin p2) { public WorldguardFlag(Plugin plugin) {
super("worldguardflag"); super("worldguardflag");
this.worldguard = (WorldGuardPlugin) p2; // this.getWorldGuard(); this.worldguard = (WorldGuardPlugin) plugin; // this.getWorldGuard();
} }
@Override @Override
public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) { public FaweMask getMask(com.sk89q.worldedit.entity.Player wePlayer, MaskType type) {
final Player player = BukkitAdapter.adapt(fp); final Player player = BukkitAdapter.adapt(wePlayer);
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
final RegionContainer container = WorldGuard.getInstance().getPlatform() final RegionContainer container = WorldGuard.getInstance().getPlatform()
.getRegionContainer(); .getRegionContainer();
final RegionManager manager = container.get(fp.getWorld()); final RegionManager manager = container.get(wePlayer.getWorld());
return new FaweMask(new ManagerRegion(manager, localplayer)) { return new FaweMask(new ManagerRegion(manager, localplayer)) {
@Override @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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import org.jetbrains.annotations.Range;
public interface IChunkExtent<T extends IChunk> extends Extent { 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); T getOrCreateChunk(int chunkX, int chunkZ);
@Override @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); final IChunk chunk = getOrCreateChunk(x >> 4, z >> 4);
return chunk.setBlock(x & 15, y, z & 15, state); 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)]; 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 layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x; final int index = (y & 15) << 8 | z << 4 | x;
return sections[layer].get(this, layer, index); 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 layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x; final int index = (y & 15) << 8 | z << 4 | x;
try { try {
@ -130,13 +130,13 @@ public abstract class CharBlocks implements IBlocks {
public static abstract class Section { 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]; 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; get(blocks, layer)[index] = value;
} }
} }

Datei anzeigen

@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import org.jetbrains.annotations.Range;
public class CharSetBlocks extends CharBlocks implements IChunkSet { public class CharSetBlocks extends CharBlocks implements IChunkSet {
private static Pool<CharSetBlocks> POOL = FaweCache.INSTANCE.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL); 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 @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()); set(x, y, z, holder.getOrdinalChar());
holder.applyTileEntity(this, x, y, z); holder.applyTileEntity(this, x, y, z);
return true; return true;

Datei anzeigen

@ -23,6 +23,7 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jetbrains.annotations.Range;
/** /**
* An abstract {@link IChunk} class that implements basic get/set blocks * 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 @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); return chunk.chunkSet.setBlock(x, y, z, block);
} }

Datei anzeigen

@ -14,16 +14,16 @@ public class VisualQueue extends SingleThreadIntervalQueue<Player> {
} }
@Override @Override
public void operate(Player fp) { public void operate(Player player) {
LocalSession session = fp.getSession(); LocalSession session = player.getSession();
Tool tool = session.getTool(fp); Tool tool = session.getTool(player);
if (tool instanceof BrushTool) { if (tool instanceof BrushTool) {
BrushTool brushTool = (BrushTool) tool; BrushTool brushTool = (BrushTool) tool;
if (brushTool.getVisualMode() != VisualMode.NONE) { if (brushTool.getVisualMode() != VisualMode.NONE) {
try { try {
brushTool.visualize(BrushTool.BrushAction.PRIMARY, fp); brushTool.visualize(BrushTool.BrushAction.PRIMARY, player);
} catch (Throwable e) { } 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.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; 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.math.BlockVector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType; 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.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import javax.annotation.Nullable;
public class MemoryOptimizedClipboard extends LinearClipboard { public class MemoryOptimizedClipboard extends LinearClipboard {
@ -310,7 +307,9 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
@Override @Override
public void removeEntity(Entity entity) { public void removeEntity(Entity entity) {
this.entities.remove(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.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -81,7 +80,7 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard {
public abstract List<? extends Entity> getEntities(); public abstract List<? extends Entity> getEntities();
@Override @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"); 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.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -65,8 +63,4 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
return hasBiomes; 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 { public class CachedTextureUtil extends DelegateTextureUtil {
private final TextureUtil parent; private final TextureUtil parent;
private transient Int2ObjectOpenHashMap<BlockType> colorBlockMap; private final transient Int2ObjectOpenHashMap<BlockType> colorBlockMap;
private transient Int2ObjectOpenHashMap<Integer> colorBiomeMap; private final transient Int2ObjectOpenHashMap<Integer> colorBiomeMap;
private transient Int2ObjectOpenHashMap<BlockType[]> colorLayerMap; private final transient Int2ObjectOpenHashMap<BlockType[]> colorLayerMap;
public CachedTextureUtil(TextureUtil parent) throws FileNotFoundException { public CachedTextureUtil(TextureUtil parent) throws FileNotFoundException {
super(parent); super(parent);
@ -39,7 +39,7 @@ public class CachedTextureUtil extends DelegateTextureUtil {
} }
BiomeColor result = parent.getNearestBiome(color); BiomeColor result = parent.getNearestBiome(color);
if (result != null) { if (result != null) {
colorBiomeMap.put((int) color, (Integer) result.id); colorBiomeMap.put(color, (Integer) result.id);
} }
return result; return result;
} }
@ -52,7 +52,7 @@ public class CachedTextureUtil extends DelegateTextureUtil {
} }
BlockType result = parent.getNearestBlock(color); BlockType result = parent.getNearestBlock(color);
if (result != null) { if (result != null) {
colorBlockMap.put((int) color, result); colorBlockMap.put(color, result);
} }
return result; return result;
} }

Datei anzeigen

@ -14,9 +14,9 @@ public class RandomTextureUtil extends CachedTextureUtil {
} }
private int index; private int index;
private int[] biomeMixBuffer = new int[3]; private final int[] biomeMixBuffer = new int[3];
private Int2ObjectOpenHashMap<Integer> offsets = new Int2ObjectOpenHashMap<>(); private final Int2ObjectOpenHashMap<Integer> offsets = new Int2ObjectOpenHashMap<>();
private Int2ObjectOpenHashMap<int[]> biomeMixes = new Int2ObjectOpenHashMap<>(); private final Int2ObjectOpenHashMap<int[]> biomeMixes = new Int2ObjectOpenHashMap<>();
protected int addRandomColor(int c1, int c2) { protected int addRandomColor(int c1, int c2) {
int red1 = (c1 >> 16) & 0xFF; int red1 = (c1 >> 16) & 0xFF;
@ -81,7 +81,7 @@ public class RandomTextureUtil extends CachedTextureUtil {
@Override @Override
public BlockType getNearestBlock(int color) { public BlockType getNearestBlock(int color) {
int offsetColor = offsets.getOrDefault((Object) color, 0); int offsetColor = offsets.getOrDefault((Object)color, 0);
if (offsetColor != 0) { if (offsetColor != 0) {
offsetColor = addRandomColor(color, offsetColor); offsetColor = addRandomColor(color, offsetColor);
} else { } else {

Datei anzeigen

@ -1,11 +1,6 @@
package com.boydti.fawe.util; 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.AccessibleObject;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -24,80 +19,11 @@ public class ReflectionUtils {
} }
public static <T extends Enum<?>> T addEnum(Class<T> enumType, String enumName) { public static <T extends Enum<?>> T addEnum(Class<T> enumType, String enumName) {
try { return ReflectionUtils9.addEnum(enumType, enumName);
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) public static void setAccessibleNonFinal(Field field)
throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
// let's make the field accessible // let's make the field accessible
field.setAccessible(true); field.setAccessible(true);
@ -134,12 +60,7 @@ public class ReflectionUtils {
throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
setAccessibleNonFinal(field); setAccessibleNonFinal(field);
try { field.set(target,value);
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) private static void blankField(Class<?> enumClass, String fieldName)

Datei anzeigen

@ -141,6 +141,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -865,7 +866,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
@Override @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++; this.changes++;
try { try {
return this.getExtent().setBlock(x, y, z, block); 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 VirtualWorld virtual;
private transient BlockVector3 cuiTemporaryBlock; private transient BlockVector3 cuiTemporaryBlock;
@SuppressWarnings("unused")
private transient EditSession.ReorderMode reorderMode = EditSession.ReorderMode.MULTI_STAGE;
private transient List<Countable<BlockState>> lastDistribution; private transient List<Countable<BlockState>> lastDistribution;
private transient World worldOverride; private transient World worldOverride;
private transient boolean tickingWatchdog = false; private transient boolean tickingWatchdog = false;
@ -395,6 +397,9 @@ public class LocalSession implements TextureHolder {
public void remember(EditSession editSession) { public void remember(EditSession editSession) {
checkNotNull(editSession); checkNotNull(editSession);
// Don't store anything if no changes were made
if (editSession.size() == 0) return;
Player player = editSession.getPlayer(); Player player = editSession.getPlayer();
int limit = player == null ? Integer.MAX_VALUE : player.getLimit().MAX_HISTORY; int limit = player == null ? Integer.MAX_VALUE : player.getLimit().MAX_HISTORY;
remember(editSession, true, limit); 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 @Nullable
public Snapshot getSnapshot() { public Snapshot getSnapshot() {

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -115,11 +115,11 @@ public class ClipboardCommands {
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public void copy(Actor actor, LocalSession session, EditSession editSession, public void copy(Actor actor, LocalSession session, EditSession editSession,
@Selection Region region, @Selection Region region,
@Switch(name = 'e', desc = "Skip copy entities") @Switch(name = 'e', desc = "Also copy entities")
boolean skipEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes, 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 { Mask mask) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
@ -134,11 +134,9 @@ public class ClipboardCommands {
Clipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId()); Clipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId());
session.setClipboard(new ClipboardHolder(clipboard));
clipboard.setOrigin(session.getPlacementPosition(actor)); clipboard.setOrigin(session.getPlacementPosition(actor));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setCopyingEntities(!skipEntities); copy.setCopyingEntities(copyEntities);
copy.setCopyingBiomes(copyBiomes); copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask(); Mask sourceMask = editSession.getSourceMask();
@ -147,15 +145,12 @@ public class ClipboardCommands {
copy.setSourceMask(sourceMask); copy.setSourceMask(sourceMask);
editSession.setSourceMask(null); editSession.setSourceMask(null);
} }
if (mask != null && mask != Masks.alwaysTrue()) { if (mask != null) {
copy.setSourceMask(mask); copy.setSourceMask(mask);
} }
Operations.completeLegacy(copy); Operations.completeLegacy(copy);
if (!actor.hasPermission("fawe.tips")) { session.setClipboard(new ClipboardHolder(clipboard));
System.out.println("TODO FIXME tips"); copy.getStatusMessages().forEach(actor::print);
// 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);
}
copy.getStatusMessages().forEach(actor::print);
} }
@Command( @Command(
@ -167,8 +162,6 @@ public class ClipboardCommands {
@Selection Region region, @Selection Region region,
@Switch(name = 'e', desc = "Skip copy entities") @Switch(name = 'e', desc = "Skip copy entities")
boolean skipEntities, boolean skipEntities,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
Mask maskOpt,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes) throws WorldEditException { boolean copyBiomes) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
@ -184,10 +177,6 @@ public class ClipboardCommands {
lazyClipboard.setOrigin(session.getPlacementPosition(actor)); lazyClipboard.setOrigin(session.getPlacementPosition(actor));
session.setClipboard(new ClipboardHolder(lazyClipboard)); session.setClipboard(new ClipboardHolder(lazyClipboard));
actor.print(Caption.of("fawe.worldedit.copy.command.copy" , region.getArea())); 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( // @Command(
@ -234,11 +223,11 @@ public class ClipboardCommands {
@Selection Region region, @Selection Region region,
@Arg(desc = "Pattern to leave in place of the selection", def = "air") @Arg(desc = "Pattern to leave in place of the selection", def = "air")
Pattern leavePattern, Pattern leavePattern,
@Switch(name = 'e', desc = "Skip cut entities") @Switch(name = 'e', desc = "Also cut entities")
boolean skipEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected") @Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected")
boolean copyBiomes, 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 { Mask mask) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
@ -258,7 +247,7 @@ public class ClipboardCommands {
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setSourceFunction(new BlockReplace(editSession, leavePattern)); copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
copy.setCopyingEntities(!skipEntities); copy.setCopyingEntities(copyEntities);
copy.setRemovingEntities(true); copy.setRemovingEntities(true);
copy.setCopyingBiomes(copyBiomes); copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask(); Mask sourceMask = editSession.getSourceMask();
@ -442,7 +431,7 @@ public class ClipboardCommands {
ClipboardHolder holder = session.getClipboard(); ClipboardHolder holder = session.getClipboard();
if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) { 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; return;
} }
Clipboard clipboard = holder.getClipboard(); Clipboard clipboard = holder.getClipboard();
@ -473,10 +462,6 @@ public class ClipboardCommands {
session.setRegionSelector(world, selector); session.setRegionSelector(world, selector);
selector.learnChanges(); selector.learnChanges();
selector.explainRegionAdjust(actor, session); 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) { if (onlySelect) {
actor.printInfo(TranslatableComponent.of("worldedit.paste.selected")); actor.printInfo(TranslatableComponent.of("worldedit.paste.selected"));
@ -511,14 +496,18 @@ public class ClipboardCommands {
@Switch(name = 'o', desc = "Paste at the original position") @Switch(name = 'o', desc = "Paste at the original position")
boolean atOrigin, boolean atOrigin,
@Switch(name = 's', desc = "Select the region after pasting") @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(); ClipboardHolder holder = session.getClipboard();
final Clipboard clipboard = holder.getClipboard(); final Clipboard clipboard = holder.getClipboard();
final BlockVector3 origin = clipboard.getOrigin(); final BlockVector3 origin = clipboard.getOrigin();
final BlockVector3 to = atOrigin ? origin : session.getPlacementPosition(actor); final BlockVector3 to = atOrigin ? origin : session.getPlacementPosition(actor);
checkPaste(actor, editSession, to, holder, clipboard); checkPaste(actor, editSession, to, holder, clipboard);
clipboard.paste(editSession, to, !ignoreAirBlocks); clipboard.paste(editSession, to, !ignoreAirBlocks, pasteEntities, pasteBiomes);
Region region = clipboard.getRegion().clone(); Region region = clipboard.getRegion().clone();
if (selectPasted) { if (selectPasted) {
@ -539,7 +528,6 @@ public class ClipboardCommands {
@Command( @Command(
name = "/rotate", name = "/rotate",
aliases = {"/rt"},
desc = "Rotate the contents of the clipboard", desc = "Rotate the contents of the clipboard",
descFooter = "Non-destructively rotate the contents of the clipboard.\n" + 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. " + "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); transform = transform.rotateZ(-zRotate);
holder.setTransform(holder.getTransform().combine(transform)); holder.setTransform(holder.getTransform().combine(transform));
actor.printInfo(TranslatableComponent.of("worldedit.rotate.rotated")); 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( @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.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.RegionVisitor; 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.annotation.Selection;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
@ -182,14 +183,15 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.cylinder") @CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT) @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") @Arg(desc = "The pattern of blocks to generate")
Pattern pattern, Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The radii of the cylinder. 1st is N/S, 2nd is E/W") @Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The radii of the cylinder. 1st is N/S, 2nd is E/W")
BlockVector2 radii, @Radii(2)
@Arg(desc = "The height of the cylinder", def = "1") List<Double> radii,
@Arg(desc = "The height of the cylinder", def = "1")
int height) throws WorldEditException { int height) throws WorldEditException {
cyl(actor, session, editSession, pattern, radii, height, true); return cyl(actor, session, editSession, pattern, radii, height, true);
} }
@Command( @Command(
@ -198,19 +200,40 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.cylinder") @CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT) @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") @Arg(desc = "The pattern of blocks to generate")
Pattern pattern, 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")
@Arg(desc = "The height of the cylinder", def = "1") @Radii(2)
List<Double> radii,
@Arg(desc = "The height of the cylinder", def = "1")
int height, int height,
@Switch(name = 'h', desc = "Make a hollow cylinder") @Switch(name = 'h', desc = "Make a hollow cylinder")
boolean hollow) throws WorldEditException { boolean hollow) throws WorldEditException {
double max = Math.max(radius.getBlockX(), radius.getBlockZ()); final double radiusX, radiusZ;
worldEdit.checkMaxRadius(max); 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); 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))); actor.printInfo(TranslatableComponent.of("worldedit.cyl.created", TextComponent.of(affected)));
return affected;
} }
@Command( @Command(
@ -219,13 +242,15 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.sphere") @CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT) @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") @Arg(desc = "The pattern of blocks to generate")
Pattern pattern, 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") @Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
boolean raised) throws WorldEditException { boolean raised) throws WorldEditException {
sphere(actor, session, editSession, pattern, radii, raised, true); return sphere(actor, session, editSession, pattern, radii, raised, true);
} }
@Command( @Command(
@ -234,24 +259,47 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.sphere") @CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT) @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") @Arg(desc = "The pattern of blocks to generate")
Pattern pattern, Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W") @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") @Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
boolean raised, boolean raised,
@Switch(name = 'h', desc = "Make a hollow sphere") @Switch(name = 'h', desc = "Make a hollow sphere")
boolean hollow) throws WorldEditException { boolean hollow) throws WorldEditException {
double max = MathMan.max(radii.getBlockX(), radii.getBlockY(), radii.getBlockZ()); final double radiusX, radiusY, radiusZ;
worldEdit.checkMaxRadius(max); 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 pos = session.getPlacementPosition(actor);
BlockVector3 finalPos = raised ? pos.add(0, radii.getY(), 0) : pos; if (raised) {
int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow); pos = pos.add(0, (int) radiusY, 0);
}
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
if (actor instanceof Player) { if (actor instanceof Player) {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
actor.printInfo(TranslatableComponent.of("worldedit.sphere.created", TextComponent.of(affected))); actor.printInfo(TranslatableComponent.of("worldedit.sphere.created", TextComponent.of(affected)));
return affected;
} }
@Command( @Command(
@ -299,12 +347,12 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.pyramid") @CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT) @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") @Arg(desc = "The pattern of blocks to set")
Pattern pattern, Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The size of the pyramid") @Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The size of the pyramid")
int size) throws WorldEditException { int size) throws WorldEditException {
pyramid(actor, session, editSession, pattern, size, true); return pyramid(actor, session, editSession, pattern, size, true);
} }
@Command( @Command(
@ -313,20 +361,21 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.pyramid") @CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT) @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") @Arg(desc = "The pattern of blocks to set")
Pattern pattern, Pattern pattern,
@Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The size of the pyramid") @Confirm(Confirm.Processor.RADIUS) @Arg(desc = "The size of the pyramid")
int size, int size,
@Switch(name = 'h', desc = "Make a hollow pyramid") @Switch(name = 'h', desc = "Make a hollow pyramid")
boolean hollow) throws WorldEditException { boolean hollow) throws WorldEditException {
BlockVector3 pos = session.getPlacementPosition(actor);
worldEdit.checkMaxRadius(size); worldEdit.checkMaxRadius(size);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makePyramid(pos, pattern, size, !hollow); int affected = editSession.makePyramid(pos, pattern, size, !hollow);
if (actor instanceof Player) { if (actor instanceof Player) {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
actor.printInfo(TranslatableComponent.of("worldedit.pyramid.created", TextComponent.of(affected))); actor.printInfo(TranslatableComponent.of("worldedit.pyramid.created", TextComponent.of(affected)));
return affected;
} }
@Command( @Command(
@ -338,7 +387,7 @@ public class GenerationCommands {
@CommandPermissions("worldedit.generation.shape") @CommandPermissions("worldedit.generation.shape")
@Logging(ALL) @Logging(ALL)
@Confirm(Confirm.Processor.REGION) @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, @Selection Region region,
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern pattern, Pattern pattern,
@ -388,8 +437,10 @@ public class GenerationCommands {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
actor.printInfo(TranslatableComponent.of("worldedit.generate.created", TextComponent.of(affected))); actor.printInfo(TranslatableComponent.of("worldedit.generate.created", TextComponent.of(affected)));
return affected;
} catch (ExpressionException e) { } catch (ExpressionException e) {
actor.printError(TextComponent.of(e.getMessage())); actor.printError(TextComponent.of(e.getMessage()));
return 0;
} }
} }
@ -404,7 +455,7 @@ public class GenerationCommands {
@CommandPermissions("worldedit.generation.shape.biome") @CommandPermissions("worldedit.generation.shape.biome")
@Logging(ALL) @Logging(ALL)
@Confirm(Confirm.Processor.REGION) @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, @Selection Region region,
@Arg(desc = "The biome type to set") @Arg(desc = "The biome type to set")
BiomeType target, BiomeType target,
@ -449,8 +500,10 @@ public class GenerationCommands {
try { try {
final int affected = editSession.makeBiomeShape(region, zero, unit1, target, String.join(" ", expression), hollow, session.getTimeout()); 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))); actor.printInfo(TranslatableComponent.of("worldedit.generatebiome.changed", TextComponent.of(affected)));
return affected;
} catch (ExpressionException e) { } catch (ExpressionException e) {
actor.printError(TextComponent.of(e.getMessage())); actor.printError(TextComponent.of(e.getMessage()));
return 0;
} }
} }

Datei anzeigen

@ -56,12 +56,12 @@ public class HistoryCommands {
} }
@Command( @Command(
name = "/undo", name = "undo",
aliases = { "/un", "/ud", "undo" }, aliases = { "/undo" },
desc = "Undoes the last action (from history)" desc = "Undoes the last action (from history)"
) )
@CommandPermissions({"worldedit.history.undo", "worldedit.history.undo.self"}) @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") @Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1")
int times, int times,
@Arg(name = "player", desc = "Undo this player's operations", def = "") @Arg(name = "player", desc = "Undo this player's operations", def = "")
@ -69,42 +69,41 @@ public class HistoryCommands {
times = Math.max(1, times); times = Math.max(1, times);
LocalSession undoSession = session; LocalSession undoSession = session;
if (session.hasFastMode()) { if (session.hasFastMode()) {
actor.print(TranslatableComponent.of("fawe.worldedit.history.command.undo.disabled")); player.print(TranslatableComponent.of("fawe.worldedit.history.command.undo.disabled"));
return; return;
} }
if (playerName != null) { if (playerName != null) {
actor.checkPermission("worldedit.history.undo.other"); player.checkPermission("worldedit.history.undo.other");
undoSession = worldEdit.getSessionManager().findByName(playerName); undoSession = worldEdit.getSessionManager().findByName(playerName);
if (undoSession == null) { 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; return;
} }
} }
int timesUndone = 0; int timesUndone = 0;
for (int i = 0; i < times; ++i) { for (int i = 0; i < times; ++i) {
BlockBag bag = actor instanceof Player ? undoSession.getBlockBag((Player) actor) : null; EditSession undone = undoSession.undo(undoSession.getBlockBag(player), player);
EditSession undone = undoSession.undo(bag, actor);
if (undone != null) { if (undone != null) {
timesUndone++; timesUndone++;
worldEdit.flushBlockBag(actor, undone); worldEdit.flushBlockBag(player, undone);
} else { } else {
break; break;
} }
} }
if (timesUndone > 0) { if (timesUndone > 0) {
actor.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone))); player.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
} else { } else {
actor.printError(TranslatableComponent.of("worldedit.undo.none")); player.printError(TranslatableComponent.of("worldedit.undo.none"));
} }
} }
@Command( @Command(
name = "/redo", name = "redo",
aliases = { "/do", "/rd", "redo" }, aliases = { "/redo" },
desc = "Redoes the last action (from history)" desc = "Redoes the last action (from history)"
) )
@CommandPermissions({"worldedit.history.redo", "worldedit.history.redo.self"}) @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") @Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1")
int times, int times,
@Arg(name = "player", desc = "Redo this player's operations", def = "") @Arg(name = "player", desc = "Redo this player's operations", def = "")
@ -112,28 +111,27 @@ public class HistoryCommands {
times = Math.max(1, times); times = Math.max(1, times);
LocalSession redoSession = session; LocalSession redoSession = session;
if (playerName != null) { if (playerName != null) {
actor.checkPermission("worldedit.history.redo.other"); player.checkPermission("worldedit.history.redo.other");
redoSession = worldEdit.getSessionManager().findByName(playerName); redoSession = worldEdit.getSessionManager().findByName(playerName);
if (redoSession == null) { 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; return;
} }
} }
int timesRedone = 0; int timesRedone = 0;
for (int i = 0; i < times; ++i) { for (int i = 0; i < times; ++i) {
BlockBag bag = actor instanceof Player ? redoSession.getBlockBag((Player) actor) : null; EditSession redone = redoSession.redo(redoSession.getBlockBag(player), player);
EditSession redone = redoSession.redo(bag, actor);
if (redone != null) { if (redone != null) {
timesRedone++; timesRedone++;
worldEdit.flushBlockBag(actor, redone); worldEdit.flushBlockBag(player, redone);
} else { } else {
break; break;
} }
} }
if (timesRedone > 0) { if (timesRedone > 0) {
actor.printInfo(TranslatableComponent.of("worldedit.redo.redone", TextComponent.of(timesRedone))); player.printInfo(TranslatableComponent.of("worldedit.redo.redone", TextComponent.of(timesRedone)));
} else { } 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( @Command(
name = "/line", name = "/line",
desc = "Draws a line segment between cuboid selection corners", desc = "Draws line segments between cuboid selection corners or convex polyhedral selection vertices",
descFooter = "Can only be used with a cuboid selection" descFooter = "Can only be used with a cuboid selection or a convex polyhedral selection"
) )
@CommandPermissions("worldedit.region.line") @CommandPermissions("worldedit.region.line")
@Logging(REGION) @Logging(REGION)
@ -490,8 +490,8 @@ public class RegionCommands {
boolean moveSelection, boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks") @Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks, boolean ignoreAirBlocks,
@Switch(name = 'e', desc = "Skip copy entities") @Switch(name = 'e', desc = "Also copy entities")
boolean skipEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes, boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
@ -509,7 +509,7 @@ public class RegionCommands {
combinedMask = mask; 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) { if (moveSelection) {
try { try {
@ -561,8 +561,8 @@ public class RegionCommands {
boolean moveSelection, boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks") @Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks, boolean ignoreAirBlocks,
@Switch(name = 'e', desc = "Skip entities") @Switch(name = 'e', desc = "Also copy entities")
boolean skipEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes, boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
@ -579,7 +579,7 @@ public class RegionCommands {
combinedMask = mask; combinedMask = mask;
} }
int affected = editSession.stackCuboidRegion(region, direction, count, !skipEntities, copyBiomes, combinedMask); int affected = editSession.stackCuboidRegion(region, direction, count, copyEntities, copyBiomes, combinedMask);
if (moveSelection) { if (moveSelection) {
try { try {
@ -695,7 +695,7 @@ public class RegionCommands {
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public int hollow(Actor actor, EditSession editSession, public int hollow(Actor actor, EditSession editSession,
@Selection Region region, @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, int thickness,
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air") @Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
Pattern pattern, Pattern pattern,

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -178,8 +178,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (free == 2) { if (free == 2) {
final BlockVector3 pos = mutablePos.setComponents(x, y - 2, z); final BlockVector3 pos = mutablePos.setComponents(x, y - 2, z);
final BlockState state = world.getBlock(pos); final BlockState state = world.getBlock(pos);
setPosition(new Location(world, setPosition(Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5));
Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5)));
return; return;
} }
@ -198,8 +197,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
final BlockVector3 pos = BlockVector3.at(x, y, z); final BlockVector3 pos = BlockVector3.at(x, y, z);
final BlockState id = world.getBlock(pos); final BlockState id = world.getBlock(pos);
if (id.getBlockType().getMaterial().isMovementBlocker()) { if (id.getBlockType().getMaterial().isMovementBlocker()) {
setPosition(new Location(world, setPosition(Vector3.at(x + 0.5, y + +BlockTypeUtil.centralTopLimit(id), z + 0.5));
Vector3.at(x + 0.5, y + +BlockTypeUtil.centralTopLimit(id), z + 0.5)));
return; return;
} }
@ -274,7 +272,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
public boolean descendLevel() { public boolean descendLevel() {
final Location pos = getBlockLocation(); final Location pos = getBlockLocation();
final int x = pos.getBlockX(); 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 int z = pos.getBlockZ();
final Extent world = pos.getExtent(); final Extent world = pos.getExtent();
@ -472,22 +470,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
return getBlockTrace(range, false); 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 @Override
public Location getSolidBlockTrace(int range) { public Location getSolidBlockTrace(int range) {
@ -554,6 +536,22 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
return false; 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 @Override
public boolean passThroughForwardWall(int range) { public boolean passThroughForwardWall(int range) {
TargetBlock hitBlox = new TargetBlock(this, range, 0.2); TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
@ -619,7 +617,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public void checkPermission(String permission) throws AuthorizationException { public void checkPermission(String permission) throws AuthorizationException {
if (!hasPermission(permission)) { 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 com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.List; import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jetbrains.annotations.Range;
/** /**
* A base class for {@link Extent}s that merely passes extents onto another. * A base class for {@link Extent}s that merely passes extents onto another.
@ -183,7 +184,7 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
} }
@Override @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 { throws WorldEditException {
return extent.setBlock(x, y, z, block); 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); void setOrigin(BlockVector3 origin);
/** /**
* Returns true if the clipboard has biome data. This can be checked since {@link * Returns true if the clipboard has biome data. This can be checked since {@link Extent#getBiome(BlockVector2)}
* Extent#getBiome(BlockVector2)} strongly suggests returning {@link * strongly suggests returning {@link com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null}
* com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null} if biomes aren't * if biomes aren't present. However, it might not be desired to set areas to ocean if the clipboard is defaulting
* present. However, it might not be desired to set areas to ocean if the clipboard is * to ocean, instead of having biomes explicitly set.
* defaulting to ocean, instead of having biomes explicitly set.
* *
* @return true if the clipboard has biome data 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) { 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 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) // 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 relx = to.getBlockX() - origin.getBlockX();
final int rely = to.getBlockY() - origin.getBlockY(); final int rely = to.getBlockY() - origin.getBlockY();
@ -312,9 +314,11 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
BaseBlock block = pos.getFullBlock(this); BaseBlock block = pos.getFullBlock(this);
int xx = pos.getX() + relx; int xx = pos.getX() + relx;
int zz = pos.getZ() + relz; int zz = pos.getZ() + relz;
if (copyBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) { if (hasBiomes()) {
mpos2d.setComponents(xx, zz); if (pasteBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) {
extent.setBiome(mpos2d, Clipboard.this.getBiome(pos.toBlockVector2())); mpos2d.setComponents(xx, zz);
extent.setBiome(mpos2d, Clipboard.this.getBiome(pos.toBlockVector2()));
}
} }
if (!pasteAir && block.getBlockType().getMaterial().isAir()) { if (!pasteAir && block.getBlockType().getMaterial().isAir()) {
continue; continue;
@ -329,17 +333,19 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
final int entityOffsetY = to.getBlockY() - origin.getBlockY(); final int entityOffsetY = to.getBlockY() - origin.getBlockY();
final int entityOffsetZ = to.getBlockZ() - origin.getBlockZ(); final int entityOffsetZ = to.getBlockZ() - origin.getBlockZ();
// entities // entities
for (Entity entity : this.getEntities()) { if (pasteEntities) {
// skip players on pasting schematic for (Entity entity : this.getEntities()) {
if (entity.getState() != null && entity.getState().getType().getId() // skip players on pasting schematic
.equals("minecraft:player")) { if (entity.getState() != null && entity.getState().getType().getId()
continue; .equals("minecraft:player")) {
continue;
}
Location pos = entity.getLocation();
Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX,
pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(),
pos.getPitch());
extent.createEntity(newPos, entity.getState());
} }
Location pos = entity.getLocation();
Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX,
pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(),
pos.getPitch());
extent.createEntity(newPos, entity.getState());
} }
} }
} }

Datei anzeigen

@ -19,12 +19,12 @@
package com.sk89q.worldedit.regions; 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.Filter;
import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; 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.FaweLimit;
import com.boydti.fawe.object.extent.SingleRegionExtent; import com.boydti.fawe.object.extent.SingleRegionExtent;
import com.sk89q.worldedit.extent.Extent; 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.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -80,9 +79,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
BlockVector3 min = getMinimumPoint(); BlockVector3 min = getMinimumPoint();
BlockVector3 max = getMaximumPoint(); BlockVector3 max = getMaximumPoint();
return (max.getX() - min.getX() + 1) * return (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1) * (max.getZ() - min.getZ() + 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.BlockMaterial;
import com.sk89q.worldedit.world.registry.BlockRegistry; import com.sk89q.worldedit.world.registry.BlockRegistry;
import com.sk89q.worldedit.world.registry.Registries; import com.sk89q.worldedit.world.registry.Registries;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -22,6 +21,7 @@ import java.util.List;
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 java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class BlockTypesCache { public class BlockTypesCache {
@ -127,10 +127,7 @@ public class BlockTypesCache {
int[] result = new int[maxStateId]; int[] result = new int[maxStateId];
Arrays.fill(result, -1); Arrays.fill(result, -1);
int[] state = new int[props.size()]; int[] state = new int[props.size()];
int[] sizes = new int[props.size()]; int[] sizes = props.stream().mapToInt(prop -> prop.getValues().size()).toArray();
for (int i = 0; i < props.size(); i++) {
sizes[i] = props.get(i).getValues().size();
}
int index = 0; int index = 0;
outer: outer:
while (true) { while (true) {
@ -177,7 +174,11 @@ public class BlockTypesCache {
Registries registries = platform.getRegistries(); Registries registries = platform.getRegistries();
BlockRegistry blockReg = registries.getBlockRegistry(); BlockRegistry blockReg = registries.getBlockRegistry();
Collection<String> blocks = blockReg.values(); 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; int size = blockMap.size() + 1;
Field[] idFields = BlockID.class.getDeclaredFields(); Field[] idFields = BlockID.class.getDeclaredFields();
@ -208,21 +209,22 @@ public class BlockTypesCache {
} }
} }
{ // Register new blocks // Register new blocks
int internalId = 1; int internalId = 1;
for (Map.Entry<String, String> entry : blockMap.entrySet()) { for (Map.Entry<String, String> entry : blockMap.entrySet()) {
String defaultState = entry.getValue(); String defaultState = entry.getValue();
// Skip already registered ids // Skip already registered ids
for (; values[internalId] != null; internalId++); while (values[internalId] != null) {
BlockType type = register(defaultState, internalId, stateList); internalId++;
values[internalId] = type;
} }
BlockType type = register(defaultState, internalId, stateList);
values[internalId] = type;
} }
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
if (values[i] == null) values[i] = values[0]; if (values[i] == null) values[i] = values[0];
} }
states = stateList.toArray(new BlockState[stateList.size()]); states = stateList.toArray(new BlockState[0]);
} catch (Throwable e) { } catch (Throwable e) {

Datei anzeigen

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