Skip to content

Commit e47935a

Browse files
committed
Update for 1.21.11
1 parent 51071ea commit e47935a

14 files changed

Lines changed: 54 additions & 42 deletions

File tree

cloud-fabric/src/main/java/org/incendo/cloud/fabric/FabricServerCommandManager.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
2828
import net.fabricmc.loader.api.FabricLoader;
2929
import net.minecraft.commands.CommandSourceStack;
30+
import net.minecraft.server.permissions.Permission;
3031
import org.apiguardian.api.API;
3132
import org.checkerframework.checker.nullness.qual.NonNull;
3233
import org.incendo.cloud.SenderMapper;
@@ -117,8 +118,10 @@ public boolean hasPermission(final @NonNull C sender, final @NonNull String perm
117118
}
118119
final CommandSourceStack source = this.senderMapper().reverse(sender);
119120
if (HAS_PERMISSIONS_API) {
120-
return Permissions.check(source, permission, source.getServer().operatorUserPermissionLevel());
121+
return Permissions.check(source, permission, source.getServer().operatorUserPermissions().level());
121122
}
122-
return source.hasPermission(source.getServer().operatorUserPermissionLevel());
123+
return source.permissions().hasPermission(
124+
new Permission.HasCommandLevel(source.getServer().operatorUserPermissions().level())
125+
);
123126
}
124127
}

cloud-fabric/src/main/resources/fabric.mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
],
2626

2727
"depends": {
28-
"fabricloader": ">=0.15.7",
28+
"fabricloader": ">=0.18.2",
2929
"fabric-command-api-v2": "*",
3030
"fabric-networking-api-v1": "*",
3131
"fabric-lifecycle-events-v1": "*",
32-
"minecraft": ">=1.21.5"
32+
"minecraft": ">=1.21.11"
3333
}
3434
}

cloud-fabric/src/testmod/java/org/incendo/cloud/fabric/testmod/FabricClientExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void onInitializeClient() {
136136

137137
private static void disconnectClient(final @NonNull Minecraft client) {
138138
final PauseScreen pauseScreen = new PauseScreen(true);
139-
pauseScreen.init(client, 0, 0);
139+
pauseScreen.init(0, 0);
140140
client.disconnectFromWorld(ClientLevel.DEFAULT_QUIT_MESSAGE);
141141
}
142142
}

cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/ModdedPredicatePermissions.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
package org.incendo.cloud.minecraft.modded;
2525

2626
import net.minecraft.client.Minecraft;
27-
import net.minecraft.commands.PermissionSource;
2827
import net.minecraft.commands.SharedSuggestionProvider;
28+
import net.minecraft.server.permissions.Permission;
29+
import net.minecraft.server.permissions.PermissionLevel;
2930
import org.checkerframework.checker.nullness.qual.NonNull;
3031
import org.incendo.cloud.SenderMapperHolder;
3132
import org.incendo.cloud.key.CloudKey;
@@ -47,14 +48,16 @@ private ModdedPredicatePermissions() {
4748
*/
4849
public static <C> @NonNull PredicatePermission<C> permissionLevel(
4950
final SenderMapperHolder<? extends SharedSuggestionProvider, C> mapperHolder,
50-
final int permissionLevel
51+
final PermissionLevel permissionLevel
5152
) {
5253
return new PredicatePermission<>() {
5354
@Override
5455
public @NonNull PermissionResult testPermission(final @NonNull C sender) {
5556
final SharedSuggestionProvider suggestionProvider = mapperHolder.senderMapper().reverse(sender);
5657
return PermissionLevelResult.of(
57-
suggestionProvider instanceof PermissionSource permissionSource && permissionSource.hasPermission(permissionLevel),
58+
suggestionProvider.permissions().hasPermission(
59+
new Permission.HasCommandLevel(permissionLevel)
60+
),
5861
this,
5962
permissionLevel
6063
);

cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/internal/ModdedParserMappings.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@
3737
import java.util.Set;
3838
import java.util.function.Function;
3939
import net.minecraft.ChatFormatting;
40-
import net.minecraft.advancements.critereon.MinMaxBounds;
40+
import net.minecraft.advancements.criterion.MinMaxBounds;
4141
import net.minecraft.commands.CommandBuildContext;
4242
import net.minecraft.commands.arguments.AngleArgument;
4343
import net.minecraft.commands.arguments.ColorArgument;
4444
import net.minecraft.commands.arguments.CompoundTagArgument;
4545
import net.minecraft.commands.arguments.EntityAnchorArgument;
46+
import net.minecraft.commands.arguments.IdentifierArgument;
4647
import net.minecraft.commands.arguments.MessageArgument;
4748
import net.minecraft.commands.arguments.NbtPathArgument;
4849
import net.minecraft.commands.arguments.NbtTagArgument;
@@ -51,7 +52,6 @@
5152
import net.minecraft.commands.arguments.ParticleArgument;
5253
import net.minecraft.commands.arguments.RangeArgument;
5354
import net.minecraft.commands.arguments.ResourceKeyArgument;
54-
import net.minecraft.commands.arguments.ResourceLocationArgument;
5555
import net.minecraft.commands.arguments.UuidArgument;
5656
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
5757
import net.minecraft.commands.arguments.coordinates.SwizzleArgument;
@@ -61,8 +61,8 @@
6161
import net.minecraft.core.registries.Registries;
6262
import net.minecraft.nbt.CompoundTag;
6363
import net.minecraft.nbt.Tag;
64+
import net.minecraft.resources.Identifier;
6465
import net.minecraft.resources.ResourceKey;
65-
import net.minecraft.resources.ResourceLocation;
6666
import net.minecraft.world.scores.PlayerTeam;
6767
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
6868
import org.apiguardian.api.API;
@@ -129,7 +129,7 @@ public static <C, S> void register(
129129
registerConstantNativeParserSupplier(manager, OperationArgument.Operation.class, OperationArgument.operation());
130130
registerConstantNativeParserSupplier(manager, AngleArgument.SingleAngle.class, AngleArgument.angle());
131131
registerConstantNativeParserSupplier(manager, new TypeToken<>() {}, SwizzleArgument.swizzle());
132-
registerConstantNativeParserSupplier(manager, ResourceLocation.class, ResourceLocationArgument.id());
132+
registerConstantNativeParserSupplier(manager, Identifier.class, IdentifierArgument.id());
133133
registerConstantNativeParserSupplier(manager, EntityAnchorArgument.Anchor.class, EntityAnchorArgument.anchor());
134134
registerConstantNativeParserSupplier(manager, MinMaxBounds.Ints.class, RangeArgument.intRange());
135135
registerConstantNativeParserSupplier(manager, MinMaxBounds.Doubles.class, RangeArgument.floatRange());
@@ -222,7 +222,7 @@ private static <C, S> void registerRegistryEntryMappings(
222222
final Set<Class<?>> seenClasses = new HashSet<>();
223223
/* Some registries have types that are too generic... we'll skip those for now.
224224
* Eventually, these could be resolved by using ParserParameters in some way? */
225-
seenClasses.add(ResourceLocation.class);
225+
seenClasses.add(Identifier.class);
226226
seenClasses.add(Codec.class);
227227
seenClasses.add(String.class); // avoid pottery pattern registry overriding default string parser
228228
for (final Field field : Registries.class.getDeclaredFields()) {

cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/parser/FloatRangeParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
//
2424
package org.incendo.cloud.minecraft.modded.parser;
2525

26-
import net.minecraft.advancements.critereon.MinMaxBounds;
26+
import net.minecraft.advancements.criterion.MinMaxBounds;
2727
import net.minecraft.commands.arguments.RangeArgument;
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.incendo.cloud.brigadier.parser.WrappedBrigadierParser;
3030
import org.incendo.cloud.component.CommandComponent;
3131
import org.incendo.cloud.parser.ParserDescriptor;
3232

3333
/**
34-
* An argument parsing an unbounded {@link net.minecraft.advancements.critereon.MinMaxBounds.Doubles double range}, in the form
34+
* An argument parsing an unbounded {@link net.minecraft.advancements.criterion.MinMaxBounds.Doubles double range}, in the form
3535
* {@code [min]..[max]}, where both lower and upper bounds are optional.
3636
*
3737
* @param <C> the sender type

cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/parser/ResourceLocationParser.java renamed to cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/parser/IdentifierParser.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@
2323
//
2424
package org.incendo.cloud.minecraft.modded.parser;
2525

26-
import net.minecraft.resources.ResourceLocation;
26+
import net.minecraft.resources.Identifier;
2727
import org.checkerframework.checker.nullness.qual.NonNull;
2828
import org.incendo.cloud.brigadier.parser.WrappedBrigadierParser;
2929
import org.incendo.cloud.component.CommandComponent;
3030
import org.incendo.cloud.parser.ParserDescriptor;
3131

3232
/**
33-
* An argument parsing a {@link ResourceLocation}.
33+
* An argument parsing a {@link Identifier}.
3434
*
3535
* @param <C> the sender type
3636
*/
37-
public final class ResourceLocationParser<C> extends WrappedBrigadierParser<C, ResourceLocation> {
37+
public final class IdentifierParser<C> extends WrappedBrigadierParser<C, Identifier> {
3838

3939
/**
4040
* Creates a new resource location parser.
4141
*
4242
* @param <C> command sender type
4343
* @return the created parser
4444
*/
45-
public static <C> @NonNull ParserDescriptor<C, ResourceLocation> resourceLocationParser() {
46-
return ParserDescriptor.of(new ResourceLocationParser<>(), ResourceLocation.class);
45+
public static <C> @NonNull ParserDescriptor<C, Identifier> resourceLocationParser() {
46+
return ParserDescriptor.of(new IdentifierParser<>(), Identifier.class);
4747
}
4848

4949
/**
@@ -52,12 +52,12 @@ public final class ResourceLocationParser<C> extends WrappedBrigadierParser<C, R
5252
* @param <C> the command sender type
5353
* @return the component builder
5454
*/
55-
public static <C> CommandComponent.@NonNull Builder<C, ResourceLocation> resourceLocationComponent() {
56-
return CommandComponent.<C, ResourceLocation>builder().parser(resourceLocationParser());
55+
public static <C> CommandComponent.@NonNull Builder<C, Identifier> resourceLocationComponent() {
56+
return CommandComponent.<C, Identifier>builder().parser(resourceLocationParser());
5757
}
5858

59-
ResourceLocationParser() {
60-
super(net.minecraft.commands.arguments.ResourceLocationArgument.id());
59+
IdentifierParser() {
60+
super(net.minecraft.commands.arguments.IdentifierArgument.id());
6161
}
6262

6363
}

cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/parser/IntRangeParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
//
2424
package org.incendo.cloud.minecraft.modded.parser;
2525

26-
import net.minecraft.advancements.critereon.MinMaxBounds;
26+
import net.minecraft.advancements.criterion.MinMaxBounds;
2727
import net.minecraft.commands.arguments.RangeArgument;
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.incendo.cloud.brigadier.parser.WrappedBrigadierParser;
3030
import org.incendo.cloud.component.CommandComponent;
3131
import org.incendo.cloud.parser.ParserDescriptor;
3232

3333
/**
34-
* An argument parsing an unbounded {@link net.minecraft.advancements.critereon.MinMaxBounds.Ints integer range}, in the form
34+
* An argument parsing an unbounded {@link net.minecraft.advancements.criterion.MinMaxBounds.Ints integer range}, in the form
3535
* {@code [min]..[max]}, where both lower and upper bounds are optional.
3636
*
3737
* @param <C> the sender type

cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/parser/RegistryEntryParser.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import java.util.Set;
3232
import net.minecraft.commands.SharedSuggestionProvider;
3333
import net.minecraft.core.Registry;
34+
import net.minecraft.resources.Identifier;
3435
import net.minecraft.resources.ResourceKey;
35-
import net.minecraft.resources.ResourceLocation;
3636
import org.checkerframework.checker.nullness.qual.NonNull;
3737
import org.incendo.cloud.caption.CaptionVariable;
3838
import org.incendo.cloud.component.CommandComponent;
@@ -124,9 +124,9 @@ public RegistryEntryParser(
124124
final @NonNull CommandContext<@NonNull C> commandContext,
125125
final @NonNull CommandInput commandInput
126126
) {
127-
final ResourceLocation key;
127+
final Identifier key;
128128
try {
129-
key = ResourceLocation.read(new StringReader(commandInput.readString()));
129+
key = Identifier.read(new StringReader(commandInput.readString()));
130130
} catch (final CommandSyntaxException ex) {
131131
return ArgumentParseResult.failure(ex);
132132
}
@@ -154,9 +154,9 @@ private Registry<V> resolveRegistry(final CommandContext<C> ctx) {
154154
final @NonNull CommandContext<C> commandContext,
155155
final @NonNull CommandInput input
156156
) {
157-
final Set<ResourceLocation> ids = this.resolveRegistry(commandContext).keySet();
157+
final Set<Identifier> ids = this.resolveRegistry(commandContext).keySet();
158158
final List<String> results = new ArrayList<>(ids.size());
159-
for (final ResourceLocation entry : ids) {
159+
for (final Identifier entry : ids) {
160160
if (entry.getNamespace().equals(NAMESPACE_MINECRAFT)) {
161161
results.add(entry.getPath());
162162
}
@@ -183,7 +183,7 @@ private static final class UnknownEntryException extends ParserException {
183183

184184
UnknownEntryException(
185185
final CommandContext<?> context,
186-
final ResourceLocation key,
186+
final Identifier key,
187187
final ResourceKey<? extends Registry<?>> registry
188188
) {
189189
super(

cloud-minecraft-modded-common/src/main/java/org/incendo/cloud/minecraft/modded/permission/PermissionLevelResult.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
//
2424
package org.incendo.cloud.minecraft.modded.permission;
2525

26+
import net.minecraft.server.permissions.PermissionLevel;
2627
import org.checkerframework.checker.nullness.qual.NonNull;
2728
import org.immutables.value.Value;
2829
import org.incendo.cloud.internal.ImmutableImpl;
@@ -48,7 +49,7 @@ public interface PermissionLevelResult extends PermissionResult {
4849
static @NonNull PermissionLevelResult of(
4950
final boolean result,
5051
final @NonNull Permission permission,
51-
final int requiredPermissionLevel
52+
final @NonNull PermissionLevel requiredPermissionLevel
5253
) {
5354
return PermissionLevelResultImpl.of(result, permission, requiredPermissionLevel);
5455
}
@@ -65,5 +66,5 @@ public interface PermissionLevelResult extends PermissionResult {
6566
* @return the required permission level
6667
*/
6768
@SuppressWarnings("unused")
68-
int requiredPermissionLevel();
69+
@NonNull PermissionLevel requiredPermissionLevel();
6970
}

0 commit comments

Comments
 (0)