Skip to content

Commit

Permalink
Bump to 0.5.29: use true command executor for permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
3TUSK committed Jul 31, 2022
1 parent 6ec5bfe commit 51c7623
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'

version = '0.5.28'
version = '0.5.29'
group = 'org.teacon'
archivesBaseName = 'AreaControl-Forge-1.18'

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/teacon/areacontrol/AreaControlCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.teacon.areacontrol.api.AreaProperties;
import org.teacon.areacontrol.impl.AreaPropertyArgument;
import org.teacon.areacontrol.impl.DirectionArgument;
import org.teacon.areacontrol.mixin.CommandSourceStackAccessor;

import java.util.Objects;
import java.util.UUID;
Expand Down Expand Up @@ -117,10 +118,11 @@ public AreaControlCommand(CommandDispatcher<CommandSourceStack> dispatcher) {

private static Predicate<CommandSourceStack> check(PermissionNode<Boolean> permission) {
return source -> {
if (source.getEntity() instanceof ServerPlayer) {
return PermissionAPI.getPermission((ServerPlayer) source.getEntity(), permission);
// /execute as will change the "on-behalf-of" source, so we need to extract the true source.
if (((CommandSourceStackAccessor) source).getSource() instanceof ServerPlayer sp) {
return PermissionAPI.getPermission(sp, permission);
}
return source.hasPermission(2);
return false;
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.teacon.areacontrol.mixin;

import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(CommandSourceStack.class)
public interface CommandSourceStackAccessor {

@Accessor
CommandSource getSource();
}
1 change: 0 additions & 1 deletion src/main/resources/META-INF/accesstransformer.cfg

This file was deleted.

3 changes: 2 additions & 1 deletion src/main/resources/area_control.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"mixins": [
"EntityMixin",
"FireMixin",
"LavaMixin"
"LavaMixin",
"CommandSourceStackAccessor"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 51c7623

Please sign in to comment.