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

Replace vanishedPlayers list with set #1796

Merged
merged 2 commits into from
Mar 25, 2018

Conversation

mdcfe
Copy link
Member

@mdcfe mdcfe commented Jan 23, 2018

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

Commit Link
0237c71 EssentialsX-2.0.1-pr1796.jar

Not sure if there is any particular reason to keep it ordered, but for now I've used a LinkedHashSet.
@mdcfe mdcfe requested a review from drtshock January 23, 2018 16:04
@drtshock
Copy link
Member

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.

@mdcfe
Copy link
Member Author

mdcfe commented Jan 24, 2018

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.

@drtshock
Copy link
Member

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);
Copy link
Contributor

@caojohnny caojohnny Feb 3, 2018

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.

Copy link
Member

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().

@SupaHam
Copy link
Member

SupaHam commented Feb 8, 2018

@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
@mdcfe mdcfe added this to the EssentialsX 2.0.2 milestone Feb 14, 2018
@caojohnny
Copy link
Contributor

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 vanishedPlayers field a List type and check for duplicates every time, at a cost to performance.

@mdcfe mdcfe modified the milestone: EssentialsX 2.0.2 Mar 18, 2018
@mdcfe mdcfe added the bug: confirmed Confirmed bugs in EssentialsX. label Mar 24, 2018
@mdcfe mdcfe merged commit 61c1485 into EssentialsX:2.x Mar 25, 2018
@mdcfe mdcfe mentioned this pull request Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: confirmed Confirmed bugs in EssentialsX.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants