Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate traitnames and targets lists consistently #3114

Closed
3 tasks done
SlimeDog opened this issue Apr 19, 2024 · 7 comments
Closed
3 tasks done

Generate traitnames and targets lists consistently #3114

SlimeDog opened this issue Apr 19, 2024 · 7 comments

Comments

@SlimeDog
Copy link

I confirm that I have ...

  • ...tried the latest Development Build to make sure my feature doesn't exist already.
  • ...checked the Wiki for any possible information about my feature.
  • ...checked other existing issues for my feature request.

Description

  1. I run multiple plugin test servers, and compare configuration files among them to evaluate consistent behavior. Citizens saves.yml files generate seemingly random order for traitnames and targets values. It would be nice for my purposes if the lists were consistent. I assume that it would be relatively straightforward to sort these lists alphabetically with Collections.sort() or similar.
  2. The only benefit for others would be for those with similar system usage, who no doubt are a tiny minority of server owners. But sorted lists would not negatively impact anyone else.
  3. I can edit the files myself for comparison, but on the next restart the lists are reordered again.

Following is a difference example from two of the servers. Obviously, the targets lists are preceded by

        allTargets:
          targets:

and

        allIgnores:
          targets:

respectively.

118,119c118,119
<             '0': MONSTER
<             '1': PASSIVE_MOB
---
>             '0': PASSIVE_MOB
>             '1': MONSTER
122,126c122,126
<             '0': FOX
<             '1': OWNER
<             '2': PLAYER
<             '3': CAT
<             '4': BEE
---
>             '0': BEE
>             '1': PLAYER
>             '2': FOX
>             '3': OWNER
>             '4': CAT
140c140
<     traitnames: wolfmodifiers,mounttrait,location,inventory,rotationtrait,equipment,lookclose,waypoints,age,spawned,scoreboardtrait,type,poses,owner,sentinel
---
>     traitnames: sentinel,spawned,lookclose,type,equipment,waypoints,location,rotationtrait,mounttrait,owner,inventory,age,scoreboardtrait,poses,wolfmodifiers
260,261c260,261
<             '0': MONSTER
<             '1': PASSIVE_MOB
---
>             '0': PASSIVE_MOB
>             '1': MONSTER
264,268c264,268
<             '0': FOX
<             '1': OWNER
<             '2': PLAYER
<             '3': CAT
<             '4': BEE
---
>             '0': BEE
>             '1': PLAYER
>             '2': FOX
>             '3': OWNER
>             '4': CAT
282c282
<     traitnames: wolfmodifiers,mounttrait,location,inventory,rotationtrait,equipment,lookclose,waypoints,spawned,age,scoreboardtrait,type,owner,poses,sentinel
---
>     traitnames: spawned,sentinel,lookclose,type,equipment,waypoints,location,rotationtrait,mounttrait,owner,inventory,age,scoreboardtrait,wolfmodifiers,poses
405,406c405,406
<             '0': MONSTER
<             '1': PASSIVE_MOB
---
>             '0': PASSIVE_MOB
>             '1': MONSTER
409,413c409,413
<             '0': FOX
<             '1': OWNER
<             '2': PLAYER
<             '3': CAT
<             '4': BEE
---
>             '0': BEE
>             '1': PLAYER
>             '2': FOX
>             '3': OWNER
>             '4': CAT
427c427
<     traitnames: wolfmodifiers,mounttrait,location,inventory,rotationtrait,equipment,lookclose,waypoints,spawned,age,scoreboardtrait,type,owner,poses,sentinel
---
>     traitnames: sentinel,spawned,lookclose,type,equipment,waypoints,location,rotationtrait,mounttrait,owner,inventory,age,scoreboardtrait,poses,wolfmodifiers
550,551c550,551
<             '0': MONSTER
<             '1': PASSIVE_MOB
---
>             '0': PASSIVE_MOB
>             '1': MONSTER
554,558c554,558
<             '0': FOX
<             '1': OWNER
<             '2': PLAYER
<             '3': CAT
<             '4': BEE
---
>             '0': BEE
>             '1': PLAYER
>             '2': FOX
>             '3': OWNER
>             '4': CAT
572c572
<     traitnames: wolfmodifiers,mounttrait,location,inventory,rotationtrait,equipment,lookclose,waypoints,spawned,age,scoreboardtrait,type,owner,poses,sentinel
---
>     traitnames: sentinel,spawned,lookclose,type,equipment,waypoints,location,rotationtrait,mounttrait,owner,inventory,age,scoreboardtrait,wolfmodifiers,poses
648c648
<     traitnames: profession,mounttrait,location,inventory,anchors,gravity,skintrait,rotationtrait,equipment,lookclose,waypoints,age,spawned,scoreboardtrait,sneak,type,owner
---
>     traitnames: spawned,profession,sneak,lookclose,type,equipment,waypoints,location,rotationtrait,gravity,mounttrait,owner,inventory,skintrait,age,scoreboardtrait,anchors
710c710
<     traitnames: equipment,mounttrait,lookclose,location,spawned,scoreboardtrait,inventory,type,owner
---
>     traitnames: spawned,mounttrait,owner,inventory,lookclose,type,scoreboardtrait,equipment,location
762c762
<     traitnames: wolfmodifiers,mounttrait,location,inventory,rotationtrait,equipment,lookclose,waypoints,age,spawned,scoreboardtrait,type,poses,owner
---
>     traitnames: spawned,lookclose,type,equipment,waypoints,location,rotationtrait,mounttrait,owner,inventory,age,scoreboardtrait,poses,wolfmodifiers
817c817
<     traitnames: wolfmodifiers,mounttrait,location,inventory,rotationtrait,equipment,lookclose,waypoints,age,spawned,scoreboardtrait,type,poses,owner
---
>     traitnames: spawned,lookclose,type,equipment,waypoints,location,rotationtrait,mounttrait,owner,inventory,age,scoreboardtrait,poses,wolfmodifiers
872c872
<     traitnames: wolfmodifiers,mounttrait,location,inventory,rotationtrait,equipment,lookclose,waypoints,spawned,age,scoreboardtrait,type,owner,poses
---
>     traitnames: spawned,lookclose,type,equipment,waypoints,location,rotationtrait,mounttrait,owner,inventory,age,scoreboardtrait,poses,wolfmodifiers

Code Example

No response

@fullwall
Copy link
Member

Why do you want them sorted? FYI, traits are stored in a HashMap which are guaranteed to have inconsistent iteration order for this reason.

@SlimeDog
Copy link
Author

Why do you want them sorted?

I want to compare file content on two nominally identical servers to ensure that they are in fact identical. To do that a present is a multi-step visual process. Out of 160 plugins I test, the only content that isn't identical on server shutdown/restart is Citizens/saves.yml.

I understand that a HashMap can be sorted for output by converting to a TreeMap. If you are willing to accept a PR, I can pay my programmer to make it so, or I can contribute equivalent support to Citizens if you want to do it yourself. I appreciate that this is a relatively small thing that you might be unwilling to accept.

@fullwall
Copy link
Member

Why not just make a script to compare yaml files? Should be trivial.

@SlimeDog
Copy link
Author

Why not just make a script to compare yaml files? Should be trivial.

I have done, for 10 years now. The script would be even more trivial if the lists were sorted. Thus the request.

@fullwall
Copy link
Member

I don't think I can sort every single key in the saves.yml file, so better to update your script sorry

@SlimeDog
Copy link
Author

SlimeDog commented Apr 21, 2024

If we post a PR to sort the three keys that we referenced above, will you accept it?

@fullwall
Copy link
Member

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants