PurpurMC / Purpur

Purpur is a drop-in replacement for Paper servers designed for configurability, and new fun and exciting gameplay features.
https://purpurmc.org
MIT License
2.02k stars 358 forks source link

Unable to set player's AFK status #1480

Closed Noctiro closed 7 months ago

Noctiro commented 8 months ago

Spark link

https://spark.lucko.me/VCVkSCIppB

Expected behavior

Can successfully change the afk status of a player

Observed/Actual behavior

The AFK status of the player does not change after executing setAfk(true)

Steps/models to reproduce

import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class Command implements CommandExecutor {
    @Override
    public boolean onCommand(@NotNull CommandSender sender, org.bukkit.command.@NotNull Command command, @NotNull String label, String[] args) {
        if (sender instanceof Player player) {
            boolean before = player.isAfk();
            player.setAfk(!player.isAfk());
            boolean after = player.isAfk();
            System.out.println(before + " " + after);
        }
        return true;
    }
}

Purpur version

version [19:57:52 INFO]: Checking version, please wait... [19:57:52 INFO]: Current: git-Purpur-2136 (MC: 1.20.4)* Previous: git-Purpur-2134 (MC: 1.20.4)

  • You are running the latest version

Agreements

Other

No response

granny commented 7 months ago

player-idle-timeout is set to 0 in server.properties. That must be set to a number higher than zero for the AFK system to work.