Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ e.g.

> whitelisted=true

___
#### `is-op`
Returns if the player is a server operator or not

e.g.

> is-op=true

___
#### `team`
Returns the name of the team the players is in
Expand Down Expand Up @@ -80,4 +88,4 @@ placeholderapi-placeholders:

> allowflight=true

___
___
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/lucko/extracontexts/ExtraContextsPlugin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.lucko.extracontexts;

import me.lucko.extracontexts.calculators.HasPlayedBeforeCalculator;
import me.lucko.extracontexts.calculators.OpCalculator;
import me.lucko.extracontexts.calculators.PlaceholderApiCalculator;
import me.lucko.extracontexts.calculators.TeamCalculator;
import me.lucko.extracontexts.calculators.WhitelistedCalculator;
Expand Down Expand Up @@ -56,6 +57,7 @@ private void setup() {
register("worldguard-region", "WorldGuard", WorldGuardRegionCalculator::new);
register("worldguard-flag", "WorldGuard", WorldGuardFlagCalculator::new);
register("whitelisted", null, WhitelistedCalculator::new);
register("is-op", null, OpCalculator::new);
register("team", null, TeamCalculator::new);
register("has-played-before", null, HasPlayedBeforeCalculator::new);
register("placeholderapi", "PlaceholderAPI", () -> new PlaceholderApiCalculator(getConfig().getConfigurationSection("placeholderapi-placeholders")));
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/me/lucko/extracontexts/calculators/OpCalculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package me.lucko.extracontexts.calculators;

import net.luckperms.api.context.ContextCalculator;
import net.luckperms.api.context.ContextConsumer;
import net.luckperms.api.context.ContextSet;
import net.luckperms.api.context.ImmutableContextSet;

import org.bukkit.entity.Player;

public class OpCalculator implements ContextCalculator<Player> {
private static final String KEY = "is-op";

@Override
public void calculate(Player target, ContextConsumer consumer) {
consumer.accept(KEY, String.valueOf(target.isOp()));
}

@Override
public ContextSet estimatePotentialContexts() {
return ImmutableContextSet.builder()
.add(KEY, "true")
.add(KEY, "false")
.build();
}
}
6 changes: 6 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ worldguard-flag: false
# e.g. whitelisted=true
whitelisted: false

# Provides the 'is-op' context.
# Returns if the player is a server operator or not.
#
# e.g. is-op=true
is-op: false

# Provides the 'team' context.
# Returns the name of the team the players is in.
#
Expand Down