reduce diff

This commit is contained in:
Jesse Boyd 2019-11-21 07:57:32 +00:00
parent 52a502a1c6
commit 37b6c406ac
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
18 changed files with 248 additions and 269 deletions

View File

@ -182,7 +182,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override
public void printError(String msg) {
for (String part : msg.split("\n")) {
player.sendMessage("§c" + part);
player.sendMessage("\u00A7c" + part);
}
}
@ -226,18 +226,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override
public boolean hasPermission(String perm) {
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp())
|| plugin.getPermissionsResolver().hasPermission(player.getWorld().getName(), player, perm);
}
@Override
public boolean isAllowedToFly() {
return player.getAllowFlight();
}
@Override
public void setFlying(boolean flying) {
player.setFlying(flying);
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp());
}
@Override
@ -272,14 +261,14 @@ public class BukkitPlayer extends AbstractPlayerActor {
player.sendPluginMessage(plugin, WorldEditPlugin.CUI_PLUGIN_CHANNEL, send.getBytes(CUIChannelListener.UTF_8_CHARSET));
}
public Player getPlayer() {
if (!player.isValid()) {
Player tmp = Bukkit.getPlayer(getUniqueId());
if (tmp != null) {
player = tmp;
@Override
public boolean isAllowedToFly() {
return player.getAllowFlight();
}
}
return player;
@Override
public void setFlying(boolean flying) {
player.setFlying(flying);
}
@Override
@ -311,7 +300,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override
public SessionKey getSessionKey() {
return new SessionKeyImpl(getUniqueId(), getName());
return new SessionKeyImpl(this.player.getUniqueId(), player.getName());
}
private static class SessionKeyImpl implements SessionKey {
@ -382,4 +371,14 @@ public class BukkitPlayer extends AbstractPlayerActor {
public void unregister() {
player.removeMetadata("WE", WorldEditPlugin.getInstance());
}
public Player getPlayer() {
if (!player.isValid()) {
Player tmp = Bukkit.getPlayer(getUniqueId());
if (tmp != null) {
player = tmp;
}
}
return player;
}
}

View File

@ -190,7 +190,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
@Override
public String getPlatformName() {
return "Bukkit";
return "Bukkit-Official";
}
@Override

View File

@ -190,48 +190,50 @@ public class BukkitWorld extends AbstractWorld {
@Override
public boolean regenerate(Region region, EditSession editSession) {
/*
BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
for (BlockVector2 chunk : region.getChunks()) {
BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
// First save all the blocks inside
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < (getMaxY() + 1); ++y) {
for (int z = 0; z < 16; ++z) {
BlockVector3 pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
history[index] = editSession.getFullBlock(pt);
}
}
}
try {
getWorld().regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
} catch (Throwable t) {
logger.warn("Chunk generation via Bukkit raised an error", t);
}
// Then restore
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < (getMaxY() + 1); ++y) {
for (int z = 0; z < 16; ++z) {
BlockVector3 pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
// We have to restore the block if it was outside
if (!region.contains(pt)) {
editSession.smartSetBlock(pt, history[index]);
} else { // Otherwise fool with history
editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
}
}
}
}
}
return true;
*/
return editSession.regenerate(region);
// BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
//
// for (BlockVector2 chunk : region.getChunks()) {
// BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
//
// // First save all the blocks inside
// for (int x = 0; x < 16; ++x) {
// for (int y = 0; y < (getMaxY() + 1); ++y) {
// for (int z = 0; z < 16; ++z) {
// BlockVector3 pt = min.add(x, y, z);
// int index = y * 16 * 16 + z * 16 + x;
// history[index] = editSession.getFullBlock(pt);
// }
// }
// }
//
// try {
// getWorld().regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
// } catch (Throwable t) {
// logger.warn("Chunk generation via Bukkit raised an error", t);
// }
//
// // Then restore
// for (int x = 0; x < 16; ++x) {
// for (int y = 0; y < (getMaxY() + 1); ++y) {
// for (int z = 0; z < 16; ++z) {
// BlockVector3 pt = min.add(x, y, z);
// int index = y * 16 * 16 + z * 16 + x;
//
// // We have to restore the block if it was outside
// if (!region.contains(pt)) {
// editSession.smartSetBlock(pt, history[index]);
// } else { // Otherwise fool with history
// editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
// }
// }
// }
// }
// }
//
// return true;
}
/**
@ -514,11 +516,27 @@ public class BukkitWorld extends AbstractWorld {
return false;
}
@Override
public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
return adapter.simulateItemUse(getWorld(), position, item, face);
}
return false;
}
@Override
public BiomeType getBiome(BlockVector2 position) {
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome));
return true;
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
@ -530,12 +548,6 @@ public class BukkitWorld extends AbstractWorld {
return false;
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome));
return true;
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
return setBiome(BlockVector2.at(x,z), biome);
@ -556,14 +568,4 @@ public class BukkitWorld extends AbstractWorld {
org.bukkit.entity.Player bukkitPlayer = BukkitAdapter.adapt(player);
WorldEditPlugin.getInstance().getBukkitImplAdapter().sendFakeChunk(getWorld(), bukkitPlayer, packet);
}
@Override
public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
return adapter.simulateItemUse(getWorld(), position, item, face);
}
return false;
}
}

View File

@ -31,7 +31,7 @@ import java.nio.charset.StandardCharsets;
*/
public class CUIChannelListener implements PluginMessageListener {
public static final Charset UTF_8_CHARSET = StandardCharsets.UTF_8;
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
private final WorldEditPlugin plugin;
public CUIChannelListener(WorldEditPlugin plugin) {

View File

@ -341,20 +341,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
}
}
// @Override
// public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) {
// // Add the command to the array because the underlying command handling
// // code of WorldEdit expects it
// String[] split = new String[args.length + 1];
// System.arraycopy(args, 0, split, 1, args.length);
// split[0] = commandLabel;
//
// String arguments = Joiner.on(" ").join(split);
// CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments);
// getWorldEdit().getEventBus().post(event);
// return CommandUtil.fixSuggestions(arguments, event.getSuggestions());
// }
private void fail(Runnable run, String message) {
try {
run.run();
@ -430,6 +416,22 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
this.getServer().getScheduler().cancelTasks(this);
}
/*
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) {
// Add the command to the array because the underlying command handling
// code of WorldEdit expects it
String[] split = new String[args.length + 1];
System.arraycopy(args, 0, split, 1, args.length);
split[0] = commandLabel;
String arguments = Joiner.on(" ").join(split);
CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments);
getWorldEdit().getEventBus().post(event);
return CommandUtil.fixSuggestions(arguments, event.getSuggestions());
}
*/
/**
* Loads and reloads all configuration.
*/

View File

@ -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) {

View File

@ -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 (&gt;= 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);
}
/**

View File

@ -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;

View File

@ -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";

View File

@ -448,6 +448,7 @@ public class ClipboardCommands {
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(actor);
checkPaste(actor, editSession, to, holder, clipboard);
if (!onlySelect) {
Operation operation = holder
.createPaste(editSession)
.to(to)
@ -457,6 +458,7 @@ public class ClipboardCommands {
.maskSource(sourceMask)
.build();
Operations.completeLegacy(operation);
}
if (selectPasted || onlySelect) {
BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());

View File

@ -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.");
}
}

View File

@ -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;
}
} 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;
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 (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());
if (timesUndone > 0) {
player.print("Undid " + timesUndone + " available edits.");
} else {
player.printError("Nothing left to undo.");
}
}

View File

@ -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"))));

View File

@ -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;
}
}

View File

@ -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

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.extent.transform;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.HashSet;
import java.util.Set;
@ -37,30 +38,32 @@ public class BlockTransformExtentTest {
private static final Transform ROTATE_NEG_90 = new AffineTransform().rotateY(90);
private final Set<BlockType> ignored = new HashSet<>();
/*
@BeforeEach
public void setUp() {
//BlockType.REGISTRY.register("worldedit:test", new BlockType("worldedit:test"));
BlockType.REGISTRY.register("worldedit:test", new BlockType("worldedit:test"));
}
@Test
public void testTransform() {
// for (BlockType type : BlockType.REGISTRY.values()) {
// if (ignored.contains(type)) {
// continue;
// }
//
// BlockState base = type.getDefaultState();
// BlockState rotated = base;
//
// for (int i = 1; i < 4; i++) {
// rotated = BlockTransformExtent.transform(base, ROTATE_90);
// }
// assertEquals(base, rotated);
// rotated = base;
// for (int i = 1; i < 4; i++) {
// rotated = BlockTransformExtent.transform(base, ROTATE_NEG_90);
// }
// assertEquals(base, rotated);
// }
for (BlockType type : BlockType.REGISTRY.values()) {
if (ignored.contains(type)) {
continue;
}
BlockState base = type.getDefaultState();
BlockState rotated = base;
for (int i = 1; i < 4; i++) {
rotated = BlockTransformExtent.transform(base, ROTATE_90);
}
assertEquals(base, rotated);
rotated = base;
for (int i = 1; i < 4; i++) {
rotated = BlockTransformExtent.transform(base, ROTATE_NEG_90);
}
assertEquals(base, rotated);
}
}
*/
}

View File

@ -20,31 +20,17 @@
package com.sk89q.worldedit.internal.expression;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
import java.time.Duration;
import com.sk89q.worldedit.internal.expression.runtime.ExpressionTimeoutException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import static java.lang.Math.atan2;
import static java.lang.Math.sin;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class ExpressionTest extends BaseExpressionTest {
private Platform mockPlat = mock(Platform.class);
@AfterEach
public void tearDown() {
WorldEdit.getInstance().getPlatformManager().unregister(mockPlat);
}
@Test
public void testEvaluate() throws ExpressionException {
// check

View File

@ -56,7 +56,7 @@ public class LocationTest {
World world = mock(World.class);
Vector3 position = Vector3.at(1, 1, 1);
Location location = new Location(world, position);
assertEquals(position, location);
assertEquals(position, location.toVector());
}
@Test