Skip to content

Instantly share code, notes, and snippets.

@cindyker
Created August 22, 2018 13:23
Show Gist options
  • Save cindyker/90d1a00efa50651b538b4cbcf6f24f01 to your computer and use it in GitHub Desktop.
Save cindyker/90d1a00efa50651b538b4cbcf6f24f01 to your computer and use it in GitHub Desktop.
//Reading metadata functions...
///////////////////////////////////////////////////
public String getMetadataString(Player player, String key, Plugin plugin) {
List<MetadataValue> values = player.getMetadata(key);
for (MetadataValue value : values) {
if (value.getOwningPlugin().getDescription().getName().equals(plugin.getDescription().getName())) {
return value.asString(); //value();
}
}
return "";
}
public boolean getMetadata(Player player, String key, Plugin plugin) {
List<MetadataValue> values = player.getMetadata(key);
if(plugin == null){ logme( LOG_LEVELS.DEBUG, "getMetadata Plugin info", "Plugin is null");return false; }
if(plugin.getDescription() == null){logme( LOG_LEVELS.DEBUG, "getMetadata Plugin info", "Plugin.getDescription is null"); return false; }
if(plugin.getDescription().getName() == null){logme( LOG_LEVELS.DEBUG, "getMetadata Plugin info", "Plugin.getDescription.getName is null"); return false; }
for (MetadataValue value : values) {
if (value.getOwningPlugin().getDescription().getName().equals(plugin.getDescription().getName())) {
return value.asBoolean(); //value();
}
}
return false;
}
///////////////////////////////
//Setting Metadata
player.setMetadata("currentchannel", new FixedMetadataValue(plugin, curChannel));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment