Merge remote-tracking branch 'upstream/feature/translatable-text' into i18n-merge

Dieser Commit ist enthalten in:
Jesse Boyd 2019-11-21 13:50:05 +00:00
Commit 66744bfaa4
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
102 geänderte Dateien mit 1606 neuen und 584 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -21,6 +21,8 @@ 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;
@ -33,10 +35,13 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.BlockCommandSender;
import java.util.Locale;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -92,7 +97,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

Datei anzeigen

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
import com.sk89q.bukkit.util.CommandInspector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor;
import java.util.Optional;
import org.bukkit.command.Command;
@ -32,6 +33,8 @@ import org.enginehub.piston.inject.InjectedValueStore;
import org.enginehub.piston.inject.Key;
import org.enginehub.piston.inject.MapBackedValueStore;
import org.slf4j.Logger;
import java.util.Locale;
import org.slf4j.LoggerFactory;
class BukkitCommandInspector implements CommandInspector {
@ -51,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";
@ -62,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";

Datei anzeigen

@ -22,6 +22,8 @@ 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;
@ -29,6 +31,8 @@ import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import java.util.UUID;
import java.util.Locale;
import javax.annotation.Nullable;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
@ -93,7 +97,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
@ -113,6 +117,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() {

Datei anzeigen

@ -188,7 +188,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
@ -292,6 +292,11 @@ public class BukkitPlayer extends AbstractPlayerActor {
return player.teleport(BukkitAdapter.adapt(location));
}
@Override
public Locale getLocale() {
return Locale.forLanguageTag(player.getLocale().replace('_', '-'));
}
@Nullable
@Override
public <T> T getFacet(Class<? extends T> cls) {

Datei anzeigen

@ -24,6 +24,7 @@ import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
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;
@ -38,6 +39,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;
@ -167,8 +169,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()));
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -1,11 +1,14 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
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")
}
repositories {
@ -101,3 +104,28 @@ tasks.named<ShadowJar>("shadowJar") {
}
}
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")
}
}

Datei anzeigen

@ -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()
}

Datei anzeigen

@ -34,6 +34,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;
@ -82,6 +83,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(

Datei anzeigen

@ -52,12 +52,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;
@ -109,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);
@ -224,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
@ -631,7 +645,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();
@ -639,7 +653,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;
}
@ -652,7 +666,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 {
@ -665,7 +679,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;
}
@ -678,8 +692,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;
}
@ -693,14 +706,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()) {

Datei anzeigen

@ -61,19 +61,19 @@ import org.enginehub.piston.part.SubCommandPart;
@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();
@ -85,7 +85,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));
}

Datei anzeigen

@ -49,6 +49,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;
@ -58,6 +63,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import java.util.List;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
@ -101,7 +107,7 @@ public class BiomeCommands {
})
.collect(Collectors.toList()));
return paginationBox.create(page);
}, null);
}, (Component) null);
}
@Command(
@ -118,24 +124,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(BBC.NO_BLOCK.s());
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);
@ -150,19 +156,18 @@ public class BiomeCommands {
}
}
qualifier = "in your selection";
messageKey = "worldedit.biomeinfo.selection";
}
BBC.BIOME_LIST_HEADER.send(player, 1, 1);
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(
@ -195,7 +200,10 @@ public class BiomeCommands {
FlatRegionVisitor visitor = new FlatRegionVisitor(Regions.asFlatRegion(region), replace);
Operations.completeLegacy(visitor);
BBC.BIOME_CHANGED.send(player, visitor.getAffected());
player.printInfo(TranslatableComponent.of(
"worldedit.setbiome.changed",
TextComponent.of(visitor.getAffected())
));
if (!player.hasPermission("fawe.tips")) {
BBC.TIP_BIOME_PATTERN.or(BBC.TIP_BIOME_MASK).send(player);
}

Datei anzeigen

@ -124,6 +124,8 @@ import java.net.URI;
import java.nio.file.FileSystems;
import java.util.List;
import java.util.zip.GZIPInputStream;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import org.enginehub.piston.annotation.Command;
import com.sk89q.worldedit.function.factory.Apply;
import org.enginehub.piston.annotation.CommandContainer;
@ -1147,6 +1149,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())));
}
}

Datei anzeigen

@ -40,6 +40,7 @@ import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
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(
@ -99,7 +100,7 @@ public class ChunkCommands {
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
final Region region = session.getSelection(world);
actor.print("Listing chunks for " + actor.getName());
actor.print(TranslatableComponent.of("worldedit.listchunks.listfor", TextComponent.of(actor.getName())));
actor.print(new ChunkListPaginationBox(region).create(page));
}

Datei anzeigen

@ -73,7 +73,10 @@ 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;
@ -149,10 +152,10 @@ public class ClipboardCommands {
copy.setSourceMask(mask);
}
Operations.completeLegacy(copy);
BBC.COMMAND_COPY.send(actor, region.getArea());
if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_PASTE.or(BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(actor);
}
copy.getStatusMessages().forEach(actor::print);
}
@Command(
@ -269,10 +272,10 @@ public class ClipboardCommands {
Operations.completeLegacy(copy);
session.setClipboard(new ClipboardHolder(clipboard));
BBC.COMMAND_CUT_SLOW.send(actor, region.getArea());
if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_LAZYCUT.send(actor);
}
copy.getStatusMessages().forEach(actor::print);
}
@Command(
@ -443,7 +446,7 @@ public class ClipboardCommands {
}
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);
checkPaste(actor, editSession, to, holder, clipboard);
@ -458,6 +461,7 @@ public class ClipboardCommands {
.maskSource(sourceMask)
.build();
Operations.completeLegacy(operation);
messages.addAll(Lists.newArrayList(operation.getStatusMessages()));
}
if (selectPasted || onlySelect) {
@ -469,9 +473,13 @@ public class ClipboardCommands {
selector.learnChanges();
selector.explainRegionAdjust(actor, session);
}
BBC.COMMAND_PASTE.send(actor, to);
if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_COPYPASTE.or(BBC.TIP_SOURCE_MASK, BBC.TIP_REPLACE_MARKER).send(actor, to);
}
if (onlySelect) {
actor.printInfo(TranslatableComponent.of("worldedit.paste.selected"));
} else {
actor.printInfo(TranslatableComponent.of("worldedit.paste.pasted", TextComponent.of(to.toString())));
}
}
@ -548,7 +556,7 @@ public class ClipboardCommands {
transform = transform.rotateX(-xRotate);
transform = transform.rotateZ(-zRotate);
holder.setTransform(holder.getTransform().combine(transform));
actor.print(BBC.COMMAND_ROTATE.s());
actor.printInfo(TranslatableComponent.of("worldedit.rotate.rotated"));
if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_FLIP.or(BBC.TIP_DEFORM, BBC.TIP_TRANSFORM).send(actor);
}
@ -567,7 +575,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(
@ -577,6 +585,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"));
}
}

Datei anzeigen

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

Datei anzeigen

@ -19,6 +19,8 @@
package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.extent.ResettableExtent;
@ -48,6 +50,9 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
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.formatting.text.Component;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.item.ItemType;
@ -63,8 +68,6 @@ import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* General WorldEdit commands.
*/
@ -98,14 +101,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(
@ -122,14 +128,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(
@ -142,16 +151,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"));
}
}
@ -164,10 +173,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())));
}
}
@ -184,17 +193,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"));
}
}
@ -207,9 +217,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())));
}
}
@ -224,16 +234,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(
@ -247,10 +257,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"));
}
}
@ -261,9 +271,9 @@ public class GeneralCommands {
)
public void togglePlace(Player player, LocalSession session) {
if (session.togglePlacementPosition()) {
player.print(BBC.PLACE_ENABLED.s());
player.printInfo(TranslatableComponent.of("worldedit.toggleplace.pos1"));
} else {
player.print(BBC.PLACE_DISABLED.s());
player.printInfo(TranslatableComponent.of("worldedit.toggleplace.player"));
}
}
@ -284,11 +294,11 @@ public class GeneralCommands {
List<String> query) throws Exception {
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;
}

Datei anzeigen

@ -53,10 +53,12 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.IOException;
@ -211,7 +213,7 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(max);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow);
BBC.VISITOR_BLOCK.send(actor, affected);
actor.printInfo(TranslatableComponent.of("worldedit.cyl.created", TextComponent.of(affected)));
}
@Command(
@ -252,7 +254,7 @@ public class GenerationCommands {
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
BBC.VISITOR_BLOCK.send(actor, affected);
actor.printInfo(TranslatableComponent.of("worldedit.sphere.created", TextComponent.of(affected)));
}
@Command(
@ -272,7 +274,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;
}
@ -290,7 +292,7 @@ public class GenerationCommands {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
worldEdit.checkMaxRadius(size);
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), size, density);
actor.print(affected + " pumpkin patches created.");
actor.printInfo(TranslatableComponent.of("worldedit.pumpkins.created", TextComponent.of(affected)));
return affected;
}
@ -327,7 +329,7 @@ public class GenerationCommands {
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
BBC.VISITOR_BLOCK.send(actor, affected);
actor.printInfo(TranslatableComponent.of("worldedit.pyramid.created", TextComponent.of(affected)));
}
@Command(
@ -388,9 +390,9 @@ public class GenerationCommands {
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
BBC.VISITOR_BLOCK.send(actor, affected);
actor.printInfo(TranslatableComponent.of("worldedit.generate.created", TextComponent.of(affected)));
} catch (ExpressionException e) {
actor.printError(e.getMessage());
actor.printError(TextComponent.of(e.getMessage()));
}
}
@ -449,9 +451,9 @@ public class GenerationCommands {
final Vector3 unit1 = unit;
try {
final int affected = editSession.makeBiomeShape(region, zero, unit1, target, String.join(" ", expression), hollow, session.getTimeout());
BBC.VISITOR_FLAT.send(actor, affected);
actor.printInfo(TranslatableComponent.of("worldedit.generatebiome.changed", TextComponent.of(affected)));
} catch (ExpressionException e) {
actor.printError(e.getMessage());
actor.printError(TextComponent.of(e.getMessage()));
}
}

Datei anzeigen

@ -41,6 +41,7 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.annotation.Confirm;
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.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
@ -49,6 +50,7 @@ import java.io.File;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
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;
@ -240,7 +242,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;
}
}
@ -255,9 +257,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"));
}
}
@ -278,7 +280,7 @@ public class HistoryCommands {
player.checkPermission("worldedit.history.redo.other");
redoSession = worldEdit.getSessionManager().findByName(playerName);
if (redoSession == null) {
BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, playerName);
player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
return;
}
}
@ -293,9 +295,9 @@ public class HistoryCommands {
}
}
if (timesRedone > 0) {
BBC.COMMAND_REDO_SUCCESS.send(player, timesRedone == 1 ? "" : " x" + timesRedone);
player.printInfo(TranslatableComponent.of("worldedit.redo.redid", TextComponent.of(timesRedone)));
} else {
player.printError(BBC.COMMAND_REDO_ERROR.s());
player.printError(TranslatableComponent.of("worldedit.redo.none"));
}
}
@ -307,7 +309,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"));
}
}

Datei anzeigen

@ -29,6 +29,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;
@ -62,7 +64,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(
@ -82,9 +84,9 @@ public class NavigationCommands {
}
}
if (ascentLevels == 0) {
player.printError(BBC.ASCEND_FAIL.s());
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)));
}
}
@ -105,11 +107,9 @@ public class NavigationCommands {
}
}
if (descentLevels == 0) {
player.printError(BBC.DESCEND_FAIL.s());
} else if (descentLevels == 1) {
player.print(BBC.DESCEND_SINGULAR.s());
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)));
}
}
@ -130,9 +130,9 @@ public class NavigationCommands {
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
if (player.ascendToCeiling(clearance, alwaysGlass)) {
player.print(BBC.WHOOSH.s());
player.printInfo(TranslatableComponent.of("worldedit.ceil.moved"));
} else {
player.printError(BBC.ASCEND_FAIL.s());
player.printError(TranslatableComponent.of("worldedit.ceil.obstructed"));
}
}
@ -143,9 +143,9 @@ public class NavigationCommands {
@CommandPermissions("worldedit.navigation.thru.command")
public void thru(Player player) throws WorldEditException {
if (player.passThroughForwardWall(6)) {
player.print(BBC.WHOOSH.s());
player.printInfo(TranslatableComponent.of("worldedit.thru.moved"));
} else {
player.printError(BBC.THRU_FAIL.s());
player.printError(TranslatableComponent.of("worldedit.thru.obstructed"));
}
}
@ -165,14 +165,10 @@ public class NavigationCommands {
pos = player.getSolidBlockTrace(300);
}
if (pos != null) {
if (force) {
player.setPosition(pos);
} else {
player.findFreePosition(pos);
}
player.print(BBC.POOF.s());
player.findFreePosition(pos);
player.printInfo(TranslatableComponent.of("worldedit.jumpto.moved"));
} else {
player.printError(BBC.NO_BLOCK.s());
player.printError(TranslatableComponent.of("worldedit.jumpto.none"));
}
}
@ -191,9 +187,9 @@ public class NavigationCommands {
boolean forceGlass) throws WorldEditException {
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
if (player.ascendUpwards(distance, alwaysGlass)) {
player.print(BBC.WHOOSH.s());
player.printInfo(TranslatableComponent.of("worldedit.up.moved"));
} else {
player.printError(BBC.UP_FAIL.s());
player.printError(TranslatableComponent.of("worldedit.up.obstructed"));
}
}

Datei anzeigen

@ -62,24 +62,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();
@ -92,7 +92,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());
@ -125,15 +125,14 @@ public class PaintBrushCommands {
)
@CommandPermissions("worldedit.brush.item")
public void item(CommandParameters parameters,
Player player, LocalSession localSession,
@Arg(desc = "The type of item to use")
BaseItem item,
@Arg(desc = "The direction in which the item will be applied", def = "up")
@Direction(includeDiagonals = true)
com.sk89q.worldedit.util.Direction direction) throws WorldEditException {
Player player, LocalSession localSession,
@Arg(desc = "The type of item to use")
BaseItem item,
@Arg(desc = "The direction in which the item will be applied", def = "up")
@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));
}

Datei anzeigen

@ -65,8 +65,12 @@ import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
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.world.block.BlockTypes;
import org.enginehub.piston.annotation.Command;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
@ -113,7 +117,7 @@ public class RegionCommands {
Pattern pattern) {
int affected = editSession.setBlocks(region, pattern);
if (affected != 0) {
BBC.OPERATION.send(actor, affected);
actor.printInfo(TranslatableComponent.of("worldedit.set.done"));
if (!actor.hasPermission("fawe.tips"))
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(actor);
}
@ -245,7 +249,7 @@ public class RegionCommands {
@Switch(name = 'h', desc = "Generate only a shell")
boolean shell) throws WorldEditException {
if (!(region instanceof CuboidRegion)) {
actor.printError("//line only works with cuboid selections");
actor.printError(TranslatableComponent.of("worldedit.line.cuboid-only"));
return 0;
}
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
@ -255,7 +259,7 @@ public class RegionCommands {
BlockVector3 pos2 = cuboidregion.getPos2();
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
actor.print(blocksChanged + " block(s) have been changed.");
actor.printInfo(TranslatableComponent.of("worldedit.line.changed", TextComponent.of(blocksChanged)));
return blocksChanged;
}
@ -276,7 +280,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.convex-only"));
return;
}
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
@ -286,7 +290,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)));
}
@Command(
@ -305,9 +309,8 @@ public class RegionCommands {
if (from == null) {
from = new ExistingBlockMask(editSession);
}
Mask finalFrom = from;
int affected = editSession.replaceBlocks(region, finalFrom, to);
actor.print(affected + " block(s) have been replaced.");
int affected = editSession.replaceBlocks(region, from, to);
actor.printInfo(TranslatableComponent.of("worldedit.replace.replaced", TextComponent.of(affected)));
}
@Command(
@ -321,7 +324,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)));
}
@Command(
@ -360,7 +363,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;
}
@ -373,7 +376,7 @@ public class RegionCommands {
@Confirm(Confirm.Processor.REGION)
public void 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)));
}
@Command(
@ -387,7 +390,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)));
}
@Command(
@ -402,7 +405,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)));
}
@Command(
@ -428,12 +431,12 @@ public class RegionCommands {
}
try {
HeightMap heightMap = new HeightMap(editSession, region, mask, snow);
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.");
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations);
actor.printInfo(TranslatableComponent.of("worldedit.smooth.changed", TextComponent.of(affected)));
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
}
@Command(
@ -518,11 +521,12 @@ 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()));
}
}
BBC.VISITOR_BLOCK.send(actor, affected);
actor.printInfo(TranslatableComponent.of("worldedit.move.moved", TextComponent.of(affected)));
return affected;
}
@Command(
@ -589,11 +593,12 @@ 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()));
}
}
BBC.VISITOR_BLOCK.send(actor, affected);
actor.printInfo(TranslatableComponent.of("worldedit.stack.changed", TextComponent.of(affected)));
return affected;
}
@Command(
@ -641,9 +646,9 @@ 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)));
} catch (ExpressionException e) {
actor.printError(e.getMessage());
actor.printError(TextComponent.of(e.getMessage()));
}
}
@ -667,17 +672,7 @@ public class RegionCommands {
editSession.regenerate(region, biome, seed);
session.setMask(mask);
session.setSourceMask(mask);
if (!player.hasPermission("fawe.tips")) {
player.print(BBC.COMMAND_REGEN_2.s());
} else if (biome == null) {
BBC.COMMAND_REGEN_0.send(player);
if (!player.hasPermission("fawe.tips")) player.print(BBC.TIP_REGEN_0.s());
} else if (seed == null) {
player.print(BBC.COMMAND_REGEN_1.s());
if (!player.hasPermission("fawe.tips")) BBC.TIP_REGEN_1.send(player);
} else {
player.print(BBC.COMMAND_REGEN_2.s());
}
actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated"));
}
@Command(
@ -701,7 +696,7 @@ public class RegionCommands {
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
actor.print(affected + " block(s) have been changed.");
actor.printInfo(TranslatableComponent.of("worldedit.hollow.changed", TextComponent.of(affected)));
}
@Command(
@ -718,7 +713,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;
}
@ -740,7 +735,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)));
}
}

Datei anzeigen

@ -59,6 +59,7 @@ 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.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.component.CodeFormat;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
@ -246,7 +247,7 @@ public class SchematicCommands {
}
file = actor.openFileOpenDialog(extensions);
if (file == null || !file.exists()) {
actor.printError("Schematic " + filename + " does not exist! (" + file + ")");
actor.printError(TranslatableComponent.of("worldedit.schematic.load.does-not-exist", TextComponent.of(filename)));
return;
}
} else {
@ -273,7 +274,7 @@ public class SchematicCommands {
if (format == null) {
format = ClipboardFormats.findByFile(file);
if (format == null) {
BBC.CLIPBOARD_INVALID_FORMAT.send(actor, file.getName());
actor.printError(TranslatableComponent.of("worldedit.schematic.unknown-format", TextComponent.of(formatName)));
return;
}
}
@ -322,7 +323,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;
}
@ -353,7 +354,7 @@ public class SchematicCommands {
}
}
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;
}
}
@ -362,8 +363,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"));
}
}
@ -372,7 +373,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());
@ -449,7 +450,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()) {
@ -463,7 +464,7 @@ public class SchematicCommands {
first = false;
}
first = true;
actor.print(builder.toString());
actor.printInfo(TextComponent.of(builder.toString()));
}
}

Datei anzeigen

@ -28,6 +28,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 com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import java.io.File;
import java.util.List;
@ -70,7 +71,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;
}
@ -96,12 +97,12 @@ public class ScriptingCommands {
String lastScript = session.getLastScript();
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
player.printError(BBC.SCRIPTING_NO_PERM.s());
player.printError(TranslatableComponent.of("worldedit.execute.script-permissions"));
return;
}
if (lastScript == null) {
player.printError(BBC.SCRIPTING_CS.s());
player.printError(TranslatableComponent.of("worldedit.executelast.no-script"));
return;
}

Datei anzeigen

@ -71,6 +71,7 @@ import com.sk89q.worldedit.util.formatting.component.CommandListBox;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
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.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World;
@ -123,12 +124,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;
}
@ -152,12 +153,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;
}
@ -175,15 +176,15 @@ public class SelectionCommands {
Location pos = player.getBlockTrace(300);
if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.printError(BBC.SELECTOR_ALREADY_SET.s());
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.printError(TranslatableComponent.of("worldedit.hpos.already-set"));
return;
}
session.getRegionSelector(player.getWorld())
.explainPrimarySelection(player, session, pos.toBlockPoint());
} else {
player.printError(BBC.NO_BLOCK.s());
player.printError(TranslatableComponent.of("worldedit.hpos.no-block"));
}
}
@ -197,15 +198,15 @@ public class SelectionCommands {
Location pos = player.getBlockTrace(300);
if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.printError(BBC.SELECTOR_ALREADY_SET.s());
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.printError(TranslatableComponent.of("worldedit.hpos.already-set"));
return;
}
session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos.toBlockPoint());
} else {
player.printError(BBC.NO_BLOCK.s());
player.printError(TranslatableComponent.of("worldedit.hpos.no-block"));
}
}
@ -233,9 +234,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) {
@ -255,8 +260,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;
@ -287,16 +292,16 @@ public class SelectionCommands {
}
ItemType itemType = ItemTypes.parse(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, NavigationWand.INSTANCE);
player.print("Left click: jump to location; Right click: pass through walls");
player.printInfo(TranslatableComponent.of("worldedit.wand.navwand.info"));
} else {
session.setTool(itemType, SelectionWand.INSTANCE);
player.print(BBC.SELECTION_WAND.s());
session.setTool(itemType, new SelectionWand());
player.printInfo(TranslatableComponent.of("worldedit.wand.selwand.info"));
}
if (!player.hasPermission("fawe.tips"))
BBC.TIP_SEL_LIST.or(BBC.TIP_SELECT_CONNECTED, BBC.TIP_SET_POS1, BBC.TIP_FARWAND, BBC.TIP_DISCORD).send(player);
@ -350,9 +355,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()));
}
}
@ -379,9 +384,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()));
}
}
@ -402,7 +407,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(
@ -422,7 +427,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) {
@ -480,20 +485,15 @@ public class SelectionCommands {
long numBlocks = ((long) size.getBlockX() * size.getBlockY() * size.getBlockZ());
String msg = String.format("%1$s: %2$s @ %3$s (%4$d blocks)", name, sizeStr, originStr, numBlocks);
player.print(msg);
index++;
}
return;
BlockVector3 origin = clipboard.getOrigin();
actor.printInfo(TranslatableComponent.of("worldedit.size.offset", TextComponent.of(origin.toString())));
} else {
region = session.getSelection(world);
actor.printInfo(TranslatableComponent.of("worldedit.size.type", TextComponent.of(session.getRegionSelector(world).getTypeName())));
region = session.getSelection(player.getWorld());
player.print("Type: " + session.getRegionSelector(player.getWorld()).getTypeName());
for (String line : session.getRegionSelector(player.getWorld()).getInformationLines()) {
player.print(line);
for (Component line : session.getRegionSelector(world).getSelectionInfoLines()) {
actor.print(line);
}
}
@ -501,22 +501,22 @@ public class SelectionCommands {
.subtract(region.getMinimumPoint())
.add(1, 1, 1);
player.print("Size: " + size);
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint()));
player.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(
@ -547,22 +547,13 @@ public class SelectionCommands {
if (distribution.isEmpty()) { // *Should* always be false
player.printError("No blocks counted.");
actor.printError(TranslatableComponent.of("worldedit.distr.no-blocks"));
return;
}
// note: doing things like region.getArea is inaccurate for non-cuboids.
int size = session.getSelection(player.getWorld()).getArea();
BBC.SELECTION_DISTR.send(player, size);
for (Countable c : distribution) {
String name = c.getID().toString();
String str = String.format("%-7s (%.3f%%) %s",
String.valueOf(c.getAmount()),
c.getAmount() / (double) size * 100,
name);
player.print(str);
}
BlockDistributionResult res = new BlockDistributionResult(distribution, separateStates);
if (!actor.isPlayer()) res.formatForConsole();
return res.create(finalPage);
}
private static class BlockDistributionResult extends PaginationBox {
@ -618,7 +609,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);
}
@ -638,7 +629,7 @@ public class SelectionCommands {
if (selector == null) {
session.getRegionSelector(world).clear();
session.dispatchCUISelection(actor);
actor.print(BBC.SELECTION_CLEARED.s());
actor.printInfo(TranslatableComponent.of("worldedit.select.cleared"));
return;
}
@ -648,38 +639,38 @@ public class SelectionCommands {
switch (selector) {
case CUBOID:
newSelector = new CuboidRegionSelector(oldSelector);
actor.print(BBC.SEL_CUBOID.s());
actor.printInfo(TranslatableComponent.of("worldedit.select.cuboid.message"));
break;
case EXTEND:
newSelector = new ExtendingCuboidRegionSelector(oldSelector);
actor.print(BBC.SEL_CUBOID_EXTEND.s());
actor.printInfo(TranslatableComponent.of("worldedit.select.extend.message"));
break;
case POLY: {
newSelector = new Polygonal2DRegionSelector(oldSelector);
actor.print(BBC.SEL_2D_POLYGON.s());
actor.printInfo(TranslatableComponent.of("worldedit.select.poly.message"));
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit();
limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
limit.ifPresent(integer -> actor.printInfo(TranslatableComponent.of("worldedit.select.poly.limit-message", TextComponent.of(integer))));
break;
}
case ELLIPSOID:
newSelector = new EllipsoidRegionSelector(oldSelector);
actor.print(BBC.SAL_ELLIPSOID.s());
actor.printInfo(TranslatableComponent.of("worldedit.select.ellipsoid.message"));
break;
case SPHERE:
newSelector = new SphereRegionSelector(oldSelector);
actor.print(BBC.SEL_SPHERE.s());
actor.printInfo(TranslatableComponent.of("worldedit.select.sphere.message"));
break;
case CYL:
newSelector = new CylinderRegionSelector(oldSelector);
actor.print(BBC.SEL_CYLINDRICAL.s());
actor.printInfo(TranslatableComponent.of("worldedit.select.cyl.message"));
break;
case CONVEX:
case HULL:
case POLYHEDRON: {
newSelector = new ConvexPolyhedralRegionSelector(oldSelector);
actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
actor.printInfo(TranslatableComponent.of("worldedit.select.convex.message"));
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer)));
limit.ifPresent(integer -> actor.printInfo(TranslatableComponent.of("worldedit.select.convex.limit-message", TextComponent.of(integer))));
break;
}
case POLYHEDRAL:
@ -706,14 +697,14 @@ 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("polyhedral", "Select a hollow polyhedral", "//sel polyhedral");
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");
box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral");
box.appendCommand("fuzzy[=<mask>]", "Select all connected blocks (magic wand)", "//sel fuzzy[=<mask>]");
actor.print(box.create(1));
@ -731,7 +722,7 @@ public class SelectionCommands {
if (found != null) {
session.setDefaultRegionSelector(found);
BBC.SELECTOR_SET_DEFAULT.send(actor, found.name());
actor.printInfo(TranslatableComponent.of("worldedit.select.default-set", TextComponent.of(found.name())));
} else {
throw new RuntimeException("Something unexpected happened. Please report this.");
}

Datei anzeigen

@ -28,11 +28,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"));
}
}

Datei anzeigen

@ -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;
@ -55,20 +57,20 @@ public class SnapshotUtilCommands {
}
@Command(
name = "restore",
aliases = { "/restore" },
desc = "Restore the selection from a snapshot"
name = "restore",
aliases = { "/restore" },
desc = "Restore the selection from a snapshot"
)
@Logging(REGION)
@CommandPermissions("worldedit.snapshots.restore")
public void restore(Actor actor, World world, LocalSession session, EditSession editSession,
@Arg(name = "snapshot", desc = "The snapshot to restore", def = "")
String snapshotName) throws WorldEditException {
String snapshotName) throws WorldEditException {
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 {

Datei anzeigen

@ -30,6 +30,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;
@ -50,7 +52,7 @@ public class SuperPickaxeCommands {
public void single(Player player, LocalSession session) throws WorldEditException {
session.setSuperPickaxe(new SinglePickaxe());
session.enableSuperPickAxe();
player.print(BBC.SUPERPICKAXE_AREA_ENABLED.s());
player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.mode.single"));
}
@Command(
@ -65,13 +67,13 @@ public class SuperPickaxeCommands {
LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) {
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
player.printError(TranslatableComponent.of("worldedit.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
return;
}
session.setSuperPickaxe(new AreaPickaxe(range));
session.enableSuperPickAxe();
player.print(BBC.SUPERPICKAXE_AREA_ENABLED.s());
player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.mode.area"));
}
@Command(
@ -87,12 +89,12 @@ public class SuperPickaxeCommands {
LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) {
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
player.printError(TranslatableComponent.of("worldedit.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
return;
}
session.setSuperPickaxe(new RecursivePickaxe(range));
session.enableSuperPickAxe();
player.print(BBC.SUPERPICKAXE_AREA_ENABLED.s());
player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.mode.recursive"));
}
}

Datei anzeigen

@ -27,7 +27,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.InvalidToolBindException;
@ -125,10 +124,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;
@ -146,7 +145,7 @@ public class ToolCommands {
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(itemType, SelectionWand.INSTANCE);
player.print("Selection wand bound to " + itemType.getName() + ".");
player.printInfo(TranslatableComponent.of("worldedit.tool.selwand.equip", TextComponent.of(itemType.getName())));
}
@Command(
@ -159,7 +158,7 @@ public class ToolCommands {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, NavigationWand.INSTANCE);
player.print("Navigation wand bound to " + itemStack.getType().getName() + ".");
player.printInfo(TranslatableComponent.of("worldedit.tool.navWand.equip", TextComponent.of(itemType.getName())));
}
@Command(
@ -171,7 +170,7 @@ public class ToolCommands {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, new QueryTool());
BBC.TOOL_INFO.send(player, itemStack.getType().getName());
player.printInfo(TranslatableComponent.of("worldedit.tool.info.equip", TextComponent.of(itemType.getName())));
}
@Command(
@ -196,7 +195,7 @@ public class ToolCommands {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, new TreePlanter(type));
BBC.TOOL_TREE.send(player, itemStack.getType().getName());
player.printInfo(TranslatableComponent.of("worldedit.tool.tree.equip", TextComponent.of(itemType.getName())));
}
@Command(
@ -210,7 +209,7 @@ public class ToolCommands {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, new BlockReplacer(pattern));
BBC.TOOL_REPL.send(player, itemStack.getType().getName());
player.printInfo(TranslatableComponent.of("worldedit.tool.repl.equip", TextComponent.of(itemType.getName())));
}
@Command(
@ -222,7 +221,7 @@ public class ToolCommands {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, new BlockDataCyler());
BBC.TOOL_CYCLER.send(player, itemStack.getType().getName());
player.printInfo(TranslatableComponent.of("worldedit.tool.data-cycler.equip", TextComponent.of(itemType.getName())));
}
@Command(
@ -240,13 +239,13 @@ public class ToolCommands {
LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) {
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
player.printError(TranslatableComponent.of("worldedit.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
return;
}
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, new FloodFillTool(range, pattern));
BBC.TOOL_FLOOD_FILL.send(player, itemStack.getType().getName());
player.printInfo(TranslatableComponent.of("worldedit.tool.floodfill.equip", TextComponent.of(itemType.getName())));
}
@Command(
@ -258,7 +257,7 @@ public class ToolCommands {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, new FloatingTreeRemover());
BBC.TOOL_DELTREE.send(player, itemStack.getType().getName());
player.printInfo(TranslatableComponent.of("worldedit.tool.deltree.equip", TextComponent.of(itemType.getName())));
}
@Command(
@ -270,7 +269,7 @@ public class ToolCommands {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, new DistanceWand());
BBC.TOOL_FARWAND.send(player, itemStack.getType().getName());
player.printInfo(TranslatableComponent.of("worldedit.tool.farwand.equip", TextComponent.of(itemType.getName())));
}
@Command(
@ -284,10 +283,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) {
@ -296,7 +295,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)));
}
}

Datei anzeigen

@ -44,6 +44,7 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.command.CommandArgParser;
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;
@ -82,7 +83,7 @@ public class ToolUtilCommands {
return;
}
if (maskOpt == null) {
player.print("Brush mask disabled.");
player.print(TranslatableComponent.of("worldedit.tool.mask.disabled"));
tool.setMask(null);
return;
}
@ -91,7 +92,7 @@ public class ToolUtilCommands {
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
settings.setMask(maskOpt);
tool.update();
player.print("Brush mask set.");
player.print(TranslatableComponent.of("worldedit.tool.mask.set"));
}
@Command(
@ -112,16 +113,15 @@ public class ToolUtilCommands {
return;
}
if (pattern == null) {
player.print(BBC.BRUSH_MATERIAL.s());
tool.setFill(null);
return;
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.setFill(pattern);
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
tool.update();
player.print(BBC.BRUSH_MATERIAL.s());
} else {
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.setFill(pattern);
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
tool.update();
}
player.print(TranslatableComponent.of("worldedit.tool.material.set"));
}
@Command(
@ -133,7 +133,7 @@ public class ToolUtilCommands {
@Arg(desc = "The range of the brush")
int range) throws WorldEditException {
session.getBrushTool(player, false).setRange(range);
player.print("Brush range set.");
player.printInfo(TranslatableComponent.of("worldedit.tool.range.set"));
}
@Command(
@ -147,7 +147,7 @@ public class ToolUtilCommands {
we.checkMaxBrushRadius(size);
session.getBrushTool(player, false).setSize(size);
player.print("Brush size set.");
player.printInfo(TranslatableComponent.of("worldedit.tool.size.set"));
}
//todo none should be moved to the same class where it is in upstream
@ -172,9 +172,9 @@ public class ToolUtilCommands {
Mask maskOpt) throws WorldEditException {
session.getBrushTool(player, false).setTraceMask(maskOpt);
if (maskOpt == 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"));
}
}
@ -189,15 +189,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"));
}
}

Datei anzeigen

@ -72,6 +72,7 @@ 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.format.TextColor;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.awt.RenderingHints;
@ -214,7 +215,7 @@ public class UtilityCommands {
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillDirection(pos, pattern, radius, depth, direction);
actor.print(affected + " block(s) have been created.");
actor.printInfo(TranslatableComponent.of("worldedit.fill.created", TextComponent.of(affected)));
return affected;
}
@ -312,7 +313,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;
}
@ -330,9 +331,8 @@ public class UtilityCommands {
double radius = radiusExp.evaluate();
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;
}
@ -349,7 +349,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;
}
@ -366,7 +366,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;
}
@ -387,7 +387,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;
}
@ -408,7 +408,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;
}
@ -428,7 +428,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;
}
@ -459,7 +459,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;
}
@ -477,7 +477,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;
}
@ -495,7 +495,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;
}
@ -516,7 +516,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;
}
@ -554,7 +554,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 {
@ -566,7 +566,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(
@ -599,7 +600,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) {
@ -622,7 +623,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;
}
@ -656,20 +661,19 @@ 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;
}
// 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(
@ -685,16 +689,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(

Datei anzeigen

@ -36,9 +36,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.text.format.TextColor;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
import com.sk89q.worldedit.util.formatting.component.MessageBox;
import java.io.IOException;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@ -47,8 +51,8 @@ import java.time.format.TextStyle;
import java.time.zone.ZoneRulesException;
import java.util.Date;
import java.util.GregorianCalendar;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
@ -76,37 +80,45 @@ public class WorldEditCommands {
FaweVersion fVer = Fawe.get().getVersion();
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92");
if (fVer != null) {
actor.printDebug("----------- Platforms -----------");
FaweVersion version = Fawe.get().getVersion();
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day)
.getTime();
actor.printDebug(" - DATE: " + date.toLocaleString());
actor.printDebug(" - COMMIT: " + Integer.toHexString(version.hash));
actor.printDebug(" - BUILD: " + version.build);
actor.printDebug(" - PLATFORM: " + Settings.IMP.PLATFORM);
actor.printDebug("------------------------------------");
TextComponent dateArg = TextComponent.of(date.toLocaleString());
TextComponent commitArg = TextComponent.of(Integer.toHexString(version.hash));
TextComponent buildArg = TextComponent.of(version.build);
TextComponent platformArg = TextComponent.of(Settings.IMP.PLATFORM);
actor.printInfo(TranslatableComponent.of("worldedit.version.version", dateArg, commitArg, buildArg, platformArg));
}
actor.printInfo(TextComponent.of("Wiki: https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki"));
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.printDebug("----------- Capabilities -----------");
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"));
}
actor.print(new MessageBox("Platforms", producer, TextColor.GRAY).create());
producer.reset();
for (Capability capability : Capability.values()) {
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.printDebug("");
actor.printDebug("Wiki: https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki");
actor.print(new MessageBox("Capabilities", producer, TextColor.GRAY).create());
}
@Command(
@ -118,7 +130,7 @@ public class WorldEditCommands {
we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload();
we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
Fawe.get().setupConfigs();
actor.print("Configuration and translations reloaded!");
actor.printInfo(TranslatableComponent.of("worldedit.reload.config"));
}
@Command(
@ -129,7 +141,9 @@ public class WorldEditCommands {
@SkipQueue
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
public void report(Actor actor) throws WorldEditException, IOException {
BBC.DOWNLOAD_LINK.send(actor, IncendoPaster.debugPaste());
String dest = IncendoPaster.debugPaste();
actor.printInfo(TranslatableComponent.of("worldedit.report.written", TextComponent.of(dest)));
BBC.DOWNLOAD_LINK.send(actor, );
}
@Command(
@ -172,12 +186,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"));
}
}

Datei anzeigen

@ -27,6 +27,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;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -79,7 +80,7 @@ public class AreaPickaxe implements BlockTool {
}
editSession.flushQueue();
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
} finally {
session.remember(editSession);
}

Datei anzeigen

@ -31,6 +31,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;
@ -62,12 +64,12 @@ public class BlockDataCyler implements DoubleActionBlockTool {
if (!config.allowedDataCycleBlocks.isEmpty()
&& !player.hasPermission("worldedit.override.data-cycler")
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) {
player.printError(BBC.BLOCK_CYCLER_NO_PERM.s());
player.printError(TranslatableComponent.of("worldedit.tool.data-cycler.block-not-permitted"));
return true;
}
if (block.getStates().keySet().isEmpty()) {
player.printError(BBC.BLOCK_CYCLER_CANNOT_CYCLE.s());
player.printError(TranslatableComponent.of("worldedit.tool.data-cycler.cant-cycle"));
} else {
Property<?> currentProperty = selectedProperties.get(player.getUniqueId());
@ -89,9 +91,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(BBC.BLOCK_CYCLER_LIMIT.s());
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
} finally {
session.remember(editSession);
}
@ -102,7 +108,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())));
}
}

Datei anzeigen

@ -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;
/**
@ -76,7 +78,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;

Datei anzeigen

@ -86,6 +86,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier;
import java.util.stream.Stream;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import javax.annotation.Nullable;
/**

Datei anzeigen

@ -29,6 +29,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.
@ -75,7 +76,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
}
if (target == null) {
player.printError(BBC.NO_BLOCK.s());
player.printError(TranslatableComponent.of("worldedit.tool.no-block"));
return null;
}

Datei anzeigen

@ -32,6 +32,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;
@ -74,7 +75,7 @@ public class FloatingTreeRemover implements BlockTool {
final BlockState state = world.getBlock(clicked.toVector().toBlockPoint());
if (!isTreeBlock(state.getBlockType())) {
player.printError(BBC.TOOL_DELTREE_ERROR.s());
player.printError(TranslatableComponent.of("worldedit.tool.deltree.not-tree"));
return true;
}
@ -82,7 +83,7 @@ public class FloatingTreeRemover implements BlockTool {
try {
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
if (blockSet == null) {
player.printError(BBC.TOOL_DELTREE_FLOATING_ERROR.s());
player.printError(TranslatableComponent.of("worldedit.tool.deltree.not-floating"));
return true;
}
@ -93,7 +94,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);
}

Datei anzeigen

@ -33,6 +33,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
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;
@ -80,7 +81,7 @@ public class FloodFillTool implements BlockTool {
visitor.visit(origin);
Operations.completeLegacy(visitor);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
} finally {
session.remember(editSession);
}

Datei anzeigen

@ -32,6 +32,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;
/**
@ -119,7 +120,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
}
if (target == null) {
player.printError(BBC.NO_BLOCK.s());
player.printError(TranslatableComponent.of("worldedit.tool.no-block"));
return null;
}

Datei anzeigen

@ -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 enum NavigationWand implements DoubleActionTraceTool {
INSTANCE;

Datei anzeigen

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

Datei anzeigen

@ -32,6 +32,7 @@ import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
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;

Datei anzeigen

@ -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;
@ -56,7 +57,7 @@ public class SinglePickaxe implements BlockTool {
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
session.remember(editSession);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
}
return true;

Datei anzeigen

@ -31,6 +31,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.
@ -64,10 +65,10 @@ public class TreePlanter implements BlockTool {
}
if (!successful) {
player.printError(BBC.TOOL_TREE_ERROR_BLOCK.s());
player.printError(TranslatableComponent.of("worldedit.tool.tree.obstructed"));
}
} catch (MaxChangedBlocksException e) {
player.printError(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES.s());
player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
} finally {
session.remember(editSession);
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -30,6 +30,8 @@ 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 java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -76,7 +78,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);
@ -87,8 +89,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);
@ -100,8 +102,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;

Datei anzeigen

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

Datei anzeigen

@ -56,6 +56,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;
@ -358,10 +359,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
.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);
@ -590,13 +589,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;
}
@ -645,7 +644,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
}
@SuppressWarnings("CloneDoesntCallSuperClone")
@Override
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException("Not supported");

Datei anzeigen

@ -38,6 +38,7 @@ import com.sk89q.worldedit.session.request.Request;
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 org.enginehub.piston.inject.InjectedValueAccess;
import org.jetbrains.annotations.NotNull;
@ -45,6 +46,7 @@ import java.io.File;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.concurrent.locks.Condition;
import java.util.Locale;
/**
* An object that can perform actions in WorldEdit.
@ -71,30 +73,56 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
* 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 {@link Component}.
*
@ -109,6 +137,15 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
*/
boolean canDestroyBedrock();
/**
* Print a WorldEdit message.
*
* @param component The component to print
*/
default void printDebug(Component component) {
print(component.color(TextColor.GRAY));
}
/**
* Return whether this actor is a player.
*
@ -232,4 +269,11 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
}
return cancelled;
}
/**
* Get the locale of this actor.
*
* @return The locale
*/
Locale getLocale();
}

Datei anzeigen

@ -813,7 +813,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));
@ -831,8 +831,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);
}

Datei anzeigen

@ -42,7 +42,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.math.Vector3;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location;

Datei anzeigen

@ -34,9 +34,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.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Locale;
import com.sk89q.worldedit.world.gamemode.GameMode;
import javax.annotation.Nullable;
@ -141,22 +144,22 @@ public 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
@ -226,4 +229,9 @@ public 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();
}
}

Datei anzeigen

@ -109,10 +109,6 @@ public class ChunkBatchingExtent extends AbstractBufferingExtent {
@Override
public void cancel() {
}
@Override
public void addStatusMessages(List<String> messages) {
}
};
}

Datei anzeigen

@ -149,10 +149,6 @@ public class FastModeExtent extends AbstractDelegateExtent {
@Override
public void cancel() {
}
@Override
public void addStatusMessages(List<String> messages) {
}
};
}

Datei anzeigen

@ -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.Lists;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -36,7 +37,12 @@ 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 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.Collection;
import java.util.List;
public class Deform implements Contextual<Operation> {
@ -186,9 +192,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 Lists.newArrayList(TranslatableComponent.of("worldedit.operation.deform.expression",
TextComponent.of(expression).color(TextColor.LIGHT_PURPLE)));
}
}

Datei anzeigen

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

Datei anzeigen

@ -93,10 +93,6 @@ public class ChangeSetExecutor implements Operation {
public void cancel() {
}
@Override
public void addStatusMessages(List<String> messages) {
}
public static ChangeSetExecutor create(ChangeSet changeSet, UndoContext context, Type type, BlockBag blockBag, int inventory) {
return new ChangeSetExecutor(changeSet, type, context, blockBag, inventory);
}

Datei anzeigen

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

Datei anzeigen

@ -58,7 +58,13 @@ import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.entity.EntityTypes;
import java.util.Collections;
import com.sk89q.worldedit.util.formatting.text.Component;
import java.util.List;
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.ArrayList;
import java.util.stream.Collectors;
/**
@ -421,25 +427,16 @@ 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() {
List<Component> messages = new ArrayList<>();
messages.add(TranslatableComponent.of("worldedit.operation.affected.block",
TextComponent.of(affectedBlocks)).color(TextColor.LIGHT_PURPLE));
messages.add(TranslatableComponent.of("worldedit.operation.affected.biome",
TextComponent.of(affectedBiomeCols)).color(TextColor.LIGHT_PURPLE));
messages.add(TranslatableComponent.of("worldedit.operation.affected.entity",
TextComponent.of(affectedEntities)).color(TextColor.LIGHT_PURPLE));
return messages;
}
}

Datei anzeigen

@ -20,8 +20,12 @@
package com.sk89q.worldedit.function.operation;
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.List;
import java.util.stream.Collectors;
/**
* An task that may be split into multiple steps to be run sequentially
@ -56,7 +60,22 @@ 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) {
}
/**
* 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);
return oldMessages.stream().map(TextComponent::of).collect(Collectors.toList());
}
}

Datei anzeigen

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

Datei anzeigen

@ -49,8 +49,4 @@ public class SetLocatedBlocks implements Operation {
public void cancel() {
}
@Override
public void addStatusMessages(List<String> messages) {
}
}

Datei anzeigen

@ -21,6 +21,8 @@ package com.sk89q.worldedit.function.visitor;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.collection.BlockVectorSet;
import com.google.common.collect.Sets;
@ -30,7 +32,11 @@ import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.Direction;
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.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -168,11 +174,9 @@ public abstract class BreadthFirstSearch implements Operation {
* @param position the position
*/
public void visit(BlockVector3 position) {
BlockVector3 blockVector = position;
if (!visited.contains(blockVector)) {
isVisitable(position, position); // Ignore this, just to initialize mask on this point
queue.add(blockVector);
visited.add(blockVector);
if (!visited.contains(position)) {
queue.add(position);
visited.add(position);
}
}
@ -183,11 +187,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);
}
}
}
@ -276,8 +279,11 @@ public abstract class BreadthFirstSearch implements Operation {
}
@Override
public void addStatusMessages(List<String> messages) {
messages.add(BBC.VISITOR_BLOCK.format(getAffected()));
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
"worldedit.operation.affected.block",
TextComponent.of(getAffected())
).color(TextColor.LIGHT_PURPLE));
}
}

Datei anzeigen

@ -23,14 +23,19 @@ import com.boydti.fawe.config.BBC;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists;
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 java.util.Iterator;
import java.util.List;
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;
/**
* Visits entities as provided by an {@code Iterator}.
@ -79,8 +84,11 @@ public class EntityVisitor implements Operation {
}
@Override
public void addStatusMessages(List<String> messages) {
messages.add(BBC.VISITOR_ENTITY.format(getAffected()));
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
"worldedit.operation.affected.entity",
TextComponent.of(getAffected())
).color(TextColor.LIGHT_PURPLE));
}
}

Datei anzeigen

@ -20,6 +20,8 @@
package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.config.BBC;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.operation.Operation;
@ -27,9 +29,11 @@ import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.FlatRegion;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
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}.
@ -79,8 +83,11 @@ public class FlatRegionVisitor implements Operation {
}
@Override
public void addStatusMessages(List<String> messages) {
messages.add(BBC.VISITOR_FLAT.format(getAffected()));
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
"worldedit.operation.affected.column",
TextComponent.of(getAffected())
).color(TextColor.LIGHT_PURPLE));
}
}

Datei anzeigen

@ -128,8 +128,4 @@ public class LayerVisitor implements Operation {
public void cancel() {
}
@Override
public void addStatusMessages(List<String> messages) {
}
}

Datei anzeigen

@ -19,6 +19,8 @@
package com.sk89q.worldedit.function.visitor;
import com.google.common.collect.Lists;
import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction;
@ -26,7 +28,10 @@ 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}.
@ -90,8 +95,11 @@ public class RegionVisitor implements Operation {
}
@Override
public void addStatusMessages(List<String> messages) {
messages.add(BBC.VISITOR_BLOCK.format(getAffected()));
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
"worldedit.operation.affected.block",
TextComponent.of(getAffected())
).color(TextColor.LIGHT_PURPLE));
}
}

Datei anzeigen

@ -19,15 +19,20 @@
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.world.World;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
@ -152,10 +157,24 @@ public interface RegionSelector {
/**
* Get lines of information about the selection.
*
*
* @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());
}
/**
* Get the vertices

Datei anzeigen

@ -35,6 +35,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;
@ -188,16 +191,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);
@ -206,7 +208,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
session.describeCUI(player);
BBC.SELECTOR_POS.send(player, 1, pos, region.getArea());
player.printInfo(TranslatableComponent.of("worldedit.selection.convex.explain.primary", TextComponent.of(pos.toString())));
}
@Override
@ -217,7 +219,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
session.describeCUI(player);
BBC.SELECTOR_POS.send(player, region.getVertices().size(), pos, region.getArea());
player.printInfo(TranslatableComponent.of("worldedit.selection.convex.explain.secondary", TextComponent.of(pos.toString())));
}
@Override

Datei anzeigen

@ -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 javax.annotation.Nullable;
@ -155,9 +158,13 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
//TODO Re-add better translation
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()));
@ -171,9 +178,13 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
//TODO Re-add better translation
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()));
@ -243,15 +254,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;

Datei anzeigen

@ -37,6 +37,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;
@ -172,7 +175,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
@Override
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
BBC.SELECTOR_CENTER.send(player, pos, 0);
player.printInfo(TranslatableComponent.of("worldedit.selection.cylinder.explain.primary", TextComponent.of(pos.toString())));
session.describeCUI(player);
}
@ -181,9 +185,14 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
Vector3 center = region.getCenter();
if (!center.equals(Vector3.ZERO)) {
BBC.SELECTOR_RADIUS.send(player, NUMBER_FORMAT.format(region.getRadius().getX()) + "/" + NUMBER_FORMAT.format(region.getRadius().getZ()), 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;
}
@ -238,14 +247,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;

Datei anzeigen

@ -35,7 +35,10 @@ 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.world.World;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import javax.annotation.Nullable;
import java.util.ArrayList;
@ -145,14 +148,36 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
@Override
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
BBC.SELECTOR_CENTER.send(player, region.getCenter(), region.getArea());
if (isDefined()) {
player.printInfo(TranslatableComponent.of(
"worldedit.selection.ellipsoid.explain.primary-area",
TextComponent.of(region.getCenter().toString()),
TextComponent.of(region.getArea())
));
} else {
player.printInfo(TranslatableComponent.of(
"worldedit.selection.ellipsoid.explain.primary",
TextComponent.of(region.getCenter().toString())
));
}
session.describeCUI(player);
}
@Override
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
BBC.SELECTOR_RADIUS.send(player, region.getRadius(), region.getArea());
if (isDefined()) {
player.printInfo(TranslatableComponent.of(
"worldedit.selection.ellipsoid.explain.secondary-area",
TextComponent.of(region.getRadius().toString()),
TextComponent.of(region.getArea())
));
} else {
player.printInfo(TranslatableComponent.of(
"worldedit.selection.ellipsoid.explain.secondary",
TextComponent.of(region.getRadius().toString())
));
}
session.describeCUI(player);
}
@ -197,17 +222,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;

Datei anzeigen

@ -25,6 +25,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;
@ -130,14 +132,22 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
@Override
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
BBC.SELECTOR_POS.send(player, 1, 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) {
BBC.SELECTOR_EXPANDED.send(player, pos, region.getArea());
player.printInfo(TranslatableComponent.of(
"worldedit.selection.extend.explain.secondary",
TextComponent.of(pos.toString()),
TextComponent.of(region.getArea())
));
explainRegionAdjust(player, session);
}

Datei anzeigen

@ -35,6 +35,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;
@ -169,7 +172,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
@Override
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
BBC.SELECTOR_POS.send(player, 1, pos, region.getArea());
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()));
@ -178,7 +181,11 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
@Override
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
BBC.SELECTOR_POS.send(player, region.size(), pos, region.getArea());
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()));
@ -236,8 +243,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

Datei anzeigen

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

Datei anzeigen

@ -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;
@ -110,29 +111,29 @@ public class CraftScriptContext extends CraftScriptEnvironment {
/**
* Print a regular message to the user.
*
*
* @param message a message
*/
public void print(String message) {
player.print(message);
player.printInfo(TextComponent.of(message));
}
/**
* Print an error message to the user.
*
*
* @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));
}
/**

Datei anzeigen

@ -39,6 +39,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
@ -122,6 +123,12 @@ public class PropertiesConfiguration extends LocalConfiguration {
allowSymlinks = getBool("allow-symbolic-links", allowSymlinks);
serverSideCUI = getBool("server-side-cui", serverSideCUI);
extendedYLimit = getBool("extended-y-limit", extendedYLimit);
defaultLocaleName = getString("default-locale", defaultLocaleName);
if (defaultLocaleName.equals("default")) {
defaultLocale = Locale.getDefault();
} else {
defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-'));
}
LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15));

Datei anzeigen

@ -30,6 +30,7 @@ import org.slf4j.Logger;
import java.io.IOException;
import java.util.HashSet;
import java.util.Locale;
/**
* A less simple implementation of {@link LocalConfiguration}
@ -126,6 +127,13 @@ public class YAMLConfiguration extends LocalConfiguration {
shellSaveType = type.isEmpty() ? null : type;
extendedYLimit = config.getBoolean("compat.extended-y-limit", false);
defaultLocaleName = config.getString("default-locale", defaultLocaleName);
if (defaultLocaleName.equals("default")) {
defaultLocale = Locale.getDefault();
} else {
defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-'));
}
}
public void unload() {

Datei anzeigen

@ -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 CONFIG_HOLDER.replace(WorldEdit.getInstance().getTranslationManager().convertText(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() {

Datei anzeigen

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

Datei anzeigen

@ -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));
}
/**

Datei anzeigen

@ -0,0 +1,49 @@
/*
* 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;
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();
}
}

Datei anzeigen

@ -27,16 +27,31 @@ public class ResourceLoader {
private ResourceLoader() {
}
private static URL getResourceForgeHack(String location) throws IOException {
return new URL("modjar://worldedit/" + 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);
return getResourceForgeHack(clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/")
+ "/" + name);
} catch (Exception e) {
// Not forge.
throw new IOException("Could not find " + name);
}
}
return url;
}
public static URL getResourceRoot(String name) throws IOException {
URL url = ResourceLoader.class.getResource("/" + name);
if (url == null) {
try {
return getResourceForgeHack(name);
} catch (Exception e) {
throw new IOException("Could not find " + name);
}
throw new IOException("Could not find " + name);
}
return url;
}

Datei anzeigen

@ -23,6 +23,8 @@ import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
import com.boydti.fawe.util.IncendoPaster;
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;
@ -43,7 +45,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);
@ -55,4 +59,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());
}
}

Datei anzeigen

@ -0,0 +1,159 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.translation;
import com.google.common.io.Files;
import com.google.common.io.Resources;
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.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
/**
* 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 HashMap<>();
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 HashMap<>();
}
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 HashMap<>();
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);
}
}

Datei anzeigen

@ -0,0 +1 @@
*/

Datei anzeigen

@ -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.cuboid-only": "//line only works with cuboid selections",
"worldedit.curve.changed": "{0} blocks have been changed.",
"worldedit.curve.convex-only": "//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!"
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -4,7 +4,8 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinServerPlayerEntity",
"MixinMinecraftServer"
"MixinMinecraftServer",
"AccessorServerPlayerEntity"
],
"server": [
],

Datei anzeigen

@ -57,6 +57,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;
@ -156,7 +157,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) {
@ -206,6 +207,11 @@ public class ForgePlayer extends AbstractPlayerActor {
}
}
@Override
public Locale getLocale() {
return Locale.forLanguageTag(player.language.replace('_', '-'));
}
@Override
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
World world = getWorld();

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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