Sometimes, GUIs are only meant to be used by one player. However, since the API is designed to work with multiple players, it can be cumbersome when you know beforehand that only one player should see the GUI at a time.
This could be accomplished by adding convenience methods, like Gui#getViewer() which would return the first viewer in the viewers list (equivalent to gui.getViewers().get(0)).
Another idea is to introduce a ViewerPolicy, such as EVERYONE (the default), FIRST_ONLY (only the first to open it), SINGLE (when a new viewer is added, the old one gets removed).
Challenges
Handling changes of the ViewerPolicy (e.g. switching from EVERYONE to SINGLE)
Description
Sometimes, GUIs are only meant to be used by one player. However, since the API is designed to work with multiple players, it can be cumbersome when you know beforehand that only one player should see the GUI at a time.
This could be accomplished by adding convenience methods, like
Gui#getViewer()
which would return the first viewer in the viewers list (equivalent togui.getViewers().get(0)
).Another idea is to introduce a
ViewerPolicy
, such asEVERYONE
(the default),FIRST_ONLY
(only the first to open it),SINGLE
(when a new viewer is added, the old one gets removed).Challenges
ViewerPolicy
(e.g. switching fromEVERYONE
toSINGLE
)