[Help] NBT Tags

Discussion in 'Spigot Plugin Development' started by LordofLightning, Jun 17, 2018.

  1. Code (Text):
    package lordoflightning.to;

    import org.bukkit.entity.Arrow;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityShootBowEvent;

    public class ArrowListener implements Listener {

        @EventHandler
        public void onShotArrow(EntityShootBowEvent event)
        {
       
         if(event.getEntity() instanceof Player){
             Player p = (Player)event.getEntity();
             if(event.getProjectile() instanceof Arrow){
               
                }
            }
        }
    }
    So I've been looking all over for help on NBT tags, but all I've found is stuff on "why use them" and other people who can't solve it. For those of you who are asking why I'm trying to test if a player has a Bow with a certain NBT tag or an arrow with a Certain NBT tag. If they meet either of these requirements the arrow will be fired with a tag of {NoGravity:1} which in vanilla Minecraft will make the arrow move straight and not adhere to gravity. So far I got the above.

    Can someone help me with checking for NBT tags and inserting them? I'm completely lost.
     
  2. And an addition to @BananaPuncher714 's post - As the "Arrow" simply is an entity, you could make use of the setGravity after you check if it is the correct arrow. No need to use NBT for that.
     
  3. Thanks for helping, if there's anything I can do for you guys just ask.