geforkt von Mirrors/FastAsyncWorldEdit
Minor upstream changes and obviously more command work
Dieser Commit ist enthalten in:
Ursprung
9816eb3102
Commit
01c371df9c
@ -19,7 +19,10 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.IntTag;
|
||||||
import com.sk89q.jnbt.ListTag;
|
import com.sk89q.jnbt.ListTag;
|
||||||
import com.sk89q.jnbt.NBTUtils;
|
import com.sk89q.jnbt.NBTUtils;
|
||||||
import com.sk89q.jnbt.ShortTag;
|
import com.sk89q.jnbt.ShortTag;
|
||||||
@ -28,7 +31,6 @@ import com.sk89q.jnbt.Tag;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -38,17 +40,17 @@ import java.util.Map;
|
|||||||
public class MobSpawnerBlock extends BaseBlock {
|
public class MobSpawnerBlock extends BaseBlock {
|
||||||
|
|
||||||
private String mobType;
|
private String mobType;
|
||||||
private short delay;
|
private short delay = -1;
|
||||||
|
|
||||||
// advanced mob spawner features
|
// advanced mob spawner features
|
||||||
private short spawnCount;
|
private short spawnCount = 4;
|
||||||
private short spawnRange;
|
private short spawnRange = 4;
|
||||||
private CompoundTag spawnData;
|
private CompoundTag spawnData;
|
||||||
private ListTag spawnPotentials;
|
private ListTag spawnPotentials;
|
||||||
private short minSpawnDelay;
|
private short minSpawnDelay = 200;
|
||||||
private short maxSpawnDelay;
|
private short maxSpawnDelay = 800;
|
||||||
private short maxNearbyEntities;
|
private short maxNearbyEntities = 6;
|
||||||
private short requiredPlayerRange;
|
private short requiredPlayerRange = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the mob spawner block with a specified data value.
|
* Construct the mob spawner block with a specified data value.
|
||||||
@ -113,7 +115,7 @@ public class MobSpawnerBlock extends BaseBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNbtId() {
|
public String getNbtId() {
|
||||||
return "MobSpawner";
|
return "minecraft:mob_spawner";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -127,10 +129,16 @@ public class MobSpawnerBlock extends BaseBlock {
|
|||||||
values.put("MaxSpawnDelay", new ShortTag(maxSpawnDelay));
|
values.put("MaxSpawnDelay", new ShortTag(maxSpawnDelay));
|
||||||
values.put("MaxNearbyEntities", new ShortTag(maxNearbyEntities));
|
values.put("MaxNearbyEntities", new ShortTag(maxNearbyEntities));
|
||||||
values.put("RequiredPlayerRange", new ShortTag(requiredPlayerRange));
|
values.put("RequiredPlayerRange", new ShortTag(requiredPlayerRange));
|
||||||
if (spawnData != null) {
|
if (spawnData == null) {
|
||||||
|
values.put("SpawnData", new CompoundTag(ImmutableMap.of("id", new StringTag(mobType))));
|
||||||
|
} else {
|
||||||
values.put("SpawnData", new CompoundTag(spawnData.getValue()));
|
values.put("SpawnData", new CompoundTag(spawnData.getValue()));
|
||||||
}
|
}
|
||||||
if (spawnPotentials != null) {
|
if (spawnPotentials == null) {
|
||||||
|
values.put("SpawnPotentials", new ListTag(CompoundTag.class, ImmutableList.of(
|
||||||
|
new CompoundTag(ImmutableMap.of("Weight", new IntTag(1), "Entity",
|
||||||
|
new CompoundTag(ImmutableMap.of("id", new StringTag(mobType))))))));
|
||||||
|
} else {
|
||||||
values.put("SpawnPotentials", new ListTag(CompoundTag.class, spawnPotentials.getValue()));
|
values.put("SpawnPotentials", new ListTag(CompoundTag.class, spawnPotentials.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,22 +154,32 @@ public class MobSpawnerBlock extends BaseBlock {
|
|||||||
Map<String, Tag> values = rootTag.getValue();
|
Map<String, Tag> values = rootTag.getValue();
|
||||||
|
|
||||||
Tag t = values.get("id");
|
Tag t = values.get("id");
|
||||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("MobSpawner")) {
|
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals(getNbtId())) {
|
||||||
throw new RuntimeException("'MobSpawner' tile entity expected");
|
throw new RuntimeException(String.format("'%s' tile entity expected", getNbtId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTag mobTypeTag;
|
CompoundTag spawnDataTag;
|
||||||
|
String mobType;
|
||||||
ShortTag delayTag;
|
ShortTag delayTag;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mobTypeTag = NBTUtils.getChildTag(values, "EntityId", StringTag.class);
|
spawnDataTag = NBTUtils.getChildTag(values, "SpawnData", CompoundTag.class);
|
||||||
delayTag = NBTUtils.getChildTag(values, "Delay", ShortTag.class);
|
mobType = spawnDataTag.getString("id");
|
||||||
|
if (mobType.equals("")) {
|
||||||
|
throw new InvalidFormatException("No spawn id.");
|
||||||
|
}
|
||||||
|
this.mobType = mobType;
|
||||||
|
this.spawnData = spawnDataTag;
|
||||||
} catch (InvalidFormatException ignored) {
|
} catch (InvalidFormatException ignored) {
|
||||||
throw new RuntimeException("Invalid mob spawner data: no EntityId and/or no Delay");
|
throw new RuntimeException("Invalid mob spawner data: no SpawnData and/or no Delay");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
delayTag = NBTUtils.getChildTag(values, "Delay", ShortTag.class);
|
||||||
|
this.delay = delayTag.getValue();
|
||||||
|
} catch (InvalidFormatException ignored) {
|
||||||
|
this.delay = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mobType = mobTypeTag.getValue();
|
|
||||||
this.delay = delayTag.getValue();
|
|
||||||
|
|
||||||
ShortTag spawnCountTag = null;
|
ShortTag spawnCountTag = null;
|
||||||
ShortTag spawnRangeTag = null;
|
ShortTag spawnRangeTag = null;
|
||||||
@ -170,7 +188,6 @@ public class MobSpawnerBlock extends BaseBlock {
|
|||||||
ShortTag maxNearbyEntitiesTag = null;
|
ShortTag maxNearbyEntitiesTag = null;
|
||||||
ShortTag requiredPlayerRangeTag = null;
|
ShortTag requiredPlayerRangeTag = null;
|
||||||
ListTag spawnPotentialsTag = null;
|
ListTag spawnPotentialsTag = null;
|
||||||
CompoundTag spawnDataTag = null;
|
|
||||||
try {
|
try {
|
||||||
spawnCountTag = NBTUtils.getChildTag(values, "SpawnCount", ShortTag.class);
|
spawnCountTag = NBTUtils.getChildTag(values, "SpawnCount", ShortTag.class);
|
||||||
} catch (InvalidFormatException ignored) {
|
} catch (InvalidFormatException ignored) {
|
||||||
@ -199,10 +216,6 @@ public class MobSpawnerBlock extends BaseBlock {
|
|||||||
spawnPotentialsTag = NBTUtils.getChildTag(values, "SpawnPotentials", ListTag.class);
|
spawnPotentialsTag = NBTUtils.getChildTag(values, "SpawnPotentials", ListTag.class);
|
||||||
} catch (InvalidFormatException ignored) {
|
} catch (InvalidFormatException ignored) {
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
spawnDataTag = NBTUtils.getChildTag(values, "SpawnData", CompoundTag.class);
|
|
||||||
} catch (InvalidFormatException ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (spawnCountTag != null) {
|
if (spawnCountTag != null) {
|
||||||
this.spawnCount = spawnCountTag.getValue();
|
this.spawnCount = spawnCountTag.getValue();
|
||||||
@ -225,9 +238,6 @@ public class MobSpawnerBlock extends BaseBlock {
|
|||||||
if (spawnPotentialsTag != null) {
|
if (spawnPotentialsTag != null) {
|
||||||
this.spawnPotentials = new ListTag(CompoundTag.class, spawnPotentialsTag.getValue());
|
this.spawnPotentials = new ListTag(CompoundTag.class, spawnPotentialsTag.getValue());
|
||||||
}
|
}
|
||||||
if (spawnDataTag != null) {
|
|
||||||
this.spawnData = new CompoundTag(spawnDataTag.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class SignBlock extends BaseBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNbtId() {
|
public String getNbtId() {
|
||||||
return "Sign";
|
return "minecraft:sign";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,8 +114,8 @@ public class SignBlock extends BaseBlock {
|
|||||||
text = new String[] { EMPTY, EMPTY, EMPTY, EMPTY };
|
text = new String[] { EMPTY, EMPTY, EMPTY, EMPTY };
|
||||||
|
|
||||||
t = values.get("id");
|
t = values.get("id");
|
||||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Sign")) {
|
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals(getNbtId())) {
|
||||||
throw new RuntimeException("'Sign' tile entity expected");
|
throw new RuntimeException(String.format("'%s' tile entity expected", getNbtId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
t = values.get("Text1");
|
t = values.get("Text1");
|
||||||
|
@ -83,14 +83,15 @@ public class SkullBlock extends BaseBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNbtId() {
|
public String getNbtId() {
|
||||||
return "Skull";
|
return "skull";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
Map<String, Tag> values = new HashMap<>();
|
Map<String, Tag> values = new HashMap<>();
|
||||||
if (owner == null) owner = "";
|
Map<String, Tag> inner = new HashMap<>();
|
||||||
values.put("ExtraType", new StringTag(owner));
|
inner.put("Name", new StringTag(owner));
|
||||||
|
values.put("Owner", new CompoundTag(inner));
|
||||||
return new CompoundTag(values);
|
return new CompoundTag(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,13 +106,13 @@ public class SkullBlock extends BaseBlock {
|
|||||||
Tag t;
|
Tag t;
|
||||||
|
|
||||||
t = values.get("id");
|
t = values.get("id");
|
||||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Skull")) {
|
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals(getNbtId())) {
|
||||||
throw new RuntimeException("'Skull' tile entity expected");
|
throw new RuntimeException(String.format("'%s' tile entity expected", getNbtId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
t = values.get("ExtraType");
|
t = values.get("Owner");
|
||||||
if (t instanceof StringTag) {
|
if (t instanceof CompoundTag) {
|
||||||
owner = ((StringTag) t).getValue();
|
setOwner(((CompoundTag) t).getValue().get("Name").getValue().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,10 +111,14 @@ public class AnvilCommands {
|
|||||||
name = "replaceall",
|
name = "replaceall",
|
||||||
aliases = {"rea", "repall"},
|
aliases = {"rea", "repall"},
|
||||||
desc = "Replace all blocks in the selection with another",
|
desc = "Replace all blocks in the selection with another",
|
||||||
descFooter = "The -d flag disabled wildcard data matching\n"
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.replaceall")
|
@CommandPermissions("worldedit.anvil.replaceall")
|
||||||
public void replaceAll(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, String to, @Switch(name = 'd', desc = "TODO") boolean useData) throws WorldEditException {
|
public void replaceAll(Player player, String folder,
|
||||||
|
@Arg(name = "from", desc = "String", def = "")
|
||||||
|
String from,
|
||||||
|
String to,
|
||||||
|
@Switch(name = 'd', desc = "Disable wildcard data matching")
|
||||||
|
boolean useData) throws WorldEditException {
|
||||||
// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
|
// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
|
||||||
// if (from == null) {
|
// if (from == null) {
|
||||||
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
||||||
@ -234,8 +238,7 @@ public class AnvilCommands {
|
|||||||
name = "trimallplots",
|
name = "trimallplots",
|
||||||
|
|
||||||
desc = "Trim chunks in a Plot World",
|
desc = "Trim chunks in a Plot World",
|
||||||
descFooter = "Unclaimed chunks will be deleted\n" +
|
descFooter = "Unclaimed chunks will be deleted\nUnmodified chunks will be deleted\n"
|
||||||
"Unmodified chunks will be deleted\n"
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.trimallplots")
|
@CommandPermissions("worldedit.anvil.trimallplots")
|
||||||
public void trimAllPlots(Player player, @Switch(name = 'v', desc = "Delete unvisited chunks") boolean deleteUnvisited) throws WorldEditException {
|
public void trimAllPlots(Player player, @Switch(name = 'v', desc = "Delete unvisited chunks") boolean deleteUnvisited) throws WorldEditException {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.boydti.fawe.command;
|
package com.boydti.fawe.command;
|
||||||
|
|
||||||
|
import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline;
|
||||||
|
|
||||||
import com.boydti.fawe.config.Commands;
|
import com.boydti.fawe.config.Commands;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
||||||
@ -56,13 +58,14 @@ public class CFICommand extends CommandProcessor<Object, Object> {
|
|||||||
hmCmd =
|
hmCmd =
|
||||||
Commands.getAlias(CFICommands.class, "heightmap") + " " + settings.imageArg;
|
Commands.getAlias(CFICommands.class, "heightmap") + " " + settings.imageArg;
|
||||||
}
|
}
|
||||||
TextComponent.of("What do you want to use as the base?").newline()
|
TextComponent build = TextComponent.builder("What do you want to use as the base?")
|
||||||
.text("[HeightMap]").cmdTip(hmCmd).text(" - A heightmap like ")
|
.append(newline())
|
||||||
.text("[this]").linkTip("http://i.imgur.com/qCd30MR.jpg")
|
.append("[HeightMap]")/* TODO .cmdTip(hmCmd).*/.append(" - A heightmap like ")
|
||||||
.newline()
|
.append("[this]")//TODO .linkTip("http://i.imgur.com/qCd30MR.jpg")
|
||||||
.text("[Empty]").cmdTip(CFICommands.alias() + " empty")
|
.append(newline())
|
||||||
.text("- An empty map of a specific size")
|
.append("[Empty]")//TODO .cmdTip(CFICommands.alias() + " empty")
|
||||||
.send(fp);
|
.append("- An empty map of a specific size").build();
|
||||||
|
fp.toWorldEditPlayer().print(build);
|
||||||
} else {
|
} else {
|
||||||
args = new ArrayList<>(args);
|
args = new ArrayList<>(args);
|
||||||
switch (args.size()) {
|
switch (args.size()) {
|
||||||
|
@ -1,20 +1,13 @@
|
|||||||
package com.boydti.fawe.command;
|
package com.boydti.fawe.command;
|
||||||
|
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.boydti.fawe.util.StringMan;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
public class SuggestInputParseException extends InputParseException {
|
public class SuggestInputParseException extends InputParseException {
|
||||||
|
|
||||||
private final InputParseException cause;
|
private final InputParseException cause;
|
||||||
@ -56,7 +49,7 @@ public class SuggestInputParseException extends InputParseException {
|
|||||||
public static SuggestInputParseException of(String input, List<Object> values) {
|
public static SuggestInputParseException of(String input, List<Object> values) {
|
||||||
throw new SuggestInputParseException("No value: " + input, input, () ->
|
throw new SuggestInputParseException("No value: " + input, input, () ->
|
||||||
values.stream()
|
values.stream()
|
||||||
.map(v -> v.toString())
|
.map(Object::toString)
|
||||||
.filter(v -> v.startsWith(input))
|
.filter(v -> v.startsWith(input))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
import static org.enginehub.piston.part.CommandParts.arg;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -29,8 +32,6 @@ import com.sk89q.worldedit.command.factory.ReplaceFactory;
|
|||||||
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.command.util.CommandQueued;
|
|
||||||
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
|
|
||||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.function.Contextual;
|
import com.sk89q.worldedit.function.Contextual;
|
||||||
@ -45,6 +46,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
|||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||||
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration;
|
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
import org.enginehub.piston.CommandManagerService;
|
import org.enginehub.piston.CommandManagerService;
|
||||||
import org.enginehub.piston.CommandParameters;
|
import org.enginehub.piston.CommandParameters;
|
||||||
@ -55,11 +57,6 @@ import org.enginehub.piston.inject.Key;
|
|||||||
import org.enginehub.piston.part.CommandArgument;
|
import org.enginehub.piston.part.CommandArgument;
|
||||||
import org.enginehub.piston.part.SubCommandPart;
|
import org.enginehub.piston.part.SubCommandPart;
|
||||||
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
|
||||||
import static org.enginehub.piston.part.CommandParts.arg;
|
|
||||||
|
|
||||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
public class ApplyBrushCommands {
|
public class ApplyBrushCommands {
|
||||||
|
|
||||||
|
@ -63,12 +63,11 @@ public class BrushOptionsCommands {
|
|||||||
@Command(
|
@Command(
|
||||||
name = "savebrush",
|
name = "savebrush",
|
||||||
aliases = {"save"},
|
aliases = {"save"},
|
||||||
desc = "Save your current brush",
|
desc = "Save your current brush"
|
||||||
descFooter = "Save your current brush use the -g flag to save globally"
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.save")
|
@CommandPermissions("worldedit.brush.save")
|
||||||
public void saveBrush(Player player, LocalSession session, String name,
|
public void saveBrush(Player player, LocalSession session, String name,
|
||||||
@Switch(name = 'g', desc = "TODO") boolean root) throws WorldEditException, IOException {
|
@Switch(name = 'g', desc = "Save the brush globally") boolean root) throws WorldEditException, IOException {
|
||||||
BrushTool tool = session.getBrushTool(player);
|
BrushTool tool = session.getBrushTool(player);
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
root |= name.startsWith("../");
|
root |= name.startsWith("../");
|
||||||
@ -134,8 +133,7 @@ public class BrushOptionsCommands {
|
|||||||
@Command(
|
@Command(
|
||||||
name = "/listbrush",
|
name = "/listbrush",
|
||||||
desc = "List saved brushes",
|
desc = "List saved brushes",
|
||||||
descFooter = "List all brushes in the brush directory\n" +
|
descFooter = "List all brushes in the brush directory"
|
||||||
" -p <page> prints the requested page\n"
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.list")
|
@CommandPermissions("worldedit.brush.list")
|
||||||
public void list(Actor actor, InjectedValueAccess args,
|
public void list(Actor actor, InjectedValueAccess args,
|
||||||
|
@ -42,6 +42,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
|
|||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.command.util.Logging;
|
import com.sk89q.worldedit.command.util.Logging;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.function.GroundFunction;
|
import com.sk89q.worldedit.function.GroundFunction;
|
||||||
import com.sk89q.worldedit.function.generator.FloraGenerator;
|
import com.sk89q.worldedit.function.generator.FloraGenerator;
|
||||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||||
@ -69,6 +70,7 @@ import com.sk89q.worldedit.regions.RegionOperationException;
|
|||||||
import com.sk89q.worldedit.regions.Regions;
|
import com.sk89q.worldedit.regions.Regions;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -84,7 +86,7 @@ import org.enginehub.piston.inject.InjectedValueAccess;
|
|||||||
* Commands that operate on regions.
|
* Commands that operate on regions.
|
||||||
*/
|
*/
|
||||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
public class RegionCommands extends MethodCommands {
|
public class RegionCommands {
|
||||||
|
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
|
|
||||||
@ -103,7 +105,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
desc = "Get the light at a position"
|
desc = "Get the light at a position"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.fix")
|
@CommandPermissions("worldedit.light.fix")
|
||||||
public void fixlighting(Player player) throws WorldEditException {
|
public void fixLighting(Player player) throws WorldEditException {
|
||||||
FawePlayer fp = FawePlayer.wrap(player);
|
FawePlayer fp = FawePlayer.wrap(player);
|
||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
Region selection = fp.getSelection();
|
Region selection = fp.getSelection();
|
||||||
@ -121,7 +123,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
desc = "Get the light at a position"
|
desc = "Get the light at a position"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.fix")
|
@CommandPermissions("worldedit.light.fix")
|
||||||
public void getlighting(Player player, EditSession editSession) throws WorldEditException {
|
public void getLighting(Player player, EditSession editSession) throws WorldEditException {
|
||||||
FawePlayer fp = FawePlayer.wrap(player);
|
FawePlayer fp = FawePlayer.wrap(player);
|
||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
int block = editSession.getBlockLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
int block = editSession.getBlockLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||||
@ -134,7 +136,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
desc = "Removing lighting in a selection"
|
desc = "Removing lighting in a selection"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.remove")
|
@CommandPermissions("worldedit.light.remove")
|
||||||
public void removelighting(Player player) {
|
public void removeLighting(Player player) {
|
||||||
FawePlayer fp = FawePlayer.wrap(player);
|
FawePlayer fp = FawePlayer.wrap(player);
|
||||||
Region selection = fp.getSelection();
|
Region selection = fp.getSelection();
|
||||||
if (selection == null) {
|
if (selection == null) {
|
||||||
@ -190,7 +192,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.line")
|
@CommandPermissions("worldedit.region.line")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public int line(Player player, EditSession editSession,
|
public int line(Actor actor, EditSession editSession,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Arg(desc = "The pattern of blocks to place")
|
@Arg(desc = "The pattern of blocks to place")
|
||||||
Pattern pattern,
|
Pattern pattern,
|
||||||
@ -199,7 +201,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
@Switch(name = 'h', desc = "Generate only a shell")
|
@Switch(name = 'h', desc = "Generate only a shell")
|
||||||
boolean shell) throws WorldEditException {
|
boolean shell) throws WorldEditException {
|
||||||
if (!(region instanceof CuboidRegion)) {
|
if (!(region instanceof CuboidRegion)) {
|
||||||
player.printError("//line only works with cuboid selections");
|
actor.printError("//line only works with cuboid selections");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||||
@ -209,7 +211,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
BlockVector3 pos2 = cuboidregion.getPos2();
|
BlockVector3 pos2 = cuboidregion.getPos2();
|
||||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
||||||
|
|
||||||
BBC.VISITOR_BLOCK.send(player, blocksChanged);
|
BBC.VISITOR_BLOCK.send(actor, blocksChanged);
|
||||||
return blocksChanged;
|
return blocksChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,11 +342,11 @@ public class RegionCommands extends MethodCommands {
|
|||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.region.center")
|
@CommandPermissions("worldedit.region.center")
|
||||||
public void center(Player player, EditSession editSession, @Selection Region region,
|
public void center(Actor actor, EditSession editSession, @Selection Region region,
|
||||||
@Arg(desc = "The pattern of blocks to set")
|
@Arg(desc = "The pattern of blocks to set")
|
||||||
Pattern pattern) throws WorldEditException {
|
Pattern pattern) throws WorldEditException {
|
||||||
int affected = editSession.center(region, pattern);
|
int affected = editSession.center(region, pattern);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(actor, affected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -458,18 +460,11 @@ public class RegionCommands extends MethodCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/move",
|
name = "/move",
|
||||||
desc = "Move the contents of the selection",
|
desc = "Move the contents of the selection"
|
||||||
descFooter =
|
)
|
||||||
"Moves the contents of the selection.\n" +
|
|
||||||
"The -s flag shifts the selection to the target location.\n" +
|
|
||||||
"The -b also copies biomes\n" +
|
|
||||||
"The -e ignores entities\n" +
|
|
||||||
"The -a ignores air blocks.\n" +
|
|
||||||
"Optionally fills the old location with <leave-id>."
|
|
||||||
)
|
|
||||||
@CommandPermissions("worldedit.region.move")
|
@CommandPermissions("worldedit.region.move")
|
||||||
@Logging(ORIENTATION_REGION)
|
@Logging(ORIENTATION_REGION)
|
||||||
public void move(FawePlayer player, EditSession editSession, LocalSession session,
|
public void move(FawePlayer player, World world, EditSession editSession, LocalSession session,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Arg(desc = "# of blocks to move", def = "1")
|
@Arg(desc = "# of blocks to move", def = "1")
|
||||||
int count,
|
int count,
|
||||||
@ -482,23 +477,21 @@ public class RegionCommands extends MethodCommands {
|
|||||||
boolean moveSelection,
|
boolean moveSelection,
|
||||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||||
boolean ignoreAirBlocks,
|
boolean ignoreAirBlocks,
|
||||||
@Switch(name = 'b', desc = "TODO")
|
@Switch(name = 'b', desc = "Copy Biomes")
|
||||||
boolean copyBiomes,
|
boolean copyBiomes,
|
||||||
@Switch(name = 'e', desc = "TODO")
|
@Switch(name = 'e', desc = "Ignore entities")
|
||||||
boolean skipEntities,
|
boolean skipEntities,
|
||||||
@Switch(name = 'a', desc = "TODO")
|
|
||||||
boolean skipAir,
|
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
InjectedValueAccess context) throws WorldEditException {
|
||||||
checkCommandArgument(count >= 1, "Count must be >= 1");
|
checkCommandArgument(count >= 1, "Count must be >= 1");
|
||||||
player.checkConfirmationRegion(() -> {
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected = editSession.moveRegion(region, direction, count, !skipAir, !skipEntities, copyBiomes, replace);
|
int affected = editSession.moveRegion(region, direction, count, !ignoreAirBlocks, !skipEntities, copyBiomes, replace);
|
||||||
|
|
||||||
if (moveSelection) {
|
if (moveSelection) {
|
||||||
try {
|
try {
|
||||||
region.shift(direction.multiply(count));
|
region.shift(direction.multiply(count));
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(world).learnChanges();
|
||||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
session.getRegionSelector(world).explainRegionAdjust(player.getPlayer(), session);
|
||||||
} catch (RegionOperationException e) {
|
} catch (RegionOperationException e) {
|
||||||
player.printError(e.getMessage());
|
player.printError(e.getMessage());
|
||||||
}
|
}
|
||||||
@ -533,7 +526,7 @@ public class RegionCommands extends MethodCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.stack")
|
@CommandPermissions("worldedit.region.stack")
|
||||||
@Logging(ORIENTATION_REGION)
|
@Logging(ORIENTATION_REGION)
|
||||||
public void stack(FawePlayer player, EditSession editSession, LocalSession session,
|
public void stack(FawePlayer player, World world, EditSession editSession, LocalSession session,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Arg(desc = "# of copies to stack", def = "1")
|
@Arg(desc = "# of copies to stack", def = "1")
|
||||||
int count,
|
int count,
|
||||||
@ -542,11 +535,15 @@ public class RegionCommands extends MethodCommands {
|
|||||||
BlockVector3 direction,
|
BlockVector3 direction,
|
||||||
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
|
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
|
||||||
boolean moveSelection,
|
boolean moveSelection,
|
||||||
@Switch(name = 'b', desc = "//TODO") boolean copyBiomes,
|
@Switch(name = 'b', desc = "Copy Biomes")
|
||||||
@Switch(name = 'e', desc = "//TODO") boolean skipEntities,
|
boolean copyBiomes,
|
||||||
|
@Switch(name = 'e', desc = "Skip entities")
|
||||||
|
boolean skipEntities,
|
||||||
@Switch(name = 'a', desc = "Ignore air blocks")
|
@Switch(name = 'a', desc = "Ignore air blocks")
|
||||||
boolean ignoreAirBlocks,
|
boolean ignoreAirBlocks,
|
||||||
@Switch(name = 'm', desc = "TODO") Mask sourceMask, InjectedValueAccess context) throws WorldEditException {
|
@Switch(name = 'm', desc = "TODO")
|
||||||
|
Mask sourceMask,
|
||||||
|
InjectedValueAccess context) throws WorldEditException {
|
||||||
player.checkConfirmationStack(() -> {
|
player.checkConfirmationStack(() -> {
|
||||||
if (sourceMask != null) {
|
if (sourceMask != null) {
|
||||||
editSession.addSourceMask(sourceMask);
|
editSession.addSourceMask(sourceMask);
|
||||||
@ -555,14 +552,15 @@ public class RegionCommands extends MethodCommands {
|
|||||||
|
|
||||||
if (moveSelection) {
|
if (moveSelection) {
|
||||||
try {
|
try {
|
||||||
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint());
|
||||||
final BlockVector3 shiftVector = BlockVector3.at(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count);
|
|
||||||
|
final BlockVector3 shiftVector = direction.toVector3().multiply(count * (Math.abs(direction.dot(size)) + 1)).toBlockPoint();
|
||||||
region.shift(shiftVector);
|
region.shift(shiftVector);
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(world).learnChanges();
|
||||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
|
session.getRegionSelector(world).explainRegionAdjust(player.getPlayer(), session);
|
||||||
} catch (RegionOperationException e) {
|
} catch (RegionOperationException e) {
|
||||||
player.sendMessage(e.getMessage());
|
player.toWorldEditPlayer().printError(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,11 +668,12 @@ public class RegionCommands extends MethodCommands {
|
|||||||
public void hollow(FawePlayer player, EditSession editSession,
|
public void hollow(FawePlayer player, EditSession editSession,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Arg(desc = "Thickness of the shell to leave", def = "0")
|
@Arg(desc = "Thickness of the shell to leave", def = "0")
|
||||||
@Range(min = 0) int thickness,
|
int thickness,
|
||||||
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
||||||
Pattern pattern,
|
Pattern pattern,
|
||||||
@Switch(name = 'm', desc = "Mask to hollow with") Mask mask,
|
@Switch(name = 'm', desc = "Mask to hollow with") Mask mask,
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
InjectedValueAccess context) throws WorldEditException {
|
||||||
|
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||||
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
|
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
|
||||||
player.checkConfirmationRegion(() -> {
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
|
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
|
||||||
@ -688,14 +687,15 @@ public class RegionCommands extends MethodCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.forest")
|
@CommandPermissions("worldedit.region.forest")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void forest(Player player, EditSession editSession, @Selection Region region,
|
public int forest(Actor actor, EditSession editSession, @Selection Region region,
|
||||||
@Arg(desc = "The type of tree to place", def = "tree")
|
@Arg(desc = "The type of tree to place", def = "tree")
|
||||||
TreeType type,
|
TreeType type,
|
||||||
@Arg(desc = "The density of the forest", def = "5")
|
@Arg(desc = "The density of the forest", def = "5")
|
||||||
double density) throws WorldEditException {
|
double density) throws WorldEditException {
|
||||||
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
|
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
|
||||||
int affected = editSession.makeForest(region, density / 100, type);
|
int affected = editSession.makeForest(region, density / 100, type);
|
||||||
BBC.COMMAND_TREE.send(player, affected);
|
BBC.COMMAND_TREE.send(actor, affected);
|
||||||
|
return affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -201,7 +201,7 @@ public class SchematicCommands {
|
|||||||
desc = "Load a schematic into your clipboard"
|
desc = "Load a schematic into your clipboard"
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.asset", "worldedit.schematic.load.web", "worldedit.schematic.load.other"})
|
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.asset", "worldedit.schematic.load.web", "worldedit.schematic.load.other"})
|
||||||
public void load(Player player, LocalSession session,
|
public void load(Actor actor, LocalSession session,
|
||||||
@Arg(desc = "File name.")
|
@Arg(desc = "File name.")
|
||||||
String filename,
|
String filename,
|
||||||
@Arg(desc = "Format name.", def = "sponge")
|
@Arg(desc = "Format name.", def = "sponge")
|
||||||
@ -213,8 +213,8 @@ public class SchematicCommands {
|
|||||||
try {
|
try {
|
||||||
URI uri;
|
URI uri;
|
||||||
if (filename.startsWith("url:")) {
|
if (filename.startsWith("url:")) {
|
||||||
if (!player.hasPermission("worldedit.schematic.load.web")) {
|
if (!actor.hasPermission("worldedit.schematic.load.web")) {
|
||||||
BBC.NO_PERM.send(player, "worldedit.schematic.load.web");
|
BBC.NO_PERM.send(actor, "worldedit.schematic.load.web");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID uuid = UUID.fromString(filename.substring(4));
|
UUID uuid = UUID.fromString(filename.substring(4));
|
||||||
@ -225,7 +225,7 @@ public class SchematicCommands {
|
|||||||
uri = url.toURI();
|
uri = url.toURI();
|
||||||
} else {
|
} else {
|
||||||
File saveDir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
File saveDir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(saveDir, player.getUniqueId().toString()) : saveDir;
|
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(saveDir, actor.getUniqueId().toString()) : saveDir;
|
||||||
File file;
|
File file;
|
||||||
if (filename.startsWith("#")) {
|
if (filename.startsWith("#")) {
|
||||||
String[] extensions;
|
String[] extensions;
|
||||||
@ -234,14 +234,14 @@ public class SchematicCommands {
|
|||||||
} else {
|
} else {
|
||||||
extensions = ClipboardFormats.getFileExtensionArray();
|
extensions = ClipboardFormats.getFileExtensionArray();
|
||||||
}
|
}
|
||||||
file = player.openFileOpenDialog(extensions);
|
file = actor.openFileOpenDialog(extensions);
|
||||||
if (file == null || !file.exists()) {
|
if (file == null || !file.exists()) {
|
||||||
player.printError("Schematic " + filename + " does not exist! (" + file + ")");
|
actor.printError("Schematic " + filename + " does not exist! (" + file + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !player.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) {
|
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) {
|
||||||
BBC.NO_PERM.send(player, "worldedit.schematic.load.other");
|
BBC.NO_PERM.send(actor, "worldedit.schematic.load.other");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (format == null && filename.matches(".*\\.[\\w].*")) {
|
if (format == null && filename.matches(".*\\.[\\w].*")) {
|
||||||
@ -257,25 +257,25 @@ public class SchematicCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file == null || !file.exists() || !MainUtil.isInSubDirectory(saveDir, file)) {
|
if (file == null || !file.exists() || !MainUtil.isInSubDirectory(saveDir, file)) {
|
||||||
player.printError("Schematic " + filename + " does not exist! (" + (file != null && file.exists()) + "|" + file + "|" + (file != null && !MainUtil.isInSubDirectory(saveDir, file)) + ")");
|
actor.printError("Schematic " + filename + " does not exist! (" + (file != null && file.exists()) + "|" + file + "|" + (file != null && !MainUtil.isInSubDirectory(saveDir, file)) + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
format = ClipboardFormats.findByFile(file);
|
format = ClipboardFormats.findByFile(file);
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
BBC.CLIPBOARD_INVALID_FORMAT.send(player, file.getName());
|
BBC.CLIPBOARD_INVALID_FORMAT.send(actor, file.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in = new FileInputStream(file);
|
in = new FileInputStream(file);
|
||||||
uri = file.toURI();
|
uri = file.toURI();
|
||||||
}
|
}
|
||||||
format.hold(player, uri, in);
|
format.hold(actor, uri, in);
|
||||||
BBC.SCHEMATIC_LOADED.send(player, filename);
|
BBC.SCHEMATIC_LOADED.send(actor, filename);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
player.printError("Unknown filename: " + filename);
|
actor.printError("Unknown filename: " + filename);
|
||||||
} catch (URISyntaxException | IOException e) {
|
} catch (URISyntaxException | IOException e) {
|
||||||
player.printError("File could not be read or it does not exist: " + e.getMessage());
|
actor.printError("File could not be read or it does not exist: " + e.getMessage());
|
||||||
log.warn("Failed to load a saved clipboard", e);
|
log.warn("Failed to load a saved clipboard", e);
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
|
@ -19,21 +19,20 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.clipboard.io;
|
package com.sk89q.worldedit.extent.clipboard.io;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||||
import com.boydti.fawe.object.schematic.Schematic;
|
import com.boydti.fawe.object.schematic.Schematic;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -111,8 +110,8 @@ public interface ClipboardFormat {
|
|||||||
* @param in
|
* @param in
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
default URIClipboardHolder hold(Player player, URI uri, InputStream in) throws IOException {
|
default URIClipboardHolder hold(Actor actor, URI uri, InputStream in) throws IOException {
|
||||||
checkNotNull(player);
|
checkNotNull(actor);
|
||||||
checkNotNull(uri);
|
checkNotNull(uri);
|
||||||
checkNotNull(in);
|
checkNotNull(in);
|
||||||
|
|
||||||
@ -120,9 +119,9 @@ public interface ClipboardFormat {
|
|||||||
|
|
||||||
final Clipboard clipboard;
|
final Clipboard clipboard;
|
||||||
|
|
||||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
|
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
clipboard = reader.read(player.getUniqueId());
|
clipboard = reader.read(actor.getUniqueId());
|
||||||
URIClipboardHolder holder = new URIClipboardHolder(uri, clipboard);
|
URIClipboardHolder holder = new URIClipboardHolder(uri, clipboard);
|
||||||
session.setClipboard(holder);
|
session.setClipboard(holder);
|
||||||
return holder;
|
return holder;
|
||||||
|
@ -47,7 +47,7 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object evaluate(String script, String filename, Map<String, Object> args)
|
public Object evaluate(String script, String filename, Map<String, Object> args)
|
||||||
throws Throwable {
|
throws ScriptException, Throwable {
|
||||||
RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
|
RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
|
||||||
Context cx = factory.enterContext();
|
Context cx = factory.enterContext();
|
||||||
ScriptableObject scriptable = new ImporterTopLevel(cx);
|
ScriptableObject scriptable = new ImporterTopLevel(cx);
|
||||||
|
@ -120,13 +120,15 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
|
|||||||
public ScriptEngineFactory getFactory() {
|
public ScriptEngineFactory getFactory() {
|
||||||
if (factory != null) {
|
if (factory != null) {
|
||||||
return factory;
|
return factory;
|
||||||
|
} else {
|
||||||
|
return new RhinoScriptEngineFactory();
|
||||||
}
|
}
|
||||||
return new RhinoScriptEngineFactory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Scriptable setupScope(Context cx, ScriptContext context) {
|
private Scriptable setupScope(Context cx, ScriptContext context) {
|
||||||
ScriptableObject scriptable = new ImporterTopLevel(cx);
|
ScriptableObject scriptable = new ImporterTopLevel(cx);
|
||||||
|
Scriptable scope = cx.initStandardObjects(scriptable);
|
||||||
//ScriptableObject.putProperty(scope, "argv", Context.javaToJS(args, scope));
|
//ScriptableObject.putProperty(scope, "argv", Context.javaToJS(args, scope));
|
||||||
return cx.initStandardObjects(scriptable);
|
return scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren