Remove support for pluralisation to match Minecraft and alleviate issues with over-complexity

This commit is contained in:
Matthew Miller
2019-10-27 15:29:40 +10:00
parent 455a40b3fc
commit 0e6037584f
13 changed files with 99 additions and 191 deletions

View File

@ -167,7 +167,7 @@ public class BiomeCommands {
return TextComponent.of(biome.getId());
}
}).collect(Collectors.toList());
player.printInfo(TranslatableComponent.of(pluraliseI18n(messageKey, biomes.size()), TextUtils.join(components, TextComponent.of(", "))));
player.printInfo(TranslatableComponent.of(messageKey, TextUtils.join(components, TextComponent.of(", "))));
}
@Command(
@ -201,7 +201,7 @@ public class BiomeCommands {
Operations.completeLegacy(visitor);
player.printInfo(TranslatableComponent.of(
pluraliseI18n("worldedit.setbiome.changed", visitor.getAffected()),
"worldedit.setbiome.changed",
TextComponent.of(visitor.getAffected())
));
}

View File

@ -113,7 +113,7 @@ public class ExpandCommands {
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
int changeSize = newSize - oldSize;
player.printInfo(
TranslatableComponent.of(pluraliseI18n("worldedit.expand.expanded.vert", changeSize), TextComponent.of(changeSize))
TranslatableComponent.of("worldedit.expand.expanded.vert", TextComponent.of(changeSize))
);
} catch (RegionOperationException e) {
player.printError(TextComponent.of(e.getMessage()));
@ -152,7 +152,7 @@ public class ExpandCommands {
session.getRegionSelector(world).explainRegionAdjust(actor, session);
int changeSize = newSize - oldSize;
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.expand.expanded", changeSize), TextComponent.of(changeSize)));
actor.printInfo(TranslatableComponent.of("worldedit.expand.expanded", TextComponent.of(changeSize)));
}
}

View File

@ -126,7 +126,7 @@ public class GenerationCommands {
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.cyl.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.cyl.created", TextComponent.of(affected)));
return affected;
}
@ -193,7 +193,7 @@ public class GenerationCommands {
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.sphere.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.sphere.created", TextComponent.of(affected)));
return affected;
}
@ -214,7 +214,7 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(size);
density /= 100;
int affected = editSession.makeForest(session.getPlacementPosition(actor), size, density, type);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.forestgen.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.forestgen.created", TextComponent.of(affected)));
return affected;
}
@ -229,7 +229,7 @@ public class GenerationCommands {
int size) throws WorldEditException {
worldEdit.checkMaxRadius(size);
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), size);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.pumpkins.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.pumpkins.created", TextComponent.of(affected)));
return affected;
}
@ -266,7 +266,7 @@ public class GenerationCommands {
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.pyramid.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.pyramid.created", TextComponent.of(affected)));
return affected;
}
@ -325,7 +325,7 @@ public class GenerationCommands {
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.generate.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.generate.created", TextComponent.of(affected)));
return affected;
} catch (ExpressionException e) {
actor.printError(TextComponent.of(e.getMessage()));
@ -384,7 +384,7 @@ public class GenerationCommands {
try {
final int affected = editSession.makeBiomeShape(region, zero, unit, target, String.join(" ", expression), hollow, session.getTimeout());
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.generatebiome.changed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.generatebiome.changed", TextComponent.of(affected)));
return affected;
} catch (ExpressionException e) {
actor.printError(TextComponent.of(e.getMessage()));

View File

@ -86,7 +86,7 @@ public class NavigationCommands {
if (ascentLevels == 0) {
player.printError(TranslatableComponent.of("worldedit.ascend.obstructed"));
} else {
player.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.ascend.moved", ascentLevels), TextComponent.of(ascentLevels)));
player.printInfo(TranslatableComponent.of("worldedit.ascend.moved", TextComponent.of(ascentLevels)));
}
}
@ -109,7 +109,7 @@ public class NavigationCommands {
if (descentLevels == 0) {
player.printError(TranslatableComponent.of("worldedit.descend.obstructed"));
} else {
player.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.descend.moved", descentLevels), TextComponent.of(descentLevels)));
player.printInfo(TranslatableComponent.of("worldedit.descend.moved", TextComponent.of(descentLevels)));
}
}

View File

@ -139,7 +139,7 @@ public class RegionCommands {
BlockVector3 pos2 = cuboidregion.getPos2();
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.line.changed", blocksChanged), TextComponent.of(blocksChanged)));
actor.printInfo(TranslatableComponent.of("worldedit.line.changed", TextComponent.of(blocksChanged)));
return blocksChanged;
}
@ -169,7 +169,7 @@ public class RegionCommands {
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.curve.changed", blocksChanged), TextComponent.of(blocksChanged)));
actor.printInfo(TranslatableComponent.of("worldedit.curve.changed", TextComponent.of(blocksChanged)));
return blocksChanged;
}
@ -189,7 +189,7 @@ public class RegionCommands {
from = new ExistingBlockMask(editSession);
}
int affected = editSession.replaceBlocks(region, from, to);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.replace.replaced", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.replace.replaced", TextComponent.of(affected)));
return affected;
}
@ -203,7 +203,7 @@ public class RegionCommands {
@Arg(desc = "The pattern of blocks to overlay")
Pattern pattern) throws WorldEditException {
int affected = editSession.overlayCuboidBlocks(region, pattern);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.overlay.overlaid", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.overlay.overlaid", TextComponent.of(affected)));
return affected;
}
@ -218,7 +218,7 @@ public class RegionCommands {
@Arg(desc = "The pattern of blocks to set")
Pattern pattern) throws WorldEditException {
int affected = editSession.center(region, pattern);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.center.changed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.center.changed", TextComponent.of(affected)));
return affected;
}
@ -230,7 +230,7 @@ public class RegionCommands {
@Logging(REGION)
public int naturalize(Actor actor, EditSession editSession, @Selection Region region) throws WorldEditException {
int affected = editSession.naturalizeCuboidBlocks(region);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.naturalize.naturalized", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.naturalize.naturalized", TextComponent.of(affected)));
return affected;
}
@ -244,7 +244,7 @@ public class RegionCommands {
@Arg(desc = "The pattern of blocks to set")
Pattern pattern) throws WorldEditException {
int affected = editSession.makeWalls(region, pattern);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.walls.changed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.walls.changed", TextComponent.of(affected)));
return affected;
}
@ -259,7 +259,7 @@ public class RegionCommands {
@Arg(desc = "The pattern of blocks to set")
Pattern pattern) throws WorldEditException {
int affected = editSession.makeCuboidFaces(region, pattern);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.faces.changed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.faces.changed", TextComponent.of(affected)));
return affected;
}
@ -278,7 +278,7 @@ public class RegionCommands {
HeightMap heightMap = new HeightMap(editSession, region, mask);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.smooth.changed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.smooth.changed", TextComponent.of(affected)));
return affected;
}
@ -333,7 +333,7 @@ public class RegionCommands {
}
}
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.move.moved", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.move.moved", TextComponent.of(affected)));
return affected;
}
@ -388,7 +388,7 @@ public class RegionCommands {
}
}
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.stack.changed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.stack.changed", TextComponent.of(affected)));
return affected;
}
@ -455,7 +455,7 @@ public class RegionCommands {
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.deform.deformed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.deform.deformed", TextComponent.of(affected)));
return affected;
} catch (ExpressionException e) {
actor.printError(TextComponent.of(e.getMessage()));
@ -479,7 +479,7 @@ public class RegionCommands {
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
int affected = editSession.hollowOutRegion(region, thickness, pattern);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.hollow.changed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.hollow.changed", TextComponent.of(affected)));
return affected;
}
@ -496,7 +496,7 @@ public class RegionCommands {
double density) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
int affected = editSession.makeForest(region, density / 100, type);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.forest.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.forest.created", TextComponent.of(affected)));
return affected;
}
@ -518,7 +518,7 @@ public class RegionCommands {
Operations.completeLegacy(visitor);
int affected = ground.getAffected();
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.flora.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.flora.created", TextComponent.of(affected)));
return affected;
}

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import static com.sk89q.worldedit.util.translation.LocalisationHelpers.pluraliseI18n;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
@ -101,7 +100,7 @@ public class UtilityCommands {
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillXZ(pos, pattern, radius, depth, false);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.fill.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.fill.created", TextComponent.of(affected)));
return affected;
}
@ -125,7 +124,7 @@ public class UtilityCommands {
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillXZ(pos, pattern, radius, depth, true);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.fillr.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.fillr.created", TextComponent.of(affected)));
return affected;
}
@ -143,7 +142,7 @@ public class UtilityCommands {
radius = Math.max(0, radius);
we.checkMaxRadius(radius);
int affected = editSession.drainArea(session.getPlacementPosition(actor), radius, waterlogged);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.drain.drained", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.drain.drained", TextComponent.of(affected)));
return affected;
}
@ -160,7 +159,7 @@ public class UtilityCommands {
radius = Math.max(0, radius);
we.checkMaxRadius(radius);
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.LAVA);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.fixlava.fixed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.fixlava.fixed", TextComponent.of(affected)));
return affected;
}
@ -177,7 +176,7 @@ public class UtilityCommands {
radius = Math.max(0, radius);
we.checkMaxRadius(radius);
int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.WATER);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.fixwater.fixed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.fixwater.fixed", TextComponent.of(affected)));
return affected;
}
@ -198,7 +197,7 @@ public class UtilityCommands {
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
int affected = editSession.removeAbove(session.getPlacementPosition(actor), size, height);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.removeabove.removed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.removeabove.removed", TextComponent.of(affected)));
return affected;
}
@ -219,7 +218,7 @@ public class UtilityCommands {
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
int affected = editSession.removeBelow(session.getPlacementPosition(actor), size, height);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.removebelow.removed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.removebelow.removed", TextComponent.of(affected)));
return affected;
}
@ -239,7 +238,7 @@ public class UtilityCommands {
we.checkMaxRadius(radius);
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, radius);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.removenear.removed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.removenear.removed", TextComponent.of(affected)));
return affected;
}
@ -270,7 +269,7 @@ public class UtilityCommands {
}
int affected = editSession.replaceBlocks(region, from, to);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.replacenear.replaced", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.replacenear.replaced", TextComponent.of(affected)));
return affected;
}
@ -288,7 +287,7 @@ public class UtilityCommands {
we.checkMaxRadius(size);
int affected = editSession.simulateSnow(session.getPlacementPosition(actor), size);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.snow.created", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.snow.created", TextComponent.of(affected)));
return affected;
}
@ -306,7 +305,7 @@ public class UtilityCommands {
we.checkMaxRadius(size);
int affected = editSession.thaw(session.getPlacementPosition(actor), size);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.thaw.removed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.thaw.removed", TextComponent.of(affected)));
return affected;
}
@ -327,7 +326,7 @@ public class UtilityCommands {
final boolean onlyNormalDirt = !convertCoarse;
final int affected = editSession.green(session.getPlacementPosition(actor), size, onlyNormalDirt);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.green.changed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.green.changed", TextComponent.of(affected)));
return affected;
}
@ -350,7 +349,7 @@ public class UtilityCommands {
Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE);
int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, size);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.extinguish.removed", affected), TextComponent.of(affected)));
actor.printInfo(TranslatableComponent.of("worldedit.extinguish.removed", TextComponent.of(affected)));
return affected;
}
@ -408,7 +407,7 @@ public class UtilityCommands {
int killed = killMatchingEntities(radius, actor, flags::createFunction);
actor.printInfo(TranslatableComponent.of(
pluraliseI18n("worldedit.butcher.killed", killed),
"worldedit.butcher.killed",
TextComponent.of(killed),
TextComponent.of(radius)
));
@ -434,7 +433,7 @@ public class UtilityCommands {
}
int removed = killMatchingEntities(radius, actor, remover::createFunction);
actor.printInfo(TranslatableComponent.of(pluraliseI18n("worldedit.remove.removed", removed), TextComponent.of(removed)));
actor.printInfo(TranslatableComponent.of("worldedit.remove.removed", TextComponent.of(removed)));
return removed;
}

View File

@ -345,11 +345,11 @@ public class ForwardExtentCopy implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
List<Component> messages = new ArrayList<>();
messages.add(TranslatableComponent.of(pluraliseI18n("worldedit.operation.affected.block", affectedBlocks),
messages.add(TranslatableComponent.of("worldedit.operation.affected.block",
TextComponent.of(affectedBlocks)).color(TextColor.LIGHT_PURPLE));
messages.add(TranslatableComponent.of(pluraliseI18n("worldedit.operation.affected.biome", affectedBiomeCols),
messages.add(TranslatableComponent.of("worldedit.operation.affected.biome",
TextComponent.of(affectedBiomeCols)).color(TextColor.LIGHT_PURPLE));
messages.add(TranslatableComponent.of(pluraliseI18n("worldedit.operation.affected.entity", affectedEntities),
messages.add(TranslatableComponent.of("worldedit.operation.affected.entity",
TextComponent.of(affectedEntities)).color(TextColor.LIGHT_PURPLE));
return messages;

View File

@ -189,7 +189,7 @@ public abstract class BreadthFirstSearch implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
pluraliseI18n("worldedit.operation.affected.block", getAffected()),
"worldedit.operation.affected.block",
TextComponent.of(getAffected())
).color(TextColor.LIGHT_PURPLE));
}

View File

@ -86,7 +86,7 @@ public class EntityVisitor implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
pluraliseI18n("worldedit.operation.affected.entity", getAffected()),
"worldedit.operation.affected.entity",
TextComponent.of(getAffected())
).color(TextColor.LIGHT_PURPLE));
}

View File

@ -87,7 +87,7 @@ public class FlatRegionVisitor implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
pluraliseI18n("worldedit.operation.affected.column", getAffected()),
"worldedit.operation.affected.column",
TextComponent.of(getAffected())
).color(TextColor.LIGHT_PURPLE));
}

View File

@ -74,7 +74,7 @@ public class RegionVisitor implements Operation {
@Override
public Iterable<Component> getStatusMessages() {
return Lists.newArrayList(TranslatableComponent.of(
pluraliseI18n("worldedit.operation.affected.block", getAffected()),
"worldedit.operation.affected.block",
TextComponent.of(getAffected())
).color(TextColor.LIGHT_PURPLE));
}

View File

@ -1,42 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.translation;
public class LocalisationHelpers {
private LocalisationHelpers() {
}
/**
* Turn a translation key into a ".singular" or ".plural"
* depending on what the given number is.
*
* @param translationKey The base translation key
* @param number The number
* @return The key with .plural or .singular appended
*/
public static String pluraliseI18n(String translationKey, float number) {
if (number == 1) {
return translationKey + ".singular";
} else {
return translationKey + ".plural";
}
}
}