mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
reduce diff
This commit is contained in:
@ -50,7 +50,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
} catch (Throwable ignored) {
|
||||
log.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/");
|
||||
}
|
||||
if (Settings.PLATFORM.equalsIgnoreCase("bukkit")) {
|
||||
if (Settings.PLATFORM.toLowerCase().startsWith("bukkit")) {
|
||||
new FaweTrim();
|
||||
}
|
||||
if (MainCommand.getInstance().getCommand("generatebiome") == null) {
|
||||
|
@ -205,6 +205,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
return this.displayName;
|
||||
}
|
||||
}
|
||||
|
||||
private final World world;
|
||||
private final String worldName;
|
||||
private boolean wrapped;
|
||||
@ -438,7 +439,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @param limit the limit (>= 0) or -1 for no limit
|
||||
*/
|
||||
public void setBlockChangeLimit(int limit) {
|
||||
// Nothing
|
||||
this.limit.MAX_CHANGES = limit;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -907,7 +908,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block at the given coordiantes, subject to both history and block re-ordering.
|
||||
* Sets the block at a position, subject to both history and block re-ordering.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
@ -1095,7 +1096,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
if (direction.equals(BlockVector3.at(0, -1, 0))) {
|
||||
return fillXZ(origin, pattern, radius, depth, false);
|
||||
}
|
||||
final MaskIntersection mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this)));
|
||||
final Mask mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), Masks.negate(new ExistingBlockMask(EditSession.this)));
|
||||
|
||||
// Want to replace blocks
|
||||
final BlockReplace replace = new BlockReplace(EditSession.this, pattern);
|
||||
@ -1640,7 +1641,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
|
||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||
|
||||
// Around the origin in a 3×3 block
|
||||
// Around the origin in a 3x3 block
|
||||
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||
if (liquidMask.test(position)) {
|
||||
visitor.visit(position);
|
||||
@ -2213,6 +2214,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @return number of patches created
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makePumpkinPatches(BlockVector3 position, int apothem) throws MaxChangedBlocksException {
|
||||
return makePumpkinPatches(position, apothem, 0.02);
|
||||
}
|
||||
|
||||
public int makePumpkinPatches(BlockVector3 position, int apothem, double density) throws MaxChangedBlocksException {
|
||||
// We want to generate pumpkins
|
||||
GardenPatchGenerator generator = new GardenPatchGenerator(this);
|
||||
@ -2242,33 +2247,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeForest(BlockVector3 basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
|
||||
for (int x = basePosition.getBlockX() - size; x <= (basePosition.getBlockX() + size); ++x) {
|
||||
for (int z = basePosition.getBlockZ() - size; z <= (basePosition.getBlockZ() + size); ++z) {
|
||||
// Don't want to be in the ground
|
||||
if (!this.getBlockType(x, basePosition.getBlockY(), z).getMaterial().isAir()) {
|
||||
continue;
|
||||
}
|
||||
// The gods don't want a tree here
|
||||
if (ThreadLocalRandom.current().nextInt(65536) >= (density * 65536)) {
|
||||
continue;
|
||||
} // def 0.05
|
||||
this.changes++;
|
||||
for (int y = basePosition.getBlockY(); y >= (basePosition.getBlockY() - 10); --y) {
|
||||
BlockType type = getBlockType(x, y, z);
|
||||
switch (type.getInternalId()) {
|
||||
case BlockID.GRASS:
|
||||
case BlockID.DIRT:
|
||||
treeType.generate(this, BlockVector3.at(x, y + 1, z));
|
||||
this.changes++;
|
||||
break;
|
||||
case BlockID.SNOW:
|
||||
setBlock(BlockVector3.at(x, y, z), BlockTypes.AIR.getDefaultState());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.changes;
|
||||
return makeForest(CuboidRegion.fromCenter(basePosition, size), density, treeType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||
|
||||
@ -84,67 +85,69 @@ public abstract class LocalConfiguration {
|
||||
|
||||
protected String[] getDefaultDisallowedBlocks() {
|
||||
List<BlockType> blockTypes = Lists.newArrayList(
|
||||
// BlockTypes.OAK_SAPLING,
|
||||
// BlockTypes.JUNGLE_SAPLING,
|
||||
// BlockTypes.DARK_OAK_SAPLING,
|
||||
// BlockTypes.SPRUCE_SAPLING,
|
||||
// BlockTypes.BIRCH_SAPLING,
|
||||
// BlockTypes.ACACIA_SAPLING,
|
||||
// BlockTypes.BLACK_BED,
|
||||
// BlockTypes.BLUE_BED,
|
||||
// BlockTypes.BROWN_BED,
|
||||
// BlockTypes.CYAN_BED,
|
||||
// BlockTypes.GRAY_BED,
|
||||
// BlockTypes.GREEN_BED,
|
||||
// BlockTypes.LIGHT_BLUE_BED,
|
||||
// BlockTypes.LIGHT_GRAY_BED,
|
||||
// BlockTypes.LIME_BED,
|
||||
// BlockTypes.MAGENTA_BED,
|
||||
// BlockTypes.ORANGE_BED,
|
||||
// BlockTypes.PINK_BED,
|
||||
// BlockTypes.PURPLE_BED,
|
||||
// BlockTypes.RED_BED,
|
||||
// BlockTypes.WHITE_BED,
|
||||
// BlockTypes.YELLOW_BED,
|
||||
// BlockTypes.POWERED_RAIL,
|
||||
// BlockTypes.DETECTOR_RAIL,
|
||||
// BlockTypes.GRASS,
|
||||
// BlockTypes.DEAD_BUSH,
|
||||
// BlockTypes.MOVING_PISTON,
|
||||
// BlockTypes.PISTON_HEAD,
|
||||
// BlockTypes.SUNFLOWER,
|
||||
// BlockTypes.ROSE_BUSH,
|
||||
// BlockTypes.DANDELION,
|
||||
// BlockTypes.POPPY,
|
||||
// BlockTypes.BROWN_MUSHROOM,
|
||||
// BlockTypes.RED_MUSHROOM,
|
||||
// BlockTypes.TNT,
|
||||
// BlockTypes.TORCH,
|
||||
// BlockTypes.FIRE,
|
||||
// BlockTypes.REDSTONE_WIRE,
|
||||
// BlockTypes.WHEAT,
|
||||
// BlockTypes.POTATOES,
|
||||
// BlockTypes.CARROTS,
|
||||
// BlockTypes.MELON_STEM,
|
||||
// BlockTypes.PUMPKIN_STEM,
|
||||
// BlockTypes.BEETROOTS,
|
||||
// BlockTypes.RAIL,
|
||||
// BlockTypes.LEVER,
|
||||
// BlockTypes.REDSTONE_TORCH,
|
||||
// BlockTypes.REDSTONE_WALL_TORCH,
|
||||
// BlockTypes.REPEATER,
|
||||
// BlockTypes.COMPARATOR,
|
||||
// BlockTypes.STONE_BUTTON,
|
||||
// BlockTypes.BIRCH_BUTTON,
|
||||
// BlockTypes.ACACIA_BUTTON,
|
||||
// BlockTypes.DARK_OAK_BUTTON,
|
||||
// BlockTypes.JUNGLE_BUTTON,
|
||||
// BlockTypes.OAK_BUTTON,
|
||||
// BlockTypes.SPRUCE_BUTTON,
|
||||
// BlockTypes.CACTUS,
|
||||
// BlockTypes.SUGAR_CANE,
|
||||
// // ores and stuff
|
||||
// BlockTypes.BEDROCK
|
||||
/*
|
||||
BlockTypes.OAK_SAPLING,
|
||||
BlockTypes.JUNGLE_SAPLING,
|
||||
BlockTypes.DARK_OAK_SAPLING,
|
||||
BlockTypes.SPRUCE_SAPLING,
|
||||
BlockTypes.BIRCH_SAPLING,
|
||||
BlockTypes.ACACIA_SAPLING,
|
||||
BlockTypes.BLACK_BED,
|
||||
BlockTypes.BLUE_BED,
|
||||
BlockTypes.BROWN_BED,
|
||||
BlockTypes.CYAN_BED,
|
||||
BlockTypes.GRAY_BED,
|
||||
BlockTypes.GREEN_BED,
|
||||
BlockTypes.LIGHT_BLUE_BED,
|
||||
BlockTypes.LIGHT_GRAY_BED,
|
||||
BlockTypes.LIME_BED,
|
||||
BlockTypes.MAGENTA_BED,
|
||||
BlockTypes.ORANGE_BED,
|
||||
BlockTypes.PINK_BED,
|
||||
BlockTypes.PURPLE_BED,
|
||||
BlockTypes.RED_BED,
|
||||
BlockTypes.WHITE_BED,
|
||||
BlockTypes.YELLOW_BED,
|
||||
BlockTypes.POWERED_RAIL,
|
||||
BlockTypes.DETECTOR_RAIL,
|
||||
BlockTypes.GRASS,
|
||||
BlockTypes.DEAD_BUSH,
|
||||
BlockTypes.MOVING_PISTON,
|
||||
BlockTypes.PISTON_HEAD,
|
||||
BlockTypes.SUNFLOWER,
|
||||
BlockTypes.ROSE_BUSH,
|
||||
BlockTypes.DANDELION,
|
||||
BlockTypes.POPPY,
|
||||
BlockTypes.BROWN_MUSHROOM,
|
||||
BlockTypes.RED_MUSHROOM,
|
||||
BlockTypes.TNT,
|
||||
BlockTypes.TORCH,
|
||||
BlockTypes.FIRE,
|
||||
BlockTypes.REDSTONE_WIRE,
|
||||
BlockTypes.WHEAT,
|
||||
BlockTypes.POTATOES,
|
||||
BlockTypes.CARROTS,
|
||||
BlockTypes.MELON_STEM,
|
||||
BlockTypes.PUMPKIN_STEM,
|
||||
BlockTypes.BEETROOTS,
|
||||
BlockTypes.RAIL,
|
||||
BlockTypes.LEVER,
|
||||
BlockTypes.REDSTONE_TORCH,
|
||||
BlockTypes.REDSTONE_WALL_TORCH,
|
||||
BlockTypes.REPEATER,
|
||||
BlockTypes.COMPARATOR,
|
||||
BlockTypes.STONE_BUTTON,
|
||||
BlockTypes.BIRCH_BUTTON,
|
||||
BlockTypes.ACACIA_BUTTON,
|
||||
BlockTypes.DARK_OAK_BUTTON,
|
||||
BlockTypes.JUNGLE_BUTTON,
|
||||
BlockTypes.OAK_BUTTON,
|
||||
BlockTypes.SPRUCE_BUTTON,
|
||||
BlockTypes.CACTUS,
|
||||
BlockTypes.SUGAR_CANE,
|
||||
// ores and stuff
|
||||
BlockTypes.BEDROCK
|
||||
*/
|
||||
);
|
||||
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new);
|
||||
}
|
||||
@ -154,7 +157,15 @@ public abstract class LocalConfiguration {
|
||||
*/
|
||||
public abstract void load();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param holder
|
||||
* @return true if block is not permitted
|
||||
*/
|
||||
public boolean checkDisallowedBlocks(BlockStateHolder holder) {
|
||||
if (disallowedBlocks.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (disallowedBlocksMask == null) {
|
||||
BlockMaskBuilder builder = new BlockMaskBuilder();
|
||||
for (String blockRegex : disallowedBlocks) {
|
||||
@ -191,7 +202,7 @@ public abstract class LocalConfiguration {
|
||||
data = Byte.parseByte(splitter[1]);
|
||||
}
|
||||
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
|
||||
} catch (Throwable ignored) {
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
return item;
|
||||
|
@ -127,12 +127,12 @@ public class BiomeCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
BiomeType biome = player.getWorld().getBiome(blockPosition.toBlockPoint().toBlockVector2());
|
||||
BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at line of sight point";
|
||||
} else if (usePosition) {
|
||||
BiomeType biome = player.getWorld().getBiome(player.getLocation().toBlockPoint().toBlockVector2());
|
||||
BiomeType biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2());
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at your position";
|
||||
@ -145,11 +145,9 @@ public class BiomeCommands {
|
||||
biomes.add(world.getBiome(pt));
|
||||
}
|
||||
} else {
|
||||
RegionVisitor visitor = new RegionVisitor(region, pt -> {
|
||||
for (BlockVector3 pt : region) {
|
||||
biomes.add(world.getBiome(pt.toBlockVector2()));
|
||||
return true;
|
||||
});
|
||||
Operations.completeBlindly(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
qualifier = "in your selection";
|
||||
|
@ -448,15 +448,17 @@ public class ClipboardCommands {
|
||||
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(actor);
|
||||
checkPaste(actor, editSession, to, holder, clipboard);
|
||||
|
||||
Operation operation = holder
|
||||
.createPaste(editSession)
|
||||
.to(to)
|
||||
.ignoreAirBlocks(ignoreAirBlocks)
|
||||
.copyBiomes(pasteBiomes)
|
||||
.copyEntities(pasteEntities)
|
||||
.maskSource(sourceMask)
|
||||
.build();
|
||||
Operations.completeLegacy(operation);
|
||||
if (!onlySelect) {
|
||||
Operation operation = holder
|
||||
.createPaste(editSession)
|
||||
.to(to)
|
||||
.ignoreAirBlocks(ignoreAirBlocks)
|
||||
.copyBiomes(pasteBiomes)
|
||||
.copyEntities(pasteEntities)
|
||||
.maskSource(sourceMask)
|
||||
.build();
|
||||
Operations.completeLegacy(operation);
|
||||
}
|
||||
|
||||
if (selectPasted || onlySelect) {
|
||||
BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
|
@ -194,7 +194,7 @@ public class GeneralCommands {
|
||||
} else {
|
||||
session.setUseServerCUI(true);
|
||||
session.updateServerCUI(player);
|
||||
player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32×32×32.");
|
||||
player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,35 +231,33 @@ public class HistoryCommands {
|
||||
@Arg(name = "player", desc = "Undo this player's operations", def = "")
|
||||
String playerName) throws WorldEditException {
|
||||
times = Math.max(1, times);
|
||||
LocalSession undoSession;
|
||||
LocalSession undoSession = session;
|
||||
if (session.hasFastMode()) {
|
||||
player.print(BBC.COMMAND_UNDO_DISABLED.s());
|
||||
return;
|
||||
}
|
||||
if (playerName != null && !playerName.isEmpty()) {
|
||||
if (playerName != null) {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
undoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||
if (undoSession == null) {
|
||||
BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, playerName);
|
||||
player.printError("Unable to find session for " + playerName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int timesUndone = 0;
|
||||
for (int i = 0; i < times; ++i) {
|
||||
EditSession undone = undoSession.undo(undoSession.getBlockBag(player), player);
|
||||
if (undone != null) {
|
||||
timesUndone++;
|
||||
worldEdit.flushBlockBag(player, undone);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (timesUndone > 0) {
|
||||
player.print("Undid " + timesUndone + " available edits.");
|
||||
} else {
|
||||
undoSession = session;
|
||||
}
|
||||
int finalTimes = times;
|
||||
EditSession undone = null;
|
||||
int i = 0;
|
||||
for (; i < finalTimes; ++i) {
|
||||
undone = undoSession.undo(undoSession.getBlockBag(player), player);
|
||||
if (undone == null) break;
|
||||
worldEdit.flushBlockBag(player, undone);
|
||||
}
|
||||
if (undone == null) i--;
|
||||
if (i > 0) {
|
||||
BBC.COMMAND_UNDO_SUCCESS.send(player, i == 1 ? "" : " x" + i);
|
||||
}
|
||||
if (undone == null) {
|
||||
player.printError(BBC.COMMAND_UNDO_ERROR.s());
|
||||
player.printError("Nothing left to undo.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,13 +59,11 @@ public class QueryTool implements BlockTool {
|
||||
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
|
||||
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state"))));
|
||||
/*
|
||||
final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
|
||||
if (internalId.isPresent()) {
|
||||
builder.append(TextComponent.of(" (" + internalId.getAsInt() + ") ", TextColor.DARK_GRAY)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Internal ID"))));
|
||||
}
|
||||
*/
|
||||
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
|
||||
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));
|
||||
|
@ -28,7 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* This class is currently only for internal use. Do not post or catch this event.
|
||||
*/
|
||||
public class CommandEvent extends AbstractCancellable implements Runnable {
|
||||
public class CommandEvent extends AbstractCancellable {
|
||||
|
||||
private final Actor actor;
|
||||
private final String arguments;
|
||||
@ -66,7 +66,8 @@ public class CommandEvent extends AbstractCancellable implements Runnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
public boolean call() {
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ public abstract class AbstractWorld implements World {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void play() {
|
||||
playEffect(position, 2001, blockType.getLegacyCombinedId() >> 4);
|
||||
playEffect(position, 2001, blockType.getLegacyId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user