mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Update how admins are gotten
This commit is contained in:
parent
fc3ded1615
commit
5b44da4075
5 changed files with 26 additions and 38 deletions
23
.github/workflows/gradle.yml
vendored
23
.github/workflows/gradle.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
@ -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
1
Jenkinsfile
vendored
|
@ -1 +0,0 @@
|
|||
|
|
@ -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" }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue