Paper
                                
                                 Paper copied to clipboard
                                
                                    Paper copied to clipboard
                            
                            
                            
                        Can't reset villager reputation
Expected behavior
Reputation gets reset
Observed/Actual behavior
I cant reset the villager's reputation with the api
Steps/models to reproduce
rep.setReputation(ReputationType.MINOR_NEGATIVE, 0);
rep.setReputation(ReputationType.MAJOR_NEGATIVE, 0);
villager.setReputation(p.getUniqueId(), rep);
Plugin and Datapack List
Irrelevant
Paper version
This server is running Paper version git-Paper-66 (MC: 1.18) (Implementing API version 1.18-R0.1-SNAPSHOT) (Git: dce79f3) You are running the latest version
Other
https://github.com/PaperMC/Paper/blob/master/patches/server/0422-Add-villager-reputation-API.patch lines 54-58 should be the problem
A possible workaround:
Map<UUID, Reputation> reps = villager.getReputations();
Reputation rep = reps.get(p.getUniqueId());
if (rep != null) {
	rep.setReputation(ReputationType.MINOR_NEGATIVE, 0);
	rep.setReputation(ReputationType.MAJOR_NEGATIVE, 0);
}
villager.clearReputations();
villager.setReputations(reps);
Would this be related to an issue I've observed that Villagers in Paper seem to be a lot more temperamental with prices than in base Java -> I haven't posted as its own issue cause I don't know if it is an issue but in paper when trading with villagers I've found they increase their prices a lot faster than I was used to when the server was Java
On paper 12 trades is enough to increase the prices of things 1 stage, each sleep only reduces those prices 1 stage so max trading with villagers makes prices runaway expensive over a few in game days. Trading 2 and sometimes 3 items with a villager to full potential doesn't seem to balance the price increases either though 4 items does seem to work. On plain Java, even just trading 2 items say carrots and potatoes would make the cost go down on all farmer villager trades there by a single stage, not as much as curing with zombies but at least not more expensive. And this would be regardless of Villager sleeping iirc
I believe these lines are the actual cause of the problem. https://github.com/PaperMC/Paper/blob/41647af74caed955c1fd5b38d458ee59298ae5d4/patches/server/0411-Add-villager-reputation-API.patch#L54-L58 So when you're trying to set new reputation using #setReputation(UUID, Reputations) method it will execute the code above and update reputations map only if provided Reputation object has non-zero values. https://github.com/PaperMC/Paper/blob/41647af74caed955c1fd5b38d458ee59298ae5d4/patches/server/0411-Add-villager-reputation-API.patch#L105-L113
According to https://github.com/PaperMC/Paper/pull/3857 there was a bug that would delete (?) villagers if 0 reputations was set.
I'm not sure what we can do about it at this point, so I'm sorry for pinging you here @aikar, but how do you reckon we could fix the issue? I think if there's no way we can make #setReputation(UUID, Reputations) work with zero values, it's better to at least write it in the docs and reference the alterntive solution using #setReputations(Map<UUID, Reputation) method.