feat(i18n): add support for translatable text replacement (#478)
* Rebase translation work for easier rebasing * Fixed gradle setup * Further translations * Add a few more strings * Remove support for pluralisation to match Minecraft and alleviate issues with over-complexity * Further translations * Added a tonne more translations * Added the remaining translation nodes * When custom files are found, use the base files for default values. * Only download translations if a key is provided * Fixed typo in brush radius too large * Allow translation files to be missing entries, and use the english version in place. * Fixed issues brought up in review * Reverse translation order (#533) * Fix a lot of PR comments * Add JD to the Operation warned field due to no private fields in J8 * Only warn when there are messages
Dieser Commit ist enthalten in:
Ursprung
da2ab0293f
Commit
679b00bde6
6
.gitignore
vendored
6
.gitignore
vendored
@ -16,4 +16,8 @@ out
|
||||
run
|
||||
|
||||
/dependency-reduced-pom.xml
|
||||
*-private.sh
|
||||
*-private.sh
|
||||
|
||||
# i18n
|
||||
worldedit-core/src/main/resources/lang/*
|
||||
!worldedit-core/src/main/resources/lang/strings.json
|
||||
|
@ -53,4 +53,5 @@ dependencies {
|
||||
implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143")
|
||||
implementation("net.fabricmc:fabric-loom:$loomVersion")
|
||||
implementation("net.fabricmc:sponge-mixin:$mixinVersion")
|
||||
implementation("gradle.plugin.com.mendhak.gradlecrowdin:plugin:0.1.0")
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
|
||||
import com.sk89q.worldedit.extension.platform.Locatable;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -36,10 +37,9 @@ import org.bukkit.Material;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable {
|
||||
|
||||
private static final String UUID_PREFIX = "CMD";
|
||||
@ -94,7 +94,12 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
TextAdapter.sendComponent(sender, WorldEditText.format(component));
|
||||
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return WorldEdit.getInstance().getConfiguration().defaultLocale;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.bukkit.util.CommandInspector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -30,6 +31,7 @@ import org.enginehub.piston.inject.MapBackedValueStore;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -52,7 +54,7 @@ class BukkitCommandInspector implements CommandInspector {
|
||||
public String getShortText(Command command) {
|
||||
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
|
||||
if (mapping.isPresent()) {
|
||||
return reduceToText(mapping.get().getDescription());
|
||||
return reduceToText(mapping.get().getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale);
|
||||
} else {
|
||||
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
|
||||
return "Help text not available";
|
||||
@ -63,7 +65,7 @@ class BukkitCommandInspector implements CommandInspector {
|
||||
public String getFullText(Command command) {
|
||||
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
|
||||
if (mapping.isPresent()) {
|
||||
return reduceToText(mapping.get().getFullHelp());
|
||||
return reduceToText(mapping.get().getFullHelp(), WorldEdit.getInstance().getConfiguration().defaultLocale);
|
||||
} else {
|
||||
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
|
||||
return "Help text not available";
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
@ -31,6 +32,7 @@ import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -94,7 +96,7 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
TextAdapter.sendComponent(sender, WorldEditText.format(component));
|
||||
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,6 +113,11 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
|
||||
public void checkPermission(String permission) throws AuthorizationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return WorldEdit.getInstance().getConfiguration().defaultLocale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
return new SessionKey() {
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
@ -32,14 +33,15 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.formatting.WorldEditText;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -130,7 +132,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
TextAdapter.sendComponent(player, WorldEditText.format(component));
|
||||
TextAdapter.sendComponent(player, WorldEditText.format(component, getLocale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -216,6 +218,11 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
return player.teleport(BukkitAdapter.adapt(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return TextUtils.getLocaleByMinecraftTag(player.getLocale());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getFacet(Class<? extends T> cls) {
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit;
|
||||
import com.sk89q.bukkit.util.CommandInfo;
|
||||
import com.sk89q.bukkit.util.CommandRegistration;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
@ -43,6 +44,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@ -172,8 +174,9 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
Stream.of(command.getName()),
|
||||
command.getAliases().stream()
|
||||
).toArray(String[]::new);
|
||||
return new CommandInfo(reduceToText(command.getUsage()),
|
||||
reduceToText(command.getDescription()), aliases,
|
||||
// TODO Handle localisation correctly
|
||||
return new CommandInfo(reduceToText(command.getUsage(), WorldEdit.getInstance().getConfiguration().defaultLocale),
|
||||
reduceToText(command.getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale), aliases,
|
||||
inspector, permissionsArray);
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.cli;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
@ -32,6 +33,7 @@ import com.sk89q.worldedit.util.formatting.text.serializer.plain.PlainComponentS
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CLICommandSender implements Actor {
|
||||
@ -97,7 +99,7 @@ public class CLICommandSender implements Actor {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
print(PlainComponentSerializer.INSTANCE.serialize(WorldEditText.format(component)));
|
||||
print(PlainComponentSerializer.INSTANCE.serialize(WorldEditText.format(component, getLocale())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,6 +140,11 @@ public class CLICommandSender implements Actor {
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return WorldEdit.getInstance().getConfiguration().defaultLocale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
return new SessionKey() {
|
||||
|
@ -32,6 +32,7 @@ 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.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -237,13 +238,13 @@ public class CLIWorldEdit {
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
if (line.equals("stop")) {
|
||||
commandSender.print("Stopping!");
|
||||
commandSender.printInfo(TranslatableComponent.of("worldedit.cli.stopping"));
|
||||
break;
|
||||
}
|
||||
CommandEvent event = new CommandEvent(commandSender, line);
|
||||
WorldEdit.getInstance().getEventBus().post(event);
|
||||
if (!event.isCancelled()) {
|
||||
commandSender.printError("Unknown command!");
|
||||
commandSender.printError(TranslatableComponent.of("worldedit.cli.unknown-command"));
|
||||
} else {
|
||||
saveAllWorlds(false);
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
import net.minecrell.gradle.licenser.LicenseExtension
|
||||
import org.gradle.plugins.ide.idea.model.IdeaModel
|
||||
import com.mendhak.gradlecrowdin.DownloadTranslationsTask
|
||||
import com.mendhak.gradlecrowdin.UploadSourceFileTask
|
||||
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("net.ltgt.apt-eclipse")
|
||||
id("net.ltgt.apt-idea")
|
||||
id("antlr")
|
||||
id("com.mendhak.gradlecrowdin")
|
||||
}
|
||||
|
||||
applyPlatformAndCoreConfiguration()
|
||||
@ -84,3 +87,28 @@ sourceSets {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val crowdinApiKey = "crowdin_apikey"
|
||||
|
||||
if (project.hasProperty(crowdinApiKey)) {
|
||||
tasks.named<UploadSourceFileTask>("crowdinUpload") {
|
||||
apiKey = "${project.property(crowdinApiKey)}"
|
||||
projectId = "worldedit-core"
|
||||
files = arrayOf(
|
||||
object {
|
||||
var name = "strings.json"
|
||||
var source = "${file("src/main/resources/lang/strings.json")}"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
tasks.named<DownloadTranslationsTask>("crowdinDownload") {
|
||||
apiKey = "${project.property(crowdinApiKey)}"
|
||||
destination = "${file("build/resources/main/lang")}"
|
||||
projectId = "worldedit-core"
|
||||
}
|
||||
|
||||
tasks.named("classes").configure {
|
||||
dependsOn("crowdinDownload")
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration
|
||||
import org.enginehub.piston.util.TextHelper
|
||||
import java.util.Locale
|
||||
|
||||
fun reduceToRst(component: Component): String {
|
||||
val formatted = WorldEditText.format(component)
|
||||
val formatted = WorldEditText.format(component, Locale.US)
|
||||
return formatAsRst(formatted).toString()
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -29,6 +30,7 @@ import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@ -76,6 +78,8 @@ public abstract class LocalConfiguration {
|
||||
public boolean allowSymlinks = false;
|
||||
public boolean serverSideCUI = true;
|
||||
public boolean extendedYLimit = false;
|
||||
public String defaultLocaleName = "default";
|
||||
public Locale defaultLocale = Locale.getDefault();
|
||||
|
||||
protected String[] getDefaultDisallowedBlocks() {
|
||||
List<BlockType> blockTypes = Lists.newArrayList(
|
||||
@ -177,4 +181,12 @@ public abstract class LocalConfiguration {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void setDefaultLocaleName(String localeName) {
|
||||
this.defaultLocaleName = localeName;
|
||||
if (localeName.equals("default")) {
|
||||
this.defaultLocale = Locale.getDefault();
|
||||
} else {
|
||||
this.defaultLocale = TextUtils.getLocaleByMinecraftTag(localeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,12 +48,16 @@ import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
|
||||
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
|
||||
import com.sk89q.worldedit.util.task.SimpleSupervisor;
|
||||
import com.sk89q.worldedit.util.task.Supervisor;
|
||||
import com.sk89q.worldedit.util.translation.TranslationManager;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
@ -64,6 +68,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -108,6 +113,7 @@ public final class WorldEdit {
|
||||
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(
|
||||
EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20, "WorldEdit Task Executor - %s"));
|
||||
private final Supervisor supervisor = new SimpleSupervisor();
|
||||
private final TranslationManager translationManager = new TranslationManager(this);
|
||||
|
||||
private final BlockFactory blockFactory = new BlockFactory(this);
|
||||
private final ItemFactory itemFactory = new ItemFactory(this);
|
||||
@ -223,6 +229,15 @@ public final class WorldEdit {
|
||||
return sessions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the translation manager.
|
||||
*
|
||||
* @return the translation manager
|
||||
*/
|
||||
public TranslationManager getTranslationManager() {
|
||||
return translationManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path to a file. This method will check to see if the filename
|
||||
* has valid characters and has an extension. It also prevents directory
|
||||
@ -621,7 +636,7 @@ public final class WorldEdit {
|
||||
* @param player the player
|
||||
* @param f the script file to execute
|
||||
* @param args arguments for the script
|
||||
* @throws WorldEditException
|
||||
* @throws WorldEditException if something goes wrong
|
||||
*/
|
||||
public void runScript(Player player, File f, String[] args) throws WorldEditException {
|
||||
String filename = f.getPath();
|
||||
@ -629,7 +644,7 @@ public final class WorldEdit {
|
||||
String ext = filename.substring(index + 1);
|
||||
|
||||
if (!ext.equalsIgnoreCase("js")) {
|
||||
player.printError("Only .js scripts are currently supported");
|
||||
player.printError(TranslatableComponent.of("worldedit.script.unsupported"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -642,7 +657,7 @@ public final class WorldEdit {
|
||||
file = WorldEdit.class.getResourceAsStream("craftscripts/" + filename);
|
||||
|
||||
if (file == null) {
|
||||
player.printError("Script does not exist: " + filename);
|
||||
player.printError(TranslatableComponent.of("worldedit.script.file-not-found", TextComponent.of(filename)));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -655,7 +670,7 @@ public final class WorldEdit {
|
||||
in.close();
|
||||
script = new String(data, 0, data.length, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
player.printError("Script read error: " + e.getMessage());
|
||||
player.printError(TranslatableComponent.of("worldedit.script.read-error", TextComponent.of(e.getMessage())));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -668,8 +683,7 @@ public final class WorldEdit {
|
||||
try {
|
||||
engine = new RhinoCraftScriptEngine();
|
||||
} catch (NoClassDefFoundError ignored) {
|
||||
player.printError("Failed to find an installed script engine.");
|
||||
player.printError("Please see https://worldedit.enginehub.org/en/latest/usage/other/craftscripts/");
|
||||
player.printError(TranslatableComponent.of("worldedit.script.no-script-engine"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -683,14 +697,13 @@ public final class WorldEdit {
|
||||
try {
|
||||
engine.evaluate(script, filename, vars);
|
||||
} catch (ScriptException e) {
|
||||
player.printError("Failed to execute:");
|
||||
player.printRaw(e.getMessage());
|
||||
player.printError(TranslatableComponent.of("worldedit.script.failed", TextComponent.of(e.getMessage(), TextColor.WHITE)));
|
||||
logger.warn("Failed to execute script", e);
|
||||
} catch (NumberFormatException | WorldEditException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
player.printError("Failed to execute (see console):");
|
||||
player.printRaw(e.getClass().getCanonicalName());
|
||||
player.printError(TranslatableComponent.of("worldedit.script.failed-console", TextComponent.of(e.getClass().getCanonicalName(),
|
||||
TextColor.WHITE)));
|
||||
logger.warn("Failed to execute script", e);
|
||||
} finally {
|
||||
for (EditSession editSession : scriptContext.getEditSessions()) {
|
||||
|
@ -61,19 +61,19 @@ import static org.enginehub.piston.part.CommandParts.arg;
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class ApplyBrushCommands {
|
||||
|
||||
private static final CommandArgument REGION_FACTORY = arg(TranslatableComponent.of("shape"), TextComponent.of("The shape of the region"))
|
||||
private static final CommandArgument REGION_FACTORY = arg(TranslatableComponent.of("shape"), TranslatableComponent.of("worldedit.brush.apply.shape"))
|
||||
.defaultsTo(ImmutableList.of())
|
||||
.ofTypes(ImmutableList.of(Key.of(RegionFactory.class)))
|
||||
.build();
|
||||
|
||||
private static final CommandArgument RADIUS = arg(TranslatableComponent.of("radius"), TextComponent.of("The size of the brush"))
|
||||
private static final CommandArgument RADIUS = arg(TranslatableComponent.of("radius"), TranslatableComponent.of("worldedit.brush.apply.radius"))
|
||||
.defaultsTo(ImmutableList.of("5"))
|
||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||
.build();
|
||||
|
||||
public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) {
|
||||
commandManager.register("apply", builder -> {
|
||||
builder.description(TextComponent.of("Apply brush, apply a function to every block"));
|
||||
builder.description(TranslatableComponent.of("worldedit.brush.apply.description"));
|
||||
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
||||
|
||||
CommandManager manager = service.newCommandManager();
|
||||
@ -86,7 +86,7 @@ public class ApplyBrushCommands {
|
||||
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.apply")));
|
||||
|
||||
builder.addParts(REGION_FACTORY, RADIUS);
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TranslatableComponent.of("worldedit.brush.apply.type"))
|
||||
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||
.required()
|
||||
.build());
|
||||
@ -125,8 +125,7 @@ public class ApplyBrushCommands {
|
||||
@Direction(includeDiagonals = true)
|
||||
com.sk89q.worldedit.util.Direction direction) throws WorldEditException {
|
||||
player.print(TextComponent.builder().append("WARNING: ", TextColor.RED, TextDecoration.BOLD)
|
||||
.append("This brush simulates item usages. Its effects may not work on all platforms, may not be undo-able," +
|
||||
" and may cause strange interactions with other mods/plugins. Use at your own risk.").build());
|
||||
.append(TranslatableComponent.of("worldedit.brush.apply.item.warning")).build());
|
||||
setApplyBrush(parameters, player, localSession, new ItemUseFactory(item, direction));
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,11 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
@ -56,6 +61,7 @@ import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -100,7 +106,7 @@ public class BiomeCommands {
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
return paginationBox.create(page);
|
||||
}, null);
|
||||
}, (Component) null);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -117,24 +123,24 @@ public class BiomeCommands {
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
Set<BiomeType> biomes = new HashSet<>();
|
||||
String qualifier;
|
||||
String messageKey;
|
||||
|
||||
if (useLineOfSight) {
|
||||
Location blockPosition = player.getBlockTrace(300);
|
||||
if (blockPosition == null) {
|
||||
player.printError("No block in sight!");
|
||||
player.printError(TranslatableComponent.of("worldedit.raytrace.noblock"));
|
||||
return;
|
||||
}
|
||||
|
||||
BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at line of sight point";
|
||||
messageKey = "worldedit.biomeinfo.lineofsight";
|
||||
} else if (usePosition) {
|
||||
BiomeType biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2());
|
||||
biomes.add(biome);
|
||||
|
||||
qualifier = "at your position";
|
||||
messageKey = "worldedit.biomeinfo.position";
|
||||
} else {
|
||||
World world = player.getWorld();
|
||||
Region region = session.getSelection(world);
|
||||
@ -149,18 +155,18 @@ public class BiomeCommands {
|
||||
}
|
||||
}
|
||||
|
||||
qualifier = "in your selection";
|
||||
messageKey = "worldedit.biomeinfo.selection";
|
||||
}
|
||||
|
||||
player.print(biomes.size() != 1 ? "Biomes " + qualifier + ":" : "Biome " + qualifier + ":");
|
||||
for (BiomeType biome : biomes) {
|
||||
List<Component> components = biomes.stream().map(biome -> {
|
||||
BiomeData data = biomeRegistry.getData(biome);
|
||||
if (data != null) {
|
||||
player.print(" " + data.getName());
|
||||
return TextComponent.of(data.getName()).hoverEvent(HoverEvent.showText(TextComponent.of(biome.getId())));
|
||||
} else {
|
||||
player.print(" <unknown #" + biome.getId() + ">");
|
||||
return TextComponent.of(biome.getId());
|
||||
}
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
player.printInfo(TranslatableComponent.of(messageKey, TextUtils.join(components, TextComponent.of(", "))));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -193,7 +199,10 @@ public class BiomeCommands {
|
||||
FlatRegionVisitor visitor = new FlatRegionVisitor(Regions.asFlatRegion(region), replace);
|
||||
Operations.completeLegacy(visitor);
|
||||
|
||||
player.print("Biomes were changed in " + visitor.getAffected() + " columns. You may have to rejoin your game (or close and reopen your world) to see a change.");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.setbiome.changed",
|
||||
TextComponent.of(visitor.getAffected())
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.session.request.RequestExtent;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
@ -88,7 +90,7 @@ public class BrushCommands {
|
||||
desc = "Unbind a bound brush from your current item"
|
||||
)
|
||||
void none(Player player, LocalSession session) throws WorldEditException {
|
||||
ToolCommands.setToolNone(player, session, "Brush");
|
||||
ToolCommands.setToolNone(player, session, true);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -116,7 +118,7 @@ public class BrushCommands {
|
||||
tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
|
||||
}
|
||||
|
||||
player.print(String.format("Sphere brush shape equipped (%.0f).", radius));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.brush.sphere.equip", TextComponent.of(String.format("%.0f", radius))));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -147,7 +149,7 @@ public class BrushCommands {
|
||||
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
|
||||
}
|
||||
|
||||
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).", radius, height));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.brush.cylinder.equip", TextComponent.of((int) radius), TextComponent.of(height)));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -183,7 +185,7 @@ public class BrushCommands {
|
||||
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
tool.setBrush(new ClipboardBrush(newHolder, ignoreAir, usingOrigin, pasteEntities, pasteBiomes, sourceMask), "worldedit.brush.clipboard");
|
||||
|
||||
player.print("Clipboard brush shape equipped.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.brush.clipboard.equip"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -205,7 +207,12 @@ public class BrushCommands {
|
||||
tool.setSize(radius);
|
||||
tool.setBrush(new SmoothBrush(iterations, mask), "worldedit.brush.smooth");
|
||||
|
||||
player.print(String.format("Smooth brush equipped (%.0f x %dx, using %s).", radius, iterations, mask == null ? "any block" : "filter"));
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.brush.smooth.equip",
|
||||
TextComponent.of((int) radius),
|
||||
TextComponent.of(iterations),
|
||||
TextComponent.of(mask == null ? "any block" : "filter")
|
||||
));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -225,7 +232,7 @@ public class BrushCommands {
|
||||
tool.setMask(new BlockTypeMask(new RequestExtent(), BlockTypes.FIRE));
|
||||
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
|
||||
|
||||
player.print(String.format("Extinguisher equipped (%.0f).", radius));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.brush.extinguish.equip", TextComponent.of((int) radius)));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -245,8 +252,7 @@ public class BrushCommands {
|
||||
tool.setSize(radius);
|
||||
tool.setBrush(new GravityBrush(fromMaxY), "worldedit.brush.gravity");
|
||||
|
||||
player.print(String.format("Gravity brush equipped (%.0f).",
|
||||
radius));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.brush.gravity.equip", TextComponent.of((int) radius)));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -284,7 +290,7 @@ public class BrushCommands {
|
||||
maxRadius = Math.max(config.maxBrushRadius, config.butcherMaxRadius);
|
||||
}
|
||||
if (radius > maxRadius) {
|
||||
player.printError("Maximum allowed brush radius: " + maxRadius);
|
||||
player.printError(TranslatableComponent.of("worldedit.brush.radius-too-large", TextComponent.of(maxRadius)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -302,7 +308,7 @@ public class BrushCommands {
|
||||
tool.setSize(radius);
|
||||
tool.setBrush(new ButcherBrush(flags), "worldedit.brush.butcher");
|
||||
|
||||
player.print(String.format("Butcher brush equipped (%.0f).", radius));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.brush.butcher.equip", TextComponent.of((int) radius)));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -404,6 +410,6 @@ public class BrushCommands {
|
||||
tool.setFill(null);
|
||||
tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission);
|
||||
|
||||
player.print("Set brush to " + factory);
|
||||
player.printInfo(TranslatableComponent.of("worldedit.brush.operation.equip", TextComponent.of(factory.toString())));
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -85,9 +86,9 @@ public class ChunkCommands {
|
||||
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
|
||||
|
||||
final BlockVector2 chunkPos = BlockVector2.at(chunkX, chunkZ);
|
||||
player.print("Chunk: " + chunkX + ", " + chunkZ);
|
||||
player.print("Old format: " + LegacyChunkStore.getFilename(chunkPos));
|
||||
player.print("McRegion: region/" + McRegionChunkStore.getFilename(chunkPos));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.chunkinfo.chunk", TextComponent.of(chunkX), TextComponent.of(chunkZ)));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.chunkinfo.old-filename", TextComponent.of(LegacyChunkStore.getFilename(chunkPos))));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.chunkinfo.mcregion-filename", TextComponent.of(McRegionChunkStore.getFilename(chunkPos))));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -101,7 +102,7 @@ public class ChunkCommands {
|
||||
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor,
|
||||
() -> new ChunkListPaginationBox(region).create(page),
|
||||
"Listing chunks for " + actor.getName());
|
||||
TranslatableComponent.of("worldedit.listchunks.listfor", TextComponent.of(actor.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -45,18 +45,21 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Clipboard commands.
|
||||
*/
|
||||
@ -87,9 +90,7 @@ public class ClipboardCommands {
|
||||
Operations.completeLegacy(copy);
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
|
||||
List<String> messages = Lists.newArrayList();
|
||||
copy.addStatusMessages(messages);
|
||||
messages.forEach(actor::print);
|
||||
copy.getStatusMessages().forEach(actor::print);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -122,9 +123,7 @@ public class ClipboardCommands {
|
||||
Operations.completeLegacy(copy);
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
|
||||
List<String> messages = Lists.newArrayList();
|
||||
copy.addStatusMessages(messages);
|
||||
messages.forEach(actor::print);
|
||||
copy.getStatusMessages().forEach(actor::print);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -153,7 +152,7 @@ public class ClipboardCommands {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
Region region = clipboard.getRegion();
|
||||
List<String> messages = Lists.newArrayList();
|
||||
List<Component> messages = Lists.newArrayList();
|
||||
|
||||
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(actor);
|
||||
if (!onlySelect) {
|
||||
@ -166,7 +165,7 @@ public class ClipboardCommands {
|
||||
.maskSource(sourceMask)
|
||||
.build();
|
||||
Operations.completeLegacy(operation);
|
||||
operation.addStatusMessages(messages);
|
||||
messages.addAll(Lists.newArrayList(operation.getStatusMessages()));
|
||||
}
|
||||
|
||||
if (selectPasted || onlySelect) {
|
||||
@ -180,9 +179,9 @@ public class ClipboardCommands {
|
||||
}
|
||||
|
||||
if (onlySelect) {
|
||||
actor.print("Selected clipboard paste region.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.paste.selected"));
|
||||
} else {
|
||||
actor.print("The clipboard has been pasted at " + to);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.paste.pasted", TextComponent.of(to.toString())));
|
||||
}
|
||||
messages.forEach(actor::print);
|
||||
}
|
||||
@ -205,7 +204,7 @@ public class ClipboardCommands {
|
||||
if (Math.abs(yRotate % 90) > 0.001 ||
|
||||
Math.abs(xRotate % 90) > 0.001 ||
|
||||
Math.abs(zRotate % 90) > 0.001) {
|
||||
actor.printDebug("Note: Interpolation is not yet supported, so angles that are multiples of 90 is recommended.");
|
||||
actor.printDebug(TranslatableComponent.of("worldedit.rotate.no-interpolation"));
|
||||
}
|
||||
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
@ -214,7 +213,7 @@ public class ClipboardCommands {
|
||||
transform = transform.rotateX(-xRotate);
|
||||
transform = transform.rotateZ(-zRotate);
|
||||
holder.setTransform(holder.getTransform().combine(transform));
|
||||
actor.print("The clipboard copy has been rotated.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.rotate.rotated"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -229,7 +228,7 @@ public class ClipboardCommands {
|
||||
AffineTransform transform = new AffineTransform();
|
||||
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
|
||||
holder.setTransform(holder.getTransform().combine(transform));
|
||||
actor.print("The clipboard copy has been flipped.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.flip.flipped"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -239,6 +238,6 @@ public class ClipboardCommands {
|
||||
@CommandPermissions("worldedit.clipboard.clear")
|
||||
public void clearClipboard(Actor actor, LocalSession session) throws WorldEditException {
|
||||
session.setClipboard(null);
|
||||
actor.print("Clipboard cleared.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.clearclipboard.cleared"));
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class ExpandCommands {
|
||||
|
||||
private static Command createVertCommand(CommandManager commandManager) {
|
||||
return commandManager.newCommand("vert")
|
||||
.description(TextComponent.of("Vertically expand the selection to world limits."))
|
||||
.description(TranslatableComponent.of("worldedit.expand.description.vert"))
|
||||
.action(parameters -> {
|
||||
expandVert(
|
||||
requireIV(Key.of(LocalSession.class), "localSession", parameters),
|
||||
@ -110,10 +110,12 @@ public class ExpandCommands {
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
int newSize = region.getArea();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
player.print("Region expanded " + (newSize - oldSize)
|
||||
+ " blocks [top-to-bottom].");
|
||||
int changeSize = newSize - oldSize;
|
||||
player.printInfo(
|
||||
TranslatableComponent.of("worldedit.expand.expanded.vert", TextComponent.of(changeSize))
|
||||
);
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(e.getMessage());
|
||||
player.printError(TextComponent.of(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +150,8 @@ public class ExpandCommands {
|
||||
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
|
||||
actor.print("Region expanded " + (newSize - oldSize) + " block(s).");
|
||||
int changeSize = newSize - oldSize;
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.expand.expanded", TextComponent.of(changeSize)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -36,6 +38,9 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
@ -50,8 +55,6 @@ import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* General WorldEdit commands.
|
||||
*/
|
||||
@ -85,14 +88,17 @@ public class GeneralCommands {
|
||||
limit = limit == null ? config.defaultChangeLimit : Math.max(-1, limit);
|
||||
if (!mayDisable && config.maxChangeLimit > -1) {
|
||||
if (limit > config.maxChangeLimit) {
|
||||
actor.printError("Your maximum allowable limit is " + config.maxChangeLimit + ".");
|
||||
actor.printError(TranslatableComponent.of("worldedit.limit.too-high", TextComponent.of(config.maxChangeLimit)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
session.setBlockChangeLimit(limit);
|
||||
actor.print("Block change limit set to " + limit + "."
|
||||
+ (limit == config.defaultChangeLimit ? "" : " (Use //limit to go back to the default.)"));
|
||||
Component component = TextComponent.empty().append(TranslatableComponent.of("worldedit.limit.set", TextComponent.of(limit)));
|
||||
if (limit != config.defaultChangeLimit) {
|
||||
component.append(TextComponent.space()).append(TranslatableComponent.of("worldedit.limit.return-to-default", TextColor.GRAY));
|
||||
}
|
||||
actor.printInfo(component);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -109,14 +115,17 @@ public class GeneralCommands {
|
||||
limit = limit == null ? config.calculationTimeout : Math.max(-1, limit);
|
||||
if (!mayDisable && config.maxCalculationTimeout > -1) {
|
||||
if (limit > config.maxCalculationTimeout) {
|
||||
actor.printError("Your maximum allowable timeout is " + config.maxCalculationTimeout + " ms.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.timeout.too-high", TextComponent.of(config.maxCalculationTimeout)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
session.setTimeout(limit);
|
||||
actor.print("Timeout time set to " + limit + " ms."
|
||||
+ (limit == config.calculationTimeout ? "" : " (Use //timeout to go back to the default.)"));
|
||||
Component component = TextComponent.empty().append(TranslatableComponent.of("worldedit.timeout.set", TextComponent.of(limit)));
|
||||
if (limit != config.calculationTimeout) {
|
||||
component.append(TranslatableComponent.of("worldedit.timeout.return-to-default", TextColor.GRAY));
|
||||
}
|
||||
actor.printInfo(component);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -129,16 +138,16 @@ public class GeneralCommands {
|
||||
Boolean fastMode) {
|
||||
boolean hasFastMode = session.hasFastMode();
|
||||
if (fastMode != null && fastMode == hasFastMode) {
|
||||
actor.printError("Fast mode already " + (fastMode ? "enabled" : "disabled") + ".");
|
||||
actor.printError(TranslatableComponent.of(fastMode ? "worldedit.fast.enabled.already" : "worldedit.fast.disabled.already"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasFastMode) {
|
||||
session.setFastMode(false);
|
||||
actor.print("Fast mode disabled.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.fast.disabled"));
|
||||
} else {
|
||||
session.setFastMode(true);
|
||||
actor.print("Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.fast.enabled"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,10 +160,10 @@ public class GeneralCommands {
|
||||
@Arg(desc = "The reorder mode", def = "")
|
||||
EditSession.ReorderMode reorderMode) {
|
||||
if (reorderMode == null) {
|
||||
actor.print("The reorder mode is " + session.getReorderMode().getDisplayName());
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.reorder.current", TextComponent.of(session.getReorderMode().getDisplayName())));
|
||||
} else {
|
||||
session.setReorderMode(reorderMode);
|
||||
actor.print("The reorder mode is now " + session.getReorderMode().getDisplayName());
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.reorder.set", TextComponent.of(session.getReorderMode().getDisplayName())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,17 +180,18 @@ public class GeneralCommands {
|
||||
}
|
||||
boolean useServerCui = session.shouldUseServerCUI();
|
||||
if (drawSelection != null && drawSelection == useServerCui) {
|
||||
player.printError("Server CUI already " + (useServerCui ? "enabled" : "disabled") + ".");
|
||||
player.printError(TranslatableComponent.of("worldedit.drawsel." + (useServerCui ? "enabled" : "disabled") + ".already"));
|
||||
|
||||
return;
|
||||
}
|
||||
if (useServerCui) {
|
||||
session.setUseServerCUI(false);
|
||||
session.updateServerCUI(player);
|
||||
player.print("Server CUI disabled.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.drawsel.disabled"));
|
||||
} else {
|
||||
session.setUseServerCUI(true);
|
||||
session.updateServerCUI(player);
|
||||
player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.drawsel.enabled"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,9 +204,9 @@ public class GeneralCommands {
|
||||
@Arg(desc = "The world override", def = "") World world) {
|
||||
session.setWorldOverride(world);
|
||||
if (world == null) {
|
||||
actor.print("Removed world override.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.world.remove"));
|
||||
} else {
|
||||
actor.print("Set the world override to " + world.getId() + ". (Use //world to go back to default)");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.world.set", TextComponent.of(world.getId())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,16 +221,16 @@ public class GeneralCommands {
|
||||
@Arg(desc = "The mode to set the watchdog hook to", def = "")
|
||||
HookMode hookMode) {
|
||||
if (WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getWatchdog() == null) {
|
||||
actor.printError("This platform has no watchdog hook.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.watchdog.no-hook"));
|
||||
return;
|
||||
}
|
||||
boolean previousMode = session.isTickingWatchdog();
|
||||
if (hookMode != null && (hookMode == HookMode.ACTIVE) == previousMode) {
|
||||
actor.printError("Watchdog hook already " + (previousMode ? "active" : "inactive") + ".");
|
||||
actor.printError(TranslatableComponent.of(previousMode ? "worldedit.watchdog.active.already" : "worldedit.watchdog.inactive.already"));
|
||||
return;
|
||||
}
|
||||
session.setTickingWatchdog(!previousMode);
|
||||
actor.print("Watchdog hook now " + (previousMode ? "inactive" : "active") + ".");
|
||||
actor.printInfo(TranslatableComponent.of(previousMode ? "worldedit.watchdog.inactive" : "worldedit.watchdog.active"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -234,10 +244,10 @@ public class GeneralCommands {
|
||||
Mask mask) {
|
||||
if (mask == null) {
|
||||
session.setMask(null);
|
||||
actor.print("Global mask disabled.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.gmask.disabled"));
|
||||
} else {
|
||||
session.setMask(mask);
|
||||
actor.print("Global mask set.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.gmask.set"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,9 +258,9 @@ public class GeneralCommands {
|
||||
)
|
||||
public void togglePlace(Player player, LocalSession session) {
|
||||
if (session.togglePlacementPosition()) {
|
||||
player.print("Now placing at pos #1.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.toggleplace.pos1"));
|
||||
} else {
|
||||
player.print("Now placing at the block you stand in.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.toggleplace.player"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,16 +281,16 @@ public class GeneralCommands {
|
||||
List<String> query) {
|
||||
String search = String.join(" ", query);
|
||||
if (search.length() <= 2) {
|
||||
actor.printError("Enter a longer search string (len > 2).");
|
||||
actor.printError(TranslatableComponent.of("worldedit.searchitem.too-short"));
|
||||
return;
|
||||
}
|
||||
if (blocksOnly && itemsOnly) {
|
||||
actor.printError("You cannot use both the 'b' and 'i' flags simultaneously.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.searchitem.either-b-or-i"));
|
||||
return;
|
||||
}
|
||||
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, new ItemSearcher(search, blocksOnly, itemsOnly, page),
|
||||
"(Please wait... searching items.)");
|
||||
TranslatableComponent.of("worldedit.searchitem.searching"));
|
||||
}
|
||||
|
||||
private static class ItemSearcher implements Callable<Component> {
|
||||
|
@ -36,6 +36,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
@ -113,7 +115,7 @@ public class GenerationCommands {
|
||||
break;
|
||||
|
||||
default:
|
||||
actor.printError("You must either specify 1 or 2 radius values.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.cyl.invalid-radius"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -123,7 +125,7 @@ public class GenerationCommands {
|
||||
|
||||
BlockVector3 pos = session.getPlacementPosition(actor);
|
||||
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
|
||||
actor.print(affected + " block(s) have been created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.cyl.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -173,7 +175,7 @@ public class GenerationCommands {
|
||||
break;
|
||||
|
||||
default:
|
||||
actor.printError("You must either specify 1 or 3 radius values.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.sphere.invalid-radius"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -190,7 +192,7 @@ public class GenerationCommands {
|
||||
if (actor instanceof Player) {
|
||||
((Player) actor).findFreePosition();
|
||||
}
|
||||
actor.print(affected + " block(s) have been created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.sphere.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -211,7 +213,7 @@ public class GenerationCommands {
|
||||
worldEdit.checkMaxRadius(size);
|
||||
density /= 100;
|
||||
int affected = editSession.makeForest(session.getPlacementPosition(actor), size, density, type);
|
||||
actor.print(affected + " trees created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.forestgen.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -226,7 +228,7 @@ public class GenerationCommands {
|
||||
int size) throws WorldEditException {
|
||||
worldEdit.checkMaxRadius(size);
|
||||
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), size);
|
||||
actor.print(affected + " pumpkin patches created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.pumpkins.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -263,7 +265,7 @@ public class GenerationCommands {
|
||||
if (actor instanceof Player) {
|
||||
((Player) actor).findFreePosition();
|
||||
}
|
||||
actor.print(affected + " block(s) have been created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.pyramid.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -322,10 +324,10 @@ public class GenerationCommands {
|
||||
if (actor instanceof Player) {
|
||||
((Player) actor).findFreePosition();
|
||||
}
|
||||
actor.print(affected + " block(s) have been created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.generate.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
} catch (ExpressionException e) {
|
||||
actor.printError(e.getMessage());
|
||||
actor.printError(TextComponent.of(e.getMessage()));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -381,10 +383,10 @@ public class GenerationCommands {
|
||||
|
||||
try {
|
||||
final int affected = editSession.makeBiomeShape(region, zero, unit, target, String.join(" ", expression), hollow, session.getTimeout());
|
||||
actor.print("" + affected + " columns affected.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.generatebiome.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
} catch (ExpressionException e) {
|
||||
actor.printError(e.getMessage());
|
||||
actor.printError(TextComponent.of(e.getMessage()));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
@ -68,7 +70,7 @@ public class HistoryCommands {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
undoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||
if (undoSession == null) {
|
||||
player.printError("Unable to find session for " + playerName);
|
||||
player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -83,9 +85,9 @@ public class HistoryCommands {
|
||||
}
|
||||
}
|
||||
if (timesUndone > 0) {
|
||||
player.print("Undid " + timesUndone + " available edits.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
|
||||
} else {
|
||||
player.printError("Nothing left to undo.");
|
||||
player.printError(TranslatableComponent.of("worldedit.undo.none"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +108,7 @@ public class HistoryCommands {
|
||||
player.checkPermission("worldedit.history.redo.other");
|
||||
redoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||
if (redoSession == null) {
|
||||
player.printError("Unable to find session for " + playerName);
|
||||
player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -121,9 +123,9 @@ public class HistoryCommands {
|
||||
}
|
||||
}
|
||||
if (timesRedone > 0) {
|
||||
player.print("Redid " + timesRedone + " available edits.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.redo.redid", TextComponent.of(timesRedone)));
|
||||
} else {
|
||||
player.printError("Nothing left to redo.");
|
||||
player.printError(TranslatableComponent.of("worldedit.redo.none"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +137,7 @@ public class HistoryCommands {
|
||||
@CommandPermissions("worldedit.history.clear")
|
||||
public void clearHistory(Actor actor, LocalSession session) {
|
||||
session.clearHistory();
|
||||
actor.print("History cleared.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.clearhistory.cleared"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
@ -61,7 +63,7 @@ public class NavigationCommands {
|
||||
@CommandPermissions("worldedit.navigation.unstuck")
|
||||
public void unstuck(Player player) throws WorldEditException {
|
||||
player.findFreePosition();
|
||||
player.print("There you go!");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.unstuck.moved"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -81,9 +83,9 @@ public class NavigationCommands {
|
||||
}
|
||||
}
|
||||
if (ascentLevels == 0) {
|
||||
player.printError("No free spot above you found.");
|
||||
player.printError(TranslatableComponent.of("worldedit.ascend.obstructed"));
|
||||
} else {
|
||||
player.print((ascentLevels != 1) ? "Ascended " + ascentLevels + " levels." : "Ascended a level.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.ascend.moved", TextComponent.of(ascentLevels)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +106,9 @@ public class NavigationCommands {
|
||||
}
|
||||
}
|
||||
if (descentLevels == 0) {
|
||||
player.printError("No free spot below you found.");
|
||||
player.printError(TranslatableComponent.of("worldedit.descend.obstructed"));
|
||||
} else {
|
||||
player.print((descentLevels != 1) ? "Descended " + descentLevels + " levels." : "Descended a level.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.descend.moved", TextComponent.of(descentLevels)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,9 +129,9 @@ public class NavigationCommands {
|
||||
|
||||
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
|
||||
if (player.ascendToCeiling(clearance, alwaysGlass)) {
|
||||
player.print("Whoosh!");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.ceil.moved"));
|
||||
} else {
|
||||
player.printError("No free spot above you found.");
|
||||
player.printError(TranslatableComponent.of("worldedit.ceil.obstructed"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,9 +142,9 @@ public class NavigationCommands {
|
||||
@CommandPermissions("worldedit.navigation.thru.command")
|
||||
public void thru(Player player) throws WorldEditException {
|
||||
if (player.passThroughForwardWall(6)) {
|
||||
player.print("Whoosh!");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.thru.moved"));
|
||||
} else {
|
||||
player.printError("No free spot ahead of you found.");
|
||||
player.printError(TranslatableComponent.of("worldedit.thru.obstructed"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,9 +159,9 @@ public class NavigationCommands {
|
||||
Location pos = player.getSolidBlockTrace(300);
|
||||
if (pos != null) {
|
||||
player.findFreePosition(pos);
|
||||
player.print("Poof!");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.jumpto.moved"));
|
||||
} else {
|
||||
player.printError("No block in sight!");
|
||||
player.printError(TranslatableComponent.of("worldedit.jumpto.none"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,9 +180,9 @@ public class NavigationCommands {
|
||||
boolean forceGlass) throws WorldEditException {
|
||||
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
|
||||
if (player.ascendUpwards(distance, alwaysGlass)) {
|
||||
player.print("Whoosh!");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.up.moved"));
|
||||
} else {
|
||||
player.printError("You would hit something above you.");
|
||||
player.printError(TranslatableComponent.of("worldedit.up.obstructed"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,24 +61,24 @@ import static org.enginehub.piston.part.CommandParts.arg;
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class PaintBrushCommands {
|
||||
|
||||
private static final CommandArgument REGION_FACTORY = arg(TranslatableComponent.of("shape"), TextComponent.of("The shape of the region"))
|
||||
private static final CommandArgument REGION_FACTORY = arg(TranslatableComponent.of("shape"), TranslatableComponent.of("worldedit.brush.paint.shape"))
|
||||
.defaultsTo(ImmutableList.of())
|
||||
.ofTypes(ImmutableList.of(Key.of(RegionFactory.class)))
|
||||
.build();
|
||||
|
||||
private static final CommandArgument RADIUS = arg(TranslatableComponent.of("radius"), TextComponent.of("The size of the brush"))
|
||||
private static final CommandArgument RADIUS = arg(TranslatableComponent.of("radius"), TranslatableComponent.of("worldedit.brush.paint.size"))
|
||||
.defaultsTo(ImmutableList.of("5"))
|
||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||
.build();
|
||||
|
||||
private static final CommandArgument DENSITY = arg(TranslatableComponent.of("density"), TextComponent.of("The density of the brush"))
|
||||
private static final CommandArgument DENSITY = arg(TranslatableComponent.of("density"), TranslatableComponent.of("worldedit.brush.paint.density"))
|
||||
.defaultsTo(ImmutableList.of("20"))
|
||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||
.build();
|
||||
|
||||
public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) {
|
||||
commandManager.register("paint", builder -> {
|
||||
builder.description(TextComponent.of("Paint brush, apply a function to a surface"));
|
||||
builder.description(TranslatableComponent.of("worldedit.brush.paint.description"));
|
||||
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
||||
|
||||
CommandManager manager = service.newCommandManager();
|
||||
@ -91,7 +91,7 @@ public class PaintBrushCommands {
|
||||
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.paint")));
|
||||
|
||||
builder.addParts(REGION_FACTORY, RADIUS, DENSITY);
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TranslatableComponent.of("worldedit.brush.paint.type"))
|
||||
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||
.required()
|
||||
.build());
|
||||
@ -131,8 +131,7 @@ public class PaintBrushCommands {
|
||||
@Direction(includeDiagonals = true)
|
||||
com.sk89q.worldedit.util.Direction direction) throws WorldEditException {
|
||||
player.print(TextComponent.builder().append("WARNING: ", TextColor.RED, TextDecoration.BOLD)
|
||||
.append("This brush simulates item usages. Its effects may not work on all platforms, may not be undo-able," +
|
||||
" and may cause strange interactions with other mods/plugins. Use at your own risk.").build());
|
||||
.append(TranslatableComponent.of("worldedit.brush.paint.item.warning")).build());
|
||||
setPaintBrush(parameters, player, localSession, new ItemUseFactory(item, direction));
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -57,6 +56,10 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
@ -100,12 +103,11 @@ public class RegionCommands {
|
||||
RegionVisitor visitor = new RegionVisitor(region, set);
|
||||
|
||||
Operations.completeBlindly(visitor);
|
||||
List<String> messages = Lists.newArrayList();
|
||||
visitor.addStatusMessages(messages);
|
||||
List<Component> messages = Lists.newArrayList(visitor.getStatusMessages());
|
||||
if (messages.isEmpty()) {
|
||||
actor.print("Operation completed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.set.done"));
|
||||
} else {
|
||||
actor.print("Operation completed (" + Joiner.on(", ").join(messages) + ").");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.set.done.verbose", TextUtils.join(messages, TextComponent.of(", "))));
|
||||
}
|
||||
|
||||
return visitor.getAffected();
|
||||
@ -127,7 +129,7 @@ public class RegionCommands {
|
||||
@Switch(name = 'h', desc = "Generate only a shell")
|
||||
boolean shell) throws WorldEditException {
|
||||
if (!((region instanceof CuboidRegion) || (region instanceof ConvexPolyhedralRegion))) {
|
||||
actor.printError("//line only works with cuboid selections or convex polyhedral selections");
|
||||
actor.printError(TranslatableComponent.of("worldedit.line.invalid-type"));
|
||||
return 0;
|
||||
}
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
@ -145,7 +147,7 @@ public class RegionCommands {
|
||||
|
||||
int blocksChanged = editSession.drawLine(pattern, vectors, thickness, !shell);
|
||||
|
||||
actor.print(blocksChanged + " block(s) have been changed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.line.changed", TextComponent.of(blocksChanged)));
|
||||
return blocksChanged;
|
||||
}
|
||||
|
||||
@ -165,7 +167,7 @@ public class RegionCommands {
|
||||
@Switch(name = 'h', desc = "Generate only a shell")
|
||||
boolean shell) throws WorldEditException {
|
||||
if (!(region instanceof ConvexPolyhedralRegion)) {
|
||||
actor.printError("//curve only works with convex polyhedral selections");
|
||||
actor.printError(TranslatableComponent.of("worldedit.curve.invalid-type"));
|
||||
return 0;
|
||||
}
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
@ -175,7 +177,7 @@ public class RegionCommands {
|
||||
|
||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
||||
|
||||
actor.print(blocksChanged + " block(s) have been changed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.curve.changed", TextComponent.of(blocksChanged)));
|
||||
return blocksChanged;
|
||||
}
|
||||
|
||||
@ -195,7 +197,7 @@ public class RegionCommands {
|
||||
from = new ExistingBlockMask(editSession);
|
||||
}
|
||||
int affected = editSession.replaceBlocks(region, from, to);
|
||||
actor.print(affected + " block(s) have been replaced.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.replace.replaced", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -209,7 +211,7 @@ public class RegionCommands {
|
||||
@Arg(desc = "The pattern of blocks to overlay")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.overlayCuboidBlocks(region, pattern);
|
||||
actor.print(affected + " block(s) have been overlaid.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.overlay.overlaid", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -224,7 +226,7 @@ public class RegionCommands {
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.center(region, pattern);
|
||||
actor.print("Center set (" + affected + " block(s) changed)");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.center.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -236,7 +238,7 @@ public class RegionCommands {
|
||||
@Logging(REGION)
|
||||
public int naturalize(Actor actor, EditSession editSession, @Selection Region region) throws WorldEditException {
|
||||
int affected = editSession.naturalizeCuboidBlocks(region);
|
||||
actor.print(affected + " block(s) have been made to look more natural.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.naturalize.naturalized", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -250,7 +252,7 @@ public class RegionCommands {
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.makeWalls(region, pattern);
|
||||
actor.print(affected + " block(s) have been changed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.walls.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -265,7 +267,7 @@ public class RegionCommands {
|
||||
@Arg(desc = "The pattern of blocks to set")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.makeCuboidFaces(region, pattern);
|
||||
actor.print(affected + " block(s) have been changed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.faces.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -284,7 +286,7 @@ public class RegionCommands {
|
||||
HeightMap heightMap = new HeightMap(editSession, region, mask);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
int affected = heightMap.applyFilter(filter, iterations);
|
||||
actor.print("Terrain's height map smoothed. " + affected + " block(s) changed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.smooth.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -335,11 +337,11 @@ public class RegionCommands {
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
} catch (RegionOperationException e) {
|
||||
actor.printError(e.getMessage());
|
||||
actor.printError(TextComponent.of(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
actor.print(affected + " block(s) moved.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.move.moved", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -390,11 +392,11 @@ public class RegionCommands {
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
} catch (RegionOperationException e) {
|
||||
actor.printError(e.getMessage());
|
||||
actor.printError(TextComponent.of(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
actor.print(affected + " block(s) changed. Undo with //undo");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.stack.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -415,7 +417,7 @@ public class RegionCommands {
|
||||
} finally {
|
||||
session.setMask(mask);
|
||||
}
|
||||
actor.print("Region regenerated.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -461,10 +463,10 @@ public class RegionCommands {
|
||||
if (actor instanceof Player) {
|
||||
((Player) actor).findFreePosition();
|
||||
}
|
||||
actor.print(affected + " block(s) have been deformed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.deform.deformed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
} catch (ExpressionException e) {
|
||||
actor.printError(e.getMessage());
|
||||
actor.printError(TextComponent.of(e.getMessage()));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -485,7 +487,7 @@ public class RegionCommands {
|
||||
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
|
||||
|
||||
int affected = editSession.hollowOutRegion(region, thickness, pattern);
|
||||
actor.print(affected + " block(s) have been changed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.hollow.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -502,7 +504,7 @@ public class RegionCommands {
|
||||
double density) throws WorldEditException {
|
||||
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
|
||||
int affected = editSession.makeForest(region, density / 100, type);
|
||||
actor.print(affected + " trees created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.forest.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -524,7 +526,7 @@ public class RegionCommands {
|
||||
Operations.completeLegacy(visitor);
|
||||
|
||||
int affected = ground.getAffected();
|
||||
actor.print(affected + " flora created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.flora.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
@ -112,7 +113,7 @@ public class SchematicCommands {
|
||||
ClipboardFormats.getFileExtensionArray());
|
||||
|
||||
if (!f.exists()) {
|
||||
actor.printError("Schematic " + filename + " does not exist!");
|
||||
actor.printError(TranslatableComponent.of("worldedit.schematic.load.does-not-exist", TextComponent.of(filename)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -121,14 +122,14 @@ public class SchematicCommands {
|
||||
format = ClipboardFormats.findByAlias(formatName);
|
||||
}
|
||||
if (format == null) {
|
||||
actor.printError("Unknown schematic format: " + formatName);
|
||||
actor.printError(TranslatableComponent.of("worldedit.schematic.unknown-format", TextComponent.of(formatName)));
|
||||
return;
|
||||
}
|
||||
|
||||
SchematicLoadTask task = new SchematicLoadTask(actor, f, format);
|
||||
AsyncCommandBuilder.wrap(task, actor)
|
||||
.registerWithSupervisor(worldEdit.getSupervisor(), "Loading schematic " + filename)
|
||||
.sendMessageAfterDelay("(Please wait... loading schematic.)")
|
||||
.sendMessageAfterDelay(TranslatableComponent.of("worldedit.schematic.load.loading"))
|
||||
.onSuccess(TextComponent.of(filename, TextColor.GOLD)
|
||||
.append(TextComponent.of(" loaded. Paste it with ", TextColor.LIGHT_PURPLE))
|
||||
.append(CodeFormat.wrap("//paste").clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "//paste"))),
|
||||
@ -156,7 +157,7 @@ public class SchematicCommands {
|
||||
|
||||
ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
if (format == null) {
|
||||
actor.printError("Unknown schematic format: " + formatName);
|
||||
actor.printError(TranslatableComponent.of("worldedit.schematic.unknown-format", TextComponent.of(formatName)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -168,7 +169,7 @@ public class SchematicCommands {
|
||||
throw new StopExecutionException(TextComponent.of("That schematic already exists!"));
|
||||
}
|
||||
if (!allowOverwrite) {
|
||||
actor.printError("That schematic already exists. Use the -f flag to overwrite it.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.schematic.save.already-exists"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -177,8 +178,8 @@ public class SchematicCommands {
|
||||
File parent = f.getParentFile();
|
||||
if (parent != null && !parent.exists()) {
|
||||
if (!parent.mkdirs()) {
|
||||
throw new StopExecutionException(TextComponent.of(
|
||||
"Could not create folder for schematics!"));
|
||||
throw new StopExecutionException(TranslatableComponent.of(
|
||||
"worldedit.schematic.save.failed-directory"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +188,7 @@ public class SchematicCommands {
|
||||
SchematicSaveTask task = new SchematicSaveTask(actor, f, format, holder, overwrite);
|
||||
AsyncCommandBuilder.wrap(task, actor)
|
||||
.registerWithSupervisor(worldEdit.getSupervisor(), "Saving schematic " + filename)
|
||||
.sendMessageAfterDelay("(Please wait... saving schematic.)")
|
||||
.sendMessageAfterDelay(TranslatableComponent.of("worldedit.schematic.save.saving"))
|
||||
.onSuccess(filename + " saved" + (overwrite ? " (overwriting previous file)." : "."), null)
|
||||
.onFailure("Failed to load schematic", worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter())
|
||||
.buildAndExec(worldEdit.getExecutorService());
|
||||
@ -209,16 +210,16 @@ public class SchematicCommands {
|
||||
dir, filename, "schematic", ClipboardFormats.getFileExtensionArray());
|
||||
|
||||
if (!f.exists()) {
|
||||
actor.printError("Schematic " + filename + " does not exist!");
|
||||
actor.printError(TranslatableComponent.of("worldedit.schematic.delete.does-not-exist", TextComponent.of(filename)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!f.delete()) {
|
||||
actor.printError("Deletion of " + filename + " failed! Maybe it is read-only.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.schematic.delete.failed", TextComponent.of(filename)));
|
||||
return;
|
||||
}
|
||||
|
||||
actor.print(filename + " has been deleted.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.schematic.delete.deleted", TextComponent.of(filename)));
|
||||
try {
|
||||
log.info(actor.getName() + " deleted " + f.getCanonicalPath());
|
||||
} catch (IOException e) {
|
||||
@ -233,7 +234,7 @@ public class SchematicCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.formats")
|
||||
public void formats(Actor actor) {
|
||||
actor.print("Available clipboard formats (Name: Lookup names)");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.schematic.formats.title"));
|
||||
StringBuilder builder;
|
||||
boolean first = true;
|
||||
for (ClipboardFormat format : ClipboardFormats.getAll()) {
|
||||
@ -247,7 +248,7 @@ public class SchematicCommands {
|
||||
first = false;
|
||||
}
|
||||
first = true;
|
||||
actor.print(builder.toString());
|
||||
actor.printInfo(TextComponent.of(builder.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
@ -67,7 +68,7 @@ public class ScriptingCommands {
|
||||
@Arg(desc = "Arguments to the CraftScript", def = "", variable = true)
|
||||
List<String> args) throws WorldEditException {
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + filename)) {
|
||||
player.printError("You don't have permission to use that script.");
|
||||
player.printError(TranslatableComponent.of("worldedit.execute.script-permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -93,12 +94,12 @@ public class ScriptingCommands {
|
||||
String lastScript = session.getLastScript();
|
||||
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
|
||||
player.printError("You don't have permission to use that script.");
|
||||
player.printError(TranslatableComponent.of("worldedit.execute.script-permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastScript == null) {
|
||||
player.printError("Use /cs with a script name first.");
|
||||
player.printError(TranslatableComponent.of("worldedit.executelast.no-script"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,7 @@ import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
@ -116,12 +117,12 @@ public class SelectionCommands {
|
||||
} else if (actor instanceof Locatable) {
|
||||
pos = ((Locatable) actor).getBlockLocation();
|
||||
} else {
|
||||
actor.printError("You must provide coordinates as console.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.pos.console-require-coords"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!session.getRegionSelector(world).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
|
||||
actor.printError("Position already set.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.pos.already-set"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -144,12 +145,12 @@ public class SelectionCommands {
|
||||
} else if (actor instanceof Locatable) {
|
||||
pos = ((Locatable) actor).getBlockLocation();
|
||||
} else {
|
||||
actor.printError("You must provide coordinates as console.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.pos.console-require-coords"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!session.getRegionSelector(world).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
|
||||
actor.printError("Position already set.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.pos.already-set"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -168,14 +169,14 @@ public class SelectionCommands {
|
||||
|
||||
if (pos != null) {
|
||||
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||
player.printError("Position already set.");
|
||||
player.printError(TranslatableComponent.of("worldedit.hpos.already-set"));
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
.explainPrimarySelection(player, session, pos.toVector().toBlockPoint());
|
||||
} else {
|
||||
player.printError("No block in sight!");
|
||||
player.printError(TranslatableComponent.of("worldedit.hpos.no-block"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,14 +191,14 @@ public class SelectionCommands {
|
||||
|
||||
if (pos != null) {
|
||||
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
|
||||
player.printError("Position already set.");
|
||||
player.printError(TranslatableComponent.of("worldedit.hpos.already-set"));
|
||||
return;
|
||||
}
|
||||
|
||||
session.getRegionSelector(player.getWorld())
|
||||
.explainSecondarySelection(player, session, pos.toVector().toBlockPoint());
|
||||
} else {
|
||||
player.printError("No block in sight!");
|
||||
player.printError(TranslatableComponent.of("worldedit.hpos.no-block"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,9 +226,13 @@ public class SelectionCommands {
|
||||
min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||
max = BlockVector3.at(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15);
|
||||
|
||||
actor.print("Chunks selected: ("
|
||||
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - ("
|
||||
+ max2D.getBlockX() + ", " + max2D.getBlockZ() + ")");
|
||||
actor.printInfo(TranslatableComponent.of(
|
||||
"worldedit.chunk.selected-multiple",
|
||||
TextComponent.of(min2D.getBlockX()),
|
||||
TextComponent.of(min2D.getBlockZ()),
|
||||
TextComponent.of(max2D.getBlockX()),
|
||||
TextComponent.of(max2D.getBlockZ())
|
||||
));
|
||||
} else {
|
||||
final BlockVector2 min2D;
|
||||
if (coordinates != null) {
|
||||
@ -247,8 +252,8 @@ public class SelectionCommands {
|
||||
min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
|
||||
max = min.add(15, world.getMaxY(), 15);
|
||||
|
||||
actor.print("Chunk selected: "
|
||||
+ min2D.getBlockX() + ", " + min2D.getBlockZ());
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.chunk.selected", TextComponent.of(min2D.getBlockX()),
|
||||
TextComponent.of(min2D.getBlockZ())));
|
||||
}
|
||||
|
||||
final CuboidRegionSelector selector;
|
||||
@ -278,16 +283,16 @@ public class SelectionCommands {
|
||||
}
|
||||
ItemType itemType = ItemTypes.get(wandId);
|
||||
if (itemType == null) {
|
||||
player.printError("Wand item is mis-configured or disabled.");
|
||||
player.printError(TranslatableComponent.of("worldedit.wand.invalid"));
|
||||
return;
|
||||
}
|
||||
player.giveItem(new BaseItemStack(itemType, 1));
|
||||
if (navWand) {
|
||||
session.setTool(itemType, new NavigationWand());
|
||||
player.print("Left click: jump to location; Right click: pass through walls");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.wand.navwand.info"));
|
||||
} else {
|
||||
session.setTool(itemType, new SelectionWand());
|
||||
player.print("Left click: select pos #1; Right click: select pos #2");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.wand.selwand.info"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,9 +344,9 @@ public class SelectionCommands {
|
||||
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
|
||||
actor.print("Region contracted " + (oldSize - newSize) + " blocks.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.contract.contracted", TextComponent.of(oldSize - newSize)));
|
||||
} catch (RegionOperationException e) {
|
||||
actor.printError(e.getMessage());
|
||||
actor.printError(TextComponent.of(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,9 +373,9 @@ public class SelectionCommands {
|
||||
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
|
||||
actor.print("Region shifted.");
|
||||
actor.print(TranslatableComponent.of("worldedit.shift.shifted"));
|
||||
} catch (RegionOperationException e) {
|
||||
actor.printError(e.getMessage());
|
||||
actor.printError(TextComponent.of(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,7 +396,7 @@ public class SelectionCommands {
|
||||
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
actor.print("Region outset.");
|
||||
actor.print(TranslatableComponent.of("worldedit.outset.outset"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -411,7 +416,7 @@ public class SelectionCommands {
|
||||
region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
actor.print("Region inset.");
|
||||
actor.print(TranslatableComponent.of("worldedit.inset.inset"));
|
||||
}
|
||||
|
||||
private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) {
|
||||
@ -447,13 +452,13 @@ public class SelectionCommands {
|
||||
region = clipboard.getRegion();
|
||||
|
||||
BlockVector3 origin = clipboard.getOrigin();
|
||||
actor.print("Offset: " + origin);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.size.offset", TextComponent.of(origin.toString())));
|
||||
} else {
|
||||
region = session.getSelection(world);
|
||||
|
||||
actor.print("Type: " + session.getRegionSelector(world).getTypeName());
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.size.type", TextComponent.of(session.getRegionSelector(world).getTypeName())));
|
||||
|
||||
for (String line : session.getRegionSelector(world).getInformationLines()) {
|
||||
for (Component line : session.getRegionSelector(world).getSelectionInfoLines()) {
|
||||
actor.print(line);
|
||||
}
|
||||
}
|
||||
@ -461,22 +466,22 @@ public class SelectionCommands {
|
||||
.subtract(region.getMinimumPoint())
|
||||
.add(1, 1, 1);
|
||||
|
||||
actor.print("Size: " + size);
|
||||
actor.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
|
||||
actor.print("# of blocks: " + region.getArea());
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.size.size", TextComponent.of(size.toString())));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.size.distance", TextComponent.of(region.getMaximumPoint().distance(region.getMinimumPoint()))));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.size.blocks", TextComponent.of(region.getArea())));
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
name = "/count",
|
||||
desc = "Counts the number of blocks matching a mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.analysis.count")
|
||||
public void count(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
public int count(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The mask of blocks to match")
|
||||
Mask mask) throws WorldEditException {
|
||||
int count = editSession.countBlocks(session.getSelection(world), mask);
|
||||
actor.print("Counted: " + count);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.count.counted", TextComponent.of(count)));
|
||||
return count;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -510,13 +515,13 @@ public class SelectionCommands {
|
||||
} else {
|
||||
distribution = session.getLastDistribution();
|
||||
if (distribution == null) {
|
||||
actor.printError("No previous distribution.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.distr.no-previous"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (distribution.isEmpty()) { // *Should* always be false
|
||||
actor.printError("No blocks counted.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.distr.no-blocks"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -526,7 +531,7 @@ public class SelectionCommands {
|
||||
BlockDistributionResult res = new BlockDistributionResult(distribution, separateStates);
|
||||
if (!actor.isPlayer()) res.formatForConsole();
|
||||
return res.create(finalPage);
|
||||
}, null);
|
||||
}, (Component) null);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -542,7 +547,7 @@ public class SelectionCommands {
|
||||
if (selector == null) {
|
||||
session.getRegionSelector(world).clear();
|
||||
session.dispatchCUISelection(actor);
|
||||
actor.print("Selection cleared.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.select.cleared"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -552,38 +557,38 @@ public class SelectionCommands {
|
||||
switch (selector) {
|
||||
case CUBOID:
|
||||
newSelector = new CuboidRegionSelector(oldSelector);
|
||||
actor.print("Cuboid: left click for point 1, right click for point 2");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.select.cuboid.message"));
|
||||
break;
|
||||
case EXTEND:
|
||||
newSelector = new ExtendingCuboidRegionSelector(oldSelector);
|
||||
actor.print("Cuboid: left click for a starting point, right click to extend");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.select.extend.message"));
|
||||
break;
|
||||
case POLY: {
|
||||
newSelector = new Polygonal2DRegionSelector(oldSelector);
|
||||
actor.print("2D polygon selector: Left/right click to add a point.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.select.poly.message"));
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit();
|
||||
limit.ifPresent(integer -> actor.print(integer + " points maximum."));
|
||||
limit.ifPresent(integer -> actor.printInfo(TranslatableComponent.of("worldedit.select.poly.limit-message", TextComponent.of(integer))));
|
||||
break;
|
||||
}
|
||||
case ELLIPSOID:
|
||||
newSelector = new EllipsoidRegionSelector(oldSelector);
|
||||
actor.print("Ellipsoid selector: left click=center, right click to extend");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.select.ellipsoid.message"));
|
||||
break;
|
||||
case SPHERE:
|
||||
newSelector = new SphereRegionSelector(oldSelector);
|
||||
actor.print("Sphere selector: left click=center, right click to set radius");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.select.sphere.message"));
|
||||
break;
|
||||
case CYL:
|
||||
newSelector = new CylinderRegionSelector(oldSelector);
|
||||
actor.print("Cylindrical selector: Left click=center, right click to extend.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.select.cyl.message"));
|
||||
break;
|
||||
case CONVEX:
|
||||
case HULL:
|
||||
case POLYHEDRON: {
|
||||
newSelector = new ConvexPolyhedralRegionSelector(oldSelector);
|
||||
actor.print("Convex polyhedral selector: Left click=First vertex, right click to add more.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.select.convex.message"));
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> actor.print(integer + " points maximum."));
|
||||
limit.ifPresent(integer -> actor.printInfo(TranslatableComponent.of("worldedit.select.convex.limit-message", TextComponent.of(integer))));
|
||||
break;
|
||||
}
|
||||
case LIST:
|
||||
@ -593,13 +598,13 @@ public class SelectionCommands {
|
||||
TextComponentProducer contents = box.getContents();
|
||||
contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline();
|
||||
|
||||
box.appendCommand("cuboid", "Select two corners of a cuboid", "//sel cuboid");
|
||||
box.appendCommand("extend", "Fast cuboid selection mode", "//sel extend");
|
||||
box.appendCommand("poly", "Select a 2D polygon with height", "//sel poly");
|
||||
box.appendCommand("ellipsoid", "Select an ellipsoid", "//sel ellipsoid");
|
||||
box.appendCommand("sphere", "Select a sphere", "//sel sphere");
|
||||
box.appendCommand("cyl", "Select a cylinder", "//sel cyl");
|
||||
box.appendCommand("convex", "Select a convex polyhedral", "//sel convex");
|
||||
box.appendCommand("cuboid", TranslatableComponent.of("worldedit.select.cuboid.description"), "//sel cuboid");
|
||||
box.appendCommand("extend", TranslatableComponent.of("worldedit.select.extend.description"), "//sel extend");
|
||||
box.appendCommand("poly", TranslatableComponent.of("worldedit.select.poly.description"), "//sel poly");
|
||||
box.appendCommand("ellipsoid", TranslatableComponent.of("worldedit.select.ellipsoid.description"), "//sel ellipsoid");
|
||||
box.appendCommand("sphere", TranslatableComponent.of("worldedit.select.sphere.description"), "//sel sphere");
|
||||
box.appendCommand("cyl", TranslatableComponent.of("worldedit.select.cyl.description"), "//sel cyl");
|
||||
box.appendCommand("convex", TranslatableComponent.of("worldedit.select.convex.description"), "//sel convex");
|
||||
|
||||
actor.print(box.create(1));
|
||||
return;
|
||||
@ -616,7 +621,7 @@ public class SelectionCommands {
|
||||
|
||||
if (found != null) {
|
||||
session.setDefaultRegionSelector(found);
|
||||
actor.print("Your default region selector is now " + found.name() + ".");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.select.default-set", TextComponent.of(found.name())));
|
||||
} else {
|
||||
throw new RuntimeException("Something unexpected happened. Please report this.");
|
||||
}
|
||||
@ -679,7 +684,7 @@ public class SelectionCommands {
|
||||
|
||||
@Override
|
||||
public Component create(int page) throws InvalidComponentException {
|
||||
super.getContents().append(TextComponent.of("Total Block Count: " + totalBlocks, TextColor.GRAY))
|
||||
super.getContents().append(TranslatableComponent.of("worldedit.distr.total", TextColor.GRAY, TextComponent.of(totalBlocks)))
|
||||
.append(TextComponent.newline());
|
||||
return super.create(page);
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
@ -76,7 +76,7 @@ public class SnapshotCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
actor.printError("Snapshot/backup restore is not configured.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class SnapshotCommands {
|
||||
if (!snapshots.isEmpty()) {
|
||||
actor.print(new SnapshotListBox(world.getName(), snapshots).create(page));
|
||||
} else {
|
||||
actor.printError("No snapshots are available. See console for details.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.none-found-console"));
|
||||
|
||||
// Okay, let's toss some debugging information!
|
||||
File dir = config.snapshotRepo.getDirectory();
|
||||
@ -101,7 +101,7 @@ public class SnapshotCommands {
|
||||
}
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
actor.printError("No snapshots were found for this world.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ public class SnapshotCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
actor.printError("Snapshot/backup restore is not configured.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -128,19 +128,19 @@ public class SnapshotCommands {
|
||||
|
||||
if (snapshot != null) {
|
||||
session.setSnapshot(null);
|
||||
actor.print("Now using newest snapshot.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use.newest"));
|
||||
} else {
|
||||
actor.printError("No snapshots were found.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.none-found"));
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
actor.printError("No snapshots were found for this world.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
session.setSnapshot(config.snapshotRepo.getSnapshot(name));
|
||||
actor.print("Snapshot set to: " + name);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(name)));
|
||||
} catch (InvalidSnapshotException e) {
|
||||
actor.printError("That snapshot does not exist or is not available.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.not-available"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -156,30 +156,30 @@ public class SnapshotCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
actor.printError("Snapshot/backup restore is not configured.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (index < 1) {
|
||||
actor.printError("Invalid index, must be equal or higher then 1.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.snapshot.index-above-0"));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, world.getName());
|
||||
if (snapshots.size() < index) {
|
||||
actor.printError("Invalid index, must be between 1 and " + snapshots.size() + ".");
|
||||
actor.printError(TranslatableComponent.of("worldedit.snapshot.index-oob", TextComponent.of(snapshots.size())));
|
||||
return;
|
||||
}
|
||||
Snapshot snapshot = snapshots.get(index - 1);
|
||||
if (snapshot == null) {
|
||||
actor.printError("That snapshot does not exist or is not available.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.not-available"));
|
||||
return;
|
||||
}
|
||||
session.setSnapshot(snapshot);
|
||||
actor.print("Snapshot set to: " + snapshot.getName());
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
|
||||
} catch (MissingWorldException e) {
|
||||
actor.printError("No snapshots were found for this world.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ public class SnapshotCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
actor.printError("Snapshot/backup restore is not configured.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -203,14 +203,16 @@ public class SnapshotCommands {
|
||||
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, world.getName());
|
||||
|
||||
if (snapshot == null) {
|
||||
actor.printError("Couldn't find a snapshot before "
|
||||
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
|
||||
actor.printError(TranslatableComponent.of(
|
||||
"worldedit.snapshot.none-before",
|
||||
TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date)))
|
||||
);
|
||||
} else {
|
||||
session.setSnapshot(snapshot);
|
||||
actor.print("Snapshot set to: " + snapshot.getName());
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
actor.printError("No snapshots were found for this world.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,21 +228,23 @@ public class SnapshotCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
actor.printError("Snapshot/backup restore is not configured.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, world.getName());
|
||||
if (snapshot == null) {
|
||||
actor.printError("Couldn't find a snapshot after "
|
||||
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
|
||||
actor.printError(TranslatableComponent.of(
|
||||
"worldedit.snapshot.none-after",
|
||||
TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date)))
|
||||
);
|
||||
} else {
|
||||
session.setSnapshot(snapshot);
|
||||
actor.print("Snapshot set to: " + snapshot.getName());
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
actor.printError("No snapshots were found for this world.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,8 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||
@ -68,7 +70,7 @@ public class SnapshotUtilCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (config.snapshotRepo == null) {
|
||||
actor.printError("Snapshot/backup restore is not configured.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -79,7 +81,7 @@ public class SnapshotUtilCommands {
|
||||
try {
|
||||
snapshot = config.snapshotRepo.getSnapshot(snapshotName);
|
||||
} catch (InvalidSnapshotException e) {
|
||||
actor.printError("That snapshot does not exist or is not available.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.not-available"));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -92,7 +94,7 @@ public class SnapshotUtilCommands {
|
||||
snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName());
|
||||
|
||||
if (snapshot == null) {
|
||||
actor.printError("No snapshots were found. See console for details.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.none-found-console"));
|
||||
|
||||
// Okay, let's toss some debugging information!
|
||||
File dir = config.snapshotRepo.getDirectory();
|
||||
@ -109,7 +111,7 @@ public class SnapshotUtilCommands {
|
||||
return;
|
||||
}
|
||||
} catch (MissingWorldException ex) {
|
||||
actor.printError("No snapshots were found for this world.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -119,9 +121,9 @@ public class SnapshotUtilCommands {
|
||||
// Load chunk store
|
||||
try {
|
||||
chunkStore = snapshot.getChunkStore();
|
||||
actor.print("Snapshot '" + snapshot.getName() + "' loaded; now restoring...");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.restore.loaded", TextComponent.of(snapshot.getName())));
|
||||
} catch (DataException | IOException e) {
|
||||
actor.printError("Failed to load snapshot: " + e.getMessage());
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.failed", TextComponent.of(e.getMessage())));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -135,18 +137,17 @@ public class SnapshotUtilCommands {
|
||||
if (restore.hadTotalFailure()) {
|
||||
String error = restore.getLastErrorMessage();
|
||||
if (!restore.getMissingChunks().isEmpty()) {
|
||||
actor.printError("Chunks were not present in snapshot.");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.chunk-not-present"));
|
||||
} else if (error != null) {
|
||||
actor.printError("Errors prevented any blocks from being restored.");
|
||||
actor.printError("Last error: " + error);
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.block-place-failed"));
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.block-place-error", TextComponent.of(error)));
|
||||
} else {
|
||||
actor.printError("No chunks could be loaded. (Bad archive?)");
|
||||
actor.printError(TranslatableComponent.of("worldedit.restore.chunk-load-failed"));
|
||||
}
|
||||
} else {
|
||||
actor.print(String.format("Restored; %d "
|
||||
+ "missing chunks and %d other errors.",
|
||||
restore.getMissingChunks().size(),
|
||||
restore.getErrorChunks().size()));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.restore.restored",
|
||||
TextComponent.of(restore.getMissingChunks().size()),
|
||||
TextComponent.of(restore.getErrorChunks().size())));
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
|
@ -29,6 +29,8 @@ import com.sk89q.worldedit.command.tool.SinglePickaxe;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
@ -49,7 +51,7 @@ public class SuperPickaxeCommands {
|
||||
public void single(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setSuperPickaxe(new SinglePickaxe());
|
||||
session.enableSuperPickAxe();
|
||||
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.mode.single"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -64,13 +66,13 @@ public class SuperPickaxeCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||
player.printError(TranslatableComponent.of("worldedit.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
|
||||
return;
|
||||
}
|
||||
|
||||
session.setSuperPickaxe(new AreaPickaxe(range));
|
||||
session.enableSuperPickAxe();
|
||||
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.mode.area"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -86,12 +88,12 @@ public class SuperPickaxeCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||
player.printError(TranslatableComponent.of("worldedit.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
|
||||
return;
|
||||
}
|
||||
|
||||
session.setSuperPickaxe(new RecursivePickaxe(range));
|
||||
session.enableSuperPickAxe();
|
||||
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.mode.recursive"));
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.command.tool.BlockDataCyler;
|
||||
import com.sk89q.worldedit.command.tool.BlockReplacer;
|
||||
import com.sk89q.worldedit.command.tool.DistanceWand;
|
||||
@ -122,10 +121,10 @@ public class ToolCommands {
|
||||
return "/tool " + name;
|
||||
}
|
||||
|
||||
static void setToolNone(Player player, LocalSession session, String type)
|
||||
static void setToolNone(Player player, LocalSession session, boolean isBrush)
|
||||
throws InvalidToolBindException {
|
||||
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null);
|
||||
player.print(type + " unbound from your current item.");
|
||||
player.printInfo(TranslatableComponent.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip"));
|
||||
}
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -140,7 +139,7 @@ public class ToolCommands {
|
||||
desc = "Unbind a bound tool from your current item"
|
||||
)
|
||||
public void none(Player player, LocalSession session) throws WorldEditException {
|
||||
setToolNone(player, session, "Tool");
|
||||
setToolNone(player, session, false);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -153,7 +152,7 @@ public class ToolCommands {
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new SelectionWand());
|
||||
player.print("Selection wand bound to " + itemType.getName() + ".");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.selwand.equip", TextComponent.of(itemType.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -164,9 +163,9 @@ public class ToolCommands {
|
||||
@CommandPermissions("worldedit.setwand")
|
||||
public void navwand(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new NavigationWand());
|
||||
player.print("Navigation wand bound to " + itemStack.getType().getName() + ".");
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new NavigationWand());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.navWand.equip", TextComponent.of(itemType.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -176,10 +175,9 @@ public class ToolCommands {
|
||||
@CommandPermissions("worldedit.tool.info")
|
||||
public void info(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new QueryTool());
|
||||
player.print("Info tool bound to "
|
||||
+ itemStack.getType().getName() + ".");
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new QueryTool());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.info.equip", TextComponent.of(itemType.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -191,9 +189,9 @@ public class ToolCommands {
|
||||
@Arg(desc = "Type of tree to generate", def = "tree")
|
||||
TreeGenerator.TreeType type) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new TreePlanter(type));
|
||||
player.print("Tree tool bound to " + itemStack.getType().getName() + ".");
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new TreePlanter(type));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.tree.equip", TextComponent.of(itemType.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -205,9 +203,9 @@ public class ToolCommands {
|
||||
@Arg(desc = "The pattern of blocks to place")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new BlockReplacer(pattern));
|
||||
player.print("Block replacer tool bound to " + itemStack.getType().getName() + ".");
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new BlockReplacer(pattern));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.repl.equip", TextComponent.of(itemType.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -217,9 +215,9 @@ public class ToolCommands {
|
||||
@CommandPermissions("worldedit.tool.data-cycler")
|
||||
public void cycler(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new BlockDataCyler());
|
||||
player.print("Block data cycler tool bound to " + itemStack.getType().getName() + ".");
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new BlockDataCyler());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.data-cycler.equip", TextComponent.of(itemType.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -237,13 +235,13 @@ public class ToolCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||
player.printError(TranslatableComponent.of("worldedit.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
|
||||
return;
|
||||
}
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new FloodFillTool(range, pattern));
|
||||
player.print("Block flood fill tool bound to " + itemStack.getType().getName() + ".");
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new FloodFillTool(range, pattern));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.floodfill.equip", TextComponent.of(itemType.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -253,10 +251,9 @@ public class ToolCommands {
|
||||
@CommandPermissions("worldedit.tool.deltree")
|
||||
public void deltree(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new FloatingTreeRemover());
|
||||
player.print("Floating tree remover tool bound to "
|
||||
+ itemStack.getType().getName() + ".");
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new FloatingTreeRemover());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.deltree.equip", TextComponent.of(itemType.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -266,9 +263,9 @@ public class ToolCommands {
|
||||
@CommandPermissions("worldedit.tool.farwand")
|
||||
public void farwand(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), new DistanceWand());
|
||||
player.print("Far wand tool bound to " + itemStack.getType().getName() + ".");
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new DistanceWand());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.farwand.equip", TextComponent.of(itemType.getName())));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -282,10 +279,10 @@ public class ToolCommands {
|
||||
Pattern primary,
|
||||
@Arg(desc = "Pattern to set on right-click")
|
||||
Pattern secondary) throws WorldEditException {
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
|
||||
session.setTool(itemStack.getType(), new LongRangeBuildTool(primary, secondary));
|
||||
player.print("Long-range building tool bound to " + itemStack.getType().getName() + ".");
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(itemType, new LongRangeBuildTool(primary, secondary));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.lrbuild.equip", TextComponent.of(itemType.getName())));
|
||||
String primaryName = "pattern";
|
||||
String secondaryName = "pattern";
|
||||
if (primary instanceof BlockStateHolder) {
|
||||
@ -294,7 +291,6 @@ public class ToolCommands {
|
||||
if (secondary instanceof BlockStateHolder) {
|
||||
secondaryName = ((BlockStateHolder<?>) secondary).getBlockType().getName();
|
||||
}
|
||||
player.print("Left-click set to " + primaryName + "; right-click set to "
|
||||
+ secondaryName + ".");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.lrbuild.set", TextComponent.of(primaryName), TextComponent.of(secondaryName)));
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
@ -54,15 +55,15 @@ public class ToolUtilCommands {
|
||||
Boolean superPickaxe) {
|
||||
boolean hasSuperPickAxe = session.hasSuperPickAxe();
|
||||
if (superPickaxe != null && superPickaxe == hasSuperPickAxe) {
|
||||
player.printError("Super pickaxe already " + (superPickaxe ? "enabled" : "disabled") + ".");
|
||||
player.printError(TranslatableComponent.of(superPickaxe ? "worldedit.tool.superpickaxe.enabled.already" : "worldedit.tool.superpickaxe.disabled.already"));
|
||||
return;
|
||||
}
|
||||
if (hasSuperPickAxe) {
|
||||
session.disableSuperPickAxe();
|
||||
player.print("Super pickaxe disabled.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.disabled"));
|
||||
} else {
|
||||
session.enableSuperPickAxe();
|
||||
player.print("Super pickaxe enabled.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.enabled"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -77,9 +78,9 @@ public class ToolUtilCommands {
|
||||
Mask mask) throws WorldEditException {
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setMask(mask);
|
||||
if (mask == null) {
|
||||
player.print("Brush mask disabled.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.mask.disabled"));
|
||||
} else {
|
||||
player.print("Brush mask set.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.mask.set"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +94,7 @@ public class ToolUtilCommands {
|
||||
@Arg(desc = "The pattern of blocks to use")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setFill(pattern);
|
||||
player.print("Brush material set.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.material.set"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -105,7 +106,7 @@ public class ToolUtilCommands {
|
||||
@Arg(desc = "The range of the brush")
|
||||
int range) throws WorldEditException {
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range);
|
||||
player.print("Brush range set.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.range.set"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -119,7 +120,7 @@ public class ToolUtilCommands {
|
||||
we.checkMaxBrushRadius(size);
|
||||
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setSize(size);
|
||||
player.print("Brush size set.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.size.set"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -132,9 +133,9 @@ public class ToolUtilCommands {
|
||||
Mask mask) throws WorldEditException {
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setTraceMask(mask);
|
||||
if (mask == null) {
|
||||
player.print("Trace mask disabled.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.tracemask.disabled"));
|
||||
} else {
|
||||
player.print("Trace mask set.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.tracemask.set"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,9 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -99,7 +101,7 @@ public class UtilityCommands {
|
||||
|
||||
BlockVector3 pos = session.getPlacementPosition(actor);
|
||||
int affected = editSession.fillXZ(pos, pattern, radius, depth, false);
|
||||
actor.print(affected + " block(s) have been created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.fill.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -123,7 +125,7 @@ public class UtilityCommands {
|
||||
|
||||
BlockVector3 pos = session.getPlacementPosition(actor);
|
||||
int affected = editSession.fillXZ(pos, pattern, radius, depth, true);
|
||||
actor.print(affected + " block(s) have been created.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.fillr.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -140,9 +142,8 @@ public class UtilityCommands {
|
||||
boolean waterlogged) throws WorldEditException {
|
||||
radius = Math.max(0, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
int affected = editSession.drainArea(
|
||||
session.getPlacementPosition(actor), radius, waterlogged);
|
||||
actor.print(affected + " block(s) have been changed.");
|
||||
int affected = editSession.drainArea(session.getPlacementPosition(actor), radius, waterlogged);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.drain.drained", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -159,7 +160,7 @@ public class UtilityCommands {
|
||||
radius = Math.max(0, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.LAVA);
|
||||
actor.print(affected + " block(s) have been changed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.fixlava.fixed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -176,7 +177,7 @@ public class UtilityCommands {
|
||||
radius = Math.max(0, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.WATER);
|
||||
actor.print(affected + " block(s) have been changed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.fixwater.fixed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -197,7 +198,7 @@ public class UtilityCommands {
|
||||
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
|
||||
|
||||
int affected = editSession.removeAbove(session.getPlacementPosition(actor), size, height);
|
||||
actor.print(affected + " block(s) have been removed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.removeabove.removed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -218,7 +219,7 @@ public class UtilityCommands {
|
||||
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
|
||||
|
||||
int affected = editSession.removeBelow(session.getPlacementPosition(actor), size, height);
|
||||
actor.print(affected + " block(s) have been removed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.removebelow.removed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -238,7 +239,7 @@ public class UtilityCommands {
|
||||
we.checkMaxRadius(radius);
|
||||
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, radius);
|
||||
actor.print(affected + " block(s) have been removed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.removenear.removed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -269,7 +270,7 @@ public class UtilityCommands {
|
||||
}
|
||||
|
||||
int affected = editSession.replaceBlocks(region, from, to);
|
||||
actor.print(affected + " block(s) have been replaced.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.replacenear.replaced", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -287,7 +288,7 @@ public class UtilityCommands {
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.simulateSnow(session.getPlacementPosition(actor), size);
|
||||
actor.print(affected + " surface(s) covered. Let it snow~");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.snow.created", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -305,7 +306,7 @@ public class UtilityCommands {
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.thaw(session.getPlacementPosition(actor), size);
|
||||
actor.print(affected + " surface(s) thawed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.thaw.removed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -326,7 +327,7 @@ public class UtilityCommands {
|
||||
final boolean onlyNormalDirt = !convertCoarse;
|
||||
|
||||
final int affected = editSession.green(session.getPlacementPosition(actor), size, onlyNormalDirt);
|
||||
actor.print(affected + " surface(s) greened.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.green.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -337,7 +338,7 @@ public class UtilityCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.extinguish")
|
||||
@Logging(PLACEMENT)
|
||||
public void extinguish(Actor actor, LocalSession session, EditSession editSession,
|
||||
public int extinguish(Actor actor, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The radius of the square to remove in", def = "")
|
||||
Integer radius) throws WorldEditException {
|
||||
|
||||
@ -349,7 +350,8 @@ public class UtilityCommands {
|
||||
|
||||
Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE);
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, size);
|
||||
actor.print(affected + " block(s) have been removed.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.extinguish.removed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -382,7 +384,7 @@ public class UtilityCommands {
|
||||
if (radius == null) {
|
||||
radius = config.butcherDefaultRadius;
|
||||
} else if (radius < -1) {
|
||||
actor.printError("Use -1 to remove all mobs in loaded chunks");
|
||||
actor.printError(TranslatableComponent.of("worldedit.butcher.explain-all"));
|
||||
return 0;
|
||||
} else if (radius == -1) {
|
||||
if (config.butcherMaxRadius != -1) {
|
||||
@ -405,7 +407,11 @@ public class UtilityCommands {
|
||||
|
||||
int killed = killMatchingEntities(radius, actor, flags::createFunction);
|
||||
|
||||
actor.print("Killed " + killed + (killed != 1 ? " mobs" : " mob") + (radius < 0 ? "" : " in a radius of " + radius) + ".");
|
||||
actor.printInfo(TranslatableComponent.of(
|
||||
"worldedit.butcher.killed",
|
||||
TextComponent.of(killed),
|
||||
TextComponent.of(radius)
|
||||
));
|
||||
|
||||
return killed;
|
||||
}
|
||||
@ -423,13 +429,12 @@ public class UtilityCommands {
|
||||
@Arg(desc = "The radius of the cuboid to remove from")
|
||||
int radius) throws WorldEditException {
|
||||
if (radius < -1) {
|
||||
actor.printError("Use -1 to remove all entities in loaded chunks");
|
||||
actor.printError(TranslatableComponent.of("worldedit.remove.explain-all"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int removed = killMatchingEntities(radius, actor, remover::createFunction);
|
||||
|
||||
actor.print("Marked " + removed + (removed != 1 ? " entities" : " entity") + " for removal.");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.remove.removed", TextComponent.of(removed)));
|
||||
return removed;
|
||||
}
|
||||
|
||||
@ -460,10 +465,10 @@ public class UtilityCommands {
|
||||
return killed;
|
||||
}
|
||||
|
||||
// get the formatter with the system locale. in the future, if we can get a local from a player, we can use that
|
||||
private static final DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.getDefault());
|
||||
static {
|
||||
formatter.applyPattern("#,##0.#####"); // pattern is locale-insensitive. this can translate to "1.234,56789"
|
||||
private DecimalFormat formatForLocale(Locale locale) {
|
||||
DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(locale);
|
||||
format.applyPattern("#,##0.#####");
|
||||
return format;
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -479,16 +484,15 @@ public class UtilityCommands {
|
||||
try {
|
||||
expression = Expression.compile(String.join(" ", input));
|
||||
} catch (ExpressionException e) {
|
||||
actor.printError(String.format(
|
||||
"'%s' could not be parsed as a valid expression", input));
|
||||
actor.printError(TranslatableComponent.of("worldedit.calc.invalid", TextComponent.of(String.join(" ", input))));
|
||||
return;
|
||||
}
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
|
||||
double result = expression.evaluate(
|
||||
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
|
||||
String formatted = Double.isNaN(result) ? "NaN" : formatter.format(result);
|
||||
String formatted = Double.isNaN(result) ? "NaN" : formatForLocale(actor.getLocale()).format(result);
|
||||
return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
|
||||
}, null);
|
||||
}, (Component) null);
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -30,9 +30,13 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.NoCapablePlatformException;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.util.formatting.component.MessageBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.util.paste.ActorCallbackPaste;
|
||||
import com.sk89q.worldedit.util.report.ConfigReport;
|
||||
import com.sk89q.worldedit.util.report.ReportList;
|
||||
@ -45,14 +49,13 @@ import org.enginehub.piston.annotation.param.Switch;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.TextStyle;
|
||||
import java.time.zone.ZoneRulesException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class WorldEditCommands {
|
||||
@ -70,25 +73,31 @@ public class WorldEditCommands {
|
||||
desc = "Get WorldEdit version"
|
||||
)
|
||||
public void version(Actor actor) {
|
||||
actor.print("WorldEdit version " + WorldEdit.getVersion());
|
||||
actor.print("https://github.com/EngineHub/worldedit/");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.version.version", TextComponent.of(WorldEdit.getVersion())));
|
||||
actor.printInfo(TextComponent.of("https://github.com/EngineHub/WorldEdit/"));
|
||||
|
||||
PlatformManager pm = we.getPlatformManager();
|
||||
|
||||
actor.printDebug("----------- Platforms -----------");
|
||||
TextComponentProducer producer = new TextComponentProducer();
|
||||
for (Platform platform : pm.getPlatforms()) {
|
||||
actor.printDebug(String.format("* %s (%s)", platform.getPlatformName(), platform.getPlatformVersion()));
|
||||
producer.append(
|
||||
TextComponent.of("* ", TextColor.GRAY)
|
||||
.append(TextComponent.of(platform.getPlatformName()))
|
||||
.append(TextComponent.of("(" + platform.getPlatformVersion() + ")"))
|
||||
).newline();
|
||||
}
|
||||
actor.print(new MessageBox("Platforms", producer, TextColor.GRAY).create());
|
||||
|
||||
actor.printDebug("----------- Capabilities -----------");
|
||||
producer.reset();
|
||||
for (Capability capability : Capability.values()) {
|
||||
try {
|
||||
Platform platform = pm.queryCapability(capability);
|
||||
actor.printDebug(String.format("%s: %s", capability.name(), platform != null ? platform.getPlatformName() : "NONE"));
|
||||
} catch (NoCapablePlatformException e) {
|
||||
actor.printDebug(String.format("%s: %s", capability.name(), "NONE"));
|
||||
}
|
||||
Platform platform = pm.queryCapability(capability);
|
||||
producer.append(
|
||||
TextComponent.of(capability.name(), TextColor.GRAY)
|
||||
.append(TextComponent.of(": ")
|
||||
.append(TextComponent.of(platform != null ? platform.getPlatformName() : "NONE")))
|
||||
).newline();
|
||||
}
|
||||
actor.print(new MessageBox("Capabilities", producer, TextColor.GRAY).create());
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -99,7 +108,7 @@ public class WorldEditCommands {
|
||||
public void reload(Actor actor) {
|
||||
we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload();
|
||||
we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
|
||||
actor.print("Configuration reloaded!");
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.reload.config"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -117,15 +126,15 @@ public class WorldEditCommands {
|
||||
|
||||
try {
|
||||
File dest = new File(we.getConfiguration().getWorkingDirectory(), "report.txt");
|
||||
Files.write(result, dest, Charset.forName("UTF-8"));
|
||||
actor.print("WorldEdit report written to " + dest.getAbsolutePath());
|
||||
Files.write(result, dest, StandardCharsets.UTF_8);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.report.written", TextComponent.of(dest.getAbsolutePath())));
|
||||
} catch (IOException e) {
|
||||
actor.printError("Failed to write report: " + e.getMessage());
|
||||
actor.printError(TranslatableComponent.of("worldedit.report.error", TextComponent.of(e.getMessage())));
|
||||
}
|
||||
|
||||
if (pastebin) {
|
||||
actor.checkPermission("worldedit.report.pastebin");
|
||||
ActorCallbackPaste.pastebin(we.getSupervisor(), actor, result, "WorldEdit report: %s.report");
|
||||
ActorCallbackPaste.pastebin(we.getSupervisor(), actor, result, TranslatableComponent.builder("worldedit.report.callback"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,12 +157,13 @@ public class WorldEditCommands {
|
||||
try {
|
||||
ZoneId tz = ZoneId.of(timezone);
|
||||
session.setTimezone(tz);
|
||||
actor.print("Timezone set for this session to: " + tz.getDisplayName(
|
||||
TextStyle.FULL, Locale.ENGLISH
|
||||
));
|
||||
actor.print("The current time in that timezone is: " + dateFormat.format(ZonedDateTime.now(tz)));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.timezone.set", TextComponent.of(tz.getDisplayName(
|
||||
TextStyle.FULL, actor.getLocale()
|
||||
))));
|
||||
actor.print(TranslatableComponent.of("worldedit.timezone.current",
|
||||
TextComponent.of(dateFormat.withLocale(actor.getLocale()).format(ZonedDateTime.now(tz)))));
|
||||
} catch (ZoneRulesException e) {
|
||||
actor.printError("Invalid timezone");
|
||||
actor.printError(TranslatableComponent.of("worldedit.timezone.invalid"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -83,7 +84,7 @@ public class AreaPickaxe implements BlockTool {
|
||||
}
|
||||
}
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
@ -61,12 +63,12 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
if (!config.allowedDataCycleBlocks.isEmpty()
|
||||
&& !player.hasPermission("worldedit.override.data-cycler")
|
||||
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) {
|
||||
player.printError("You are not permitted to cycle the data value of that block.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.data-cycler.block-not-permitted"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (block.getStates().keySet().isEmpty()) {
|
||||
player.printError("That block's data cannot be cycled!");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.data-cycler.cant-cycle"));
|
||||
} else {
|
||||
Property<?> currentProperty = selectedProperties.get(player.getUniqueId());
|
||||
|
||||
@ -88,9 +90,13 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
|
||||
try {
|
||||
editSession.setBlock(blockPoint, newBlock);
|
||||
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index));
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.tool.data-cycler.new-value",
|
||||
TextComponent.of(currentProperty.getName()),
|
||||
TextComponent.of(String.valueOf(currentProperty.getValues().get(index)))
|
||||
));
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
@ -101,7 +107,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
index = (index + 1) % properties.size();
|
||||
currentProperty = properties.get(index);
|
||||
selectedProperties.put(player.getUniqueId(), currentProperty);
|
||||
player.print("Now cycling " + currentProperty.getName());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.data-cycler.cycling", TextComponent.of(currentProperty.getName())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,8 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
/**
|
||||
@ -77,7 +79,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
|
||||
if (targetBlock != null) {
|
||||
pattern = targetBlock;
|
||||
player.print("Replacer tool switched to: " + targetBlock.getBlockType().getName());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.repl.switched", TextComponent.of(targetBlock.getBlockType().getName())));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -35,6 +35,7 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -183,7 +184,7 @@ public class BrushTool implements TraceTool {
|
||||
Location target = player.getBlockTrace(getRange(), true, traceMask);
|
||||
|
||||
if (target == null) {
|
||||
player.printError("No block in sight!");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.no-block"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -207,7 +208,7 @@ public class BrushTool implements TraceTool {
|
||||
try {
|
||||
brush.build(editSession, target.toVector().toBlockPoint(), material, size);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
/**
|
||||
* A wand that can be used at a distance.
|
||||
@ -74,7 +75,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
player.printError("No block in sight!");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.no-block"));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -72,7 +73,7 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
final BlockState state = world.getBlock(clicked.toVector().toBlockPoint());
|
||||
|
||||
if (!isTreeBlock(state.getBlockType())) {
|
||||
player.printError("That's not a tree.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.deltree.not-tree"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -80,7 +81,7 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
try {
|
||||
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
|
||||
if (blockSet == null) {
|
||||
player.printError("That's not a floating tree.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.deltree.not-floating"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -91,7 +92,7 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
}
|
||||
}
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -73,7 +74,7 @@ public class FloodFillTool implements BlockTool {
|
||||
try {
|
||||
recurse(editSession, origin, origin, range, initialType, new HashSet<>());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
/**
|
||||
@ -118,7 +119,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
player.printError("No block in sight!");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.no-block"));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
public class NavigationWand implements DoubleActionTraceTool {
|
||||
@Override
|
||||
@ -40,7 +41,7 @@ public class NavigationWand implements DoubleActionTraceTool {
|
||||
if (pos != null) {
|
||||
player.findFreePosition(pos);
|
||||
} else {
|
||||
player.printError("No block in sight (or too far)!");
|
||||
player.printError(TranslatableComponent.of("worldedit.jumpto.none"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -56,7 +57,7 @@ public class NavigationWand implements DoubleActionTraceTool {
|
||||
}
|
||||
|
||||
if (!player.passThroughForwardWall(Math.max(1, maxDist - 10))) {
|
||||
player.printError("Nothing to pass through (or too far)!");
|
||||
player.printError(TranslatableComponent.of("worldedit.thru.obstructed"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -58,15 +59,15 @@ public class QueryTool implements BlockTool {
|
||||
builder.append(TextComponent.of("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE));
|
||||
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
|
||||
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state"))));
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.blockstate.hover"))));
|
||||
final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
|
||||
if (internalId.isPresent()) {
|
||||
builder.append(TextComponent.of(" (" + internalId.getAsInt() + ") ", TextColor.DARK_GRAY)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Internal ID"))));
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.internalid.hover"))));
|
||||
}
|
||||
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
|
||||
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.light.hover"))));
|
||||
|
||||
player.print(builder.build());
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -74,7 +75,7 @@ public class RecursivePickaxe implements BlockTool {
|
||||
recurse(server, editSession, world, clicked.toVector().toBlockPoint(),
|
||||
clicked.toVector().toBlockPoint(), range, initialType, new HashSet<>());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -55,7 +56,7 @@ public class SinglePickaxe implements BlockTool {
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
||||
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
/**
|
||||
* Plants a tree.
|
||||
@ -62,10 +63,10 @@ public class TreePlanter implements BlockTool {
|
||||
}
|
||||
|
||||
if (!successful) {
|
||||
player.printError("A tree can't go there.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.tree.obstructed"));
|
||||
}
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max. blocks changed reached.");
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public final class AsyncCommandBuilder<T> {
|
||||
@Nullable
|
||||
private String description;
|
||||
@Nullable
|
||||
private String delayMessage;
|
||||
private Component delayMessage;
|
||||
|
||||
@Nullable
|
||||
private Component successMessage;
|
||||
@ -84,7 +84,12 @@ public final class AsyncCommandBuilder<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AsyncCommandBuilder<T> sendMessageAfterDelay(String message) {
|
||||
return sendMessageAfterDelay(TextComponent.of(checkNotNull(message)));
|
||||
}
|
||||
|
||||
public AsyncCommandBuilder<T> sendMessageAfterDelay(Component message) {
|
||||
this.delayMessage = checkNotNull(message);
|
||||
return this;
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.Timer;
|
||||
|
||||
@ -34,7 +36,12 @@ public class FutureProgressListener implements Runnable {
|
||||
|
||||
private final MessageTimerTask task;
|
||||
|
||||
@Deprecated
|
||||
public FutureProgressListener(Actor sender, String message) {
|
||||
this(sender, TextComponent.of(message));
|
||||
}
|
||||
|
||||
public FutureProgressListener(Actor sender, Component message) {
|
||||
checkNotNull(sender);
|
||||
checkNotNull(message);
|
||||
|
||||
@ -47,8 +54,13 @@ public class FutureProgressListener implements Runnable {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addProgressListener(ListenableFuture<?> future, Actor sender, String message) {
|
||||
future.addListener(new FutureProgressListener(sender, message), MoreExecutors.directExecutor());
|
||||
}
|
||||
|
||||
public static void addProgressListener(ListenableFuture<?> future, Actor sender, Component message) {
|
||||
future.addListener(new FutureProgressListener(sender, message), MoreExecutors.directExecutor());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,15 +22,22 @@ package com.sk89q.worldedit.command.util;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class MessageTimerTask extends TimerTask {
|
||||
|
||||
private final Actor sender;
|
||||
private final String message;
|
||||
private final Component message;
|
||||
|
||||
@Deprecated
|
||||
MessageTimerTask(Actor sender, String message) {
|
||||
this(sender, TextComponent.of(message));
|
||||
}
|
||||
|
||||
MessageTimerTask(Actor sender, Component message) {
|
||||
checkNotNull(sender);
|
||||
checkNotNull(message);
|
||||
|
||||
|
@ -19,14 +19,19 @@
|
||||
|
||||
package com.sk89q.worldedit.command.util;
|
||||
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.byCleanName;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.InvalidComponentException;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
|
||||
@ -37,10 +42,6 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.byCleanName;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
/**
|
||||
* Implementation of the //help command.
|
||||
*/
|
||||
@ -78,7 +79,7 @@ public class PrintCommandHelp {
|
||||
List<Command> visited = new ArrayList<>();
|
||||
Command currentCommand = detectCommand(manager, commandPath.get(0));
|
||||
if (currentCommand == null) {
|
||||
actor.printError(String.format("The command '%s' could not be found.", commandPath.get(0)));
|
||||
actor.printError(TranslatableComponent.of("worldedit.help.command-not-found", TextComponent.of(commandPath.get(0))));
|
||||
return;
|
||||
}
|
||||
visited.add(currentCommand);
|
||||
@ -89,8 +90,8 @@ public class PrintCommandHelp {
|
||||
Map<String, Command> subCommands = getSubCommands(currentCommand);
|
||||
|
||||
if (subCommands.isEmpty()) {
|
||||
actor.printError(String.format("'%s' has no sub-commands. (Maybe '%s' is for a parameter?)",
|
||||
toCommandString(visited), subCommand));
|
||||
actor.printError(TranslatableComponent.of("worldedit.help.no-subcommands",
|
||||
TextComponent.of(toCommandString(visited)), TextComponent.of(subCommand)));
|
||||
// full help for single command
|
||||
CommandUsageBox box = new CommandUsageBox(visited, visited.stream()
|
||||
.map(Command::getName).collect(Collectors.joining(" ")), helpRootCommand);
|
||||
@ -102,8 +103,8 @@ public class PrintCommandHelp {
|
||||
currentCommand = subCommands.get(subCommand);
|
||||
visited.add(currentCommand);
|
||||
} else {
|
||||
actor.printError(String.format("The sub-command '%s' under '%s' could not be found.",
|
||||
subCommand, toCommandString(visited)));
|
||||
actor.printError(TranslatableComponent.of("worldedit.help.subcommand-not-found",
|
||||
TextComponent.of(subCommand), TextComponent.of(toCommandString(visited))));
|
||||
// list subcommands for currentCommand
|
||||
printCommands(page, getSubCommands(Iterables.getLast(visited)).values().stream(), actor, visited, helpRootCommand);
|
||||
return;
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.command.util;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.concurrent.Callable;
|
||||
@ -33,13 +34,18 @@ public final class WorldEditAsyncCommandBuilder {
|
||||
private WorldEditAsyncCommandBuilder() {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void createAndSendMessage(Actor actor, Callable<Component> task, @Nullable String desc) {
|
||||
createAndSendMessage(actor, task, desc != null ? TextComponent.of(desc) : null);
|
||||
}
|
||||
|
||||
public static void createAndSendMessage(Actor actor, Callable<Component> task, @Nullable Component desc) {
|
||||
final AsyncCommandBuilder<Component> builder = AsyncCommandBuilder.wrap(task, actor);
|
||||
if (desc != null) {
|
||||
builder.sendMessageAfterDelay(desc);
|
||||
}
|
||||
builder
|
||||
.onSuccess((String) null, actor::print)
|
||||
.onSuccess((String) null, actor::printInfo)
|
||||
.onFailure((String) null, WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getExceptionConverter())
|
||||
.buildAndExec(WorldEdit.getInstance().getExecutorService());
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TargetBlock;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -264,10 +265,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
int platformY = Math.max(initialY, y - 3 - clearance);
|
||||
if (platformY < initialY) { // if ==, they already have the given clearance, if <, clearance is too large
|
||||
printError("Not enough space above you!");
|
||||
return false;
|
||||
} else if (platformY == initialY) {
|
||||
printError("You're already at the ceiling.");
|
||||
return false;
|
||||
}
|
||||
floatAt(x, platformY + 1, z, alwaysGlass);
|
||||
@ -492,13 +491,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
@Override
|
||||
public File openFileOpenDialog(String[] extensions) {
|
||||
printError("File dialogs are not supported in your environment.");
|
||||
printError(TranslatableComponent.of("worldedit.platform.no-file-dialog"));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File openFileSaveDialog(String[] extensions) {
|
||||
printError("File dialogs are not supported in your environment.");
|
||||
printError(TranslatableComponent.of("worldedit.platform.no-file-dialog"));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -547,7 +546,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("CloneDoesntCallSuperClone")
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
throw new CloneNotSupportedException("Not supported");
|
||||
|
@ -24,8 +24,10 @@ import com.sk89q.worldedit.session.SessionOwner;
|
||||
import com.sk89q.worldedit.util.Identifiable;
|
||||
import com.sk89q.worldedit.util.auth.Subject;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* An object that can perform actions in WorldEdit.
|
||||
@ -52,30 +54,65 @@ public interface Actor extends Identifiable, SessionOwner, Subject {
|
||||
* Print a message.
|
||||
*
|
||||
* @param msg The message text
|
||||
* @deprecated Use component-based functions (print)
|
||||
*/
|
||||
@Deprecated
|
||||
void printRaw(String msg);
|
||||
|
||||
/**
|
||||
* Print a WorldEdit message.
|
||||
*
|
||||
* @param msg The message text
|
||||
* @deprecated Use component-based functions (printDebug)
|
||||
*/
|
||||
@Deprecated
|
||||
void printDebug(String msg);
|
||||
|
||||
/**
|
||||
* Print a WorldEdit message.
|
||||
*
|
||||
* @param msg The message text
|
||||
* @deprecated Use component-based functions (printInfo)
|
||||
*/
|
||||
@Deprecated
|
||||
void print(String msg);
|
||||
|
||||
/**
|
||||
* Print a WorldEdit error.
|
||||
*
|
||||
* @param msg The error message text
|
||||
* @deprecated Use component-based functions (printError)
|
||||
*/
|
||||
@Deprecated
|
||||
void printError(String msg);
|
||||
|
||||
/**
|
||||
* Print a WorldEdit error.
|
||||
*
|
||||
* @param component The component to print
|
||||
*/
|
||||
default void printError(Component component) {
|
||||
print(component.color(TextColor.RED));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a WorldEdit message.
|
||||
*
|
||||
* @param component The component to print
|
||||
*/
|
||||
default void printInfo(Component component) {
|
||||
print(component.color(TextColor.LIGHT_PURPLE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a WorldEdit message.
|
||||
*
|
||||
* @param component The component to print
|
||||
*/
|
||||
default void printDebug(Component component) {
|
||||
print(component.color(TextColor.GRAY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a {@link Component}.
|
||||
*
|
||||
@ -120,4 +157,10 @@ public interface Actor extends Identifiable, SessionOwner, Subject {
|
||||
*/
|
||||
void dispatchCUIEvent(CUIEvent event);
|
||||
|
||||
/**
|
||||
* Get the locale of this actor.
|
||||
*
|
||||
* @return The locale
|
||||
*/
|
||||
Locale getLocale();
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
} catch (ConditionFailedException e) {
|
||||
if (e.getCondition() instanceof PermissionCondition) {
|
||||
actor.printError("You are not permitted to do that. Are you in the right mode?");
|
||||
actor.printError(TranslatableComponent.of("worldedit.command.permissions"));
|
||||
} else {
|
||||
actor.print(e.getRichMessage());
|
||||
}
|
||||
@ -533,15 +533,15 @@ public final class PlatformCommandManager {
|
||||
|
||||
if (config.profile) {
|
||||
long time = System.currentTimeMillis() - start;
|
||||
double timeS = (time / 1000.0);
|
||||
int changed = editSession.getBlockChangeCount();
|
||||
if (time > 0) {
|
||||
double throughput = changed / (time / 1000.0);
|
||||
actor.printDebug((time / 1000.0) + "s elapsed (history: "
|
||||
+ changed + " changed; "
|
||||
+ Math.round(throughput) + " blocks/sec).");
|
||||
} else {
|
||||
actor.printDebug((time / 1000.0) + "s elapsed.");
|
||||
}
|
||||
double throughput = timeS == 0 ? changed : changed / timeS;
|
||||
actor.printDebug(TranslatableComponent.of(
|
||||
"worldedit.command.time-elapsed",
|
||||
TextComponent.of(timeS),
|
||||
TextComponent.of(changed),
|
||||
TextComponent.of(Math.round(throughput))
|
||||
));
|
||||
}
|
||||
|
||||
worldEdit.flushBlockBag(actor, editSession);
|
||||
@ -559,7 +559,7 @@ public final class PlatformCommandManager {
|
||||
store.injectValue(Key.of(Player.class), ValueProvider.constant((Player) actor));
|
||||
} else {
|
||||
store.injectValue(Key.of(Player.class), context -> {
|
||||
throw new CommandException(TextComponent.of("This command must be used with a player."), ImmutableList.of());
|
||||
throw new CommandException(TranslatableComponent.of("worldedit.command.player-only"), ImmutableList.of());
|
||||
});
|
||||
}
|
||||
store.injectValue(Key.of(Arguments.class), ValueProvider.constant(arguments));
|
||||
@ -576,8 +576,8 @@ public final class PlatformCommandManager {
|
||||
}
|
||||
|
||||
private void handleUnknownException(Actor actor, Throwable t) {
|
||||
actor.printError("Please report this error: [See console]");
|
||||
actor.printRaw(t.getClass().getName() + ": " + t.getMessage());
|
||||
actor.printError(TranslatableComponent.of("worldedit.command.error.report"));
|
||||
actor.print(TextComponent.of(t.getClass().getName() + ": " + t.getMessage()));
|
||||
log.error("An unexpected error while handling a WorldEdit command", t);
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,6 @@ import com.sk89q.worldedit.event.platform.Interaction;
|
||||
import com.sk89q.worldedit.event.platform.PlatformInitializeEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlayerInputEvent;
|
||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
@ -32,10 +32,12 @@ import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -115,22 +117,22 @@ class PlayerProxy extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
basePlayer.printRaw(msg);
|
||||
basePlayer.print(TextComponent.of(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
basePlayer.printDebug(msg);
|
||||
basePlayer.printDebug(TextComponent.of(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
basePlayer.print(msg);
|
||||
basePlayer.printInfo(TextComponent.of(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
basePlayer.printError(msg);
|
||||
basePlayer.printError(TextComponent.of(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -183,4 +185,9 @@ class PlayerProxy extends AbstractPlayerActor {
|
||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
||||
basePlayer.floatAt(x, y, z, alwaysGlass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return basePlayer.getLocale();
|
||||
}
|
||||
}
|
||||
|
@ -109,10 +109,6 @@ public class ChunkBatchingExtent extends AbstractBufferingExtent {
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -146,10 +146,6 @@ public class FastModeExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.function.factory;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -36,8 +37,10 @@ import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.NullRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
public class Deform implements Contextual<Operation> {
|
||||
|
||||
@ -186,9 +189,11 @@ public class Deform implements Contextual<Operation> {
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
messages.add("deformed using " + expression);
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return ImmutableList.of(TranslatableComponent.of("worldedit.operation.deform.expression",
|
||||
TextComponent.of(expression).color(TextColor.LIGHT_PURPLE)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -162,14 +162,12 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
position = position.add(0, 1, 0);
|
||||
}
|
||||
|
||||
if (editSession.getBlock(position.add(0, -1, 0)).getBlockType() != BlockTypes.GRASS_BLOCK) {
|
||||
if (!editSession.getBlock(position.add(0, -1, 0)).getBlockType().equals(BlockTypes.GRASS_BLOCK)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (editSession.getBlock(position).getBlockType().getMaterial().isAir()) {
|
||||
editSession.setBlock(position, leafPattern);
|
||||
}
|
||||
setBlockIfAir(editSession, position, leafPattern);
|
||||
|
||||
placeVine(position, position.add(0, 0, 1));
|
||||
placeVine(position, position.add(0, 0, -1));
|
||||
|
@ -80,10 +80,6 @@ public class ChangeSetExecutor implements Operation {
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new undo operation.
|
||||
*
|
||||
|
@ -21,8 +21,11 @@ package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -60,9 +63,8 @@ public class DelegateOperation implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
original.addStatusMessages(messages);
|
||||
delegate.addStatusMessages(messages);
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return Iterables.concat(original.getStatusMessages(), delegate.getStatusMessages());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.function.operation;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
@ -46,6 +47,10 @@ import com.sk89q.worldedit.math.transform.Identity;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -337,25 +342,15 @@ public class ForwardExtentCopy implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append(affectedBlocks).append(" block(s)");
|
||||
if (affectedBiomeCols > 0) {
|
||||
if (affectedEntities > 0) {
|
||||
msg.append(", ");
|
||||
} else {
|
||||
msg.append(" and ");
|
||||
}
|
||||
msg.append(affectedBiomeCols).append(" biome(s)");
|
||||
}
|
||||
if (affectedEntities > 0) {
|
||||
if (affectedBiomeCols > 0) {
|
||||
msg.append(",");
|
||||
}
|
||||
msg.append(" and ").append(affectedEntities).append(" entities(s)");
|
||||
}
|
||||
msg.append(" affected.");
|
||||
messages.add(msg.toString());
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return ImmutableList.of(
|
||||
TranslatableComponent.of("worldedit.operation.affected.block",
|
||||
TextComponent.of(affectedBlocks)).color(TextColor.LIGHT_PURPLE),
|
||||
TranslatableComponent.of("worldedit.operation.affected.biome",
|
||||
TextComponent.of(affectedBiomeCols)).color(TextColor.LIGHT_PURPLE),
|
||||
TranslatableComponent.of("worldedit.operation.affected.entity",
|
||||
TextComponent.of(affectedEntities)).color(TextColor.LIGHT_PURPLE)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,9 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* An task that may be split into multiple steps to be run sequentially
|
||||
@ -56,7 +63,34 @@ public interface Operation {
|
||||
* of the operation.
|
||||
*
|
||||
* @param messages The list to add messages to
|
||||
* @deprecated Will be removed in WorldEdit 8.0 - use the Component variant
|
||||
*/
|
||||
void addStatusMessages(List<String> messages);
|
||||
@Deprecated
|
||||
default void addStatusMessages(List<String> messages) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an internal field, and should not be touched.
|
||||
*/
|
||||
Set<String> warnedDeprecatedClasses = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Gets an iterable of messages that describe the current status of the
|
||||
* operation.
|
||||
*
|
||||
* @return The status messages
|
||||
*/
|
||||
default Iterable<Component> getStatusMessages() {
|
||||
// TODO Remove legacy code WorldEdit 8.0.0
|
||||
List<String> oldMessages = new ArrayList<>();
|
||||
addStatusMessages(oldMessages);
|
||||
if (oldMessages.size() > 0) {
|
||||
String className = getClass().getName();
|
||||
if (!warnedDeprecatedClasses.contains(className)) {
|
||||
WorldEdit.logger.warn("An operation is using the old status message API. This will be removed in WorldEdit 8. Class: " + className);
|
||||
warnedDeprecatedClasses.add(className);
|
||||
}
|
||||
}
|
||||
return oldMessages.stream().map(TextComponent::of).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,16 @@ package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Executes multiple queues in order.
|
||||
@ -105,10 +108,8 @@ public class OperationQueue implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
for (Operation operation : operations) {
|
||||
operation.addStatusMessages(messages);
|
||||
}
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return Iterables.concat(operations.stream().map(Operation::getStatusMessages).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,8 +49,4 @@ public class SetLocatedBlocks implements Operation {
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,12 +21,17 @@ package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
@ -119,10 +124,9 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
* @param position the position
|
||||
*/
|
||||
public void visit(BlockVector3 position) {
|
||||
BlockVector3 blockVector = position;
|
||||
if (!visited.contains(blockVector)) {
|
||||
queue.add(blockVector);
|
||||
visited.add(blockVector);
|
||||
if (!visited.contains(position)) {
|
||||
queue.add(position);
|
||||
visited.add(position);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,11 +137,10 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
* @param to the block under question
|
||||
*/
|
||||
private void visit(BlockVector3 from, BlockVector3 to) {
|
||||
BlockVector3 blockVector = to;
|
||||
if (!visited.contains(blockVector)) {
|
||||
visited.add(blockVector);
|
||||
if (!visited.contains(to)) {
|
||||
visited.add(to);
|
||||
if (isVisitable(from, to)) {
|
||||
queue.add(blockVector);
|
||||
queue.add(to);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -183,8 +186,11 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
messages.add(getAffected() + " blocks affected");
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return ImmutableList.of(TranslatableComponent.of(
|
||||
"worldedit.operation.affected.block",
|
||||
TextComponent.of(getAffected())
|
||||
).color(TextColor.LIGHT_PURPLE));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,14 +21,18 @@ package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.EntityFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Visits entities as provided by an {@code Iterator}.
|
||||
@ -77,8 +81,11 @@ public class EntityVisitor implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
messages.add(getAffected() + " entities affected");
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return ImmutableList.of(TranslatableComponent.of(
|
||||
"worldedit.operation.affected.entity",
|
||||
TextComponent.of(getAffected())
|
||||
).color(TextColor.LIGHT_PURPLE));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,14 +21,17 @@ package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Applies region functions to columns in a {@link FlatRegion}.
|
||||
@ -78,8 +81,11 @@ public class FlatRegionVisitor implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
messages.add(getAffected() + " columns affected");
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return ImmutableList.of(TranslatableComponent.of(
|
||||
"worldedit.operation.affected.column",
|
||||
TextComponent.of(getAffected())
|
||||
).color(TextColor.LIGHT_PURPLE));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -128,8 +128,4 @@ public class LayerVisitor implements Operation {
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,17 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Utility class to apply region functions to {@link com.sk89q.worldedit.regions.Region}.
|
||||
@ -67,8 +70,11 @@ public class RegionVisitor implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
messages.add(getAffected() + " blocks affected");
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return ImmutableList.of(TranslatableComponent.of(
|
||||
"worldedit.operation.affected.block",
|
||||
TextComponent.of(getAffected())
|
||||
).color(TextColor.LIGHT_PURPLE));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -154,6 +158,19 @@ public interface RegionSelector {
|
||||
*
|
||||
* @return a list of lines describing the region
|
||||
*/
|
||||
List<String> getInformationLines();
|
||||
@Deprecated
|
||||
default List<String> getInformationLines() {
|
||||
return Lists.newArrayList();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get lines of information about the selection.
|
||||
*
|
||||
* @return a list of lines describing the region.
|
||||
*/
|
||||
default List<Component> getSelectionInfoLines() {
|
||||
return getInformationLines().stream()
|
||||
.map(TextComponent::of)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.polyhedron.Triangle;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -182,16 +185,15 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInformationLines() {
|
||||
List<String> ret = new ArrayList<>();
|
||||
public List<Component> getSelectionInfoLines() {
|
||||
List<Component> ret = new ArrayList<>();
|
||||
|
||||
ret.add("Vertices: "+region.getVertices().size());
|
||||
ret.add("Triangles: "+region.getTriangles().size());
|
||||
ret.add(TranslatableComponent.of("worldedit.selection.convex.info.vertices", TextComponent.of(region.getVertices().size())));
|
||||
ret.add(TranslatableComponent.of("worldedit.selection.convex.info.triangles", TextComponent.of(region.getTriangles().size())));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
checkNotNull(player);
|
||||
@ -200,7 +202,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
|
||||
session.describeCUI(player);
|
||||
|
||||
player.print("Started new selection with vertex "+pos+".");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.selection.convex.explain.primary", TextComponent.of(pos.toString())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -211,7 +213,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
|
||||
session.describeCUI(player);
|
||||
|
||||
player.print("Added vertex " + pos + " to the selection.");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.selection.convex.explain.secondary", TextComponent.of(pos.toString())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,6 +32,9 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -154,9 +157,13 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
checkNotNull(pos);
|
||||
|
||||
if (position1 != null && position2 != null) {
|
||||
player.print("First position set to " + position1 + " (" + region.getArea() + ").");
|
||||
} else {
|
||||
player.print("First position set to " + position1 + ".");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.cuboid.explain.primary-area",
|
||||
TextComponent.of(position1.toString()),
|
||||
TextComponent.of(region.getArea())
|
||||
));
|
||||
} else if (position1 != null) {
|
||||
player.printInfo(TranslatableComponent.of("worldedit.selection.cuboid.explain.primary", TextComponent.of(position1.toString())));
|
||||
}
|
||||
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getArea()));
|
||||
@ -169,9 +176,13 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
checkNotNull(pos);
|
||||
|
||||
if (position1 != null && position2 != null) {
|
||||
player.print("Second position set to " + position2 + " (" + region.getArea() + ").");
|
||||
} else {
|
||||
player.print("Second position set to " + position2 + ".");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.cuboid.explain.secondary-area",
|
||||
TextComponent.of(position2.toString()),
|
||||
TextComponent.of(region.getArea())
|
||||
));
|
||||
} else if (position2 != null) {
|
||||
player.printInfo(TranslatableComponent.of("worldedit.selection.cuboid.explain.secondary", TextComponent.of(position2.toString())));
|
||||
}
|
||||
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea()));
|
||||
@ -241,15 +252,15 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInformationLines() {
|
||||
final List<String> lines = new ArrayList<>();
|
||||
public List<Component> getSelectionInfoLines() {
|
||||
final List<Component> lines = new ArrayList<>();
|
||||
|
||||
if (position1 != null) {
|
||||
lines.add("Position 1: " + position1);
|
||||
lines.add(TranslatableComponent.of("worldedit.selection.cuboid.info.pos1", TextComponent.of(position1.toString())));
|
||||
}
|
||||
|
||||
if (position2 != null) {
|
||||
lines.add("Position 2: " + position2);
|
||||
lines.add(TranslatableComponent.of("worldedit.selection.cuboid.info.pos2", TextComponent.of(position2.toString())));
|
||||
}
|
||||
|
||||
return lines;
|
||||
|
@ -36,6 +36,9 @@ import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
@ -166,7 +169,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Starting a new cylindrical selection at " + pos + ".");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.selection.cylinder.explain.primary", TextComponent.of(pos.toString())));
|
||||
|
||||
session.describeCUI(player);
|
||||
}
|
||||
@ -176,9 +179,14 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
Vector3 center = region.getCenter();
|
||||
|
||||
if (!center.equals(Vector3.ZERO)) {
|
||||
player.print("Radius set to " + NUMBER_FORMAT.format(region.getRadius().getX()) + "/" + NUMBER_FORMAT.format(region.getRadius().getZ()) + " blocks. (" + region.getArea() + ").");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.cylinder.explain.secondary",
|
||||
TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getX())),
|
||||
TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getZ())),
|
||||
TextComponent.of(region.getArea())
|
||||
));
|
||||
} else {
|
||||
player.printError("You must select the center point before setting the radius.");
|
||||
player.printError(TranslatableComponent.of("worldedit.selection.cylinder.explain.secondary-missing"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -233,14 +241,14 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInformationLines() {
|
||||
final List<String> lines = new ArrayList<>();
|
||||
public List<Component> getSelectionInfoLines() {
|
||||
final List<Component> lines = new ArrayList<>();
|
||||
|
||||
if (!region.getCenter().equals(Vector3.ZERO)) {
|
||||
lines.add("Center: " + region.getCenter());
|
||||
lines.add(TranslatableComponent.of("worldedit.selection.cylinder.info.center", TextComponent.of(region.getCenter().toString())));
|
||||
}
|
||||
if (!region.getRadius().equals(Vector2.ZERO)) {
|
||||
lines.add("Radius: " + region.getRadius());
|
||||
lines.add(TranslatableComponent.of("worldedit.selection.cylinder.info.radius", TextComponent.of(region.getRadius().toString())));
|
||||
}
|
||||
|
||||
return lines;
|
||||
|
@ -33,6 +33,9 @@ import com.sk89q.worldedit.regions.EllipsoidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -145,9 +148,16 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
if (isDefined()) {
|
||||
player.print("Center position set to " + region.getCenter() + " (" + region.getArea() + ").");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.ellipsoid.explain.primary-area",
|
||||
TextComponent.of(region.getCenter().toString()),
|
||||
TextComponent.of(region.getArea())
|
||||
));
|
||||
} else {
|
||||
player.print("Center position set to " + region.getCenter() + ".");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.ellipsoid.explain.primary",
|
||||
TextComponent.of(region.getCenter().toString())
|
||||
));
|
||||
}
|
||||
|
||||
session.describeCUI(player);
|
||||
@ -156,9 +166,16 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
if (isDefined()) {
|
||||
player.print("Radius set to " + region.getRadius() + " (" + region.getArea() + ").");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.ellipsoid.explain.secondary-area",
|
||||
TextComponent.of(region.getRadius().toString()),
|
||||
TextComponent.of(region.getArea())
|
||||
));
|
||||
} else {
|
||||
player.print("Radius set to " + region.getRadius() + ".");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.ellipsoid.explain.secondary",
|
||||
TextComponent.of(region.getRadius().toString())
|
||||
));
|
||||
}
|
||||
|
||||
session.describeCUI(player);
|
||||
@ -204,17 +221,17 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInformationLines() {
|
||||
final List<String> lines = new ArrayList<>();
|
||||
public List<Component> getSelectionInfoLines() {
|
||||
final List<Component> lines = new ArrayList<>();
|
||||
|
||||
final Vector3 center = region.getCenter();
|
||||
if (center.lengthSq() > 0) {
|
||||
lines.add("Center: " + center);
|
||||
lines.add(TranslatableComponent.of("worldedit.selection.ellipsoid.info.center", TextComponent.of(center.toString())));
|
||||
}
|
||||
|
||||
final Vector3 radius = region.getRadius();
|
||||
if (radius.lengthSq() > 0) {
|
||||
lines.add("X/Y/Z radius: " + radius);
|
||||
lines.add(TranslatableComponent.of("worldedit.selection.ellipsoid.info.radius", TextComponent.of(radius.toString())));
|
||||
}
|
||||
|
||||
return lines;
|
||||
|
@ -24,6 +24,8 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -129,14 +131,22 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Started selection at " + pos + " (" + region.getArea() + ").");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.extend.explain.primary",
|
||||
TextComponent.of(pos.toString()),
|
||||
TextComponent.of(region.getArea())
|
||||
));
|
||||
|
||||
explainRegionAdjust(player, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Extended selection to encompass " + pos + " (" + region.getArea() + ").");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.extend.explain.secondary",
|
||||
TextComponent.of(pos.toString()),
|
||||
TextComponent.of(region.getArea())
|
||||
));
|
||||
|
||||
explainRegionAdjust(player, session);
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -163,7 +166,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Starting a new polygon at " + pos + ".");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.selection.polygon2d.explain.primary", TextComponent.of(pos.toString())));
|
||||
|
||||
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
|
||||
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(0, pos, getArea()));
|
||||
@ -172,7 +175,11 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Added point #" + region.size() + " at " + pos + ".");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.polygon2d.explain.secondary",
|
||||
TextComponent.of(region.size()),
|
||||
TextComponent.of(pos.toString())
|
||||
));
|
||||
|
||||
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
|
||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
||||
@ -230,8 +237,8 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInformationLines() {
|
||||
return Collections.singletonList("# points: " + region.size());
|
||||
public List<Component> getSelectionInfoLines() {
|
||||
return Collections.singletonList(TranslatableComponent.of("worldedit.selection.polygon2d.info", TextComponent.of(region.size())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,6 +25,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -88,9 +90,13 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
if (isDefined()) {
|
||||
player.print("Radius set to " + region.getRadius().getX() + " (" + region.getArea() + ").");
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.selection.sphere.explain.secondary-defined",
|
||||
TextComponent.of(region.getRadius().getX()),
|
||||
TextComponent.of(region.getArea())
|
||||
));
|
||||
} else {
|
||||
player.print("Radius set to " + region.getRadius().getX() + ".");
|
||||
player.printInfo(TranslatableComponent.of("worldedit.selection.sphere.explain.secondary", TextComponent.of(region.getRadius().getX())));
|
||||
}
|
||||
|
||||
session.describeCUI(player);
|
||||
|
@ -32,6 +32,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
@ -114,7 +115,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
* @param message a message
|
||||
*/
|
||||
public void print(String message) {
|
||||
player.print(message);
|
||||
player.printInfo(TextComponent.of(message));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,16 +124,16 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
* @param message a message
|
||||
*/
|
||||
public void error(String message) {
|
||||
player.printError(message);
|
||||
player.printError(TextComponent.of(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an raw message to the user.
|
||||
* Print a raw message to the user.
|
||||
*
|
||||
* @param message a message
|
||||
*/
|
||||
public void printRaw(String message) {
|
||||
player.printRaw(message);
|
||||
player.print(TextComponent.of(message));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,6 +119,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
|
||||
allowSymlinks = getBool("allow-symbolic-links", allowSymlinks);
|
||||
serverSideCUI = getBool("server-side-cui", serverSideCUI);
|
||||
extendedYLimit = getBool("extended-y-limit", extendedYLimit);
|
||||
setDefaultLocaleName(getString("default-locale", defaultLocaleName));
|
||||
|
||||
LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15));
|
||||
|
||||
|
@ -125,6 +125,8 @@ public class YAMLConfiguration extends LocalConfiguration {
|
||||
shellSaveType = type.isEmpty() ? null : type;
|
||||
|
||||
extendedYLimit = config.getBoolean("compat.extended-y-limit", false);
|
||||
|
||||
setDefaultLocaleName(config.getString("default-locale", defaultLocaleName));
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
|
@ -19,11 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import org.enginehub.piston.config.ConfigHolder;
|
||||
import org.enginehub.piston.config.TextConfig;
|
||||
import org.enginehub.piston.util.TextHelper;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class WorldEditText {
|
||||
public static final ConfigHolder CONFIG_HOLDER = ConfigHolder.create();
|
||||
|
||||
@ -31,12 +34,12 @@ public class WorldEditText {
|
||||
CONFIG_HOLDER.getConfig(TextConfig.commandPrefix()).setValue("/");
|
||||
}
|
||||
|
||||
public static Component format(Component component) {
|
||||
return CONFIG_HOLDER.replace(component);
|
||||
public static Component format(Component component, Locale locale) {
|
||||
return WorldEdit.getInstance().getTranslationManager().convertText(CONFIG_HOLDER.replace(component), locale);
|
||||
}
|
||||
|
||||
public static String reduceToText(Component component) {
|
||||
return TextHelper.reduceToText(format(component));
|
||||
public static String reduceToText(Component component, Locale locale) {
|
||||
return TextHelper.reduceToText(format(component, locale));
|
||||
}
|
||||
|
||||
private WorldEditText() {
|
||||
|
@ -58,6 +58,7 @@ public class CommandListBox extends PaginationBox {
|
||||
appendCommand(alias, description, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void appendCommand(String alias, String description, String insertion) {
|
||||
appendCommand(alias, TextComponent.of(description), insertion);
|
||||
}
|
||||
|
@ -36,13 +36,22 @@ public class MessageBox extends TextComponentProducer {
|
||||
private static final int GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH = 47;
|
||||
|
||||
private TextComponentProducer contents;
|
||||
private TextColor borderColor;
|
||||
|
||||
/**
|
||||
* Create a new box.
|
||||
*/
|
||||
public MessageBox(String title, TextComponentProducer contents) {
|
||||
this(title, contents, TextColor.YELLOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new box.
|
||||
*/
|
||||
public MessageBox(String title, TextComponentProducer contents, TextColor borderColor) {
|
||||
checkNotNull(title);
|
||||
|
||||
this.borderColor = borderColor;
|
||||
append(centerAndBorder(TextComponent.of(title))).newline();
|
||||
this.contents = contents;
|
||||
}
|
||||
@ -74,7 +83,7 @@ public class MessageBox extends TextComponentProducer {
|
||||
|
||||
private TextComponent createBorder(int count) {
|
||||
return TextComponent.of(Strings.repeat("-", count),
|
||||
TextColor.YELLOW, Sets.newHashSet(TextDecoration.STRIKETHROUGH));
|
||||
borderColor, Sets.newHashSet(TextDecoration.STRIKETHROUGH));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class TextUtils {
|
||||
|
||||
private TextUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Join an array of components with a joiner component.
|
||||
*
|
||||
* @param components The components to join
|
||||
* @param joiner The joiner component
|
||||
* @return The joined component
|
||||
*/
|
||||
public static Component join(List<Component> components, Component joiner) {
|
||||
TextComponent.Builder builder = TextComponent.builder();
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
builder.append(components.get(i));
|
||||
if (i < components.size() - 1) {
|
||||
builder.append(joiner);
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Java Locale object by the Minecraft locale tag.
|
||||
*
|
||||
* @param locale The Minecraft locale tag
|
||||
* @return A Java locale
|
||||
*/
|
||||
public static Locale getLocaleByMinecraftTag(String locale) {
|
||||
return Locale.forLanguageTag(locale.replace('_', '-'));
|
||||
}
|
||||
}
|
@ -27,16 +27,27 @@ public class ResourceLoader {
|
||||
private ResourceLoader() {
|
||||
}
|
||||
|
||||
private static URL getResourceForgeHack(String location) throws IOException {
|
||||
try {
|
||||
return new URL("modjar://worldedit/" + location);
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Could not find " + location);
|
||||
}
|
||||
}
|
||||
|
||||
public static URL getResource(Class clazz, String name) throws IOException {
|
||||
URL url = clazz.getResource(name);
|
||||
if (url == null) {
|
||||
try {
|
||||
return new URL("modjar://worldedit/" + clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/") + "/"
|
||||
+ name);
|
||||
} catch (Exception e) {
|
||||
// Not forge.
|
||||
}
|
||||
throw new IOException("Could not find " + name);
|
||||
return getResourceForgeHack(clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/")
|
||||
+ "/" + name);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
public static URL getResourceRoot(String name) throws IOException {
|
||||
URL url = ResourceLoader.class.getResource("/" + name);
|
||||
if (url == null) {
|
||||
return getResourceForgeHack(name);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.util.paste;
|
||||
|
||||
import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.task.Supervisor;
|
||||
|
||||
import java.net.URL;
|
||||
@ -41,7 +43,9 @@ public final class ActorCallbackPaste {
|
||||
* @param sender The sender
|
||||
* @param content The content
|
||||
* @param successMessage The message, formatted with {@link String#format(String, Object...)} on success
|
||||
* @deprecated Use the Component-based version
|
||||
*/
|
||||
@Deprecated
|
||||
public static void pastebin(Supervisor supervisor, final Actor sender, String content, final String successMessage) {
|
||||
Callable<URL> task = paster.paste(content);
|
||||
|
||||
@ -53,4 +57,24 @@ public final class ActorCallbackPaste {
|
||||
.buildAndExec(Pasters.getExecutor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit data to a pastebin service and inform the sender of
|
||||
* success or failure.
|
||||
*
|
||||
* @param supervisor The supervisor instance
|
||||
* @param sender The sender
|
||||
* @param content The content
|
||||
* @param successMessage The message builder, given the URL as an arg
|
||||
*/
|
||||
public static void pastebin(Supervisor supervisor, final Actor sender, String content, final TranslatableComponent.Builder successMessage) {
|
||||
Callable<URL> task = paster.paste(content);
|
||||
|
||||
AsyncCommandBuilder.wrap(task, sender)
|
||||
.registerWithSupervisor(supervisor, "Submitting content to a pastebin service.")
|
||||
.sendMessageAfterDelay(TranslatableComponent.of("worldedit.pastebin.uploading"))
|
||||
.onSuccess((String) null, url -> sender.printInfo(successMessage.args(TextComponent.of(url.toString())).build()))
|
||||
.onFailure("Failed to submit paste", null)
|
||||
.buildAndExec(Pasters.getExecutor());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* 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.util.translation;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.renderer.FriendlyComponentRenderer;
|
||||
import com.sk89q.worldedit.util.io.ResourceLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Handles translations for the plugin.
|
||||
*
|
||||
* These should be in the following format:
|
||||
* plugin.component.message[.meta]*
|
||||
*
|
||||
* Where,
|
||||
* plugin = worldedit
|
||||
* component = The part of the plugin, eg expand
|
||||
* message = A descriptor for which message, eg, expanded
|
||||
* meta = Any extra information such as plural/singular (Can have none to infinite)
|
||||
*/
|
||||
public class TranslationManager {
|
||||
|
||||
private static final Gson gson = new GsonBuilder().create();
|
||||
private static final Type STRING_MAP_TYPE = new TypeToken<Map<String, String>>() {}.getType();
|
||||
|
||||
private final Map<Locale, Map<String, String>> translationMap = new ConcurrentHashMap<>();
|
||||
private final FriendlyComponentRenderer<Locale> friendlyComponentRenderer = FriendlyComponentRenderer.from(
|
||||
(locale, key) -> new MessageFormat(getTranslationMap(locale).getOrDefault(key, key), locale));
|
||||
private Locale defaultLocale = Locale.ENGLISH;
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
private final Set<Locale> checkedLocales = new HashSet<>();
|
||||
|
||||
public TranslationManager(WorldEdit worldEdit) {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
public void setDefaultLocale(Locale defaultLocale) {
|
||||
this.defaultLocale = defaultLocale;
|
||||
}
|
||||
|
||||
private Map<String, String> filterTranslations(Map<String, String> translations) {
|
||||
translations.entrySet().removeIf(entry -> entry.getValue().isEmpty());
|
||||
return translations;
|
||||
}
|
||||
|
||||
private Map<String, String> parseTranslationFile(InputStream inputStream) {
|
||||
return filterTranslations(gson.fromJson(new InputStreamReader(inputStream), STRING_MAP_TYPE));
|
||||
}
|
||||
|
||||
private Optional<Map<String, String>> loadTranslationFile(String filename) {
|
||||
Map<String, String> baseTranslations;
|
||||
|
||||
try {
|
||||
baseTranslations = parseTranslationFile(ResourceLoader.getResourceRoot("lang/" + filename).openStream());
|
||||
} catch (IOException e) {
|
||||
// Seem to be missing base. If the user has provided a file use that.
|
||||
baseTranslations = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
File localFile = worldEdit.getWorkingDirectoryFile("lang/" + filename);
|
||||
if (localFile.exists()) {
|
||||
try {
|
||||
baseTranslations.putAll(parseTranslationFile(new FileInputStream(localFile)));
|
||||
} catch (IOException e) {
|
||||
// Failed to parse custom language file. Worth printing.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return baseTranslations.size() == 0 ? Optional.empty() : Optional.of(baseTranslations);
|
||||
}
|
||||
|
||||
private boolean tryLoadTranslations(Locale locale) {
|
||||
if (checkedLocales.contains(locale)) {
|
||||
return false;
|
||||
}
|
||||
checkedLocales.add(locale);
|
||||
// Make a copy of the default language file
|
||||
Map<String, String> baseTranslations = new ConcurrentHashMap<>();
|
||||
if (!locale.equals(defaultLocale)) {
|
||||
baseTranslations.putAll(getTranslationMap(defaultLocale));
|
||||
}
|
||||
Optional<Map<String, String>> langData = loadTranslationFile(locale.getLanguage() + "-" + locale.getCountry() + "/strings.json");
|
||||
if (!langData.isPresent()) {
|
||||
langData = loadTranslationFile(locale.getLanguage() + "/strings.json");
|
||||
}
|
||||
if (langData.isPresent()) {
|
||||
baseTranslations.putAll(langData.get());
|
||||
translationMap.put(locale, baseTranslations);
|
||||
return true;
|
||||
}
|
||||
if (locale.equals(defaultLocale)) {
|
||||
translationMap.put(Locale.ENGLISH, loadTranslationFile("strings.json").orElseThrow(
|
||||
() -> new RuntimeException("Failed to load WorldEdit strings!")
|
||||
));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Map<String, String> getTranslationMap(Locale locale) {
|
||||
Map<String, String> translations = translationMap.get(locale);
|
||||
if (translations == null) {
|
||||
if (tryLoadTranslations(locale)) {
|
||||
return getTranslationMap(locale);
|
||||
}
|
||||
if (!locale.equals(defaultLocale)) {
|
||||
translations = getTranslationMap(defaultLocale);
|
||||
}
|
||||
}
|
||||
|
||||
return translations;
|
||||
}
|
||||
|
||||
public Component convertText(Component component, Locale locale) {
|
||||
return friendlyComponentRenderer.render(component, locale);
|
||||
}
|
||||
}
|
330
worldedit-core/src/main/resources/lang/strings.json
Normale Datei
330
worldedit-core/src/main/resources/lang/strings.json
Normale Datei
@ -0,0 +1,330 @@
|
||||
{
|
||||
"worldedit.expand.description.vert": "Vertically expand the selection to world limits.",
|
||||
"worldedit.expand.expanded": "Region expanded {0} blocks",
|
||||
"worldedit.expand.expanded.vert": "Region expanded {0} blocks (top-to-bottom).",
|
||||
|
||||
"worldedit.biomeinfo.lineofsight": "Biomes at line of sight point: {0}",
|
||||
"worldedit.biomeinfo.position": "Biomes at your position: {0}",
|
||||
"worldedit.biomeinfo.selection": "Biomes in your selection: {0}",
|
||||
|
||||
"worldedit.brush.radius-too-large": "Maximum allowed brush radius: {0}",
|
||||
"worldedit.brush.apply.description": "Apply brush, apply a function to every block",
|
||||
"worldedit.brush.apply.radius": "The size of the brush",
|
||||
"worldedit.brush.apply.shape": "The shape of the region",
|
||||
"worldedit.brush.apply.type": "Type of brush to use",
|
||||
"worldedit.brush.apply.item.warning": "This brush simulates item usages. Its effects may not work on all platforms, may not be undo-able, and may cause strange interactions with other mods/plugins. Use at your own risk.",
|
||||
"worldedit.brush.paint.description": "Paint brush, apply a function to a surface",
|
||||
"worldedit.brush.paint.size": "The size of the brush",
|
||||
"worldedit.brush.paint.shape": "The shape of the region",
|
||||
"worldedit.brush.paint.density": "The density of the brush",
|
||||
"worldedit.brush.paint.type": "Type of brush to use",
|
||||
"worldedit.brush.paint.item.warning": "This brush simulates item usages. Its effects may not work on all platforms, may not be undo-able, and may cause strange interactions with other mods/plugins. Use at your own risk.",
|
||||
"worldedit.brush.sphere.equip": "Sphere brush shape equipped ({0}).",
|
||||
"worldedit.brush.cylinder.equip": "Cylinder brush shape equipped ({0} by {1}).",
|
||||
"worldedit.brush.clipboard.equip": "Clipboard brush shape equipped.",
|
||||
"worldedit.brush.smooth.equip": "Smooth brush equipped ({0} x {1}x using {2}).",
|
||||
"worldedit.brush.extinguish.equip": "Extinguisher equipped ({0}).",
|
||||
"worldedit.brush.gravity.equip": "Gravity brush equipped ({0}).",
|
||||
"worldedit.brush.butcher.equip": "Butcher brush equipped ({0}).",
|
||||
"worldedit.brush.operation.equip": "Set brush to {0}.",
|
||||
"worldedit.brush.none.equip": "Brush unbound from your current item.",
|
||||
|
||||
"worldedit.setbiome.changed": "Biomes were changed in {0} columns. You may have to rejoin your game (or close and reopen your world) to see a change.",
|
||||
|
||||
"worldedit.drawsel.disabled": "Server CUI disabled.",
|
||||
"worldedit.drawsel.enabled": "Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32.",
|
||||
"worldedit.drawsel.disabled.already": "Server CUI already disabled.",
|
||||
"worldedit.drawsel.enabled.already": "Server CUI already enabled.",
|
||||
"worldedit.limit.too-high": "Your maximum allowable limit is {0}.",
|
||||
"worldedit.limit.set": "Block change limit set to {0}.",
|
||||
"worldedit.limit.return-to-default": "(Use //limit to go back to the default.)",
|
||||
"worldedit.timeout.too-high": "Your maximum allowable timeout is {0}ms.",
|
||||
"worldedit.timeout.set": "Timeout time set to {0} ms.",
|
||||
"worldedit.timeout.return-to-default": " (Use //timeout to go back to the default.)",
|
||||
"worldedit.fast.disabled": "Fast mode disabled.",
|
||||
"worldedit.fast.enabled": "Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes.",
|
||||
"worldedit.fast.disabled.already": "Fast mode already disabled.",
|
||||
"worldedit.fast.enabled.already": "Fast mode already enabled.",
|
||||
"worldedit.reorder.current": "The reorder mode is {0}",
|
||||
"worldedit.reorder.set": "The reorder mode is now {0}",
|
||||
"worldedit.gmask.disabled": "Global mask disabled.",
|
||||
"worldedit.gmask.set": "Global mask set.",
|
||||
"worldedit.toggleplace.pos1": "Now placing at pos #1.",
|
||||
"worldedit.toggleplace.player": "Now placing at the block you stand in.",
|
||||
"worldedit.searchitem.too-short": "Enter a longer search string (len > 2).",
|
||||
"worldedit.searchitem.either-b-or-i": "You cannot use both the 'b' and 'i' flags simultaneously.",
|
||||
"worldedit.searchitem.searching": "(Please wait... searching items.)",
|
||||
"worldedit.watchdog.no-hook": "This platform has no watchdog hook.",
|
||||
"worldedit.watchdog.active.already": "Watchdog hook already active.",
|
||||
"worldedit.watchdog.inactive.already": "Watchdog hook already inactive.",
|
||||
"worldedit.watchdog.active": "Watchdog hook now active.",
|
||||
"worldedit.watchdog.inactive": "Watchdog hook now inactive.",
|
||||
"worldedit.world.remove": "Removed world override.",
|
||||
"worldedit.world.set": "Set the world override to {0}. (Use //world to go back to default)",
|
||||
|
||||
"worldedit.undo.undone": "Undid {0} available edits.",
|
||||
"worldedit.undo.none": "Nothing left to undo.",
|
||||
"worldedit.redo.undone": "Redid {0} available edits.",
|
||||
"worldedit.redo.none": "Nothing left to redo.",
|
||||
"worldedit.clearhistory.cleared": "History cleared.",
|
||||
|
||||
"worldedit.raytrace.noblock": "No block in sight!",
|
||||
|
||||
"worldedit.restore.not-configured": "Snapshot/backup restore is not configured.",
|
||||
"worldedit.restore.not-available": "That snapshot does not exist or is not available.",
|
||||
"worldedit.restore.failed": "Failed to load snapshot: {0}",
|
||||
"worldedit.restore.loaded": "Snapshot '{0}' loaded; now restoring...",
|
||||
"worldedit.restore.restored": "Restored; {0} missing chunks and {1} other errors.",
|
||||
"worldedit.restore.none-for-world": "No snapshots were found for this world.",
|
||||
"worldedit.restore.none-found": "No snapshots were found.",
|
||||
"worldedit.restore.none-found-console": "No snapshots were found. See console for details.",
|
||||
"worldedit.restore.chunk-not-present": "Chunks were not present in snapshot.",
|
||||
"worldedit.restore.chunk-load-failed": "No chunks could be loaded. (Bad archive?)",
|
||||
"worldedit.restore.block-place-failed": "Errors prevented any blocks from being restored.",
|
||||
"worldedit.restore.block-place-error": "Last error: {0}",
|
||||
|
||||
"worldedit.snapshot.use.newest": "Now using newest snapshot.",
|
||||
"worldedit.snapshot.use": "Snapshot set to: {0}",
|
||||
"worldedit.snapshot.none-before": "Couldn't find a snapshot before {0}.",
|
||||
"worldedit.snapshot.none-after": "Couldn't find a snapshot after {0}.",
|
||||
"worldedit.snapshot.index-above-0": "Invalid index, must be equal or higher then 1.",
|
||||
"worldedit.snapshot.index-oob": "Invalid index, must be between 1 and {0}.",
|
||||
|
||||
"worldedit.schematic.unknown-format": "Unknown schematic format: {0}.",
|
||||
"worldedit.schematic.load.does-not-exist": "Schematic {0} does not exist!",
|
||||
"worldedit.schematic.load.loading": "(Please wait... loading schematic.)",
|
||||
"worldedit.schematic.save.already-exists": "That schematic already exists. Use the -f flag to overwrite it.",
|
||||
"worldedit.schematic.save.failed-directory": "Could not create folder for schematics!",
|
||||
"worldedit.schematic.save.saving": "(Please wait... saving schematic.)",
|
||||
"worldedit.schematic.delete.does-not-exist": "Schematic {0} does not exist!",
|
||||
"worldedit.schematic.delete.failed": "Deletion of {0} failed! Is it read-only?",
|
||||
"worldedit.schematic.delete.deleted": "{0} has been deleted.",
|
||||
"worldedit.schematic.formats.title": "Available clipboard formats (Name: Lookup names)",
|
||||
|
||||
"worldedit.pos.already-set": "Position already set.",
|
||||
"worldedit.pos.console-require-coords": "You must provide coordinates as console.",
|
||||
"worldedit.hpos.no-block": "No block in sight!",
|
||||
"worldedit.hpos.already-set": "Position already set.",
|
||||
"worldedit.chunk.selected-multiple": "Chunks selected: ({0}, {1}) - ({2}, {3})",
|
||||
"worldedit.chunk.selected": "Chunk selected: {0}, {1}",
|
||||
"worldedit.wand.invalid": "Wand item is mis-configured or disabled.",
|
||||
"worldedit.wand.selwand.info": "Left click: select pos #1; Right click: select pos #2",
|
||||
"worldedit.wand.navwand.info": "Left click: jump to location; Right click: pass through walls",
|
||||
"worldedit.contract.contracted": "Region contracted {0} blocks.",
|
||||
"worldedit.shift.shifted": "Region shifted.",
|
||||
"worldedit.outset.outset": "Region outset.",
|
||||
"worldedit.inset.inset": "Region inset.",
|
||||
"worldedit.size.offset": "Offset: {0}",
|
||||
"worldedit.size.type": "Type: {0}",
|
||||
"worldedit.size.size": "Size: {0}",
|
||||
"worldedit.size.distance": "Cuboid distance: {0}",
|
||||
"worldedit.size.blocks": "# of blocks: {0}",
|
||||
"worldedit.count.counted": "Counted: {0}",
|
||||
"worldedit.distr.no-blocks": "No blocks counted.",
|
||||
"worldedit.distr.no-previous": "No previous distribution.",
|
||||
"worldedit.distr.total": "Total Block Count: {0}",
|
||||
"worldedit.select.cleared": "Selection cleared.",
|
||||
"worldedit.select.cuboid.message": "Cuboid: left click for point 1, right click for point 2",
|
||||
"worldedit.select.cuboid.description": "Select two corners of a cuboid",
|
||||
"worldedit.select.extend.message": "Cuboid: left click for a starting point, right click to extend",
|
||||
"worldedit.select.extend.description": "Fast cuboid selection mode",
|
||||
"worldedit.select.poly.message": "2D polygon selector: Left/right click to add a point.",
|
||||
"worldedit.select.poly.limit-message": "{0} points maximum.",
|
||||
"worldedit.select.poly.description": "Select a 2D polygon with height",
|
||||
"worldedit.select.ellipsoid.message": "Ellipsoid selector: left click=center, right click to extend",
|
||||
"worldedit.select.ellipsoid.description": "Select an ellipsoid",
|
||||
"worldedit.select.sphere.message": "Sphere selector: left click=center, right click to set radius",
|
||||
"worldedit.select.sphere.description": "Select a sphere",
|
||||
"worldedit.select.cyl.message": "Cylindrical selector: Left click=center, right click to extend",
|
||||
"worldedit.select.cyl.description": "Select a cylinder",
|
||||
"worldedit.select.convex.message": "Convex polyhedral selector: Left click=First vertex, right click to add more.",
|
||||
"worldedit.select.convex.limit-message": "{0} points maximum.",
|
||||
"worldedit.select.convex.description": "Select a convex polyhedral",
|
||||
"worldedit.select.default-set": "Your default region selector is now {0}.",
|
||||
|
||||
"worldedit.chunkinfo.chunk": "Chunk: {0}, {1}",
|
||||
"worldedit.chunkinfo.old-filename": "Old format: {0}",
|
||||
"worldedit.chunkinfo.mcregion-filename": "McRegion: region/{0}",
|
||||
"worldedit.listchunks.listfor": "Listing chunks for: {0}",
|
||||
|
||||
"worldedit.drain.drained": "{0} blocks have been drained.",
|
||||
"worldedit.fill.created": "{0} blocks have been filled.",
|
||||
"worldedit.fillr.created": "{0} blocks have been filled.",
|
||||
"worldedit.fixlava.fixed": "{0} blocks have been fixed.",
|
||||
"worldedit.fixwater.fixed": "{0} blocks have been fixed.",
|
||||
"worldedit.removeabove.removed": "{0} blocks have been removed.",
|
||||
"worldedit.removebelow.removed": "{0} blocks have been removed.",
|
||||
"worldedit.removenear.removed": "{0} blocks have been removed.",
|
||||
"worldedit.replacenear.replaced": "{0} blocks have been replaced.",
|
||||
"worldedit.snow.created": "{0} surfaces have been covered.",
|
||||
"worldedit.thaw.removed": "{0} blocks have been thawed.",
|
||||
"worldedit.green.changed": "{0} blocks have been greened.",
|
||||
"worldedit.extinguish.removed": "{0} fires have been extinguished.",
|
||||
"worldedit.butcher.killed": "{0} mobs have been killed in a radius of {1}.",
|
||||
"worldedit.butcher.explain-all": "Use -1 to remove all mobs in loaded chunks",
|
||||
"worldedit.remove.removed": "{0} entities have been marked for removal.",
|
||||
"worldedit.remove.explain-all": "Use -1 to remove all entities in loaded chunks",
|
||||
"worldedit.calc.invalid": "'{0}' could not be parsed as a valid expression",
|
||||
|
||||
"worldedit.paste.pasted": "The clipboard has been pasted at {0}",
|
||||
"worldedit.paste.selected": "Selected clipboard paste region.",
|
||||
"worldedit.rotate.no-interpolation": "Note: Interpolation is not yet supported, so angles that are multiples of 90 is recommended.",
|
||||
"worldedit.rotate.rotated": "The clipboard copy has been rotated.",
|
||||
"worldedit.flip.flipped": "The clipboard copy has been flipped.",
|
||||
"worldedit.clearclipboard.cleared": "Clipboard cleared.",
|
||||
|
||||
"worldedit.set.done": "Operation completed.",
|
||||
"worldedit.set.done.verbose": "Operation completed ({0}).",
|
||||
"worldedit.line.changed": "{0} blocks have been changed.",
|
||||
"worldedit.line.invalid-type": "//line only works with cuboid selections or convex polyhedral selections",
|
||||
"worldedit.curve.changed": "{0} blocks have been changed.",
|
||||
"worldedit.curve.invalid-type": "//curve only works with convex polyhedral selections",
|
||||
"worldedit.replace.replaced": "{0} blocks have been replaced.",
|
||||
"worldedit.stack.changed": "{0} blocks changed. Undo with //undo",
|
||||
"worldedit.regen.regenerated": "Region regenerated.",
|
||||
"worldedit.walls.changed": "{0} blocks have been changed.",
|
||||
"worldedit.faces.changed": "{0} blocks have been changed.",
|
||||
"worldedit.overlay.overlaid": "{0} blocks have been overlaid.",
|
||||
"worldedit.naturalize.naturalized": "{0} block(s) have been made to look more natural.",
|
||||
"worldedit.center.changed": "Center set. ({0} blocks changed)",
|
||||
"worldedit.smooth.changed": "Terrain's height map smoothed. {0} blocks changed.",
|
||||
"worldedit.move.moved": "{0} blocks moved.",
|
||||
"worldedit.deform.deformed": "{0} blocks have been deformed.",
|
||||
"worldedit.hollow.changed": "{0} blocks have been changed.",
|
||||
"worldedit.forest.created": "{0} trees created.",
|
||||
"worldedit.flora.created": "{0} flora created.",
|
||||
|
||||
"worldedit.unstuck.moved": "There you go!",
|
||||
"worldedit.ascend.obstructed": "No free spot above you found.",
|
||||
"worldedit.ascend.moved": "Ascended {0} levels.",
|
||||
"worldedit.descend.obstructed": "No free spot below you found.",
|
||||
"worldedit.descend.moved": "Descended {0} levels.",
|
||||
"worldedit.ceil.obstructed": "No free spot above you found.",
|
||||
"worldedit.ceil.moved": "Woosh!",
|
||||
"worldedit.thru.obstructed": "No free spot ahead of you found.",
|
||||
"worldedit.thru.moved": "Woosh!",
|
||||
"worldedit.jumpto.moved": "Poof!",
|
||||
"worldedit.jumpto.none": "No block in sight (or too far away)!",
|
||||
"worldedit.up.obstructed": "You would hit something above you.",
|
||||
"worldedit.up.moved": "Woosh!",
|
||||
|
||||
"worldedit.cyl.invalid-radius": "You must either specify 1 or 2 radius values.",
|
||||
"worldedit.cyl.created": "{0} blocks have been created.",
|
||||
"worldedit.sphere.invalid-radius": "You must either specify 1 or 3 radius values.",
|
||||
"worldedit.sphere.created": "{0} blocks have been created.",
|
||||
"worldedit.forestgen.created": "{0} trees created.",
|
||||
"worldedit.pumpkins.created": "{0} pumpkin patches created.",
|
||||
"worldedit.pyramid.created": "{0} blocks have been created.",
|
||||
"worldedit.generate.created": "{0} blocks have been created.",
|
||||
"worldedit.generate.changed": "{0} columns affected.",
|
||||
|
||||
"worldedit.reload.config": "Configuration reloaded!",
|
||||
"worldedit.report.written": "WorldEdit report written to {0}",
|
||||
"worldedit.report.error": "Failed to write report: {0}",
|
||||
"worldedit.report.callback": "WorldEdit report: {0}.report",
|
||||
"worldedit.timezone.invalid": "Invalid timezone",
|
||||
"worldedit.timezone.set": "Timezone set for this session to: {0}",
|
||||
"worldedit.timezone.current": "The current time in that timezone is: {0}",
|
||||
"worldedit.version.version": "WorldEdit version {0}",
|
||||
|
||||
"worldedit.command.time-elapsed": "{0}s elapsed (history: {1} changed; {2} blocks/sec).",
|
||||
"worldedit.command.permissions": "You are not permitted to do that. Are you in the right mode?",
|
||||
"worldedit.command.player-only": "This command must be used with a player.",
|
||||
"worldedit.command.error.report": "Please report this error: [See console]",
|
||||
"worldedit.pastebin.uploading": "(Please wait... sending output to pastebin...)",
|
||||
"worldedit.session.cant-find-session": "Unable to find session for {0}",
|
||||
"worldedit.platform.no-file-dialog": "File dialogs are not supported in your environment.",
|
||||
|
||||
"worldedit.tool.max-block-changes": "Max blocks change limit reached.",
|
||||
"worldedit.tool.no-block": "No block in sight!",
|
||||
"worldedit.tool.repl.equip": "Block replacer tool bound to {0}.",
|
||||
"worldedit.tool.repl.switched": "Replacer tool switched to: {0}",
|
||||
"worldedit.tool.data-cycler.equip": "Block data cycler tool bound to {0}.",
|
||||
"worldedit.tool.data-cycler.block-not-permitted": "You are not permitted to cycle the data value of that block.",
|
||||
"worldedit.tool.data-cycler.cant-cycle": "That block's data cannot be cycled!",
|
||||
"worldedit.tool.data-cycler.new-value": "Value of {0} is now {1}.",
|
||||
"worldedit.tool.data-cycler.cycling": "Now cycling {0}.",
|
||||
"worldedit.tool.deltree.equip": "Floating tree remover tool bound to {0}.",
|
||||
"worldedit.tool.deltree.not-tree": "That's not a tree.",
|
||||
"worldedit.tool.deltree.not-floating": "That's not a floating tree.",
|
||||
"worldedit.tool.tree.equip": "Tree tool bound to {0}.",
|
||||
"worldedit.tool.tree.obstructed": "A tree can't go there.",
|
||||
"worldedit.tool.info.equip": "Info tool bound to {0}.",
|
||||
"worldedit.tool.info.blockstate.hover": "Block state",
|
||||
"worldedit.tool.info.internalid.hover": "Internal ID",
|
||||
"worldedit.tool.info.light.hover": "Block Light/Light Above",
|
||||
"worldedit.tool.none.equip": "Tool unbound from your current item.",
|
||||
"worldedit.tool.selwand.equip": "Selection wand bound to {0}.",
|
||||
"worldedit.tool.navwand.equip": "Navigation wand bound to {0}.",
|
||||
"worldedit.tool.floodfill.equip": "Block flood fill tool bound to {0}.",
|
||||
"worldedit.tool.farwand.equip": "Far wand tool bound to {0}.",
|
||||
"worldedit.tool.lrbuild.equip": "Long-range building tool bound to {0}.",
|
||||
"worldedit.tool.lrbuild.set": "Left-click set to {0}; right-click set to {1}.",
|
||||
|
||||
"worldedit.tool.superpickaxe.mode.single": "Mode is now single. Left click with a pickaxe. // to disable.",
|
||||
"worldedit.tool.superpickaxe.mode.area": "Mode is now area. Left click with a pickaxe. // to disable.",
|
||||
"worldedit.tool.superpickaxe.mode.recursive": "Mode is now recursive. Left click with a pickaxe. // to disable.",
|
||||
"worldedit.tool.superpickaxe.max-range": "Maximum range is {0}.",
|
||||
"worldedit.tool.superpickaxe.enabled.already": "Super pickaxe already enabled.",
|
||||
"worldedit.tool.superpickaxe.disabled.already": "Super pickaxe already disabled.",
|
||||
"worldedit.tool.superpickaxe.enabled": "Super pickaxe enabled.",
|
||||
"worldedit.tool.superpickaxe.disabled": "Super pickaxe disabled.",
|
||||
"worldedit.tool.mask.set": "Brush mask set.",
|
||||
"worldedit.tool.mask.disabled": "Brush mask disabled.",
|
||||
"worldedit.tool.material.set": "Brush material set.",
|
||||
"worldedit.tool.range.set": "Brush range set.",
|
||||
"worldedit.tool.size.set": "Brush size set.",
|
||||
"worldedit.tool.tracemask.set": "Trace mask set.",
|
||||
"worldedit.tool.tracemask.disabled": "Trace mask disabled.",
|
||||
|
||||
"worldedit.execute.script-permissions": "You don't have permission to use that script.",
|
||||
"worldedit.executelast.no-script": "Use /cs with a script name first.",
|
||||
"worldedit.script.read-error": "Script read error: {0}",
|
||||
"worldedit.script.unsupported": "Only .js scripts are currently supported",
|
||||
"worldedit.script.file-not-found": "Script does not exist: {0}",
|
||||
"worldedit.script.no-script-engine": "Failed to find an installed script engine.\nPlease see https://worldedit.enginehub.org/en/latest/usage/other/craftscripts/",
|
||||
"worldedit.script.failed": "Failed to execute: {0}",
|
||||
"worldedit.script.failed-console": "Failed to execute (see console): {0}",
|
||||
|
||||
"worldedit.operation.affected.biome": "{0} biomes affected",
|
||||
"worldedit.operation.affected.block": "{0} blocks affected",
|
||||
"worldedit.operation.affected.column": "{0} columns affected",
|
||||
"worldedit.operation.affected.entity": "{0} entities affected",
|
||||
"worldedit.operation.deform.expression": "deformed using {0}",
|
||||
|
||||
"worldedit.selection.convex.info.vertices": "Vertices: {0}",
|
||||
"worldedit.selection.convex.info.triangles": "Triangles: {0}",
|
||||
"worldedit.selection.convex.explain.primary": "Started new selection with vertex {0}.",
|
||||
"worldedit.selection.convex.explain.secondary": "Added vertex {0} to the selection.",
|
||||
"worldedit.selection.cuboid.info.pos1": "Position 1: {0}",
|
||||
"worldedit.selection.cuboid.info.pos2": "Position 2: {0}",
|
||||
"worldedit.selection.cuboid.explain.primary": "First position set to {0}.",
|
||||
"worldedit.selection.cuboid.explain.primary-area": "First position set to {0} ({1}).",
|
||||
"worldedit.selection.cuboid.explain.secondary": "Second position set to {0}.",
|
||||
"worldedit.selection.cuboid.explain.secondary-area": "Second position set to {0} ({1}).",
|
||||
"worldedit.selection.extend.explain.primary": "Started selection at {0} ({1}).",
|
||||
"worldedit.selection.extend.explain.secondary": "Extended selection to encompass {0} ({1}).",
|
||||
"worldedit.selection.ellipsoid.info.center": "Center: {0}",
|
||||
"worldedit.selection.ellipsoid.info.radius": "X/Y/Z Radius: {0}",
|
||||
"worldedit.selection.ellipsoid.explain.primary": "Center position set to {0}.",
|
||||
"worldedit.selection.ellipsoid.explain.primary-area": "Center position set to {0} ({1}).",
|
||||
"worldedit.selection.ellipsoid.explain.secondary": "Radius set to {0}.",
|
||||
"worldedit.selection.ellipsoid.explain.secondary-area": "Radius set to {0} ({1}).",
|
||||
"worldedit.selection.cylinder.info.center": "Center: {0}",
|
||||
"worldedit.selection.cylinder.info.radius": "Radius: {0}",
|
||||
"worldedit.selection.cylinder.explain.primary": "Starting a new cylindrical selection at {0}.",
|
||||
"worldedit.selection.cylinder.explain.secondary": "Radius set to {0}/{1} blocks. ({2})",
|
||||
"worldedit.selection.cylinder.explain.secondary-missing": "You must select the center point before setting the radius.",
|
||||
"worldedit.selection.polygon2d.info": "# points: {0}",
|
||||
"worldedit.selection.polygon2d.explain.primary": "Starting a new polygon at {0}.",
|
||||
"worldedit.selection.polygon2d.explain.secondary": "Added point #{0} at {1}.",
|
||||
"worldedit.selection.sphere.explain.secondary": "Radius set to {0}.",
|
||||
"worldedit.selection.sphere.explain.secondary-defined": "Radius set to {0} ({1}).",
|
||||
|
||||
"worldedit.help.command-not-found": "The command '{0}' could not be found.",
|
||||
"worldedit.help.no-subcommands": "'{0}' has no sub-commands. (Maybe '{1}' is for a parameter?)",
|
||||
"worldedit.help.subcommand-not-found": "The sub-command '{0}' under '{1}' could not be found.",
|
||||
|
||||
"worldedit.cli.stopping": "Stopping!",
|
||||
"worldedit.cli.unknown-command": "Unknown command!"
|
||||
}
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.fabric.mixin.AccessorServerPlayerEntity;
|
||||
import com.sk89q.worldedit.fabric.net.handler.WECUIPacketHandler;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -56,6 +57,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FabricPlayer extends AbstractPlayerActor {
|
||||
@ -128,6 +130,11 @@ public class FabricPlayer extends AbstractPlayerActor {
|
||||
this.player.networkHandler.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return Locale.forLanguageTag(((AccessorServerPlayerEntity) this.player).getClientLanguage().replace("_", "-"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
@ -152,7 +159,7 @@ public class FabricPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
this.player.sendMessage(Text.Serializer.fromJson(GsonComponentSerializer.INSTANCE.serialize(WorldEditText.format(component))));
|
||||
this.player.sendMessage(Text.Serializer.fromJson(GsonComponentSerializer.INSTANCE.serialize(WorldEditText.format(component, getLocale()))));
|
||||
}
|
||||
|
||||
private void sendColorized(String msg, Formatting formatting) {
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.fabric.mixin;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ServerPlayerEntity.class)
|
||||
public interface AccessorServerPlayerEntity {
|
||||
|
||||
@Accessor
|
||||
String getClientLanguage();
|
||||
}
|
@ -4,7 +4,8 @@
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinServerPlayerEntity",
|
||||
"MixinMinecraftServer"
|
||||
"MixinMinecraftServer",
|
||||
"AccessorServerPlayerEntity"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
|
@ -33,6 +33,7 @@ import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.WorldEditText;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -55,6 +56,7 @@ import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -153,7 +155,7 @@ public class ForgePlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
this.player.sendMessage(ITextComponent.Serializer.fromJson(GsonComponentSerializer.INSTANCE.serialize(WorldEditText.format(component))));
|
||||
this.player.sendMessage(ITextComponent.Serializer.fromJson(GsonComponentSerializer.INSTANCE.serialize(WorldEditText.format(component, getLocale()))));
|
||||
}
|
||||
|
||||
private void sendColorized(String msg, TextFormatting formatting) {
|
||||
@ -203,6 +205,11 @@ public class ForgePlayer extends AbstractPlayerActor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return TextUtils.getLocaleByMinecraftTag(player.language);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
|
||||
World world = getWorld();
|
||||
|
@ -1 +1,2 @@
|
||||
public net.minecraft.server.MinecraftServer field_211151_aa # serverTime
|
||||
public net.minecraft.server.MinecraftServer field_211151_aa # serverTime
|
||||
public net.minecraft.entity.player.ServerPlayerEntity field_71148_cg # language
|
||||
|
@ -54,17 +54,17 @@ public abstract class CommandAdapter implements CommandCallable {
|
||||
@Override
|
||||
public Optional<Text> getShortDescription(CommandSource source) {
|
||||
return Optional.of(command.getDescription())
|
||||
.map(SpongeTextAdapter::convert);
|
||||
.map(desc -> SpongeTextAdapter.convert(desc, source.getLocale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Text> getHelp(CommandSource source) {
|
||||
return Optional.of(command.getFullHelp())
|
||||
.map(SpongeTextAdapter::convert);
|
||||
.map(help -> SpongeTextAdapter.convert(help, source.getLocale()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getUsage(CommandSource source) {
|
||||
return convert(command.getUsage());
|
||||
return convert(command.getUsage(), source.getLocale());
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.sponge;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
@ -37,6 +38,7 @@ import org.spongepowered.api.text.format.TextColors;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -94,7 +96,7 @@ public class SpongeCommandSender implements Actor {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
TextAdapter.sendComponent(sender, WorldEditText.format(component));
|
||||
TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
|
||||
}
|
||||
|
||||
private void sendColorized(String msg, TextColor formatting) {
|
||||
@ -141,6 +143,11 @@ public class SpongeCommandSender implements Actor {
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return WorldEdit.getInstance().getConfiguration().defaultLocale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
return new SessionKey() {
|
||||
|
@ -51,6 +51,7 @@ import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -154,7 +155,7 @@ public class SpongePlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
TextAdapter.sendComponent(player, WorldEditText.format(component));
|
||||
TextAdapter.sendComponent(player, WorldEditText.format(component, getLocale()));
|
||||
}
|
||||
|
||||
private void sendColorized(String msg, TextColor formatting) {
|
||||
@ -231,6 +232,11 @@ public class SpongePlayer extends AbstractPlayerActor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return player.getLocale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
return new SessionKeyImpl(player.getUniqueId(), player.getName());
|
||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren