mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
feature(cli): Added a CLI version of WorldEdit, and allowed most commands to be run from console (#508)
* Re-do commits to avoid awful rebase * You can load and save a schematic file now. Still gotta setup ability to use commands as a console actor. * Add a world override concept to LocalSession, and allow a lot more commands to be performed by actors. * Fixed commands, and set the loaded schematic as the world override in CLI * Properly load tags * Added 1.14.4 data values * Allow a majority of commands to be performed by the console. * Fixed a lot of PR requested changes * Added a Locatable interface and use that for getting the location of the player in commands. * Added script support. Currently requires a newline at the end of the script. * Shade everything to allow this to run locally - should probably minimize this to an extent later. * Actually hook up the version * Added a //world command to set the override * Fixed a missed checkstyle issue * Added CommandBlock support to Bukkit * Make command block support configurable * Minor cleanup and implementing a few of the final functions * Fixed most issues from PR * Improve UX, saving is now automatic and unknown command messages show * Better save docs and support any clipboard format * Include the entire formats list * Arrays.copyOf * Clear the world override if the selector is called on another world. * Update logging extent to allow basic logging with non-player actors
This commit is contained in:
33
worldedit-cli/build.gradle.kts
Normal file
33
worldedit-cli/build.gradle.kts
Normal file
@ -0,0 +1,33 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
applyPlatformAndCoreConfiguration()
|
||||
applyShadowConfiguration()
|
||||
|
||||
dependencies {
|
||||
"compile"(project(":worldedit-core"))
|
||||
"compile"("org.apache.logging.log4j:log4j-core:2.8.1")
|
||||
"compile"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||
"compile"("commons-cli:commons-cli:1.4")
|
||||
}
|
||||
|
||||
tasks.named<Jar>("jar") {
|
||||
manifest {
|
||||
attributes(
|
||||
"Implementation-Version" to project.version,
|
||||
"Main-Class" to "com.sk89q.worldedit.cli.CLIWorldEdit"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
dependencies {
|
||||
include { true }
|
||||
}
|
||||
minimize {
|
||||
exclude { true }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("assemble").configure {
|
||||
dependsOn("shadowJar")
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BlockCategoryRegistry;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CLIBlockCategoryRegistry implements BlockCategoryRegistry {
|
||||
|
||||
@Override
|
||||
public Set<BlockType> getCategorisedByName(String category) {
|
||||
return CLIWorldEdit.inst.getFileRegistries().getDataFile().blocktags.getOrDefault(category, Collections.emptyList()).stream()
|
||||
.map(BlockType.REGISTRY::get)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.worldedit.cli.data.FileRegistries;
|
||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||
import com.sk89q.worldedit.registry.state.EnumProperty;
|
||||
import com.sk89q.worldedit.registry.state.IntegerProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CLIBlockRegistry extends BundledBlockRegistry {
|
||||
|
||||
private Property<?> createProperty(String type, String key, List<String> values) {
|
||||
switch (type) {
|
||||
case "int": {
|
||||
List<Integer> fixedValues = values.stream().map(Integer::parseInt).collect(Collectors.toList());
|
||||
return new IntegerProperty(key, fixedValues);
|
||||
}
|
||||
case "bool": {
|
||||
List<Boolean> fixedValues = values.stream().map(Boolean::parseBoolean).collect(Collectors.toList());
|
||||
return new BooleanProperty(key, fixedValues);
|
||||
}
|
||||
case "enum": {
|
||||
return new EnumProperty(key, values);
|
||||
}
|
||||
case "direction": {
|
||||
List<Direction> fixedValues = values.stream().map(String::toUpperCase).map(Direction::valueOf).collect(Collectors.toList());
|
||||
return new DirectionalProperty(key, fixedValues);
|
||||
}
|
||||
default:
|
||||
throw new RuntimeException("Failed to create property");
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||
Map<String, FileRegistries.BlockProperty> properties =
|
||||
CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.getId()).properties;
|
||||
return ImmutableMap.copyOf(Maps.transformEntries(properties,
|
||||
(Maps.EntryTransformer<String, FileRegistries.BlockProperty, Property<?>>)
|
||||
(key, value) -> createProperty(value.type, key, value.values)));
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.FileDialogUtil;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.serializer.plain.PlainComponentSerializer;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CLICommandSender implements Actor {
|
||||
|
||||
/**
|
||||
* One time generated ID.
|
||||
*/
|
||||
private static final UUID DEFAULT_ID = UUID.fromString("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be");
|
||||
|
||||
private final CLIWorldEdit app;
|
||||
private final Logger sender;
|
||||
|
||||
public CLICommandSender(CLIWorldEdit app, Logger sender) {
|
||||
checkNotNull(app);
|
||||
checkNotNull(sender);
|
||||
|
||||
this.app = app;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return DEFAULT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Console";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.info(part);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String ANSI_PURPLE = "\u001B[35m";
|
||||
private static final String ANSI_RED = "\u001B[31m";
|
||||
private static final String ANSI_GREEN = "\u001B[32m";
|
||||
private static final String ANSI_RESET = "\u001B[0m";
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.info(ANSI_PURPLE + part + ANSI_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.debug(ANSI_GREEN + part + ANSI_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
sender.error(ANSI_RED + part + ANSI_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
print(PlainComponentSerializer.INSTANCE.serialize(component));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDestroyBedrock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkPermission(String permission) throws AuthorizationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File openFileOpenDialog(String[] extensions) {
|
||||
return FileDialogUtil.showOpenDialog(extensions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File openFileSaveDialog(String[] extensions) {
|
||||
return FileDialogUtil.showSaveDialog(extensions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
return new SessionKey() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Console";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPersistent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return DEFAULT_ID;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import com.sk89q.worldedit.util.PropertiesConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CLIConfiguration extends PropertiesConfiguration {
|
||||
|
||||
public CLIConfiguration(CLIWorldEdit app) {
|
||||
super(app.getWorkingDir().resolve("worldedit.properties").toFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadExtra() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorkingDirectory() {
|
||||
return CLIWorldEdit.inst.getWorkingDir().toFile();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.registry.ItemCategoryRegistry;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CLIItemCategoryRegistry implements ItemCategoryRegistry {
|
||||
|
||||
@Override
|
||||
public Set<ItemType> getCategorisedByName(String category) {
|
||||
return CLIWorldEdit.inst.getFileRegistries().getDataFile().itemtags.get(category).stream()
|
||||
.map(ItemType.REGISTRY::get)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.AbstractPlatform;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Preference;
|
||||
import com.sk89q.worldedit.world.DataFixer;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import com.sk89q.worldedit.world.registry.Registries;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
class CLIPlatform extends AbstractPlatform {
|
||||
|
||||
private final CLIWorldEdit app;
|
||||
private int dataVersion = -1;
|
||||
|
||||
private final List<World> worlds = new ArrayList<>();
|
||||
private final Timer timer = new Timer();
|
||||
private int lastTimerId = 0;
|
||||
|
||||
CLIPlatform(CLIWorldEdit app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Registries getRegistries() {
|
||||
return CLIRegistries.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDataVersion() {
|
||||
return this.dataVersion;
|
||||
}
|
||||
|
||||
public void setDataVersion(int dataVersion) {
|
||||
this.dataVersion = dataVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataFixer getDataFixer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidMobType(String type) {
|
||||
return EntityTypes.get(type) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
getConfiguration().load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int schedule(long delay, long period, Runnable task) {
|
||||
this.timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
task.run();
|
||||
if (period >= 0) {
|
||||
timer.schedule(this, period);
|
||||
}
|
||||
}
|
||||
}, delay);
|
||||
return this.lastTimerId++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends World> getWorlds() {
|
||||
return this.worlds;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Player matchPlayer(Player player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public World matchWorld(World world) {
|
||||
return this.worlds.stream()
|
||||
.filter(w -> w.getId().equals(world.getId()))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCommands(CommandManager manager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGameHooks() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLIConfiguration getConfiguration() {
|
||||
return app.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return app.getInternalVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "CLI-Official";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformVersion() {
|
||||
return app.getInternalVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Capability, Preference> getCapabilities() {
|
||||
Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class);
|
||||
capabilities.put(Capability.CONFIGURATION, Preference.PREFER_OTHERS);
|
||||
capabilities.put(Capability.GAME_HOOKS, Preference.NORMAL);
|
||||
capabilities.put(Capability.PERMISSIONS, Preference.NORMAL);
|
||||
capabilities.put(Capability.USER_COMMANDS, Preference.NORMAL);
|
||||
capabilities.put(Capability.WORLD_EDITING, Preference.PREFERRED);
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
public void addWorld(World world) {
|
||||
worlds.add(world);
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import com.sk89q.worldedit.world.registry.BlockCategoryRegistry;
|
||||
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
||||
import com.sk89q.worldedit.world.registry.BundledRegistries;
|
||||
import com.sk89q.worldedit.world.registry.ItemCategoryRegistry;
|
||||
|
||||
public class CLIRegistries extends BundledRegistries {
|
||||
|
||||
private static final CLIRegistries INSTANCE = new CLIRegistries();
|
||||
private final BlockRegistry blockRegistry = new CLIBlockRegistry();
|
||||
private final BlockCategoryRegistry blockCategoryRegistry = new CLIBlockCategoryRegistry();
|
||||
private final ItemCategoryRegistry itemCategoryRegistry = new CLIItemCategoryRegistry();
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
private CLIRegistries() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRegistry getBlockRegistry() {
|
||||
return blockRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCategoryRegistry getBlockCategoryRegistry() {
|
||||
return blockCategoryRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCategoryRegistry getItemCategoryRegistry() {
|
||||
return itemCategoryRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a static instance.
|
||||
*
|
||||
* @return an instance
|
||||
*/
|
||||
public static CLIRegistries getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
public interface CLIWorld {
|
||||
|
||||
/**
|
||||
* Saves this world back to file if dirty or forced.
|
||||
*
|
||||
* @param force Force a save
|
||||
*/
|
||||
void save(boolean force);
|
||||
|
||||
/**
|
||||
* Gets whether the world is dirty.
|
||||
*
|
||||
* @return If it's dirty
|
||||
*/
|
||||
boolean isDirty();
|
||||
|
||||
/**
|
||||
* Set the world's dirty status
|
||||
*
|
||||
* @param dirty if dirty
|
||||
*/
|
||||
void setDirty(boolean dirty);
|
||||
}
|
@ -0,0 +1,335 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.cli.data.FileRegistries;
|
||||
import com.sk89q.worldedit.cli.schematic.ClipboardWorld;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.item.ItemCategory;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.SequenceInputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* The CLI implementation of WorldEdit.
|
||||
*/
|
||||
public class CLIWorldEdit {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CLIWorldEdit.class);
|
||||
|
||||
public static CLIWorldEdit inst;
|
||||
|
||||
private CLIPlatform platform;
|
||||
private CLIConfiguration config;
|
||||
private Path workingDir;
|
||||
private String version;
|
||||
|
||||
private Actor commandSender;
|
||||
|
||||
private FileRegistries fileRegistries;
|
||||
|
||||
public CLIWorldEdit() {
|
||||
inst = this;
|
||||
}
|
||||
|
||||
private void setupPlatform() {
|
||||
this.fileRegistries = new FileRegistries(this);
|
||||
this.fileRegistries.loadDataFiles();
|
||||
|
||||
WorldEdit.getInstance().getPlatformManager().register(platform);
|
||||
}
|
||||
|
||||
public void setupRegistries() {
|
||||
// Blocks
|
||||
for (Map.Entry<String, FileRegistries.BlockManifest> manifestEntry : fileRegistries.getDataFile().blocks.entrySet()) {
|
||||
if (BlockType.REGISTRY.get(manifestEntry.getKey()) == null) {
|
||||
BlockType.REGISTRY.register(manifestEntry.getKey(), new BlockType(manifestEntry.getKey(), input -> {
|
||||
ParserContext context = new ParserContext();
|
||||
context.setPreferringWildcard(true);
|
||||
context.setTryLegacy(false);
|
||||
context.setRestricted(false);
|
||||
try {
|
||||
FuzzyBlockState state = (FuzzyBlockState) WorldEdit.getInstance().getBlockFactory().parseFromInput(
|
||||
manifestEntry.getValue().defaultstate,
|
||||
context
|
||||
).toImmutableState();
|
||||
BlockState defaultState = input.getBlockType().getAllStates().get(0);
|
||||
for (Map.Entry<Property<?>, Object> propertyObjectEntry : state.getStates().entrySet()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Property<Object> prop = (Property<Object>) propertyObjectEntry.getKey();
|
||||
defaultState = defaultState.with(prop, propertyObjectEntry.getValue());
|
||||
}
|
||||
return defaultState;
|
||||
} catch (InputParseException e) {
|
||||
LOGGER.warn("Error loading block state for " + manifestEntry.getKey(), e);
|
||||
return input;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
// Items
|
||||
for (String name : fileRegistries.getDataFile().items) {
|
||||
if (ItemType.REGISTRY.get(name) == null) {
|
||||
ItemType.REGISTRY.register(name, new ItemType(name));
|
||||
}
|
||||
}
|
||||
// Entities
|
||||
for (String name : fileRegistries.getDataFile().entities) {
|
||||
if (EntityType.REGISTRY.get(name) == null) {
|
||||
EntityType.REGISTRY.register(name, new EntityType(name));
|
||||
}
|
||||
}
|
||||
// Biomes
|
||||
for (String name : fileRegistries.getDataFile().biomes) {
|
||||
if (BiomeType.REGISTRY.get(name) == null) {
|
||||
BiomeType.REGISTRY.register(name, new BiomeType(name));
|
||||
}
|
||||
}
|
||||
// Tags
|
||||
for (String name : fileRegistries.getDataFile().blocktags.keySet()) {
|
||||
if (BlockCategory.REGISTRY.get(name) == null) {
|
||||
BlockCategory.REGISTRY.register(name, new BlockCategory(name));
|
||||
}
|
||||
}
|
||||
for (String name : fileRegistries.getDataFile().itemtags.keySet()) {
|
||||
if (ItemCategory.REGISTRY.get(name) == null) {
|
||||
ItemCategory.REGISTRY.register(name, new ItemCategory(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onInitialized() {
|
||||
// Setup working directory
|
||||
workingDir = Paths.get("worldedit");
|
||||
if (!Files.exists(workingDir)) {
|
||||
try {
|
||||
Files.createDirectory(workingDir);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
this.commandSender = new CLICommandSender(this, LOGGER);
|
||||
this.platform = new CLIPlatform(this);
|
||||
LOGGER.info("WorldEdit CLI (version " + getInternalVersion() + ") is loaded");
|
||||
}
|
||||
|
||||
public void onStarted() {
|
||||
setupPlatform();
|
||||
|
||||
setupRegistries();
|
||||
WorldEdit.getInstance().loadMappings();
|
||||
|
||||
config = new CLIConfiguration(this);
|
||||
config.load();
|
||||
|
||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
||||
}
|
||||
|
||||
public void onStopped() {
|
||||
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||
worldEdit.getSessionManager().unload();
|
||||
worldEdit.getPlatformManager().unregister(platform);
|
||||
}
|
||||
|
||||
public FileRegistries getFileRegistries() {
|
||||
return this.fileRegistries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration.
|
||||
*
|
||||
* @return the CLI configuration
|
||||
*/
|
||||
CLIConfiguration getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WorldEdit proxy for the platform.
|
||||
*
|
||||
* @return the WorldEdit platform
|
||||
*/
|
||||
public Platform getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the working directory where WorldEdit's files are stored.
|
||||
*
|
||||
* @return the working directory
|
||||
*/
|
||||
public Path getWorkingDir() {
|
||||
return this.workingDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version of the WorldEdit-CLI implementation.
|
||||
*
|
||||
* @return a version string
|
||||
*/
|
||||
String getInternalVersion() {
|
||||
if (version == null) {
|
||||
version = getClass().getPackage().getImplementationVersion();
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
public void saveAllWorlds(boolean force) {
|
||||
platform.getWorlds().stream()
|
||||
.filter(world -> world instanceof CLIWorld)
|
||||
.forEach(world -> ((CLIWorld) world).save(force));
|
||||
}
|
||||
|
||||
public void run(InputStream inputStream) {
|
||||
try (Scanner scanner = new Scanner(inputStream)) {
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
if (line.equals("stop")) {
|
||||
commandSender.print("Stopping!");
|
||||
break;
|
||||
}
|
||||
CommandEvent event = new CommandEvent(commandSender, line);
|
||||
WorldEdit.getInstance().getEventBus().post(event);
|
||||
if (!event.isCancelled()) {
|
||||
commandSender.printError("Unknown command!");
|
||||
} else {
|
||||
saveAllWorlds(false);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
saveAllWorlds(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Options options = new Options();
|
||||
options.addOption("f", "file", true, "The file to load in. Either a schematic, or a level.dat in a world folder.");
|
||||
options.addOption("s", "script", true, "A file containing a list of commands to run. Newline separated.");
|
||||
int exitCode = 0;
|
||||
|
||||
CLIWorldEdit app = new CLIWorldEdit();
|
||||
app.onInitialized();
|
||||
|
||||
InputStream inputStream = System.in;
|
||||
|
||||
try {
|
||||
CommandLine cmd = new DefaultParser().parse(options, args);
|
||||
|
||||
String fileArg = cmd.getOptionValue('f');
|
||||
File file;
|
||||
if (fileArg == null) {
|
||||
String[] formats = Arrays.copyOf(ClipboardFormats.getFileExtensionArray(), ClipboardFormats.getFileExtensionArray().length + 1);
|
||||
formats[formats.length - 1] = "dat";
|
||||
file = app.commandSender.openFileOpenDialog(formats);
|
||||
} else {
|
||||
file = new File(fileArg);
|
||||
}
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("A file must be provided!");
|
||||
}
|
||||
if (file.getName().endsWith("level.dat")) {
|
||||
throw new IllegalArgumentException("level.dat file support is unfinished.");
|
||||
} else {
|
||||
ClipboardFormat format = ClipboardFormats.findByFile(file);
|
||||
if (format != null) {
|
||||
ClipboardReader dataVersionReader = format
|
||||
.getReader(Files.newInputStream(file.toPath(), StandardOpenOption.READ));
|
||||
int dataVersion = dataVersionReader.getDataVersion()
|
||||
.orElseThrow(() -> new IllegalArgumentException("Failed to obtain data version from schematic."));
|
||||
dataVersionReader.close();
|
||||
app.platform.setDataVersion(dataVersion);
|
||||
app.onStarted();
|
||||
try (ClipboardReader clipboardReader = format.getReader(Files.newInputStream(file.toPath(), StandardOpenOption.READ))) {
|
||||
ClipboardWorld world = new ClipboardWorld(
|
||||
file,
|
||||
clipboardReader.read(),
|
||||
file.getName()
|
||||
);
|
||||
app.platform.addWorld(world);
|
||||
WorldEdit.getInstance().getSessionManager().get(app.commandSender).setWorldOverride(world);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown file provided!");
|
||||
}
|
||||
}
|
||||
|
||||
String scriptFile = cmd.getOptionValue('s');
|
||||
if (scriptFile != null) {
|
||||
File scriptFileHandle = new File(scriptFile);
|
||||
if (!scriptFileHandle.exists()) {
|
||||
throw new IllegalArgumentException("Could not find given script file.");
|
||||
}
|
||||
InputStream scriptStream = Files.newInputStream(scriptFileHandle.toPath(), StandardOpenOption.READ);
|
||||
InputStream newLineStream = new ByteArrayInputStream("\n".getBytes(StandardCharsets.UTF_8));
|
||||
// Cleaner to do this than make an Enumeration :(
|
||||
inputStream = new SequenceInputStream(new SequenceInputStream(scriptStream, newLineStream), inputStream);
|
||||
}
|
||||
|
||||
app.run(inputStream);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
exitCode = 1;
|
||||
} finally {
|
||||
app.onStopped();
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
System.exit(exitCode);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli.data;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.sk89q.worldedit.cli.CLIWorldEdit;
|
||||
import com.sk89q.worldedit.util.io.ResourceLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FileRegistries {
|
||||
|
||||
private CLIWorldEdit app;
|
||||
private Gson gson = new GsonBuilder().create();
|
||||
|
||||
private DataFile dataFile;
|
||||
|
||||
public FileRegistries(CLIWorldEdit app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public void loadDataFiles() {
|
||||
try {
|
||||
URL url = ResourceLoader.getResource(FileRegistries.class, app.getPlatform().getDataVersion() + ".json");
|
||||
this.dataFile = gson.fromJson(Resources.toString(url, StandardCharsets.UTF_8), DataFile.class);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("The provided file is not compatible with this version of WorldEdit-CLI. Please update or report this.");
|
||||
}
|
||||
}
|
||||
|
||||
public DataFile getDataFile() {
|
||||
return this.dataFile;
|
||||
}
|
||||
|
||||
public static class BlockManifest {
|
||||
public String defaultstate;
|
||||
public Map<String, BlockProperty> properties;
|
||||
}
|
||||
|
||||
public static class BlockProperty {
|
||||
public List<String> values;
|
||||
public String type;
|
||||
}
|
||||
|
||||
public static class DataFile {
|
||||
public Map<String, List<String>> itemtags;
|
||||
public Map<String, List<String>> blocktags;
|
||||
public Map<String, List<String>> entitytags;
|
||||
public List<String> items;
|
||||
public List<String> entities;
|
||||
public List<String> biomes;
|
||||
public Map<String, BlockManifest> blocks;
|
||||
}
|
||||
}
|
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli.schematic;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.cli.CLIWorld;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ClipboardWorld extends AbstractWorld implements Clipboard, CLIWorld {
|
||||
|
||||
private final File file;
|
||||
private final Clipboard clipboard;
|
||||
private final String name;
|
||||
|
||||
private boolean dirty = false;
|
||||
|
||||
public ClipboardWorld(File file, Clipboard clipboard, String name) {
|
||||
this.file = file;
|
||||
this.clipboard = clipboard;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight)
|
||||
throws WorldEditException {
|
||||
dirty = true;
|
||||
return clipboard.setBlock(position, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightLevel(BlockVector3 position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearContainerBlockContents(BlockVector3 position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropItem(Vector3 position, BaseItemStack item) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simulateBlockMine(BlockVector3 position) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerate(Region region, EditSession editSession) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position)
|
||||
throws MaxChangedBlocksException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getSpawnPosition() {
|
||||
return clipboard.getOrigin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
return clipboard.getEntities(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
return clipboard.getEntities();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
dirty = true;
|
||||
return clipboard.createEntity(location, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return clipboard.getBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return clipboard.getFullBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return clipboard.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
dirty = true;
|
||||
return clipboard.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region getRegion() {
|
||||
return clipboard.getRegion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getDimensions() {
|
||||
return clipboard.getDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getOrigin() {
|
||||
return clipboard.getOrigin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrigin(BlockVector3 origin) {
|
||||
clipboard.setOrigin(origin);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBiomes() {
|
||||
return clipboard.hasBiomes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return clipboard.getMaximumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return clipboard.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(boolean force) {
|
||||
if (dirty || force) {
|
||||
try (ClipboardWriter writer = ClipboardFormats.findByFile(file).getWriter(new FileOutputStream(file))) {
|
||||
writer.write(this);
|
||||
dirty = false;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return this.dirty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirty(boolean dirty) {
|
||||
this.dirty = dirty;
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,33 @@
|
||||
#Don't put comments; they get removed
|
||||
default-max-polygon-points=-1
|
||||
schematic-save-dir=schematics
|
||||
super-pickaxe-many-drop-items=true
|
||||
register-help=true
|
||||
nav-wand-item=minecraft:compass
|
||||
profile=false
|
||||
trace-unflushed-sessions=false
|
||||
super-pickaxe-drop-items=true
|
||||
disallowed-blocks=minecraft:oak_sapling,minecraft:jungle_sapling,minecraft:dark_oak_sapling,minecraft:spruce_sapling,minecraft:birch_sapling,minecraft:acacia_sapling,minecraft:black_bed,minecraft:blue_bed,minecraft:brown_bed,minecraft:cyan_bed,minecraft:gray_bed,minecraft:green_bed,minecraft:light_blue_bed,minecraft:light_gray_bed,minecraft:lime_bed,minecraft:magenta_bed,minecraft:orange_bed,minecraft:pink_bed,minecraft:purple_bed,minecraft:red_bed,minecraft:white_bed,minecraft:yellow_bed,minecraft:powered_rail,minecraft:detector_rail,minecraft:grass,minecraft:dead_bush,minecraft:moving_piston,minecraft:piston_head,minecraft:sunflower,minecraft:rose_bush,minecraft:dandelion,minecraft:poppy,minecraft:brown_mushroom,minecraft:red_mushroom,minecraft:tnt,minecraft:torch,minecraft:fire,minecraft:redstone_wire,minecraft:wheat,minecraft:potatoes,minecraft:carrots,minecraft:melon_stem,minecraft:pumpkin_stem,minecraft:beetroots,minecraft:rail,minecraft:lever,minecraft:redstone_torch,minecraft:redstone_wall_torch,minecraft:repeater,minecraft:comparator,minecraft:stone_button,minecraft:birch_button,minecraft:acacia_button,minecraft:dark_oak_button,minecraft:jungle_button,minecraft:oak_button,minecraft:spruce_button,minecraft:cactus,minecraft:sugar_cane,minecraft:bedrock
|
||||
max-super-pickaxe-size=5
|
||||
max-brush-radius=10
|
||||
craftscript-dir=craftscripts
|
||||
no-double-slash=false
|
||||
wand-item=minecraft:wooden_axe
|
||||
shell-save-type=
|
||||
scripting-timeout=3000
|
||||
snapshots-dir=
|
||||
use-inventory-creative-override=false
|
||||
log-file=worldedit.log
|
||||
log-format=[%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s]: %5$s%6$s%n
|
||||
max-changed-blocks=-1
|
||||
nav-wand-distance=50
|
||||
butcher-default-radius=-1
|
||||
default-max-changed-blocks=-1
|
||||
history-size=15
|
||||
use-inventory=false
|
||||
allow-symbolic-links=false
|
||||
use-inventory-override=false
|
||||
log-commands=false
|
||||
butcher-max-radius=-1
|
||||
max-polygon-points=20
|
||||
max-radius=-1
|
21
worldedit-cli/src/main/resources/log4j2.xml
Normal file
21
worldedit-cli/src/main/resources/log4j2.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN" packages="com.sk89q,org.enginehub">
|
||||
<Appenders>
|
||||
<Console name="SysOut" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
||||
</Console>
|
||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<OnStartupTriggeringPolicy />
|
||||
</Policies>
|
||||
</RollingRandomAccessFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="SysOut"/>
|
||||
<AppenderRef ref="File"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
Reference in New Issue
Block a user