mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 14:38:53 +00:00
feat: add support for Minecraft 1.21.5 on Fabric (#809)
* feat: support Fabric 1.21.5 (working, awaiting adventure) * fix: add world, server & dimension contexts during numerical perm calc, close #808 Not perfect but close-enough * feat: more 1.21.5 work & fixes * ci: update CI for 1.21.5 * build: update dependencies for 1.21.5
This commit is contained in:
1 parent
bab7ac5d40
commit
e02dd9f8ef
17 files changed
+125
-26
No files matched your search
@@ -21,15 +21,19 @@ package net.william278.huskhomes.hook;
|
||||
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@PluginHook(
|
||||
name = "LuckPerms",
|
||||
@@ -59,7 +63,7 @@ public class LuckPermsHook extends Hook {
|
||||
if (user == null) {
|
||||
return List.of();
|
||||
}
|
||||
return user.resolveInheritedNodes(QueryOptions.defaultContextualOptions()).stream().filter(Node::getValue)
|
||||
return user.resolveInheritedNodes(QueryOptions.contextual(getContexts(online))).stream().filter(Node::getValue)
|
||||
.filter(n -> n.getKey().startsWith(nodePrefix))
|
||||
.filter(perm -> canParse(perm, nodePrefix))
|
||||
.map(perm -> Integer.parseInt(perm.getKey().substring(nodePrefix.length())))
|
||||
@@ -67,6 +71,17 @@ public class LuckPermsHook extends Hook {
|
||||
|
||||
}
|
||||
|
||||
// Get basic contexts for a user
|
||||
@NotNull
|
||||
private static ImmutableContextSet getContexts(@NotNull OnlineUser user) {
|
||||
final World world = user.getPosition().getWorld();
|
||||
return ImmutableContextSet.builder()
|
||||
.add(DefaultContextKeys.WORLD_KEY, world.getName())
|
||||
.add(DefaultContextKeys.SERVER_KEY, user.getPosition().getServer())
|
||||
.add(DefaultContextKeys.DIMENSION_TYPE_KEY, world.getEnvironment().name().toLowerCase(Locale.ENGLISH))
|
||||
.build();
|
||||
}
|
||||
|
||||
// Remove node prefix from the permission and parse as an integer
|
||||
private static boolean canParse(@NotNull Node permission, @NotNull String nodePrefix) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user