diff --git a/src/com/massivecraft/mcore/MetadataSimple.java b/src/com/massivecraft/mcore/MetadataSimple.java index c4a05aec..bfd7ddcd 100644 --- a/src/com/massivecraft/mcore/MetadataSimple.java +++ b/src/com/massivecraft/mcore/MetadataSimple.java @@ -50,12 +50,19 @@ public class MetadataSimple extends MetadataValueAdapter metadatable.setMetadata(key, new MetadataSimple(plugin, value)); } - public static Object get(Metadatable metadatable, String key) + public static MetadataValue getMeta(Metadatable metadatable, String key) { List metaValues = metadatable.getMetadata(key); if (metaValues == null) return null; if (metaValues.size() < 1) return null; - return metaValues.get(0).value(); + return metaValues.get(0); + } + + public static Object get(Metadatable metadatable, String key) + { + MetadataValue metaValue = getMeta(metadatable, key); + if (metaValue == null) return null; + return metaValue.value(); } } diff --git a/src/com/massivecraft/mcore/util/MUtil.java b/src/com/massivecraft/mcore/util/MUtil.java index da125041..67e77761 100644 --- a/src/com/massivecraft/mcore/util/MUtil.java +++ b/src/com/massivecraft/mcore/util/MUtil.java @@ -490,6 +490,18 @@ public class MUtil return new ArrayList(coll).get(index); } + public static List random(Collection coll, int count) + { + List ret = new ArrayList(coll); + if (count < 0) count = 0; + while (ret.size() > count) + { + int index = MCore.random.nextInt(ret.size()); + ret.remove(index); + } + return ret; + } + // -------------------------------------------- // // LE NICE EQUALS and compare // -------------------------------------------- //