worldtype: Add PVP_WORLD_TYPES and isPvpWorld
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
@@ -75,6 +76,13 @@ public enum WorldType
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
private static EnumSet<WorldType> PVP_WORLD_TYPES = EnumSet.of(
|
||||
DEADMAN,
|
||||
PVP,
|
||||
PVP_HIGH_RISK,
|
||||
SEASONAL_DEADMAN
|
||||
);
|
||||
|
||||
/**
|
||||
* Create enum set of world types from mask.
|
||||
*
|
||||
@@ -113,4 +121,16 @@ public enum WorldType
|
||||
|
||||
return mask;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a world having a {@link Collection} of {@link WorldType}s is a PVP world.
|
||||
*
|
||||
* @param worldTypes A {@link Collection} of {@link WorldType}s describing the given world.
|
||||
* @return True if the given worldtypes of the world are a PVP world, false otherwise.
|
||||
* @see Client#getWorldType()
|
||||
*/
|
||||
public static boolean isPvpWorld(final Collection<WorldType> worldTypes)
|
||||
{
|
||||
return worldTypes.stream().anyMatch(PVP_WORLD_TYPES::contains);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user