kangarko / Foundation

Foundation™ helps you create highly customized Minecraft plugins (based on Spigot/Paper API) that support multiple MC versions.
https://mineacademy.org
305 stars 63 forks source link

Reset player's attack speed in #normalize #256

Closed Dybol closed 9 months ago

Dybol commented 9 months ago

According to the docs: https://minecraft.fandom.com/wiki/Attribute default player's attack speed is 4.0.

I had an issue, that after joining a minigame and calling #normalize, attack speed was not reset.

kangarko commented 9 months ago

It would probably be a good idea to store the old attack speed somewhere and restore it to what it was previously, making it compatible with other plugin.

Dybol commented 9 months ago

It would probably be a good idea to store the old attack speed somewhere and restore it to what it was previously, making it compatible with other plugin.

I think it is stored when you call #storeStare method:

        final Map<CompAttribute, Double> attributes = new HashMap<>();

        for (final CompAttribute attribute : CompAttribute.values()) {
            final Double value = attribute.get(player);

            if (value != null)
                attributes.put(attribute, value);
        }

        data.put("attributes", attributes);

And then restored in #restoreState

kangarko commented 9 months ago

Thank you, merged!