Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-19 09:20:08 +01:00
Move floatAt logic to AbstractPlayer, add isAllowedToFly and setFlying.
Dieser Commit ist enthalten in:
Ursprung
8545417b3a
Commit
2cc6a367c6
@ -185,14 +185,13 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
public boolean isAllowedToFly() {
|
||||||
if (alwaysGlass || !player.getAllowFlight()) {
|
return player.getAllowFlight();
|
||||||
super.floatAt(x, y, z, alwaysGlass);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
|
@Override
|
||||||
player.setFlying(true);
|
public void setFlying(boolean flying) {
|
||||||
|
player.setFlying(flying);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -187,6 +187,24 @@ public interface Player extends Entity, Actor {
|
|||||||
*/
|
*/
|
||||||
void floatAt(int x, int y, int z, boolean alwaysGlass);
|
void floatAt(int x, int y, int z, boolean alwaysGlass);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the player is allowed to fly.
|
||||||
|
*
|
||||||
|
* @return true if allowed flight
|
||||||
|
*/
|
||||||
|
default boolean isAllowedToFly() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the player is currently flying.
|
||||||
|
*
|
||||||
|
* @param flying true to fly
|
||||||
|
*/
|
||||||
|
default void setFlying(boolean flying) {
|
||||||
|
throw new UnsupportedOperationException("setFlying unimplemented but isAllowedToFly was true (or unchecked)");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the point of the block that is being stood in.
|
* Get the point of the block that is being stood in.
|
||||||
*
|
*
|
||||||
|
@ -313,13 +313,17 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
||||||
BlockVector3 spot = BlockVector3.at(x, y - 1, z);
|
if (alwaysGlass || !isAllowedToFly()) {
|
||||||
final World world = (World) getLocation().getExtent();
|
BlockVector3 spot = BlockVector3.at(x, y - 1, z);
|
||||||
if (!world.getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
|
final World world = getWorld();
|
||||||
try (EditSession session = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 1, this)) {
|
if (!world.getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
session.setBlock(spot, BlockTypes.GLASS.getDefaultState());
|
try (EditSession session = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 1, this)) {
|
||||||
} catch (MaxChangedBlocksException ignored) {
|
session.setBlock(spot, BlockTypes.GLASS.getDefaultState());
|
||||||
|
} catch (MaxChangedBlocksException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setFlying(true);
|
||||||
}
|
}
|
||||||
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
|
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
|
||||||
}
|
}
|
||||||
|
@ -189,15 +189,14 @@ public class FabricPlayer extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
public boolean isAllowedToFly() {
|
||||||
if (alwaysGlass || !player.abilities.allowFlying) {
|
return player.abilities.allowFlying;
|
||||||
super.floatAt(x, y, z, alwaysGlass);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
|
@Override
|
||||||
if (!player.abilities.flying) {
|
public void setFlying(boolean flying) {
|
||||||
player.abilities.flying = true;
|
if (player.abilities.flying != flying) {
|
||||||
|
player.abilities.flying = flying;
|
||||||
player.sendAbilitiesUpdate();
|
player.sendAbilitiesUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,15 +190,14 @@ public class ForgePlayer extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
public boolean isAllowedToFly() {
|
||||||
if (alwaysGlass || !player.abilities.allowFlying) {
|
return player.abilities.allowFlying;
|
||||||
super.floatAt(x, y, z, alwaysGlass);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
|
@Override
|
||||||
if (!player.abilities.isFlying) {
|
public void setFlying(boolean flying) {
|
||||||
player.abilities.isFlying = true;
|
if (player.abilities.isFlying != flying) {
|
||||||
|
player.abilities.isFlying = flying;
|
||||||
player.sendPlayerAbilities();
|
player.sendPlayerAbilities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,14 +204,13 @@ public class SpongePlayer extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
public boolean isAllowedToFly() {
|
||||||
if (alwaysGlass || !player.get(Keys.CAN_FLY).orElse(false)) {
|
return player.get(Keys.CAN_FLY).orElse(super.isAllowedToFly());
|
||||||
super.floatAt(x, y, z, alwaysGlass);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
|
@Override
|
||||||
player.offer(Keys.IS_FLYING, true);
|
public void setFlying(boolean flying) {
|
||||||
|
player.offer(Keys.IS_FLYING, flying);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren