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

This commit is contained in:
Jesse Boyd
2019-11-21 13:50:05 +00:00
102 changed files with 1606 additions and 584 deletions

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.extent.ResettableExtent;
@ -48,6 +50,9 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.item.ItemType;
@ -63,8 +68,6 @@ import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* General WorldEdit commands.
*/
@ -98,14 +101,17 @@ public class GeneralCommands {
limit = limit == null ? config.defaultChangeLimit : Math.max(-1, limit);
if (!mayDisable && config.maxChangeLimit > -1) {
if (limit > config.maxChangeLimit) {
actor.printError("Your maximum allowable limit is " + config.maxChangeLimit + ".");
actor.printError(TranslatableComponent.of("worldedit.limit.too-high", TextComponent.of(config.maxChangeLimit)));
return;
}
}
session.setBlockChangeLimit(limit);
actor.print("Block change limit set to " + limit + "."
+ (limit == config.defaultChangeLimit ? "" : " (Use //limit to go back to the default.)"));
Component component = TextComponent.empty().append(TranslatableComponent.of("worldedit.limit.set", TextComponent.of(limit)));
if (limit != config.defaultChangeLimit) {
component.append(TextComponent.space()).append(TranslatableComponent.of("worldedit.limit.return-to-default", TextColor.GRAY));
}
actor.printInfo(component);
}
@Command(
@ -122,14 +128,17 @@ public class GeneralCommands {
limit = limit == null ? config.calculationTimeout : Math.max(-1, limit);
if (!mayDisable && config.maxCalculationTimeout > -1) {
if (limit > config.maxCalculationTimeout) {
actor.printError("Your maximum allowable timeout is " + config.maxCalculationTimeout + " ms.");
actor.printError(TranslatableComponent.of("worldedit.timeout.too-high", TextComponent.of(config.maxCalculationTimeout)));
return;
}
}
session.setTimeout(limit);
actor.print("Timeout time set to " + limit + " ms."
+ (limit == config.calculationTimeout ? "" : " (Use //timeout to go back to the default.)"));
Component component = TextComponent.empty().append(TranslatableComponent.of("worldedit.timeout.set", TextComponent.of(limit)));
if (limit != config.calculationTimeout) {
component.append(TranslatableComponent.of("worldedit.timeout.return-to-default", TextColor.GRAY));
}
actor.printInfo(component);
}
@Command(
@ -142,16 +151,16 @@ public class GeneralCommands {
Boolean fastMode) {
boolean hasFastMode = session.hasFastMode();
if (fastMode != null && fastMode == hasFastMode) {
actor.printError("Fast mode already " + (fastMode ? "enabled" : "disabled") + ".");
actor.printError(TranslatableComponent.of(fastMode ? "worldedit.fast.enabled.already" : "worldedit.fast.disabled.already"));
return;
}
if (hasFastMode) {
session.setFastMode(false);
actor.print("Fast mode disabled.");
actor.printInfo(TranslatableComponent.of("worldedit.fast.disabled"));
} else {
session.setFastMode(true);
actor.print("Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes.");
actor.printInfo(TranslatableComponent.of("worldedit.fast.enabled"));
}
}
@ -164,10 +173,10 @@ public class GeneralCommands {
@Arg(desc = "The reorder mode", def = "")
EditSession.ReorderMode reorderMode) {
if (reorderMode == null) {
actor.print("The reorder mode is " + session.getReorderMode().getDisplayName());
actor.printInfo(TranslatableComponent.of("worldedit.reorder.current", TextComponent.of(session.getReorderMode().getDisplayName())));
} else {
session.setReorderMode(reorderMode);
actor.print("The reorder mode is now " + session.getReorderMode().getDisplayName());
actor.printInfo(TranslatableComponent.of("worldedit.reorder.set", TextComponent.of(session.getReorderMode().getDisplayName())));
}
}
@ -184,17 +193,18 @@ public class GeneralCommands {
}
boolean useServerCui = session.shouldUseServerCUI();
if (drawSelection != null && drawSelection == useServerCui) {
player.printError("Server CUI already " + (useServerCui ? "enabled" : "disabled") + ".");
player.printError(TranslatableComponent.of("worldedit.drawsel." + (useServerCui ? "enabled" : "disabled") + ".already"));
return;
}
if (useServerCui) {
session.setUseServerCUI(false);
session.updateServerCUI(player);
player.print("Server CUI disabled.");
player.printInfo(TranslatableComponent.of("worldedit.drawsel.disabled"));
} else {
session.setUseServerCUI(true);
session.updateServerCUI(player);
player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32.");
player.printInfo(TranslatableComponent.of("worldedit.drawsel.enabled"));
}
}
@ -207,9 +217,9 @@ public class GeneralCommands {
@Arg(desc = "The world override", def = "") World world) {
session.setWorldOverride(world);
if (world == null) {
actor.print("Removed world override.");
actor.printInfo(TranslatableComponent.of("worldedit.world.remove"));
} else {
actor.print("Set the world override to " + world.getId() + ". (Use //world to go back to default)");
actor.printInfo(TranslatableComponent.of("worldedit.world.set", TextComponent.of(world.getId())));
}
}
@ -224,16 +234,16 @@ public class GeneralCommands {
@Arg(desc = "The mode to set the watchdog hook to", def = "")
HookMode hookMode) {
if (WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getWatchdog() == null) {
actor.printError("This platform has no watchdog hook.");
actor.printError(TranslatableComponent.of("worldedit.watchdog.no-hook"));
return;
}
boolean previousMode = session.isTickingWatchdog();
if (hookMode != null && (hookMode == HookMode.ACTIVE) == previousMode) {
actor.printError("Watchdog hook already " + (previousMode ? "active" : "inactive") + ".");
actor.printError(TranslatableComponent.of(previousMode ? "worldedit.watchdog.active.already" : "worldedit.watchdog.inactive.already"));
return;
}
session.setTickingWatchdog(!previousMode);
actor.print("Watchdog hook now " + (previousMode ? "inactive" : "active") + ".");
actor.printInfo(TranslatableComponent.of(previousMode ? "worldedit.watchdog.inactive" : "worldedit.watchdog.active"));
}
@Command(
@ -247,10 +257,10 @@ public class GeneralCommands {
Mask mask) {
if (mask == null) {
session.setMask(null);
actor.print("Global mask disabled.");
actor.printInfo(TranslatableComponent.of("worldedit.gmask.disabled"));
} else {
session.setMask(mask);
actor.print("Global mask set.");
actor.printInfo(TranslatableComponent.of("worldedit.gmask.set"));
}
}
@ -261,9 +271,9 @@ public class GeneralCommands {
)
public void togglePlace(Player player, LocalSession session) {
if (session.togglePlacementPosition()) {
player.print(BBC.PLACE_ENABLED.s());
player.printInfo(TranslatableComponent.of("worldedit.toggleplace.pos1"));
} else {
player.print(BBC.PLACE_DISABLED.s());
player.printInfo(TranslatableComponent.of("worldedit.toggleplace.player"));
}
}
@ -284,11 +294,11 @@ public class GeneralCommands {
List<String> query) throws Exception {
String search = String.join(" ", query);
if (search.length() <= 2) {
actor.printError("Enter a longer search string (len > 2).");
actor.printError(TranslatableComponent.of("worldedit.searchitem.too-short"));
return;
}
if (blocksOnly && itemsOnly) {
actor.printError("You cannot use both the 'b' and 'i' flags simultaneously.");
actor.printError(TranslatableComponent.of("worldedit.searchitem.either-b-or-i"));
return;
}