Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
@@ -23,6 +23,6 @@ jobs:
|
||||
distribution: 'temurin'
|
||||
cache: 'gradle'
|
||||
- name: Build with Gradle
|
||||
uses: gradle/gradle-build-action@d23c38fad3e837961b39af2b98b046694927aca4
|
||||
uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c
|
||||
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)
|
||||
+4
-3
@@ -4,8 +4,9 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":luckperms-expansion-velocity"))
|
||||
implementation(project(":luckperms-expansion-paper"))
|
||||
implementation(projects.luckpermsExpansionPaper)
|
||||
implementation(projects.luckpermsExpansionVelocity)
|
||||
implementation(projects.luckpermsExpansionSponge)
|
||||
}
|
||||
|
||||
subprojects {
|
||||
@@ -26,7 +27,7 @@ subprojects {
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("LuckPerms-Expansion-${project.version}.jar")
|
||||
archiveFileName.set("MiniPlaceholders-LuckPerms-Expansion-${project.version}.jar")
|
||||
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)
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package io.github.miniplaceholders.expansion.luckperms.common;
|
||||
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
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.util.Tristate;
|
||||
|
||||
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;
|
||||
}
|
||||
String meta = queue.popOr(() -> "you need to introduce a meta key").value();
|
||||
String result = user.getCachedData().getMetaData().getMetaValue(meta);
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
return Tag.inserting(ctx.deserialize(result));
|
||||
})
|
||||
.audiencePlaceholder("has_permission", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
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) -> {
|
||||
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 null;
|
||||
}
|
||||
return Tag.preProcessParsed(primaryGroup);
|
||||
})
|
||||
.audiencePlaceholder("inherits_group", (aud, queue, ctx) -> {
|
||||
final User user = user(aud);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
group = io.github.miniplaceholders
|
||||
version = 1.1.1
|
||||
version = 1.3.0
|
||||
description = LuckPerms-Expansion
|
||||
@@ -8,10 +8,11 @@ paper = "1.19.3-R0.1-SNAPSHOT"
|
||||
blossom = "1.3.1"
|
||||
shadow = "8.1.1"
|
||||
runtask = "2.1.0"
|
||||
pluginyml = "0.5.3"
|
||||
pluginyml = "0.6.0"
|
||||
|
||||
miniplaceholders = "2.1.0"
|
||||
miniplaceholders = "2.2.1"
|
||||
luckperms = "5.4"
|
||||
adventure = "4.14.0"
|
||||
|
||||
[libraries]
|
||||
|
||||
@@ -20,6 +21,10 @@ 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" }
|
||||
|
||||
[plugins]
|
||||
|
||||
blossom = { id = "net.kyori.blossom", version.ref = "blossom" }
|
||||
|
||||
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.2.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -130,10 +130,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.
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
rootProject.name = "Luckperms-Expansion"
|
||||
|
||||
arrayOf("paper", "velocity").forEach {
|
||||
arrayOf("common", "paper", "velocity", "sponge").forEach {
|
||||
include("luckperms-expansion-$it")
|
||||
project(":luckperms-expansion-$it").projectDir = file(it)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import org.spongepowered.gradle.plugin.config.PluginLoaders
|
||||
import org.spongepowered.plugin.metadata.model.PluginDependency
|
||||
|
||||
plugins {
|
||||
id("org.spongepowered.gradle.plugin") version "2.1.1"
|
||||
}
|
||||
|
||||
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("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,16 @@
|
||||
plugins {
|
||||
alias(libs.plugins.blossom)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.velocity.api)
|
||||
annotationProcessor(libs.velocity.api)
|
||||
compileOnly(libs.miniplaceholders)
|
||||
compileOnly(libs.luckperms)
|
||||
implementation(projects.luckpermsExpansionCommon)
|
||||
}
|
||||
|
||||
blossom {
|
||||
replaceTokenIn("src/main/java/io/github/miniplaceholders/expansion/luckperms/velocity/Constants.java")
|
||||
replaceToken("{version}", project.version)
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package io.github.miniplaceholders.expansion.luckperms.velocity;
|
||||
|
||||
public class 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