3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-19 17:30:08 +01:00

Names via Translation (#1268)

* Deprecate BiomeRegistry, etc.

* Update some libraries, e.g. text

* Move to new translation renderer

* Revert "Deprecate BiomeRegistry, etc."

This reverts commit 59a5d6c92aec52739a8dc68ac3d23898af7593dd.

This was not a good idea for potential mod shenanigans.

* Move BiomeData#getName to BiomeRegistry, use i18n

* Use getRichName instead of getName

* Implement getRichName for NullBiomeRegistry

* Add getRichName for blocks

* Relocate net.kyori.minecraft

* Update adapters for getRichBlockName

* Add getRichName for items

* Update adapters for getRichItemName

* Update adapters JAR for merge

(cherry picked from commit cfd26253b6fb59ff6c65a0157a6780be7db4ea5a)
Dieser Commit ist enthalten in:
Octavia Togami 2020-03-23 23:47:27 +01:00 committet von Hannes Greule
Ursprung 008238c686
Commit 92f8776796
28 geänderte Dateien mit 317 neuen und 176 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,11 @@ fun Project.applyLibrariesConfiguration() {
group = "${rootProject.group}.worldedit-libs" group = "${rootProject.group}.worldedit-libs"
val relocations = mapOf(
"net.kyori.text" to "com.sk89q.worldedit.util.formatting.text",
"net.kyori.minecraft" to "com.sk89q.worldedit.util.kyori"
)
tasks.register<ShadowJar>("jar") { tasks.register<ShadowJar>("jar") {
configurations = listOf(project.configurations["shade"]) configurations = listOf(project.configurations["shade"])
archiveClassifier.set("") archiveClassifier.set("")
@ -36,13 +41,15 @@ fun Project.applyLibrariesConfiguration() {
exclude(dependency("org.slf4j:slf4j-api")) exclude(dependency("org.slf4j:slf4j-api"))
} }
relocate("net.kyori.text", "com.sk89q.worldedit.util.formatting.text") relocations.forEach { (from, to) ->
relocate(from, to)
}
} }
val altConfigFiles = { artifactType: String -> val altConfigFiles = { artifactType: String ->
val deps = configurations["shade"].incoming.dependencies val deps = configurations["shade"].incoming.dependencies
.filterIsInstance<ModuleDependency>() .filterIsInstance<ModuleDependency>()
.map { it.copy() } .map { it.copy() }
.map { dependency: ModuleDependency -> .map { dependency ->
dependency.artifact { dependency.artifact {
name = dependency.name name = dependency.name
type = artifactType type = artifactType
@ -61,13 +68,15 @@ fun Project.applyLibrariesConfiguration() {
from({ from({
altConfigFiles("sources") altConfigFiles("sources")
}) })
val filePattern = Regex("(.*)net/kyori/text((?:/|$).*)") relocations.forEach { (from, to) ->
val textPattern = Regex("net\\.kyori\\.text") val filePattern = Regex("(.*)${from.replace('.', '/')}((?:/|$).*)")
eachFile { val textPattern = Regex.fromLiteral(from)
filter { eachFile {
it.replaceFirst(textPattern, "com.sk89q.worldedit.util.formatting.text") filter {
it.replaceFirst(textPattern, to)
}
path = path.replaceFirst(filePattern, "$1${to.replace('.', '/')}$2")
} }
path = path.replaceFirst(filePattern, "$1com/sk89q/worldedit/util/formatting/text$2")
} }
archiveClassifier.set("sources") archiveClassifier.set("sources")
} }

Datei anzeigen

@ -19,6 +19,9 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.translation.TranslationManager;
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;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
@ -34,6 +37,14 @@ class BukkitBiomeRegistry implements BiomeRegistry {
BukkitBiomeRegistry() { BukkitBiomeRegistry() {
} }
@Override
public Component getRichName(BiomeType biomeType) {
return TranslatableComponent.of(
TranslationManager.makeTranslationKey("biome", biomeType.getId())
);
}
@Deprecated
@Nullable @Nullable
@Override @Override
public BiomeData getData(BiomeType biome) { public BiomeData getData(BiomeType biome) {

Datei anzeigen

@ -20,6 +20,7 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
@ -39,6 +40,14 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
private BukkitBlockMaterial[] materialMap; private BukkitBlockMaterial[] materialMap;
@Override
public Component getRichName(BlockType blockType) {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
return WorldEditPlugin.getInstance().getBukkitImplAdapter().getRichBlockName(blockType);
}
return super.getRichName(blockType);
}
@Nullable @Nullable
@Override @Override
public BlockMaterial getMaterial(BlockType blockType) { public BlockMaterial getMaterial(BlockType blockType) {

Datei anzeigen

@ -19,13 +19,32 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.BundledItemRegistry; import com.sk89q.worldedit.world.registry.BundledItemRegistry;
import org.bukkit.Material; import org.bukkit.Material;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
public class BukkitItemRegistry extends BundledItemRegistry { class BukkitItemRegistry extends BundledItemRegistry {
@Override
public Component getRichName(ItemType itemType) {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
return WorldEditPlugin.getInstance().getBukkitImplAdapter().getRichItemName(itemType);
}
return super.getRichName(itemType);
}
@Override
public Component getRichName(BaseItemStack itemStack) {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
return WorldEditPlugin.getInstance().getBukkitImplAdapter().getRichItemName(itemStack);
}
return super.getRichName(itemStack);
}
@Override @Override
public Collection<String> values() { public Collection<String> values() {
ArrayList<String> values = new ArrayList<>(); ArrayList<String> values = new ArrayList<>();

Datei anzeigen

@ -22,7 +22,6 @@ package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import com.sk89q.worldedit.world.registry.BlockCategoryRegistry; import com.sk89q.worldedit.world.registry.BlockCategoryRegistry;
import com.sk89q.worldedit.world.registry.BlockRegistry; import com.sk89q.worldedit.world.registry.BlockRegistry;
import com.sk89q.worldedit.world.registry.BundledItemRegistry;
import com.sk89q.worldedit.world.registry.BundledRegistries; import com.sk89q.worldedit.world.registry.BundledRegistries;
import com.sk89q.worldedit.world.registry.EntityRegistry; import com.sk89q.worldedit.world.registry.EntityRegistry;
import com.sk89q.worldedit.world.registry.ItemCategoryRegistry; import com.sk89q.worldedit.world.registry.ItemCategoryRegistry;
@ -35,8 +34,8 @@ class BukkitRegistries extends BundledRegistries {
private static final BukkitRegistries INSTANCE = new BukkitRegistries(); private static final BukkitRegistries INSTANCE = new BukkitRegistries();
private final BlockRegistry blockRegistry = new BukkitBlockRegistry(); private final BlockRegistry blockRegistry = new BukkitBlockRegistry();
private final ItemRegistry itemRegistry = new BukkitItemRegistry();
private final BiomeRegistry biomeRegistry = new BukkitBiomeRegistry(); private final BiomeRegistry biomeRegistry = new BukkitBiomeRegistry();
private final ItemRegistry itemRegistry = new BukkitItemRegistry();
private final EntityRegistry entityRegistry = new BukkitEntityRegistry(); private final EntityRegistry entityRegistry = new BukkitEntityRegistry();
private final BlockCategoryRegistry blockCategoryRegistry = new BukkitBlockCategoryRegistry(); private final BlockCategoryRegistry blockCategoryRegistry = new BukkitBlockCategoryRegistry();
private final ItemCategoryRegistry itemCategoryRegistry = new BukkitItemCategoryRegistry(); private final ItemCategoryRegistry itemCategoryRegistry = new BukkitItemCategoryRegistry();
@ -57,6 +56,11 @@ class BukkitRegistries extends BundledRegistries {
return biomeRegistry; return biomeRegistry;
} }
@Override
public ItemRegistry getItemRegistry() {
return itemRegistry;
}
@Override @Override
public BlockCategoryRegistry getBlockCategoryRegistry() { public BlockCategoryRegistry getBlockCategoryRegistry() {
return blockCategoryRegistry; return blockCategoryRegistry;
@ -81,8 +85,4 @@ class BukkitRegistries extends BundledRegistries {
return INSTANCE; return INSTANCE;
} }
@Override
public ItemRegistry getItemRegistry() {
return itemRegistry;
}
} }

Datei anzeigen

@ -36,12 +36,14 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.DataFixer; import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.RegenOptions; import com.sk89q.worldedit.world.RegenOptions;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
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;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -52,10 +54,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import javax.annotation.Nullable;
import java.util.Map; import java.util.Map;
import java.util.OptionalInt; import java.util.OptionalInt;
import java.util.Set; import java.util.Set;
import javax.annotation.Nullable;
/** /**
* An interface for adapters of various Bukkit implementations. * An interface for adapters of various Bukkit implementations.
@ -127,6 +129,30 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
@Nullable @Nullable
Entity createEntity(Location location, BaseEntity state); Entity createEntity(Location location, BaseEntity state);
/**
* Gets the name for the given block.
*
* @param blockType the block
* @return The name
*/
Component getRichBlockName(BlockType blockType);
/**
* Gets the name for the given item.
*
* @param itemType the item
* @return The name
*/
Component getRichItemName(ItemType itemType);
/**
* Gets the name for the given item stack.
*
* @param itemStack the item stack
* @return The name
*/
Component getRichItemName(BaseItemStack itemStack);
/** /**
* Get a map of {@code string -> property}. * Get a map of {@code string -> property}.
* *

Datei anzeigen

@ -591,15 +591,17 @@ public final class WorldEdit {
Map<BlockType, Integer> missingBlocks = editSession.popMissingBlocks(); Map<BlockType, Integer> missingBlocks = editSession.popMissingBlocks();
if (!missingBlocks.isEmpty()) { if (!missingBlocks.isEmpty()) {
StringBuilder str = new StringBuilder(); TextComponent.Builder str = TextComponent.builder();
str.append("Missing these blocks: "); str.append("Missing these blocks: ");
int size = missingBlocks.size(); int size = missingBlocks.size();
int i = 0; int i = 0;
for (Map.Entry<BlockType, Integer> blockTypeIntegerEntry : missingBlocks.entrySet()) { for (Map.Entry<BlockType, Integer> blockTypeIntegerEntry : missingBlocks.entrySet()) {
str.append((blockTypeIntegerEntry.getKey()).getName()); str.append((blockTypeIntegerEntry.getKey()).getRichName());
str.append(" [Amt: ").append(blockTypeIntegerEntry.getValue()).append("]"); str.append(" [Amt: ")
.append(String.valueOf(blockTypeIntegerEntry.getValue()))
.append("]");
++i; ++i;
@ -608,7 +610,7 @@ public final class WorldEdit {
} }
} }
actor.printError(str.toString()); actor.printError(str.build());
} }
} }

Datei anzeigen

@ -20,6 +20,9 @@
package com.sk89q.worldedit.blocks; package com.sk89q.worldedit.blocks;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
/** /**
@ -80,4 +83,9 @@ public class BaseItemStack extends BaseItem {
public void setAmount(int amount) { public void setAmount(int amount) {
this.amount = amount; this.amount = amount;
} }
public Component getRichName() {
return WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getRichName(this);
}
} }

Datei anzeigen

@ -49,7 +49,6 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; 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.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeData;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
@ -87,23 +86,19 @@ public class BiomeCommands {
@ArgFlag(name = 'p', desc = "Page number.", def = "1") @ArgFlag(name = 'p', desc = "Page number.", def = "1")
int page) { int page) {
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> { WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
BiomeRegistry biomeRegistry = BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS) .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
.getRegistries().getBiomeRegistry();
PaginationBox paginationBox = PaginationBox PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%",
.fromStrings("Available Biomes", "/biomelist -p %page%", BiomeType.REGISTRY.values().stream()
BiomeType.REGISTRY.values().stream().map(biomeType -> { .map(biomeType -> TextComponent.builder()
String id = biomeType.getId(); .append(biomeType.getId())
final BiomeData data = biomeRegistry.getData(biomeType); .append(" (")
if (data != null) { .append(biomeRegistry.getRichName(biomeType))
String name = data.getName(); .append(")")
return id + " (" + name + ")"; .build())
} else { .collect(Collectors.toList()));
return id; return paginationBox.create(page);
}
}).collect(Collectors.toList()));
return paginationBox.create(page);
}, (Component) null); }, (Component) null);
} }
@ -150,14 +145,11 @@ public class BiomeCommands {
messageKey = "worldedit.biomeinfo.selection"; messageKey = "worldedit.biomeinfo.selection";
} }
List<Component> components = biomes.stream().map(biome -> { List<Component> components = biomes.stream().map(biome ->
BiomeData data = biomeRegistry.getData(biome); biomeRegistry.getRichName(biome).hoverEvent(
if (data != null) { HoverEvent.showText(TextComponent.of(biome.getId()))
return TextComponent.of(data.getName()).hoverEvent(HoverEvent.showText(TextComponent.of(biome.getId()))); )
} else { ).collect(Collectors.toList());
return TextComponent.of(biome.getId());
}
}).collect(Collectors.toList());
player.printInfo(TranslatableComponent.of(messageKey, TextUtils.join(components, TextComponent.of(", ")))); player.printInfo(TranslatableComponent.of(messageKey, TextUtils.join(components, TextComponent.of(", "))));
} }

Datei anzeigen

@ -715,7 +715,7 @@ 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); Component blockName = blockType.getRichName().color(TextColor.LIGHT_PURPLE);
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);

Datei anzeigen

@ -78,7 +78,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
if (targetBlock != null) { if (targetBlock != null) {
pattern = targetBlock; pattern = targetBlock;
player.printInfo(TranslatableComponent.of("worldedit.tool.repl.switched", TextComponent.of(targetBlock.getBlockType().getName()))); player.printInfo(TranslatableComponent.of("worldedit.tool.repl.switched", targetBlock.getBlockType().getRichName()));
} }
return true; return true;

Datei anzeigen

@ -59,7 +59,7 @@ public class QueryTool implements BlockTool {
TextComponent.Builder builder = TextComponent.builder(); TextComponent.Builder builder = TextComponent.builder();
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(block.getBlockType().getRichName().color(TextColor.YELLOW));
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY) builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.blockstate.hover")))); .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.blockstate.hover"))));
final int internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState()); final int internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());

Datei anzeigen

@ -36,6 +36,7 @@ import com.sk89q.worldedit.command.InsufficientArgumentsException;
import com.sk89q.worldedit.command.tool.InvalidToolBindException; import com.sk89q.worldedit.command.tool.InvalidToolBindException;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.regions.RegionOperationException;
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.io.file.FileSelectionAbortedException; import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameResolutionException; import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
@ -62,7 +63,11 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
} }
private CommandException newCommandException(String message, Throwable cause) { private CommandException newCommandException(String message, Throwable cause) {
return new CommandException(TextComponent.of(String.valueOf(message)), cause, ImmutableList.of()); return newCommandException(TextComponent.of(String.valueOf(message)), cause);
}
private CommandException newCommandException(Component message, Throwable cause) {
return new CommandException(message, cause, ImmutableList.of());
} }
@ExceptionMatch @ExceptionMatch
@ -158,7 +163,13 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
@ExceptionMatch @ExceptionMatch
public void convert(InvalidToolBindException e) throws CommandException { public void convert(InvalidToolBindException e) throws CommandException {
throw newCommandException("Can't bind tool to " + e.getItemType().getName() + ": " + e.getMessage(), e); throw newCommandException(
TextComponent.builder("Can't bind tool to ")
.append(e.getItemType().getRichName())
.append(": " + e.getMessage())
.build(),
e
);
} }
@ExceptionMatch @ExceptionMatch

Datei anzeigen

@ -21,17 +21,19 @@ package com.sk89q.worldedit.util.formatting.component;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.history.changeset.ChangeSet;
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.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 javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
import javax.annotation.Nullable; import java.util.stream.Collectors;
public abstract class PaginationBox extends MessageBox { public abstract class PaginationBox extends MessageBox {
@ -145,46 +147,27 @@ public abstract class PaginationBox extends MessageBox {
return new ListPaginationBox(header, pageCommand, lines); return new ListPaginationBox(header, pageCommand, lines);
} }
public static PaginationBox fromStrings(String header, @Nullable String pageCommand, List<String> lines) { public static PaginationBox fromStrings(String header, @Nullable String pageCommand, Collection<String> lines) {
return fromStrings(header, pageCommand, (Collection) lines); return fromComponents(header, pageCommand, lines.stream()
.map(TextComponent::of)
.collect(Collectors.toList()));
} }
public static class ListPaginationBox extends PaginationBox { public static PaginationBox fromComponents(String header, @Nullable String pageCommand, Collection<Component> lines) {
private final Collection lines; return new ListPaginationBox(header, pageCommand, lines);
private int iterIndex; }
private Iterator iterator;
public ListPaginationBox(String header, String pageCommand, List<String> lines) { private static class ListPaginationBox extends PaginationBox {
this(header, pageCommand, (Collection) lines); private final List<Component> lines;
}
public ListPaginationBox(String header, String pageCommand, Collection lines) { ListPaginationBox(String header, String pageCommand, Collection<Component> lines) {
super(header, pageCommand); super(header, pageCommand);
this.lines = lines; this.lines = lines;
} }
@Override @Override
public Component getComponent(int number) { public Component getComponent(int number) {
Object obj; return lines.get(number);
if (lines instanceof List) {
obj = ((List) lines).get(number);
} else {
if (iterator == null || iterIndex > number) {
iterator = lines.iterator();
iterIndex = 0;
}
do {
obj = iterator.next();
iterIndex++;
} while (iterIndex < number);
}
if (obj instanceof Supplier) {
obj = ((Supplier) obj).get();
}
if (obj instanceof Component) {
return (Component) obj;
}
return TextComponent.of(obj + "");
} }
@Override @Override

Datei anzeigen

@ -19,6 +19,8 @@
package com.sk89q.worldedit.world.biome; package com.sk89q.worldedit.world.biome;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
/** /**
* Provides information about a biome. * Provides information about a biome.
* *
@ -32,6 +34,8 @@ public interface BiomeData {
* particular convention. * particular convention.
* *
* @return the biome's name * @return the biome's name
* @deprecated This method does not work on the server.
* Use {@link BiomeRegistry#getRichName(BiomeType)}.
*/ */
@Deprecated @Deprecated
String getName(); String getName();

Datei anzeigen

@ -33,6 +33,7 @@ import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.util.concurrency.LazyReference; import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
@ -96,6 +97,11 @@ public class BlockType implements Keyed, Pattern {
return this.id; return this.id;
} }
public Component getRichName() {
return WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getBlockRegistry().getRichName(this);
}
public String getNamespace() { public String getNamespace() {
String id = getId(); String id = getId();
int i = id.indexOf(':'); int i = id.indexOf(':');
@ -111,15 +117,11 @@ public class BlockType implements Keyed, Pattern {
* Gets the name of this block, or the ID if the name cannot be found. * Gets the name of this block, or the ID if the name cannot be found.
* *
* @return The name, or ID * @return The name, or ID
* @deprecated The name is now translatable, use {@link #getRichName()}.
*/ */
@Deprecated @Deprecated
public String getName() { public String getName() {
String name = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getName(this); return getRichName().toString();
if (name == null) {
return getId();
} else {
return name;
}
} }
/* /*
@ -274,9 +276,7 @@ public class BlockType implements Keyed, Pattern {
/** /**
* Gets the legacy ID. Needed for legacy reasons. * Gets the legacy ID. Needed for legacy reasons.
* *
* <p>
* DO NOT USE THIS. * DO NOT USE THIS.
* </p>
* *
* @return legacy id or 0, if unknown * @return legacy id or 0, if unknown
*/ */
@ -286,11 +286,39 @@ public class BlockType implements Keyed, Pattern {
return combinedId == null ? 0 : combinedId; return combinedId == null ? 0 : combinedId;
} }
/**
* Gets the legacy data. Needed for legacy reasons.
*
* DO NOT USE THIS.
*
* @return legacy data or 0, if unknown
*/
@Deprecated @Deprecated
public int getLegacyId() { public int getLegacyId() {
return computeLegacy(0); return computeLegacy(0);
} }
/**
* Gets the legacy data. Needed for legacy reasons.
*
* <p>
* DO NOT USE THIS.
* </p>
*
* @return legacy data or 0, if unknown
*/
@Deprecated
public int getLegacyData() {
return computeLegacy(1);
}
private int computeLegacy(int index) {
if (this.legacyCombinedId == null) {
this.legacyCombinedId = LegacyMapper.getInstance().getLegacyCombined(this.getDefaultState());
}
return index == 0 ? legacyCombinedId >> 4 : legacyCombinedId & 15;
}
/** /**
* The internal index of this type. * The internal index of this type.
* *
@ -336,25 +364,4 @@ public class BlockType implements Keyed, Pattern {
public SingleBlockTypeMask toMask(Extent extent) { public SingleBlockTypeMask toMask(Extent extent) {
return new SingleBlockTypeMask(extent, this); return new SingleBlockTypeMask(extent, this);
} }
/**
* Gets the legacy data. Needed for legacy reasons.
*
* <p>
* DO NOT USE THIS.
* </p>
*
* @return legacy data or 0, if unknown
*/
@Deprecated
public int getLegacyData() {
return computeLegacy(1);
}
private int computeLegacy(int index) {
if (this.legacyCombinedId == null) {
this.legacyCombinedId = LegacyMapper.getInstance().getLegacyCombined(this.getDefaultState());
}
return index == 0 ? legacyCombinedId >> 4 : legacyCombinedId & 15;
}
} }

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.util.formatting.text.Component;
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;
@ -29,11 +30,21 @@ import javax.annotation.Nullable;
*/ */
public interface BiomeRegistry { public interface BiomeRegistry {
/**
* Get the name of the biome, usually as a translatable component.
*
* @param biomeType the biome type
* @return the name of the biome
*/
Component getRichName(BiomeType biomeType);
/** /**
* Get data about a biome. * Get data about a biome.
* *
* @param biome the biome * @param biome the biome
* @return a data object or null if information is not known * @return a data object or null if information is not known
* @deprecated This method no longer returns any useful information.
* Use {@link #getRichName(BiomeType)} for the name of the biome.
*/ */
@Deprecated @Deprecated
@Nullable @Nullable

Datei anzeigen

@ -20,29 +20,41 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.OptionalInt; import java.util.OptionalInt;
import javax.annotation.Nullable;
/** /**
* Provides information on blocks and provides methods to create them. * Provides information on blocks and provides methods to create them.
*/ */
public interface BlockRegistry { public interface BlockRegistry {
/**
* Gets the name for the given block.
*
* @param blockType the block
* @return The name
*/
Component getRichName(BlockType blockType);
/** /**
* Gets the name for the given block. * Gets the name for the given block.
* *
* @param blockType the block * @param blockType the block
* @return The name, or null if it's unknown * @return The name, or null if it's unknown
* @deprecated Names are now translatable, use {@link #getRichName(BlockType)}.
*/ */
@Deprecated @Deprecated
@Nullable @Nullable
String getName(BlockType blockType); default String getName(BlockType blockType) {
return getRichName(blockType).toString();
}
/** /**
* Get the material for the given block. * Get the material for the given block.

Datei anzeigen

@ -20,6 +20,10 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
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.translation.TranslationManager;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
@ -34,11 +38,19 @@ import javax.annotation.Nullable;
*/ */
public class BundledBlockRegistry implements BlockRegistry { public class BundledBlockRegistry implements BlockRegistry {
@Nullable
@Override @Override
public String getName(BlockType blockType) { public Component getRichName(BlockType blockType) {
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.getId()); BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.getId());
return blockEntry != null ? blockEntry.localizedName : null; if (blockEntry != null) {
// This is more likely to be "right", but not translated
// Some vanilla MC blocks have overrides so we need this name here
// Most platforms should be overriding this anyways, so it likely doesn't matter
// too much!
return TextComponent.of(blockEntry.localizedName);
}
return TranslatableComponent.of(
TranslationManager.makeTranslationKey("block", blockType.getId())
);
} }
@Nullable @Nullable

Datei anzeigen

@ -23,9 +23,9 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import javax.annotation.Nullable;
public interface ItemRegistry { public interface ItemRegistry {

Datei anzeigen

@ -19,6 +19,9 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.translation.TranslationManager;
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;
@ -35,6 +38,14 @@ public class NullBiomeRegistry implements BiomeRegistry {
public NullBiomeRegistry() { public NullBiomeRegistry() {
} }
@Override
public Component getRichName(BiomeType biomeType) {
return TranslatableComponent.of(
TranslationManager.makeTranslationKey("biome", biomeType.getId())
);
}
@Deprecated
@Nullable @Nullable
@Override @Override
public BiomeData getData(BiomeType biome) { public BiomeData getData(BiomeType biome) {

Datei anzeigen

@ -19,6 +19,8 @@
package com.sk89q.worldedit.fabric; package com.sk89q.worldedit.fabric;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
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;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
@ -29,6 +31,12 @@ import net.minecraft.world.biome.Biome;
*/ */
class FabricBiomeRegistry implements BiomeRegistry { class FabricBiomeRegistry implements BiomeRegistry {
@Override
public Component getRichName(BiomeType biomeType) {
return TranslatableComponent.of(FabricAdapter.adapt(biomeType).getTranslationKey());
}
@Deprecated
@Override @Override
public BiomeData getData(BiomeType biome) { public BiomeData getData(BiomeType biome) {
return new FabricBiomeData(FabricAdapter.adapt(biome)); return new FabricBiomeData(FabricAdapter.adapt(biome));
@ -37,6 +45,7 @@ class FabricBiomeRegistry implements BiomeRegistry {
/** /**
* Cached biome data information. * Cached biome data information.
*/ */
@Deprecated
private static class FabricBiomeData implements BiomeData { private static class FabricBiomeData implements BiomeData {
private final Biome biome; private final Biome biome;
@ -49,6 +58,7 @@ class FabricBiomeRegistry implements BiomeRegistry {
this.biome = biome; this.biome = biome;
} }
@SuppressWarnings("deprecation")
@Override @Override
public String getName() { public String getName() {
return biome.getName().asFormattedString(); return biome.getName().asFormattedString();

Datei anzeigen

@ -20,17 +20,15 @@
package com.sk89q.worldedit.fabric; package com.sk89q.worldedit.fabric;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BundledBlockRegistry; import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -41,15 +39,9 @@ public class FabricBlockRegistry extends BundledBlockRegistry {
private Map<Material, FabricBlockMaterial> materialMap = new HashMap<>(); private Map<Material, FabricBlockMaterial> materialMap = new HashMap<>();
@Nullable
@Override @Override
public String getName(BlockType blockType) { public Component getRichName(BlockType blockType) {
Block block = FabricAdapter.adapt(blockType); return TranslatableComponent.of(FabricAdapter.adapt(blockType).getTranslationKey());
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
return block.getName().asFormattedString();
} else {
return super.getName(blockType);
}
} }
@Override @Override

Datei anzeigen

@ -19,24 +19,26 @@
package com.sk89q.worldedit.fabric; package com.sk89q.worldedit.fabric;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.BundledItemRegistry; import com.sk89q.worldedit.world.registry.BundledItemRegistry;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Item;
import javax.annotation.Nullable;
public class FabricItemRegistry extends BundledItemRegistry { public class FabricItemRegistry extends BundledItemRegistry {
@Nullable
@Override @Override
public String getName(ItemType itemType) { public Component getRichName(ItemType itemType) {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { return TranslatableComponent.of(
final Item item = FabricAdapter.adapt(itemType); FabricAdapter.adapt(itemType).getTranslationKey()
return I18n.translate(item.getTranslationKey()); );
}
return super.getName(itemType);
} }
@Override
public Component getRichName(BaseItemStack itemStack) {
return TranslatableComponent.of(
FabricAdapter.adapt(itemStack).getTranslationKey()
);
}
} }

Datei anzeigen

@ -19,6 +19,8 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
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;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
@ -29,6 +31,12 @@ import net.minecraft.world.biome.Biome;
*/ */
class ForgeBiomeRegistry implements BiomeRegistry { class ForgeBiomeRegistry implements BiomeRegistry {
@Override
public Component getRichName(BiomeType biomeType) {
return TranslatableComponent.of(ForgeAdapter.adapt(biomeType).getTranslationKey());
}
@Deprecated
@Override @Override
public BiomeData getData(BiomeType biome) { public BiomeData getData(BiomeType biome) {
return new ForgeBiomeData(ForgeAdapter.adapt(biome)); return new ForgeBiomeData(ForgeAdapter.adapt(biome));
@ -37,6 +45,7 @@ class ForgeBiomeRegistry implements BiomeRegistry {
/** /**
* Cached biome data information. * Cached biome data information.
*/ */
@Deprecated
private static class ForgeBiomeData implements BiomeData { private static class ForgeBiomeData implements BiomeData {
private final Biome biome; private final Biome biome;
@ -49,6 +58,7 @@ class ForgeBiomeRegistry implements BiomeRegistry {
this.biome = biome; this.biome = biome;
} }
@SuppressWarnings("deprecation")
@Override @Override
public String getName() { public String getName() {
return biome.getDisplayName().getString(); return biome.getDisplayName().getString();

Datei anzeigen

@ -20,6 +20,8 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
@ -27,9 +29,7 @@ import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.state.IProperty; import net.minecraft.state.IProperty;
import net.minecraftforge.fml.loading.FMLLoader;
import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -40,15 +40,9 @@ public class ForgeBlockRegistry extends BundledBlockRegistry {
private Map<Material, ForgeBlockMaterial> materialMap = new HashMap<>(); private Map<Material, ForgeBlockMaterial> materialMap = new HashMap<>();
@Nullable
@Override @Override
public String getName(BlockType blockType) { public Component getRichName(BlockType blockType) {
Block block = ForgeAdapter.adapt(blockType); return TranslatableComponent.of(ForgeAdapter.adapt(blockType).getTranslationKey());
if (block != null && FMLLoader.getDist().isClient()) {
return block.getNameTextComponent().getFormattedText();
} else {
return super.getName(blockType);
}
} }
@Override @Override

Datei anzeigen

@ -19,33 +19,26 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.registry.ItemRegistry; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.BundledItemRegistry; import com.sk89q.worldedit.world.registry.BundledItemRegistry;
import javax.annotation.Nullable;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.registries.RegistryManager;
public class ForgeItemRegistry extends BundledItemRegistry { public class ForgeItemRegistry extends BundledItemRegistry {
@Nullable
@Override @Override
public String getName(ItemType itemType) { public Component getRichName(ItemType itemType) {
if (FMLLoader.getDist().isClient()) { return TranslatableComponent.of(
final Item item = RegistryManager.ACTIVE.getRegistry(Item.class) ForgeAdapter.adapt(itemType).getTranslationKey()
.getValue(ResourceLocation.tryCreate(itemType.getId())); );
if (item != null) {
return I18n.format(item.getTranslationKey());
}
}
return super.getName(itemType);
} }
@Override
public Component getRichName(BaseItemStack itemStack) {
return TranslatableComponent.of(
ForgeAdapter.adapt(itemStack).getTranslationKey()
);
}
} }

Datei anzeigen

@ -19,6 +19,9 @@
package com.sk89q.worldedit.sponge; package com.sk89q.worldedit.sponge;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.translation.TranslationManager;
import com.sk89q.worldedit.world.biome.BiomeData; import com.sk89q.worldedit.world.biome.BiomeData;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeType;
@ -30,12 +33,21 @@ import javax.annotation.Nullable;
*/ */
class SpongeBiomeRegistry implements BiomeRegistry { class SpongeBiomeRegistry implements BiomeRegistry {
@Override
public Component getRichName(com.sk89q.worldedit.world.biome.BiomeType biomeType) {
return TranslatableComponent.of(
TranslationManager.makeTranslationKey("biome", biomeType.getId())
);
}
@Deprecated
@Nullable @Nullable
@Override @Override
public BiomeData getData(com.sk89q.worldedit.world.biome.BiomeType biome) { public BiomeData getData(com.sk89q.worldedit.world.biome.BiomeType biome) {
return new SpongeBiomeData(SpongeAdapter.adapt(biome)); return new SpongeBiomeData(SpongeAdapter.adapt(biome));
} }
@Deprecated
private static class SpongeBiomeData implements BiomeData { private static class SpongeBiomeData implements BiomeData {
private final BiomeType biome; private final BiomeType biome;
@ -48,6 +60,7 @@ class SpongeBiomeRegistry implements BiomeRegistry {
this.biome = biome; this.biome = biome;
} }
@SuppressWarnings("deprecation")
@Override @Override
public String getName() { public String getName() {
return biome.getName(); return biome.getName();