[SPIGOT-6858] Add API method to get a villager's gossips for a player Created: 21/Dec/21  Updated: 31/Dec/24  Resolved: 31/Dec/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: PretzelJohn Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

N/A


Issue Links:
Duplicate
is duplicated by SPIGOT-5784 No way to access villager gossip/repu... Resolved
Version: This server is running CraftBukkit version 3361-Spigot-f65de01-dad8517 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

It would be great to have a way to get a villager's gossips for a given player (NBT tag "Gossips"). I currently need to use NMS for this, so adding this feature would eliminate the last bit of NMS dependency in my villager plugin.

Example function header:

 

public List<Gossip> getGossips(Player player)

 

 

This feature might need a Gossip class to hold a gossip's type (minor_negative, negative, trading, positive, and major_positive) and value? Thank you in advance, and happy holidays!



 Comments   
Comment by Mikołaj Nowak [ 26/Dec/24 ]

The old PR is no longer being fixed/updated, so I decided to have a go at this, with a slightly different approach.

 

Bukkit PR: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/1089

CraftBukkit PR: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1527

Comment by James Peters [ 22/Dec/21 ]

Made a PR for this: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/983/overview

Comment by PretzelJohn [ 22/Dec/21 ]

Here is the relevant code in my plugin, before I switched to using NBT-API: See lines 88-108 here

I used reflections, and I implemented my own classes to handle NMS in this folder: here

Here's the logic of it as well, if it helps... Gossips are contained as an NBTTagList in a villager's NBT data. So, the process I used is:

  1. Get the villager as an NMSEntity
  2. Get the entity's NBT data (NBTTagCompound)
  3. Get the "Gossips" list (NBTTagList) from the entity's NBT data
  4. Get the given player as an NMSEntity
  5. Get the player's NBT data (NBTTagCompound)
  6. Get the given player's UUID (int[] of length 4) from the player's NBT data
  7. Loop through each gossip (NBTTagCompound) in the Gossips list from step 3
  8. For each gossip, get the gossip's "Target" (int[] of length 4), and match it to the player's UUID from step 6
  9. If the Target UUID and player UUID match, then get the gossip's "Type" (String) and "Value" (int)
  10. Wrap the Type and Value into a Gossip class perhaps? And add it to an ArrayList of Gossips that are returned
Comment by James Peters [ 22/Dec/21 ]

Do you have any example NMS code that you use to achieve this already?

Generated at Sat Dec 13 13:43:10 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.