Don't add active contexts during getPermissionValue calls.

* Fix 'entity-spawn' flag lookups with wrong context.
This commit is contained in:
bloodshot 2020-01-01 19:43:36 -05:00
parent cccb3c79d5
commit 8743c5fe96
4 changed files with 2 additions and 6 deletions

View File

@ -239,7 +239,7 @@ public Tristate getFinalPermission(Event event, Location location, Set<Context>
if (flag == Flags.ENTITY_SPAWN) { if (flag == Flags.ENTITY_SPAWN) {
// Check spawn limit // Check spawn limit
final int spawnLimit = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), GriefDefenderPlugin.DEFAULT_HOLDER, Options.SPAWN_LIMIT, claim, contexts); final int spawnLimit = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), GriefDefenderPlugin.DEFAULT_HOLDER, Options.SPAWN_LIMIT, claim, new HashSet<>(contexts));
if (spawnLimit > -1) { if (spawnLimit > -1) {
if (target instanceof Entity) { if (target instanceof Entity) {
final Entity entity = (Entity) target; final Entity entity = (Entity) target;

View File

@ -579,7 +579,6 @@ public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, Str
} }
public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts) { public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts) {
this.addActiveContexts(contexts, holder, null, claim);
this.checkServerContext(contexts); this.checkServerContext(contexts);
ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy(); ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, contextSet); return this.getPermissionValue(holder, permission, contextSet);
@ -692,7 +691,6 @@ public Tristate getPermissionValueWithRequiredContexts(GDClaim claim, GDPermissi
} }
public Tristate getPermissionValue(GDPermissionHolder holder, String permission, Set<Context> contexts) { public Tristate getPermissionValue(GDPermissionHolder holder, String permission, Set<Context> contexts) {
this.addActiveContexts(contexts, holder, null, null);
this.checkServerContext(contexts); this.checkServerContext(contexts);
ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy(); ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, contextSet); return this.getPermissionValue(holder, permission, contextSet);

View File

@ -284,7 +284,7 @@ public Tristate getFinalPermission(Event event, Location<World> location, Set<Co
if (flag == Flags.ENTITY_SPAWN) { if (flag == Flags.ENTITY_SPAWN) {
// Check spawn limit // Check spawn limit
final int spawnLimit = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), GriefDefenderPlugin.DEFAULT_HOLDER, Options.SPAWN_LIMIT, claim, contexts); final int spawnLimit = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), GriefDefenderPlugin.DEFAULT_HOLDER, Options.SPAWN_LIMIT, claim, new HashSet<>(contexts));
if (spawnLimit > -1) { if (spawnLimit > -1) {
if (target instanceof Entity) { if (target instanceof Entity) {
final Entity entity = (Entity) target; final Entity entity = (Entity) target;

View File

@ -575,7 +575,6 @@ public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, Str
} }
public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts) { public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts) {
this.addActiveContexts(contexts, holder, null, claim);
this.checkServerContext(contexts); this.checkServerContext(contexts);
ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy(); ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, contextSet); return this.getPermissionValue(holder, permission, contextSet);
@ -688,7 +687,6 @@ public Tristate getPermissionValueWithRequiredContexts(GDClaim claim, GDPermissi
} }
public Tristate getPermissionValue(GDPermissionHolder holder, String permission, Set<Context> contexts) { public Tristate getPermissionValue(GDPermissionHolder holder, String permission, Set<Context> contexts) {
this.addActiveContexts(contexts, holder, null, null);
this.checkServerContext(contexts); this.checkServerContext(contexts);
ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy(); ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, contextSet); return this.getPermissionValue(holder, permission, contextSet);