Skip to content

Commit 452f319

Browse files
update to 21.11 (#360)
WIP, some tests fail disabled a test because the game didn't want to init --------- Co-authored-by: John Paul R <johnpaul122jpr@gmail.com>
1 parent 53e0c33 commit 452f319

5 files changed

Lines changed: 33 additions & 18 deletions

File tree

gradle.properties

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx2048M
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/develup
6-
minecraft_version=1.21.9
7-
yarn_mappings=1.21.9+build.1
8-
loader_version=0.17.2
9-
loom_version=1.11-SNAPSHOT
6+
minecraft_version=1.21.11
7+
yarn_mappings=1.21.11+build.1
8+
loader_version=0.18.2
9+
loom_version=1.13-SNAPSHOT
1010

1111
# Fabric API
12-
fabric_version=0.134.0+1.21.9
12+
fabric_version=0.139.4+1.21.11
1313

1414
# Mod Properties
1515
mod_name = Essential Commands
@@ -20,13 +20,13 @@ maven_group = com.fibermc
2020
archives_base_name = essential_commands
2121

2222
# Common Publishing
23-
game_versions=1.21.9
23+
game_versions=1.21.11
2424
gh_owner=John-Paul-R
2525
gh_repo=essential-commands
2626

2727
# Dependencies
28-
permissions_api_version=0.5.0
29-
placeholder_api_version=2.8.0+1.21.9
28+
permissions_api_version=0.6.1
29+
placeholder_api_version=2.8.1+1.21.10
3030
pal_version=1.15.0
3131
vanish_version=1.6.1+1.21.9-rc1
3232
mixinextras_version=0.5.0

src/main/java/com/fibermc/essentialcommands/ECPerms.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
import java.util.stream.Stream;
77

88
import me.lucko.fabric.api.permissions.v0.Permissions;
9+
10+
import net.minecraft.command.permission.Permission;
11+
12+
import net.minecraft.command.permission.PermissionLevel;
13+
914
import org.jetbrains.annotations.NotNull;
1015

1116
import net.minecraft.server.command.ServerCommandSource;
@@ -112,7 +117,7 @@ static void init() {
112117
}
113118

114119
private static boolean isSuperAdmin(ServerCommandSource source) {
115-
return source.hasPermissionLevel(4);
120+
return source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS));
116121
}
117122

118123
public static @NotNull Predicate<ServerCommandSource> require(@NotNull String permission, int defaultRequireLevel) {
@@ -127,13 +132,13 @@ public static boolean check(@NotNull ServerCommandSource source, @NotNull String
127132
if (CONFIG.USE_PERMISSIONS_API) {
128133
try {
129134
// TODO: In the future, config option for granting ops all perms.
130-
return Permissions.getPermissionValue(source, permission).orElse(source.hasPermissionLevel(Math.max(2, defaultRequireLevel)));
135+
return Permissions.getPermissionValue(source, permission).orElse(source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.fromLevel(Math.max(2, defaultRequireLevel)))));
131136
} catch (Exception e) {
132137
EssentialCommands.LOGGER.error(e);
133138
return false;
134139
}
135140
} else {
136-
return source.hasPermissionLevel(defaultRequireLevel);
141+
return source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.fromLevel(defaultRequireLevel)));
137142
}
138143
}
139144

@@ -195,7 +200,7 @@ public static String[] makeNumericPermissionGroup(String basePermission, Collect
195200

196201
public static Stream<String> getGrantedStatefulPlayerAbilityPermissions(ServerPlayerEntity player) {
197202
var list = Arrays.stream(Registry.Group.stateful_player_abilities);
198-
return player.hasPermissionLevel(2)
203+
return player.getPermissions().hasPermission(new Permission.Level(PermissionLevel.GAMEMASTERS))
199204
? list // TODO: this is hacky
200205
: list.filter(permission -> check(player.getCommandSource(), permission));
201206
}

src/main/java/com/fibermc/essentialcommands/EssentialCommandRegistry.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
import com.fibermc.essentialcommands.types.NamedMinecraftLocation;
1818
import com.fibermc.essentialcommands.util.EssentialsConvertor;
1919
import com.fibermc.essentialcommands.util.EssentialsXParser;
20+
21+
import net.minecraft.command.permission.Permission;
22+
23+
import net.minecraft.command.permission.PermissionLevel;
24+
2025
import org.apache.logging.log4j.Level;
2126
import org.spongepowered.asm.util.IConsumer;
2227

@@ -628,15 +633,15 @@ public static void register(
628633

629634
if (true) {
630635
essentialCommandsRootNode.addChild(CommandManager.literal("deleteAllPlayerData")
631-
.requires(source -> source.hasPermissionLevel(4))
636+
.requires(source -> source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS)))
632637
.executes(new ClearPlayerDataCommand())
633638
.build()
634639
);
635640
}
636641

637642
if (CONFIG.ENABLE_ESSENTIALSX_CONVERT) {
638643
essentialCommandsRootNode.addChild(CommandManager.literal("convertEssentialsXPlayerHomes")
639-
.requires(source -> source.hasPermissionLevel(4))
644+
.requires(source -> source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS)))
640645
.executes((source) -> {
641646
Path mcDir = source.getSource().getServer().getRunDirectory();
642647
try {
@@ -653,7 +658,7 @@ public static void register(
653658
}).build()
654659
);
655660
essentialCommandsRootNode.addChild(CommandManager.literal("convertEssentialsXWarps")
656-
.requires(source -> source.hasPermissionLevel(4))
661+
.requires(source -> source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS)))
657662
.executes((source) -> {
658663
Path mcDir = source.getSource().getServer().getRunDirectory();
659664
EssentialsConvertor.warpConvert(

src/main/java/com/fibermc/essentialcommands/commands/BedCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import net.minecraft.server.network.ServerPlayerEntity;
2222
import net.minecraft.server.world.ServerWorld;
2323
import net.minecraft.util.math.Vec3d;
24+
import net.minecraft.world.attribute.EnvironmentAttributes;
2425

2526
public class BedCommand implements Command<ServerCommandSource> {
2627
@Override
@@ -65,11 +66,11 @@ private static Optional<MinecraftLocation> getSafeSpawnPos(ServerPlayerEntity pl
6566
BlockState blockState = world.getBlockState(spawnPos);
6667
Block block = blockState.getBlock();
6768
if (block instanceof RespawnAnchorBlock
68-
&& blockState.get(RespawnAnchorBlock.CHARGES) > 0 && RespawnAnchorBlock.isNether(world)
69+
&& blockState.get(RespawnAnchorBlock.CHARGES) > 0 && RespawnAnchorBlock.isUsable(world, spawnPos)
6970
) {
7071
Optional<Vec3d> optional = RespawnAnchorBlock.findRespawnPosition(EntityType.PLAYER, world, spawnPos);
7172
safeSpawnPos = optional.orElseGet(() -> new Vec3d((double) spawnPos.getX() + 0.5, (double) spawnPos.getY() + 1, (double) spawnPos.getZ() + 0.5));
72-
} else if (block instanceof BedBlock && BedBlock.isBedWorking(world)) {
73+
} else if (block instanceof BedBlock && world.getEnvironmentAttributes().getAttributeValue(EnvironmentAttributes.BED_RULE_GAMEPLAY, spawnPos).canSetSpawn(world)) {
7374
Optional<Vec3d> optional = BedBlock.findWakeUpPosition(EntityType.PLAYER, world, spawnPos, blockState.get(BedBlock.FACING), respawn.respawnData().pitch());
7475
safeSpawnPos = optional.orElseGet(() -> new Vec3d((double) spawnPos.getX() + 0.5, (double) spawnPos.getY() + 0.5625, (double) spawnPos.getZ() + 0.5));
7576
} else {

src/main/java/com/fibermc/essentialcommands/teleportation/PlayerTeleporter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
import com.fibermc.essentialcommands.access.ServerPlayerEntityAccess;
99
import com.fibermc.essentialcommands.playerdata.PlayerData;
1010
import com.fibermc.essentialcommands.types.MinecraftLocation;
11+
12+
import net.minecraft.command.permission.Permission;
13+
import net.minecraft.command.permission.PermissionLevel;
14+
1115
import org.apache.logging.log4j.LogManager;
1216
import org.apache.logging.log4j.Logger;
1317

@@ -215,7 +219,7 @@ private static void sendTeleportMessage(ServerPlayerEntity playerEntity, Mutable
215219

216220
static boolean playerHasTpRulesBypass(ServerPlayerEntity player, String permission) {
217221
return (
218-
(player.hasPermissionLevel(4) && CONFIG.OPS_BYPASS_TELEPORT_RULES)
222+
(player.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS)) && CONFIG.OPS_BYPASS_TELEPORT_RULES)
219223
|| ECPerms.check(player.getCommandSource(), permission, 5)
220224
);
221225
}

0 commit comments

Comments
 (0)