Merge pull request #257 from IntellectualSites/i18n-merge

FAWE branch for i18n
This commit is contained in:
Jesse Boyd 2019-11-22 06:57:00 +11:00 committed by GitHub
commit 38d1e79fcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
141 changed files with 2556 additions and 974 deletions

View File

@ -53,4 +53,5 @@ dependencies {
// implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143") // implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143")
// implementation("net.fabricmc:fabric-loom:$loomVersion") // implementation("net.fabricmc:fabric-loom:$loomVersion")
// implementation("net.fabricmc:sponge-mixin:$mixinVersion") // implementation("net.fabricmc:sponge-mixin:$mixinVersion")
implementation("gradle.plugin.com.mendhak.gradlecrowdin:plugin:0.1.0")
} }

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.bukkit; package com.boydti.fawe.bukkit;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FaweCommand;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitBlockCommandSender; import com.sk89q.worldedit.bukkit.BukkitBlockCommandSender;

View File

@ -21,6 +21,8 @@ package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkNotNull; 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.AbstractNonPlayerActor;
import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extent.Extent; 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.adapter.bukkit.TextAdapter;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.BlockCommandSender; import org.bukkit.command.BlockCommandSender;
import java.util.Locale;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -72,7 +77,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
@Override @Override
public void print(String msg) { public void print(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
print(TextComponent.of(part, TextColor.LIGHT_PURPLE)); print(TextComponent.of(part, TextColor.GRAY));
} }
} }
@ -92,7 +97,12 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
@Override @Override
public void print(Component component) { 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 @Override

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText; import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
import com.sk89q.bukkit.util.CommandInspector; import com.sk89q.bukkit.util.CommandInspector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import java.util.Optional; import java.util.Optional;
import org.bukkit.command.Command; 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.Key;
import org.enginehub.piston.inject.MapBackedValueStore; import org.enginehub.piston.inject.MapBackedValueStore;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.util.Locale;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
class BukkitCommandInspector implements CommandInspector { class BukkitCommandInspector implements CommandInspector {
@ -51,7 +54,7 @@ class BukkitCommandInspector implements CommandInspector {
public String getShortText(Command command) { public String getShortText(Command command) {
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName()); Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
if (mapping.isPresent()) { if (mapping.isPresent()) {
return reduceToText(mapping.get().getDescription()); return reduceToText(mapping.get().getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale);
} else { } else {
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available"; return "Help text not available";
@ -62,7 +65,7 @@ class BukkitCommandInspector implements CommandInspector {
public String getFullText(Command command) { public String getFullText(Command command) {
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName()); Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
if (mapping.isPresent()) { if (mapping.isPresent()) {
return reduceToText(mapping.get().getFullHelp()); return reduceToText(mapping.get().getFullHelp(), WorldEdit.getInstance().getConfiguration().defaultLocale);
} else { } else {
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available"; return "Help text not available";

View File

@ -22,6 +22,8 @@ package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; 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.AbstractNonPlayerActor;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.auth.AuthorizationException; 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.Component;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter; import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import java.util.UUID; import java.util.UUID;
import java.util.Locale;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -93,7 +97,7 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
@Override @Override
public void print(Component component) { public void print(Component component) {
TextAdapter.sendComponent(sender, WorldEditText.format(component)); TextAdapter.sendComponent(sender, WorldEditText.format(component, getLocale()));
} }
@Override @Override
@ -113,6 +117,11 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
public void checkPermission(String permission) throws AuthorizationException { public void checkPermission(String permission) throws AuthorizationException {
} }
@Override
public Locale getLocale() {
return WorldEdit.getInstance().getConfiguration().defaultLocale;
}
@Override @Override
public SessionKey getSessionKey() { public SessionKey getSessionKey() {
return new SessionKey() { return new SessionKey() {

View File

@ -21,6 +21,8 @@ package com.sk89q.worldedit.bukkit;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
@ -40,11 +42,17 @@ import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.text.Component; 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.adapter.bukkit.TextAdapter; import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
@ -167,28 +175,25 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public void print(String msg) { public void print(String msg) {
for (String part : msg.split("\n")) { print(LegacyComponentSerializer.legacy().deserialize("&7" + msg, '&'));
player.sendMessage("\u00A7d" + part);
}
} }
@Override @Override
public void printDebug(String msg) { public void printDebug(String msg) {
for (String part : msg.split("\n")) { print(LegacyComponentSerializer.legacy().deserialize("&3" + msg, '&'));
player.sendMessage("\u00A77" + part);
}
} }
@Override @Override
public void printError(String msg) { public void printError(String msg) {
for (String part : msg.split("\n")) { print(LegacyComponentSerializer.legacy().deserialize("&c" + msg, '&'));
player.sendMessage("\u00A7c" + part);
}
} }
@Override @Override
public void print(Component component) { public void print(Component component) {
TextAdapter.sendComponent(player, WorldEditText.format(component)); Component prefix = TranslatableComponent.of("fawe.prefix");
component = TextComponent.builder().append(prefix).append(component).build();
component = BBC.color(component, getLocale());
TextAdapter.sendComponent(player, component);
} }
@Override @Override
@ -292,6 +297,11 @@ public class BukkitPlayer extends AbstractPlayerActor {
return player.teleport(BukkitAdapter.adapt(location)); return player.teleport(BukkitAdapter.adapt(location));
} }
@Override
public Locale getLocale() {
return Locale.forLanguageTag(player.getLocale().replace('_', '-'));
}
@Nullable @Nullable
@Override @Override
public <T> T getFacet(Class<? extends T> cls) { public <T> T getFacet(Class<? extends T> cls) {
@ -361,10 +371,10 @@ public class BukkitPlayer extends AbstractPlayerActor {
} }
@Override @Override
public void sendTitle(String title, String sub) { public void sendTitle(Component title, Component sub) {
player.sendTitle(ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20); String titleStr = WorldEditText.reduceToText(title, getLocale());
Bukkit.getServer().dispatchCommand(player, "title " + getName() + " subtitle [{\"text\":\"" + sub + "\",\"color\":\"gold\"}]"); String subStr = WorldEditText.reduceToText(sub, getLocale());
Bukkit.getServer().dispatchCommand(player, "title " + getName() + " title [{\"text\":\"" + title + "\",\"color\":\"gold\"}]"); player.sendTitle(titleStr, subStr, 0, 70, 20);
} }
@Override @Override

View File

@ -24,6 +24,7 @@ import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
import com.sk89q.bukkit.util.CommandInfo; import com.sk89q.bukkit.util.CommandInfo;
import com.sk89q.bukkit.util.CommandRegistration; import com.sk89q.bukkit.util.CommandRegistration;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.PermissionCondition; import com.sk89q.worldedit.command.util.PermissionCondition;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -38,6 +39,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -167,8 +169,9 @@ public class BukkitServerInterface implements MultiUserPlatform {
Stream.of(command.getName()), Stream.of(command.getName()),
command.getAliases().stream() command.getAliases().stream()
).toArray(String[]::new); ).toArray(String[]::new);
return new CommandInfo(reduceToText(command.getUsage()), // TODO Handle localisation correctly
reduceToText(command.getDescription()), aliases, return new CommandInfo(reduceToText(command.getUsage(), WorldEdit.getInstance().getConfiguration().defaultLocale),
reduceToText(command.getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale), aliases,
inspector, permissionsArray); inspector, permissionsArray);
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
} }

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.cli;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey; 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 org.slf4j.Logger;
import java.io.File; import java.io.File;
import java.util.Locale;
import java.util.UUID; import java.util.UUID;
public class CLICommandSender implements Actor { public class CLICommandSender implements Actor {
@ -97,7 +99,7 @@ public class CLICommandSender implements Actor {
@Override @Override
public void print(Component component) { public void print(Component component) {
print(PlainComponentSerializer.INSTANCE.serialize(WorldEditText.format(component))); print(PlainComponentSerializer.INSTANCE.serialize(WorldEditText.format(component, getLocale())));
} }
@Override @Override
@ -138,6 +140,11 @@ public class CLICommandSender implements Actor {
public void dispatchCUIEvent(CUIEvent event) { public void dispatchCUIEvent(CUIEvent event) {
} }
@Override
public Locale getLocale() {
return WorldEdit.getInstance().getConfiguration().defaultLocale;
}
@Override @Override
public SessionKey getSessionKey() { public SessionKey getSessionKey() {
return new SessionKey() { return new SessionKey() {

View File

@ -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.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.registry.state.Property; 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.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -237,13 +238,13 @@ public class CLIWorldEdit {
while (scanner.hasNextLine()) { while (scanner.hasNextLine()) {
String line = scanner.nextLine(); String line = scanner.nextLine();
if (line.equals("stop")) { if (line.equals("stop")) {
commandSender.print("Stopping!"); commandSender.printInfo(TranslatableComponent.of("worldedit.cli.stopping"));
break; break;
} }
CommandEvent event = new CommandEvent(commandSender, line); CommandEvent event = new CommandEvent(commandSender, line);
WorldEdit.getInstance().getEventBus().post(event); WorldEdit.getInstance().getEventBus().post(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
commandSender.printError("Unknown command!"); commandSender.printError(TranslatableComponent.of("worldedit.cli.unknown-command"));
} else { } else {
saveAllWorlds(false); saveAllWorlds(false);
} }

View File

@ -1,11 +1,14 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.plugins.ide.idea.model.IdeaModel import org.gradle.plugins.ide.idea.model.IdeaModel
import com.mendhak.gradlecrowdin.DownloadTranslationsTask
import com.mendhak.gradlecrowdin.UploadSourceFileTask
plugins { plugins {
id("java-library") id("java-library")
id("net.ltgt.apt-eclipse") id("net.ltgt.apt-eclipse")
id("net.ltgt.apt-idea") id("net.ltgt.apt-idea")
id("antlr") id("antlr")
id("com.mendhak.gradlecrowdin")
} }
repositories { 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")
}
}

View File

@ -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.event.ClickEvent
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration import com.sk89q.worldedit.util.formatting.text.format.TextDecoration
import org.enginehub.piston.util.TextHelper import org.enginehub.piston.util.TextHelper
import java.util.Locale
fun reduceToRst(component: Component): String { fun reduceToRst(component: Component): String {
val formatted = WorldEditText.format(component) val formatted = WorldEditText.format(component, Locale.US)
return formatAsRst(formatted).toString() return formatAsRst(formatted).toString()
} }

View File

@ -2,6 +2,7 @@ package com.boydti.fawe;
import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.brush.visualization.VisualQueue; import com.boydti.fawe.object.brush.visualization.VisualQueue;
import com.boydti.fawe.regions.general.integrations.plotquared.PlotSquaredFeature; import com.boydti.fawe.regions.general.integrations.plotquared.PlotSquaredFeature;

View File

@ -2,6 +2,8 @@ package com.boydti.fawe;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
@ -232,7 +234,7 @@ public class FaweAPI {
* @param reason * @param reason
* @see EditSession#getRegionExtent() To get the FaweExtent for an EditSession * @see EditSession#getRegionExtent() To get the FaweExtent for an EditSession
*/ */
public static void cancelEdit(Extent extent, BBC reason) { public static void cancelEdit(Extent extent, Component reason) {
try { try {
WEManager.IMP.cancelEdit(extent, new FaweException(reason)); WEManager.IMP.cancelEdit(extent, new FaweException(reason));
} catch (WorldEditException ignore) { } catch (WorldEditException ignore) {

View File

@ -5,6 +5,7 @@ import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.beta.Trimable;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BitArray4096; import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.CleanableThreadLocal; import com.boydti.fawe.object.collection.CleanableThreadLocal;
@ -199,15 +200,15 @@ public enum FaweCache implements Trimable {
*/ */
public static final FaweChunkLoadException CHUNK = new FaweChunkLoadException(); public static final FaweChunkLoadException CHUNK = new FaweChunkLoadException();
public static final FaweBlockBagException BLOCK_BAG = new FaweBlockBagException(); public static final FaweBlockBagException BLOCK_BAG = new FaweBlockBagException();
public static final FaweException MANUAL = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MANUAL); public static final FaweException MANUAL = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual"));
public static final FaweException NO_REGION = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_NO_REGION); public static final FaweException NO_REGION = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.no.region"));
public static final FaweException OUTSIDE_REGION = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION); public static final FaweException OUTSIDE_REGION = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region"));
public static final FaweException MAX_CHECKS = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); public static final FaweException MAX_CHECKS = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.checks"));
public static final FaweException MAX_CHANGES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES); public static final FaweException MAX_CHANGES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.changes"));
public static final FaweException LOW_MEMORY = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY); public static final FaweException LOW_MEMORY = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory"));
public static final FaweException MAX_ENTITIES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_ENTITIES); public static final FaweException MAX_ENTITIES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.entities"));
public static final FaweException MAX_TILES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_TILES); public static final FaweException MAX_TILES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.tiles"));
public static final FaweException MAX_ITERATIONS = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_ITERATIONS); public static final FaweException MAX_ITERATIONS = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.iterations"));
/* /*
thread cache thread cache

View File

@ -52,7 +52,7 @@ public class AnvilCommands {
// boolean copy = false; // boolean copy = false;
// if (FaweAPI.getWorld(folder) != null) { // if (FaweAPI.getWorld(folder) != null) {
// if (!force) { // if (!force) {
// BBC.WORLD_IS_LOADED.send(player); // player.print(TranslatableComponent.of("fawe.worldedit.anvil.world.is.loaded"))
// return null; // return null;
// } // }
// copy = true; // copy = true;
@ -80,7 +80,7 @@ public class AnvilCommands {
// @Deprecated // @Deprecated
// public static <G, T extends MCAFilter<G>> T runWithSelection(Player player, EditSession editSession, Region selection, T filter) { // public static <G, T extends MCAFilter<G>> T runWithSelection(Player player, EditSession editSession, Region selection, T filter) {
// if (!(selection instanceof CuboidRegion)) { // if (!(selection instanceof CuboidRegion)) {
// BBC.NO_REGION.send(player); // player.print(TranslatableComponent.of("fawe.error.no.region"))
// return null; // return null;
// } // }
// CuboidRegion cuboid = (CuboidRegion) selection; // CuboidRegion cuboid = (CuboidRegion) selection;
@ -131,7 +131,7 @@ public class AnvilCommands {
// final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true)); // final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true));
// ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo);
// ReplaceSimpleFilter result = runWithWorld(player, folder, filter, true); // ReplaceSimpleFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
} }
@Command( @Command(
@ -148,7 +148,7 @@ public class AnvilCommands {
// RemapFilter filter = new RemapFilter(from, to); // RemapFilter filter = new RemapFilter(from, to);
// RemapFilter result = runWithWorld(player, folder, filter, true); // RemapFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -167,7 +167,7 @@ public class AnvilCommands {
// DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED // DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED
// DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true); // DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -190,7 +190,7 @@ public class AnvilCommands {
// } // }
// DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true); // DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -212,7 +212,7 @@ public class AnvilCommands {
// } // }
// DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter); // DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -229,7 +229,7 @@ public class AnvilCommands {
// DeleteOldFilter filter = new DeleteOldFilter(duration); // DeleteOldFilter filter = new DeleteOldFilter(duration);
// DeleteOldFilter result = runWithWorld(player, folder, filter, true); // DeleteOldFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -249,7 +249,7 @@ public class AnvilCommands {
// MCAQueue queue = new MCAQueue(defaultQueue); // MCAQueue queue = new MCAQueue(defaultQueue);
// PlotTrimFilter result = queue.filterWorld(filter); // PlotTrimFilter result = queue.filterWorld(filter);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -262,7 +262,7 @@ public class AnvilCommands {
// DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); TODO NOT IMPLEMENTED // DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); TODO NOT IMPLEMENTED
// DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe); // DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -275,7 +275,7 @@ public class AnvilCommands {
// TrimAirFilter filter = new TrimAirFilter(); TODO NOT IMPLEMENTED // TrimAirFilter filter = new TrimAirFilter(); TODO NOT IMPLEMENTED
// TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe); // TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -289,7 +289,7 @@ public class AnvilCommands {
// DebugFixP2Roads filter = new DebugFixP2Roads(); TODO NOT IMPLEMENTED // DebugFixP2Roads filter = new DebugFixP2Roads(); TODO NOT IMPLEMENTED
// DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true); // DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -319,7 +319,7 @@ public class AnvilCommands {
// filter = new ReplacePatternFilter(matchFrom, to); // filter = new ReplacePatternFilter(matchFrom, to);
// } // }
// MCAFilterCounter result = runWithWorld(player, folder, filter, true); // MCAFilterCounter result = runWithWorld(player, folder, filter, true);
// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
} }
// //
@ -341,7 +341,7 @@ public class AnvilCommands {
// filter = counter; // filter = counter;
// } // }
// MCAFilterCounter result = runWithWorld(player, folder, filter, true); // MCAFilterCounter result = runWithWorld(player, folder, filter, true);
// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal())); // if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.selection.selection.count", (result.getTotal())));
} }
@Command( @Command(
@ -393,7 +393,7 @@ public class AnvilCommands {
// }; // };
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -415,7 +415,7 @@ public class AnvilCommands {
// filter = counter; // filter = counter;
// } // }
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal())); // if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.selection.selection.count", (result.getTotal())));
} }
// //
@ -514,7 +514,7 @@ public class AnvilCommands {
// ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo);
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -546,7 +546,7 @@ public class AnvilCommands {
// } // }
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -560,7 +560,7 @@ public class AnvilCommands {
// MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED // MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -578,7 +578,7 @@ public class AnvilCommands {
// RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id); // RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id);
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) { // if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); // player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal())));
// } // }
} }
@ -590,7 +590,7 @@ public class AnvilCommands {
@CommandPermissions("worldedit.anvil.copychunks") @CommandPermissions("worldedit.anvil.copychunks")
public void copy(Player player, LocalSession session, EditSession editSession, @Selection Region selection) throws WorldEditException { public void copy(Player player, LocalSession session, EditSession editSession, @Selection Region selection) throws WorldEditException {
// if (!(selection instanceof CuboidRegion)) { TODO NOT IMPLEMENTED // if (!(selection instanceof CuboidRegion)) { TODO NOT IMPLEMENTED
// BBC.NO_REGION.send(player); // player.print(TranslatableComponent.of("fawe.error.no.region"))
// return; // return;
// } // }
// CuboidRegion cuboid = (CuboidRegion) selection; // CuboidRegion cuboid = (CuboidRegion) selection;
@ -601,7 +601,7 @@ public class AnvilCommands {
// MCAClipboard clipboard = new MCAClipboard(queue, cuboid, origin); // MCAClipboard clipboard = new MCAClipboard(queue, cuboid, origin);
// FawePlayer fp = FawePlayer.wrap(player); // FawePlayer fp = FawePlayer.wrap(player);
// fp.setMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD, clipboard); // fp.setMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD, clipboard);
// BBC.COMMAND_COPY.send(player, selection.getArea()); // player.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy" , selection.getArea()));
} }
@Command( @Command(
@ -638,6 +638,6 @@ public class AnvilCommands {
// pasteQueue.pasteRegion(copyQueue, copyRegion, offset, iAnvilHistory); // pasteQueue.pasteRegion(copyQueue, copyRegion, offset, iAnvilHistory);
// } catch (IOException e) { throw new RuntimeException(e); } // } catch (IOException e) { throw new RuntimeException(e); }
// }); // });
// BBC.COMMAND_PASTE.send(player, player.getPosition().toBlockVector()); // player.print(TranslatableComponent.of("fawe.worldedit.paste.command.paste" , player.getPosition().toBlockVector()));
} }
} }

View File

@ -8,6 +8,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
@ -949,7 +950,7 @@ public class CFICommands {
JsonObject data1 = obj.get("data").getAsJsonObject(); JsonObject data1 = obj.get("data").getAsJsonObject();
String link = data1.get("link").getAsString(); String link = data1.get("link").getAsString();
URL url = new URL(link); URL url = new URL(link);
BBC.DOWNLOAD_LINK.send(player, url); player.print(TranslatableComponent.of("fawe.web.download.link" , url));
} }
@Command( @Command(

View File

@ -3,6 +3,7 @@ package com.boydti.fawe.command;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
@ -34,11 +35,11 @@ public class Rollback extends FaweCommand {
} }
Player player = (Player) actor; Player player = (Player) actor;
if (!Settings.IMP.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )"); player.print(TranslatableComponent.of("fawe.error.setting.disable" , "history.use-database (Import with /frb #import )"));
return false; return false;
} }
if (args.length != 3) { if (args.length != 3) {
BBC.COMMAND_SYNTAX.send(player, "/frb u:<uuid> r:<radius> t:<time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb u:<uuid> r:<radius> t:<time>"));
return false; return false;
} }
switch (args[0]) { switch (args[0]) {
@ -46,13 +47,13 @@ public class Rollback extends FaweCommand {
case "info": case "info":
case "undo": case "undo":
case "revert": case "revert":
BBC.COMMAND_SYNTAX.send(player, "/frb u:<uuid> r:<radius> t:<time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb u:<uuid> r:<radius> t:<time>"));
return false; return false;
} }
if (args.length < 1) { if (args.length < 1) {
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb <info|undo> u:<uuid> r:<radius> t:<time>"));
return false; return false;
} }
World world = player.getWorld(); World world = player.getWorld();
@ -60,7 +61,7 @@ public class Rollback extends FaweCommand {
case "i": case "i":
case "info": case "info":
if (args.length < 2) { if (args.length < 2) {
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb <info|undo> u:<uuid> r:<radius> t:<time>"));
return false; return false;
} }
player.deleteMeta(Player.METADATA_KEYS.ROLLBACK); player.deleteMeta(Player.METADATA_KEYS.ROLLBACK);
@ -101,13 +102,13 @@ public class Rollback extends FaweCommand {
case "undo": case "undo":
case "revert": case "revert":
if (!player.hasPermission("fawe.rollback.perform")) { if (!player.hasPermission("fawe.rollback.perform")) {
BBC.NO_PERM.send(player, "fawe.rollback.perform"); player.print(TranslatableComponent.of("fawe.error.no.perm", "fawe.rollback.perform"));
return false; return false;
} }
final List<DiskStorageHistory> edits = player.getMeta(Player.METADATA_KEYS.ROLLBACK); final List<DiskStorageHistory> edits = player.getMeta(Player.METADATA_KEYS.ROLLBACK);
player.deleteMeta(Player.METADATA_KEYS.ROLLBACK); player.deleteMeta(Player.METADATA_KEYS.ROLLBACK);
if (edits == null) { if (edits == null) {
BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb info u:<uuid> r:<radius> t:<time>"));
return false; return false;
} }
for (DiskStorageHistory edit : edits) { for (DiskStorageHistory edit : edits) {
@ -119,7 +120,7 @@ public class Rollback extends FaweCommand {
} }
player.print("Rollback complete!"); player.print("Rollback complete!");
default: default:
BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb info u:<uuid> r:<radius> t:<time>"));
return false; return false;
} }
return true; return true;
@ -132,7 +133,7 @@ public class Rollback extends FaweCommand {
for (String arg : args) { for (String arg : args) {
String[] split = arg.split(":"); String[] split = arg.split(":");
if (split.length != 2) { if (split.length != 2) {
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb <info|undo> u:<uuid> r:<radius> t:<time>"));
return; return;
} }
switch (split[0].toLowerCase()) { switch (split[0].toLowerCase()) {
@ -165,7 +166,7 @@ public class Rollback extends FaweCommand {
time = MainUtil.timeToSec(split[1]) * 1000; time = MainUtil.timeToSec(split[1]) * 1000;
break; break;
default: default:
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb <info|undo> u:<uuid> r:<radius> t:<time>"));
return; return;
} }
} }

View File

@ -4,12 +4,21 @@ import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.configuration.MemorySection; import com.boydti.fawe.configuration.MemorySection;
import com.boydti.fawe.configuration.file.YamlConfiguration; import com.boydti.fawe.configuration.file.YamlConfiguration;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.WorldEditText;
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.serializer.legacy.LegacyComponentSerializer;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -20,6 +29,7 @@ public enum BBC {
* Things to note about this class: * Things to note about this class:
* Can use multiple arguments %s, %s1, %s2, %s3 etc * Can use multiple arguments %s, %s1, %s2, %s3 etc
*/ */
PREFIX("&4&lFAWE&7: ", "Info"),
FILE_DELETED("%s0 has been deleted.", "Info"), FILE_DELETED("%s0 has been deleted.", "Info"),
SCHEMATIC_PASTING("&7The schematic is pasting. This cannot be undone.", "Info"), SCHEMATIC_PASTING("&7The schematic is pasting. This cannot be undone.", "Info"),
LIGHTING_PROPAGATE_SELECTION("Lighting has been propogated in %s0 chunks. (Note: To remove light use //removelight)", "Info"), LIGHTING_PROPAGATE_SELECTION("Lighting has been propogated in %s0 chunks. (Note: To remove light use //removelight)", "Info"),
@ -136,7 +146,6 @@ public enum BBC {
BRUSH_TRANSFORM("Brush transform set", "WorldEdit.Brush"), BRUSH_TRANSFORM("Brush transform set", "WorldEdit.Brush"),
BRUSH_MATERIAL("Brush material set", "WorldEdit.Brush"), BRUSH_MATERIAL("Brush material set", "WorldEdit.Brush"),
ROLLBACK_ELEMENT("Undoing %s0", "WorldEdit.Rollback"), ROLLBACK_ELEMENT("Undoing %s0", "WorldEdit.Rollback"),
TOOL_INSPECT("Inspect tool bound to %s0.", "WorldEdit.Tool"), TOOL_INSPECT("Inspect tool bound to %s0.", "WorldEdit.Tool"),
@ -309,6 +318,8 @@ public enum BBC {
SCRIPTING_CS("Use /cs with a script name first.", "WorldEdit.Scripting"), SCRIPTING_CS("Use /cs with a script name first.", "WorldEdit.Scripting"),
SCRIPTING_ERROR("An error occured while executing a craft script", "WorldEdit.Scripting"), SCRIPTING_ERROR("An error occured while executing a craft script", "WorldEdit.Scripting"),
TIP_SEL_LIST("Tip: See the different selection modes with //sel list", "Tips"), TIP_SEL_LIST("Tip: See the different selection modes with //sel list", "Tips"),
TIP_SELECT_CONNECTED("Tip: Select all connected blocks with //sel fuzzy", "Tips"), TIP_SELECT_CONNECTED("Tip: Select all connected blocks with //sel fuzzy", "Tips"),
TIP_SET_POS1("Tip: Use pos1 as a pattern with //set pos1", "Tips"), TIP_SET_POS1("Tip: Use pos1 as a pattern with //set pos1", "Tips"),
@ -377,7 +388,7 @@ public enum BBC {
*/ */
BBC(String defaultMessage, String category) { BBC(String defaultMessage, String category) {
this.defaultMessage = defaultMessage; this.defaultMessage = defaultMessage;
this.translatedMessage = defaultMessage; setTranslated(defaultMessage);
this.category = category.toLowerCase(Locale.ROOT); this.category = category.toLowerCase(Locale.ROOT);
} }
@ -428,7 +439,7 @@ public enum BBC {
yml.set(caption.category + "." + caption.name().toLowerCase(Locale.ROOT), value); yml.set(caption.category + "." + caption.name().toLowerCase(Locale.ROOT), value);
} }
captions.add(caption); captions.add(caption);
caption.translatedMessage = (String) value; caption.setTranslated((String) value);
} else { } else {
toRemove.add(key); toRemove.add(key);
} }
@ -451,6 +462,10 @@ public enum BBC {
} }
} }
private void setTranslated(String msg) {
this.translatedMessage = msg;
}
@Override @Override
public String toString() { public String toString() {
return s(); return s();
@ -509,4 +524,47 @@ public enum BBC {
} }
} }
/**
* Colorize a component with legacy color codes
* @param parent
* @param locale
* @return Component
*/
public static Component color(Component component, Locale locale) {
return color(WorldEditText.format(component, locale));
}
public static Component color(Component parent) {
if (parent instanceof TextComponent) {
TextComponent text = (TextComponent) parent;
String content = text.content();
if (content.indexOf('&') != -1) {
Component legacy = LegacyComponentSerializer.legacy().deserialize(content, '&');
legacy = legacy.style(parent.style());
if (!parent.children().isEmpty()) {
parent = TextComponent.builder().append(legacy).append(parent.children()).build();
} else {
parent = legacy;
}
}
}
List<Component> children = parent.children();
if (!children.isEmpty()) {
for (int i = 0; i < children.size(); i++) {
Component child = children.get(i);
Component coloredChild = color(child);
if (coloredChild != child) {
if (!(children instanceof ArrayList)) {
children = new ArrayList<>(children);
}
children.set(i, coloredChild);
}
}
if (children instanceof ArrayList) {
parent = parent.children(children);
}
}
return parent;
}
} }

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object; package com.boydti.fawe.object;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -30,7 +31,7 @@ public abstract class FaweCommand<T> {
TaskManager.IMP.async(() -> execute(player, args)); TaskManager.IMP.async(() -> execute(player, args));
} else { } else {
if (!player.runAction(() -> execute(player, args), true, true)) { if (!player.runAction(() -> execute(player, args), true, true)) {
player.printError(BBC.WORLDEDIT_COMMAND_LIMIT.s()); player.printError(TranslatableComponent.of("fawe.info.worldedit.command.limit"));
return true; return true;
} }
} }

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
@ -35,14 +36,14 @@ public class CatenaryBrush implements Brush, ResettableTool {
if (pos1 == null || pos2.equals(pos1)) { if (pos1 == null || pos2.equals(pos1)) {
if (!visual) { if (!visual) {
pos1 = pos2; pos1 = pos2;
BBC.BRUSH_LINE_PRIMARY.send(editSession.getPlayer(), pos2); editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.line.primary", pos2));
} }
return; return;
} }
if (this.vertex == null) { if (this.vertex == null) {
vertex = getVertex(pos1.toVector3(), pos2.toVector3(), slack); vertex = getVertex(pos1.toVector3(), pos2.toVector3(), slack);
if (this.direction) { if (this.direction) {
BBC.BRUSH_CATENARY_DIRECTION.send(editSession.getPlayer(), 2); editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.catenary.direction", 2));
return; return;
} }
} else if (this.direction) { } else if (this.direction) {
@ -60,7 +61,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
e.printStackTrace(); e.printStackTrace();
} }
if (!visual) { if (!visual) {
BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer()); editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.line.secondary"));
if (!select) { if (!select) {
pos1 = null; pos1 = null;
return; return;

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder; import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder;
import com.boydti.fawe.object.function.NullRegionFunction; import com.boydti.fawe.object.function.NullRegionFunction;
@ -42,7 +43,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
@Override @Override
public boolean reset() { public boolean reset() {
session.setClipboard(null); session.setClipboard(null);
player.print(BBC.BRUSH_RESET.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.reset"));
return true; return true;
} }
@ -87,7 +88,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
ClipboardHolder holder = new ClipboardHolder(newClipboard); ClipboardHolder holder = new ClipboardHolder(newClipboard);
session.setClipboard(holder); session.setClipboard(holder);
int blocks = builder.size(); int blocks = builder.size();
BBC.COMMAND_COPY.send(player, blocks); player.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy" , blocks));
} else { } else {
AffineTransform transform = null; AffineTransform transform = null;
if (randomRotate) { if (randomRotate) {

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.brush.heightmap.HeightMap; import com.boydti.fawe.object.brush.heightmap.HeightMap;
@ -46,7 +47,7 @@ public class HeightBrush implements Brush {
try { try {
heightMap = ScalableHeightMap.fromPNG(stream); heightMap = ScalableHeightMap.fromPNG(stream);
} catch (IOException e) { } catch (IOException e) {
throw new FaweException(BBC.BRUSH_HEIGHT_INVALID); throw new FaweException(TranslatableComponent.of("fawe.worldedit.brush.brush.height.invalid"));
} }
} else if (clipboard != null) { } else if (clipboard != null) {
heightMap = ScalableHeightMap.fromClipboard(clipboard); heightMap = ScalableHeightMap.fromClipboard(clipboard);

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.brush;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.database.DBHandler; import com.boydti.fawe.database.DBHandler;
import com.boydti.fawe.database.RollbackDatabase; import com.boydti.fawe.database.RollbackDatabase;
@ -20,6 +21,7 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location; 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.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import java.io.IOException; import java.io.IOException;
@ -58,11 +60,11 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
public boolean perform(final Player player, LocalSession session, boolean rightClick) { public boolean perform(final Player player, LocalSession session, boolean rightClick) {
if (!session.isToolControlEnabled() || !player.hasPermission("worldedit.tool.inspect")) { if (!session.isToolControlEnabled() || !player.hasPermission("worldedit.tool.inspect")) {
player.print(BBC.NO_PERM.format("worldedit.tool.inspect")); player.print(TranslatableComponent.of("", "worldedit.tool.inspect"));
return false; return false;
} }
if (!Settings.IMP.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
player.print(BBC.SETTING_DISABLE.format("history.use-database (Import with /frb #import )")); player.print(TranslatableComponent.of("fawe.error.setting.disable", ("history.use-database (Import with /frb #import )")));
return false; return false;
} }
BlockVector3 target = getTarget(player, rightClick).toBlockPoint(); BlockVector3 target = getTarget(player, rightClick).toBlockPoint();
@ -89,7 +91,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
int index = value.getIndex(); int index = value.getIndex();
long age = System.currentTimeMillis() - value.getBDFile().lastModified(); long age = System.currentTimeMillis() - value.getBDFile().lastModified();
String ageFormatted = MainUtil.secToTime(age / 1000); String ageFormatted = MainUtil.secToTime(age / 1000);
BBC.TOOL_INSPECT_INFO.send(player, name, BlockState.getFromOrdinal(from).getAsString(), BlockState.getFromOrdinal(to).getAsString(), ageFormatted); player.print(TranslatableComponent.of("fawe.worldedit.tool.tool.inspect.info" , name, BlockState.getFromOrdinal(from).getAsString(), BlockState.getFromOrdinal(to).getAsString(), ageFormatted));
count.incrementAndGet(); count.incrementAndGet();
return; return;
} }
@ -100,7 +102,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
}, new Runnable() { }, new Runnable() {
@Override @Override
public void run() { public void run() {
BBC.TOOL_INSPECT_INFO_FOOTER.send(player, count); player.print(TranslatableComponent.of("fawe.worldedit.tool.tool.inspect.info.footer" , count));
} }
}, false, false); }, false, false);
return true; return true;

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
@ -25,13 +26,13 @@ public class LineBrush implements Brush, ResettableTool {
if (pos1 == null) { if (pos1 == null) {
if (!visual) { if (!visual) {
pos1 = position; pos1 = position;
BBC.BRUSH_LINE_PRIMARY.send(editSession.getPlayer(), position); editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.line.primary", position));
} }
return; return;
} }
editSession.drawLine(pattern, pos1, position, size, !shell, flat); editSession.drawLine(pattern, pos1, position, size, !shell, flat);
if (!visual) { if (!visual) {
BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer()); editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.line.secondary"));
if (!select) { if (!select) {
pos1 = null; pos1 = null;
} else { } else {

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.brush;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.mask.IdMask; import com.boydti.fawe.object.mask.IdMask;
@ -94,13 +95,13 @@ public class SplineBrush implements Brush, ResettableTool {
points.add(position); points.add(position);
} }
this.positionSets.add(points); this.positionSets.add(points);
player.print(BBC.BRUSH_SPLINE_PRIMARY_2.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline.primary.2"));
if (!visualization) { if (!visualization) {
return; return;
} }
} }
if (positionSets.size() < 2) { if (positionSets.size() < 2) {
player.print(BBC.BRUSH_SPLINE_SECONDARY_ERROR.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline.secondary.error"));
return; return;
} }
List<Vector3> centroids = new ArrayList<>(); List<Vector3> centroids = new ArrayList<>();
@ -132,7 +133,7 @@ public class SplineBrush implements Brush, ResettableTool {
} }
editSession.drawSpline(pattern, currentSpline, 0, 0, 0, 10, 0, true); editSession.drawSpline(pattern, currentSpline, 0, 0, 0, 10, 0, true);
} }
player.print(BBC.BRUSH_SPLINE_SECONDARY.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline.secondary"));
if (visualization) { if (visualization) {
numSplines = originalSize; numSplines = originalSize;
positionSets.remove(positionSets.size() - 1); positionSets.remove(positionSets.size() - 1);

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
@ -39,7 +40,7 @@ public class SurfaceSpline implements Brush {
if (max == -1) return; if (max == -1) return;
// pos.mutY(max); // pos.mutY(max);
path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ())); path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ()));
editSession.getPlayer().print(BBC.BRUSH_SPLINE_PRIMARY_2.s()); editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline.primary.2"));
if (!vis) return; if (!vis) return;
} }
LocalBlockVectorSet vset = new LocalBlockVectorSet(); LocalBlockVectorSet vset = new LocalBlockVectorSet();
@ -93,6 +94,6 @@ public class SurfaceSpline implements Brush {
editSession.setBlocks(newSet, pattern); editSession.setBlocks(newSet, pattern);
if (!vis) path.clear(); if (!vis) path.clear();
} }
editSession.getPlayer().print(BBC.BRUSH_SPLINE_SECONDARY.s()); editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline.secondary"));
} }
} }

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush.scroll; package com.boydti.fawe.object.brush.scroll;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -46,7 +47,7 @@ public abstract class Scroll implements ScrollTool {
return null; return null;
case CLIPBOARD: case CLIPBOARD:
if (arguments.size() != 2) { if (arguments.size() != 2) {
if (message) BBC.COMMAND_SYNTAX.send(player, "clipboard [file]"); if (message) player.print(TranslatableComponent.of("fawe.error.command.syntax" , "clipboard [file]"));
return null; return null;
} }
String filename = arguments.get(1); String filename = arguments.get(1);
@ -61,7 +62,7 @@ public abstract class Scroll implements ScrollTool {
} }
case MASK: case MASK:
if (arguments.size() < 2) { if (arguments.size() < 2) {
if (message) BBC.COMMAND_SYNTAX.send(player, "mask [mask 1] [mask 2] [mask 3]..."); if (message) player.print(TranslatableComponent.of("fawe.error.command.syntax" , "mask [mask 1] [mask 2] [mask 3]..."));
return null; return null;
} }
Mask[] masks = new Mask[arguments.size() - 1]; Mask[] masks = new Mask[arguments.size() - 1];
@ -72,7 +73,7 @@ public abstract class Scroll implements ScrollTool {
return (new ScrollMask(tool, masks)); return (new ScrollMask(tool, masks));
case PATTERN: case PATTERN:
if (arguments.size() < 2) { if (arguments.size() < 2) {
if (message) BBC.COMMAND_SYNTAX.send(player, "pattern [pattern 1] [pattern 2] [pattern 3]..."); if (message) player.print(TranslatableComponent.of("fawe.error.command.syntax" , "pattern [pattern 1] [pattern 2] [pattern 3]..."));
return null; return null;
} }
Pattern[] patterns = new Pattern[arguments.size() - 1]; Pattern[] patterns = new Pattern[arguments.size() - 1];

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush.sweep; package com.boydti.fawe.object.brush.sweep;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.ResettableTool; import com.boydti.fawe.object.brush.ResettableTool;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
@ -53,13 +54,13 @@ public class SweepBrush implements Brush, ResettableTool {
return; return;
} }
if (newPos) { if (newPos) {
player.print(BBC.BRUSH_SPLINE_PRIMARY_2.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline.primary.2"));
positions.add(position); positions.add(position);
return; return;
} }
if (positions.size() < 2) { if (positions.size() < 2) {
player.printError(BBC.BRUSH_SPLINE_SECONDARY_ERROR.s()); player.printError(TranslatableComponent.of("fawe.worldedit.brush.brush.spline.secondary.error"));
return; return;
} }
@ -122,7 +123,7 @@ public class SweepBrush implements Brush, ResettableTool {
break; break;
} }
} }
player.print(BBC.BRUSH_SPLINE_SECONDARY.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline.secondary"));
reset(); reset();
} }

View File

@ -1,9 +1,10 @@
package com.boydti.fawe.object.exception; package com.boydti.fawe.object.exception;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
public class FaweBlockBagException extends FaweException { public class FaweBlockBagException extends FaweException {
public FaweBlockBagException() { public FaweBlockBagException() {
super(BBC.WORLDEDIT_SOME_FAILS_BLOCKBAG); super(TranslatableComponent.of("fawe.error.worldedit.some.fails.blockbag"));
} }
} }

View File

@ -1,9 +1,10 @@
package com.boydti.fawe.object.exception; package com.boydti.fawe.object.exception;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
public class FaweChunkLoadException extends FaweException { public class FaweChunkLoadException extends FaweException {
public FaweChunkLoadException() { public FaweChunkLoadException() {
super(BBC.WORLDEDIT_FAILED_LOAD_CHUNK); super(TranslatableComponent.of("fawe.cancel.worldedit.failed.load.chunk"));
} }
} }

View File

@ -1,8 +1,15 @@
package com.boydti.fawe.object.exception; package com.boydti.fawe.object.exception;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.util.formatting.WorldEditText;
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.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import java.util.Locale;
public class FaweException extends RuntimeException { public class FaweException extends RuntimeException {
// DEBUG // DEBUG
public static final FaweException _enableQueue; public static final FaweException _enableQueue;
@ -18,18 +25,22 @@ public class FaweException extends RuntimeException {
} }
} }
private final String message; private final Component message;
public FaweException(String reason) { public FaweException(String reason) {
this.message = reason; this(TextComponent.of(reason));
} }
public FaweException(BBC reason) { public FaweException(Component reason) {
this(reason.format()); this.message = reason;
} }
@Override @Override
public String getMessage() { public String getMessage() {
return WorldEditText.reduceToText(message, Locale.ROOT);
}
public Component getComponent() {
return message; return message;
} }

View File

@ -9,6 +9,7 @@ import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent; import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
public class MemoryCheckingExtent extends PassthroughExtent { public class MemoryCheckingExtent extends PassthroughExtent {
private final Player player; private final Player player;
@ -22,9 +23,9 @@ public class MemoryCheckingExtent extends PassthroughExtent {
public Extent getExtent() { public Extent getExtent() {
if (MemUtil.isMemoryLimited()) { if (MemUtil.isMemoryLimited()) {
if (this.player != null) { if (this.player != null) {
player.print(BBC.WORLDEDIT_CANCEL_REASON.format(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY.s())); player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason", (TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory"))));
if (Permission.hasPermission(this.player, "worldedit.fast")) { if (Permission.hasPermission(this.player, "worldedit.fast")) {
BBC.WORLDEDIT_OOM_ADMIN.send(this.player); this.player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin"));
} }
} }
WEManager.IMP.cancelEdit(this, FaweCache.LOW_MEMORY); WEManager.IMP.cancelEdit(this, FaweCache.LOW_MEMORY);

View File

@ -6,6 +6,8 @@ import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
@ -44,7 +46,7 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
* *
* @param extent the extent * @param extent the extent
*/ */
public NullExtent(Extent extent, BBC failReason) { public NullExtent(Extent extent, Component failReason) {
this(extent, new FaweException(failReason)); this(extent, new FaweException(failReason));
} }

View File

@ -1,6 +1,8 @@
package com.boydti.fawe.object.progress; package com.boydti.fawe.object.progress;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
public class ChatProgressTracker extends DefaultProgressTracker { public class ChatProgressTracker extends DefaultProgressTracker {
public ChatProgressTracker(Player player) { public ChatProgressTracker(Player player) {
@ -9,7 +11,7 @@ public class ChatProgressTracker extends DefaultProgressTracker {
} }
@Override @Override
public void sendTile(String title, String sub) { public void sendTile(Component title, Component sub) {
getPlayer().print(title + sub); getPlayer().print(TextComponent.builder().append(title).append("\n").append(sub).build());
} }
} }

View File

@ -1,6 +1,9 @@
package com.boydti.fawe.object.progress; package com.boydti.fawe.object.progress;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
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.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
@ -101,7 +104,7 @@ public class DefaultProgressTracker implements BiConsumer<DefaultProgressTracker
} }
public void doneTask() { public void doneTask() {
sendTile("", BBC.PROGRESS_FINISHED.s()); sendTile(TextComponent.empty(), TranslatableComponent.of("fawe.progress.progress.finished"));
} }
public void sendTask() { public void sendTask() {
@ -112,10 +115,10 @@ public class DefaultProgressTracker implements BiConsumer<DefaultProgressTracker
String speedStr = StringMan.padRight("" + speed, 3); String speedStr = StringMan.padRight("" + speed, 3);
String percent = StringMan.padRight("" + (amountDispatch != 0 ? (amountDispatch * 100) / totalQueue : 0), 3); String percent = StringMan.padRight("" + (amountDispatch != 0 ? (amountDispatch * 100) / totalQueue : 0), 3);
int remaining = speed != 0 ? amountQueue / speed : -1; int remaining = speed != 0 ? amountQueue / speed : -1;
sendTile("", BBC.PROGRESS_MESSAGE.format(queue, dispatch, percent, StringMan.padLeft("" + speed, 3), StringMan.padLeft("" + remaining, 3))); sendTile(TextComponent.empty(), TranslatableComponent.of("fawe.progress.progress.message", queue, dispatch, percent, StringMan.padLeft("" + speed, 3), StringMan.padLeft("" + remaining, 3)));
} }
public void sendTile(String title, String sub) { public void sendTile(Component title, Component sub) {
player.sendTitle(title, sub); player.sendTitle(title, sub);
} }
} }

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.regions.selector; package com.boydti.fawe.object.regions.selector;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.regions.FuzzyRegion; import com.boydti.fawe.object.regions.FuzzyRegion;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.ExtentTraverser;
@ -88,13 +89,13 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele
@Override @Override
public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) { public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) {
int size = this.region.getArea(); int size = this.region.getArea();
BBC.SELECTOR_FUZZY_POS1.send(player, position, "(" + region.getArea() + ")"); player.print(TranslatableComponent.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getArea() + ")"));
} }
@Override @Override
public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) { public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) {
int size = this.region.getArea(); int size = this.region.getArea();
BBC.SELECTOR_FUZZY_POS2.send(player, position, "(" + region.getArea() + ")"); player.print(TranslatableComponent.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getArea() + ")"));
} }
@Override @Override

View File

@ -5,6 +5,7 @@
//import com.boydti.fawe.beta.IChunk; //import com.boydti.fawe.beta.IChunk;
//import com.boydti.fawe.beta.IQueueExtent; //import com.boydti.fawe.beta.IQueueExtent;
//import com.boydti.fawe.config.BBC; //import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
//import com.boydti.fawe.object.*; //import com.boydti.fawe.object.*;
//import com.boydti.fawe.object.brush.visualization.ImmutableVirtualWorld; //import com.boydti.fawe.object.brush.visualization.ImmutableVirtualWorld;
//import com.boydti.fawe.object.clipboard.LazyClipboardHolder; //import com.boydti.fawe.object.clipboard.LazyClipboardHolder;
@ -129,7 +130,7 @@
// URI uri = file.toURI(); // URI uri = file.toURI();
// ClipboardFormat format = ClipboardFormats.findByFile(file); // ClipboardFormat format = ClipboardFormats.findByFile(file);
// format.hold(player, uri, new FileInputStream(file)); // format.hold(player, uri, new FileInputStream(file));
// BBC.SCHEMATIC_LOADED.send(player, filename); // player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded" , filename));
// session.setVirtualWorld(null); // session.setVirtualWorld(null);
// return; // return;
// } // }
@ -157,7 +158,7 @@
// session.setClipboard(null); // session.setClipboard(null);
// } // }
// select.put(clicked, false); // select.put(clicked, false);
// BBC.CLIPBOARD_CLEARED.send(player); // player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.cleared"))
// } // }
// } else { // } else {
// // Add it // // Add it
@ -165,7 +166,7 @@
// MultiClipboardHolder multi = new MultiClipboardHolder(URI.create(""), new LazyClipboardHolder(uri, source, format, null)); // MultiClipboardHolder multi = new MultiClipboardHolder(URI.create(""), new LazyClipboardHolder(uri, source, format, null));
// session.addClipboard(multi); // session.addClipboard(multi);
// select.put(clicked, true); // select.put(clicked, true);
// BBC.SCHEMATIC_LOADED.send(player, file.getName()); // player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded" , file.getName()));
// } // }
// } // }
// // Resend relevant chunks // // Resend relevant chunks

View File

@ -1,12 +1,18 @@
package com.boydti.fawe.object.visitor; package com.boydti.fawe.object.visitor;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.google.common.collect.Lists;
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.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.object.IntegerTrio;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
@ -139,9 +145,11 @@ public abstract class DFSVisitor implements Operation {
} }
@Override public Iterable<Component> getStatusMessages() {
public void addStatusMessages(List<String> messages) { return Lists.newArrayList(TranslatableComponent.of(
messages.add(BBC.VISITOR_BLOCK.format(getAffected())); "fawe.worldedit.visitor.visitor.block",
TextComponent.of(getAffected())
).color(TextColor.GRAY));
} }
public int getAffected() { public int getAffected() {

View File

@ -10,6 +10,7 @@ import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.processors.LimitProcessor; import com.boydti.fawe.beta.implementation.processors.LimitProcessor;
import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent; import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.logging.LoggingChangeSet; import com.boydti.fawe.logging.LoggingChangeSet;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
@ -306,7 +307,7 @@ public class EditSessionBuilder {
if (checkMemory) { if (checkMemory) {
if (MemUtil.isMemoryLimitedSlow()) { if (MemUtil.isMemoryLimitedSlow()) {
if (Permission.hasPermission(player, "worldedit.fast")) { if (Permission.hasPermission(player, "worldedit.fast")) {
player.print(BBC.WORLDEDIT_OOM_ADMIN.s()); player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin"));
} }
throw FaweCache.LOW_MEMORY; throw FaweCache.LOW_MEMORY;
} }

View File

@ -5,6 +5,10 @@ import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.FaweOutputStream;
@ -61,6 +65,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Scanner; import java.util.Scanner;
import java.util.UUID; import java.util.UUID;
@ -831,7 +836,8 @@ public class MainUtil {
long age = now - file.lastModified(); long age = now - file.lastModified();
if (age > timeDiff) { if (age > timeDiff) {
pool.submit(file::delete); pool.submit(file::delete);
if (printDebug) BBC.FILE_DELETED.send((Player)null, file); Component msg = WorldEditText.format(TranslatableComponent.of("fawe.info.file.deleted"), Locale.ROOT);
if (printDebug) Fawe.debug(msg);
} }
}); });
pool.shutdown(); pool.shutdown();

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
@ -700,7 +701,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
} }
} }
BBC.WORLDEDIT_SOME_FAILS_BLOCKBAG.send(player, str.toString()); player.print(TranslatableComponent.of("fawe.error.worldedit.some.fails.blockbag", str.toString()));
} }
} }
return Collections.emptyMap(); return Collections.emptyMap();
@ -1020,11 +1021,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
FaweLimit used = getLimitUsed(); FaweLimit used = getLimitUsed();
if (used.MAX_FAILS > 0) { if (used.MAX_FAILS > 0) {
if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) { if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) {
BBC.WORLDEDIT_SOME_FAILS.send(player, used.MAX_FAILS); player.print(TranslatableComponent.of("fawe.error.worldedit.some.fails", used.MAX_FAILS));
} else if (new ExtentTraverser<>(getExtent()).findAndGet(FaweRegionExtent.class) != null){ } else if (new ExtentTraverser<>(getExtent()).findAndGet(FaweRegionExtent.class) != null){
player.printError(BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION.s()); player.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region"));
} else { } else {
player.printError(BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_LEVEL.s()); player.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.level"));
} }
} }
// Reset limit // Reset limit

View File

@ -34,6 +34,7 @@ import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
import java.io.File; import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
@ -82,6 +83,8 @@ public abstract class LocalConfiguration {
public boolean allowSymlinks = false; public boolean allowSymlinks = false;
public boolean serverSideCUI = true; public boolean serverSideCUI = true;
public boolean extendedYLimit = false; public boolean extendedYLimit = false;
public String defaultLocaleName = "default";
public Locale defaultLocale = Locale.getDefault();
protected String[] getDefaultDisallowedBlocks() { protected String[] getDefaultDisallowedBlocks() {
List<BlockType> blockTypes = Lists.newArrayList( List<BlockType> blockTypes = Lists.newArrayList(

View File

@ -52,12 +52,16 @@ import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors; import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors;
import com.sk89q.worldedit.util.eventbus.EventBus; 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.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameException; import com.sk89q.worldedit.util.io.file.FilenameException;
import com.sk89q.worldedit.util.io.file.FilenameResolutionException; import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
import com.sk89q.worldedit.util.io.file.InvalidFilenameException; import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
import com.sk89q.worldedit.util.task.SimpleSupervisor; import com.sk89q.worldedit.util.task.SimpleSupervisor;
import com.sk89q.worldedit.util.task.Supervisor; 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.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BundledBlockData; import com.sk89q.worldedit.world.registry.BundledBlockData;
@ -109,6 +113,7 @@ public final class WorldEdit {
private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator( private final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(
EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20, "WorldEdit Task Executor - %s")); EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 20, "WorldEdit Task Executor - %s"));
private final Supervisor supervisor = new SimpleSupervisor(); private final Supervisor supervisor = new SimpleSupervisor();
private final TranslationManager translationManager = new TranslationManager(this);
private final BlockFactory blockFactory = new BlockFactory(this); private final BlockFactory blockFactory = new BlockFactory(this);
private final ItemFactory itemFactory = new ItemFactory(this); private final ItemFactory itemFactory = new ItemFactory(this);
@ -224,6 +229,15 @@ public final class WorldEdit {
return sessions; 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 * 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 * has valid characters and has an extension. It also prevents directory
@ -631,7 +645,7 @@ public final class WorldEdit {
* @param player the player * @param player the player
* @param f the script file to execute * @param f the script file to execute
* @param args arguments for the script * @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 { public void runScript(Player player, File f, String[] args) throws WorldEditException {
String filename = f.getPath(); String filename = f.getPath();
@ -639,7 +653,7 @@ public final class WorldEdit {
String ext = filename.substring(index + 1); String ext = filename.substring(index + 1);
if (!ext.equalsIgnoreCase("js")) { if (!ext.equalsIgnoreCase("js")) {
player.printError("Only .js scripts are currently supported"); player.printError(TranslatableComponent.of("worldedit.script.unsupported"));
return; return;
} }
@ -652,7 +666,7 @@ public final class WorldEdit {
file = WorldEdit.class.getResourceAsStream("craftscripts/" + filename); file = WorldEdit.class.getResourceAsStream("craftscripts/" + filename);
if (file == null) { if (file == null) {
player.printError("Script does not exist: " + filename); player.printError(TranslatableComponent.of("worldedit.script.file-not-found", TextComponent.of(filename)));
return; return;
} }
} else { } else {
@ -665,7 +679,7 @@ public final class WorldEdit {
in.close(); in.close();
script = new String(data, 0, data.length, StandardCharsets.UTF_8); script = new String(data, 0, data.length, StandardCharsets.UTF_8);
} catch (IOException e) { } catch (IOException e) {
player.printError("Script read error: " + e.getMessage()); player.printError(TranslatableComponent.of("worldedit.script.read-error", TextComponent.of(e.getMessage())));
return; return;
} }
@ -678,8 +692,7 @@ public final class WorldEdit {
try { try {
engine = new RhinoCraftScriptEngine(); engine = new RhinoCraftScriptEngine();
} catch (NoClassDefFoundError ignored) { } catch (NoClassDefFoundError ignored) {
player.printError("Failed to find an installed script engine."); player.printError(TranslatableComponent.of("worldedit.script.no-script-engine"));
player.printError("Please see https://worldedit.enginehub.org/en/latest/usage/other/craftscripts/");
return; return;
} }
@ -693,14 +706,13 @@ public final class WorldEdit {
try { try {
engine.evaluate(script, filename, vars); engine.evaluate(script, filename, vars);
} catch (ScriptException e) { } catch (ScriptException e) {
player.printError("Failed to execute:"); player.printError(TranslatableComponent.of("worldedit.script.failed", TextComponent.of(e.getMessage(), TextColor.WHITE)));
player.printRaw(e.getMessage());
logger.warn("Failed to execute script", e); logger.warn("Failed to execute script", e);
} catch (NumberFormatException | WorldEditException e) { } catch (NumberFormatException | WorldEditException e) {
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
player.printError("Failed to execute (see console):"); player.printError(TranslatableComponent.of("worldedit.script.failed-console", TextComponent.of(e.getClass().getCanonicalName(),
player.printRaw(e.getClass().getCanonicalName()); TextColor.WHITE)));
logger.warn("Failed to execute script", e); logger.warn("Failed to execute script", e);
} finally { } finally {
for (EditSession editSession : scriptContext.getEditSessions()) { for (EditSession editSession : scriptContext.getEditSessions()) {

View File

@ -61,19 +61,19 @@ import org.enginehub.piston.part.SubCommandPart;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class ApplyBrushCommands { 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()) .defaultsTo(ImmutableList.of())
.ofTypes(ImmutableList.of(Key.of(RegionFactory.class))) .ofTypes(ImmutableList.of(Key.of(RegionFactory.class)))
.build(); .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")) .defaultsTo(ImmutableList.of("5"))
.ofTypes(ImmutableList.of(Key.of(double.class))) .ofTypes(ImmutableList.of(Key.of(double.class)))
.build(); .build();
public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) { public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) {
commandManager.register("apply", builder -> { 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); builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
CommandManager manager = service.newCommandManager(); CommandManager manager = service.newCommandManager();
@ -85,7 +85,7 @@ public class ApplyBrushCommands {
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.apply"))); builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.apply")));
builder.addParts(REGION_FACTORY, RADIUS); 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())) .withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required() .required()
.build()); .build());
@ -125,8 +125,7 @@ public class ApplyBrushCommands {
@Direction(includeDiagonals = true) @Direction(includeDiagonals = true)
com.sk89q.worldedit.util.Direction direction) throws WorldEditException { com.sk89q.worldedit.util.Direction direction) throws WorldEditException {
player.print(TextComponent.builder().append("WARNING: ", TextColor.RED, TextDecoration.BOLD) 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," + .append(TranslatableComponent.of("worldedit.brush.apply.item.warning")).build());
" and may cause strange interactions with other mods/plugins. Use at your own risk.").build());
setApplyBrush(parameters, player, localSession, new ItemUseFactory(item, direction)); setApplyBrush(parameters, player, localSession, new ItemUseFactory(item, direction));
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -49,6 +50,11 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.Regions; import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.component.PaginationBox; 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.World;
import com.sk89q.worldedit.world.biome.BiomeData; import com.sk89q.worldedit.world.biome.BiomeData;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
@ -58,6 +64,7 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import java.util.List;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch; import org.enginehub.piston.annotation.param.Switch;
@ -101,7 +108,7 @@ public class BiomeCommands {
}) })
.collect(Collectors.toList())); .collect(Collectors.toList()));
return paginationBox.create(page); return paginationBox.create(page);
}, null); }, (Component) null);
} }
@Command( @Command(
@ -118,24 +125,24 @@ public class BiomeCommands {
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
Set<BiomeType> biomes = new HashSet<>(); Set<BiomeType> biomes = new HashSet<>();
String qualifier; String messageKey;
if (useLineOfSight) { if (useLineOfSight) {
Location blockPosition = player.getBlockTrace(300); Location blockPosition = player.getBlockTrace(300);
if (blockPosition == null) { if (blockPosition == null) {
player.printError(BBC.NO_BLOCK.s()); player.printError(TranslatableComponent.of("worldedit.raytrace.noblock"));
return; return;
} }
BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2()); BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint().toBlockVector2());
biomes.add(biome); biomes.add(biome);
qualifier = "at line of sight point"; messageKey = "worldedit.biomeinfo.lineofsight";
} else if (usePosition) { } else if (usePosition) {
BiomeType biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2()); BiomeType biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint().toBlockVector2());
biomes.add(biome); biomes.add(biome);
qualifier = "at your position"; messageKey = "worldedit.biomeinfo.position";
} else { } else {
World world = player.getWorld(); World world = player.getWorld();
Region region = session.getSelection(world); Region region = session.getSelection(world);
@ -150,19 +157,18 @@ public class BiomeCommands {
} }
} }
qualifier = "in your selection"; messageKey = "worldedit.biomeinfo.selection";
} }
BBC.BIOME_LIST_HEADER.send(player, 1, 1); List<Component> components = biomes.stream().map(biome -> {
player.print(biomes.size() != 1 ? "Biomes " + qualifier + ":" : "Biome " + qualifier + ":");
for (BiomeType biome : biomes) {
BiomeData data = biomeRegistry.getData(biome); BiomeData data = biomeRegistry.getData(biome);
if (data != null) { if (data != null) {
player.print(" " + data.getName()); return TextComponent.of(data.getName()).hoverEvent(HoverEvent.showText(TextComponent.of(biome.getId())));
} else { } 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( @Command(
@ -195,9 +201,13 @@ public class BiomeCommands {
FlatRegionVisitor visitor = new FlatRegionVisitor(Regions.asFlatRegion(region), replace); FlatRegionVisitor visitor = new FlatRegionVisitor(Regions.asFlatRegion(region), replace);
Operations.completeLegacy(visitor); 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")) { if (!player.hasPermission("fawe.tips")) {
BBC.TIP_BIOME_PATTERN.or(BBC.TIP_BIOME_MASK).send(player); System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.biome.pattern").or(TranslatableComponent.of("fawe.tips.tip.biome.mask")).send(player);
} }
} }

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.command;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.brush.BlendBall; import com.boydti.fawe.object.brush.BlendBall;
@ -124,6 +125,8 @@ import java.net.URI;
import java.nio.file.FileSystems; import java.nio.file.FileSystems;
import java.util.List; import java.util.List;
import java.util.zip.GZIPInputStream; 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 org.enginehub.piston.annotation.Command;
import com.sk89q.worldedit.function.factory.Apply; import com.sk89q.worldedit.function.factory.Apply;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
@ -270,7 +273,7 @@ public class BrushCommands {
@Arg(desc = "The radius to sample for blending", def = "25") @Arg(desc = "The radius to sample for blending", def = "25")
Expression radius) throws WorldEditException { Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
player.print(BBC.BRUSH_SPLINE.format(radius)); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline", (radius)));
set(context, set(context,
new SplineBrush(player)) new SplineBrush(player))
.setSize(radius) .setSize(radius)
@ -288,7 +291,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.sweep") @CommandPermissions("worldedit.brush.sweep")
public void sweepBrush(Player player, InjectedValueAccess context, public void sweepBrush(Player player, InjectedValueAccess context,
@Arg(desc = "int", def = "-1") int copies) throws WorldEditException { @Arg(desc = "int", def = "-1") int copies) throws WorldEditException {
player.print(BBC.BRUSH_SPLINE.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline"));
set(context, new SweepBrush(copies)); set(context, new SweepBrush(copies));
} }
@ -331,7 +334,7 @@ public class BrushCommands {
@Arg(desc = "double", def = "0") double bias, @Arg(desc = "double", def = "0") double bias,
@Arg(desc = "double", def = "0") double continuity, @Arg(desc = "double", def = "0") double continuity,
@Arg(desc = "double", def = "10") double quality) throws WorldEditException { @Arg(desc = "double", def = "10") double quality) throws WorldEditException {
player.print(BBC.BRUSH_SPLINE.format(radius)); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline", (radius)));
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
set(context, set(context,
new SurfaceSpline(tension, bias, continuity, quality)) new SurfaceSpline(tension, bias, continuity, quality))
@ -386,7 +389,7 @@ public class BrushCommands {
switch (type.getInternalId()) { switch (type.getInternalId()) {
case BlockID.SAND: case BlockID.SAND:
case BlockID.GRAVEL: case BlockID.GRAVEL:
player.print(BBC.BRUSH_TRY_OTHER.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.try.other"));
falling = true; falling = true;
} }
} }
@ -537,12 +540,12 @@ public class BrushCommands {
try { try {
MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true); MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true);
if (clipboards == null) { if (clipboards == null) {
BBC.SCHEMATIC_NOT_FOUND.send(player, clipboardStr); player.print(TranslatableComponent.of("fawe.error.schematic.not.found" , clipboardStr));
return; return;
} }
List<ClipboardHolder> holders = clipboards.getHolders(); List<ClipboardHolder> holders = clipboards.getHolders();
if (holders == null) { if (holders == null) {
BBC.SCHEMATIC_NOT_FOUND.send(player, clipboardStr); player.print(TranslatableComponent.of("fawe.error.schematic.not.found" , clipboardStr));
return; return;
} }
@ -843,7 +846,7 @@ public class BrushCommands {
@Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate,
@Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate) throws WorldEditException { @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
player.print(BBC.BRUSH_COPY.format(radius)); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.copy", (radius)));
set(context, set(context,
new CopyPastaBrush(player, session, randomRotate, autoRotate)) new CopyPastaBrush(player, session, randomRotate, autoRotate))
@ -918,7 +921,7 @@ public class BrushCommands {
tool.setPrimary(settings); tool.setPrimary(settings);
tool.setSecondary(settings); tool.setSecondary(settings);
BBC.BRUSH_EQUIPPED.send(player, arguments.get().split(" ")[1]); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.equipped" , arguments.get().split(" ")[1]));
} }
return settings; return settings;
} }
@ -981,9 +984,9 @@ public class BrushCommands {
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
BBC.SCHEMATIC_SAVED.send(player, name); player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.saved" , name));
} else { } else {
player.printError(BBC.BRUSH_NONE.s()); player.printError(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
} }
} }
@ -1004,7 +1007,7 @@ public class BrushCommands {
} }
if (!file.exists()) { if (!file.exists()) {
File[] files = folder.listFiles(pathname -> false); File[] files = folder.listFiles(pathname -> false);
BBC.BRUSH_NOT_FOUND.send(player, name); player.print(TranslatableComponent.of("fawe.error.brush.not.found" , name));
return; return;
} }
try (DataInputStream in = new DataInputStream( try (DataInputStream in = new DataInputStream(
@ -1013,10 +1016,10 @@ public class BrushCommands {
BrushTool tool = BrushTool.fromString(player, session, json); BrushTool tool = BrushTool.fromString(player, session, json);
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(item, tool, player); session.setTool(item, tool, player);
BBC.BRUSH_EQUIPPED.send(player, name); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.equipped" , name));
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
player.printError(BBC.BRUSH_INCOMPATIBLE.s()); player.printError(TranslatableComponent.of("fawe.error.brush.incompatible"));
} }
} }
@ -1147,6 +1150,6 @@ public class BrushCommands {
tool.setFill(null); tool.setFill(null);
tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission); 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())));
} }
} }

View File

@ -40,6 +40,7 @@ import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; 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.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -85,9 +86,9 @@ public class ChunkCommands {
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0); int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
final BlockVector2 chunkPos = BlockVector2.at(chunkX, chunkZ); final BlockVector2 chunkPos = BlockVector2.at(chunkX, chunkZ);
player.print("Chunk: " + chunkX + ", " + chunkZ); player.printInfo(TranslatableComponent.of("worldedit.chunkinfo.chunk", TextComponent.of(chunkX), TextComponent.of(chunkZ)));
player.print("Old format: " + LegacyChunkStore.getFilename(chunkPos)); player.printInfo(TranslatableComponent.of("worldedit.chunkinfo.old-filename", TextComponent.of(LegacyChunkStore.getFilename(chunkPos))));
player.print("McRegion: region/" + McRegionChunkStore.getFilename(chunkPos)); player.printInfo(TranslatableComponent.of("worldedit.chunkinfo.mcregion-filename", TextComponent.of(McRegionChunkStore.getFilename(chunkPos))));
} }
@Command( @Command(
@ -99,7 +100,7 @@ public class ChunkCommands {
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException { @ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
final Region region = session.getSelection(world); 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)); actor.print(new ChunkListPaginationBox(region).create(page));
} }
@ -166,7 +167,7 @@ public class ChunkCommands {
actor.printDebug(String.format("%d chunks total marked for deletion. (May have overlaps).", actor.printDebug(String.format("%d chunks total marked for deletion. (May have overlaps).",
currentInfo.batches.stream().mapToInt(ChunkDeletionInfo.ChunkBatch::getChunkCount).sum())); currentInfo.batches.stream().mapToInt(ChunkDeletionInfo.ChunkBatch::getChunkCount).sum()));
} }
actor.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.LIGHT_PURPLE) actor.print(TextComponent.of("You can mark more chunks for deletion, or to stop now, run: ", TextColor.GRAY)
.append(TextComponent.of("/stop", TextColor.AQUA) .append(TextComponent.of("/stop", TextColor.AQUA)
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop")))); .clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop"))));
} }

View File

@ -24,6 +24,7 @@ import com.google.common.collect.Lists;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
@ -73,7 +74,10 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.World; 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.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
@ -149,10 +153,11 @@ public class ClipboardCommands {
copy.setSourceMask(mask); copy.setSourceMask(mask);
} }
Operations.completeLegacy(copy); Operations.completeLegacy(copy);
BBC.COMMAND_COPY.send(actor, region.getArea());
if (!actor.hasPermission("fawe.tips")) { 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); System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.paste").or(TranslatableComponent.of("fawe.tips.tip.download"), TranslatableComponent.of("fawe.tips.tip.rotate"), TranslatableComponent.of("fawe.tips.tip.copypaste"), TranslatableComponent.of("fawe.tips.tip.replace.marker"), TranslatableComponent.of("fawe.tips.tip.copy.pattern")).send(actor);
} }
copy.getStatusMessages().forEach(actor::print);
} }
@Command( @Command(
@ -173,16 +178,17 @@ public class ClipboardCommands {
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = actor.getLimit(); FaweLimit limit = actor.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); throw new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.checks"));
} }
session.setClipboard(null); session.setClipboard(null);
ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(region, !skipEntities, copyBiomes); ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(region, !skipEntities, copyBiomes);
lazyClipboard.setOrigin(session.getPlacementPosition(actor)); lazyClipboard.setOrigin(session.getPlacementPosition(actor));
session.setClipboard(new ClipboardHolder(lazyClipboard)); session.setClipboard(new ClipboardHolder(lazyClipboard));
BBC.COMMAND_COPY.send(actor, region.getArea()); actor.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy" , region.getArea()));
if (!actor.hasPermission("fawe.tips")) { if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_PASTE.or(BBC.TIP_LAZYCOPY, BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(actor); System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.paste").or(TranslatableComponent.of("fawe.tips.tip.lazycopy"), TranslatableComponent.of("fawe.tips.tip.download"), TranslatableComponent.of("fawe.tips.tip.rotate"), TranslatableComponent.of("fawe.tips.tip.copypaste"), TranslatableComponent.of("fawe.tips.tip.replace.marker"), TranslatableComponent.of("fawe.tips.tip.copy.pattern")).send(actor);
} }
} }
@ -214,7 +220,7 @@ public class ClipboardCommands {
// ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes); // ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
// clipboard.setOrigin(session.getPlacementPosition(actor)); // clipboard.setOrigin(session.getPlacementPosition(actor));
// session.setClipboard(new ClipboardHolder(lazyClipboard)); // session.setClipboard(new ClipboardHolder(lazyClipboard));
// BBC.COMMAND_CUT_LAZY.send(actor, region.getArea()); // actor.print(TranslatableComponent.of("fawe.worldedit.cut.command.cut.lazy" , region.getArea()));
// } // }
@Command( @Command(
@ -269,10 +275,10 @@ public class ClipboardCommands {
Operations.completeLegacy(copy); Operations.completeLegacy(copy);
session.setClipboard(new ClipboardHolder(clipboard)); session.setClipboard(new ClipboardHolder(clipboard));
BBC.COMMAND_CUT_SLOW.send(actor, region.getArea());
if (!actor.hasPermission("fawe.tips")) { if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_LAZYCUT.send(actor); actor.print(TranslatableComponent.of("fawe.tips.tip.lazycut"));
} }
copy.getStatusMessages().forEach(actor::print);
} }
@Command( @Command(
@ -284,11 +290,11 @@ public class ClipboardCommands {
public void download(final Player player, final LocalSession session, @Arg(name = "format", desc = "String", def = "schem") final String formatName) throws WorldEditException { public void download(final Player player, final LocalSession session, @Arg(name = "format", desc = "String", def = "schem") final String formatName) throws WorldEditException {
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName); final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
if (format == null) { if (format == null) {
BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName); player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.invalid.format" , formatName));
return; return;
} }
BBC.GENERATING_LINK.send(player, formatName); player.print(TranslatableComponent.of("fawe.web.generating.link" , formatName));
ClipboardHolder holder = session.getClipboard(); ClipboardHolder holder = session.getClipboard();
URL url; URL url;
@ -357,14 +363,14 @@ public class ClipboardCommands {
} }
} else { } else {
if (Settings.IMP.WEB.URL.isEmpty()) { if (Settings.IMP.WEB.URL.isEmpty()) {
BBC.SETTING_DISABLE.send(player, "web.url"); player.print(TranslatableComponent.of("fawe.error.setting.disable", "web.url"));
return; return;
} }
url = FaweAPI.upload(target, format); url = FaweAPI.upload(target, format);
} }
} }
if (url == null) { if (url == null) {
player.printError(BBC.GENERATING_LINK_FAILED.s()); player.printError(TranslatableComponent.of("fawe.web.generating.link.failed"));
} else { } else {
String urlText = url.toString(); String urlText = url.toString();
if (Settings.IMP.WEB.SHORTEN_URLS) { if (Settings.IMP.WEB.SHORTEN_URLS) {
@ -374,7 +380,7 @@ public class ClipboardCommands {
e.printStackTrace(); e.printStackTrace();
} }
} }
BBC.DOWNLOAD_LINK.send(player, urlText); player.print(TranslatableComponent.of("fawe.web.download.link" , urlText));
} }
} }
@ -398,16 +404,16 @@ public class ClipboardCommands {
} else { } else {
target = clipboard; target = clipboard;
} }
BBC.GENERATING_LINK.send(player, format.getName()); player.print(TranslatableComponent.of("fawe.web.generating.link" , format.getName()));
if (Settings.IMP.WEB.ASSETS.isEmpty()) { if (Settings.IMP.WEB.ASSETS.isEmpty()) {
BBC.SETTING_DISABLE.send(player, "web.assets"); player.print(TranslatableComponent.of("fawe.error.setting.disable", "web.assets"));
return; return;
} }
URL url = format.uploadPublic(target, category.replaceAll("[/|\\\\]", "."), player.getName()); URL url = format.uploadPublic(target, category.replaceAll("[/|\\\\]", "."), player.getName());
if (url == null) { if (url == null) {
player.printError(BBC.GENERATING_LINK_FAILED.s()); player.printError(TranslatableComponent.of("fawe.web.generating.link.failed"));
} else { } else {
BBC.DOWNLOAD_LINK.send(player, Settings.IMP.WEB.ASSETS); player.print(TranslatableComponent.of("fawe.web.download.link" , Settings.IMP.WEB.ASSETS));
} }
} }
@ -443,7 +449,7 @@ public class ClipboardCommands {
} }
Clipboard clipboard = holder.getClipboard(); Clipboard clipboard = holder.getClipboard();
Region region = clipboard.getRegion(); Region region = clipboard.getRegion();
List<String> messages = Lists.newArrayList(); List<Component> messages = Lists.newArrayList();
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(actor); BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(actor);
checkPaste(actor, editSession, to, holder, clipboard); checkPaste(actor, editSession, to, holder, clipboard);
@ -458,6 +464,7 @@ public class ClipboardCommands {
.maskSource(sourceMask) .maskSource(sourceMask)
.build(); .build();
Operations.completeLegacy(operation); Operations.completeLegacy(operation);
messages.addAll(Lists.newArrayList(operation.getStatusMessages()));
} }
if (selectPasted || onlySelect) { if (selectPasted || onlySelect) {
@ -469,9 +476,14 @@ public class ClipboardCommands {
selector.learnChanges(); selector.learnChanges();
selector.explainRegionAdjust(actor, session); selector.explainRegionAdjust(actor, session);
} }
BBC.COMMAND_PASTE.send(actor, to);
if (!actor.hasPermission("fawe.tips")) { if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_COPYPASTE.or(BBC.TIP_SOURCE_MASK, BBC.TIP_REPLACE_MARKER).send(actor, to); System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.copypaste").or(TranslatableComponent.of("fawe.tips.tip.source.mask"), TranslatableComponent.of("fawe.tips.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())));
} }
} }
@ -483,7 +495,7 @@ public class ClipboardCommands {
PasteEvent event = new PasteEvent(player, clipboard, uri, editSession, to); PasteEvent event = new PasteEvent(player, clipboard, uri, editSession, to);
WorldEdit.getInstance().getEventBus().post(event); WorldEdit.getInstance().getEventBus().post(event);
if (event.isCancelled()) { if (event.isCancelled()) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MANUAL); throw new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual"));
} }
} }
@ -519,10 +531,10 @@ public class ClipboardCommands {
selector.learnChanges(); selector.learnChanges();
selector.explainRegionAdjust(actor, session); selector.explainRegionAdjust(actor, session);
} }
BBC.COMMAND_PASTE.send(actor, to); actor.print(TranslatableComponent.of("fawe.worldedit.paste.command.paste" , to));
if (!actor.hasPermission("fawe.tips")) { if (!actor.hasPermission("fawe.tips")) {
actor.print(BBC.TIP_COPYPASTE.s()); actor.print(TranslatableComponent.of("fawe.tips.tip.copypaste"));
} }
} }
@ -548,9 +560,10 @@ public class ClipboardCommands {
transform = transform.rotateX(-xRotate); transform = transform.rotateX(-xRotate);
transform = transform.rotateZ(-zRotate); transform = transform.rotateZ(-zRotate);
holder.setTransform(holder.getTransform().combine(transform)); holder.setTransform(holder.getTransform().combine(transform));
actor.print(BBC.COMMAND_ROTATE.s()); actor.printInfo(TranslatableComponent.of("worldedit.rotate.rotated"));
if (!actor.hasPermission("fawe.tips")) { if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_FLIP.or(BBC.TIP_DEFORM, BBC.TIP_TRANSFORM).send(actor); System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.flip").or(TranslatableComponent.of("fawe.tips.tip.deform"), TranslatableComponent.of("fawe.tips.tip.transform")).send(actor);
} }
} }
@ -567,7 +580,7 @@ public class ClipboardCommands {
AffineTransform transform = new AffineTransform(); AffineTransform transform = new AffineTransform();
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3()); transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
holder.setTransform(holder.getTransform().combine(transform)); holder.setTransform(holder.getTransform().combine(transform));
actor.print("The clipboard copy has been flipped."); actor.printInfo(TranslatableComponent.of("worldedit.flip.flipped"));
} }
@Command( @Command(
@ -577,6 +590,6 @@ public class ClipboardCommands {
@CommandPermissions("worldedit.clipboard.clear") @CommandPermissions("worldedit.clipboard.clear")
public void clearClipboard(Actor actor, LocalSession session) throws WorldEditException { public void clearClipboard(Actor actor, LocalSession session) throws WorldEditException {
session.setClipboard(null); session.setClipboard(null);
actor.print("Clipboard cleared."); actor.printInfo(TranslatableComponent.of("worldedit.clearclipboard.cleared"));
} }
} }

View File

@ -89,7 +89,7 @@ public class ExpandCommands {
private static Command createVertCommand(CommandManager commandManager) { private static Command createVertCommand(CommandManager commandManager) {
return commandManager.newCommand("vert") return commandManager.newCommand("vert")
.description(TextComponent.of("Vertically expand the selection to world limits.")) .description(TranslatableComponent.of("worldedit.expand.description.vert"))
.action(parameters -> { .action(parameters -> {
expandVert( expandVert(
requireIV(Key.of(LocalSession.class), "localSession", parameters), requireIV(Key.of(LocalSession.class), "localSession", parameters),
@ -110,10 +110,12 @@ public class ExpandCommands {
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(player.getWorld()).learnChanges();
int newSize = region.getArea(); int newSize = region.getArea();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session); session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region expanded " + (newSize - oldSize) int changeSize = newSize - oldSize;
+ " blocks [top-to-bottom]."); player.printInfo(
TranslatableComponent.of("worldedit.expand.expanded.vert", TextComponent.of(changeSize))
);
} catch (RegionOperationException e) { } 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); 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)));
} }
} }

View File

@ -19,8 +19,11 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.extent.ResettableExtent; import com.boydti.fawe.object.extent.ResettableExtent;
import com.boydti.fawe.util.CachedTextureUtil; import com.boydti.fawe.util.CachedTextureUtil;
import com.boydti.fawe.util.CleanTextureUtil; import com.boydti.fawe.util.CleanTextureUtil;
@ -48,6 +51,9 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.util.formatting.component.PaginationBox; 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.util.formatting.text.Component;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
@ -63,8 +69,6 @@ import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch; import org.enginehub.piston.annotation.param.Switch;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* General WorldEdit commands. * General WorldEdit commands.
*/ */
@ -98,14 +102,17 @@ public class GeneralCommands {
limit = limit == null ? config.defaultChangeLimit : Math.max(-1, limit); limit = limit == null ? config.defaultChangeLimit : Math.max(-1, limit);
if (!mayDisable && config.maxChangeLimit > -1) { if (!mayDisable && config.maxChangeLimit > -1) {
if (limit > config.maxChangeLimit) { 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; return;
} }
} }
session.setBlockChangeLimit(limit); session.setBlockChangeLimit(limit);
actor.print("Block change limit set to " + limit + "." Component component = TextComponent.empty().append(TranslatableComponent.of("worldedit.limit.set", TextComponent.of(limit)));
+ (limit == config.defaultChangeLimit ? "" : " (Use //limit to go back to the default.)")); if (limit != config.defaultChangeLimit) {
component.append(TextComponent.space()).append(TranslatableComponent.of("worldedit.limit.return-to-default", TextColor.GRAY));
}
actor.printInfo(component);
} }
@Command( @Command(
@ -122,14 +129,17 @@ public class GeneralCommands {
limit = limit == null ? config.calculationTimeout : Math.max(-1, limit); limit = limit == null ? config.calculationTimeout : Math.max(-1, limit);
if (!mayDisable && config.maxCalculationTimeout > -1) { if (!mayDisable && config.maxCalculationTimeout > -1) {
if (limit > config.maxCalculationTimeout) { 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; return;
} }
} }
session.setTimeout(limit); session.setTimeout(limit);
actor.print("Timeout time set to " + limit + " ms." Component component = TextComponent.empty().append(TranslatableComponent.of("worldedit.timeout.set", TextComponent.of(limit)));
+ (limit == config.calculationTimeout ? "" : " (Use //timeout to go back to the default.)")); if (limit != config.calculationTimeout) {
component.append(TranslatableComponent.of("worldedit.timeout.return-to-default", TextColor.GRAY));
}
actor.printInfo(component);
} }
@Command( @Command(
@ -142,16 +152,16 @@ public class GeneralCommands {
Boolean fastMode) { Boolean fastMode) {
boolean hasFastMode = session.hasFastMode(); boolean hasFastMode = session.hasFastMode();
if (fastMode != null && fastMode == 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; return;
} }
if (hasFastMode) { if (hasFastMode) {
session.setFastMode(false); session.setFastMode(false);
actor.print("Fast mode disabled."); actor.printInfo(TranslatableComponent.of("worldedit.fast.disabled"));
} else { } else {
session.setFastMode(true); 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 +174,10 @@ public class GeneralCommands {
@Arg(desc = "The reorder mode", def = "") @Arg(desc = "The reorder mode", def = "")
EditSession.ReorderMode reorderMode) { EditSession.ReorderMode reorderMode) {
if (reorderMode == null) { 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 { } else {
session.setReorderMode(reorderMode); 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 +194,18 @@ public class GeneralCommands {
} }
boolean useServerCui = session.shouldUseServerCUI(); boolean useServerCui = session.shouldUseServerCUI();
if (drawSelection != null && drawSelection == useServerCui) { if (drawSelection != null && drawSelection == useServerCui) {
player.printError("Server CUI already " + (useServerCui ? "enabled" : "disabled") + "."); player.printError(TranslatableComponent.of("worldedit.drawsel." + (useServerCui ? "enabled" : "disabled") + ".already"));
return; return;
} }
if (useServerCui) { if (useServerCui) {
session.setUseServerCUI(false); session.setUseServerCUI(false);
session.updateServerCUI(player); session.updateServerCUI(player);
player.print("Server CUI disabled."); player.printInfo(TranslatableComponent.of("worldedit.drawsel.disabled"));
} else { } else {
session.setUseServerCUI(true); session.setUseServerCUI(true);
session.updateServerCUI(player); session.updateServerCUI(player);
player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32."); player.printInfo(TranslatableComponent.of("worldedit.drawsel.enabled"));
} }
} }
@ -207,9 +218,9 @@ public class GeneralCommands {
@Arg(desc = "The world override", def = "") World world) { @Arg(desc = "The world override", def = "") World world) {
session.setWorldOverride(world); session.setWorldOverride(world);
if (world == null) { if (world == null) {
actor.print("Removed world override."); actor.printInfo(TranslatableComponent.of("worldedit.world.remove"));
} else { } 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 +235,16 @@ public class GeneralCommands {
@Arg(desc = "The mode to set the watchdog hook to", def = "") @Arg(desc = "The mode to set the watchdog hook to", def = "")
HookMode hookMode) { HookMode hookMode) {
if (WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getWatchdog() == null) { 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; return;
} }
boolean previousMode = session.isTickingWatchdog(); boolean previousMode = session.isTickingWatchdog();
if (hookMode != null && (hookMode == HookMode.ACTIVE) == previousMode) { 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; return;
} }
session.setTickingWatchdog(!previousMode); session.setTickingWatchdog(!previousMode);
actor.print("Watchdog hook now " + (previousMode ? "inactive" : "active") + "."); actor.printInfo(TranslatableComponent.of(previousMode ? "worldedit.watchdog.inactive" : "worldedit.watchdog.active"));
} }
@Command( @Command(
@ -247,10 +258,10 @@ public class GeneralCommands {
Mask mask) { Mask mask) {
if (mask == null) { if (mask == null) {
session.setMask(null); session.setMask(null);
actor.print("Global mask disabled."); actor.printInfo(TranslatableComponent.of("worldedit.gmask.disabled"));
} else { } else {
session.setMask(mask); session.setMask(mask);
actor.print("Global mask set."); actor.printInfo(TranslatableComponent.of("worldedit.gmask.set"));
} }
} }
@ -261,9 +272,9 @@ public class GeneralCommands {
) )
public void togglePlace(Player player, LocalSession session) { public void togglePlace(Player player, LocalSession session) {
if (session.togglePlacementPosition()) { if (session.togglePlacementPosition()) {
player.print(BBC.PLACE_ENABLED.s()); player.printInfo(TranslatableComponent.of("worldedit.toggleplace.pos1"));
} else { } else {
player.print(BBC.PLACE_DISABLED.s()); player.printInfo(TranslatableComponent.of("worldedit.toggleplace.player"));
} }
} }
@ -284,11 +295,11 @@ public class GeneralCommands {
List<String> query) throws Exception { List<String> query) throws Exception {
String search = String.join(" ", query); String search = String.join(" ", query);
if (search.length() <= 2) { if (search.length() <= 2) {
actor.printError("Enter a longer search string (len > 2)."); actor.printError(TranslatableComponent.of("worldedit.searchitem.too-short"));
return; return;
} }
if (blocksOnly && itemsOnly) { 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; return;
} }
@ -347,7 +358,7 @@ public class GeneralCommands {
// TODO NOT IMPLEMENTED convert this to an ArgumentConverter // TODO NOT IMPLEMENTED convert this to an ArgumentConverter
if (arguments.isEmpty()) { if (arguments.isEmpty()) {
session.setTextureUtil(null); session.setTextureUtil(null);
player.print(BBC.TEXTURE_DISABLED.s()); player.print(TranslatableComponent.of("fawe.worldedit.general.texture.disabled"));
} else { } else {
String arg = arguments.get(0); String arg = arguments.get(0);
String argLower = arg.toLowerCase(Locale.ROOT); String argLower = arg.toLowerCase(Locale.ROOT);
@ -390,7 +401,7 @@ public class GeneralCommands {
} }
if (!(util instanceof CachedTextureUtil)) util = new CachedTextureUtil(util); if (!(util instanceof CachedTextureUtil)) util = new CachedTextureUtil(util);
session.setTextureUtil(util); session.setTextureUtil(util);
BBC.TEXTURE_SET.send(player, StringMan.join(arguments, " ")); player.print(TranslatableComponent.of("fawe.worldedit.general.texture.set" , StringMan.join(arguments, " ")));
} }
} }
@ -404,9 +415,9 @@ public class GeneralCommands {
public void gsmask(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The mask to set", def = "") Mask maskOpt) throws WorldEditException { public void gsmask(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The mask to set", def = "") Mask maskOpt) throws WorldEditException {
session.setSourceMask(maskOpt); session.setSourceMask(maskOpt);
if (maskOpt == null) { if (maskOpt == null) {
player.print(BBC.SOURCE_MASK_DISABLED.s()); player.print(TranslatableComponent.of("fawe.worldedit.general.source.mask.disabled"));
} else { } else {
player.print(BBC.SOURCE_MASK.s()); player.print(TranslatableComponent.of("fawe.worldedit.general.source.mask"));
} }
} }
@ -420,9 +431,9 @@ public class GeneralCommands {
public void gtransform(Player player, EditSession editSession, LocalSession session, ResettableExtent transform) throws WorldEditException { public void gtransform(Player player, EditSession editSession, LocalSession session, ResettableExtent transform) throws WorldEditException {
session.setTransform(transform); session.setTransform(transform);
if (transform == null) { if (transform == null) {
player.print(BBC.TRANSFORM_DISABLED.s()); player.print(TranslatableComponent.of("fawe.worldedit.general.transform.disabled"));
} else { } else {
player.print(BBC.TRANSFORM.s()); player.print(TranslatableComponent.of("fawe.worldedit.general.transform"));
} }
} }
@ -434,9 +445,9 @@ public class GeneralCommands {
@CommandPermissions("fawe.tips") @CommandPermissions("fawe.tips")
public void tips(Player player, LocalSession session) throws WorldEditException { public void tips(Player player, LocalSession session) throws WorldEditException {
if (player.togglePermission("fawe.tips")) { if (player.togglePermission("fawe.tips")) {
player.print(BBC.WORLDEDIT_TOGGLE_TIPS_ON.s()); player.print(TranslatableComponent.of("fawe.info.worldedit.toggle.tips.on"));
} else { } else {
player.print(BBC.WORLDEDIT_TOGGLE_TIPS_OFF.s()); player.print(TranslatableComponent.of("fawe.info.worldedit.toggle.tips.off"));
} }
} }
} }

View File

@ -26,6 +26,7 @@ import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgum
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
@ -53,10 +54,12 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
@ -108,7 +111,7 @@ public class GenerationCommands {
@Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt) throws WorldEditException { @Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt) throws WorldEditException {
CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt); CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt);
editSession.generate(region, gen); editSession.generate(region, gen);
BBC.VISITOR_BLOCK.send(actor, editSession.getBlockChangeCount()); actor.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
} }
@ -121,7 +124,7 @@ public class GenerationCommands {
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException { public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException {
editSession.addOres(region, mask); editSession.addOres(region, mask);
BBC.VISITOR_BLOCK.send(actor, editSession.getBlockChangeCount()); actor.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
} }
@Command( @Command(
@ -162,7 +165,7 @@ public class GenerationCommands {
return false; return false;
}); });
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
BBC.VISITOR_BLOCK.send(actor, editSession.getBlockChangeCount()); actor.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
} }
@Command( @Command(
@ -174,7 +177,7 @@ public class GenerationCommands {
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public void ore(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern") Pattern material, @Arg(desc="Ore vein size") @Range(from = 0, to=Integer.MAX_VALUE) int size, int freq, @Range(from=0, to=100) int rarity, @Range(from=0, to=255) int minY, @Range(from=0, to=255) int maxY) throws WorldEditException { public void ore(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern") Pattern material, @Arg(desc="Ore vein size") @Range(from = 0, to=Integer.MAX_VALUE) int size, int freq, @Range(from=0, to=100) int rarity, @Range(from=0, to=255) int minY, @Range(from=0, to=255) int maxY) throws WorldEditException {
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY); editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
BBC.VISITOR_BLOCK.send(actor, editSession.getBlockChangeCount()); actor.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
} }
@Command( @Command(
@ -211,7 +214,7 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(max); worldEdit.checkMaxRadius(max);
BlockVector3 pos = session.getPlacementPosition(actor); BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow); 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( @Command(
@ -252,7 +255,7 @@ public class GenerationCommands {
if (actor instanceof Player) { if (actor instanceof Player) {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
BBC.VISITOR_BLOCK.send(actor, affected); actor.printInfo(TranslatableComponent.of("worldedit.sphere.created", TextComponent.of(affected)));
} }
@Command( @Command(
@ -272,7 +275,7 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(size); worldEdit.checkMaxRadius(size);
density /= 100; density /= 100;
int affected = editSession.makeForest(session.getPlacementPosition(actor), size, density, type); 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; return affected;
} }
@ -290,7 +293,7 @@ public class GenerationCommands {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100"); checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
worldEdit.checkMaxRadius(size); worldEdit.checkMaxRadius(size);
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), size, density); 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; return affected;
} }
@ -327,7 +330,7 @@ public class GenerationCommands {
if (actor instanceof Player) { if (actor instanceof Player) {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
BBC.VISITOR_BLOCK.send(actor, affected); actor.printInfo(TranslatableComponent.of("worldedit.pyramid.created", TextComponent.of(affected)));
} }
@Command( @Command(
@ -388,9 +391,9 @@ public class GenerationCommands {
if (actor instanceof Player) { if (actor instanceof Player) {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
BBC.VISITOR_BLOCK.send(actor, affected); actor.printInfo(TranslatableComponent.of("worldedit.generate.created", TextComponent.of(affected)));
} catch (ExpressionException e) { } catch (ExpressionException e) {
actor.printError(e.getMessage()); actor.printError(TextComponent.of(e.getMessage()));
} }
} }
@ -449,9 +452,9 @@ public class GenerationCommands {
final Vector3 unit1 = unit; final Vector3 unit1 = unit;
try { try {
final int affected = editSession.makeBiomeShape(region, zero, unit1, target, String.join(" ", expression), hollow, session.getTimeout()); 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) { } catch (ExpressionException e) {
actor.printError(e.getMessage()); actor.printError(TextComponent.of(e.getMessage()));
} }
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.database.DBHandler; import com.boydti.fawe.database.DBHandler;
import com.boydti.fawe.database.RollbackDatabase; import com.boydti.fawe.database.RollbackDatabase;
@ -41,6 +42,7 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.command.util.annotation.Confirm;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; 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.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
@ -49,6 +51,7 @@ import java.io.File;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger; 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.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
@ -86,13 +89,13 @@ public class HistoryCommands {
@CommandPermissions("worldedit.history.rollback") @CommandPermissions("worldedit.history.rollback")
public void faweRollback(Player player, LocalSession session, @Arg(desc = "String user") String user, @Arg(def = "0", desc = "radius") @Range(from = 0, to=Integer.MAX_VALUE) int radius, @Arg(name = "time", desc = "String", def = "0") String time, @Switch(name = 'r', desc = "TODO") boolean restore) throws WorldEditException { public void faweRollback(Player player, LocalSession session, @Arg(desc = "String user") String user, @Arg(def = "0", desc = "radius") @Range(from = 0, to=Integer.MAX_VALUE) int radius, @Arg(name = "time", desc = "String", def = "0") String time, @Switch(name = 'r', desc = "TODO") boolean restore) throws WorldEditException {
if (!Settings.IMP.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )"); player.print(TranslatableComponent.of("fawe.error.setting.disable" , "history.use-database (Import with /frb #import )"));
return; return;
} }
if (user.charAt(0) == '#') { if (user.charAt(0) == '#') {
if (user.equals("#import")) { if (user.equals("#import")) {
if (!player.hasPermission("fawe.rollback.import")) { if (!player.hasPermission("fawe.rollback.import")) {
BBC.NO_PERM.send(player, "fawe.rollback.import"); player.print(TranslatableComponent.of("fawe.error.no.perm", "fawe.rollback.import"));
return; return;
} }
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY); File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY);
@ -145,7 +148,7 @@ public class HistoryCommands {
} }
String toParse = user.substring(1); String toParse = user.substring(1);
if (!MathMan.isInteger(toParse)) { if (!MathMan.isInteger(toParse)) {
BBC.COMMAND_SYNTAX.send(player, "/frb #<index>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb #<index>"));
return; return;
} }
int index = Integer.parseInt(toParse); int index = Integer.parseInt(toParse);
@ -155,24 +158,24 @@ public class HistoryCommands {
if (file.getBDFile().exists()) { if (file.getBDFile().exists()) {
if (restore) file.redo(player); if (restore) file.redo(player);
else file.undo(player); else file.undo(player);
BBC.ROLLBACK_ELEMENT.send(player, world.getName() + "/" + user + "-" + index); player.print(TranslatableComponent.of("fawe.worldedit.rollback.rollback.element" , world.getName() + "/" + user + "-" + index));
} else { } else {
BBC.TOOL_INSPECT_INFO_FOOTER.send(player, 0); player.print(TranslatableComponent.of("fawe.worldedit.tool.tool.inspect.info.footer" , 0));
} }
return; return;
} }
UUID other = Fawe.imp().getUUID(user); UUID other = Fawe.imp().getUUID(user);
if (other == null) { if (other == null) {
BBC.PLAYER_NOT_FOUND.send(player, user); player.print(TranslatableComponent.of("fawe.error.player.not.found" , user));
return; return;
} }
if (radius == 0) { if (radius == 0) {
BBC.COMMAND_SYNTAX.send(player, "/frb " + user + " <radius> <time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb " + user + " <radius> <time>"));
return; return;
} }
long timeDiff = MainUtil.timeToSec(time) * 1000; long timeDiff = MainUtil.timeToSec(time) * 1000;
if (timeDiff == 0) { if (timeDiff == 0) {
BBC.COMMAND_SYNTAX.send(player, "/frb " + user + " " + radius + " <time>"); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/frb " + user + " " + radius + " <time>"));
return; return;
} }
radius = Math.max(Math.min(500, radius), 0); radius = Math.max(Math.min(500, radius), 0);
@ -187,7 +190,7 @@ public class HistoryCommands {
Region[] allowedRegions = player.getCurrentRegions(FaweMaskManager.MaskType.OWNER); Region[] allowedRegions = player.getCurrentRegions(FaweMaskManager.MaskType.OWNER);
if (allowedRegions == null) { if (allowedRegions == null) {
player.printError(BBC.NO_REGION.s()); player.printError(TranslatableComponent.of("fawe.error.no.region"));
return; return;
} }
// TODO mask the regions bot / top to the bottom and top coord in the allowedRegions // TODO mask the regions bot / top to the bottom and top coord in the allowedRegions
@ -201,10 +204,10 @@ public class HistoryCommands {
@Override @Override
public void run(DiskStorageHistory edit) { public void run(DiskStorageHistory edit) {
edit.undo(player, allowedRegions); edit.undo(player, allowedRegions);
BBC.ROLLBACK_ELEMENT.send(player, edit.getWorld().getName() + "/" + user + "-" + edit.getIndex()); player.print(TranslatableComponent.of("fawe.worldedit.rollback.rollback.element" , edit.getWorld().getName() + "/" + user + "-" + edit.getIndex()));
count.incrementAndGet(); count.incrementAndGet();
} }
}, () -> BBC.TOOL_INSPECT_INFO_FOOTER.send(player, count), true, restore); }, () -> player.print(TranslatableComponent.of("fawe.worldedit.tool.tool.inspect.info.footer" , count)), true, restore);
} }
@Command( @Command(
@ -233,14 +236,14 @@ public class HistoryCommands {
times = Math.max(1, times); times = Math.max(1, times);
LocalSession undoSession = session; LocalSession undoSession = session;
if (session.hasFastMode()) { if (session.hasFastMode()) {
player.print(BBC.COMMAND_UNDO_DISABLED.s()); player.print(TranslatableComponent.of("fawe.worldedit.history.command.undo.disabled"));
return; return;
} }
if (playerName != null) { if (playerName != null) {
player.checkPermission("worldedit.history.undo.other"); player.checkPermission("worldedit.history.undo.other");
undoSession = worldEdit.getSessionManager().findByName(playerName); undoSession = worldEdit.getSessionManager().findByName(playerName);
if (undoSession == null) { if (undoSession == null) {
player.printError("Unable to find session for " + playerName); player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
return; return;
} }
} }
@ -255,9 +258,9 @@ public class HistoryCommands {
} }
} }
if (timesUndone > 0) { if (timesUndone > 0) {
player.print("Undid " + timesUndone + " available edits."); player.printInfo(TranslatableComponent.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
} else { } else {
player.printError("Nothing left to undo."); player.printError(TranslatableComponent.of("worldedit.undo.none"));
} }
} }
@ -278,7 +281,7 @@ public class HistoryCommands {
player.checkPermission("worldedit.history.redo.other"); player.checkPermission("worldedit.history.redo.other");
redoSession = worldEdit.getSessionManager().findByName(playerName); redoSession = worldEdit.getSessionManager().findByName(playerName);
if (redoSession == null) { if (redoSession == null) {
BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, playerName); player.printError(TranslatableComponent.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
return; return;
} }
} }
@ -293,9 +296,9 @@ public class HistoryCommands {
} }
} }
if (timesRedone > 0) { if (timesRedone > 0) {
BBC.COMMAND_REDO_SUCCESS.send(player, timesRedone == 1 ? "" : " x" + timesRedone); player.printInfo(TranslatableComponent.of("worldedit.redo.redid", TextComponent.of(timesRedone)));
} else { } else {
player.printError(BBC.COMMAND_REDO_ERROR.s()); player.printError(TranslatableComponent.of("worldedit.redo.none"));
} }
} }
@ -307,7 +310,7 @@ public class HistoryCommands {
@CommandPermissions("worldedit.history.clear") @CommandPermissions("worldedit.history.clear")
public void clearHistory(Actor actor, LocalSession session) { public void clearHistory(Actor actor, LocalSession session) {
session.clearHistory(); session.clearHistory();
actor.print("History cleared."); actor.printInfo(TranslatableComponent.of("worldedit.clearhistory.cleared"));
} }
} }

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -29,6 +30,8 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.util.Location; 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.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
@ -62,7 +65,7 @@ public class NavigationCommands {
@CommandPermissions("worldedit.navigation.unstuck") @CommandPermissions("worldedit.navigation.unstuck")
public void unstuck(Player player) throws WorldEditException { public void unstuck(Player player) throws WorldEditException {
player.findFreePosition(); player.findFreePosition();
player.print("There you go!"); player.printInfo(TranslatableComponent.of("worldedit.unstuck.moved"));
} }
@Command( @Command(
@ -82,9 +85,9 @@ public class NavigationCommands {
} }
} }
if (ascentLevels == 0) { if (ascentLevels == 0) {
player.printError(BBC.ASCEND_FAIL.s()); player.printError(TranslatableComponent.of("worldedit.ascend.obstructed"));
} else { } else {
player.print((ascentLevels != 1) ? "Ascended " + ascentLevels + " levels." : "Ascended a level."); player.printInfo(TranslatableComponent.of("worldedit.ascend.moved", TextComponent.of(ascentLevels)));
} }
} }
@ -105,11 +108,9 @@ public class NavigationCommands {
} }
} }
if (descentLevels == 0) { if (descentLevels == 0) {
player.printError(BBC.DESCEND_FAIL.s()); player.printError(TranslatableComponent.of("worldedit.descend.obstructed"));
} else if (descentLevels == 1) {
player.print(BBC.DESCEND_SINGULAR.s());
} else { } else {
player.print((descentLevels != 1) ? "Descended " + descentLevels + " levels." : "Descended a level."); player.printInfo(TranslatableComponent.of("worldedit.descend.moved", TextComponent.of(descentLevels)));
} }
} }
@ -130,9 +131,9 @@ public class NavigationCommands {
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass); boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
if (player.ascendToCeiling(clearance, alwaysGlass)) { if (player.ascendToCeiling(clearance, alwaysGlass)) {
player.print(BBC.WHOOSH.s()); player.printInfo(TranslatableComponent.of("worldedit.ceil.moved"));
} else { } else {
player.printError(BBC.ASCEND_FAIL.s()); player.printError(TranslatableComponent.of("worldedit.ceil.obstructed"));
} }
} }
@ -143,9 +144,9 @@ public class NavigationCommands {
@CommandPermissions("worldedit.navigation.thru.command") @CommandPermissions("worldedit.navigation.thru.command")
public void thru(Player player) throws WorldEditException { public void thru(Player player) throws WorldEditException {
if (player.passThroughForwardWall(6)) { if (player.passThroughForwardWall(6)) {
player.print(BBC.WHOOSH.s()); player.printInfo(TranslatableComponent.of("worldedit.thru.moved"));
} else { } else {
player.printError(BBC.THRU_FAIL.s()); player.printError(TranslatableComponent.of("worldedit.thru.obstructed"));
} }
} }
@ -165,14 +166,10 @@ public class NavigationCommands {
pos = player.getSolidBlockTrace(300); pos = player.getSolidBlockTrace(300);
} }
if (pos != null) { if (pos != null) {
if (force) {
player.setPosition(pos);
} else {
player.findFreePosition(pos); player.findFreePosition(pos);
} player.printInfo(TranslatableComponent.of("worldedit.jumpto.moved"));
player.print(BBC.POOF.s());
} else { } else {
player.printError(BBC.NO_BLOCK.s()); player.printError(TranslatableComponent.of("worldedit.jumpto.none"));
} }
} }
@ -191,9 +188,9 @@ public class NavigationCommands {
boolean forceGlass) throws WorldEditException { boolean forceGlass) throws WorldEditException {
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass); boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
if (player.ascendUpwards(distance, alwaysGlass)) { if (player.ascendUpwards(distance, alwaysGlass)) {
player.print(BBC.WHOOSH.s()); player.printInfo(TranslatableComponent.of("worldedit.up.moved"));
} else { } else {
player.printError(BBC.UP_FAIL.s()); player.printError(TranslatableComponent.of("worldedit.up.obstructed"));
} }
} }

View File

@ -62,24 +62,24 @@ import static org.enginehub.piston.part.CommandParts.arg;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class PaintBrushCommands { 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()) .defaultsTo(ImmutableList.of())
.ofTypes(ImmutableList.of(Key.of(RegionFactory.class))) .ofTypes(ImmutableList.of(Key.of(RegionFactory.class)))
.build(); .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")) .defaultsTo(ImmutableList.of("5"))
.ofTypes(ImmutableList.of(Key.of(double.class))) .ofTypes(ImmutableList.of(Key.of(double.class)))
.build(); .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")) .defaultsTo(ImmutableList.of("20"))
.ofTypes(ImmutableList.of(Key.of(double.class))) .ofTypes(ImmutableList.of(Key.of(double.class)))
.build(); .build();
public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) { public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) {
commandManager.register("paint", builder -> { 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); builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
CommandManager manager = service.newCommandManager(); CommandManager manager = service.newCommandManager();
@ -92,7 +92,7 @@ public class PaintBrushCommands {
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.paint"))); builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.paint")));
builder.addParts(REGION_FACTORY, RADIUS, DENSITY); 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())) .withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required() .required()
.build()); .build());
@ -132,8 +132,7 @@ public class PaintBrushCommands {
@Direction(includeDiagonals = true) @Direction(includeDiagonals = true)
com.sk89q.worldedit.util.Direction direction) throws WorldEditException { com.sk89q.worldedit.util.Direction direction) throws WorldEditException {
player.print(TextComponent.builder().append("WARNING: ", TextColor.RED, TextDecoration.BOLD) 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," + .append(TranslatableComponent.of("worldedit.brush.paint.item.warning")).build());
" and may cause strange interactions with other mods/plugins. Use at your own risk.").build());
setPaintBrush(parameters, player, localSession, new ItemUseFactory(item, direction)); setPaintBrush(parameters, player, localSession, new ItemUseFactory(item, direction));
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
@ -62,11 +63,16 @@ import com.sk89q.worldedit.regions.Regions;
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import 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 com.sk89q.worldedit.world.block.BlockTypes;
import org.enginehub.piston.annotation.Command; 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.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.ArgFlag;
@ -113,9 +119,10 @@ public class RegionCommands {
Pattern pattern) { Pattern pattern) {
int affected = editSession.setBlocks(region, pattern); int affected = editSession.setBlocks(region, pattern);
if (affected != 0) { if (affected != 0) {
BBC.OPERATION.send(actor, affected); actor.printInfo(TranslatableComponent.of("worldedit.set.done"));
if (!actor.hasPermission("fawe.tips")) 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); System.out.println("TODO FIXME TIPS");
// TranslatableComponent.of("fawe.tips.tip.fast").or(TranslatableComponent.of("fawe.tips.tip.cancel"), TranslatableComponent.of("fawe.tips.tip.mask"), TranslatableComponent.of("fawe.tips.tip.mask.angle"), TranslatableComponent.of("fawe.tips.tip.set.linear"), TranslatableComponent.of("fawe.tips.tip.surface.spread"), TranslatableComponent.of("fawe.tips.tip.set.hand")).send(actor);
} }
return 0; return 0;
} }
@ -138,7 +145,6 @@ public class RegionCommands {
@CommandPermissions("worldedit.region.test") @CommandPermissions("worldedit.region.test")
@Logging(REGION) @Logging(REGION)
public void test(Player player, EditSession editSession, @Arg(desc = "test") @Confirm(RADIUS) BlockVector3 radius) throws WorldEditException { public void test(Player player, EditSession editSession, @Arg(desc = "test") @Confirm(RADIUS) BlockVector3 radius) throws WorldEditException {
player.print("Run test " + radius);
// editSession.addProcessor(new ChunkSendProcessor(editSession.getWorld(), () -> Collections.singleton(player))); // editSession.addProcessor(new ChunkSendProcessor(editSession.getWorld(), () -> Collections.singleton(player)));
// editSession.addProcessor(NullProcessor.INSTANCE); // editSession.addProcessor(NullProcessor.INSTANCE);
// FlatRegionFunction replace = new BiomeReplace(editSession, biome); // FlatRegionFunction replace = new BiomeReplace(editSession, biome);
@ -160,7 +166,7 @@ public class RegionCommands {
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
} }
int count = FaweAPI.fixLighting(player.getWorld(), selection,null); int count = FaweAPI.fixLighting(player.getWorld(), selection,null);
BBC.LIGHTING_PROPAGATE_SELECTION.send(player, count); player.print(TranslatableComponent.of("fawe.info.lighting.propagate.selection" , count));
} }
@Command( @Command(
@ -188,7 +194,7 @@ public class RegionCommands {
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
} }
int count = FaweAPI.fixLighting(player.getWorld(), selection, null); int count = FaweAPI.fixLighting(player.getWorld(), selection, null);
BBC.UPDATED_LIGHTING_SELECTION.send(player, count); player.print(TranslatableComponent.of("fawe.info.updated.lighting.selection" , count));
} }
@Command( @Command(
@ -200,14 +206,14 @@ public class RegionCommands {
public void nbtinfo(Player player, EditSession editSession) { public void nbtinfo(Player player, EditSession editSession) {
Location pos = player.getBlockTrace(128); Location pos = player.getBlockTrace(128);
if (pos == null) { if (pos == null) {
player.printError(BBC.NO_BLOCK.s()); player.printError(TranslatableComponent.of("fawe.navigation.no.block"));
return; return;
} }
CompoundTag nbt = editSession.getFullBlock(pos.toBlockPoint()).getNbtData(); CompoundTag nbt = editSession.getFullBlock(pos.toBlockPoint()).getNbtData();
if (nbt != null) { if (nbt != null) {
player.print(nbt.getValue().toString()); player.print(nbt.getValue().toString());
} else { } else {
player.printError(BBC.NO_BLOCK.s()); player.printError(TranslatableComponent.of("fawe.navigation.no.block"));
} }
} }
@ -245,7 +251,7 @@ public class RegionCommands {
@Switch(name = 'h', desc = "Generate only a shell") @Switch(name = 'h', desc = "Generate only a shell")
boolean shell) throws WorldEditException { boolean shell) throws WorldEditException {
if (!(region instanceof CuboidRegion)) { if (!(region instanceof CuboidRegion)) {
actor.printError("//line only works with cuboid selections"); actor.printError(TranslatableComponent.of("worldedit.line.cuboid-only"));
return 0; return 0;
} }
checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
@ -255,7 +261,7 @@ public class RegionCommands {
BlockVector3 pos2 = cuboidregion.getPos2(); BlockVector3 pos2 = cuboidregion.getPos2();
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell); int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
actor.print(blocksChanged + " block(s) have been changed."); actor.printInfo(TranslatableComponent.of("worldedit.line.changed", TextComponent.of(blocksChanged)));
return blocksChanged; return blocksChanged;
} }
@ -276,7 +282,7 @@ public class RegionCommands {
@Switch(name = 'h', desc = "Generate only a shell") @Switch(name = 'h', desc = "Generate only a shell")
boolean shell) throws WorldEditException { boolean shell) throws WorldEditException {
if (!(region instanceof ConvexPolyhedralRegion)) { if (!(region instanceof ConvexPolyhedralRegion)) {
actor.printError("//curve only works with convex polyhedral selections"); actor.printError(TranslatableComponent.of("worldedit.curve.convex-only"));
return; return;
} }
checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
@ -286,7 +292,7 @@ public class RegionCommands {
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell); 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( @Command(
@ -305,9 +311,8 @@ public class RegionCommands {
if (from == null) { if (from == null) {
from = new ExistingBlockMask(editSession); from = new ExistingBlockMask(editSession);
} }
Mask finalFrom = from; int affected = editSession.replaceBlocks(region, from, to);
int affected = editSession.replaceBlocks(region, finalFrom, to); actor.printInfo(TranslatableComponent.of("worldedit.replace.replaced", TextComponent.of(affected)));
actor.print(affected + " block(s) have been replaced.");
} }
@Command( @Command(
@ -321,7 +326,7 @@ public class RegionCommands {
@Arg(desc = "The pattern of blocks to overlay") @Arg(desc = "The pattern of blocks to overlay")
Pattern pattern) throws WorldEditException { Pattern pattern) throws WorldEditException {
int affected = editSession.overlayCuboidBlocks(region, pattern); 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( @Command(
@ -346,7 +351,7 @@ public class RegionCommands {
editSession.setBlock(x, y, z, patternArg); editSession.setBlock(x, y, z, patternArg);
affected++; affected++;
} }
BBC.VISITOR_BLOCK.send(player, affected); player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , affected));
} }
@Command( @Command(
@ -360,7 +365,7 @@ public class RegionCommands {
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern pattern) throws WorldEditException { Pattern pattern) throws WorldEditException {
int affected = editSession.center(region, pattern); int affected = editSession.center(region, pattern);
actor.print("Center set (" + affected + " block(s) changed)"); actor.printInfo(TranslatableComponent.of("worldedit.center.changed", TextComponent.of(affected)));
return affected; return affected;
} }
@ -373,7 +378,7 @@ public class RegionCommands {
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public void naturalize(Actor actor, EditSession editSession, @Selection Region region) throws WorldEditException { public void naturalize(Actor actor, EditSession editSession, @Selection Region region) throws WorldEditException {
int affected = editSession.naturalizeCuboidBlocks(region); 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( @Command(
@ -387,7 +392,7 @@ public class RegionCommands {
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern pattern) throws WorldEditException { Pattern pattern) throws WorldEditException {
int affected = editSession.makeWalls(region, pattern); 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( @Command(
@ -402,7 +407,7 @@ public class RegionCommands {
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern pattern) throws WorldEditException { Pattern pattern) throws WorldEditException {
int affected = editSession.makeCuboidFaces(region, pattern); 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( @Command(
@ -430,7 +435,7 @@ public class RegionCommands {
HeightMap heightMap = new HeightMap(editSession, region, mask, snow); HeightMap heightMap = new HeightMap(editSession, region, mask, snow);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations); int affected = heightMap.applyFilter(filter, iterations);
actor.print("Terrain's height map smoothed. " + affected + " block(s) changed."); actor.printInfo(TranslatableComponent.of("worldedit.smooth.changed", TextComponent.of(affected)));
} catch (Throwable e) { } catch (Throwable e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -445,9 +450,9 @@ public class RegionCommands {
@CommandPermissions("fawe.admin") @CommandPermissions("fawe.admin")
public void wea(Actor actor) throws WorldEditException { public void wea(Actor actor) throws WorldEditException {
if (actor.togglePermission("fawe.bypass")) { if (actor.togglePermission("fawe.bypass")) {
actor.print(BBC.WORLDEDIT_BYPASSED.s()); actor.print(TranslatableComponent.of("fawe.info.worldedit.bypassed"));
} else { } else {
actor.print(BBC.WORLDEDIT_RESTRICTED.s()); actor.print(TranslatableComponent.of("fawe.info.worldedit.restricted"));
} }
} }
@ -461,10 +466,10 @@ public class RegionCommands {
public void wer(Player player) throws WorldEditException { public void wer(Player player) throws WorldEditException {
final Region region = player.getLargestRegion(); final Region region = player.getLargestRegion();
if (region == null) { if (region == null) {
player.print(BBC.NO_REGION.s()); player.print(TranslatableComponent.of("fawe.error.no.region"));
} else { } else {
player.setSelection(region); player.setSelection(region);
player.print(BBC.SET_REGION.s()); player.print(TranslatableComponent.of("fawe.info.set.region"));
} }
} }
@ -477,7 +482,7 @@ public class RegionCommands {
@CommandPermissions("worldedit.region.move") @CommandPermissions("worldedit.region.move")
@Logging(ORIENTATION_REGION) @Logging(ORIENTATION_REGION)
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public void move(Actor actor, World world, EditSession editSession, LocalSession session, public int move(Actor actor, World world, EditSession editSession, LocalSession session,
@Selection Region region, @Selection Region region,
@Arg(desc = "# of blocks to move", def = "1") @Arg(desc = "# of blocks to move", def = "1")
int count, int count,
@ -518,11 +523,12 @@ public class RegionCommands {
session.getRegionSelector(world).learnChanges(); session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
} catch (RegionOperationException e) { } 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( @Command(
@ -539,7 +545,7 @@ public class RegionCommands {
@Arg(desc = "BlockStateHolder", def = "air") BlockStateHolder replace, @Arg(desc = "BlockStateHolder", def = "air") BlockStateHolder replace,
@Switch(name = 'm', desc = "TODO") boolean notFullHeight) throws WorldEditException { @Switch(name = 'm', desc = "TODO") boolean notFullHeight) throws WorldEditException {
int affected = editSession.fall(region, !notFullHeight, replace); int affected = editSession.fall(region, !notFullHeight, replace);
BBC.VISITOR_BLOCK.send(player, affected); player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , affected));
} }
@Command( @Command(
@ -548,7 +554,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.stack") @CommandPermissions("worldedit.region.stack")
@Logging(ORIENTATION_REGION) @Logging(ORIENTATION_REGION)
public void stack(Actor actor, World world, EditSession editSession, LocalSession session, public int stack(Actor actor, World world, EditSession editSession, LocalSession session,
@Selection Region region, @Selection Region region,
@Arg(desc = "# of copies to stack", def = "1") @Arg(desc = "# of copies to stack", def = "1")
@Confirm(Confirm.Processor.REGION) int count, @Confirm(Confirm.Processor.REGION) int count,
@ -589,11 +595,12 @@ public class RegionCommands {
session.getRegionSelector(world).learnChanges(); session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
} catch (RegionOperationException e) { } 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( @Command(
@ -641,9 +648,9 @@ public class RegionCommands {
if (actor instanceof Player) { if (actor instanceof Player) {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
actor.print(affected + " block(s) have been deformed."); actor.printInfo(TranslatableComponent.of("worldedit.deform.deformed", TextComponent.of(affected)));
} catch (ExpressionException e) { } catch (ExpressionException e) {
actor.printError(e.getMessage()); actor.printError(TextComponent.of(e.getMessage()));
} }
} }
@ -658,7 +665,7 @@ public class RegionCommands {
@CommandPermissions("worldedit.regen") @CommandPermissions("worldedit.regen")
@Logging(REGION) @Logging(REGION)
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public void regenerateChunk(Player player, LocalSession session, EditSession editSession, @Selection Region region, public void regenerateChunk(Actor actor, LocalSession session, EditSession editSession, @Selection Region region,
@Arg(def = "", desc = "Regenerate with biome") BiomeType biome, @Arg(def = "", desc = "Regenerate with biome") BiomeType biome,
@Arg(def = "", desc = "Regenerate with seed") Long seed) throws WorldEditException { @Arg(def = "", desc = "Regenerate with seed") Long seed) throws WorldEditException {
Mask mask = session.getMask(); Mask mask = session.getMask();
@ -667,17 +674,7 @@ public class RegionCommands {
editSession.regenerate(region, biome, seed); editSession.regenerate(region, biome, seed);
session.setMask(mask); session.setMask(mask);
session.setSourceMask(mask); session.setSourceMask(mask);
if (!player.hasPermission("fawe.tips")) { actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated"));
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());
}
} }
@Command( @Command(
@ -701,7 +698,7 @@ public class RegionCommands {
checkCommandArgument(thickness >= 0, "Thickness must be >= 0"); checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask; Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask); 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( @Command(
@ -718,7 +715,7 @@ public class RegionCommands {
double density) throws WorldEditException { double density) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]"); checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
int affected = editSession.makeForest(region, density / 100, type); int affected = editSession.makeForest(region, density / 100, type);
actor.print(affected + " trees created."); actor.printInfo(TranslatableComponent.of("worldedit.forest.created", TextComponent.of(affected)));
return affected; return affected;
} }
@ -740,7 +737,7 @@ public class RegionCommands {
Operations.completeLegacy(visitor); Operations.completeLegacy(visitor);
int affected = ground.getAffected(); int affected = ground.getAffected();
actor.print(affected + " flora created."); actor.printInfo(TranslatableComponent.of("worldedit.flora.created", TextComponent.of(affected)));
} }
} }

View File

@ -23,6 +23,7 @@ import static com.boydti.fawe.util.ReflectionUtils.as;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.clipboard.URIClipboardHolder;
@ -59,6 +60,7 @@ import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; 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.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.component.CodeFormat; import com.sk89q.worldedit.util.formatting.component.CodeFormat;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
@ -133,14 +135,14 @@ public class SchematicCommands {
boolean randomRotate) throws FilenameException { boolean randomRotate) throws FilenameException {
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName); final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
if (format == null) { if (format == null) {
BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName); player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.invalid.format" , formatName));
return; return;
} }
try { try {
MultiClipboardHolder all = ClipboardFormats.loadAllFromInput(player, filename, null, true); MultiClipboardHolder all = ClipboardFormats.loadAllFromInput(player, filename, null, true);
if (all != null) { if (all != null) {
session.addClipboard(all); session.addClipboard(all);
BBC.SCHEMATIC_LOADED.send(player, filename); player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded" , filename));
} }
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -154,7 +156,7 @@ public class SchematicCommands {
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"}) @CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
public void clear(Player player, LocalSession session) throws WorldEditException { public void clear(Player player, LocalSession session) throws WorldEditException {
session.setClipboard(null); session.setClipboard(null);
player.print(BBC.CLIPBOARD_CLEARED.s()); player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.cleared"));
} }
@Command( @Command(
@ -184,11 +186,11 @@ public class SchematicCommands {
} else { } else {
session.setClipboard(null); session.setClipboard(null);
} }
player.print(BBC.CLIPBOARD_CLEARED.s()); player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.cleared"));
return; return;
} }
} }
BBC.CLIPBOARD_URI_NOT_FOUND.send(player, fileName); player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.uri.not.found" , fileName));
} }
@Command( @Command(
@ -224,7 +226,7 @@ public class SchematicCommands {
URI uri; URI uri;
if (filename.startsWith("url:")) { if (filename.startsWith("url:")) {
if (!actor.hasPermission("worldedit.schematic.load.web")) { if (!actor.hasPermission("worldedit.schematic.load.web")) {
BBC.NO_PERM.send(actor, "worldedit.schematic.load.web"); actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.web"));
return; return;
} }
UUID uuid = UUID.fromString(filename.substring(4)); UUID uuid = UUID.fromString(filename.substring(4));
@ -246,12 +248,12 @@ public class SchematicCommands {
} }
file = actor.openFileOpenDialog(extensions); file = actor.openFileOpenDialog(extensions);
if (file == null || !file.exists()) { 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; return;
} }
} else { } else {
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) {
BBC.NO_PERM.send(actor, "worldedit.schematic.load.other"); actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.other"));
return; return;
} }
if (format == null && filename.matches(".*\\.[\\w].*")) { if (format == null && filename.matches(".*\\.[\\w].*")) {
@ -273,7 +275,7 @@ public class SchematicCommands {
if (format == null) { if (format == null) {
format = ClipboardFormats.findByFile(file); format = ClipboardFormats.findByFile(file);
if (format == null) { if (format == null) {
BBC.CLIPBOARD_INVALID_FORMAT.send(actor, file.getName()); actor.printError(TranslatableComponent.of("worldedit.schematic.unknown-format", TextComponent.of(formatName)));
return; return;
} }
} }
@ -281,7 +283,7 @@ public class SchematicCommands {
uri = file.toURI(); uri = file.toURI();
} }
format.hold(actor, uri, in); format.hold(actor, uri, in);
BBC.SCHEMATIC_LOADED.send(actor, filename); actor.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded" , filename));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
actor.printError("Unknown filename: " + filename); actor.printError("Unknown filename: " + filename);
} catch (URISyntaxException | IOException e) { } catch (URISyntaxException | IOException e) {
@ -322,7 +324,7 @@ public class SchematicCommands {
ClipboardFormat format = ClipboardFormats.findByAlias(formatName); ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
if (format == null) { if (format == null) {
actor.printError("Unknown schematic format: " + formatName); actor.printError(TranslatableComponent.of("worldedit.schematic.unknown-format", TextComponent.of(formatName)));
return; return;
} }
@ -330,7 +332,7 @@ public class SchematicCommands {
if (filename.contains("../")) { if (filename.contains("../")) {
other = true; other = true;
if (!actor.hasPermission("worldedit.schematic.save.other")) { if (!actor.hasPermission("worldedit.schematic.save.other")) {
BBC.NO_PERM.send(actor, "worldedit.schematic.save.other"); actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.save.other"));
return; return;
} }
if (filename.startsWith("../")) { if (filename.startsWith("../")) {
@ -348,12 +350,12 @@ public class SchematicCommands {
} }
if (other) { if (other) {
if (!actor.hasPermission("worldedit.schematic.delete.other")) { if (!actor.hasPermission("worldedit.schematic.delete.other")) {
BBC.NO_PERM.send(actor, "worldedit.schematic.delete.other"); actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.delete.other"));
return; return;
} }
} }
if (!allowOverwrite) { 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; return;
} }
} }
@ -362,8 +364,8 @@ public class SchematicCommands {
File parent = f.getParentFile(); File parent = f.getParentFile();
if (parent != null && !parent.exists()) { if (parent != null && !parent.exists()) {
if (!parent.mkdirs()) { if (!parent.mkdirs()) {
throw new StopExecutionException(TextComponent.of( throw new StopExecutionException(TranslatableComponent.of(
"Could not create folder for schematics!")); "worldedit.schematic.save.failed-directory"));
} }
} }
@ -372,7 +374,7 @@ public class SchematicCommands {
SchematicSaveTask task = new SchematicSaveTask(actor, f, format, holder, overwrite); SchematicSaveTask task = new SchematicSaveTask(actor, f, format, holder, overwrite);
AsyncCommandBuilder.wrap(task, actor) AsyncCommandBuilder.wrap(task, actor)
.registerWithSupervisor(worldEdit.getSupervisor(), "Saving schematic " + filename) .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) .onSuccess(filename + " saved" + (overwrite ? " (overwriting previous file)." : "."), null)
.onFailure("Failed to load schematic", worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter()) .onFailure("Failed to load schematic", worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter())
.buildAndExec(worldEdit.getExecutorService()); .buildAndExec(worldEdit.getExecutorService());
@ -394,13 +396,13 @@ public class SchematicCommands {
return; return;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) {
BBC.NO_PERM.send(player, "worldedit.schematic.move.other"); player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.move.other"));
return; return;
} }
ClipboardHolder clipboard = session.getClipboard(); ClipboardHolder clipboard = session.getClipboard();
List<File> sources = getFiles(clipboard); List<File> sources = getFiles(clipboard);
if (sources.isEmpty()) { if (sources.isEmpty()) {
player.printError(BBC.SCHEMATIC_NONE.s()); player.printError(TranslatableComponent.of("fawe.worldedit.schematic.schematic.none"));
return; return;
} }
if (!destDir.exists() && !destDir.mkdirs()) { if (!destDir.exists() && !destDir.mkdirs()) {
@ -410,19 +412,19 @@ public class SchematicCommands {
for (File source : sources) { for (File source : sources) {
File destFile = new File(destDir, source.getName()); File destFile = new File(destDir, source.getName());
if (destFile.exists()) { if (destFile.exists()) {
BBC.SCHEMATIC_MOVE_EXISTS.send(player, destFile); player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.move.exists" , destFile));
continue; continue;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) {
BBC.SCHEMATIC_MOVE_FAILED.send(player, destFile, player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.move.failed", destFile,
BBC.NO_PERM.format("worldedit.schematic.move.other")); TranslatableComponent.of("fawe.error.no.perm", ("worldedit.schematic.move.other"))));
continue; continue;
} }
try { try {
File cached = new File(source.getParentFile(), "." + source.getName() + ".cached"); File cached = new File(source.getParentFile(), "." + source.getName() + ".cached");
Files.move(source.toPath(), destFile.toPath()); Files.move(source.toPath(), destFile.toPath());
if (cached.exists()) Files.move(cached.toPath(), destFile.toPath()); if (cached.exists()) Files.move(cached.toPath(), destFile.toPath());
BBC.SCHEMATIC_MOVE_SUCCESS.send(player, source, destFile); player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.move.success" , source, destFile));
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -449,7 +451,7 @@ public class SchematicCommands {
) )
@CommandPermissions("worldedit.schematic.formats") @CommandPermissions("worldedit.schematic.formats")
public void formats(Actor actor) { public void formats(Actor actor) {
actor.print("Available clipboard formats (Name: Lookup names)"); actor.printInfo(TranslatableComponent.of("worldedit.schematic.formats.title"));
StringBuilder builder; StringBuilder builder;
boolean first = true; boolean first = true;
for (ClipboardFormat format : ClipboardFormats.getAll()) { for (ClipboardFormat format : ClipboardFormats.getAll()) {
@ -463,7 +465,7 @@ public class SchematicCommands {
first = false; first = false;
} }
first = true; first = true;
actor.print(builder.toString()); actor.printInfo(TextComponent.of(builder.toString()));
} }
} }
@ -481,7 +483,7 @@ public class SchematicCommands {
if (args.argsLength() == 0) { if (args.argsLength() == 0) {
if (fp.getSession().getVirtualWorld() != null) fp.setVirtualWorld(null); if (fp.getSession().getVirtualWorld() != null) fp.setVirtualWorld(null);
else { else {
BBC.COMMAND_SYNTAX.send(player, "/" + Commands.getAlias(SchematicCommands.class, "schematic") + " " + getCommand().aliases()[0] + " " + getCommand().usage()); player.print(TranslatableComponent.of("fawe.error.command.syntax" , "/" + Commands.getAlias(SchematicCommands.class, "schematic") + " " + getCommand().aliases()[0] + " " + getCommand().usage()));
} }
return; return;
} }
@ -503,11 +505,11 @@ public class SchematicCommands {
long total = count.longValue(); long total = count.longValue();
if (total == 0) { if (total == 0) {
if (args.getJoinedStrings(0).toLowerCase().startsWith("all")) { if (args.getJoinedStrings(0).toLowerCase().startsWith("all")) {
BBC.SCHEMATIC_NONE.send(player); player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.none"))
} else { } else {
String joined = args.getJoinedStrings(0); String joined = args.getJoinedStrings(0);
String cmd = "/" + Commands.getAlias(SchematicCommands.class, "schematic") + " " + getCommand().aliases()[0] + " all " + joined; String cmd = "/" + Commands.getAlias(SchematicCommands.class, "schematic") + " " + getCommand().aliases()[0] + " all " + joined;
BBC.HELP_SUGGEST.send(player, joined, cmd); player.print(TranslatableComponent.of("fawe.worldedit.help.help.suggest" , joined, cmd));
} }
return; return;
} }
@ -516,11 +518,11 @@ public class SchematicCommands {
String cmdPrefix = "/" + (config.noDoubleSlash ? "" : "/"); String cmdPrefix = "/" + (config.noDoubleSlash ? "" : "/");
String cmdShow = Commands.getAlias(ClipboardCommands.class, "schematic") + " " + Commands.getAlias(ClipboardCommands.class, "show"); String cmdShow = Commands.getAlias(ClipboardCommands.class, "schematic") + " " + Commands.getAlias(ClipboardCommands.class, "show");
BBC.SCHEMATIC_SHOW.send(fp, count.longValue(), args.getJoinedStrings(0), cmdShow); fp.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.show" , count.longValue(), args.getJoinedStrings(0), cmdShow));
if (fp.getSession().getExistingClipboard() != null) { if (fp.getSession().getExistingClipboard() != null) {
String cmd = cmdPrefix + Commands.getAlias(ClipboardCommands.class, "clearclipboard"); String cmd = cmdPrefix + Commands.getAlias(ClipboardCommands.class, "clearclipboard");
BBC.SCHEMATIC_PROMPT_CLEAR.send(fp, cmd); fp.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.prompt.clear" , cmd));
} }
} catch (Throwable e) { } catch (Throwable e) {
@ -719,9 +721,9 @@ public class SchematicCommands {
writer.write(target); writer.write(target);
} }
log.info(actor.getName() + " saved " + file.getCanonicalPath()); log.info(actor.getName() + " saved " + file.getCanonicalPath());
BBC.SCHEMATIC_SAVED.send(actor, file.getName()); actor.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.saved" , file.getName()));
} else { } else {
actor.printError(BBC.WORLDEDIT_CANCEL_REASON_MANUAL.s()); actor.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual"));
} }
} }
return null; return null;
@ -826,28 +828,27 @@ public class SchematicCommands {
} }
if (files.isEmpty()) { if (files.isEmpty()) {
actor.printError(BBC.SCHEMATIC_NONE.s()); actor.printError(TranslatableComponent.of("worldedit.schematic.delete.does-not-exist", TextComponent.of(filename)));
return; return;
} }
for (File f : files) { for (File f : files) {
if (!MainUtil.isInSubDirectory(working, f) || !f.exists()) { if (!MainUtil.isInSubDirectory(working, f) || !f.exists()) {
actor.printError("Schematic " + filename + " does not exist! (" + f.exists() + "|" + f + "|" + !MainUtil.isInSubDirectory(working, f) actor.printError(TranslatableComponent.of("worldedit.schematic.delete.does-not-exist", TextComponent.of(filename)));
+ ")");
continue; continue;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission("worldedit.schematic.delete.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission("worldedit.schematic.delete.other")) {
BBC.NO_PERM.send(actor, "worldedit.schematic.delete.other"); actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.delete.other"));
continue; continue;
} }
if (!delete(f)) { if (!deleteFile(f)) {
actor.printError("Deletion of " + filename + " failed! Maybe it is read-only."); actor.printError(TranslatableComponent.of("worldedit.schematic.delete.failed", TextComponent.of(filename)));
continue; continue;
} }
BBC.FILE_DELETED.send(actor, filename); actor.print(TranslatableComponent.of("fawe.info.file.deleted" , filename));
} }
} }
private boolean delete(File file) { private boolean deleteFile(File file) {
if (file.delete()) { if (file.delete()) {
new File(file.getParentFile(), "." + file.getName() + ".cached").delete(); new File(file.getParentFile(), "." + file.getName() + ".cached").delete();
return true; return true;

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -28,6 +29,7 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager; import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -70,7 +72,7 @@ public class ScriptingCommands {
@Arg(desc = "Arguments to the CraftScript", def = "", variable = true) @Arg(desc = "Arguments to the CraftScript", def = "", variable = true)
List<String> args) throws WorldEditException { List<String> args) throws WorldEditException {
if (!player.hasPermission("worldedit.scripting.execute." + filename)) { 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; return;
} }
@ -96,12 +98,12 @@ public class ScriptingCommands {
String lastScript = session.getLastScript(); String lastScript = session.getLastScript();
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) { if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
player.printError(BBC.SCRIPTING_NO_PERM.s()); player.printError(TranslatableComponent.of("worldedit.execute.script-permissions"));
return; return;
} }
if (lastScript == null) { if (lastScript == null) {
player.printError(BBC.SCRIPTING_CS.s()); player.printError(TranslatableComponent.of("worldedit.executelast.no-script"));
return; return;
} }

View File

@ -25,6 +25,7 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.clipboard.URIClipboardHolder;
import com.boydti.fawe.object.mask.IdMask; import com.boydti.fawe.object.mask.IdMask;
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector; import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
@ -46,7 +47,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extension.platform.Locatable;
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.annotation.Direction;
@ -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.SubtleFormat;
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
import com.sk89q.worldedit.util.formatting.text.TextComponent; 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.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -123,12 +124,12 @@ public class SelectionCommands {
} else if (actor instanceof Locatable) { } else if (actor instanceof Locatable) {
pos = ((Locatable) actor).getBlockLocation(); pos = ((Locatable) actor).getBlockLocation();
} else { } else {
actor.printError("You must provide coordinates as console."); actor.printError(TranslatableComponent.of("worldedit.pos.console-require-coords"));
return; return;
} }
if (!session.getRegionSelector(world).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(actor))) { 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; return;
} }
@ -152,12 +153,12 @@ public class SelectionCommands {
} else if (actor instanceof Locatable) { } else if (actor instanceof Locatable) {
pos = ((Locatable) actor).getBlockLocation(); pos = ((Locatable) actor).getBlockLocation();
} else { } else {
actor.printError("You must provide coordinates as console."); actor.printError(TranslatableComponent.of("worldedit.pos.console-require-coords"));
return; return;
} }
if (!session.getRegionSelector(world).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(actor))) { 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; return;
} }
@ -175,15 +176,15 @@ public class SelectionCommands {
Location pos = player.getBlockTrace(300); Location pos = player.getBlockTrace(300);
if (pos != null) { if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) { if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.printError(BBC.SELECTOR_ALREADY_SET.s()); player.printError(TranslatableComponent.of("worldedit.hpos.already-set"));
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(player.getWorld())
.explainPrimarySelection(player, session, pos.toBlockPoint()); .explainPrimarySelection(player, session, pos.toBlockPoint());
} else { } 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); Location pos = player.getBlockTrace(300);
if (pos != null) { if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) { if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.printError(BBC.SELECTOR_ALREADY_SET.s()); player.printError(TranslatableComponent.of("worldedit.hpos.already-set"));
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos.toBlockPoint()); .explainSecondarySelection(player, session, pos.toBlockPoint());
} else { } 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); min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
max = BlockVector3.at(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15); max = BlockVector3.at(max2D.getBlockX() * 16 + 15, world.getMaxY(), max2D.getBlockZ() * 16 + 15);
actor.print("Chunks selected: (" actor.printInfo(TranslatableComponent.of(
+ min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - (" "worldedit.chunk.selected-multiple",
+ max2D.getBlockX() + ", " + max2D.getBlockZ() + ")"); TextComponent.of(min2D.getBlockX()),
TextComponent.of(min2D.getBlockZ()),
TextComponent.of(max2D.getBlockX()),
TextComponent.of(max2D.getBlockZ())
));
} else { } else {
final BlockVector2 min2D; final BlockVector2 min2D;
if (coordinates != null) { if (coordinates != null) {
@ -255,8 +260,8 @@ public class SelectionCommands {
min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); min = BlockVector3.at(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);
max = min.add(15, world.getMaxY(), 15); max = min.add(15, world.getMaxY(), 15);
actor.print("Chunk selected: " actor.printInfo(TranslatableComponent.of("worldedit.chunk.selected", TextComponent.of(min2D.getBlockX()),
+ min2D.getBlockX() + ", " + min2D.getBlockZ()); TextComponent.of(min2D.getBlockZ())));
} }
final CuboidRegionSelector selector; final CuboidRegionSelector selector;
@ -287,19 +292,20 @@ public class SelectionCommands {
} }
ItemType itemType = ItemTypes.parse(wandId); ItemType itemType = ItemTypes.parse(wandId);
if (itemType == null) { if (itemType == null) {
player.printError("Wand item is mis-configured or disabled."); player.printError(TranslatableComponent.of("worldedit.wand.invalid"));
return; return;
} }
player.giveItem(new BaseItemStack(itemType, 1)); player.giveItem(new BaseItemStack(itemType, 1));
if (navWand) { if (navWand) {
session.setTool(itemType, NavigationWand.INSTANCE); 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 { } else {
session.setTool(itemType, SelectionWand.INSTANCE); session.setTool(itemType, SelectionWand.INSTANCE);
player.print(BBC.SELECTION_WAND.s()); player.printInfo(TranslatableComponent.of("worldedit.wand.selwand.info"));
} }
if (!player.hasPermission("fawe.tips")) 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); System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.sel.list").or(TranslatableComponent.of("fawe.tips.tip.select.connected"), TranslatableComponent.of("fawe.tips.tip.set.pos1"), TranslatableComponent.of("fawe.tips.tip.farwand"), TranslatableComponent.of("fawe.tips.tip.discord")).send(player);
} }
@Command( @Command(
@ -350,9 +356,9 @@ public class SelectionCommands {
session.getRegionSelector(world).explainRegionAdjust(actor, session); 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) { } catch (RegionOperationException e) {
actor.printError(e.getMessage()); actor.printError(TextComponent.of(e.getMessage()));
} }
} }
@ -379,9 +385,9 @@ public class SelectionCommands {
session.getRegionSelector(world).explainRegionAdjust(actor, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
actor.print("Region shifted."); actor.print(TranslatableComponent.of("worldedit.shift.shifted"));
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
actor.printError(e.getMessage()); actor.printError(TextComponent.of(e.getMessage()));
} }
} }
@ -402,7 +408,7 @@ public class SelectionCommands {
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical)); region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
session.getRegionSelector(world).learnChanges(); session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session); session.getRegionSelector(world).explainRegionAdjust(actor, session);
actor.print("Region outset."); actor.print(TranslatableComponent.of("worldedit.outset.outset"));
} }
@Command( @Command(
@ -422,7 +428,7 @@ public class SelectionCommands {
region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical)); region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
session.getRegionSelector(world).learnChanges(); session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session); 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) { private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) {
@ -448,7 +454,7 @@ public class SelectionCommands {
desc = "Get information about the selection" desc = "Get information about the selection"
) )
@CommandPermissions("worldedit.selection.size") @CommandPermissions("worldedit.selection.size")
public void size(Player player, LocalSession session, public void size(Actor actor, World world, LocalSession session,
@Switch(name = 'c', desc = "Get clipboard info instead") @Switch(name = 'c', desc = "Get clipboard info instead")
boolean clipboardInfo) throws WorldEditException { boolean clipboardInfo) throws WorldEditException {
Region region; Region region;
@ -479,21 +485,17 @@ public class SelectionCommands {
String originStr = origin.getBlockX() + "," + origin.getBlockY() + "," + origin.getBlockZ(); String originStr = origin.getBlockX() + "," + origin.getBlockY() + "," + origin.getBlockZ();
long numBlocks = ((long) size.getBlockX() * size.getBlockY() * size.getBlockZ()); long numBlocks = ((long) size.getBlockX() * size.getBlockY() * size.getBlockZ());
actor.printInfo(TranslatableComponent.of("worldedit.size.offset", TextComponent.of(name), TextComponent.of(sizeStr), TextComponent.of(originStr), TextComponent.of(numBlocks)));
String msg = String.format("%1$s: %2$s @ %3$s (%4$d blocks)", name, sizeStr, originStr, numBlocks);
player.print(msg);
index++; index++;
} }
return; return;
} else { } else {
region = session.getSelection(world);
region = session.getSelection(player.getWorld()); actor.printInfo(TranslatableComponent.of("worldedit.size.type", TextComponent.of(session.getRegionSelector(world).getTypeName())));
player.print("Type: " + session.getRegionSelector(player.getWorld()).getTypeName()); for (Component line : session.getRegionSelector(world).getSelectionInfoLines()) {
actor.print(line);
for (String line : session.getRegionSelector(player.getWorld()).getInformationLines()) {
player.print(line);
} }
} }
@ -501,22 +503,22 @@ public class SelectionCommands {
.subtract(region.getMinimumPoint()) .subtract(region.getMinimumPoint())
.add(1, 1, 1); .add(1, 1, 1);
player.print("Size: " + size); actor.printInfo(TranslatableComponent.of("worldedit.size.size", TextComponent.of(size.toString())));
player.print("Cuboid distance: " + region.getMaximumPoint().distance(region.getMinimumPoint())); actor.printInfo(TranslatableComponent.of("worldedit.size.distance", TextComponent.of(region.getMaximumPoint().distance(region.getMinimumPoint()))));
player.print("# of blocks: " + region.getArea()); actor.printInfo(TranslatableComponent.of("worldedit.size.blocks", TextComponent.of(region.getArea())));
} }
@Command( @Command(
name = "/count", name = "/count",
desc = "Counts the number of blocks matching a mask" desc = "Counts the number of blocks matching a mask"
) )
@CommandPermissions("worldedit.analysis.count") @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") @Arg(desc = "The mask of blocks to match")
Mask mask) throws WorldEditException { Mask mask) throws WorldEditException {
int count = editSession.countBlocks(session.getSelection(world), mask); 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( @Command(
@ -524,11 +526,13 @@ public class SelectionCommands {
desc = "Get the distribution of blocks in the selection" desc = "Get the distribution of blocks in the selection"
) )
@CommandPermissions("worldedit.analysis.distr") @CommandPermissions("worldedit.analysis.distr")
public void distr(Player player, LocalSession session, EditSession editSession, public void distr(Actor actor, World world, LocalSession session, EditSession editSession,
@Switch(name = 'c', desc = "Get the distribution of the clipboard instead") @Switch(name = 'c', desc = "Get the distribution of the clipboard instead")
boolean clipboardDistr, boolean clipboardDistr,
@Switch(name = 'd', desc = "Separate blocks by state") @Switch(name = 'd', desc = "Separate blocks by state")
boolean separateStates) throws WorldEditException { boolean separateStates,
@ArgFlag(name = 'p', desc = "Gets page from a previous distribution.", def = "")
Integer page) throws WorldEditException {
List<Countable> distribution; List<Countable> distribution;
Region region; Region region;
@ -538,7 +542,7 @@ public class SelectionCommands {
region = clipboard.getRegion(); region = clipboard.getRegion();
new ExtentTraverser<AbstractDelegateExtent>(editSession).setNext(new AbstractDelegateExtent(clipboard)); new ExtentTraverser<AbstractDelegateExtent>(editSession).setNext(new AbstractDelegateExtent(clipboard));
} else { } else {
region = session.getSelection(player.getWorld()); region = session.getSelection(world);
} }
if (separateStates) if (separateStates)
distribution = (List) editSession.getBlockDistributionWithData(region); distribution = (List) editSession.getBlockDistributionWithData(region);
@ -547,31 +551,22 @@ public class SelectionCommands {
if (distribution.isEmpty()) { // *Should* always be false if (distribution.isEmpty()) { // *Should* always be false
player.printError("No blocks counted."); actor.printError(TranslatableComponent.of("worldedit.distr.no-blocks"));
return; return;
} }
// note: doing things like region.getArea is inaccurate for non-cuboids. BlockDistributionResult res = new BlockDistributionResult(distribution, separateStates);
int size = session.getSelection(player.getWorld()).getArea(); if (!actor.isPlayer()) res.formatForConsole();
BBC.SELECTION_DISTR.send(player, size); actor.print(res.create(page));
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);
}
} }
private static class BlockDistributionResult extends PaginationBox { private static class BlockDistributionResult extends PaginationBox {
private final List<Countable<BlockState>> distribution; private final List<Countable> distribution;
private final int totalBlocks; private final int totalBlocks;
private final boolean separateStates; private final boolean separateStates;
BlockDistributionResult(List<Countable<BlockState>> distribution, boolean separateStates) { BlockDistributionResult(List<Countable> distribution, boolean separateStates) {
super("Block Distribution", "//distr -p %page%" + (separateStates ? " -d" : "")); super("Block Distribution", "//distr -p %page%" + (separateStates ? " -d" : ""));
this.distribution = distribution; this.distribution = distribution;
// note: doing things like region.getArea is inaccurate for non-cuboids. // note: doing things like region.getArea is inaccurate for non-cuboids.
@ -597,11 +592,11 @@ public class SelectionCommands {
final BlockState state = c.getID(); final BlockState state = c.getID();
final BlockType blockType = state.getBlockType(); final BlockType blockType = state.getBlockType();
TextComponent blockName = TextComponent.of(blockType.getName(), TextColor.LIGHT_PURPLE); TextComponent blockName = TextComponent.of(blockType.getName(), TextColor.GRAY);
TextComponent toolTip; TextComponent toolTip;
if (separateStates && state != blockType.getDefaultState()) { if (separateStates && state != blockType.getDefaultState()) {
toolTip = TextComponent.of(state.getAsString(), TextColor.GRAY); toolTip = TextComponent.of(state.getAsString(), TextColor.GRAY);
blockName = blockName.append(TextComponent.of("*", TextColor.LIGHT_PURPLE)); blockName = blockName.append(TextComponent.of("*", TextColor.GRAY));
} else { } else {
toolTip = TextComponent.of(blockType.getId(), TextColor.GRAY); toolTip = TextComponent.of(blockType.getId(), TextColor.GRAY);
} }
@ -618,7 +613,7 @@ public class SelectionCommands {
@Override @Override
public Component create(int page) throws InvalidComponentException { 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()); .append(TextComponent.newline());
return super.create(page); return super.create(page);
} }
@ -638,7 +633,7 @@ public class SelectionCommands {
if (selector == null) { if (selector == null) {
session.getRegionSelector(world).clear(); session.getRegionSelector(world).clear();
session.dispatchCUISelection(actor); session.dispatchCUISelection(actor);
actor.print(BBC.SELECTION_CLEARED.s()); actor.printInfo(TranslatableComponent.of("worldedit.select.cleared"));
return; return;
} }
@ -648,46 +643,46 @@ public class SelectionCommands {
switch (selector) { switch (selector) {
case CUBOID: case CUBOID:
newSelector = new CuboidRegionSelector(oldSelector); newSelector = new CuboidRegionSelector(oldSelector);
actor.print(BBC.SEL_CUBOID.s()); actor.printInfo(TranslatableComponent.of("worldedit.select.cuboid.message"));
break; break;
case EXTEND: case EXTEND:
newSelector = new ExtendingCuboidRegionSelector(oldSelector); newSelector = new ExtendingCuboidRegionSelector(oldSelector);
actor.print(BBC.SEL_CUBOID_EXTEND.s()); actor.printInfo(TranslatableComponent.of("worldedit.select.extend.message"));
break; break;
case POLY: { case POLY: {
newSelector = new Polygonal2DRegionSelector(oldSelector); 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(); 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; break;
} }
case ELLIPSOID: case ELLIPSOID:
newSelector = new EllipsoidRegionSelector(oldSelector); newSelector = new EllipsoidRegionSelector(oldSelector);
actor.print(BBC.SAL_ELLIPSOID.s()); actor.printInfo(TranslatableComponent.of("worldedit.select.ellipsoid.message"));
break; break;
case SPHERE: case SPHERE:
newSelector = new SphereRegionSelector(oldSelector); newSelector = new SphereRegionSelector(oldSelector);
actor.print(BBC.SEL_SPHERE.s()); actor.printInfo(TranslatableComponent.of("worldedit.select.sphere.message"));
break; break;
case CYL: case CYL:
newSelector = new CylinderRegionSelector(oldSelector); newSelector = new CylinderRegionSelector(oldSelector);
actor.print(BBC.SEL_CYLINDRICAL.s()); actor.printInfo(TranslatableComponent.of("worldedit.select.cyl.message"));
break; break;
case CONVEX: case CONVEX:
case HULL: case HULL:
case POLYHEDRON: { case POLYHEDRON: {
newSelector = new ConvexPolyhedralRegionSelector(oldSelector); 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(); 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; break;
} }
case POLYHEDRAL: case POLYHEDRAL:
newSelector = new PolyhedralRegionSelector(world); newSelector = new PolyhedralRegionSelector(world);
actor.print(BBC.SEL_CONVEX_POLYHEDRAL.s()); actor.print(TranslatableComponent.of("fawe.selection.sel.convex.polyhedral"));
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit(); Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
limit.ifPresent(integer -> actor.print(BBC.SEL_MAX.format(integer))); limit.ifPresent(integer -> actor.print(TranslatableComponent.of("fawe.selection.sel.max", (integer))));
actor.print(BBC.SEL_LIST.s()); actor.print(TranslatableComponent.of("fawe.selection.sel.list"));
break; break;
case FUZZY: case FUZZY:
case MAGIC: case MAGIC:
@ -696,8 +691,8 @@ public class SelectionCommands {
} }
//TODO Make FuzzyRegionSelector accept actors //TODO Make FuzzyRegionSelector accept actors
newSelector = new FuzzyRegionSelector((Player) actor, world, maskOpt); newSelector = new FuzzyRegionSelector((Player) actor, world, maskOpt);
actor.print(BBC.SEL_FUZZY.s()); actor.print(TranslatableComponent.of("fawe.selection.sel.fuzzy"));
actor.print(BBC.SEL_LIST.s()); actor.print(TranslatableComponent.of("fawe.selection.sel.list"));
break; break;
case LIST: case LIST:
default: default:
@ -706,13 +701,13 @@ public class SelectionCommands {
TextComponentProducer contents = box.getContents(); TextComponentProducer contents = box.getContents();
contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline(); contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline();
box.appendCommand("cuboid", "Select two corners of a cuboid", "//sel cuboid"); box.appendCommand("cuboid", TranslatableComponent.of("worldedit.select.cuboid.description"), "//sel cuboid");
box.appendCommand("extend", "Fast cuboid selection mode", "//sel extend"); box.appendCommand("extend", TranslatableComponent.of("worldedit.select.extend.description"), "//sel extend");
box.appendCommand("poly", "Select a 2D polygon with height", "//sel poly"); box.appendCommand("poly", TranslatableComponent.of("worldedit.select.poly.description"), "//sel poly");
box.appendCommand("ellipsoid", "Select an ellipsoid", "//sel ellipsoid"); box.appendCommand("ellipsoid", TranslatableComponent.of("worldedit.select.ellipsoid.description"), "//sel ellipsoid");
box.appendCommand("sphere", "Select a sphere", "//sel sphere"); box.appendCommand("sphere", TranslatableComponent.of("worldedit.select.sphere.description"), "//sel sphere");
box.appendCommand("cyl", "Select a cylinder", "//sel cyl"); box.appendCommand("cyl", TranslatableComponent.of("worldedit.select.cyl.description"), "//sel cyl");
box.appendCommand("convex", "Select a convex polyhedral", "//sel convex"); box.appendCommand("convex", TranslatableComponent.of("worldedit.select.convex.description"), "//sel convex");
box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral"); box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral");
box.appendCommand("fuzzy[=<mask>]", "Select all connected blocks (magic wand)", "//sel fuzzy[=<mask>]"); box.appendCommand("fuzzy[=<mask>]", "Select all connected blocks (magic wand)", "//sel fuzzy[=<mask>]");
@ -731,7 +726,7 @@ public class SelectionCommands {
if (found != null) { if (found != null) {
session.setDefaultRegionSelector(found); session.setDefaultRegionSelector(found);
BBC.SELECTOR_SET_DEFAULT.send(actor, found.name()); actor.printInfo(TranslatableComponent.of("worldedit.select.default-set", TextComponent.of(found.name())));
} else { } else {
throw new RuntimeException("Something unexpected happened. Please report this."); throw new RuntimeException("Something unexpected happened. Please report this.");
} }

View File

@ -22,17 +22,18 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.component.PaginationBox; import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; 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.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
@ -76,7 +77,7 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) { if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured."); actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return; return;
} }
@ -86,7 +87,7 @@ public class SnapshotCommands {
if (!snapshots.isEmpty()) { if (!snapshots.isEmpty()) {
actor.print(new SnapshotListBox(world.getName(), snapshots).create(page)); actor.print(new SnapshotListBox(world.getName(), snapshots).create(page));
} else { } 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! // Okay, let's toss some debugging information!
File dir = config.snapshotRepo.getDirectory(); File dir = config.snapshotRepo.getDirectory();
@ -101,7 +102,7 @@ public class SnapshotCommands {
} }
} }
} catch (MissingWorldException ex) { } catch (MissingWorldException ex) {
actor.printError("No snapshots were found for this world."); actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
} }
} }
@ -117,7 +118,7 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) { if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured."); actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return; return;
} }
@ -128,19 +129,19 @@ public class SnapshotCommands {
if (snapshot != null) { if (snapshot != null) {
session.setSnapshot(null); session.setSnapshot(null);
actor.print("Now using newest snapshot."); actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use.newest"));
} else { } else {
actor.printError("No snapshots were found."); actor.printError(TranslatableComponent.of("worldedit.restore.none-found"));
} }
} catch (MissingWorldException ex) { } catch (MissingWorldException ex) {
actor.printError("No snapshots were found for this world."); actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
} }
} else { } else {
try { try {
session.setSnapshot(config.snapshotRepo.getSnapshot(name)); 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) { } catch (InvalidSnapshotException e) {
actor.printError("That snapshot does not exist or is not available."); actor.printError(TranslatableComponent.of("worldedit.restore.not-available"));
} }
} }
} }
@ -156,30 +157,30 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) { if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured."); actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return; return;
} }
if (index < 1) { if (index < 1) {
actor.printError("Invalid index, must be equal or higher then 1."); actor.printError(TranslatableComponent.of("worldedit.snapshot.index-above-0"));
return; return;
} }
try { try {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, world.getName()); List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, world.getName());
if (snapshots.size() < index) { 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; return;
} }
Snapshot snapshot = snapshots.get(index - 1); Snapshot snapshot = snapshots.get(index - 1);
if (snapshot == null) { if (snapshot == null) {
actor.printError("That snapshot does not exist or is not available."); actor.printError(TranslatableComponent.of("worldedit.restore.not-available"));
return; return;
} }
session.setSnapshot(snapshot); session.setSnapshot(snapshot);
actor.print("Snapshot set to: " + snapshot.getName()); actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
} catch (MissingWorldException e) { } catch (MissingWorldException e) {
actor.printError("No snapshots were found for this world."); actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
} }
} }
@ -195,7 +196,7 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) { if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured."); actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return; return;
} }
@ -203,14 +204,16 @@ public class SnapshotCommands {
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, world.getName()); Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, world.getName());
if (snapshot == null) { if (snapshot == null) {
actor.printError("Couldn't find a snapshot before " actor.printError(TranslatableComponent.of(
+ dateFormat.withZone(session.getTimeZone()).format(date) + "."); "worldedit.snapshot.none-before",
TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date)))
);
} else { } else {
session.setSnapshot(snapshot); session.setSnapshot(snapshot);
actor.print("Snapshot set to: " + snapshot.getName()); actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
} }
} catch (MissingWorldException ex) { } catch (MissingWorldException ex) {
actor.printError("No snapshots were found for this world."); actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
} }
} }
@ -226,21 +229,23 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) { if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured."); actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return; return;
} }
try { try {
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, world.getName()); Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, world.getName());
if (snapshot == null) { if (snapshot == null) {
actor.printError("Couldn't find a snapshot after " actor.printError(TranslatableComponent.of(
+ dateFormat.withZone(session.getTimeZone()).format(date) + "."); "worldedit.snapshot.none-after",
TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date)))
);
} else { } else {
session.setSnapshot(snapshot); session.setSnapshot(snapshot);
actor.print("Snapshot set to: " + snapshot.getName()); actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
} }
} catch (MissingWorldException ex) { } catch (MissingWorldException ex) {
actor.printError("No snapshots were found for this world."); actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
} }
} }
@ -256,7 +261,7 @@ public class SnapshotCommands {
public Component getComponent(int number) { public Component getComponent(int number) {
final Snapshot snapshot = snapshots.get(number); final Snapshot snapshot = snapshots.get(number);
return TextComponent.of(number + 1 + ". ", TextColor.GOLD) return TextComponent.of(number + 1 + ". ", TextColor.GOLD)
.append(TextComponent.of(snapshot.getName(), TextColor.LIGHT_PURPLE) .append(TextComponent.of(snapshot.getName(), TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to use"))) .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to use")))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/snap use " + snapshot.getName()))); .clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/snap use " + snapshot.getName())));
} }

View File

@ -29,6 +29,8 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.regions.Region; 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.DataException;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException; import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
@ -68,7 +70,7 @@ public class SnapshotUtilCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) { if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured."); actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return; return;
} }
@ -79,7 +81,7 @@ public class SnapshotUtilCommands {
try { try {
snapshot = config.snapshotRepo.getSnapshot(snapshotName); snapshot = config.snapshotRepo.getSnapshot(snapshotName);
} catch (InvalidSnapshotException e) { } catch (InvalidSnapshotException e) {
actor.printError("That snapshot does not exist or is not available."); actor.printError(TranslatableComponent.of("worldedit.restore.not-available"));
return; return;
} }
} else { } else {
@ -92,7 +94,7 @@ public class SnapshotUtilCommands {
snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName()); snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName());
if (snapshot == null) { 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! // Okay, let's toss some debugging information!
File dir = config.snapshotRepo.getDirectory(); File dir = config.snapshotRepo.getDirectory();
@ -109,7 +111,7 @@ public class SnapshotUtilCommands {
return; return;
} }
} catch (MissingWorldException ex) { } catch (MissingWorldException ex) {
actor.printError("No snapshots were found for this world."); actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
return; return;
} }
} }
@ -119,9 +121,9 @@ public class SnapshotUtilCommands {
// Load chunk store // Load chunk store
try { try {
chunkStore = snapshot.getChunkStore(); 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) { } catch (DataException | IOException e) {
actor.printError("Failed to load snapshot: " + e.getMessage()); actor.printError(TranslatableComponent.of("worldedit.restore.failed", TextComponent.of(e.getMessage())));
return; return;
} }
@ -135,18 +137,17 @@ public class SnapshotUtilCommands {
if (restore.hadTotalFailure()) { if (restore.hadTotalFailure()) {
String error = restore.getLastErrorMessage(); String error = restore.getLastErrorMessage();
if (!restore.getMissingChunks().isEmpty()) { 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) { } else if (error != null) {
actor.printError("Errors prevented any blocks from being restored."); actor.printError(TranslatableComponent.of("worldedit.restore.block-place-failed"));
actor.printError("Last error: " + error); actor.printError(TranslatableComponent.of("worldedit.restore.block-place-error", TextComponent.of(error)));
} else { } else {
actor.printError("No chunks could be loaded. (Bad archive?)"); actor.printError(TranslatableComponent.of("worldedit.restore.chunk-load-failed"));
} }
} else { } else {
actor.print(String.format("Restored; %d " actor.printInfo(TranslatableComponent.of("worldedit.restore.restored",
+ "missing chunks and %d other errors.", TextComponent.of(restore.getMissingChunks().size()),
restore.getMissingChunks().size(), TextComponent.of(restore.getErrorChunks().size())));
restore.getErrorChunks().size()));
} }
} finally { } finally {
try { try {

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -30,6 +31,8 @@ import com.sk89q.worldedit.command.tool.SinglePickaxe;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player; 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.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
@ -50,7 +53,7 @@ public class SuperPickaxeCommands {
public void single(Player player, LocalSession session) throws WorldEditException { public void single(Player player, LocalSession session) throws WorldEditException {
session.setSuperPickaxe(new SinglePickaxe()); session.setSuperPickaxe(new SinglePickaxe());
session.enableSuperPickAxe(); session.enableSuperPickAxe();
player.print(BBC.SUPERPICKAXE_AREA_ENABLED.s()); player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.mode.single"));
} }
@Command( @Command(
@ -65,13 +68,13 @@ public class SuperPickaxeCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) { 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; return;
} }
session.setSuperPickaxe(new AreaPickaxe(range)); session.setSuperPickaxe(new AreaPickaxe(range));
session.enableSuperPickAxe(); session.enableSuperPickAxe();
player.print(BBC.SUPERPICKAXE_AREA_ENABLED.s()); player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.mode.area"));
} }
@Command( @Command(
@ -87,12 +90,12 @@ public class SuperPickaxeCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) { 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; return;
} }
session.setSuperPickaxe(new RecursivePickaxe(range)); session.setSuperPickaxe(new RecursivePickaxe(range));
session.enableSuperPickAxe(); session.enableSuperPickAxe();
player.print(BBC.SUPERPICKAXE_AREA_ENABLED.s()); player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.mode.recursive"));
} }
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.InspectBrush; import com.boydti.fawe.object.brush.InspectBrush;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -125,10 +126,10 @@ public class ToolCommands {
return "/tool " + name; return "/tool " + name;
} }
static void setToolNone(Player player, LocalSession session, String type) static void setToolNone(Player player, LocalSession session, boolean isBrush)
throws InvalidToolBindException { throws InvalidToolBindException {
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null); session.setTool(player, 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; private final WorldEdit we;
@ -143,10 +144,9 @@ public class ToolCommands {
) )
@CommandPermissions("worldedit.setwand") @CommandPermissions("worldedit.setwand")
public void selwand(Player player, LocalSession session) throws WorldEditException { public void selwand(Player player, LocalSession session) throws WorldEditException {
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType(); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(itemType, SelectionWand.INSTANCE); session.setTool(player, SelectionWand.INSTANCE);
player.print("Selection wand bound to " + itemType.getName() + "."); player.printInfo(TranslatableComponent.of("worldedit.tool.selwand.equip", TextComponent.of(itemType.getName())));
} }
@Command( @Command(
@ -157,9 +157,9 @@ public class ToolCommands {
@CommandPermissions("worldedit.setwand") @CommandPermissions("worldedit.setwand")
public void navwand(Player player, LocalSession session) throws WorldEditException { public void navwand(Player player, LocalSession session) throws WorldEditException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(player, NavigationWand.INSTANCE); 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( @Command(
@ -169,9 +169,9 @@ public class ToolCommands {
@CommandPermissions("worldedit.tool.info") @CommandPermissions("worldedit.tool.info")
public void info(Player player, LocalSession session) throws WorldEditException { public void info(Player player, LocalSession session) throws WorldEditException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(player, new QueryTool()); 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( @Command(
@ -180,9 +180,9 @@ public class ToolCommands {
) )
@CommandPermissions("worldedit.tool.inspect") @CommandPermissions("worldedit.tool.inspect")
public void inspectBrush(Player player, LocalSession session) throws WorldEditException { public void inspectBrush(Player player, LocalSession session) throws WorldEditException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(player, new InspectBrush()); session.setTool(player, new InspectBrush());
BBC.TOOL_INSPECT.send(player, itemStack.getType().getName()); player.printInfo(TranslatableComponent.of("worldedit.tool.inspect.equip", TextComponent.of(itemType.getName())));
} }
@Command( @Command(
@ -194,9 +194,9 @@ public class ToolCommands {
@Arg(desc = "Type of tree to generate", def = "tree") @Arg(desc = "Type of tree to generate", def = "tree")
TreeGenerator.TreeType type) throws WorldEditException { TreeGenerator.TreeType type) throws WorldEditException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(player, new TreePlanter(type)); 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( @Command(
@ -208,9 +208,9 @@ public class ToolCommands {
@Arg(desc = "The pattern of blocks to place") @Arg(desc = "The pattern of blocks to place")
Pattern pattern) throws WorldEditException { Pattern pattern) throws WorldEditException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(player, new BlockReplacer(pattern)); 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( @Command(
@ -220,9 +220,9 @@ public class ToolCommands {
@CommandPermissions("worldedit.tool.data-cycler") @CommandPermissions("worldedit.tool.data-cycler")
public void cycler(Player player, LocalSession session) throws WorldEditException { public void cycler(Player player, LocalSession session) throws WorldEditException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(player, new BlockDataCyler()); 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( @Command(
@ -240,13 +240,13 @@ public class ToolCommands {
LocalConfiguration config = we.getConfiguration(); LocalConfiguration config = we.getConfiguration();
if (range > config.maxSuperPickaxeSize) { 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; return;
} }
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(player, new FloodFillTool(range, pattern)); 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( @Command(
@ -256,9 +256,9 @@ public class ToolCommands {
@CommandPermissions("worldedit.tool.deltree") @CommandPermissions("worldedit.tool.deltree")
public void deltree(Player player, LocalSession session) throws WorldEditException { public void deltree(Player player, LocalSession session) throws WorldEditException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
session.setTool(player, new FloatingTreeRemover()); 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( @Command(
@ -267,10 +267,9 @@ public class ToolCommands {
) )
@CommandPermissions("worldedit.tool.farwand") @CommandPermissions("worldedit.tool.farwand")
public void farwand(Player player, LocalSession session) throws WorldEditException { public void farwand(Player player, LocalSession session) throws WorldEditException {
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(player, new DistanceWand()); 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( @Command(
@ -284,10 +283,10 @@ public class ToolCommands {
Pattern primary, Pattern primary,
@Arg(desc = "Pattern to set on right-click") @Arg(desc = "Pattern to set on right-click")
Pattern secondary) throws WorldEditException { Pattern secondary) throws WorldEditException {
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(itemStack.getType(), new LongRangeBuildTool(primary, secondary)); final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
player.print("Long-range building tool bound to " + itemStack.getType().getName() + "."); session.setTool(player, new LongRangeBuildTool(primary, secondary));
player.printInfo(TranslatableComponent.of("worldedit.tool.lrbuild.equip", TextComponent.of(itemType.getName())));
String primaryName = "pattern"; String primaryName = "pattern";
String secondaryName = "pattern"; String secondaryName = "pattern";
if (primary instanceof BlockStateHolder) { if (primary instanceof BlockStateHolder) {
@ -296,7 +295,6 @@ public class ToolCommands {
if (secondary instanceof BlockStateHolder) { if (secondary instanceof BlockStateHolder) {
secondaryName = ((BlockStateHolder<?>) secondary).getBlockType().getName(); secondaryName = ((BlockStateHolder<?>) secondary).getBlockType().getName();
} }
player.print("Left-click set to " + primaryName + "; right-click set to " player.printInfo(TranslatableComponent.of("worldedit.tool.lrbuild.set", TextComponent.of(primaryName), TextComponent.of(secondaryName)));
+ secondaryName + ".");
} }
} }

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.BrushSettings; import com.boydti.fawe.object.brush.BrushSettings;
import com.boydti.fawe.object.brush.TargetMode; import com.boydti.fawe.object.brush.TargetMode;
import com.boydti.fawe.object.brush.scroll.Scroll; import com.boydti.fawe.object.brush.scroll.Scroll;
@ -44,6 +45,7 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.command.CommandArgParser; import com.sk89q.worldedit.internal.command.CommandArgParser;
import com.sk89q.worldedit.util.HandSide; 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.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
@ -78,11 +80,11 @@ public class ToolUtilCommands {
throws WorldEditException { throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
return; return;
} }
if (maskOpt == null) { if (maskOpt == null) {
player.print("Brush mask disabled."); player.print(TranslatableComponent.of("worldedit.tool.mask.disabled"));
tool.setMask(null); tool.setMask(null);
return; return;
} }
@ -91,7 +93,7 @@ public class ToolUtilCommands {
settings.addSetting(BrushSettings.SettingType.MASK, lastArg); settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
settings.setMask(maskOpt); settings.setMask(maskOpt);
tool.update(); tool.update();
player.print("Brush mask set."); player.print(TranslatableComponent.of("worldedit.tool.mask.set"));
} }
@Command( @Command(
@ -108,20 +110,19 @@ public class ToolUtilCommands {
Arguments arguments) throws WorldEditException { Arguments arguments) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
return; return;
} }
if (pattern == null) { if (pattern == null) {
player.print(BBC.BRUSH_MATERIAL.s());
tool.setFill(null); tool.setFill(null);
return; } else {
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext(); BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.setFill(pattern); settings.setFill(pattern);
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring(); String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.FILL, lastArg); settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
tool.update(); tool.update();
player.print(BBC.BRUSH_MATERIAL.s()); }
player.print(TranslatableComponent.of("worldedit.tool.material.set"));
} }
@Command( @Command(
@ -133,7 +134,7 @@ public class ToolUtilCommands {
@Arg(desc = "The range of the brush") @Arg(desc = "The range of the brush")
int range) throws WorldEditException { int range) throws WorldEditException {
session.getBrushTool(player, false).setRange(range); session.getBrushTool(player, false).setRange(range);
player.print("Brush range set."); player.printInfo(TranslatableComponent.of("worldedit.tool.range.set"));
} }
@Command( @Command(
@ -147,7 +148,7 @@ public class ToolUtilCommands {
we.checkMaxBrushRadius(size); we.checkMaxBrushRadius(size);
session.getBrushTool(player, false).setSize(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 //todo none should be moved to the same class where it is in upstream
@ -158,7 +159,7 @@ public class ToolUtilCommands {
) )
public void none(Player player, LocalSession session) throws WorldEditException { public void none(Player player, LocalSession session) throws WorldEditException {
session.setTool(player, null); session.setTool(player, null);
player.print(BBC.TOOL_NONE.s()); player.print(TranslatableComponent.of("fawe.worldedit.tool.tool.none"));
} }
@Command( @Command(
@ -172,9 +173,9 @@ public class ToolUtilCommands {
Mask maskOpt) throws WorldEditException { Mask maskOpt) throws WorldEditException {
session.getBrushTool(player, false).setTraceMask(maskOpt); session.getBrushTool(player, false).setTraceMask(maskOpt);
if (maskOpt == null) { if (maskOpt == null) {
player.print("Trace mask disabled."); player.printInfo(TranslatableComponent.of("worldedit.tool.tracemask.disabled"));
} else { } else {
player.print("Trace mask set."); player.printInfo(TranslatableComponent.of("worldedit.tool.tracemask.set"));
} }
} }
@ -189,15 +190,15 @@ public class ToolUtilCommands {
Boolean superPickaxe) { Boolean superPickaxe) {
boolean hasSuperPickAxe = session.hasSuperPickAxe(); boolean hasSuperPickAxe = session.hasSuperPickAxe();
if (superPickaxe != null && superPickaxe == 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; return;
} }
if (hasSuperPickAxe) { if (hasSuperPickAxe) {
session.disableSuperPickAxe(); session.disableSuperPickAxe();
player.print("Super pickaxe disabled."); player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.disabled"));
} else { } else {
session.enableSuperPickAxe(); session.enableSuperPickAxe();
player.print("Super pickaxe enabled."); player.printInfo(TranslatableComponent.of("worldedit.tool.superpickaxe.enabled"));
} }
} }
@ -258,13 +259,13 @@ public class ToolUtilCommands {
throws WorldEditException { throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
return; return;
} }
VisualMode[] modes = VisualMode.values(); VisualMode[] modes = VisualMode.values();
VisualMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)]; VisualMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
tool.setVisualMode(player, newMode); tool.setVisualMode(player, newMode);
BBC.BRUSH_VISUAL_MODE_SET.send(player, newMode); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.visual.mode.set" , newMode));
} }
@Command( @Command(
@ -277,13 +278,13 @@ public class ToolUtilCommands {
@Arg(name = "mode", desc = "int", def = "0") int mode) throws WorldEditException { @Arg(name = "mode", desc = "int", def = "0") int mode) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
return; return;
} }
TargetMode[] modes = TargetMode.values(); TargetMode[] modes = TargetMode.values();
TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)]; TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
tool.setTargetMode(newMode); tool.setTargetMode(newMode);
BBC.BRUSH_TARGET_MODE_SET.send(player, newMode); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.target.mode.set" , newMode));
} }
@Command( @Command(
@ -296,11 +297,11 @@ public class ToolUtilCommands {
int offset) throws WorldEditException { int offset) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
return; return;
} }
tool.setTargetOffset(offset); tool.setTargetOffset(offset);
BBC.BRUSH_TARGET_OFFSET_SET.send(player, offset); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.target.offset.set" , offset));
} }
@Command( @Command(
@ -317,7 +318,7 @@ public class ToolUtilCommands {
List<String> commandStr) throws WorldEditException { List<String> commandStr) throws WorldEditException {
BrushTool bt = session.getBrushTool(player, false); BrushTool bt = session.getBrushTool(player, false);
if (bt == null) { if (bt == null) {
player.print(BBC.BRUSH_NONE.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
return; return;
} }
@ -325,11 +326,11 @@ public class ToolUtilCommands {
Scroll action = Scroll.fromArguments(bt, player, session, mode, commandStr, true); Scroll action = Scroll.fromArguments(bt, player, session, mode, commandStr, true);
settings.setScrollAction(action); settings.setScrollAction(action);
if (mode == Scroll.Action.NONE) { if (mode == Scroll.Action.NONE) {
BBC.BRUSH_SCROLL_ACTION_UNSET.send(player); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.scroll.action.unset"));
} else if (action != null) { } else if (action != null) {
String full = (mode.name().toLowerCase() + " " + StringMan.join(commandStr, " ")).trim(); String full = (mode.name().toLowerCase() + " " + StringMan.join(commandStr, " ")).trim();
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full); settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
BBC.BRUSH_SCROLL_ACTION_SET.send(player, mode); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.scroll.action.set" , mode));
} }
bt.update(); bt.update();
} }
@ -351,11 +352,11 @@ public class ToolUtilCommands {
Arguments arguments) throws WorldEditException { Arguments arguments) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
return; return;
} }
if (maskArg == null) { if (maskArg == null) {
player.print(BBC.BRUSH_SOURCE_MASK_DISABLED.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.source.mask.disabled"));
tool.setSourceMask(null); tool.setSourceMask(null);
return; return;
} }
@ -364,7 +365,7 @@ public class ToolUtilCommands {
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg); settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
settings.setSourceMask(maskArg); settings.setSourceMask(maskArg);
tool.update(); tool.update();
player.print(BBC.BRUSH_SOURCE_MASK.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.source.mask"));
} }
@Command( @Command(
@ -379,11 +380,11 @@ public class ToolUtilCommands {
Arguments arguments) throws WorldEditException { Arguments arguments) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false); BrushTool tool = session.getBrushTool(player, false);
if (tool == null) { if (tool == null) {
player.print(BBC.BRUSH_NONE.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
return; return;
} }
if (transform == null) { if (transform == null) {
player.print(BBC.BRUSH_TRANSFORM_DISABLED.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.transform.disabled"));
tool.setTransform(null); tool.setTransform(null);
return; return;
} }
@ -392,6 +393,6 @@ public class ToolUtilCommands {
settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg); settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
settings.setTransform(transform); settings.setTransform(transform);
tool.update(); tool.update();
player.print(BBC.BRUSH_TRANSFORM.s()); player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.transform"));
} }
} }

View File

@ -23,6 +23,7 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.DelegateConsumer; import com.boydti.fawe.object.DelegateConsumer;
import com.boydti.fawe.object.function.QuadFunction; import com.boydti.fawe.object.function.QuadFunction;
@ -72,6 +73,7 @@ import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.awt.RenderingHints; import java.awt.RenderingHints;
@ -188,7 +190,7 @@ public class UtilityCommands {
@SkipQueue @SkipQueue
public void cancel(Player player) { public void cancel(Player player) {
int cancelled = player.cancel(false); int cancelled = player.cancel(false);
BBC.WORLDEDIT_CANCEL_COUNT.send(player, cancelled); player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.count" , cancelled));
} }
@Command( @Command(
@ -214,7 +216,7 @@ public class UtilityCommands {
BlockVector3 pos = session.getPlacementPosition(actor); BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillDirection(pos, pattern, radius, depth, direction); 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; return affected;
} }
@ -312,7 +314,7 @@ public class UtilityCommands {
BlockVector3 pos = session.getPlacementPosition(actor); BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillXZ(pos, pattern, radius, depth, true); 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; return affected;
} }
@ -330,9 +332,8 @@ public class UtilityCommands {
double radius = radiusExp.evaluate(); double radius = radiusExp.evaluate();
radius = Math.max(0, radius); radius = Math.max(0, radius);
we.checkMaxRadius(radius); we.checkMaxRadius(radius);
int affected = editSession.drainArea( int affected = editSession.drainArea(session.getPlacementPosition(actor), radius, waterlogged);
session.getPlacementPosition(actor), radius, waterlogged); actor.printInfo(TranslatableComponent.of("worldedit.drain.drained", TextComponent.of(affected)));
actor.print(affected + " block(s) have been changed.");
return affected; return affected;
} }
@ -349,7 +350,7 @@ public class UtilityCommands {
radius = Math.max(0, radius); radius = Math.max(0, radius);
we.checkMaxRadius(radius); we.checkMaxRadius(radius);
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.LAVA); 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; return affected;
} }
@ -366,7 +367,7 @@ public class UtilityCommands {
radius = Math.max(0, radius); radius = Math.max(0, radius);
we.checkMaxRadius(radius); we.checkMaxRadius(radius);
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.WATER); 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; return affected;
} }
@ -387,7 +388,7 @@ public class UtilityCommands {
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1); height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
int affected = editSession.removeAbove(session.getPlacementPosition(actor), size, height); 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; return affected;
} }
@ -408,7 +409,7 @@ public class UtilityCommands {
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1); height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
int affected = editSession.removeBelow(session.getPlacementPosition(actor), size, height); 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; return affected;
} }
@ -428,7 +429,7 @@ public class UtilityCommands {
we.checkMaxRadius(radius); we.checkMaxRadius(radius);
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, 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; return affected;
} }
@ -459,7 +460,7 @@ public class UtilityCommands {
} }
int affected = editSession.replaceBlocks(region, from, to); 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; return affected;
} }
@ -477,7 +478,7 @@ public class UtilityCommands {
we.checkMaxRadius(size); we.checkMaxRadius(size);
int affected = editSession.simulateSnow(session.getPlacementPosition(actor), 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; return affected;
} }
@ -495,7 +496,7 @@ public class UtilityCommands {
we.checkMaxRadius(size); we.checkMaxRadius(size);
int affected = editSession.thaw(session.getPlacementPosition(actor), 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; return affected;
} }
@ -516,7 +517,7 @@ public class UtilityCommands {
final boolean onlyNormalDirt = !convertCoarse; final boolean onlyNormalDirt = !convertCoarse;
final int affected = editSession.green(session.getPlacementPosition(actor), size, onlyNormalDirt); 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; return affected;
} }
@ -554,7 +555,7 @@ public class UtilityCommands {
) )
@CommandPermissions("worldedit.extinguish") @CommandPermissions("worldedit.extinguish")
@Logging(PLACEMENT) @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 = "") @Arg(desc = "The radius of the square to remove in", def = "")
Integer radius) throws WorldEditException { Integer radius) throws WorldEditException {
@ -566,7 +567,8 @@ public class UtilityCommands {
Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE); Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE);
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, size); 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( @Command(
@ -599,7 +601,7 @@ public class UtilityCommands {
if (radius == null) { if (radius == null) {
radius = config.butcherDefaultRadius; radius = config.butcherDefaultRadius;
} else if (radius < -1) { } 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; return 0;
} else if (radius == -1) { } else if (radius == -1) {
if (config.butcherMaxRadius != -1) { if (config.butcherMaxRadius != -1) {
@ -622,7 +624,11 @@ public class UtilityCommands {
int killed = killMatchingEntities(radius, actor, flags::createFunction); 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; return killed;
} }
@ -656,20 +662,19 @@ public class UtilityCommands {
@Arg(desc = "The radius of the cuboid to remove from") @Arg(desc = "The radius of the cuboid to remove from")
int radius) throws WorldEditException { int radius) throws WorldEditException {
if (radius < -1) { if (radius < -1) {
actor.printError("Use -1 to remove all entities in loaded chunks"); actor.printError(TranslatableComponent.of("worldedit.remove.explain-all"));
return 0; return 0;
} }
int removed = killMatchingEntities(radius, actor, remover::createFunction); int removed = killMatchingEntities(radius, actor, remover::createFunction);
actor.printInfo(TranslatableComponent.of("worldedit.remove.removed", TextComponent.of(removed)));
actor.print("Marked " + removed + (removed != 1 ? " entities" : " entity") + " for removal.");
return 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 DecimalFormat formatForLocale(Locale locale) {
private static final DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.getDefault()); DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(locale);
static { format.applyPattern("#,##0.#####");
formatter.applyPattern("#,##0.#####"); // pattern is locale-insensitive. this can translate to "1.234,56789" return format;
} }
@Command( @Command(
@ -685,16 +690,15 @@ public class UtilityCommands {
try { try {
expression = Expression.compile(String.join(" ", input)); expression = Expression.compile(String.join(" ", input));
} catch (ExpressionException e) { } catch (ExpressionException e) {
actor.printError(String.format( actor.printError(TranslatableComponent.of("worldedit.calc.invalid", TextComponent.of(String.join(" ", input))));
"'%s' could not be parsed as a valid expression", input));
return; return;
} }
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> { WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
double result = expression.evaluate( double result = expression.evaluate(
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout()); 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)); return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.GRAY));
}, null); }, (Component) null);
} }
@Command( @Command(
@ -705,7 +709,7 @@ public class UtilityCommands {
@CommandPermissions("fawe.confirm") @CommandPermissions("fawe.confirm")
public void confirm(Player fp) throws WorldEditException { public void confirm(Player fp) throws WorldEditException {
if (!fp.confirm()) { if (!fp.confirm()) {
BBC.NOTHING_CONFIRMED.send(fp); fp.print(TranslatableComponent.of("fawe.worldedit.utility.nothing.confirmed"));
} }
} }
@ -765,7 +769,7 @@ public class UtilityCommands {
getFiles(dir, actor, args, formatName, playerFolder, fileList::add); getFiles(dir, actor, args, formatName, playerFolder, fileList::add);
if (fileList.isEmpty()) { if (fileList.isEmpty()) {
BBC.SCHEMATIC_NONE.send(actor); actor.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.none"));
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweVersion; import com.boydti.fawe.FaweVersion;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.util.IncendoPaster; import com.boydti.fawe.util.IncendoPaster;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -36,9 +37,13 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; 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.Platform;
import com.sk89q.worldedit.extension.platform.PlatformManager; 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.io.IOException;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
@ -47,8 +52,8 @@ import java.time.format.TextStyle;
import java.time.zone.ZoneRulesException; import java.time.zone.ZoneRulesException;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
@ -78,35 +83,43 @@ public class WorldEditCommands {
actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92"); actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92");
if (fVer != null) { if (fVer != null) {
actor.printDebug("----------- Platforms -----------");
FaweVersion version = Fawe.get().getVersion(); FaweVersion version = Fawe.get().getVersion();
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day) Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day)
.getTime(); .getTime();
actor.printDebug(" - DATE: " + date.toLocaleString());
actor.printDebug(" - COMMIT: " + Integer.toHexString(version.hash)); TextComponent dateArg = TextComponent.of(date.toLocaleString());
actor.printDebug(" - BUILD: " + version.build); TextComponent commitArg = TextComponent.of(Integer.toHexString(version.hash));
actor.printDebug(" - PLATFORM: " + Settings.IMP.PLATFORM); TextComponent buildArg = TextComponent.of(version.build);
actor.printDebug("------------------------------------"); 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(); PlatformManager pm = we.getPlatformManager();
actor.printDebug("----------- Platforms -----------"); TextComponentProducer producer = new TextComponentProducer();
for (Platform platform : pm.getPlatforms()) { for (Platform platform : pm.getPlatforms()) {
actor.printDebug(String.format("* %s (%s)", platform.getPlatformName(), platform.getPlatformVersion())); producer.append(
TextComponent.of("* ", TextColor.GRAY)
.append(TextComponent.of(platform.getPlatformName()))
.append(TextComponent.of("(" + platform.getPlatformVersion() + ")"))
).newline();
} }
actor.print(new MessageBox("Platforms", producer, TextColor.GRAY).create());
actor.printDebug("----------- Capabilities -----------"); producer.reset();
for (Capability capability : Capability.values()) { for (Capability capability : Capability.values()) {
try {
Platform platform = pm.queryCapability(capability); Platform platform = pm.queryCapability(capability);
actor.printDebug(String.format("%s: %s", capability.name(), producer.append(
platform != null ? platform.getPlatformName() : "NONE")); TextComponent.of(capability.name(), TextColor.GRAY)
} catch (NoCapablePlatformException e) { .append(TextComponent.of(": ")
actor.printDebug(String.format("%s: %s", capability.name(), "NONE")); .append(TextComponent.of(platform != null ? platform.getPlatformName() : "NONE")))
).newline();
} }
} actor.print(new MessageBox("Capabilities", producer, TextColor.GRAY).create());
actor.printDebug("");
actor.printDebug("Wiki: https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki");
} }
@Command( @Command(
@ -118,7 +131,7 @@ public class WorldEditCommands {
we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload(); we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload();
we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration())); we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
Fawe.get().setupConfigs(); Fawe.get().setupConfigs();
actor.print("Configuration and translations reloaded!"); actor.printInfo(TranslatableComponent.of("worldedit.reload.config"));
} }
@Command( @Command(
@ -129,7 +142,8 @@ public class WorldEditCommands {
@SkipQueue @SkipQueue
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"}) @CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
public void report(Actor actor) throws WorldEditException, IOException { 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)));
} }
@Command( @Command(
@ -172,12 +186,13 @@ public class WorldEditCommands {
try { try {
ZoneId tz = ZoneId.of(timezone); ZoneId tz = ZoneId.of(timezone);
session.setTimezone(tz); session.setTimezone(tz);
actor.print("Timezone set for this session to: " + tz.getDisplayName( actor.printInfo(TranslatableComponent.of("worldedit.timezone.set", TextComponent.of(tz.getDisplayName(
TextStyle.FULL, Locale.ENGLISH TextStyle.FULL, actor.getLocale()
)); ))));
actor.print("The current time in that timezone is: " + dateFormat.format(ZonedDateTime.now(tz))); actor.print(TranslatableComponent.of("worldedit.timezone.current",
TextComponent.of(dateFormat.withLocale(actor.getLocale()).format(ZonedDateTime.now(tz)))));
} catch (ZoneRulesException e) { } catch (ZoneRulesException e) {
actor.printError("Invalid timezone"); actor.printError(TranslatableComponent.of("worldedit.timezone.invalid"));
} }
} }

View File

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

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
@ -31,6 +32,8 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Location; 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.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -62,12 +65,12 @@ public class BlockDataCyler implements DoubleActionBlockTool {
if (!config.allowedDataCycleBlocks.isEmpty() if (!config.allowedDataCycleBlocks.isEmpty()
&& !player.hasPermission("worldedit.override.data-cycler") && !player.hasPermission("worldedit.override.data-cycler")
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) { && !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; return true;
} }
if (block.getStates().keySet().isEmpty()) { if (block.getStates().keySet().isEmpty()) {
player.printError(BBC.BLOCK_CYCLER_CANNOT_CYCLE.s()); player.printError(TranslatableComponent.of("worldedit.tool.data-cycler.cant-cycle"));
} else { } else {
Property<?> currentProperty = selectedProperties.get(player.getUniqueId()); Property<?> currentProperty = selectedProperties.get(player.getUniqueId());
@ -89,9 +92,13 @@ public class BlockDataCyler implements DoubleActionBlockTool {
try { try {
editSession.setBlock(blockPoint, newBlock); 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) { } catch (MaxChangedBlocksException e) {
player.printError(BBC.BLOCK_CYCLER_LIMIT.s()); player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
} finally { } finally {
session.remember(editSession); session.remember(editSession);
} }
@ -102,7 +109,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
index = (index + 1) % properties.size(); index = (index + 1) % properties.size();
currentProperty = properties.get(index); currentProperty = properties.get(index);
selectedProperties.put(player.getUniqueId(), currentProperty); selectedProperties.put(player.getUniqueId(), currentProperty);
player.print("Now cycling " + currentProperty.getName()); player.printInfo(TranslatableComponent.of("worldedit.tool.data-cycler.cycling", TextComponent.of(currentProperty.getName())));
} }
} }

View File

@ -30,6 +30,8 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location; 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; import com.sk89q.worldedit.world.block.BaseBlock;
/** /**
@ -76,7 +78,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
if (targetBlock != null) { if (targetBlock != null) {
pattern = targetBlock; 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; return true;

View File

@ -28,6 +28,7 @@ import com.boydti.fawe.beta.implementation.IChunkExtent;
import com.boydti.fawe.beta.implementation.processors.NullProcessor; import com.boydti.fawe.beta.implementation.processors.NullProcessor;
import com.boydti.fawe.beta.implementation.processors.PersistentChunkSendProcessor; import com.boydti.fawe.beta.implementation.processors.PersistentChunkSendProcessor;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.brush.BrushSettings; import com.boydti.fawe.object.brush.BrushSettings;
import com.boydti.fawe.object.brush.MovableTool; import com.boydti.fawe.object.brush.MovableTool;
@ -86,6 +87,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
@ -499,7 +501,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (brush == null) return false; if (brush == null) return false;
if (current.setWorld(player.getWorld().getName()) && !current.canUse(player)) { if (current.setWorld(player.getWorld().getName()) && !current.canUse(player)) {
BBC.NO_PERM.send(player, StringMan.join(current.getPermissions(), ",")); player.print(TranslatableComponent.of("fawe.error.no.perm" , StringMan.join(current.getPermissions(), ",")));
return false; return false;
} }
try (EditSession editSession = session.createEditSession(player)) { try (EditSession editSession = session.createEditSession(player)) {
@ -507,7 +509,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (target == null) { if (target == null) {
editSession.cancel(); editSession.cancel();
player.print(BBC.NO_BLOCK.s()); player.printError(TranslatableComponent.of("worldedit.tool.no-block"));
return true; return true;
} }
BlockBag bag = session.getBlockBag(player); BlockBag bag = session.getBlockBag(player);
@ -542,7 +544,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
WorldEdit.getInstance().checkMaxBrushRadius(size); WorldEdit.getInstance().checkMaxBrushRadius(size);
brush.build(editSession, target.toBlockPoint(), current.getMaterial(), size); brush.build(editSession, target.toBlockPoint(), current.getMaterial(), size);
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached."); player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
} finally { } finally {
session.remember(editSession); session.remember(editSession);
if (bag != null) { if (bag != null) {

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
@ -29,6 +30,7 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
/** /**
* A wand that can be used at a distance. * A wand that can be used at a distance.
@ -75,7 +77,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
} }
if (target == null) { if (target == null) {
player.printError(BBC.NO_BLOCK.s()); player.printError(TranslatableComponent.of("worldedit.tool.no-block"));
return null; return null;
} }

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
@ -32,6 +33,7 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location; 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.World;
import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -74,7 +76,7 @@ public class FloatingTreeRemover implements BlockTool {
final BlockState state = world.getBlock(clicked.toVector().toBlockPoint()); final BlockState state = world.getBlock(clicked.toVector().toBlockPoint());
if (!isTreeBlock(state.getBlockType())) { if (!isTreeBlock(state.getBlockType())) {
player.printError(BBC.TOOL_DELTREE_ERROR.s()); player.printError(TranslatableComponent.of("worldedit.tool.deltree.not-tree"));
return true; return true;
} }
@ -82,7 +84,7 @@ public class FloatingTreeRemover implements BlockTool {
try { try {
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint()); final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
if (blockSet == null) { if (blockSet == null) {
player.printError(BBC.TOOL_DELTREE_FLOATING_ERROR.s()); player.printError(TranslatableComponent.of("worldedit.tool.deltree.not-floating"));
return true; return true;
} }
@ -93,7 +95,7 @@ public class FloatingTreeRemover implements BlockTool {
} }
} }
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached."); player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
} finally { } finally {
session.remember(editSession); session.remember(editSession);
} }

View File

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

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -32,6 +33,7 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
/** /**
@ -119,7 +121,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
} }
if (target == null) { if (target == null) {
player.printError(BBC.NO_BLOCK.s()); player.printError(TranslatableComponent.of("worldedit.tool.no-block"));
return null; return null;
} }

View File

@ -25,6 +25,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
public enum NavigationWand implements DoubleActionTraceTool { public enum NavigationWand implements DoubleActionTraceTool {
INSTANCE; INSTANCE;
@ -39,7 +40,7 @@ public enum NavigationWand implements DoubleActionTraceTool {
if (pos != null) { if (pos != null) {
player.findFreePosition(pos); player.findFreePosition(pos);
} else { } else {
player.printError("No block in sight (or too far)!"); player.printError(TranslatableComponent.of("worldedit.jumpto.none"));
} }
return true; return true;
} }
@ -52,7 +53,7 @@ public enum NavigationWand implements DoubleActionTraceTool {
} }
if (!player.passThroughForwardWall(Math.max(1, maxDist - 10))) { if (!player.passThroughForwardWall(Math.max(1, maxDist - 10))) {
player.printError("Nothing to pass through (or too far)!"); player.printError(TranslatableComponent.of("worldedit.thru.obstructed"));
} }
return true; return true;
} }

View File

@ -29,6 +29,7 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.TextComponent; 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.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World; 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("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE));
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW)); builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY) builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state")))); .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.blockstate.hover"))));
final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState()); final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
if (internalId.isPresent()) { if (internalId.isPresent()) {
builder.append(TextComponent.of(" (" + internalId.getAsInt() + ") ", TextColor.DARK_GRAY) builder.append(TextComponent.of(" (" + internalId.getAsInt() + ") ", TextColor.DARK_GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Internal ID")))); .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.internalid.hover"))));
} }
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/" builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE) + world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above")))); .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.light.hover"))));
player.print(builder.build()); player.print(builder.build());

View File

@ -32,6 +32,7 @@ import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location; 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.World;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;

View File

@ -28,6 +28,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location; 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.World;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -56,7 +57,7 @@ public class SinglePickaxe implements BlockTool {
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState()); editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
session.remember(editSession); session.remember(editSession);
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached."); player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
} }
return true; return true;

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
@ -31,6 +32,7 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
/** /**
* Plants a tree. * Plants a tree.
@ -64,10 +66,10 @@ public class TreePlanter implements BlockTool {
} }
if (!successful) { if (!successful) {
player.printError(BBC.TOOL_TREE_ERROR_BLOCK.s()); player.printError(TranslatableComponent.of("worldedit.tool.tree.obstructed"));
} }
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {
player.printError(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES.s()); player.printError(TranslatableComponent.of("worldedit.tool.max-block-changes"));
} finally { } finally {
session.remember(editSession); session.remember(editSession);
} }

View File

@ -55,7 +55,7 @@ public final class AsyncCommandBuilder<T> {
@Nullable @Nullable
private String description; private String description;
@Nullable @Nullable
private String delayMessage; private Component delayMessage;
@Nullable @Nullable
private Component successMessage; private Component successMessage;
@ -84,7 +84,12 @@ public final class AsyncCommandBuilder<T> {
return this; return this;
} }
@Deprecated
public AsyncCommandBuilder<T> sendMessageAfterDelay(String message) { public AsyncCommandBuilder<T> sendMessageAfterDelay(String message) {
return sendMessageAfterDelay(TextComponent.of(checkNotNull(message)));
}
public AsyncCommandBuilder<T> sendMessageAfterDelay(Component message) {
this.delayMessage = checkNotNull(message); this.delayMessage = checkNotNull(message);
return this; return this;
} }
@ -98,7 +103,7 @@ public final class AsyncCommandBuilder<T> {
public AsyncCommandBuilder<T> onSuccess(@Nullable String message, @Nullable Consumer<T> consumer) { public AsyncCommandBuilder<T> onSuccess(@Nullable String message, @Nullable Consumer<T> consumer) {
checkArgument(message != null || consumer != null, "Can't have null message AND consumer"); checkArgument(message != null || consumer != null, "Can't have null message AND consumer");
this.successMessage = message == null ? null : TextComponent.of(message, TextColor.LIGHT_PURPLE); this.successMessage = message == null ? null : TextComponent.of(message, TextColor.GRAY);
this.consumer = consumer; this.consumer = consumer;
return this; return this;
} }

View File

@ -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.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.MoreExecutors;
import com.sk89q.worldedit.extension.platform.Actor; 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; import java.util.Timer;
@ -34,7 +36,12 @@ public class FutureProgressListener implements Runnable {
private final MessageTimerTask task; private final MessageTimerTask task;
@Deprecated
public FutureProgressListener(Actor sender, String message) { public FutureProgressListener(Actor sender, String message) {
this(sender, TextComponent.of(message));
}
public FutureProgressListener(Actor sender, Component message) {
checkNotNull(sender); checkNotNull(sender);
checkNotNull(message); checkNotNull(message);
@ -47,8 +54,13 @@ public class FutureProgressListener implements Runnable {
task.cancel(); task.cancel();
} }
@Deprecated
public static void addProgressListener(ListenableFuture<?> future, Actor sender, String message) { public static void addProgressListener(ListenableFuture<?> future, Actor sender, String message) {
future.addListener(new FutureProgressListener(sender, message), MoreExecutors.directExecutor()); 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());
}
} }

View File

@ -22,15 +22,22 @@ package com.sk89q.worldedit.command.util;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extension.platform.Actor; 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; import java.util.TimerTask;
public class MessageTimerTask extends TimerTask { public class MessageTimerTask extends TimerTask {
private final Actor sender; private final Actor sender;
private final String message; private final Component message;
@Deprecated
MessageTimerTask(Actor sender, String message) { MessageTimerTask(Actor sender, String message) {
this(sender, TextComponent.of(message));
}
MessageTimerTask(Actor sender, Component message) {
checkNotNull(sender); checkNotNull(sender);
checkNotNull(message); checkNotNull(message);

View File

@ -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.CommandListBox;
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox; import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
import com.sk89q.worldedit.util.formatting.component.InvalidComponentException; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -76,7 +78,7 @@ public class PrintCommandHelp {
List<Command> visited = new ArrayList<>(); List<Command> visited = new ArrayList<>();
Command currentCommand = detectCommand(manager, commandPath.get(0)); Command currentCommand = detectCommand(manager, commandPath.get(0));
if (currentCommand == null) { 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; return;
} }
visited.add(currentCommand); visited.add(currentCommand);
@ -87,8 +89,8 @@ public class PrintCommandHelp {
Map<String, Command> subCommands = getSubCommands(currentCommand); Map<String, Command> subCommands = getSubCommands(currentCommand);
if (subCommands.isEmpty()) { if (subCommands.isEmpty()) {
actor.printError(String.format("'%s' has no sub-commands. (Maybe '%s' is for a parameter?)", actor.printError(TranslatableComponent.of("worldedit.help.no-subcommands",
toCommandString(visited), subCommand)); TextComponent.of(toCommandString(visited)), TextComponent.of(subCommand)));
// full help for single command // full help for single command
CommandUsageBox box = new CommandUsageBox(visited, visited.stream() CommandUsageBox box = new CommandUsageBox(visited, visited.stream()
.map(Command::getName).collect(Collectors.joining(" ")), helpRootCommand); .map(Command::getName).collect(Collectors.joining(" ")), helpRootCommand);
@ -100,8 +102,8 @@ public class PrintCommandHelp {
currentCommand = subCommands.get(subCommand); currentCommand = subCommands.get(subCommand);
visited.add(currentCommand); visited.add(currentCommand);
} else { } else {
actor.printError(String.format("The sub-command '%s' under '%s' could not be found.", actor.printError(TranslatableComponent.of("worldedit.help.subcommand-not-found",
subCommand, toCommandString(visited))); TextComponent.of(subCommand), TextComponent.of(toCommandString(visited))));
// list subcommands for currentCommand // list subcommands for currentCommand
printCommands(page, getSubCommands(Iterables.getLast(visited)).values().stream(), actor, visited, helpRootCommand); printCommands(page, getSubCommands(Iterables.getLast(visited)).values().stream(), actor, visited, helpRootCommand);
return; return;

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command.util;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -33,13 +34,18 @@ public final class WorldEditAsyncCommandBuilder {
private WorldEditAsyncCommandBuilder() { private WorldEditAsyncCommandBuilder() {
} }
@Deprecated
public static void createAndSendMessage(Actor actor, Callable<Component> task, @Nullable String desc) { 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); final AsyncCommandBuilder<Component> builder = AsyncCommandBuilder.wrap(task, actor);
if (desc != null) { if (desc != null) {
builder.sendMessageAfterDelay(desc); builder.sendMessageAfterDelay(desc);
} }
builder builder
.onSuccess((String) null, actor::print) .onSuccess((String) null, actor::printInfo)
.onFailure((String) null, WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getExceptionConverter()) .onFailure((String) null, WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getExceptionConverter())
.buildAndExec(WorldEdit.getInstance().getExecutorService()); .buildAndExec(WorldEdit.getInstance().getExecutorService());
} }

View File

@ -2,6 +2,7 @@ package com.sk89q.worldedit.command.util.annotation;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.util.task.InterruptableCondition; import com.boydti.fawe.util.task.InterruptableCondition;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -47,7 +48,7 @@ public @interface Confirm {
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1) * (int) value; long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1) * (int) value;
if (area > 2 << 18) { if (area > 2 << 18) {
BBC.WORLDEDIT_CANCEL_REASON_CONFIRM_REGION.send(actor, min, max, getArgs(context)); actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , min, max, getArgs(context)));
return confirm(actor, context); return confirm(actor, context);
} }
return true; return true;
@ -58,7 +59,7 @@ public @interface Confirm {
public boolean passes(Actor actor, InjectedValueAccess context, double value) { public boolean passes(Actor actor, InjectedValueAccess context, double value) {
int max = WorldEdit.getInstance().getConfiguration().maxRadius; int max = WorldEdit.getInstance().getConfiguration().maxRadius;
if (value > max) { if (value > max) {
BBC.WORLDEDIT_CANCEL_REASON_CONFIRM_REGION.send(actor, value, max, getArgs(context)); actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context)));
return Processor.confirm(actor, context); return Processor.confirm(actor, context);
} }
return true; return true;
@ -69,7 +70,7 @@ public @interface Confirm {
public boolean passes(Actor actor, InjectedValueAccess context, double value) { public boolean passes(Actor actor, InjectedValueAccess context, double value) {
int max = 50;// TODO configurable, get Key.of(Method.class) @Limit int max = 50;// TODO configurable, get Key.of(Method.class) @Limit
if (value > max) { if (value > max) {
BBC.WORLDEDIT_CANCEL_REASON_CONFIRM_REGION.send(actor, value, max, getArgs(context)); actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context)));
return Processor.confirm(actor, context); return Processor.confirm(actor, context);
} }
return true; return true;
@ -78,7 +79,7 @@ public @interface Confirm {
ALWAYS { ALWAYS {
@Override @Override
public boolean passes(Actor actor, InjectedValueAccess context, double value) { public boolean passes(Actor actor, InjectedValueAccess context, double value) {
BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.send(actor); actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm"));
return confirm(actor, context); return confirm(actor, context);
} }
} }

View File

@ -45,6 +45,7 @@ import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -375,7 +376,7 @@ public interface Player extends Entity, Actor {
} }
} }
void sendTitle(String title, String sub); void sendTitle(Component title, Component sub);
/** /**
* Loads any history items from disk: - Should already be called if history on disk is enabled * Loads any history items from disk: - Should already be called if history on disk is enabled

View File

@ -23,6 +23,7 @@ import com.google.common.collect.Maps;
import com.boydti.fawe.command.SuggestInputParseException; import com.boydti.fawe.command.SuggestInputParseException;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.jnbt.JSON2NBT; import com.boydti.fawe.jnbt.JSON2NBT;
import com.boydti.fawe.jnbt.NBTException; import com.boydti.fawe.jnbt.NBTException;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
@ -424,7 +425,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (context.isRestricted()) { if (context.isRestricted()) {
Actor actor = context.requireActor(); Actor actor = context.requireActor();
if (!actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().checkDisallowedBlocks(holder)) { if (!actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().checkDisallowedBlocks(holder)) {
throw new DisallowedUsageException(BBC.BLOCK_NOT_ALLOWED + " '" + holder + "'"); throw new DisallowedUsageException(TranslatableComponent.of("fawe.error.block.not.allowed") + " '" + holder + "'");
} }
CompoundTag nbt = holder.getNbtData(); CompoundTag nbt = holder.getNbtData();
if (nbt != null) { if (nbt != null) {

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.extension.factory.parser.mask;
import com.boydti.fawe.command.FaweParser; import com.boydti.fawe.command.FaweParser;
import com.boydti.fawe.command.SuggestInputParseException; import com.boydti.fawe.command.SuggestInputParseException;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.CommandException;
@ -149,7 +150,7 @@ public class DefaultMaskParser extends FaweParser<Mask> {
input = input.substring(input.indexOf(char0) + 1); input = input.substring(input.indexOf(char0) + 1);
mask = parseFromInput(char0 + "[" + input + "]", context); mask = parseFromInput(char0 + "[" + input + "]", context);
if (actor != null) { if (actor != null) {
BBC.COMMAND_CLARIFYING_BRACKET.send(actor, char0 + "[" + input + "]"); actor.print(TranslatableComponent.of("fawe.worldedit.help.command.clarifying.bracket" , char0 + "[" + input + "]"));
} }
return mask; return mask;
} }

View File

@ -75,7 +75,7 @@ public abstract class AbstractNonPlayerActor implements Actor {
} else { } else {
FaweException fe = FaweException.get(throwable); FaweException fe = FaweException.get(throwable);
if (fe != null) { if (fe != null) {
printError(fe.getMessage()); printError(fe.getComponent());
} else { } else {
throwable.printStackTrace(); throwable.printStackTrace();
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.task.SimpleAsyncNotifyQueue; import com.boydti.fawe.object.task.SimpleAsyncNotifyQueue;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
@ -56,6 +57,7 @@ import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.TargetBlock;
import com.sk89q.worldedit.util.auth.AuthorizationException; 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.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -110,7 +112,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
} else { } else {
FaweException fe = FaweException.get(throwable); FaweException fe = FaweException.get(throwable);
if (fe != null) { if (fe != null) {
printError(fe.getMessage()); printError(fe.getComponent());
} else { } else {
throwable.printStackTrace(); throwable.printStackTrace();
} }
@ -358,10 +360,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
.isMovementBlocker()) { .isMovementBlocker()) {
int platformY = Math.max(initialY, y - 3 - clearance); int platformY = Math.max(initialY, y - 3 - clearance);
if (platformY < initialY) { // if ==, they already have the given clearance, if <, clearance is too large if (platformY < initialY) { // if ==, they already have the given clearance, if <, clearance is too large
printError("Not enough space above you!");
return false; return false;
} else if (platformY == initialY) { } else if (platformY == initialY) {
printError("You're already at the ceiling.");
return false; return false;
} }
floatAt(x, platformY + 1, z, alwaysGlass); floatAt(x, platformY + 1, z, alwaysGlass);
@ -590,13 +590,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public File openFileOpenDialog(String[] extensions) { public File openFileOpenDialog(String[] extensions) {
printError("File dialogs are not supported in your environment."); printError(TranslatableComponent.of("worldedit.platform.no-file-dialog"));
return null; return null;
} }
@Override @Override
public File openFileSaveDialog(String[] extensions) { public File openFileSaveDialog(String[] extensions) {
printError("File dialogs are not supported in your environment."); printError(TranslatableComponent.of("worldedit.platform.no-file-dialog"));
return null; return null;
} }
@ -645,7 +645,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
} }
@SuppressWarnings("CloneDoesntCallSuperClone")
@Override @Override
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException("Not supported"); throw new CloneNotSupportedException("Not supported");

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.platform;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.brush.visualization.VirtualWorld;
@ -38,6 +39,7 @@ import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.auth.Subject; import com.sk89q.worldedit.util.auth.Subject;
import com.sk89q.worldedit.util.formatting.text.Component; 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.enginehub.piston.inject.InjectedValueAccess;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -45,6 +47,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Condition;
import java.util.Locale;
/** /**
* An object that can perform actions in WorldEdit. * An object that can perform actions in WorldEdit.
@ -71,30 +74,56 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
* Print a message. * Print a message.
* *
* @param msg The message text * @param msg The message text
* @deprecated Use component-based functions (print)
*/ */
@Deprecated
void printRaw(String msg); void printRaw(String msg);
/** /**
* Print a WorldEdit message. * Print a WorldEdit message.
* *
* @param msg The message text * @param msg The message text
* @deprecated Use component-based functions (printDebug)
*/ */
@Deprecated
void printDebug(String msg); void printDebug(String msg);
/** /**
* Print a WorldEdit message. * Print a WorldEdit message.
* *
* @param msg The message text * @param msg The message text
* @deprecated Use component-based functions (printInfo)
*/ */
@Deprecated
void print(String msg); void print(String msg);
/** /**
* Print a WorldEdit error. * Print a WorldEdit error.
* *
* @param msg The error message text * @param msg The error message text
* @deprecated Use component-based functions (printError)
*/ */
@Deprecated
void printError(String msg); 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.GRAY));
}
/** /**
* Print a {@link Component}. * Print a {@link Component}.
* *
@ -109,6 +138,15 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
*/ */
boolean canDestroyBedrock(); 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. * Return whether this actor is a player.
* *
@ -232,4 +270,11 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
} }
return cancelled; return cancelled;
} }
/**
* Get the locale of this actor.
*
* @return The locale
*/
Locale getLocale();
} }

View File

@ -25,6 +25,7 @@ import com.boydti.fawe.command.AnvilCommandsRegistration;
import com.boydti.fawe.command.CFICommands; import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.command.CFICommandsRegistration; import com.boydti.fawe.command.CFICommandsRegistration;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.changeset.CFIChangeSet; import com.boydti.fawe.object.changeset.CFIChangeSet;
@ -736,7 +737,7 @@ public final class PlatformCommandManager {
actor.print(e.getRichMessage()); actor.print(e.getRichMessage());
} }
} catch (FaweException e) { } catch (FaweException e) {
actor.printError("Edit cancelled: " + e.getMessage()); actor.printError(TextComponent.builder().append("Edit cancelled: ").append(e.getComponent()).build());
} catch (UsageException e) { } catch (UsageException e) {
ImmutableList<Command> cmd = e.getCommands(); ImmutableList<Command> cmd = e.getCommands();
if (!cmd.isEmpty()) { if (!cmd.isEmpty()) {
@ -774,9 +775,14 @@ public final class PlatformCommandManager {
editSession.flushQueue(); editSession.flushQueue();
session.remember(editSession); session.remember(editSession);
long time = System.currentTimeMillis() - start; long timems = System.currentTimeMillis() - start;
if (time > 1000) { if (timems > 1000) {
BBC.ACTION_COMPLETE.send(actor, time / 1000D); actor.printDebug(TranslatableComponent.of(
"worldedit.command.time-elapsed",
TextComponent.of(timems + "m"),
TextComponent.of(-1),
TextComponent.of(Math.round(-1))
));
} }
worldEdit.flushBlockBag(actor, editSession); worldEdit.flushBlockBag(actor, editSession);
@ -813,7 +819,7 @@ public final class PlatformCommandManager {
store.injectValue(Key.of(Player.class), ValueProvider.constant((Player) actor)); store.injectValue(Key.of(Player.class), ValueProvider.constant((Player) actor));
} else { } else {
store.injectValue(Key.of(Player.class), context -> { 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)); store.injectValue(Key.of(Arguments.class), ValueProvider.constant(arguments));
@ -831,8 +837,8 @@ public final class PlatformCommandManager {
} }
private void handleUnknownException(Actor actor, Throwable t) { private void handleUnknownException(Actor actor, Throwable t) {
actor.printError("Please report this error: [See console]"); actor.printError(TranslatableComponent.of("worldedit.command.error.report"));
actor.printRaw(t.getClass().getName() + ": " + t.getMessage()); actor.print(TextComponent.of(t.getClass().getName() + ": " + t.getMessage()));
log.error("An unexpected error while handling a WorldEdit command", t); log.error("An unexpected error while handling a WorldEdit command", t);
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.extension.platform;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.pattern.PatternTraverser; import com.boydti.fawe.object.pattern.PatternTraverser;
@ -385,7 +386,7 @@ public class PlatformManager {
public void handleThrowable(Throwable e, Actor actor) { public void handleThrowable(Throwable e, Actor actor) {
FaweException faweException = FaweException.get(e); FaweException faweException = FaweException.get(e);
if (faweException != null) { if (faweException != null) {
BBC.WORLDEDIT_CANCEL_REASON.send(actor, faweException.getMessage()); actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason" , faweException.getComponent()));
} else { } else {
actor.printError("Please report this error: [See console]"); actor.printError("Please report this error: [See console]");
actor.printRaw(e.getClass().getName() + ": " + e.getMessage()); actor.printRaw(e.getClass().getName() + ": " + e.getMessage());
@ -437,7 +438,7 @@ public class PlatformManager {
} catch (Throwable e) { } catch (Throwable e) {
FaweException faweException = FaweException.get(e); FaweException faweException = FaweException.get(e);
if (faweException != null) { if (faweException != null) {
BBC.WORLDEDIT_CANCEL_REASON.send(player, faweException.getMessage()); player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason" , faweException.getComponent()));
} else { } else {
player.printError("Please report this error: [See console]"); player.printError("Please report this error: [See console]");
player.printRaw(e.getClass().getName() + ": " + e.getMessage()); player.printRaw(e.getClass().getName() + ": " + e.getMessage());

View File

@ -34,9 +34,12 @@ import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.Component; 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.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Locale;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -141,22 +144,22 @@ public class PlayerProxy extends AbstractPlayerActor {
@Override @Override
public void printRaw(String msg) { public void printRaw(String msg) {
basePlayer.printRaw(msg); basePlayer.print(TextComponent.of(msg));
} }
@Override @Override
public void printDebug(String msg) { public void printDebug(String msg) {
basePlayer.printDebug(msg); basePlayer.printDebug(TextComponent.of(msg));
} }
@Override @Override
public void print(String msg) { public void print(String msg) {
basePlayer.print(msg); basePlayer.printInfo(TextComponent.of(msg));
} }
@Override @Override
public void printError(String msg) { public void printError(String msg) {
basePlayer.printError(msg); basePlayer.printError(TextComponent.of(msg));
} }
@Override @Override
@ -214,7 +217,7 @@ public class PlayerProxy extends AbstractPlayerActor {
} }
@Override @Override
public void sendTitle(String title, String sub) { public void sendTitle(Component title, Component sub) {
basePlayer.sendTitle(title, sub); basePlayer.sendTitle(title, sub);
} }
@ -226,4 +229,9 @@ public class PlayerProxy extends AbstractPlayerActor {
public void floatAt(int x, int y, int z, boolean alwaysGlass) { public void floatAt(int x, int y, int z, boolean alwaysGlass) {
basePlayer.floatAt(x, y, z, alwaysGlass); basePlayer.floatAt(x, y, z, alwaysGlass);
} }
@Override
public Locale getLocale() {
return basePlayer.getLocale();
}
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.extent.clipboard.io;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.clipboard.LazyClipboardHolder; import com.boydti.fawe.object.clipboard.LazyClipboardHolder;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
@ -170,7 +171,7 @@ public class ClipboardFormats {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
if (input.startsWith("url:")) { if (input.startsWith("url:")) {
if (!player.hasPermission("worldedit.schematic.load.web")) { if (!player.hasPermission("worldedit.schematic.load.web")) {
if (message) BBC.NO_PERM.send(player, "worldedit.schematic.load.web"); if (message) player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.web"));
return null; return null;
} }
URL base = new URL(Settings.IMP.WEB.URL); URL base = new URL(Settings.IMP.WEB.URL);
@ -178,19 +179,19 @@ public class ClipboardFormats {
} }
if (input.startsWith("http")) { if (input.startsWith("http")) {
if (!player.hasPermission("worldedit.schematic.load.asset")) { if (!player.hasPermission("worldedit.schematic.load.asset")) {
if (message) BBC.NO_PERM.send(player, "worldedit.schematic.load.asset"); if (message) player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.asset"));
return null; return null;
} }
URL url = new URL(input); URL url = new URL(input);
URL webInterface = new URL(Settings.IMP.WEB.ASSETS); URL webInterface = new URL(Settings.IMP.WEB.ASSETS);
if (!url.getHost().equalsIgnoreCase(webInterface.getHost())) { if (!url.getHost().equalsIgnoreCase(webInterface.getHost())) {
if (message) BBC.WEB_UNAUTHORIZED.send(player, url); if (message) player.print(TranslatableComponent.of("fawe.error.web.unauthorized", url));
return null; return null;
} }
return loadAllFromUrl(url); return loadAllFromUrl(url);
} else { } else {
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) {
BBC.NO_PERM.send(player, "worldedit.schematic.load.other"); player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.other"));
return null; return null;
} }
File working = worldEdit.getWorkingDirectoryFile(config.saveDir); File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
@ -210,7 +211,7 @@ public class ClipboardFormats {
} }
} else { } else {
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) {
if (message) BBC.NO_PERM.send(player, "worldedit.schematic.load.other"); if (message) player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.other"));
return null; return null;
} }
if (format == null && input.matches(".*\\.[\\w].*")) { if (format == null && input.matches(".*\\.[\\w].*")) {
@ -232,12 +233,12 @@ public class ClipboardFormats {
if (format == null && f.isFile()) { if (format == null && f.isFile()) {
format = findByFile(f); format = findByFile(f);
if (format == null) { if (format == null) {
BBC.CLIPBOARD_INVALID_FORMAT.send(player, f.getName()); player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.invalid.format" , f.getName()));
return null; return null;
} }
} }
if (!f.exists()) { if (!f.exists()) {
if (message) BBC.SCHEMATIC_NOT_FOUND.send(player, input); if (message) player.print(TranslatableComponent.of("fawe.error.schematic.not.found" , input));
return null; return null;
} }
if (!f.isDirectory()) { if (!f.isDirectory()) {
@ -247,7 +248,7 @@ public class ClipboardFormats {
} }
URIClipboardHolder[] clipboards = loadAllFromDirectory(f); URIClipboardHolder[] clipboards = loadAllFromDirectory(f);
if (clipboards.length < 1) { if (clipboards.length < 1) {
if (message) BBC.SCHEMATIC_NOT_FOUND.send(player, input); if (message) player.print(TranslatableComponent.of("fawe.error.schematic.not.found" , input));
return null; return null;
} }
return new MultiClipboardHolder(f.toURI(), clipboards); return new MultiClipboardHolder(f.toURI(), clipboards);

View File

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

View File

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

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.function.factory;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; 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.math.Vector3;
import com.sk89q.worldedit.regions.NullRegion; import com.sk89q.worldedit.regions.NullRegion;
import com.sk89q.worldedit.regions.Region; 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; import java.util.List;
public class Deform implements Contextual<Operation> { public class Deform implements Contextual<Operation> {
@ -186,9 +192,11 @@ public class Deform implements Contextual<Operation> {
public void cancel() { public void cancel() {
} }
@Override @Override
public void addStatusMessages(List<String> messages) { public Iterable<Component> getStatusMessages() {
messages.add("deformed using " + expression); return Lists.newArrayList(TranslatableComponent.of("worldedit.operation.deform.expression",
TextComponent.of(expression).color(TextColor.GRAY)));
} }
} }

View File

@ -162,14 +162,12 @@ public class GardenPatchGenerator implements RegionFunction {
position = position.add(0, 1, 0); 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; return false;
} }
if (editSession.getBlock(position).getBlockType().getMaterial().isAir()) { setBlockIfAir(editSession, position, leafPattern);
editSession.setBlock(position, leafPattern);
}
placeVine(position, position.add(0, 0, 1)); placeVine(position, position.add(0, 0, 1));
placeVine(position, position.add(0, 0, -1)); placeVine(position, position.add(0, 0, -1));

View File

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

View File

@ -21,8 +21,11 @@ package com.sk89q.worldedit.function.operation;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Iterables;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.util.formatting.text.Component;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
@ -60,9 +63,8 @@ public class DelegateOperation implements Operation {
} }
@Override @Override
public void addStatusMessages(List<String> messages) { public Iterable<Component> getStatusMessages() {
original.addStatusMessages(messages); return Iterables.concat(original.getStatusMessages(), delegate.getStatusMessages());
delegate.addStatusMessages(messages);
} }
} }

Some files were not shown because too many files have changed in this diff Show More