mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-13 14:58:35 +00:00
Updated a class, minor command tweaks, and formatting
This commit is contained in:
@ -45,13 +45,12 @@ import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An abstract implementation of both a {@link Actor} and a {@link Player}
|
||||
* that is intended for implementations of WorldEdit to use to wrap
|
||||
* players that make use of WorldEdit.
|
||||
* An abstract implementation of both a {@link Actor} and a {@link Player} that is intended for
|
||||
* implementations of WorldEdit to use to wrap players that make use of WorldEdit.
|
||||
*/
|
||||
public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
@ -94,10 +93,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
public boolean isHoldingPickAxe() {
|
||||
ItemType item = getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
return item == ItemTypes.IRON_PICKAXE
|
||||
|| item == ItemTypes.WOODEN_PICKAXE
|
||||
|| item == ItemTypes.STONE_PICKAXE
|
||||
|| item == ItemTypes.DIAMOND_PICKAXE
|
||||
|| item == ItemTypes.GOLDEN_PICKAXE;
|
||||
|| item == ItemTypes.WOODEN_PICKAXE
|
||||
|| item == ItemTypes.STONE_PICKAXE
|
||||
|| item == ItemTypes.DIAMOND_PICKAXE
|
||||
|| item == ItemTypes.GOLDEN_PICKAXE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,7 +110,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
BlockVector3 mutablePos = MutableBlockVector3.ZERO;
|
||||
while (y <= world.getMaximumPoint().getBlockY() + 2) {
|
||||
if (!world.getBlock(mutablePos.setComponents(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (!world.getBlock(mutablePos.setComponents(x, y, z)).getBlockType().getMaterial()
|
||||
.isMovementBlocker()) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
@ -120,7 +120,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
if (free == 2) {
|
||||
final BlockVector3 pos = mutablePos.setComponents(x, y - 2, z);
|
||||
final BlockStateHolder state = world.getBlock(pos);
|
||||
setPosition(new Location(world, Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5)));
|
||||
setPosition(new Location(world,
|
||||
Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -139,7 +140,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
final BlockVector3 pos = BlockVector3.at(x, y, z);
|
||||
final BlockState id = world.getBlock(pos);
|
||||
if (id.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
setPosition(new Location(world, Vector3.at(x + 0.5, y + + BlockTypeUtil.centralTopLimit(id), z + 0.5)));
|
||||
setPosition(new Location(world,
|
||||
Vector3.at(x + 0.5, y + +BlockTypeUtil.centralTopLimit(id), z + 0.5)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -161,7 +163,9 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
final Extent world = pos.getExtent();
|
||||
|
||||
int maxY = world.getMaxY();
|
||||
if (y >= maxY) return false;
|
||||
if (y >= maxY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockMaterial initialMaterial = world.getBlock(BlockVector3.at(x, y, z)).getMaterial();
|
||||
|
||||
@ -172,8 +176,11 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
for (int level = y + 1; level <= maxY + 2; level++) {
|
||||
BlockState state;
|
||||
if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState();
|
||||
else state = world.getBlock(BlockVector3.at(x, level, z));
|
||||
if (level >= maxY) {
|
||||
state = BlockTypes.VOID_AIR.getDefaultState();
|
||||
} else {
|
||||
state = world.getBlock(BlockVector3.at(x, level, z));
|
||||
}
|
||||
BlockType type = state.getBlockType();
|
||||
BlockMaterial material = type.getMaterial();
|
||||
|
||||
@ -218,14 +225,19 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube();
|
||||
|
||||
int maxY = world.getMaxY();
|
||||
if (y <= 2) return false;
|
||||
if (y <= 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
double freeEnd = -1;
|
||||
double height = 1.85;
|
||||
for (int level = y + 1; level > 0; level--) {
|
||||
BlockState state;
|
||||
if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState();
|
||||
else state = world.getBlock(BlockVector3.at(x, level, z));
|
||||
if (level >= maxY) {
|
||||
state = BlockTypes.VOID_AIR.getDefaultState();
|
||||
} else {
|
||||
state = world.getBlock(BlockVector3.at(x, level, z));
|
||||
}
|
||||
BlockType type = state.getBlockType();
|
||||
BlockMaterial material = type.getMaterial();
|
||||
|
||||
@ -279,7 +291,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
while (y <= world.getMaximumPoint().getY()) {
|
||||
// Found a ceiling!
|
||||
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial()
|
||||
.isMovementBlocker()) {
|
||||
int platformY = Math.max(initialY, y - 3 - clearance);
|
||||
floatAt(x, platformY + 1, z, alwaysGlass);
|
||||
return true;
|
||||
@ -307,7 +320,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
final Extent world = getLocation().getExtent();
|
||||
|
||||
while (y <= world.getMaximumPoint().getY() + 2) {
|
||||
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial()
|
||||
.isMovementBlocker()) {
|
||||
break; // Hit something
|
||||
} else if (y > maxY + 1) {
|
||||
break;
|
||||
@ -326,7 +340,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
||||
try {
|
||||
BlockVector3 spot = BlockVector3.at(x, y - 1, z);
|
||||
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial()
|
||||
.isMovementBlocker()) {
|
||||
getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState());
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
@ -342,7 +357,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
@Override
|
||||
public Location getBlockOn() {
|
||||
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
|
||||
return getLocation()
|
||||
.setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -433,7 +449,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
boolean inFree = false;
|
||||
|
||||
while ((block = hitBlox.getNextBlock()) != null) {
|
||||
boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType().getMaterial().isMovementBlocker();
|
||||
boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType()
|
||||
.getMaterial().isMovementBlocker();
|
||||
|
||||
if (firstBlock) {
|
||||
firstBlock = false;
|
||||
|
@ -22,8 +22,6 @@
|
||||
package com.sk89q.worldedit.world.snapshot;
|
||||
|
||||
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.time.ZoneOffset;
|
||||
@ -33,6 +31,7 @@ import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A repository contains zero or more snapshots.
|
||||
@ -67,13 +66,13 @@ public class SnapshotRepository {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of snapshots in a directory. The newest snapshot is
|
||||
* near the top of the array.
|
||||
* Get a list of snapshots in a directory. The newest snapshot is near the top of the array.
|
||||
*
|
||||
* @param newestFirst true to get the newest first
|
||||
* @return a list of snapshots
|
||||
*/
|
||||
public List<Snapshot> getSnapshots(boolean newestFirst, String worldName) throws MissingWorldException {
|
||||
public List<Snapshot> getSnapshots(boolean newestFirst, String worldName)
|
||||
throws MissingWorldException {
|
||||
FilenameFilter filter = (dir, name) -> {
|
||||
File f = new File(dir, name);
|
||||
return isValidSnapshot(f);
|
||||
@ -117,7 +116,8 @@ public class SnapshotRepository {
|
||||
* @return a snapshot or null
|
||||
*/
|
||||
@Nullable
|
||||
public Snapshot getSnapshotAfter(ZonedDateTime date, String world) throws MissingWorldException {
|
||||
public Snapshot getSnapshotAfter(ZonedDateTime date, String world)
|
||||
throws MissingWorldException {
|
||||
List<Snapshot> snapshots = getSnapshots(true, world);
|
||||
Snapshot last = null;
|
||||
|
||||
@ -139,7 +139,8 @@ public class SnapshotRepository {
|
||||
* @return a snapshot or null
|
||||
*/
|
||||
@Nullable
|
||||
public Snapshot getSnapshotBefore(ZonedDateTime date, String world) throws MissingWorldException {
|
||||
public Snapshot getSnapshotBefore(ZonedDateTime date, String world)
|
||||
throws MissingWorldException {
|
||||
List<Snapshot> snapshots = getSnapshots(false, world);
|
||||
Snapshot last = null;
|
||||
|
||||
@ -205,7 +206,8 @@ public class SnapshotRepository {
|
||||
* @return whether it is a valid snapshot
|
||||
*/
|
||||
protected boolean isValidSnapshot(File file) {
|
||||
if (!file.getName().matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) {
|
||||
if (!file.getName()
|
||||
.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user