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

Fix for issue #98 (Player#getInventory#getArmorContents is always AIR) #105

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

AleksandarHaralanov
Copy link
Contributor

@AleksandarHaralanov AleksandarHaralanov commented Aug 23, 2024

Tested and works. Method successfully returns ItemStack[] of player equipped armor. Returns empty if nothing equipped.

Full armor:
image
Some armor:
image
No armor:
image

Code used for testing purposes:

package org.example;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;

import java.util.Arrays;

public class PlayerMoveListener extends PlayerListener {

    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        PlayerInventory inventory = player.getInventory();
        ItemStack[] contents = inventory.getArmorContents();
        player.sendMessage(Arrays.toString(contents));
    }
}

Copy link
Collaborator

@moderatorman moderatorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems to be in order. I'm signing off on this.

@moderatorman moderatorman merged commit 9636c90 into retromcorg:master Aug 23, 2024
2 checks passed
@RhysB RhysB linked an issue Nov 25, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Player#getInventory#getArmorContents is always AIR
3 participants