Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx2048M

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

# Fabric API
fabric_version=0.134.0+1.21.9
fabric_version=0.139.4+1.21.11

# Mod Properties
mod_name = Essential Commands
Expand All @@ -20,13 +20,13 @@ maven_group = com.fibermc
archives_base_name = essential_commands

# Common Publishing
game_versions=1.21.9
game_versions=1.21.11
gh_owner=John-Paul-R
gh_repo=essential-commands

# Dependencies
permissions_api_version=0.5.0
placeholder_api_version=2.8.0+1.21.9
permissions_api_version=0.6.1
placeholder_api_version=2.8.1+1.21.10
pal_version=1.15.0
vanish_version=1.6.1+1.21.9-rc1
mixinextras_version=0.5.0
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/com/fibermc/essentialcommands/ECPerms.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import java.util.stream.Stream;

import me.lucko.fabric.api.permissions.v0.Permissions;

import net.minecraft.command.permission.Permission;

import net.minecraft.command.permission.PermissionLevel;

import org.jetbrains.annotations.NotNull;

import net.minecraft.server.command.ServerCommandSource;
Expand Down Expand Up @@ -112,7 +117,7 @@ static void init() {
}

private static boolean isSuperAdmin(ServerCommandSource source) {
return source.hasPermissionLevel(4);
return source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS));
}

public static @NotNull Predicate<ServerCommandSource> require(@NotNull String permission, int defaultRequireLevel) {
Expand All @@ -127,13 +132,13 @@ public static boolean check(@NotNull ServerCommandSource source, @NotNull String
if (CONFIG.USE_PERMISSIONS_API) {
try {
// TODO: In the future, config option for granting ops all perms.
return Permissions.getPermissionValue(source, permission).orElse(source.hasPermissionLevel(Math.max(2, defaultRequireLevel)));
return Permissions.getPermissionValue(source, permission).orElse(source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.fromLevel(Math.max(2, defaultRequireLevel)))));
} catch (Exception e) {
EssentialCommands.LOGGER.error(e);
return false;
}
} else {
return source.hasPermissionLevel(defaultRequireLevel);
return source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.fromLevel(defaultRequireLevel)));
}
}

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

public static Stream<String> getGrantedStatefulPlayerAbilityPermissions(ServerPlayerEntity player) {
var list = Arrays.stream(Registry.Group.stateful_player_abilities);
return player.hasPermissionLevel(2)
return player.getPermissions().hasPermission(new Permission.Level(PermissionLevel.GAMEMASTERS))
? list // TODO: this is hacky
: list.filter(permission -> check(player.getCommandSource(), permission));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
import com.fibermc.essentialcommands.types.NamedMinecraftLocation;
import com.fibermc.essentialcommands.util.EssentialsConvertor;
import com.fibermc.essentialcommands.util.EssentialsXParser;

import net.minecraft.command.permission.Permission;

import net.minecraft.command.permission.PermissionLevel;

import org.apache.logging.log4j.Level;
import org.spongepowered.asm.util.IConsumer;

Expand Down Expand Up @@ -628,15 +633,15 @@ public static void register(

if (true) {
essentialCommandsRootNode.addChild(CommandManager.literal("deleteAllPlayerData")
.requires(source -> source.hasPermissionLevel(4))
.requires(source -> source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS)))
.executes(new ClearPlayerDataCommand())
.build()
);
}

if (CONFIG.ENABLE_ESSENTIALSX_CONVERT) {
essentialCommandsRootNode.addChild(CommandManager.literal("convertEssentialsXPlayerHomes")
.requires(source -> source.hasPermissionLevel(4))
.requires(source -> source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS)))
.executes((source) -> {
Path mcDir = source.getSource().getServer().getRunDirectory();
try {
Expand All @@ -653,7 +658,7 @@ public static void register(
}).build()
);
essentialCommandsRootNode.addChild(CommandManager.literal("convertEssentialsXWarps")
.requires(source -> source.hasPermissionLevel(4))
.requires(source -> source.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS)))
.executes((source) -> {
Path mcDir = source.getSource().getServer().getRunDirectory();
EssentialsConvertor.warpConvert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.attribute.EnvironmentAttributes;

public class BedCommand implements Command<ServerCommandSource> {
@Override
Expand Down Expand Up @@ -65,11 +66,11 @@ private static Optional<MinecraftLocation> getSafeSpawnPos(ServerPlayerEntity pl
BlockState blockState = world.getBlockState(spawnPos);
Block block = blockState.getBlock();
if (block instanceof RespawnAnchorBlock
&& blockState.get(RespawnAnchorBlock.CHARGES) > 0 && RespawnAnchorBlock.isNether(world)
&& blockState.get(RespawnAnchorBlock.CHARGES) > 0 && RespawnAnchorBlock.isUsable(world, spawnPos)
) {
Optional<Vec3d> optional = RespawnAnchorBlock.findRespawnPosition(EntityType.PLAYER, world, spawnPos);
safeSpawnPos = optional.orElseGet(() -> new Vec3d((double) spawnPos.getX() + 0.5, (double) spawnPos.getY() + 1, (double) spawnPos.getZ() + 0.5));
} else if (block instanceof BedBlock && BedBlock.isBedWorking(world)) {
} else if (block instanceof BedBlock && world.getEnvironmentAttributes().getAttributeValue(EnvironmentAttributes.BED_RULE_GAMEPLAY, spawnPos).canSetSpawn(world)) {
Optional<Vec3d> optional = BedBlock.findWakeUpPosition(EntityType.PLAYER, world, spawnPos, blockState.get(BedBlock.FACING), respawn.respawnData().pitch());
safeSpawnPos = optional.orElseGet(() -> new Vec3d((double) spawnPos.getX() + 0.5, (double) spawnPos.getY() + 0.5625, (double) spawnPos.getZ() + 0.5));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import com.fibermc.essentialcommands.access.ServerPlayerEntityAccess;
import com.fibermc.essentialcommands.playerdata.PlayerData;
import com.fibermc.essentialcommands.types.MinecraftLocation;

import net.minecraft.command.permission.Permission;
import net.minecraft.command.permission.PermissionLevel;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -215,7 +219,7 @@ private static void sendTeleportMessage(ServerPlayerEntity playerEntity, Mutable

static boolean playerHasTpRulesBypass(ServerPlayerEntity player, String permission) {
return (
(player.hasPermissionLevel(4) && CONFIG.OPS_BYPASS_TELEPORT_RULES)
(player.getPermissions().hasPermission(new Permission.Level(PermissionLevel.OWNERS)) && CONFIG.OPS_BYPASS_TELEPORT_RULES)
|| ECPerms.check(player.getCommandSource(), permission, 5)
);
}
Expand Down