mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 03:16:41 +00:00
More upstream compatibility fixes
This commit is contained in:
@ -191,7 +191,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.fill")
|
||||
@Logging(PLACEMENT)
|
||||
public int fill(Player player, LocalSession session, EditSession editSession,
|
||||
public int fill(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The blocks to fill with")
|
||||
Pattern pattern,
|
||||
@Range(min=1) @Arg(desc = "The radius to fill in")
|
||||
@ -204,9 +204,9 @@ public class UtilityCommands {
|
||||
we.checkMaxRadius(radius);
|
||||
depth = Math.max(1, depth);
|
||||
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
BlockVector3 pos = session.getPlacementPosition(actor);
|
||||
int affected = editSession.fillDirection(pos, pattern, radius, depth, direction);
|
||||
player.print(affected + " block(s) have been created.");
|
||||
actor.print(affected + " block(s) have been created.");
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.fill.recursive")
|
||||
@Logging(PLACEMENT)
|
||||
public int fillr(Player player, LocalSession session, EditSession editSession,
|
||||
public int fillr(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The blocks to fill with")
|
||||
Pattern pattern,
|
||||
@Range(min=1) @Arg(desc = "The radius to fill in")
|
||||
@ -300,9 +300,9 @@ public class UtilityCommands {
|
||||
depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth);
|
||||
we.checkMaxRadius(radius);
|
||||
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
BlockVector3 pos = session.getPlacementPosition(actor);
|
||||
int affected = editSession.fillXZ(pos, pattern, radius, depth, true);
|
||||
player.print(affected + " block(s) have been created.");
|
||||
actor.print(affected + " block(s) have been created.");
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.drain")
|
||||
@Logging(PLACEMENT)
|
||||
public int drain(Player player, LocalSession session, EditSession editSession,
|
||||
public int drain(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Range(min=0) @Arg(desc = "The radius to drain")
|
||||
Expression radiusExp,
|
||||
@Switch(name = 'w', desc = "Also un-waterlog blocks")
|
||||
@ -321,8 +321,8 @@ public class UtilityCommands {
|
||||
radius = Math.max(0, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
int affected = editSession.drainArea(
|
||||
session.getPlacementPosition(player), radius, waterlogged);
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
session.getPlacementPosition(actor), radius, waterlogged);
|
||||
actor.print(affected + " block(s) have been changed.");
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -333,14 +333,14 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.fixlava")
|
||||
@Logging(PLACEMENT)
|
||||
public int fixLava(Player player, LocalSession session, EditSession editSession,
|
||||
public int fixLava(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Range(min=0) @Arg(desc = "The radius to fix in")
|
||||
Expression radiusExp) throws WorldEditException, EvaluationException {
|
||||
double radius = radiusExp.evaluate();
|
||||
radius = Math.max(0, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.LAVA);
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.LAVA);
|
||||
actor.print(affected + " block(s) have been changed.");
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -351,14 +351,14 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.fixwater")
|
||||
@Logging(PLACEMENT)
|
||||
public int fixWater(Player player, LocalSession session, EditSession editSession,
|
||||
public int fixWater(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Range(min=0) @Arg(desc = "The radius to fix in")
|
||||
Expression radiusExp) throws WorldEditException, EvaluationException {
|
||||
double radius = radiusExp.evaluate();
|
||||
radius = Math.max(0, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.WATER);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.WATER);
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -369,17 +369,16 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.removeabove")
|
||||
@Logging(PLACEMENT)
|
||||
public int removeAbove(Player player, LocalSession session, EditSession editSession,
|
||||
public int removeAbove(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
@Range(min=1) @Arg(name = "size", desc = "The apothem of the square to remove from", def = "1")
|
||||
int sizeOpt,
|
||||
int size,
|
||||
@Arg(desc = "The maximum height above you to remove from", def = "")
|
||||
Integer height) throws WorldEditException {
|
||||
sizeOpt = Math.max(1, sizeOpt);
|
||||
we.checkMaxRadius(sizeOpt);
|
||||
World world = player.getWorld();
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
|
||||
int affected = editSession.removeAbove(session.getPlacementPosition(player), sizeOpt, height);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
int affected = editSession.removeAbove(session.getPlacementPosition(actor), size, height);
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -390,18 +389,17 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.removebelow")
|
||||
@Logging(PLACEMENT)
|
||||
public int removeBelow(Player player, LocalSession session, EditSession editSession,
|
||||
public int removeBelow(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
@Arg(name = "size", desc = "The apothem of the square to remove from", def = "1")
|
||||
int sizeOpt,
|
||||
int size,
|
||||
@Arg(desc = "The maximum height below you to remove from", def = "")
|
||||
Integer height) throws WorldEditException {
|
||||
sizeOpt = Math.max(1, sizeOpt);
|
||||
we.checkMaxRadius(sizeOpt);
|
||||
World world = player.getWorld();
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
|
||||
|
||||
int affected = editSession.removeBelow(session.getPlacementPosition(player), sizeOpt, height);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
int affected = editSession.removeBelow(session.getPlacementPosition(actor), size, height);
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -412,7 +410,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.removenear")
|
||||
@Logging(PLACEMENT)
|
||||
public int removeNear(Player player, LocalSession session, EditSession editSession,
|
||||
public int removeNear(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The mask of blocks to remove")
|
||||
Mask mask,
|
||||
@Range(min=1) @Arg(desc = "The radius of the square to remove from", def = "50")
|
||||
@ -420,8 +418,8 @@ public class UtilityCommands {
|
||||
radius = Math.max(1, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(player), mask, radius);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, radius);
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -432,7 +430,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.replacenear")
|
||||
@Logging(PLACEMENT)
|
||||
public int replaceNear(Player player, LocalSession session, EditSession editSession,
|
||||
public int replaceNear(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
@Range(min=1) @Arg(desc = "The radius of the square to remove in")
|
||||
int radius,
|
||||
@Arg(desc = "The mask matching blocks to remove", def = "")
|
||||
@ -442,17 +440,17 @@ public class UtilityCommands {
|
||||
radius = Math.max(1, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
|
||||
BlockVector3 base = session.getPlacementPosition(player);
|
||||
BlockVector3 base = session.getPlacementPosition(actor);
|
||||
BlockVector3 min = base.subtract(radius, radius, radius);
|
||||
BlockVector3 max = base.add(radius, radius, radius);
|
||||
Region region = new CuboidRegion(player.getWorld(), min, max);
|
||||
Region region = new CuboidRegion(world, min, max);
|
||||
|
||||
if (from == null) {
|
||||
from = new ExistingBlockMask(editSession);
|
||||
}
|
||||
|
||||
int affected = editSession.replaceBlocks(region, from, to);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -463,14 +461,14 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.snow")
|
||||
@Logging(PLACEMENT)
|
||||
public int snow(Player player, LocalSession session, EditSession editSession,
|
||||
public int snow(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Range(min=1) @Arg(desc = "The radius of the circle to snow in", def = "10")
|
||||
double sizeOpt) throws WorldEditException {
|
||||
sizeOpt = Math.max(1, sizeOpt);
|
||||
we.checkMaxRadius(sizeOpt);
|
||||
double size) throws WorldEditException {
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.simulateSnow(session.getPlacementPosition(player), sizeOpt);
|
||||
player.print(affected + " surface(s) covered. Let it snow~");
|
||||
int affected = editSession.simulateSnow(session.getPlacementPosition(actor), size);
|
||||
actor.print(affected + " surface(s) covered. Let it snow~");
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -481,14 +479,14 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.thaw")
|
||||
@Logging(PLACEMENT)
|
||||
public int thaw(Player player, LocalSession session, EditSession editSession,
|
||||
public int thaw(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Range(min=1) @Arg(desc = "The radius of the circle to thaw in", def = "10")
|
||||
double sizeOpt) throws WorldEditException {
|
||||
sizeOpt = Math.max(1, sizeOpt);
|
||||
we.checkMaxRadius(sizeOpt);
|
||||
double size) throws WorldEditException {
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.thaw(session.getPlacementPosition(player), sizeOpt);
|
||||
player.print(affected + " surface(s) thawed.");
|
||||
int affected = editSession.thaw(session.getPlacementPosition(actor), size);
|
||||
actor.print(affected + " surface(s) thawed.");
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -499,17 +497,17 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.green")
|
||||
@Logging(PLACEMENT)
|
||||
public int green(Player player, LocalSession session, EditSession editSession,
|
||||
public int green(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Range(min=1) @Arg(desc = "The radius of the circle to convert in", def = "10")
|
||||
double sizeOpt,
|
||||
double size,
|
||||
@Switch(name = 'f', desc = "Also convert coarse dirt")
|
||||
boolean convertCoarse) throws WorldEditException {
|
||||
sizeOpt = Math.max(1, sizeOpt);
|
||||
we.checkMaxRadius(sizeOpt);
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
final boolean onlyNormalDirt = !convertCoarse;
|
||||
|
||||
final int affected = editSession.green(session.getPlacementPosition(player), sizeOpt, onlyNormalDirt);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
final int affected = editSession.green(session.getPlacementPosition(actor), size, onlyNormalDirt);
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -520,7 +518,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.extinguish")
|
||||
@Logging(PLACEMENT)
|
||||
public void extinguish(Player player, LocalSession session, EditSession editSession,
|
||||
public void extinguish(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Range(min=1) @Arg(desc = "The radius of the square to remove in", def = "")
|
||||
Integer radius) throws WorldEditException {
|
||||
|
||||
@ -531,8 +529,8 @@ public class UtilityCommands {
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE);
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(player), mask, size);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, size);
|
||||
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -561,7 +559,6 @@ public class UtilityCommands {
|
||||
@Switch(name = 'r', desc = "Also destroy armor stands")
|
||||
boolean killArmorStands) throws WorldEditException {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
Player player = actor instanceof Player ? (Player) actor : null;
|
||||
|
||||
if (radius == null) {
|
||||
radius = config.butcherDefaultRadius;
|
||||
@ -587,7 +584,7 @@ public class UtilityCommands {
|
||||
flags.or(CreatureButcher.Flags.TAGGED, killWithName, "worldedit.butcher.tagged");
|
||||
flags.or(CreatureButcher.Flags.ARMOR_STAND, killArmorStands, "worldedit.butcher.armorstands");
|
||||
|
||||
int killed = killMatchingEntities(radius, player, flags::createFunction);
|
||||
int killed = killMatchingEntities(radius, actor, flags::createFunction);
|
||||
|
||||
actor.print("Killed " + killed + (killed != 1 ? " mobs" : " mob") + (radius < 0 ? "" : " in a radius of " + radius) + ".");
|
||||
|
||||
@ -606,43 +603,32 @@ public class UtilityCommands {
|
||||
EntityRemover remover,
|
||||
@Range(min=-1) @Arg(desc = "The radius of the cuboid to remove from")
|
||||
int radius) throws WorldEditException {
|
||||
Player player = actor instanceof Player ? (Player) actor : null;
|
||||
|
||||
if (radius < -1) {
|
||||
actor.printError("Use -1 to remove all entities in loaded chunks");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int removed = killMatchingEntities(radius, player, remover::createFunction);
|
||||
int removed = killMatchingEntities(radius, actor, remover::createFunction);
|
||||
|
||||
actor.print("Marked " + removed + (removed != 1 ? " entities" : " entity") + " for removal.");
|
||||
return removed;
|
||||
}
|
||||
|
||||
private int killMatchingEntities(Integer radius, Player player, Supplier<EntityFunction> func) throws IncompleteRegionException, MaxChangedBlocksException {
|
||||
private int killMatchingEntities(Integer radius, Actor actor, Supplier<EntityFunction> func) throws IncompleteRegionException, MaxChangedBlocksException {
|
||||
List<EntityVisitor> visitors = new ArrayList<>();
|
||||
LocalSession session = null;
|
||||
EditSession editSession = null;
|
||||
|
||||
if (player != null) {
|
||||
session = we.getSessionManager().get(player);
|
||||
BlockVector3 center = session.getPlacementPosition(player);
|
||||
editSession = session.createEditSession(player);
|
||||
List<? extends Entity> entities;
|
||||
if (radius >= 0) {
|
||||
CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius);
|
||||
entities = editSession.getEntities(region);
|
||||
} else {
|
||||
entities = editSession.getEntities();
|
||||
}
|
||||
visitors.add(new EntityVisitor(entities.iterator(), func.get()));
|
||||
LocalSession session = we.getSessionManager().get(actor);
|
||||
BlockVector3 center = session.getPlacementPosition(actor);
|
||||
EditSession editSession = session.createEditSession(actor);
|
||||
List<? extends Entity> entities;
|
||||
if (radius >= 0) {
|
||||
CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius);
|
||||
entities = editSession.getEntities(region);
|
||||
} else {
|
||||
Platform platform = we.getPlatformManager().queryCapability(Capability.WORLD_EDITING);
|
||||
for (World world : platform.getWorlds()) {
|
||||
List<? extends Entity> entities = world.getEntities();
|
||||
visitors.add(new EntityVisitor(entities.iterator(), func.get()));
|
||||
}
|
||||
entities = editSession.getEntities();
|
||||
}
|
||||
visitors.add(new EntityVisitor(entities.iterator(), func.get()));
|
||||
|
||||
int killed = 0;
|
||||
for (EntityVisitor visitor : visitors) {
|
||||
@ -650,12 +636,10 @@ public class UtilityCommands {
|
||||
killed += visitor.getAffected();
|
||||
}
|
||||
|
||||
BBC.KILL_SUCCESS.send(player, killed, radius);
|
||||
BBC.KILL_SUCCESS.send(actor, killed, radius);
|
||||
|
||||
if (editSession != null) {
|
||||
session.remember(editSession);
|
||||
editSession.flushSession();
|
||||
}
|
||||
session.remember(editSession);
|
||||
editSession.flushSession();
|
||||
return killed;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user