Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
416b22ba77 | ||
|
|
e58147aea0 | ||
|
|
1ddc5f1798 | ||
|
|
956cd3c029 | ||
|
|
efff714ca2 | ||
|
|
ed88680013 | ||
|
|
c194dbd624 | ||
|
|
5ddf63ca83 | ||
|
|
fea5597b93 | ||
|
|
8e0e09b62d | ||
|
|
dd808195f9 | ||
|
|
6220457381 | ||
|
|
7aa0007bfc | ||
|
|
548d04b69e | ||
|
|
59415b0b3e | ||
|
|
a43f3e42f5 | ||
|
|
6efce1cfe3 | ||
|
|
edb9edf3eb | ||
|
|
953ea8158d | ||
|
|
914b6fcef5 | ||
|
|
f829a152be | ||
|
|
b848d092fb | ||
|
|
0799f4f9c4 | ||
|
|
cd7271e247 | ||
|
|
12c6d3fb85 | ||
|
|
56fc696fd6 | ||
|
|
2dc3b75d5b | ||
|
|
c55ecb435e | ||
|
|
28b979f975 | ||
|
|
6e9094d9f0 | ||
|
|
672674a1a2 | ||
|
|
d2d5b5513f | ||
|
|
a5a201f289 | ||
|
|
b680efef52 | ||
|
|
f00cc3fc5b | ||
|
|
c5840658a2 | ||
|
|
c5183fa01b | ||
|
|
6eaccf2b65 | ||
|
|
e4df40df11 | ||
|
|
d2f8f17f90 | ||
|
|
1b1ee632c5 | ||
|
|
0758c0e526 | ||
|
|
6d49072d31 | ||
|
|
61d29e983c | ||
|
|
8b886739da | ||
|
|
33eb4711ca | ||
|
|
1dc0cba891 | ||
|
|
dba1f47d26 | ||
|
|
e38c5312c3 | ||
|
|
402ed6b10e | ||
|
|
f4d81a24f9 | ||
|
|
5bcda30624 | ||
|
|
4d9c9ddbc3 | ||
|
|
5426949be3 | ||
|
|
a1b4d64ea4 | ||
|
|
2abc476b85 | ||
|
|
e909ef687c | ||
|
|
bb237abc01 | ||
|
|
e865b0013e | ||
|
|
fe59f35290 | ||
|
|
0493adac46 | ||
|
|
8478013286 | ||
|
|
cf1a00d5a5 | ||
|
|
a18b81b2b5 | ||
|
|
3a10aa2f69 | ||
|
|
21b537d427 | ||
|
|
b80d48202e | ||
|
|
c63be1d382 | ||
|
|
409225b9e6 | ||
|
|
f56c4ddfbf | ||
|
|
4aa8afc794 | ||
|
|
e419b045ae | ||
|
|
9cc677b3c2 | ||
|
|
f09b8a44d3 | ||
|
|
9006321454 | ||
|
|
81468ca694 | ||
|
|
9780d0b729 | ||
|
|
b636018b65 | ||
|
|
b537bd1488 | ||
|
|
9f85d2d641 | ||
|
|
669f0b0c5b | ||
|
|
6e971aa7e3 | ||
|
|
fa3da54687 |
No files matched your search
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
@@ -23,6 +23,6 @@ jobs:
|
||||
distribution: 'temurin'
|
||||
cache: 'gradle'
|
||||
- name: Build with Gradle
|
||||
uses: gradle/gradle-build-action@d23c38fad3e837961b39af2b98b046694927aca4
|
||||
uses: gradle/gradle-build-action@9bca466e2722baf9e77b4f929bbe0af18848791f
|
||||
with:
|
||||
arguments: build
|
||||
@@ -15,6 +15,8 @@ LuckPerms Expansion for MiniPlaceholders
|
||||
|
||||
`<luckperms_inherits_group:group>` (true/false)
|
||||
|
||||
`<luckperms_meta:meta-key>`
|
||||
|
||||
## Downloads
|
||||
|
||||
[](https://modrinth.com/plugin/luckperms-expansion)
|
||||
+11
-6
@@ -4,15 +4,13 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":luckperms-expansion-velocity"))
|
||||
implementation(project(":luckperms-expansion-paper"))
|
||||
implementation(projects.luckpermsExpansionPaper)
|
||||
implementation(projects.luckpermsExpansionVelocity)
|
||||
implementation(projects.luckpermsExpansionSponge)
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply<JavaPlugin>()
|
||||
repositories {
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
|
||||
@@ -26,7 +24,14 @@ subprojects {
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("LuckPerms-Expansion-${project.version}.jar")
|
||||
archiveFileName.set("MiniPlaceholders-LuckPerms-Expansion-${project.version}.jar")
|
||||
archiveClassifier.set("")
|
||||
doLast {
|
||||
copy {
|
||||
from(archiveFile)
|
||||
into("${rootProject.projectDir}/build")
|
||||
}
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
build {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
dependencies {
|
||||
compileOnly(libs.miniplaceholders)
|
||||
compileOnly(libs.adventure.api)
|
||||
compileOnly(libs.adventure.minimessage)
|
||||
compileOnly(libs.adventure.legacy)
|
||||
compileOnly(libs.luckperms)
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
package io.github.miniplaceholders.expansion.luckperms.common;
|
||||
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.api.utils.TagsUtils;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
import net.luckperms.api.util.Tristate;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.github.miniplaceholders.api.utils.Components.*;
|
||||
import static io.github.miniplaceholders.api.utils.LegacyUtils.*;
|
||||
|
||||
public record CommonExpansion(LuckPerms luckPerms) {
|
||||
private static final Component UNDEFINED_COMPONENT = Component.text("undefined", NamedTextColor.GRAY);
|
||||
|
||||
public Expansion.Builder commonBuilder() {
|
||||
return Expansion.builder("luckperms")
|
||||
.audiencePlaceholder("prefix", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
return Tag.inserting(parsePossibleLegacy(user.getCachedData().getMetaData().getPrefix(), ctx));
|
||||
})
|
||||
.audiencePlaceholder("suffix", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
return Tag.inserting(parsePossibleLegacy(user.getCachedData().getMetaData().getSuffix(), ctx));
|
||||
})
|
||||
.audiencePlaceholder("meta", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
final String meta = queue.popOr(() -> "you need to introduce a meta key").value();
|
||||
final Optional<QueryOptions> queryOptions = this.luckPerms.getContextManager().getQueryOptions(user);
|
||||
if (queryOptions.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
final String result = user.getCachedData().getMetaData(queryOptions.get()).getMetaValue(meta);
|
||||
if (result == null) {
|
||||
return TagsUtils.EMPTY_TAG;
|
||||
}
|
||||
return Tag.preProcessParsed(result);
|
||||
})
|
||||
.audiencePlaceholder("has_permission", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
final String permission = queue.popOr(() -> "you need to introduce an permission").value();
|
||||
final Tristate result = user.getCachedData().getPermissionData().checkPermission(permission);
|
||||
return Tag.selfClosingInserting(result.asBoolean()
|
||||
? TRUE_COMPONENT
|
||||
: FALSE_COMPONENT
|
||||
);
|
||||
})
|
||||
.audiencePlaceholder("check_permission", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
final String permission = queue.popOr(() -> "you need to introduce an permission").value();
|
||||
final Tristate result = user.getCachedData().getPermissionData().checkPermission(permission);
|
||||
return Tag.selfClosingInserting(switch(result) {
|
||||
case TRUE -> TRUE_COMPONENT;
|
||||
case FALSE -> FALSE_COMPONENT;
|
||||
case UNDEFINED -> UNDEFINED_COMPONENT;
|
||||
});
|
||||
})
|
||||
.audiencePlaceholder("inherited_groups", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
final Component groups = user.getInheritedGroups(user.getQueryOptions()).stream()
|
||||
.map(group -> parsePossibleLegacy(group.getDisplayName(), ctx))
|
||||
.collect(Component.toComponent(Component.text(", ")));
|
||||
return Tag.selfClosingInserting(groups);
|
||||
})
|
||||
.audiencePlaceholder("primary_group_name", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
final String primaryGroup = user.getCachedData().getMetaData().getPrimaryGroup();
|
||||
if (primaryGroup == null) {
|
||||
return TagsUtils.EMPTY_TAG;
|
||||
}
|
||||
return Tag.preProcessParsed(primaryGroup);
|
||||
})
|
||||
.audiencePlaceholder("inherits_group", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
final Group group = luckPerms.getGroupManager().getGroup(queue.popOr("you need to provide a group").value());
|
||||
return Tag.selfClosingInserting(group != null && user.getInheritedGroups(user.getQueryOptions()).contains(group)
|
||||
? TRUE_COMPONENT
|
||||
: FALSE_COMPONENT
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private User user(final Audience audience) {
|
||||
final UUID uuid = audience.get(Identity.UUID).orElse(null);
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
}
|
||||
return luckPerms.getUserManager().getUser(uuid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
plugins {
|
||||
id("fabric-loom")
|
||||
alias(libs.plugins.shadow)
|
||||
}
|
||||
|
||||
val shade: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.luckperms)
|
||||
compileOnly(libs.miniplaceholders)
|
||||
implementation(projects.luckpermsExpansionCommon)
|
||||
shade(projects.luckpermsExpansionCommon)
|
||||
minecraft(libs.minecraft)
|
||||
mappings(loom.officialMojangMappings())
|
||||
modImplementation(libs.fabric.loader)
|
||||
modImplementation(libs.fabric.api)
|
||||
modImplementation(libs.adventure.platform.fabric)
|
||||
}
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand("version" to project.version)
|
||||
}
|
||||
}
|
||||
remapJar {
|
||||
inputFile.set(shadowJar.get().archiveFile)
|
||||
archiveFileName.set("MiniPlaceholders-LuckPerms-Expansion-Fabric-${project.version}.jar")
|
||||
doLast {
|
||||
copy {
|
||||
from(archiveFile)
|
||||
into("${rootProject.projectDir}/build")
|
||||
}
|
||||
}
|
||||
}
|
||||
shadowJar {
|
||||
configurations = listOf(shade)
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package io.github.miniplaceholders.expansion.luckperms.fabric;
|
||||
|
||||
import io.github.miniplaceholders.expansion.luckperms.common.CommonExpansion;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class FabricMod implements ModInitializer {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("miniplaceholders-luckperms-expansion");
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("Starting LuckPerms Expansion for Fabric");
|
||||
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
||||
final LuckPerms luckPerms = LuckPermsProvider.get();
|
||||
new CommonExpansion(luckPerms).commonBuilder()
|
||||
.filter(ServerPlayer.class)
|
||||
.build()
|
||||
.register();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "miniplaceholders-luckperms-expansion",
|
||||
"version": "${version}",
|
||||
"name": "MiniPlaceholders-LuckPerms-Expansion",
|
||||
"authors": [
|
||||
"4drian3d"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://github.com/MiniPlaceholders/LuckPerms-Expansion",
|
||||
"sources": "https://github.com/MiniPlaceholders/LuckPerms-Expansion",
|
||||
"issues": "https://github.com/MiniPlaceholders/LuckPerms-Expansion/issues"
|
||||
},
|
||||
"license": "GPL",
|
||||
"environment": "server",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"io.github.miniplaceholders.expansion.luckperms.fabric.FabricMod"
|
||||
]
|
||||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.22",
|
||||
"fabric": "*",
|
||||
"java": ">=17",
|
||||
"minecraft": ">=1.20.1",
|
||||
"miniplaceholders": ">=2.2.1",
|
||||
"luckperms": ">=5.4.0"
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
group = io.github.miniplaceholders
|
||||
version = 1.1.1
|
||||
description = LuckPerms-Expansion
|
||||
version = 1.4.1
|
||||
description = LuckPerms-Expansion
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
@@ -3,15 +3,21 @@ metadata.format.version = "1.1"
|
||||
[versions]
|
||||
|
||||
velocity = "3.2.0-SNAPSHOT"
|
||||
paper = "1.19.3-R0.1-SNAPSHOT"
|
||||
paper = "1.20.2-R0.1-SNAPSHOT"
|
||||
|
||||
blossom = "1.3.1"
|
||||
blossom = "2.1.0"
|
||||
shadow = "8.1.1"
|
||||
runtask = "2.1.0"
|
||||
pluginyml = "0.5.3"
|
||||
runtask = "2.2.0"
|
||||
pluginyml = "0.6.0"
|
||||
|
||||
miniplaceholders = "2.1.0"
|
||||
miniplaceholders = "2.2.2"
|
||||
luckperms = "5.4"
|
||||
adventure = "4.14.0"
|
||||
|
||||
fabric-loader = "0.14.24"
|
||||
fabric-api = "0.90.1+1.20.3"
|
||||
minecraft = "1.20.1"
|
||||
adventurefabric = "5.10.0"
|
||||
|
||||
[libraries]
|
||||
|
||||
@@ -20,6 +26,15 @@ paper-api = { group = "io.papermc.paper", name = "paper-api", version.ref = "pap
|
||||
miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" }
|
||||
luckperms = { module = "net.luckperms:api", version.ref = "luckperms" }
|
||||
|
||||
adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
|
||||
adventure-minimessage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" }
|
||||
adventure-legacy = { group = "net.kyori", name = "adventure-text-serializer-legacy", version.ref = "adventure" }
|
||||
|
||||
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric-loader" }
|
||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
|
||||
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
|
||||
adventure-platform-fabric = { group = "net.kyori", name = "adventure-platform-fabric", version.ref = "adventurefabric" }
|
||||
|
||||
[plugins]
|
||||
|
||||
blossom = { id = "net.kyori.blossom", version.ref = "blossom" }
|
||||
@@ -27,3 +42,4 @@ shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
|
||||
runvelocity = { id = "xyz.jpenilla.run-velocity", version.ref = "runtask" }
|
||||
runpaper = { id = "xyz.jpenilla.run-velocity", version.ref = "runtask" }
|
||||
pluginyml = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "pluginyml" }
|
||||
idea-ext = { id = "org.jetbrains.gradle.plugin.idea-ext", version = "1.1.7" }
|
||||
Vendored
BIN
Binary file not shown.
+2
-1
@@ -1,6 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -83,7 +83,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -130,10 +131,13 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -198,11 +202,11 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
@@ -6,6 +6,7 @@ dependencies {
|
||||
compileOnly(libs.paper.api)
|
||||
compileOnly(libs.miniplaceholders)
|
||||
compileOnly(libs.luckperms)
|
||||
implementation(projects.luckpermsExpansionCommon)
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
+7
-66
@@ -1,15 +1,7 @@
|
||||
package io.github.miniplaceholders.expansion.luckperms.paper;
|
||||
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.api.utils.LegacyUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import io.github.miniplaceholders.expansion.luckperms.common.CommonExpansion;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.platform.PlayerAdapter;
|
||||
import net.luckperms.api.util.Tristate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
@@ -17,73 +9,22 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class PaperPlugin extends JavaPlugin {
|
||||
private static final Component FALSE_COMPONENT = Component.text(false, NamedTextColor.RED);
|
||||
private static final Component TRUE_COMPONENT = Component.text(true, NamedTextColor.GREEN);
|
||||
private static final Component UNDEFINED_COMPONENT = Component.text("undefined", NamedTextColor.GRAY);
|
||||
@Override
|
||||
public void onEnable(){
|
||||
this.getSLF4JLogger().info("Starting LuckPerms Expansion for Paper");
|
||||
|
||||
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
|
||||
final RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
|
||||
if (provider == null) {
|
||||
this.getSLF4JLogger().error("Cannot found LuckPerms plugin, disabling expansion");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
LuckPerms luckPerms = provider.getProvider();
|
||||
final LuckPerms luckPerms = provider.getProvider();
|
||||
|
||||
PlayerAdapter<Player> adapter = luckPerms.getPlayerAdapter(Player.class);
|
||||
|
||||
Expansion.builder("luckperms")
|
||||
.filter(Player.class)
|
||||
.audiencePlaceholder("prefix", (aud, queue, ctx) ->
|
||||
Tag.inserting(LegacyUtils.parsePossibleLegacy(adapter.getMetaData((Player)aud).getPrefix())))
|
||||
.audiencePlaceholder("suffix", (aud, queue, ctx) ->
|
||||
Tag.inserting(LegacyUtils.parsePossibleLegacy(adapter.getMetaData((Player)aud).getSuffix())))
|
||||
.audiencePlaceholder("has_permission", (aud, queue, ctx) -> {
|
||||
User user = adapter.getUser((Player)aud);
|
||||
String permission = queue.popOr(() -> "you need to introduce an permission").value();
|
||||
Tristate result = user.getCachedData().getPermissionData().checkPermission(permission);
|
||||
return Tag.selfClosingInserting(result.asBoolean()
|
||||
? TRUE_COMPONENT
|
||||
: FALSE_COMPONENT
|
||||
);
|
||||
})
|
||||
.audiencePlaceholder("check_permission", (aud, queue, ctx) -> {
|
||||
User user = adapter.getUser((Player)aud);
|
||||
String permission = queue.popOr(() -> "you need to introduce an permission").value();
|
||||
Tristate result = user.getCachedData().getPermissionData().checkPermission(permission);
|
||||
|
||||
return Tag.selfClosingInserting(switch(result) {
|
||||
case TRUE -> TRUE_COMPONENT;
|
||||
case FALSE -> FALSE_COMPONENT;
|
||||
case UNDEFINED -> UNDEFINED_COMPONENT;
|
||||
});
|
||||
})
|
||||
.audiencePlaceholder("inherited_groups", (aud, queue, ctx) -> {
|
||||
User user = adapter.getUser((Player)aud);
|
||||
Component groups = user.getInheritedGroups(user.getQueryOptions()).stream()
|
||||
.map(group -> LegacyUtils.parsePossibleLegacy(group.getDisplayName()))
|
||||
.collect(Component.toComponent(Component.space()));
|
||||
return Tag.selfClosingInserting(groups);
|
||||
})
|
||||
.audiencePlaceholder("primary_group_name", (aud, queue, ctx) -> {
|
||||
final String primaryGroup = adapter.getUser((Player)aud).getCachedData().getMetaData().getPrimaryGroup();
|
||||
if (primaryGroup == null) {
|
||||
return null;
|
||||
}
|
||||
return Tag.preProcessParsed(primaryGroup);
|
||||
})
|
||||
.audiencePlaceholder("inherits_group", (aud, queue, ctx) -> {
|
||||
User user = adapter.getUser((Player)aud);
|
||||
Group group = luckPerms.getGroupManager().getGroup(queue.popOr(() -> "you need to provide a group").value());
|
||||
return Tag.selfClosingInserting(group != null && user.getInheritedGroups(user.getQueryOptions()).contains(group)
|
||||
? TRUE_COMPONENT
|
||||
: FALSE_COMPONENT
|
||||
);
|
||||
})
|
||||
.build()
|
||||
.register();
|
||||
new CommonExpansion(luckPerms).commonBuilder()
|
||||
.filter(Player.class)
|
||||
.build()
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
name: LuckPerms-Expansion
|
||||
name: MiniPlaceholders-LuckPerms-Expansion
|
||||
version: '${version}'
|
||||
author: 4drian3d
|
||||
main: io.github.miniplaceholders.expansion.luckperms.paper.PaperPlugin
|
||||
|
||||
+26
-2
@@ -1,6 +1,30 @@
|
||||
rootProject.name = "Luckperms-Expansion"
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
rootProject.name = "LuckPerms-Expansion"
|
||||
|
||||
arrayOf("paper", "velocity").forEach {
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
//maven("https://oss.sonatype.org/content/repositories/snapshots")
|
||||
}
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
}
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
maven("https://maven.fabricmc.net/")
|
||||
maven("https://maven.quiltmc.org/repository/release/")
|
||||
}
|
||||
}
|
||||
|
||||
arrayOf("common", "paper", "velocity", "sponge", "fabric").forEach {
|
||||
include("luckperms-expansion-$it")
|
||||
project(":luckperms-expansion-$it").projectDir = file(it)
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
|
||||
id("fabric-loom") version "1.4.4"
|
||||
id("org.spongepowered.gradle.plugin") version "2.2.0"
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import org.spongepowered.gradle.plugin.config.PluginLoaders
|
||||
import org.spongepowered.plugin.metadata.model.PluginDependency
|
||||
|
||||
plugins {
|
||||
id("org.spongepowered.gradle.plugin")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.miniplaceholders)
|
||||
compileOnly(libs.luckperms)
|
||||
implementation(projects.luckpermsExpansionCommon)
|
||||
}
|
||||
|
||||
sponge {
|
||||
apiVersion("8.1.0")
|
||||
license("GPL-3")
|
||||
loader {
|
||||
name(PluginLoaders.JAVA_PLAIN)
|
||||
version("1.0")
|
||||
}
|
||||
plugin("miniplaceholders-luckperms-expansion") {
|
||||
displayName("MiniPlaceholders-LuckPerms-Expansion")
|
||||
entrypoint("io.github.miniplaceholders.expansion.luckperms.sponge.SpongePlugin")
|
||||
description(project.description)
|
||||
links {
|
||||
homepage("https://github.com/MiniPlaceholders/LuckPerms-Expansion")
|
||||
source("https://github.com/MiniPlaceholders/LuckPerms-Expansion")
|
||||
issues("https://github.com/MiniPlaceholders/LuckPerms-Expansion/issues")
|
||||
}
|
||||
contributor("4drian3d") {
|
||||
description("Lead Developer")
|
||||
}
|
||||
dependency("spongeapi") {
|
||||
loadOrder(PluginDependency.LoadOrder.AFTER)
|
||||
optional(false)
|
||||
}
|
||||
dependency("miniplaceholders") {
|
||||
loadOrder(PluginDependency.LoadOrder.AFTER)
|
||||
optional(false)
|
||||
version("2.2.0")
|
||||
}
|
||||
dependency("luckperms") {
|
||||
loadOrder(PluginDependency.LoadOrder.AFTER)
|
||||
optional(false)
|
||||
version("5.4.98")
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package io.github.miniplaceholders.expansion.luckperms.sponge;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.github.miniplaceholders.expansion.luckperms.common.CommonExpansion;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.api.Server;
|
||||
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.lifecycle.StartingEngineEvent;
|
||||
import org.spongepowered.plugin.builtin.jvm.Plugin;
|
||||
|
||||
@Plugin("miniplaceholders-luckperms-expansion")
|
||||
public class SpongePlugin {
|
||||
@Inject
|
||||
private Logger logger;
|
||||
|
||||
@Listener
|
||||
public void onServerStart(final StartingEngineEvent<Server> event) {
|
||||
this.logger.info("Starting LuckPerms Expansion for Sponge");
|
||||
|
||||
final LuckPerms luckPerms = LuckPermsProvider.get();
|
||||
new CommonExpansion(luckPerms).commonBuilder()
|
||||
.filter(ServerPlayer.class)
|
||||
.build()
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,22 @@
|
||||
plugins {
|
||||
alias(libs.plugins.idea.ext)
|
||||
alias(libs.plugins.blossom)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.velocity.api)
|
||||
annotationProcessor(libs.velocity.api)
|
||||
compileOnly(libs.miniplaceholders)
|
||||
compileOnly(libs.luckperms)
|
||||
implementation(projects.luckpermsExpansionCommon)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
blossom {
|
||||
javaSources {
|
||||
property("version", project.version.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package io.github.miniplaceholders.expansion.luckperms.velocity;
|
||||
|
||||
public class Constants {
|
||||
private Constants() {}
|
||||
static final String VERSION = "{{ version }}";
|
||||
}
|
||||
+16
-71
@@ -6,37 +6,24 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.api.utils.LegacyUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import io.github.miniplaceholders.expansion.luckperms.common.CommonExpansion;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.platform.PlayerAdapter;
|
||||
import net.luckperms.api.util.Tristate;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Plugin(
|
||||
name = "LuckPerms-Expansion",
|
||||
id = "luckperms-expansion",
|
||||
version = "1.0.0",
|
||||
authors = {"4drian3d"},
|
||||
dependencies = {
|
||||
@Dependency(id = "miniplaceholders"),
|
||||
@Dependency(id = "luckperms")
|
||||
}
|
||||
|
||||
name = "MiniPlaceholders-LuckPerms-Expansion",
|
||||
id = "miniplaceholders-luckperms-expansion",
|
||||
version = Constants.VERSION,
|
||||
authors = {"4drian3d"},
|
||||
dependencies = {
|
||||
@Dependency(id = "miniplaceholders"),
|
||||
@Dependency(id = "luckperms")
|
||||
}
|
||||
|
||||
)
|
||||
public final class VelocityPlugin {
|
||||
private final Logger logger;
|
||||
private static final Component FALSE_COMPONENT = Component.text(false, NamedTextColor.RED);
|
||||
private static final Component TRUE_COMPONENT = Component.text(true, NamedTextColor.GREEN);
|
||||
private static final Component UNDEFINED_COMPONENT = Component.text("undefined", NamedTextColor.GRAY);
|
||||
|
||||
@Inject
|
||||
public VelocityPlugin(Logger logger) {
|
||||
@@ -44,56 +31,14 @@ public final class VelocityPlugin {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialize(ProxyInitializeEvent event) {
|
||||
public void onProxyInitialize(final ProxyInitializeEvent event) {
|
||||
logger.info("Starting LuckPerms Expansion for Velocity");
|
||||
|
||||
LuckPerms luckPerms = LuckPermsProvider.get();
|
||||
final LuckPerms luckPerms = LuckPermsProvider.get();
|
||||
|
||||
PlayerAdapter<Player> adapter = luckPerms.getPlayerAdapter(Player.class);
|
||||
|
||||
Expansion.builder("luckperms")
|
||||
.filter(Player.class)
|
||||
.audiencePlaceholder("prefix", (aud, queue, ctx) -> Tag.inserting(LegacyUtils.parsePossibleLegacy(adapter.getMetaData((Player)aud).getPrefix())))
|
||||
.audiencePlaceholder("suffix", (aud, queue, ctx) ->
|
||||
Tag.inserting(LegacyUtils.parsePossibleLegacy(adapter.getMetaData((Player)aud).getSuffix())))
|
||||
.audiencePlaceholder("has_permission", (aud, queue, ctx) -> {
|
||||
User user = adapter.getUser((Player)aud);
|
||||
String permission = queue.popOr(() -> "you need to introduce an permission").value();
|
||||
Tristate result = user.getCachedData().getPermissionData().checkPermission(permission);
|
||||
return Tag.selfClosingInserting(result.asBoolean()
|
||||
? TRUE_COMPONENT
|
||||
: FALSE_COMPONENT
|
||||
);
|
||||
})
|
||||
.audiencePlaceholder("check_permission", (aud, queue, ctx) -> {
|
||||
User user = adapter.getUser((Player)aud);
|
||||
String permission = queue.popOr(() -> "you need to introduce an permission").value();
|
||||
Tristate result = user.getCachedData().getPermissionData().checkPermission(permission);
|
||||
|
||||
return Tag.selfClosingInserting(switch(result) {
|
||||
case TRUE -> TRUE_COMPONENT;
|
||||
case FALSE -> FALSE_COMPONENT;
|
||||
case UNDEFINED -> UNDEFINED_COMPONENT;
|
||||
});
|
||||
})
|
||||
.audiencePlaceholder("inherited_groups", (aud, queue, ctx) -> {
|
||||
User user = adapter.getUser((Player)aud);
|
||||
String groups = user.getInheritedGroups(user.getQueryOptions()).stream()
|
||||
.map(Group::getDisplayName)
|
||||
.collect(Collectors.joining(" "));
|
||||
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(groups));
|
||||
})
|
||||
.audiencePlaceholder("primary_group_name", (aud, queue, ctx) ->
|
||||
Tag.selfClosingInserting(Component.text(adapter.getUser((Player)aud).getCachedData().getMetaData().getPrimaryGroup())))
|
||||
.audiencePlaceholder("inherits_group", (aud, queue, ctx) -> {
|
||||
User user = adapter.getUser((Player)aud);
|
||||
Group group = luckPerms.getGroupManager().getGroup(queue.popOr(() -> "you need to provide a group").value());
|
||||
return Tag.selfClosingInserting(group != null && user.getInheritedGroups(user.getQueryOptions()).contains(group)
|
||||
? TRUE_COMPONENT
|
||||
: FALSE_COMPONENT
|
||||
);
|
||||
})
|
||||
.build()
|
||||
.register();
|
||||
new CommonExpansion(luckPerms).commonBuilder()
|
||||
.filter(Player.class)
|
||||
.build()
|
||||
.register();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user