Update how admins are gotten

This commit is contained in:
Seth 2020-07-08 20:23:18 -07:00
parent fc3ded1615
commit 5b44da4075
No known key found for this signature in database
GPG key ID: A7BAB4E14F089CF3
5 changed files with 26 additions and 38 deletions

View file

@ -1,19 +1,24 @@
name: Java CI
on: [push]
on:
push:
branches:
- breaking
- master
pull_request:
branches:
- breaking
- master
jobs:
build:
runs-on: ubuntu-latest
test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Test with Gradle
run: ./gradlew clean build

View file

@ -1,4 +1,6 @@
repositories {
mavenCentral()
mavenLocal()
maven { url = "https://jitpack.io" }
maven {
name = "papermc"
@ -22,6 +24,7 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp:4.2.2")
implementation("com.squareup.okio:okio:2.4.1")
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.61")
implementation('com.github.TFPatches:TotalFreedomMod:4328a13eaf')
implementation("org.spigotmc:spigot-api:1.15.1-R0.1-SNAPSHOT")
}

View file

@ -10,7 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
public class PlotSquaredHandler
{
@ -30,28 +30,8 @@ public class PlotSquaredHandler
@SuppressWarnings("unchecked")
public boolean isAdmin(Player player) {
if (adminProvider == null) {
final Plugin tfm = getTFM();
if (tfm == null) {
return false;
}
Object provider = null;
for (RegisteredServiceProvider<?> serv : Bukkit.getServicesManager().getRegistrations(tfm)) {
if (Function.class.isAssignableFrom(serv.getService())) {
provider = serv.getProvider();
}
}
if (provider == null) {
warning("Could not obtain admin service provider!");
return false;
}
adminProvider = (Function<Player, Boolean>) provider;
}
return adminProvider.apply(player);
TotalFreedomMod tfm = getTFM();
return tfm.al.isAdmin(player);
}
public static Player getPlayer(PlotPlayer plotPlayer) {
@ -82,7 +62,8 @@ public class PlotSquaredHandler
{
List<String> adminOnlyPermissions = Arrays.asList(
"plots.worldedit.bypass", "plots.area", "plots.grant.add", "plots.debugallowunsafe", "plots.debugroadgen", "plots.debugpaste",
"plots.createroadschematic", "plots.merge", "plots.unlink", "plots.area", "plots.setup", "plots.set.flag.other");
"plots.createroadschematic", "plots.merge", "plots.unlink", "plots.area", "plots.setup", "plots.set.flag.other", "plots.reload",
"plots.backup", "plots.debug");
if (!isAdmin(player))
{
if (permission.startsWith("plots.admin") || adminOnlyPermissions.contains(permission))
@ -119,13 +100,13 @@ public class PlotSquaredHandler
return found;
}
public static Plugin getTFM() {
public static TotalFreedomMod getTFM() {
final Plugin tfm = Bukkit.getPluginManager().getPlugin("TotalFreedomMod");
if (tfm == null) {
LOGGER.warning("Could not resolve plugin: TotalFreedomMod");
}
return tfm;
return (TotalFreedomMod)tfm;
}
public void debug(String debug) {

1
Jenkinsfile vendored
View file

@ -1 +0,0 @@

View file

@ -102,7 +102,7 @@ subprojects {
repositories {
mavenCentral()
maven { url = "http://maven.sk89q.com/repo/" }
maven { url = "http://repo.maven.apache.org/maven2" }
maven { url = "https://repo.maven.apache.org/maven2" }
maven { url = "https://jitpack.io" }
}