3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 04:20:06 +01:00
Dieser Commit ist enthalten in:
Jesse Boyd 2019-11-21 07:57:32 +00:00
Ursprung 52a502a1c6
Commit 37b6c406ac
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
18 geänderte Dateien mit 248 neuen und 269 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -190,48 +190,50 @@ public class BukkitWorld extends AbstractWorld {
@Override @Override
public boolean regenerate(Region region, EditSession editSession) { 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); 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,28 +516,38 @@ public class BukkitWorld extends AbstractWorld {
return false; 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 @Override
public BiomeType getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ())); return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
} }
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
return setBlock(BlockVector3.at(x,y,z), block);
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
return false;
}
@Override @Override
public boolean setBiome(BlockVector2 position, BiomeType biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome)); getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome));
return true; return true;
} }
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
return setBlock(BlockVector3.at(x,y,z), block);
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
return false;
}
@Override @Override
public boolean setBiome(int x, int y, int z, BiomeType biome) { public boolean setBiome(int x, int y, int z, BiomeType biome) {
return setBiome(BlockVector2.at(x,z), 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); org.bukkit.entity.Player bukkitPlayer = BukkitAdapter.adapt(player);
WorldEditPlugin.getInstance().getBukkitImplAdapter().sendFakeChunk(getWorld(), bukkitPlayer, packet); 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;
}
} }

Datei anzeigen

@ -31,7 +31,7 @@ import java.nio.charset.StandardCharsets;
*/ */
public class CUIChannelListener implements PluginMessageListener { 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; private final WorldEditPlugin plugin;
public CUIChannelListener(WorldEditPlugin plugin) { public CUIChannelListener(WorldEditPlugin plugin) {

Datei anzeigen

@ -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) { private void fail(Runnable run, String message) {
try { try {
run.run(); run.run();
@ -430,6 +416,22 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
this.getServer().getScheduler().cancelTasks(this); 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. * Loads and reloads all configuration.
*/ */

Datei anzeigen

@ -50,7 +50,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
} catch (Throwable ignored) { } catch (Throwable ignored) {
log.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/"); log.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/");
} }
if (Settings.PLATFORM.equalsIgnoreCase("bukkit")) { if (Settings.PLATFORM.toLowerCase().startsWith("bukkit")) {
new FaweTrim(); new FaweTrim();
} }
if (MainCommand.getInstance().getCommand("generatebiome") == null) { if (MainCommand.getInstance().getCommand("generatebiome") == null) {

Datei anzeigen

@ -205,6 +205,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
return this.displayName; return this.displayName;
} }
} }
private final World world; private final World world;
private final String worldName; private final String worldName;
private boolean wrapped; 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 * @param limit the limit (&gt;= 0) or -1 for no limit
*/ */
public void setBlockChangeLimit(int 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 x the x coordinate
* @param y the y 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))) { if (direction.equals(BlockVector3.at(0, -1, 0))) {
return fillXZ(origin, pattern, radius, depth, false); 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 // Want to replace blocks
final BlockReplace replace = new BlockReplace(EditSession.this, pattern); 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()); BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace); 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)) { for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
if (liquidMask.test(position)) { if (liquidMask.test(position)) {
visitor.visit(position); visitor.visit(position);
@ -2213,6 +2214,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @return number of patches created * @return number of patches created
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @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 { public int makePumpkinPatches(BlockVector3 position, int apothem, double density) throws MaxChangedBlocksException {
// We want to generate pumpkins // We want to generate pumpkins
GardenPatchGenerator generator = new GardenPatchGenerator(this); 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 * @throws MaxChangedBlocksException thrown if too many blocks are changed
*/ */
public int makeForest(BlockVector3 basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException { 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) { return makeForest(CuboidRegion.fromCenter(basePosition, size), density, treeType);
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;
} }
/** /**

Datei anzeigen

@ -27,6 +27,7 @@ import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.util.logging.LogFormat; import com.sk89q.worldedit.util.logging.LogFormat;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; 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.registry.LegacyMapper;
import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
@ -84,67 +85,69 @@ public abstract class LocalConfiguration {
protected String[] getDefaultDisallowedBlocks() { protected String[] getDefaultDisallowedBlocks() {
List<BlockType> blockTypes = Lists.newArrayList( List<BlockType> blockTypes = Lists.newArrayList(
// BlockTypes.OAK_SAPLING, /*
// BlockTypes.JUNGLE_SAPLING, BlockTypes.OAK_SAPLING,
// BlockTypes.DARK_OAK_SAPLING, BlockTypes.JUNGLE_SAPLING,
// BlockTypes.SPRUCE_SAPLING, BlockTypes.DARK_OAK_SAPLING,
// BlockTypes.BIRCH_SAPLING, BlockTypes.SPRUCE_SAPLING,
// BlockTypes.ACACIA_SAPLING, BlockTypes.BIRCH_SAPLING,
// BlockTypes.BLACK_BED, BlockTypes.ACACIA_SAPLING,
// BlockTypes.BLUE_BED, BlockTypes.BLACK_BED,
// BlockTypes.BROWN_BED, BlockTypes.BLUE_BED,
// BlockTypes.CYAN_BED, BlockTypes.BROWN_BED,
// BlockTypes.GRAY_BED, BlockTypes.CYAN_BED,
// BlockTypes.GREEN_BED, BlockTypes.GRAY_BED,
// BlockTypes.LIGHT_BLUE_BED, BlockTypes.GREEN_BED,
// BlockTypes.LIGHT_GRAY_BED, BlockTypes.LIGHT_BLUE_BED,
// BlockTypes.LIME_BED, BlockTypes.LIGHT_GRAY_BED,
// BlockTypes.MAGENTA_BED, BlockTypes.LIME_BED,
// BlockTypes.ORANGE_BED, BlockTypes.MAGENTA_BED,
// BlockTypes.PINK_BED, BlockTypes.ORANGE_BED,
// BlockTypes.PURPLE_BED, BlockTypes.PINK_BED,
// BlockTypes.RED_BED, BlockTypes.PURPLE_BED,
// BlockTypes.WHITE_BED, BlockTypes.RED_BED,
// BlockTypes.YELLOW_BED, BlockTypes.WHITE_BED,
// BlockTypes.POWERED_RAIL, BlockTypes.YELLOW_BED,
// BlockTypes.DETECTOR_RAIL, BlockTypes.POWERED_RAIL,
// BlockTypes.GRASS, BlockTypes.DETECTOR_RAIL,
// BlockTypes.DEAD_BUSH, BlockTypes.GRASS,
// BlockTypes.MOVING_PISTON, BlockTypes.DEAD_BUSH,
// BlockTypes.PISTON_HEAD, BlockTypes.MOVING_PISTON,
// BlockTypes.SUNFLOWER, BlockTypes.PISTON_HEAD,
// BlockTypes.ROSE_BUSH, BlockTypes.SUNFLOWER,
// BlockTypes.DANDELION, BlockTypes.ROSE_BUSH,
// BlockTypes.POPPY, BlockTypes.DANDELION,
// BlockTypes.BROWN_MUSHROOM, BlockTypes.POPPY,
// BlockTypes.RED_MUSHROOM, BlockTypes.BROWN_MUSHROOM,
// BlockTypes.TNT, BlockTypes.RED_MUSHROOM,
// BlockTypes.TORCH, BlockTypes.TNT,
// BlockTypes.FIRE, BlockTypes.TORCH,
// BlockTypes.REDSTONE_WIRE, BlockTypes.FIRE,
// BlockTypes.WHEAT, BlockTypes.REDSTONE_WIRE,
// BlockTypes.POTATOES, BlockTypes.WHEAT,
// BlockTypes.CARROTS, BlockTypes.POTATOES,
// BlockTypes.MELON_STEM, BlockTypes.CARROTS,
// BlockTypes.PUMPKIN_STEM, BlockTypes.MELON_STEM,
// BlockTypes.BEETROOTS, BlockTypes.PUMPKIN_STEM,
// BlockTypes.RAIL, BlockTypes.BEETROOTS,
// BlockTypes.LEVER, BlockTypes.RAIL,
// BlockTypes.REDSTONE_TORCH, BlockTypes.LEVER,
// BlockTypes.REDSTONE_WALL_TORCH, BlockTypes.REDSTONE_TORCH,
// BlockTypes.REPEATER, BlockTypes.REDSTONE_WALL_TORCH,
// BlockTypes.COMPARATOR, BlockTypes.REPEATER,
// BlockTypes.STONE_BUTTON, BlockTypes.COMPARATOR,
// BlockTypes.BIRCH_BUTTON, BlockTypes.STONE_BUTTON,
// BlockTypes.ACACIA_BUTTON, BlockTypes.BIRCH_BUTTON,
// BlockTypes.DARK_OAK_BUTTON, BlockTypes.ACACIA_BUTTON,
// BlockTypes.JUNGLE_BUTTON, BlockTypes.DARK_OAK_BUTTON,
// BlockTypes.OAK_BUTTON, BlockTypes.JUNGLE_BUTTON,
// BlockTypes.SPRUCE_BUTTON, BlockTypes.OAK_BUTTON,
// BlockTypes.CACTUS, BlockTypes.SPRUCE_BUTTON,
// BlockTypes.SUGAR_CANE, BlockTypes.CACTUS,
// // ores and stuff BlockTypes.SUGAR_CANE,
// BlockTypes.BEDROCK // ores and stuff
BlockTypes.BEDROCK
*/
); );
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new); return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new);
} }
@ -154,7 +157,15 @@ public abstract class LocalConfiguration {
*/ */
public abstract void load(); public abstract void load();
/**
*
* @param holder
* @return true if block is not permitted
*/
public boolean checkDisallowedBlocks(BlockStateHolder holder) { public boolean checkDisallowedBlocks(BlockStateHolder holder) {
if (disallowedBlocks.isEmpty()) {
return false;
}
if (disallowedBlocksMask == null) { if (disallowedBlocksMask == null) {
BlockMaskBuilder builder = new BlockMaskBuilder(); BlockMaskBuilder builder = new BlockMaskBuilder();
for (String blockRegex : disallowedBlocks) { for (String blockRegex : disallowedBlocks) {
@ -191,7 +202,7 @@ public abstract class LocalConfiguration {
data = Byte.parseByte(splitter[1]); data = Byte.parseByte(splitter[1]);
} }
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId(); item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
} catch (Throwable ignored) { } catch (Throwable e) {
} }
return item; return item;

Datei anzeigen

@ -127,12 +127,12 @@ public class BiomeCommands {
return; return;
} }
BiomeType biome = player.getWorld().getBiome(blockPosition.toBlockPoint().toBlockVector2()); BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
biomes.add(biome); biomes.add(biome);
qualifier = "at line of sight point"; qualifier = "at line of sight point";
} else if (usePosition) { } 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); biomes.add(biome);
qualifier = "at your position"; qualifier = "at your position";
@ -145,11 +145,9 @@ public class BiomeCommands {
biomes.add(world.getBiome(pt)); biomes.add(world.getBiome(pt));
} }
} else { } else {
RegionVisitor visitor = new RegionVisitor(region, pt -> { for (BlockVector3 pt : region) {
biomes.add(world.getBiome(pt.toBlockVector2())); biomes.add(world.getBiome(pt.toBlockVector2()));
return true; }
});
Operations.completeBlindly(visitor);
} }
qualifier = "in your selection"; qualifier = "in your selection";

Datei anzeigen

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

Datei anzeigen

@ -194,7 +194,7 @@ public class GeneralCommands {
} else { } else {
session.setUseServerCUI(true); session.setUseServerCUI(true);
session.updateServerCUI(player); 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.");
} }
} }

Datei anzeigen

@ -231,35 +231,33 @@ public class HistoryCommands {
@Arg(name = "player", desc = "Undo this player's operations", def = "") @Arg(name = "player", desc = "Undo this player's operations", def = "")
String playerName) throws WorldEditException { String playerName) throws WorldEditException {
times = Math.max(1, times); times = Math.max(1, times);
LocalSession undoSession; LocalSession undoSession = session;
if (session.hasFastMode()) { if (session.hasFastMode()) {
player.print(BBC.COMMAND_UNDO_DISABLED.s()); player.print(BBC.COMMAND_UNDO_DISABLED.s());
return; return;
} }
if (playerName != null && !playerName.isEmpty()) { if (playerName != null) {
player.checkPermission("worldedit.history.undo.other"); player.checkPermission("worldedit.history.undo.other");
undoSession = worldEdit.getSessionManager().findByName(playerName); undoSession = worldEdit.getSessionManager().findByName(playerName);
if (undoSession == null) { if (undoSession == null) {
BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, playerName); player.printError("Unable to find session for " + playerName);
return; 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 { } else {
undoSession = session; player.printError("Nothing left to undo.");
}
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());
} }
} }

Datei anzeigen

@ -59,13 +59,11 @@ public class QueryTool implements BlockTool {
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW)); builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY) builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state")))); .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state"))));
/*
final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState()); final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
if (internalId.isPresent()) { if (internalId.isPresent()) {
builder.append(TextComponent.of(" (" + internalId.getAsInt() + ") ", TextColor.DARK_GRAY) builder.append(TextComponent.of(" (" + internalId.getAsInt() + ") ", TextColor.DARK_GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Internal ID")))); .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Internal ID"))));
} }
*/
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/" builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE) + world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above")))); .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));

Datei anzeigen

@ -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. * 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 Actor actor;
private final String arguments; private final String arguments;
@ -66,7 +66,8 @@ public class CommandEvent extends AbstractCancellable implements Runnable {
} }
@Override @Override
public void run() { public boolean call() {
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(this); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(this);
return true;
} }
} }

Datei anzeigen

@ -166,7 +166,7 @@ public abstract class AbstractWorld implements World {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void play() { public void play() {
playEffect(position, 2001, blockType.getLegacyCombinedId() >> 4); playEffect(position, 2001, blockType.getLegacyId());
} }
@Override @Override

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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