-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Replace vanishedPlayers list with set #1796
Conversation
Not sure if there is any particular reason to keep it ordered, but for now I've used a LinkedHashSet.
Hm. I agree with the change, I just don't like that we have to name a method like that in order to preserve compatibility. |
Yeah, I didn't massively like that method name either. We could just change the return type, but that would be quite annoying for a lot of people. |
Yeah that would break plugins currently hooking it. |
@@ -820,6 +820,13 @@ public EssentialsTimer getTimer() { | |||
|
|||
@Override | |||
public List<String> getVanishedPlayers() { | |||
List<String> list = new ArrayList<>(); | |||
list.addAll(vanishedPlayers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be replaced by:
return new ArrayList<>(this.vanishedPlayers);
I'd also like to question the validity of returning a modifiable collection. While changes to this collection might not cause changes, returning a modifiable collection in getVanishedPlayersSet()
would, which may confuse some people. I recommend perhaps using Collections#unmodifiableXYZ(...)
to wrap the result instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this logic. Please do use unmodifiableList()
.
@md678685 if the return type is not going to change, we need to track this so that when we do decide to push a whole bunch of breaking changes we will be able to clean up the codebase with it. A collection should be returned, not a List or a Set. Edit: but of course, if you do keep the extra method, then it'll just be messier. |
Also makes return of old method an unmodifiable list, but this is just as breaking as just changing the method return type as far as I can see
While not a fully developed idea, I think the priority between compatibility and functionality should be sorted out right now. In the case that compatibility is favored, in the worst case, you'd probably actually want to keep the |
Not sure if there is any particular reason to keep it ordered, but for now I've used a LinkedHashSet.
Closes #1789 by implementing the alternative solution.
Test builds