Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Statistics of Player for PLAYER_KILLS and DEATHS still return 0 #11855

Open
x9nico opened this issue Dec 28, 2024 · 8 comments
Open

[API] Statistics of Player for PLAYER_KILLS and DEATHS still return 0 #11855

x9nico opened this issue Dec 28, 2024 · 8 comments

Comments

@x9nico
Copy link
Contributor

x9nico commented Dec 28, 2024

Expected behavior

It should return the good number of theses stats

Observed/Actual behavior

``Theses stats return 0 when I'm logging then into messages:
Image

The code :

@EventHandler
    public void join(PlayerJoinEvent e)  {
            Player p = e.getPlayer();
            p.sendMessage(Component.text("Test kills:" +p.getStatistic(Statistic.PLAYER_KILLS)));
           p.sendMessage(Component.text("Test deaths:" +p.getStatistic(Statistic.DEATHS)));
}

Steps/models to reproduce

Just copy and paste my code, and you will get 0

Plugin and Datapack List

Plugin: PvPBox (my custom plugin which contains the problem, I only have this into my PlayerJoin)
Datapack : N/A, I just generated a simple Paper Server into 1.21.4 with build 63

Paper version

This server is running Paper version 1.21.4-63-main@feb8756 (2024-12-28T21:39:34Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)

Other

My params to launch my server :

java -Xmx1G -Xms1G -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MaxNewSizePercent=40 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1NewSizePercent=30 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200 -XX:MaxTenuringThreshold=1 -XX:SurvivorRatio=32 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar spigot.jar --nogui

@Malfrador
Copy link
Member

The join event might be too early for that data to be loaded properly. Did you try it in another event too?

@x9nico
Copy link
Contributor Author

x9nico commented Dec 28, 2024

The join event might be too early for that data to be loaded properly. Did you try it in another event too?

I tried on AsyncChatEvent (into renderer), I have the same result :
Image

My code:

 @EventHandler
    public void onChatAsync(AsyncChatEvent e) {

        e.renderer((player, sourceDisplayName, message, viewer) -> {

            Bukkit.broadcast(text("Test kills:" +player.getStatistic(Statistic.PLAYER_KILLS)));
            Bukkit.broadcast(text("Test deaths:" +player.getStatistic(Statistic.DEATHS)));
 
            return text(player.getName()+":   ").append(message.color(WHITE));
        });
    }

@x9nico
Copy link
Contributor Author

x9nico commented Dec 28, 2024

@Malfrador I tried on another ways (like a custom command with CommandExecutor), I have the same problem. It looks like that it don't come from a specific event or whatever what.

Maybe a patch from Paper who overrided the Player class ?

@Doc94
Copy link
Contributor

Doc94 commented Jan 1, 2025

Strange i test that in a fresh server and just get the value for deaths. (need people for test the other stat)
you sure the plugin its not mess with the behaviour for kills?

@x9nico
Copy link
Contributor Author

x9nico commented Jan 1, 2025

Strange i test that in a fresh server and just get the value for deaths. (need people for test the other stat) you sure the plugin its not mess with the behaviour for kills?

Yes, I'm sure. I only have this in my plugin.

@Malfrador
Copy link
Member

I am also not able to reproduce this.

Do you by any chance have statistic saving disabled? You can disable that in spigot.yml, stats.disable-saving

@x9nico
Copy link
Contributor Author

x9nico commented Jan 1, 2025

I am also not able to reproduce this.

Do you by any chance have statistic saving disabled? You can disable that in spigot.yml, stats.disable-saving

No, I didn't disabled the saves :

stats:
  disable-saving: false
  forced-stats: {}

@Doc94
Copy link
Contributor

Doc94 commented Jan 2, 2025

Still strange if you test in a fresh server with new map and well adding to the stats (like using kill) that output not change... i still cannot replicate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants