/**
* A helper method to convert a tag directly to a MetadataValue.
*
* @param plugin The owning plugin
* @param tag The tag to convert
* @return A new MetadataValue object, or null if the tag could not be converted
*/
public static PersistentMetadataValue convertToMetadata(Plugin plugin, NBTBase tag) {
if (plugin == null || tag == null) return null;
Object converted = convert(tag);
// Note that we don't currently export arrays as metadata
if (converted instanceof String) {
return new PersistentMetadataValue(plugin, (String)converted);
} else if (converted instanceof Integer) {
return new PersistentMetadataValue(plugin, (Integer)converted);
} else if (converted instanceof Short) {
return new PersistentMetadataValue(plugin, (Short)converted);
} else if (converted instanceof Byte) {
return new PersistentMetadataValue(plugin, (Byte)converted);
} else if (converted instanceof Long) {
return new PersistentMetadataValue(plugin, (Long)converted);
} else if (converted instanceof Float) {
return new PersistentMetadataValue(plugin, (Float)converted);
} else if (converted instanceof Double) {
return new PersistentMetadataValue(plugin, (Double)converted);
} else if (converted instanceof Map) {
return new PersistentMetadataValue(plugin, (Map<String, ?>)converted);
} else if (converted instanceof List) {
return new PersistentMetadataValue(plugin, (List<?>)converted);
} else if (converted instanceof ConfigurationSerializable) {
return new PersistentMetadataValue(plugin, (ConfigurationSerializable)converted);
}
return null;
}
NBTMetadataStore.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:Tweakkit-Server
作者:
评论列表
文章目录