Add methods to get translation keys

== AT ==
public org.bukkit.craftbukkit.inventory.CraftMetaFirework
public org.bukkit.craftbukkit.inventory.CraftMetaFirework power
public org.bukkit.craftbukkit.inventory.CraftMetaFirework getNBT(Lorg/bukkit/FireworkEffect$Type;)Lnet/minecraft/world/item/component/FireworkExplosion$Shape;

Co-authored-by: MeFisto94 <MeFisto94@users.noreply.github.com>
This commit is contained in:
Jake Potrebic
2020-08-11 19:16:09 +02:00
parent 4f4d4ac73e
commit 97620482eb
8 changed files with 121 additions and 1 deletions

View File

@@ -68,6 +68,16 @@ public class CraftMusicInstrument extends MusicInstrument implements Handleable<
return this.key;
}
// Paper start - add translationKey methods
@Override
public @NotNull String translationKey() {
if (!(this.getHandle().description().getContents() instanceof final net.minecraft.network.chat.contents.TranslatableContents translatableContents)) {
throw new UnsupportedOperationException("Description isn't translatable!"); // Paper
}
return translatableContents.getKey();
}
// Paper end - add translationKey methods
@Override
public boolean equals(Object other) {
if (this == other) {

View File

@@ -98,6 +98,11 @@ public class CraftAttribute implements Attribute, Handleable<net.minecraft.world
return this.attributeBase.getDescriptionId();
}
@Override
public @NotNull String translationKey() {
return this.attributeBase.getDescriptionId();
}
@Override
public int compareTo(@NotNull Attribute attribute) {
return this.ordinal - attribute.ordinal();

View File

@@ -669,5 +669,10 @@ public class CraftBlock implements Block {
public org.bukkit.SoundGroup getBlockSoundGroup() {
return org.bukkit.craftbukkit.CraftSoundGroup.getSoundGroup(this.getNMS().getSoundType());
}
@Override
public String translationKey() {
return this.getNMS().getBlock().getDescriptionId();
}
// Paper end
}

View File

@@ -234,4 +234,11 @@ public class CraftBlockType<B extends BlockData> implements BlockType.Typed<B>,
public Material asMaterial() {
return Registry.MATERIAL.get(this.key);
}
// Paper start - add Translatable
@Override
public String translationKey() {
return this.block.getDescriptionId();
}
// Paper end - add Translatable
}

View File

@@ -152,6 +152,17 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
}
// Paper end
// Paper start - add translationKey methods
@Override
public String translationKey() {
if (!(this.getHandle().description().getContents() instanceof final net.minecraft.network.chat.contents.TranslatableContents translatableContents)) {
throw new UnsupportedOperationException("Description isn't translatable!"); // Paper
}
return translatableContents.getKey();
}
// Paper end - add translationKey methods
@Override
public String getTranslationKey() {
return Util.makeDescriptionId("enchantment", this.handle.unwrapKey().get().location());

View File

@@ -237,4 +237,11 @@ public class CraftItemType<M extends ItemMeta> implements ItemType.Typed<M>, Han
public Material asMaterial() {
return Registry.MATERIAL.get(this.key);
}
// Paper start - add Translatable
@Override
public String translationKey() {
return this.item.getDescriptionId();
}
// Paper end - add Translatable
}

View File

@@ -123,7 +123,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
return new FireworkExplosion(CraftMetaFirework.getNBT(effect.getType()), colors, fadeColors, effect.hasTrail(), effect.hasFlicker());
}
static FireworkExplosion.Shape getNBT(Type type) {
public static FireworkExplosion.Shape getNBT(Type type) { // Paper - package-private -> public
switch (type) {
case BALL:
return FireworkExplosion.Shape.SMALL_BALL;