Minecraft plugin that displays text above a player's head

I have the queue, display, and deletion working, the only issue is that there can be multiple ArmorStands/Messages at once, regardless of the fact that I have a Map associating a single armor stand with a player. When the display function is called, it checks if there is an associated armor stand, and deletes it (before i get queue working, i want there to be one message displayed at a time)
public final Map<Player, ArmorStand> playerArmorStand = new HashMap<>();

public void messageDisplay(Player p, String m){
if (playerArmorStand.containsKey(p)) {
ArmorStand existingStand = playerArmorStand.get(p);
existingStand.remove();
playerArmorStand.remove(p);
}

// Set variables to be used
Location loc = p.getLocation();
World world = p.getWorld();
ArmorStand chat = world.spawn(loc, ArmorStand.class);

// Associate a specific armor stand with the player
playerArmorStand.put(p, chat);
...
public final Map<Player, ArmorStand> playerArmorStand = new HashMap<>();

public void messageDisplay(Player p, String m){
if (playerArmorStand.containsKey(p)) {
ArmorStand existingStand = playerArmorStand.get(p);
existingStand.remove();
playerArmorStand.remove(p);
}

// Set variables to be used
Location loc = p.getLocation();
World world = p.getWorld();
ArmorStand chat = world.spawn(loc, ArmorStand.class);

// Associate a specific armor stand with the player
playerArmorStand.put(p, chat);
...
3 Replies
JavaBot
JavaBot2w ago
This post has been reserved for your question.
Hey @wormy! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
wormy
wormyOP2w ago
i got it so that only one message displays at a time, but the reason for it not working in the first place is the fact that maps are not being saved outside of the functions i have decided i will have all the map logic inside of functions and passed through each other would not work i think actually
JavaBot
JavaBot2w ago
Post Closed
This post has been closed by <@707409023271436379> for the following reason:
figured it out
Want results from more Discord servers?
Add your server