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:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user