Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 18:40:05 +01:00
Code quality improvements.
Dieser Commit ist enthalten in:
Ursprung
886b2ab720
Commit
661484f858
@ -264,7 +264,7 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
current.put(pt.toBlockVector(), block);
|
current.put(blockPt, block);
|
||||||
|
|
||||||
return smartSetBlock(pt, block);
|
return smartSetBlock(pt, block);
|
||||||
}
|
}
|
||||||
|
@ -266,17 +266,17 @@ public abstract class LocalPlayer {
|
|||||||
/**
|
/**
|
||||||
* Just go up.
|
* Just go up.
|
||||||
*
|
*
|
||||||
* @param distance
|
* @param distance How far up to teleport
|
||||||
* @return whether the player was moved
|
* @return whether the player was moved
|
||||||
*/
|
*/
|
||||||
public boolean ascendUpwards(int distance) {
|
public boolean ascendUpwards(int distance) {
|
||||||
Vector pos = getBlockIn();
|
final Vector pos = getBlockIn();
|
||||||
int x = pos.getBlockX();
|
final int x = pos.getBlockX();
|
||||||
int initialY = Math.max(0, pos.getBlockY());
|
final int initialY = Math.max(0, pos.getBlockY());
|
||||||
int y = Math.max(0, pos.getBlockY() + 1);
|
int y = Math.max(0, pos.getBlockY() + 1);
|
||||||
int z = pos.getBlockZ();
|
final int z = pos.getBlockZ();
|
||||||
int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
|
final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
|
||||||
LocalWorld world = getPosition().getWorld();
|
final LocalWorld world = getPosition().getWorld();
|
||||||
|
|
||||||
while (y <= world.getMaxY() + 2) {
|
while (y <= world.getMaxY() + 2) {
|
||||||
if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
|
if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
|
||||||
|
@ -108,7 +108,7 @@ public class RegionCommands {
|
|||||||
to = we.getBlockPattern(player, args.getString(1));
|
to = we.getBlockPattern(player, args.getString(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
int affected = 0;
|
final int affected;
|
||||||
if (to instanceof SingleBlockPattern) {
|
if (to instanceof SingleBlockPattern) {
|
||||||
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from,
|
affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from,
|
||||||
((SingleBlockPattern) to).getBlock());
|
((SingleBlockPattern) to).getBlock());
|
||||||
|
@ -11,8 +11,7 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
|
|
||||||
public class BiomeTypeMask implements Mask {
|
public class BiomeTypeMask implements Mask {
|
||||||
|
private final Set<BiomeType> biomes;
|
||||||
private Set<BiomeType> biomes;
|
|
||||||
|
|
||||||
public BiomeTypeMask() {
|
public BiomeTypeMask() {
|
||||||
this(new HashSet<BiomeType>());
|
this(new HashSet<BiomeType>());
|
||||||
@ -30,8 +29,8 @@ public class BiomeTypeMask implements Mask {
|
|||||||
return biomes.contains(biome);
|
return biomes.contains(biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(EditSession editSession, Vector pos) {
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
return matches2D(editSession, pos.toVector2D());
|
return matches2D(editSession, pos.toVector2D());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,7 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
|
||||||
public class BlockMask implements Mask {
|
public class BlockMask implements Mask {
|
||||||
|
private final Set<BaseBlock> blocks;
|
||||||
protected Set<BaseBlock> blocks;
|
|
||||||
|
|
||||||
public BlockMask() {
|
public BlockMask() {
|
||||||
blocks = new HashSet<BaseBlock>();
|
blocks = new HashSet<BaseBlock>();
|
||||||
@ -38,6 +37,7 @@ public class BlockMask implements Mask {
|
|||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(EditSession editSession, Vector pos) {
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
BaseBlock block = editSession.getBlock(pos);
|
BaseBlock block = editSession.getBlock(pos);
|
||||||
return blocks.contains(block)
|
return blocks.contains(block)
|
||||||
|
@ -30,7 +30,6 @@ import com.sk89q.worldedit.blocks.BaseBlock;
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class BlockTypeMask extends BlockMask {
|
public class BlockTypeMask extends BlockMask {
|
||||||
|
|
||||||
public BlockTypeMask() {
|
public BlockTypeMask() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,7 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
public class CombinedMask implements Mask {
|
public class CombinedMask implements Mask {
|
||||||
|
private final List<Mask> masks = new ArrayList<Mask>();
|
||||||
private List<Mask> masks = new ArrayList<Mask>();
|
|
||||||
|
|
||||||
public CombinedMask() {
|
public CombinedMask() {
|
||||||
}
|
}
|
||||||
@ -53,12 +52,14 @@ public class CombinedMask implements Mask {
|
|||||||
return masks.contains(mask);
|
return masks.contains(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||||
for (Mask mask : masks) {
|
for (Mask mask : masks) {
|
||||||
mask.prepare(session, player, target);
|
mask.prepare(session, player, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(EditSession editSession, Vector pos) {
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
for (Mask mask : masks) {
|
for (Mask mask : masks) {
|
||||||
if (!mask.matches(editSession, pos)) {
|
if (!mask.matches(editSession, pos)) {
|
||||||
|
@ -8,9 +8,9 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
public class DynamicRegionMask implements Mask {
|
public class DynamicRegionMask implements Mask {
|
||||||
|
|
||||||
private Region region;
|
private Region region;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||||
try {
|
try {
|
||||||
region = session.getSelection(player.getWorld());
|
region = session.getSelection(player.getWorld());
|
||||||
|
@ -26,10 +26,10 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
|
||||||
public class ExistingBlockMask implements Mask {
|
public class ExistingBlockMask implements Mask {
|
||||||
|
|
||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(EditSession editSession, Vector pos) {
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
return editSession.getBlockType(pos) != BlockID.AIR;
|
return editSession.getBlockType(pos) != BlockID.AIR;
|
||||||
}
|
}
|
||||||
|
@ -51,5 +51,4 @@ public class InvertedBlockTypeMask extends BlockTypeMask {
|
|||||||
public boolean matches(EditSession editSession, Vector pos) {
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
return !super.matches(editSession, pos);
|
return !super.matches(editSession, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,7 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
public class InvertedMask implements Mask {
|
public class InvertedMask implements Mask {
|
||||||
|
private final Mask mask;
|
||||||
private Mask mask;
|
|
||||||
|
|
||||||
public InvertedMask(Mask mask) {
|
public InvertedMask(Mask mask) {
|
||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
|
@ -39,7 +39,7 @@ public interface Mask {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param target target of the brush, null if not a brush mask
|
* @param target target of the brush, null if not a brush mask
|
||||||
*/
|
*/
|
||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target);
|
void prepare(LocalSession session, LocalPlayer player, Vector target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a block position, this method returns true if the block at
|
* Given a block position, this method returns true if the block at
|
||||||
@ -51,5 +51,5 @@ public interface Mask {
|
|||||||
* @param pos
|
* @param pos
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean matches(EditSession editSession, Vector pos);
|
boolean matches(EditSession editSession, Vector pos);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
public class RandomMask implements Mask {
|
public class RandomMask implements Mask {
|
||||||
|
|
||||||
private final double ratio;
|
private final double ratio;
|
||||||
|
|
||||||
public RandomMask(double ratio) {
|
public RandomMask(double ratio) {
|
||||||
|
@ -26,8 +26,7 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
public class RegionMask implements Mask {
|
public class RegionMask implements Mask {
|
||||||
|
private final Region region;
|
||||||
private Region region;
|
|
||||||
|
|
||||||
public RegionMask(Region region) {
|
public RegionMask(Region region) {
|
||||||
this.region = region.clone();
|
this.region = region.clone();
|
||||||
@ -36,8 +35,8 @@ public class RegionMask implements Mask {
|
|||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(EditSession editSession, Vector pos) {
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
return region.contains(pos);
|
return region.contains(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,8 @@ import com.sk89q.worldedit.Vector;
|
|||||||
* @author 1337
|
* @author 1337
|
||||||
*/
|
*/
|
||||||
public class UnderOverlayMask implements Mask {
|
public class UnderOverlayMask implements Mask {
|
||||||
|
private final int yMod;
|
||||||
private int yMod;
|
private Mask mask; // TODO: Make this final and remove the deprecated classes
|
||||||
private Mask mask;
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public UnderOverlayMask(Set<Integer> ids, boolean overlay) {
|
public UnderOverlayMask(Set<Integer> ids, boolean overlay) {
|
||||||
@ -57,10 +56,12 @@ public class UnderOverlayMask implements Mask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||||
mask.prepare(session, player, target);
|
mask.prepare(session, player, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(EditSession editSession, Vector pos) {
|
public boolean matches(EditSession editSession, Vector pos) {
|
||||||
return mask.matches(editSession, pos.add(0, yMod, 0));
|
return mask.matches(editSession, pos.add(0, yMod, 0));
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren