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

Added GrindstoneExtractEvent #9762

Closed
wants to merge 1 commit into from

Conversation

notTamion
Copy link
Contributor

Adds an event that gets called before the ExperienceOrb is spawned because of using a Grindstone. Allows you to get a copy of the ItemStack, modify/get the amount of Experience and get the Player involved

Calling onTake with itemstack instead of itemstack1 should not be an issue since it is not used anywhere except in the onTake method of the resultslot (Calling the event). Though someone should probably double check that.

@notTamion notTamion requested a review from a team as a code owner September 25, 2023 15:33
Comment on lines +15 to +20
+// Paper start
+import io.papermc.paper.event.inventory.GrindstoneExtractEvent;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.block.BlockExpEvent;
+// Paper end
Copy link
Member

Choose a reason for hiding this comment

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

Fully qualified imports are preferred to prevent import diff like this

context.execute((world, blockposition) -> {
+ // Paper start
+ BlockExpEvent event = new GrindstoneExtractEvent((Player) player.getBukkitEntity(), CraftBlock.at(world, blockposition), stack.asBukkitCopy(),this.getExperienceAmount(world));
+ Bukkit.getServer().getPluginManager().callEvent(event);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ event.callEvent();

public void onTake(net.minecraft.world.entity.player.Player player, ItemStack stack) {
context.execute((world, blockposition) -> {
+ // Paper start
+ BlockExpEvent event = new GrindstoneExtractEvent((Player) player.getBukkitEntity(), CraftBlock.at(world, blockposition), stack.asBukkitCopy(),this.getExperienceAmount(world));
Copy link
Member

Choose a reason for hiding this comment

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

Missing space after the last comma here

+ *
+ * @return copy of the ItemStack
+ */
+ public ItemStack getItemStack() {
Copy link
Member

Choose a reason for hiding this comment

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

Missing notnull annotation here

@Sytm
Copy link
Contributor

Sytm commented Sep 25, 2023

While looking at the PrepareResult events a while back I got the idea to expand the PrepareGrindstoneEvent instead to allow getting and setting the experience during the creation of the result and not the retrieval like here.

@notTamion
Copy link
Contributor Author

While looking at the PrepareResult events a while back I got the idea to expand the PrepareGrindstoneEvent instead to allow getting and setting the experience during the creation of the result and not the retrieval like here.

Will close pr and allow you or someone else to expand on PrepareGrindstoneEvent

@notTamion notTamion closed this Sep 25, 2023
@notTamion notTamion deleted the GrindstoneExtractEvent branch September 25, 2023 17:22
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

Successfully merging this pull request may close these issues.

3 participants