Skip to content

Commit

Permalink
Remove last remnant of old canUseEntitySelector
Browse files Browse the repository at this point in the history
  • Loading branch information
3TUSK committed Sep 15, 2024
1 parent b031ef7 commit 0f08e3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Permission {

private Boolean canUseGameMasterBlock;
private Boolean canSwitchGameMode;
private Boolean canUseSelector;
// canUseSelector is superseded by NeoForgeMod.USE_SELECTORS_PERMISSION

public Optional<Boolean> isCanUseGameMasterBlock() {
return Optional.ofNullable(canUseGameMasterBlock);
Expand All @@ -39,14 +39,6 @@ public void setCanSwitchGameMode(boolean canSwitchGameMode) {
this.canSwitchGameMode = canSwitchGameMode;
}

public Optional<Boolean> isCanUseSelector() {
return Optional.ofNullable(canUseSelector);
}

public void setCanUseSelector(Boolean canUseSelector) {
this.canUseSelector = canUseSelector;
}

@EventBusSubscriber
public static class Provider {

Expand All @@ -58,23 +50,19 @@ public static class Provider {
"minecraft", "use_gamemaster_block", PermissionTypes.BOOLEAN,
(player, uuid, context) -> player != null && player.getAbilities().instabuild && player.hasPermissions(2)
);
private static final PermissionNode<Boolean> ENTITY_SELECTOR = new PermissionNode<>(
"minecraft", "command.selector", PermissionTypes.BOOLEAN,
(player, uuid, context) -> player != null && player.hasPermissions(2)
);
// ENTITY_SELECTOR is replaced by NeoForgeMod.USE_SELECTORS_PERMISSION

@SubscribeEvent
public static void on(PermissionGatherEvent.Nodes event) {
event.addNodes(GAMEMODE, COMMAND_BLOCK, ENTITY_SELECTOR);
event.addNodes(GAMEMODE, COMMAND_BLOCK);
}
}

public static void updatePermission(ServerPlayer player) {
PacketDistributor.sendToPlayer(player,
new UpdatePermissionPacket(
PermissionAPI.getPermission(player, Provider.COMMAND_BLOCK),
PermissionAPI.getPermission(player, Provider.GAMEMODE),
PermissionAPI.getPermission(player, Provider.ENTITY_SELECTOR)
PermissionAPI.getPermission(player, Provider.GAMEMODE)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
import org.teacon.powertool.utils.VanillaUtils;

@MethodsReturnNonnullByDefault
public record UpdatePermissionPacket(boolean canUseGameMasterBlock, boolean canSwitchGameMode, boolean canUseSelector) implements CustomPacketPayload {
public record UpdatePermissionPacket(boolean canUseGameMasterBlock, boolean canSwitchGameMode) implements CustomPacketPayload {

public static final CustomPacketPayload.Type<UpdatePermissionPacket> TYPE = new Type<>(VanillaUtils.modResourceLocation("update_permission"));

public static final StreamCodec<ByteBuf,UpdatePermissionPacket> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.BOOL,UpdatePermissionPacket::canUseGameMasterBlock,
ByteBufCodecs.BOOL,UpdatePermissionPacket::canSwitchGameMode,
ByteBufCodecs.BOOL,UpdatePermissionPacket::canUseSelector,
UpdatePermissionPacket::new
);

Expand All @@ -29,7 +28,6 @@ public void handle(IPayloadContext context) {
var permission = minecraft.player.getData(PowerToolAttachments.PERMISSION);
permission.setCanSwitchGameMode(canSwitchGameMode);
permission.setCanUseGameMasterBlock(canUseGameMasterBlock);
permission.setCanUseSelector(canUseSelector);
}
});
}
Expand Down

0 comments on commit 0f08e3c

Please sign in to comment.