Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-19 09:20:08 +01:00
i18n upstream merge
Dieser Commit ist enthalten in:
Ursprung
c5a9436174
Commit
80d7b0582f
3
.gitignore
vendored
3
.gitignore
vendored
@ -24,3 +24,6 @@ todo.txt
|
||||
mvn/*
|
||||
docs/
|
||||
*.sh
|
||||
# i18n
|
||||
worldedit-core/src/main/resources/lang/*
|
||||
!worldedit-core/src/main/resources/lang/strings.json
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.config.Caption;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
@ -280,7 +281,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return Locale.forLanguageTag(player.getLocale().replace('_', '-'));
|
||||
return TextUtils.getLocaleByMinecraftTag(player.getLocale());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -210,5 +211,12 @@ public abstract class LocalConfiguration {
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public void setDefaultLocaleName(String localeName) {
|
||||
this.defaultLocaleName = localeName;
|
||||
if (localeName.equals("default")) {
|
||||
this.defaultLocale = Locale.getDefault();
|
||||
} else {
|
||||
this.defaultLocale = TextUtils.getLocaleByMinecraftTag(localeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.wand.toggle")
|
||||
public void toggleWand(Player player) {
|
||||
player.print(TextComponent.of("The selection wand is now a normal tool. You can disable it with ")
|
||||
player.printInfo(TextComponent.of("The selection wand is now a normal tool. You can disable it with ")
|
||||
.append(TextComponent.of("/none", TextColor.AQUA).clickEvent(
|
||||
ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/none")))
|
||||
.append(TextComponent.of(" and rebind it to any item with "))
|
||||
@ -383,7 +383,7 @@ public class SelectionCommands {
|
||||
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
|
||||
actor.print(TranslatableComponent.of("worldedit.shift.shifted"));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.shift.shifted"));
|
||||
} catch (RegionOperationException e) {
|
||||
actor.printError(TextComponent.of(e.getMessage()));
|
||||
}
|
||||
@ -406,7 +406,7 @@ public class SelectionCommands {
|
||||
region.expand(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
actor.print(TranslatableComponent.of("worldedit.outset.outset"));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.outset.outset"));
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -426,7 +426,7 @@ public class SelectionCommands {
|
||||
region.contract(getChangesForEachDir(amount, onlyHorizontal, onlyVertical));
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
actor.print(TranslatableComponent.of("worldedit.inset.inset"));
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.inset.inset"));
|
||||
}
|
||||
|
||||
private BlockVector3[] getChangesForEachDir(int amount, boolean onlyHorizontal, boolean onlyVertical) {
|
||||
|
@ -186,7 +186,7 @@ public class WorldEditCommands {
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.timezone.set", TextComponent.of(tz.getDisplayName(
|
||||
TextStyle.FULL, actor.getLocale()
|
||||
))));
|
||||
actor.print(TranslatableComponent.of("worldedit.timezone.current",
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.timezone.current",
|
||||
TextComponent.of(dateFormat.withLocale(actor.getLocale()).format(ZonedDateTime.now(tz)))));
|
||||
} catch (ZoneRulesException e) {
|
||||
actor.printError(TranslatableComponent.of("worldedit.timezone.invalid"));
|
||||
|
@ -166,13 +166,13 @@ public final class AsyncCommandBuilder<T> {
|
||||
message = converted.getRichMessage();
|
||||
}
|
||||
}
|
||||
sender.print(failure.append(TextComponent.of(": ")).append(message));
|
||||
sender.printError(failure.append(TextComponent.of(": ")).append(message));
|
||||
}
|
||||
} else {
|
||||
throw orig;
|
||||
}
|
||||
} catch (Throwable unknown) {
|
||||
sender.print(failure.append(TextComponent.of(": Unknown error. Please see console.")));
|
||||
sender.printError(failure.append(TextComponent.of(": Unknown error. Please see console.")));
|
||||
logger.error("Uncaught exception occurred in task: " + description, orig);
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.factory;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -42,8 +39,8 @@ 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 static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
||||
|
||||
public class Deform implements Contextual<Operation> {
|
||||
|
||||
@ -160,6 +157,12 @@ public class Deform implements Contextual<Operation> {
|
||||
session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout());
|
||||
}
|
||||
|
||||
public enum Mode {
|
||||
RAW_COORD,
|
||||
OFFSET,
|
||||
UNIT_CUBE
|
||||
}
|
||||
|
||||
private static final class DeformOperation implements Operation {
|
||||
private final Extent destination;
|
||||
private final Region region;
|
||||
@ -195,16 +198,10 @@ public class Deform implements Contextual<Operation> {
|
||||
|
||||
@Override
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return Lists.newArrayList(TranslatableComponent.of("worldedit.operation.deform.expression",
|
||||
return ImmutableList.of(TranslatableComponent.of("worldedit.operation.deform.expression",
|
||||
TextComponent.of(expression).color(TextColor.GRAY)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum Mode {
|
||||
RAW_COORD,
|
||||
OFFSET,
|
||||
UNIT_CUBE
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,54 +19,49 @@
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.object.extent.BlockTranslateExtent;
|
||||
import com.boydti.fawe.object.extent.PositionTransformExtent;
|
||||
import com.boydti.fawe.object.function.block.BiomeCopy;
|
||||
import com.boydti.fawe.object.function.block.CombinedBlockCopy;
|
||||
import com.boydti.fawe.object.function.block.SimpleBlockCopy;
|
||||
import com.boydti.fawe.util.MaskTraverser;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.CombinedRegionFunction;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.FlatRegionMaskingFilter;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.RegionMaskTestFunction;
|
||||
import com.sk89q.worldedit.function.biome.ExtentBiomeCopy;
|
||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
||||
import com.sk89q.worldedit.function.entity.ExtentEntityCopy;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.IntersectRegionFunction;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Identity;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import java.util.Collections;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Makes a copy of a portion of one extent to another extent or another point.
|
||||
*
|
||||
@ -428,15 +423,14 @@ public class ForwardExtentCopy implements Operation {
|
||||
|
||||
@Override
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
List<Component> messages = new ArrayList<>();
|
||||
messages.add(TranslatableComponent.of("worldedit.operation.affected.block",
|
||||
TextComponent.of(affectedBlocks)).color(TextColor.GRAY));
|
||||
messages.add(TranslatableComponent.of("worldedit.operation.affected.biome",
|
||||
TextComponent.of(affectedBiomeCols)).color(TextColor.GRAY));
|
||||
messages.add(TranslatableComponent.of("worldedit.operation.affected.entity",
|
||||
TextComponent.of(affectedEntities)).color(TextColor.GRAY));
|
||||
|
||||
return messages;
|
||||
return ImmutableList.of(
|
||||
TranslatableComponent.of("worldedit.operation.affected.block",
|
||||
TextComponent.of(affectedBlocks)).color(TextColor.LIGHT_PURPLE),
|
||||
TranslatableComponent.of("worldedit.operation.affected.biome",
|
||||
TextComponent.of(affectedBiomeCols)).color(TextColor.LIGHT_PURPLE),
|
||||
TranslatableComponent.of("worldedit.operation.affected.entity",
|
||||
TextComponent.of(affectedEntities)).color(TextColor.LIGHT_PURPLE)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,12 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -35,6 +38,11 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public interface Operation {
|
||||
|
||||
/**
|
||||
* This is an internal field, and should not be touched.
|
||||
*/
|
||||
Set<String> warnedDeprecatedClasses = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Complete the next step. If this method returns true, then the method may
|
||||
* be called again in the future, or possibly never. If this method
|
||||
@ -76,6 +84,13 @@ public interface Operation {
|
||||
// TODO Remove legacy code WorldEdit 8.0.0
|
||||
List<String> oldMessages = new ArrayList<>();
|
||||
addStatusMessages(oldMessages);
|
||||
if (oldMessages.size() > 0) {
|
||||
String className = getClass().getName();
|
||||
if (!warnedDeprecatedClasses.contains(className)) {
|
||||
WorldEdit.logger.warn("An operation is using the old status message API. This will be removed in further versions. Class: " + className);
|
||||
warnedDeprecatedClasses.add(className);
|
||||
}
|
||||
}
|
||||
return oldMessages.stream().map(TextComponent::of).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||
@ -279,7 +279,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
|
||||
@Override
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return Lists.newArrayList(TranslatableComponent.of(
|
||||
return ImmutableList.of(TranslatableComponent.of(
|
||||
"worldedit.operation.affected.block",
|
||||
TextComponent.of(getAffected())
|
||||
).color(TextColor.GRAY));
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -84,7 +85,7 @@ public class EntityVisitor implements Operation {
|
||||
|
||||
@Override
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return Lists.newArrayList(TranslatableComponent.of(
|
||||
return ImmutableList.of(TranslatableComponent.of(
|
||||
"worldedit.operation.affected.entity",
|
||||
TextComponent.of(getAffected())
|
||||
).color(TextColor.GRAY));
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@ -83,7 +84,7 @@ public class FlatRegionVisitor implements Operation {
|
||||
|
||||
@Override
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return Lists.newArrayList(TranslatableComponent.of(
|
||||
return ImmutableList.of(TranslatableComponent.of(
|
||||
"worldedit.operation.affected.column",
|
||||
TextComponent.of(getAffected())
|
||||
).color(TextColor.GRAY));
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
@ -95,7 +96,7 @@ public class RegionVisitor implements Operation {
|
||||
|
||||
@Override
|
||||
public Iterable<Component> getStatusMessages() {
|
||||
return Lists.newArrayList(TranslatableComponent.of(
|
||||
return ImmutableList.of(TranslatableComponent.of(
|
||||
"worldedit.operation.affected.block",
|
||||
TextComponent.of(getAffected())
|
||||
).color(TextColor.GRAY));
|
||||
|
@ -20,22 +20,21 @@
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Region selectors create {@link Region}s from a series of "selected points."
|
||||
* They are used, for example, to allow users to create a {@link CuboidRegion}
|
||||
@ -163,7 +162,7 @@ public interface RegionSelector {
|
||||
@Deprecated
|
||||
default List<String> getInformationLines() {
|
||||
return Lists.newArrayList();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lines of information about the selection.
|
||||
@ -172,12 +171,13 @@ public interface RegionSelector {
|
||||
*/
|
||||
default List<Component> getSelectionInfoLines() {
|
||||
return getInformationLines().stream()
|
||||
.map(TextComponent::of)
|
||||
.map(line -> TextComponent.of(line, TextColor.LIGHT_PURPLE))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vertices
|
||||
*
|
||||
* @return
|
||||
* @throws IncompleteRegionException
|
||||
*/
|
||||
|
@ -39,7 +39,6 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@ -123,12 +122,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
|
||||
allowSymlinks = getBool("allow-symbolic-links", allowSymlinks);
|
||||
serverSideCUI = getBool("server-side-cui", serverSideCUI);
|
||||
extendedYLimit = getBool("extended-y-limit", extendedYLimit);
|
||||
defaultLocaleName = getString("default-locale", defaultLocaleName);
|
||||
if (defaultLocaleName.equals("default")) {
|
||||
defaultLocale = Locale.getDefault();
|
||||
} else {
|
||||
defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-'));
|
||||
}
|
||||
setDefaultLocaleName(getString("default-locale", defaultLocaleName));
|
||||
|
||||
LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15));
|
||||
|
||||
|
@ -30,7 +30,6 @@ import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A less simple implementation of {@link LocalConfiguration}
|
||||
@ -128,12 +127,7 @@ public class YAMLConfiguration extends LocalConfiguration {
|
||||
|
||||
extendedYLimit = config.getBoolean("compat.extended-y-limit", false);
|
||||
|
||||
defaultLocaleName = config.getString("default-locale", defaultLocaleName);
|
||||
if (defaultLocaleName.equals("default")) {
|
||||
defaultLocale = Locale.getDefault();
|
||||
} else {
|
||||
defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-'));
|
||||
}
|
||||
setDefaultLocaleName(config.getString("default-locale", defaultLocaleName));
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
|
@ -35,7 +35,7 @@ public class WorldEditText {
|
||||
}
|
||||
|
||||
public static Component format(Component component, Locale locale) {
|
||||
return CONFIG_HOLDER.replace(WorldEdit.getInstance().getTranslationManager().convertText(component, locale));
|
||||
return WorldEdit.getInstance().getTranslationManager().convertText(CONFIG_HOLDER.replace(component), locale);
|
||||
}
|
||||
|
||||
public static String reduceToText(Component component, Locale locale) {
|
||||
|
@ -23,6 +23,7 @@ import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class TextUtils {
|
||||
|
||||
@ -46,4 +47,13 @@ public class TextUtils {
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
/**
|
||||
* Gets a Java Locale object by the Minecraft locale tag.
|
||||
*
|
||||
* @param locale The Minecraft locale tag
|
||||
* @return A Java locale
|
||||
*/
|
||||
public static Locale getLocaleByMinecraftTag(String locale) {
|
||||
return Locale.forLanguageTag(locale.replace('_', '-'));
|
||||
}
|
||||
}
|
||||
|
@ -28,18 +28,18 @@ public class ResourceLoader {
|
||||
}
|
||||
|
||||
private static URL getResourceForgeHack(String location) throws IOException {
|
||||
try {
|
||||
return new URL("modjar://worldedit/" + location);
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Could not find " + location);
|
||||
}
|
||||
}
|
||||
|
||||
public static URL getResource(Class clazz, String name) throws IOException {
|
||||
URL url = clazz.getResource(name);
|
||||
if (url == null) {
|
||||
try {
|
||||
return getResourceForgeHack(clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/")
|
||||
+ "/" + name);
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Could not find " + name);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
@ -47,11 +47,7 @@ public class ResourceLoader {
|
||||
public static URL getResourceRoot(String name) throws IOException {
|
||||
URL url = ResourceLoader.class.getResource("/" + name);
|
||||
if (url == null) {
|
||||
try {
|
||||
return getResourceForgeHack(name);
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Could not find " + name);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
@ -19,8 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.util.translation;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.Resources;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@ -29,21 +28,14 @@ import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.renderer.FriendlyComponentRenderer;
|
||||
import com.sk89q.worldedit.util.io.ResourceLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
|
||||
/**
|
||||
* Handles translations for the plugin.
|
||||
@ -62,7 +54,7 @@ public class TranslationManager {
|
||||
private static final Gson gson = new GsonBuilder().create();
|
||||
private static final Type STRING_MAP_TYPE = new TypeToken<Map<String, String>>() {}.getType();
|
||||
|
||||
private final Map<Locale, Map<String, String>> translationMap = new HashMap<>();
|
||||
private final Map<Locale, Map<String, String>> translationMap = new ConcurrentHashMap<>();
|
||||
private final FriendlyComponentRenderer<Locale> friendlyComponentRenderer = FriendlyComponentRenderer.from(
|
||||
(locale, key) -> new MessageFormat(getTranslationMap(locale).getOrDefault(key, key), locale));
|
||||
private Locale defaultLocale = Locale.ENGLISH;
|
||||
@ -80,8 +72,10 @@ public class TranslationManager {
|
||||
}
|
||||
|
||||
private Map<String, String> filterTranslations(Map<String, String> translations) {
|
||||
translations.entrySet().removeIf(entry -> entry.getValue().isEmpty());
|
||||
return translations;
|
||||
return translations.entrySet().stream()
|
||||
.filter(e -> !e.getValue().isEmpty())
|
||||
.map(e -> Maps.immutableEntry(e.getKey(), e.getValue().replace("'", "''")))
|
||||
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
}
|
||||
|
||||
private Map<String, String> parseTranslationFile(InputStream inputStream) {
|
||||
@ -95,7 +89,7 @@ public class TranslationManager {
|
||||
baseTranslations = parseTranslationFile(ResourceLoader.getResourceRoot("lang/" + filename).openStream());
|
||||
} catch (IOException e) {
|
||||
// Seem to be missing base. If the user has provided a file use that.
|
||||
baseTranslations = new HashMap<>();
|
||||
baseTranslations = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
File localFile = worldEdit.getWorkingDirectoryFile("lang/" + filename);
|
||||
@ -117,7 +111,7 @@ public class TranslationManager {
|
||||
}
|
||||
checkedLocales.add(locale);
|
||||
// Make a copy of the default language file
|
||||
Map<String, String> baseTranslations = new HashMap<>();
|
||||
Map<String, String> baseTranslations = new ConcurrentHashMap<>();
|
||||
if (!locale.equals(defaultLocale)) {
|
||||
baseTranslations.putAll(getTranslationMap(defaultLocale));
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
*/
|
@ -13,7 +13,6 @@
|
||||
"fawe.worldedit.history.find.element": "&8 - &2{0}: {1} &7ago &3{2}m &6{3} &c/{4}",
|
||||
"fawe.worldedit.history.find.hover": "{0} blocks changed, click for more info",
|
||||
|
||||
|
||||
"fawe.info.lighting.propagate.selection": "Lighting has been propogated in {0} chunks. (Note: To remove light use //removelight)",
|
||||
"fawe.info.updated.lighting.selection": "Lighting has been updated in {0} chunks. (It may take a second for the packets to send)",
|
||||
"fawe.info.set.region": "Selection set to your current allowed region",
|
||||
|
@ -34,6 +34,7 @@ import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.WorldEditText;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
|
||||
@ -209,7 +210,7 @@ public class ForgePlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return Locale.forLanguageTag(player.language.replace('_', '-'));
|
||||
return TextUtils.getLocaleByMinecraftTag(player.language);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +34,6 @@ import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ConfigurateConfiguration extends LocalConfiguration {
|
||||
|
||||
@ -131,11 +130,6 @@ public class ConfigurateConfiguration extends LocalConfiguration {
|
||||
shellSaveType = type.equals("") ? null : type;
|
||||
|
||||
extendedYLimit = node.getNode("compat", "extended-y-limit").getBoolean(false);
|
||||
defaultLocaleName = node.getNode("default-locale").getString(defaultLocaleName);
|
||||
if (defaultLocaleName.equals("default")) {
|
||||
defaultLocale = Locale.getDefault();
|
||||
} else {
|
||||
defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-'));
|
||||
}
|
||||
setDefaultLocaleName(node.getNode("default-locale").getString(defaultLocaleName));
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren