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

Add test for org.bukkit.craftbukkit.entity.CraftMinecart#minecartEntityTypeToMaterial #11536

Conversation

Abelkrijgtalles
Copy link
Contributor

Hi, I hope you're having a wonderful day.
I've added a test for org.bukkit.craftbukkit.entity.CraftMinecart#minecartEntityTypeToMaterial, as requested in #11511.
In the current approach I've hardcoded the Minecart types, as is done in the function.

@Abelkrijgtalles Abelkrijgtalles requested a review from a team as a code owner October 30, 2024 22:35
@lynxplay
Copy link
Contributor

The whole point of the test is to ensure that the hardcoded values in the function are still correct.
Testing this with another set of hardcoded function is useless.
Iterate the item registry, find MinecartItems, reflectively access their entity type, ensure the static method correctly matches that.

@Abelkrijgtalles
Copy link
Contributor Author

Alright, I will try to fix it to use the Item registry

Copy link
Contributor

@lynxplay lynxplay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also merge this into the respective patch that introduces the method under test.
No need for a new patch here.

@Abelkrijgtalles
Copy link
Contributor Author

I've fixed it to not be hard-coded, except for EntityType.SPAWNER_MINECART, as that doesn't have a corresponding item, and the function just returns a normal minecart. I've used a string based system, as I couldn't find any other way to do it. The current approach gets the short string of the entitytype (like chest_minecart), and gets the item with the corresponding ResourceLocation

@lynxplay
Copy link
Contributor

Thanks!
You'll need to annotate the class with @AllFeatures in order for the test suite to pick it up and run correctly.

@Abelkrijgtalles
Copy link
Contributor Author

I'll probably also make a PR for changing it to a switch statement, as that's a better choice then 7 if/else statements.

@Abelkrijgtalles
Copy link
Contributor Author

Thanks! You'll need to annotate the class with @AllFeatures in order for the test suite to pick it up and run correctly.

Will do

@lynxplay
Copy link
Contributor

EntityType fields are not constants, you won't find much luck in making that a switch statement.

@Abelkrijgtalles
Copy link
Contributor Author

I've added it, so it should be good to go.

@Abelkrijgtalles
Copy link
Contributor Author

I've removed the empty lines. If it's to aggressive, just let me know.

@Leguan16
Copy link
Contributor

Ok, that's not what I meant lol. Just revert it and forget what I said please.

@Abelkrijgtalles
Copy link
Contributor Author

Alright.

@Abelkrijgtalles
Copy link
Contributor Author

Hi, I was just wondering, are there any specific things holding the merge back?

@lynxplay
Copy link
Contributor

The fact that no developer had time to review this yet.
Give it time, someone will get it merged soon enough.

@Abelkrijgtalles
Copy link
Contributor Author

Alright, thanks for the update

@kennytv kennytv deleted the branch PaperMC:dev/1.21.2 October 31, 2024 17:09
@kennytv kennytv closed this Oct 31, 2024
@lynxplay
Copy link
Contributor

Can you reopen the PR to master please :)
I'll try to review it tonight and get that merged.

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

Successfully merging this pull request may close these issues.

5 participants