feat: Added LuckPerms contexts
This commit is contained in:
parent
0f287df9a6
commit
0c1dbaed58
@ -1,5 +1,5 @@
|
|||||||
group = io.github.4drian3d
|
group = io.github.4drian3d
|
||||||
version = 4.0.4
|
version = 4.0.5-SNAPSHOT
|
||||||
description = AuthMeReloaded Support for Velocity
|
description = AuthMeReloaded Support for Velocity
|
||||||
url = https://modrinth.com/plugin/authmevelocity
|
url = https://modrinth.com/plugin/authmevelocity
|
||||||
id = authmevelocity
|
id = authmevelocity
|
||||||
|
@ -18,6 +18,7 @@ geantyref = "1.3.13"
|
|||||||
indra = "3.1.2"
|
indra = "3.1.2"
|
||||||
runtask = "2.1.0"
|
runtask = "2.1.0"
|
||||||
vpacketevents = "1.1.0"
|
vpacketevents = "1.1.0"
|
||||||
|
luckperms = "5.4"
|
||||||
|
|
||||||
# Test versions
|
# Test versions
|
||||||
assertj = "3.24.2"
|
assertj = "3.24.2"
|
||||||
@ -38,6 +39,7 @@ libby-velocity = { group = "net.byteflux", name = "libby-velocity", version.ref
|
|||||||
|
|
||||||
miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" }
|
miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" }
|
||||||
vpacketevents = { group = "io.github.4drian3d", name = "vpacketevents-api", version.ref = "vpacketevents" }
|
vpacketevents = { group = "io.github.4drian3d", name = "vpacketevents-api", version.ref = "vpacketevents" }
|
||||||
|
luckperms = { module = "net.luckperms:api", version.ref = "luckperms" }
|
||||||
|
|
||||||
fastlogin-velocity = { group = "com.github.games647", name = "fastlogin.velocity", version.ref = "fastlogin" }
|
fastlogin-velocity = { group = "com.github.games647", name = "fastlogin.velocity", version.ref = "fastlogin" }
|
||||||
bstats-velocity = { group = "org.bstats", name = "bstats-velocity", version.ref = "bstats" }
|
bstats-velocity = { group = "org.bstats", name = "bstats-velocity", version.ref = "bstats" }
|
||||||
|
@ -26,6 +26,7 @@ dependencies {
|
|||||||
compileOnly(libs.miniplaceholders)
|
compileOnly(libs.miniplaceholders)
|
||||||
compileOnly(libs.fastlogin.velocity)
|
compileOnly(libs.fastlogin.velocity)
|
||||||
compileOnly(libs.vpacketevents)
|
compileOnly(libs.vpacketevents)
|
||||||
|
compileOnly(libs.luckperms)
|
||||||
|
|
||||||
implementation(projects.authmevelocityCommon)
|
implementation(projects.authmevelocityCommon)
|
||||||
implementation(projects.authmevelocityApiVelocity)
|
implementation(projects.authmevelocityApiVelocity)
|
||||||
|
@ -39,6 +39,8 @@ import io.github._4drian3d.authmevelocity.common.LibsManager;
|
|||||||
import io.github._4drian3d.authmevelocity.common.configuration.ConfigurationContainer;
|
import io.github._4drian3d.authmevelocity.common.configuration.ConfigurationContainer;
|
||||||
import io.github._4drian3d.authmevelocity.common.configuration.ProxyConfiguration;
|
import io.github._4drian3d.authmevelocity.common.configuration.ProxyConfiguration;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.commands.AuthMeCommand;
|
import io.github._4drian3d.authmevelocity.velocity.commands.AuthMeCommand;
|
||||||
|
import io.github._4drian3d.authmevelocity.velocity.hooks.AuthMeContexts;
|
||||||
|
import io.github._4drian3d.authmevelocity.velocity.hooks.AuthMePlaceholders;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.listener.Listener;
|
import io.github._4drian3d.authmevelocity.velocity.listener.Listener;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.listener.compat.FastLoginListener;
|
import io.github._4drian3d.authmevelocity.velocity.listener.compat.FastLoginListener;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.listener.connection.DisconnectListener;
|
import io.github._4drian3d.authmevelocity.velocity.listener.connection.DisconnectListener;
|
||||||
@ -83,6 +85,10 @@ import java.util.stream.Stream;
|
|||||||
@Dependency(
|
@Dependency(
|
||||||
id = "vpacketevents",
|
id = "vpacketevents",
|
||||||
optional = true
|
optional = true
|
||||||
|
),
|
||||||
|
@Dependency(
|
||||||
|
id = "luckperms",
|
||||||
|
optional = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -162,6 +168,10 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
|||||||
injector.getInstance(CompletionPacketListener.class).register();
|
injector.getInstance(CompletionPacketListener.class).register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pluginManager.isLoaded("luckperms")) {
|
||||||
|
this.injector.getInstance(AuthMeContexts.class).register();
|
||||||
|
}
|
||||||
|
|
||||||
injector.getInstance(AuthMeCommand.class).register();
|
injector.getInstance(AuthMeCommand.class).register();
|
||||||
|
|
||||||
this.sendInfoMessage();
|
this.sendInfoMessage();
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package io.github._4drian3d.authmevelocity.velocity.hooks;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
|
import net.luckperms.api.LuckPerms;
|
||||||
|
import net.luckperms.api.LuckPermsProvider;
|
||||||
|
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.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
public final class AuthMeContexts implements ContextCalculator<Player> {
|
||||||
|
@Inject
|
||||||
|
private AuthMeVelocityPlugin plugin;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void calculate(final @NonNull Player target, final @NonNull ContextConsumer consumer) {
|
||||||
|
consumer.accept(ImmutableContextSet.builder()
|
||||||
|
.add("logged", Boolean.toString(plugin.isLogged(target)))
|
||||||
|
.add("isInAuthServer", Boolean.toString(plugin.isInAuthServer(target)))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull ContextSet estimatePotentialContexts() {
|
||||||
|
return ImmutableContextSet.builder()
|
||||||
|
.add("logged", "true")
|
||||||
|
.add("logged", "false")
|
||||||
|
.add("isInAuthServer", "true")
|
||||||
|
.add("isInAuthServer", "false")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register() {
|
||||||
|
final LuckPerms luckPerms = LuckPermsProvider.get();
|
||||||
|
luckPerms.getContextManager().registerCalculator(this);
|
||||||
|
}
|
||||||
|
}
|
@ -15,24 +15,25 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github._4drian3d.authmevelocity.velocity;
|
package io.github._4drian3d.authmevelocity.velocity.hooks;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
import io.github.miniplaceholders.api.Expansion;
|
import io.github.miniplaceholders.api.Expansion;
|
||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
|
|
||||||
import static io.github.miniplaceholders.api.utils.Components.FALSE_COMPONENT;
|
import static io.github.miniplaceholders.api.utils.Components.FALSE_COMPONENT;
|
||||||
import static io.github.miniplaceholders.api.utils.Components.TRUE_COMPONENT;
|
import static io.github.miniplaceholders.api.utils.Components.TRUE_COMPONENT;
|
||||||
|
|
||||||
final class AuthMePlaceholders {
|
public final class AuthMePlaceholders {
|
||||||
@Inject
|
@Inject
|
||||||
private AuthMeVelocityPlugin plugin;
|
private AuthMeVelocityPlugin plugin;
|
||||||
@Inject
|
@Inject
|
||||||
private ProxyServer proxyServer;
|
private ProxyServer proxyServer;
|
||||||
|
|
||||||
Expansion getExpansion() {
|
public Expansion getExpansion() {
|
||||||
return Expansion.builder("authme")
|
return Expansion.builder("authme")
|
||||||
.filter(Player.class)
|
.filter(Player.class)
|
||||||
// Logged Placeholders
|
// Logged Placeholders
|
Loading…
x
Reference in New Issue
Block a user