[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: |
|
||||||||
| 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:
|
| Comment by James Peters [ 22/Dec/21 ] |
|
Do you have any example NMS code that you use to achieve this already? |