Grabbing Armorstands by either tag or name

Discussion in 'Plugin Development' started by Dr.Tsuragu, Feb 18, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    Dr.Tsuragu

    I am trying to figure out how to impliment Armorstands getting via tag or custom name

    I am using: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/ArmorStand.html

    I have multiple armorstands w/ same name and/or tag so I need to look world completely, not a specific location in world. This is what I have:

    Code:
    World val = Bukkit.getWorld("Valdera");
    ArmorStand stand = (somehow make this look only world)
    stand.getName(haunted_Stand);
    stand. getTag(hauntstand); (I know doesnt actually exist but wanted to state tag as well)
    stand.setRotation(-30,0);
    My codeskills are like 2/10 and I've spent 3 days scouring google and threads before posting this
     
  2. Offline

    Kars

    getName is a getter. You cannot set name with it. You also can't simply look through an entire world. Judging by your code and explanation i doubt i can help you in a way you would understand. I suggest getting a better understanding of basic Java before tackling a problem like this.
     
  3. Offline

    bowlerguy66

    @Dr.Tsuragu To look through the armor stands in the world, you can loop through all the entities in the world with a for loop, like this:
    Code:
    for(Entity e : val.getEntities()) {
    
    }
    Then, you can grab all of the ArmorStands in the world using (world).getEntitiesByClass(ArmorStand.class). After that, you can cast the entity you searched for as an armorstand for you to work with
    Code:
    for(Entity e : val.getEntitiesByClass(ArmorStand.class)) {
      ArmorStand stand = (ArmorStand) e;
    }
    I'm not sure what you're trying to do, but maybe what I've given you will get you the kickstart you need :)

    Edit: Fixed to implement .getEntitiesByClass() instead of checking manually
     
    Last edited: Feb 21, 2020
  4. Offline

    KarimAKL

    @bowlerguy66 You can also just use World#getEntitiesByClass(ArmorStand.class) instead of checking yourself.
     
  5. Offline

    bowlerguy66

    @KarimAKL I didn't know that was a thing, thanks! (Previous post edited to fix)
     
Thread Status:
Not open for further replies.

Share This Page