Created
August 22, 2018 13:23
-
-
Save cindyker/90d1a00efa50651b538b4cbcf6f24f01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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