Add methods to get translation keys

Co-authored-by: MeFisto94 <MeFisto94@users.noreply.github.com>
This commit is contained in:
Jake Potrebic
2020-08-11 19:17:46 +02:00
parent a3e3ba54a0
commit f610d0b477
18 changed files with 186 additions and 30 deletions

View File

@@ -136,7 +136,7 @@ import org.jetbrains.annotations.Nullable;
* An enum of all material IDs accepted by the official server and client
*/
@SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"}) // Paper
public enum Material implements Keyed, Translatable {
public enum Material implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper
//<editor-fold desc="Materials" defaultstate="collapsed">
AIR(9648, 0),
STONE(22948),
@@ -4834,6 +4834,17 @@ public enum Material implements Keyed, Translatable {
}
// Paper end
// Paper start - add Translatable
@Override
public @NotNull String translationKey() {
if (this.isItem()) {
return java.util.Objects.requireNonNull(this.asItemType()).translationKey();
} else {
return java.util.Objects.requireNonNull(this.asBlockType()).translationKey();
}
}
// Paper end - add Translatable
/**
* Do not use for any reason.
*
@@ -5583,9 +5594,11 @@ public enum Material implements Keyed, Translatable {
* material
* @see #getBlockTranslationKey()
* @see #getItemTranslationKey()
* @deprecated use {@link #translationKey()}
*/
@Override
@NotNull
@Deprecated(forRemoval = true) // Paper
public String getTranslationKey() {
if (this.isItem()) {
return asItemType().getTranslationKey();