@Test public void testGetMembershipPassthroughAndRegion() throws Exception { MockApplicableRegionSet mock = new MockApplicableRegionSet(); ProtectedRegion region = mock.add(0); region.setFlag(Flags.PASSTHROUGH, State.ALLOW); region = mock.add(0); LocalPlayer player = mock.createPlayer(); FlagValueCalculator result = mock.getFlagCalculator(); assertThat(result.getMembership(player), is(Result.FAIL)); }
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { if (getPriority(region) < minimumPriority) { break; } if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
FlagValueCalculator { public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { if (getPriority(region) < minimumPriority) { break; } if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; } }
FlagValueCalculator { public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { if (getPriority(region) < minimumPriority) { break; } if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; } FlagValueCalculator(List<ProtectedRegion> regions, @Nullable ProtectedRegion globalRegion); }
FlagValueCalculator { public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { if (getPriority(region) < minimumPriority) { break; } if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; } FlagValueCalculator(List<ProtectedRegion> regions, @Nullable ProtectedRegion globalRegion); Result getMembership(RegionAssociable subject); @Nullable State queryState(@Nullable RegionAssociable subject, StateFlag... flags); @Nullable State queryState(@Nullable RegionAssociable subject, StateFlag flag); @Nullable V queryValue(@Nullable RegionAssociable subject, Flag<V> flag); Collection<V> queryAllValues(@Nullable RegionAssociable subject, Flag<V> flag); int getPriority(final ProtectedRegion region); @SuppressWarnings("unchecked") V getEffectiveFlag(final ProtectedRegion region, Flag<V> flag, @Nullable RegionAssociable subject); }
FlagValueCalculator { public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { if (getPriority(region) < minimumPriority) { break; } if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; } FlagValueCalculator(List<ProtectedRegion> regions, @Nullable ProtectedRegion globalRegion); Result getMembership(RegionAssociable subject); @Nullable State queryState(@Nullable RegionAssociable subject, StateFlag... flags); @Nullable State queryState(@Nullable RegionAssociable subject, StateFlag flag); @Nullable V queryValue(@Nullable RegionAssociable subject, Flag<V> flag); Collection<V> queryAllValues(@Nullable RegionAssociable subject, Flag<V> flag); int getPriority(final ProtectedRegion region); @SuppressWarnings("unchecked") V getEffectiveFlag(final ProtectedRegion region, Flag<V> flag, @Nullable RegionAssociable subject);  }