-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
+// 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 |
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.
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); |
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.
+ 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)); |
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.
Missing space after the last comma here
+ * | ||
+ * @return copy of the ItemStack | ||
+ */ | ||
+ public ItemStack getItemStack() { |
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.
Missing notnull annotation here
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 |
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.