diff --git a/runelite-api/src/main/java/net/runelite/api/WorldType.java b/runelite-api/src/main/java/net/runelite/api/WorldType.java index 88741753b3..81f2ae1d2d 100644 --- a/runelite-api/src/main/java/net/runelite/api/WorldType.java +++ b/runelite-api/src/main/java/net/runelite/api/WorldType.java @@ -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 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; } -} \ No newline at end of file + + /** + * 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 worldTypes) + { + return worldTypes.stream().anyMatch(PVP_WORLD_TYPES::contains); + } +}