Update to Minecraft 1.21.11

This commit is contained in:
lucko authored and GitHub committed 2025-12-10 12:12:57 +00:00
1 parent 61ce546a04
commit 2adb058e96
19 files changed
+208 -64

No files matched your search

+5 -5
View File
@@ -13,9 +13,9 @@ repositories {
dependencies {
// https://modmuss50.me/fabric.html
minecraft 'com.mojang:minecraft:1.21.10'
mappings 'net.fabricmc:yarn:1.21.10+build.2:v2'
modImplementation 'net.fabricmc:fabric-loader:0.17.3'
minecraft 'com.mojang:minecraft:1.21.11'
mappings 'net.fabricmc:yarn:1.21.11+build.1:v2'
modImplementation 'net.fabricmc:fabric-loader:0.18.2'
Set<String> apiModules = [
'fabric-api-base',
@@ -26,10 +26,10 @@ dependencies {
]
apiModules.forEach {
modImplementation(fabricApi.module(it, '0.135.0+1.21.10'))
modImplementation(fabricApi.module(it, '0.139.4+1.21.11'))
}
include(modImplementation('me.lucko:fabric-permissions-api:0.5.0'))
include(modImplementation('me.lucko:fabric-permissions-api:0.6.1'))
implementation project(':common')
}
@@ -33,6 +33,9 @@ import me.lucko.luckperms.common.command.BrigadierCommandExecutor;
import me.lucko.luckperms.common.sender.Sender;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.command.permission.LeveledPermissionPredicate;
import net.minecraft.command.permission.Permission;
import net.minecraft.command.permission.PermissionLevel;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
@@ -78,7 +81,8 @@ public class FabricCommandExecutor extends BrigadierCommandExecutor<ServerComman
@Override
public List<String> resolveSelectors(ServerCommandSource source, List<String> args) {
// usage of @ selectors requires at least level 2 permission
ServerCommandSource atAllowedSource = source.hasPermissionLevel(2) ? source : source.withLevel(2);
ServerCommandSource atAllowedSource = ensureSourceCanUseSelectors(source);
for (ListIterator<String> it = args.listIterator(); it.hasNext(); ) {
String arg = it.next();
if (arg.isEmpty() || arg.charAt(0) != '@') {
@@ -110,4 +114,11 @@ public class FabricCommandExecutor extends BrigadierCommandExecutor<ServerComman
return args;
}
private static ServerCommandSource ensureSourceCanUseSelectors(ServerCommandSource source) {
if (source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.GAMEMASTERS))) {
return source;
}
return source.withAdditionalPermissions(LeveledPermissionPredicate.GAMEMASTERS);
}
}
@@ -47,6 +47,7 @@ import me.lucko.luckperms.fabric.listeners.FabricCommandListUpdater;
import me.lucko.luckperms.fabric.listeners.FabricConnectionListener;
import me.lucko.luckperms.fabric.listeners.FabricOtherListeners;
import me.lucko.luckperms.fabric.listeners.FabricPermissionsApiListener;
import me.lucko.luckperms.fabric.listeners.FabricPermissionsListener;
import me.lucko.luckperms.fabric.messaging.FabricMessagingFactory;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.loader.api.ModContainer;
@@ -88,6 +89,7 @@ public class LPFabricPlugin extends AbstractLuckPermsPlugin {
this.connectionListener.registerListeners();
new FabricPermissionsApiListener(this).registerListeners();
new FabricPermissionsListener().registerListeners();
// Command registration also need to occur early, and will persist across game states as well.
if (!skipCommandRegistration()) {
@@ -0,0 +1,43 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.fabric.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.command.permission.PermissionPredicate;
import net.minecraft.server.network.ServerPlayerEntity;
public interface SetupPlayerPermissionsEvent {
Event<SetupPlayerPermissionsEvent> EVENT = EventFactory.createArrayBacked(SetupPlayerPermissionsEvent.class, listeners -> (entity, defaultPredicate) -> {
PermissionPredicate predicate = defaultPredicate;
for (SetupPlayerPermissionsEvent listener : listeners) {
predicate = listener.onSetupPlayerPermissions(entity, predicate);
}
return predicate;
});
PermissionPredicate onSetupPlayerPermissions(ServerPlayerEntity entity, PermissionPredicate defaultPredicate);
}
@@ -0,0 +1,73 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <[email protected]>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.fabric.listeners;
import me.lucko.luckperms.fabric.event.SetupPlayerPermissionsEvent;
import me.lucko.luckperms.fabric.model.MixinUser;
import net.luckperms.api.util.Tristate;
import net.minecraft.command.permission.Permission;
import net.minecraft.command.permission.PermissionPredicate;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
/**
* Listener to route permission checks made via Minecraft's native permission predicate to LuckPerms.
*/
public class FabricPermissionsListener {
public void registerListeners() {
SetupPlayerPermissionsEvent.EVENT.register(this::onSetupPlayerPermissions);
}
private PermissionPredicate onSetupPlayerPermissions(ServerPlayerEntity entity, PermissionPredicate predicate) {
return new LuckPermsPermissionPredicate(entity, predicate);
}
private static final class LuckPermsPermissionPredicate implements PermissionPredicate {
private final ServerPlayerEntity player;
private final PermissionPredicate delegate;
LuckPermsPermissionPredicate(ServerPlayerEntity player, PermissionPredicate delegate) {
this.player = player;
this.delegate = delegate;
}
@Override
public boolean hasPermission(Permission permission) {
if (permission instanceof Permission.Atom) {
Identifier permissionId = ((Permission.Atom) permission).id();
String permissionString = permissionId.getNamespace() + '.' + permissionId.getPath();
Tristate result = ((MixinUser) this.player).luckperms$hasPermission(permissionString);
if (result != Tristate.UNDEFINED) {
return result.asBoolean();
}
}
return this.delegate.hasPermission(permission);
}
}
}
@@ -31,21 +31,21 @@ import me.lucko.luckperms.common.context.manager.QueryOptionsSupplier;
import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.verbose.event.CheckOrigin;
import me.lucko.luckperms.fabric.context.FabricContextManager;
import me.lucko.luckperms.fabric.event.SetupPlayerPermissionsEvent;
import me.lucko.luckperms.fabric.model.MixinUser;
import net.luckperms.api.query.QueryOptions;
import net.luckperms.api.util.Tristate;
import net.minecraft.command.permission.PermissionPredicate;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
/**
* Mixin into {@link ServerPlayerEntity} to store LP caches and implement {@link MixinUser}.
*
* <p>This mixin is also temporarily used to implement our internal PlayerChangeWorldCallback,
* until a similar event is added to Fabric itself.</p>
*/
@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerEntityMixin implements MixinUser {
@@ -155,4 +155,15 @@ public abstract class ServerPlayerEntityMixin implements MixinUser {
MixinUser oldMixin = (MixinUser) oldPlayer;
luckperms$initializePermissions(oldMixin.luckperms$getUser());
}
@Inject(at = @At("RETURN"), method = "getPermissions", cancellable = true)
private void luckperms$getPermissions(CallbackInfoReturnable<PermissionPredicate> cir) {
ServerPlayerEntity entity = (ServerPlayerEntity) (Object) this;
PermissionPredicate predicate = cir.getReturnValue();
PermissionPredicate newPredicate = SetupPlayerPermissionsEvent.EVENT.invoker().onSetupPlayerPermissions(entity, predicate);
if (newPredicate != predicate) {
cir.setReturnValue(newPredicate);
}
}
}
+2 -2
View File
@@ -1,2 +1,2 @@
minecraftVersion=1.21.10
forgeVersion=60.0.3
minecraftVersion=1.21.11
forgeVersion=61.0.0
@@ -36,6 +36,9 @@ import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.permissions.LevelBasedPermissionSet;
import net.minecraft.server.permissions.Permission;
import net.minecraft.server.permissions.PermissionLevel;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.server.ServerStartedEvent;
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
@@ -80,7 +83,7 @@ public class ForgeCommandExecutor extends BrigadierCommandExecutor<CommandSource
@Override
public List<String> resolveSelectors(CommandSourceStack source, List<String> args) {
// usage of @ selectors requires at least level 2 permission
CommandSourceStack atAllowedSource = source.hasPermission(2) ? source : source.withPermission(2);
CommandSourceStack atAllowedSource = ensureSourceCanUseSelectors(source);
for (ListIterator<String> it = args.listIterator(); it.hasNext(); ) {
String arg = it.next();
if (arg.isEmpty() || arg.charAt(0) != '@') {
@@ -112,4 +115,11 @@ public class ForgeCommandExecutor extends BrigadierCommandExecutor<CommandSource
return args;
}
private static CommandSourceStack ensureSourceCanUseSelectors(CommandSourceStack source) {
if (source.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.GAMEMASTERS))) {
return source;
}
return source.withMaximumPermission(LevelBasedPermissionSet.GAMEMASTER);
}
}
@@ -35,7 +35,7 @@ import net.luckperms.api.context.ContextSet;
import net.luckperms.api.context.DefaultContextKeys;
import net.luckperms.api.context.ImmutableContextSet;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
@@ -48,11 +48,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Set;
public class ForgePlayerCalculator implements ContextCalculator<ServerPlayer> {
/**
* GameType.NOT_SET(-1, "") was removed in 1.17
*/
private static final int GAME_MODE_NOT_SET = -1;
private final LPForgePlugin plugin;
private final boolean gamemode;
@@ -70,16 +65,16 @@ public class ForgePlayerCalculator implements ContextCalculator<ServerPlayer> {
public void calculate(@NonNull ServerPlayer target, @NonNull ContextConsumer consumer) {
ServerLevel level = target.level();
if (this.dimensionType) {
consumer.accept(DefaultContextKeys.DIMENSION_TYPE_KEY, getContextKey(level.dimension().location()));
consumer.accept(DefaultContextKeys.DIMENSION_TYPE_KEY, getContextKey(level.dimension().identifier()));
}
ServerLevelData levelData = (ServerLevelData) level.getLevelData();
if (this.world) {
ServerLevelData levelData = (ServerLevelData) level.getLevelData();
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(levelData.getLevelName(), consumer);
}
GameType gameMode = target.gameMode.getGameModeForPlayer();
if (this.gamemode && gameMode.getId() != GAME_MODE_NOT_SET) {
if (this.gamemode) {
GameType gameMode = target.gameMode.getGameModeForPlayer();
consumer.accept(DefaultContextKeys.GAMEMODE_KEY, gameMode.getName());
}
}
@@ -90,10 +85,6 @@ public class ForgePlayerCalculator implements ContextCalculator<ServerPlayer> {
if (this.gamemode) {
for (GameType gameType : GameType.values()) {
if (gameType.getId() == GAME_MODE_NOT_SET) {
continue;
}
builder.add(DefaultContextKeys.GAMEMODE_KEY, gameType.getName());
}
}
@@ -101,8 +92,8 @@ public class ForgePlayerCalculator implements ContextCalculator<ServerPlayer> {
MinecraftServer server = this.plugin.getBootstrap().getServer().orElse(null);
if (this.dimensionType && server != null) {
server.registryAccess().lookup(Registries.DIMENSION_TYPE).ifPresent(registry -> {
for (ResourceLocation resourceLocation : registry.keySet()) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, getContextKey(resourceLocation));
for (Identifier id : registry.keySet()) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, getContextKey(id));
}
});
}
@@ -119,7 +110,7 @@ public class ForgePlayerCalculator implements ContextCalculator<ServerPlayer> {
return builder.build();
}
private static String getContextKey(ResourceLocation key) {
private static String getContextKey(Identifier key) {
if (key.getNamespace().equals("minecraft")) {
return key.getPath();
}
@@ -137,7 +128,7 @@ public class ForgePlayerCalculator implements ContextCalculator<ServerPlayer> {
@SubscribeEvent
public void onPlayerChangeGameMode(PlayerEvent.PlayerChangeGameModeEvent event) {
if (!this.gamemode || event.getNewGameMode().getId() == GAME_MODE_NOT_SET) {
if (!this.gamemode) {
return;
}
@@ -33,7 +33,7 @@ import me.lucko.luckperms.forge.LPForgePlugin;
import net.luckperms.api.messenger.IncomingMessageConsumer;
import net.luckperms.api.messenger.Messenger;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
@@ -45,7 +45,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
public class PluginMessageMessenger extends AbstractPluginMessageMessenger implements Messenger {
private static final ResourceLocation CHANNEL_ID = ResourceLocation.parse(AbstractPluginMessageMessenger.CHANNEL);
private static final Identifier CHANNEL_ID = Identifier.parse(AbstractPluginMessageMessenger.CHANNEL);
private static final EventNetworkChannel CHANNEL = ChannelBuilder.named(CHANNEL_ID).optional().eventNetworkChannel();
private final LPForgePlugin plugin;
@@ -36,7 +36,7 @@ import net.luckperms.api.context.ImmutableContextSet;
import net.luckperms.api.query.QueryMode;
import net.luckperms.api.query.QueryOptions;
import net.luckperms.api.util.Tristate;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.server.permission.handler.IPermissionHandler;
import net.minecraftforge.server.permission.nodes.PermissionDynamicContext;
@@ -51,7 +51,7 @@ import java.util.Set;
import java.util.UUID;
public class ForgePermissionHandler implements IPermissionHandler {
public static final ResourceLocation IDENTIFIER = ResourceLocation.fromNamespaceAndPath(LPForgeBootstrap.ID, "permission_handler");
public static final Identifier IDENTIFIER = Identifier.fromNamespaceAndPath(LPForgeBootstrap.ID, "permission_handler");
private final LPForgePlugin plugin;
private final Set<PermissionNode<?>> permissionNodes;
@@ -66,7 +66,7 @@ public class ForgePermissionHandler implements IPermissionHandler {
}
@Override
public ResourceLocation getIdentifier() {
public Identifier getIdentifier() {
return IDENTIFIER;
}
@@ -36,6 +36,7 @@ import net.luckperms.api.query.QueryOptions;
import net.luckperms.api.util.Tristate;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.permissions.LevelBasedPermissionSet;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -149,7 +150,7 @@ public final class BrigadierInjector {
Tristate state = user.getCachedData().getPermissionData(queryOptions).checkPermission(this.permission);
if (state != Tristate.UNDEFINED) {
return state.asBoolean() && this.delegate.test(source.withPermission(4));
return state.asBoolean() && this.delegate.test(source.withPermission(LevelBasedPermissionSet.OWNER));
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ shadow = "8.3.8"
blossom = "1.3.1"
moddevgradle = "2.0.110"
forgegradle = "[6.0.36,6.2)"
loom = "1.11-SNAPSHOT"
loom = "1.13-SNAPSHOT"
licenser = "0.6.1"
[plugins]
+2 -2
View File
@@ -1,2 +1,2 @@
minecraftVersion=1.21.10
neoForgeVersion=21.10.10-beta
minecraftVersion=1.21.11
neoForgeVersion=21.11.0-beta
@@ -36,6 +36,9 @@ import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.permissions.LevelBasedPermissionSet;
import net.minecraft.server.permissions.Permission;
import net.minecraft.server.permissions.PermissionLevel;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
@@ -73,7 +76,7 @@ public class NeoForgeCommandExecutor extends BrigadierCommandExecutor<CommandSou
@Override
public List<String> resolveSelectors(CommandSourceStack source, List<String> args) {
// usage of @ selectors requires at least level 2 permission
CommandSourceStack atAllowedSource = source.hasPermission(2) ? source : source.withPermission(2);
CommandSourceStack atAllowedSource = ensureSourceCanUseSelectors(source);
for (ListIterator<String> it = args.listIterator(); it.hasNext(); ) {
String arg = it.next();
if (arg.isEmpty() || arg.charAt(0) != '@') {
@@ -105,4 +108,11 @@ public class NeoForgeCommandExecutor extends BrigadierCommandExecutor<CommandSou
return args;
}
private static CommandSourceStack ensureSourceCanUseSelectors(CommandSourceStack source) {
if (source.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.GAMEMASTERS))) {
return source;
}
return source.withMaximumPermission(LevelBasedPermissionSet.GAMEMASTER);
}
}
@@ -35,7 +35,7 @@ import net.luckperms.api.context.ContextSet;
import net.luckperms.api.context.DefaultContextKeys;
import net.luckperms.api.context.ImmutableContextSet;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
@@ -48,11 +48,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Set;
public class NeoForgePlayerCalculator implements ContextCalculator<ServerPlayer> {
/**
* GameType.NOT_SET(-1, "") was removed in 1.17
*/
private static final int GAME_MODE_NOT_SET = -1;
private final LPNeoForgePlugin plugin;
private final boolean gamemode;
@@ -70,16 +65,16 @@ public class NeoForgePlayerCalculator implements ContextCalculator<ServerPlayer>
public void calculate(@NonNull ServerPlayer target, @NonNull ContextConsumer consumer) {
ServerLevel level = target.level();
if (this.dimensionType) {
consumer.accept(DefaultContextKeys.DIMENSION_TYPE_KEY, getContextKey(level.dimension().location()));
consumer.accept(DefaultContextKeys.DIMENSION_TYPE_KEY, getContextKey(level.dimension().identifier()));
}
ServerLevelData levelData = (ServerLevelData) level.getLevelData();
if (this.world) {
ServerLevelData levelData = (ServerLevelData) level.getLevelData();
this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(levelData.getLevelName(), consumer);
}
GameType gameMode = target.gameMode.getGameModeForPlayer();
if (this.gamemode && gameMode.getId() != GAME_MODE_NOT_SET) {
if (this.gamemode) {
GameType gameMode = target.gameMode.getGameModeForPlayer();
consumer.accept(DefaultContextKeys.GAMEMODE_KEY, gameMode.getName());
}
}
@@ -90,10 +85,6 @@ public class NeoForgePlayerCalculator implements ContextCalculator<ServerPlayer>
if (this.gamemode) {
for (GameType gameType : GameType.values()) {
if (gameType.getId() == GAME_MODE_NOT_SET) {
continue;
}
builder.add(DefaultContextKeys.GAMEMODE_KEY, gameType.getName());
}
}
@@ -101,8 +92,8 @@ public class NeoForgePlayerCalculator implements ContextCalculator<ServerPlayer>
MinecraftServer server = this.plugin.getBootstrap().getServer().orElse(null);
if (this.dimensionType && server != null) {
server.registryAccess().lookup(Registries.DIMENSION_TYPE).ifPresent(registry -> {
for (ResourceLocation resourceLocation : registry.keySet()) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, getContextKey(resourceLocation));
for (Identifier id : registry.keySet()) {
builder.add(DefaultContextKeys.DIMENSION_TYPE_KEY, getContextKey(id));
}
});
}
@@ -119,7 +110,7 @@ public class NeoForgePlayerCalculator implements ContextCalculator<ServerPlayer>
return builder.build();
}
private static String getContextKey(ResourceLocation key) {
private static String getContextKey(Identifier key) {
if (key.getNamespace().equals("minecraft")) {
return key.getPath();
}
@@ -137,7 +128,7 @@ public class NeoForgePlayerCalculator implements ContextCalculator<ServerPlayer>
@SubscribeEvent
public void onPlayerChangeGameMode(PlayerEvent.PlayerChangeGameModeEvent event) {
if (!this.gamemode || event.getNewGameMode().getId() == GAME_MODE_NOT_SET) {
if (!this.gamemode) {
return;
}
@@ -33,7 +33,7 @@ import net.luckperms.api.messenger.IncomingMessageConsumer;
import net.luckperms.api.messenger.Messenger;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
@@ -46,7 +46,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
public class PluginMessageMessenger extends AbstractPluginMessageMessenger implements Messenger {
private static final ResourceLocation CHANNEL_ID = ResourceLocation.parse(AbstractPluginMessageMessenger.CHANNEL);
private static final Identifier CHANNEL_ID = Identifier.parse(AbstractPluginMessageMessenger.CHANNEL);
private static final CustomPacketPayload.Type<MessageWrapper> PAYLOAD_TYPE = new CustomPacketPayload.Type<>(CHANNEL_ID);
private final LPNeoForgePlugin plugin;
@@ -36,7 +36,7 @@ import net.luckperms.api.context.ImmutableContextSet;
import net.luckperms.api.query.QueryMode;
import net.luckperms.api.query.QueryOptions;
import net.luckperms.api.util.Tristate;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.neoforge.server.permission.handler.IPermissionHandler;
import net.neoforged.neoforge.server.permission.nodes.PermissionDynamicContext;
@@ -51,7 +51,7 @@ import java.util.Set;
import java.util.UUID;
public class NeoForgePermissionHandler implements IPermissionHandler {
public static final ResourceLocation IDENTIFIER = ResourceLocation.fromNamespaceAndPath(LPNeoForgeBootstrap.ID, "permission_handler");
public static final Identifier IDENTIFIER = Identifier.fromNamespaceAndPath(LPNeoForgeBootstrap.ID, "permission_handler");
private final LPNeoForgePlugin plugin;
private final Set<PermissionNode<?>> permissionNodes;
@@ -66,7 +66,7 @@ public class NeoForgePermissionHandler implements IPermissionHandler {
}
@Override
public ResourceLocation getIdentifier() {
public Identifier getIdentifier() {
return IDENTIFIER;
}
@@ -36,6 +36,7 @@ import net.luckperms.api.query.QueryOptions;
import net.luckperms.api.util.Tristate;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.permissions.LevelBasedPermissionSet;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -150,7 +151,7 @@ public final class BrigadierInjector {
Tristate state = user.getCachedData().getPermissionData(queryOptions).checkPermission(this.permission);
if (state != Tristate.UNDEFINED) {
return state.asBoolean() && this.delegate.test(source.withPermission(4));
return state.asBoolean() && this.delegate.test(source.withPermission(LevelBasedPermissionSet.OWNER));
}
}