Make UtilEnt#GetMetadata infer needed type

This commit is contained in:
AlexTheCoder 2017-07-15 15:45:24 -04:00 committed by cnr
parent eb566d3363
commit 66e5339eab
2 changed files with 4 additions and 3 deletions

View File

@ -1025,14 +1025,15 @@ public class UtilEnt
}
// Nicer than doing entity.getMetadata(key).get(0);
public static Object GetMetadata(Entity entity, String key)
@SuppressWarnings("unchecked")
public static <T> T GetMetadata(Entity entity, String key)
{
if (!entity.hasMetadata(key))
{
return null;
}
return entity.getMetadata(key).get(0).value();
return (T) entity.getMetadata(key).get(0).value();
}
public static void removeMetadata(Entity entity, String key)

View File

@ -268,7 +268,7 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
{
if (UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME") != null)
{
Long dismount = (Long) UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME");
Long dismount = UtilEnt.GetMetadata(entry.getKey(), "DISMOUNT_TIME");
if (UtilTime.elapsed(dismount.longValue(), MAX_TIME_DISMOUNTED))
{
mountIterator.remove();