#804: Added methods to get translation keys for materials, itemstacks and more

By: mfnalex <mfnalex@gmail.com>
This commit is contained in:
Bukkit/Spigot
2023-02-10 20:51:15 +11:00
parent cd28159b45
commit e17edb7785
6 changed files with 92 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Translatable;
import org.bukkit.Utility;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.enchantments.Enchantment;
@@ -22,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
* use this class to encapsulate Materials for which {@link Material#isItem()}
* returns false.</b>
*/
public class ItemStack implements Cloneable, ConfigurationSerializable {
public class ItemStack implements Cloneable, ConfigurationSerializable, Translatable {
private Material type = Material.AIR;
private int amount = 0;
private MaterialData data = null;
@@ -595,4 +596,10 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
return true;
}
@Override
@NotNull
public String getTranslationKey() {
return Bukkit.getUnsafe().getTranslationKey(this);
}
}