-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Implemented BlockFailedDispenseEvent #3205
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
Spigot-API-Patches/0199-Implemented-BlockFailedDispenseEvent.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| From 74cde8a498b882475b236e27fc34adeee51c7973 Mon Sep 17 00:00:00 2001 | ||
| From: TheViperShow <29604693+TheViperShow@users.noreply.github.com> | ||
| Date: Wed, 22 Apr 2020 09:40:23 +0200 | ||
| Subject: [PATCH] Implemented BlockFailedDispenseEvent | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/block/BlockFailedDispenseEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BlockFailedDispenseEvent.java | ||
| new file mode 100644 | ||
| index 00000000..99ab7b65 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/block/BlockFailedDispenseEvent.java | ||
| @@ -0,0 +1,26 @@ | ||
| +package com.destroystokyo.paper.event.block; | ||
| + | ||
| +import org.bukkit.block.Block; | ||
| +import org.bukkit.event.HandlerList; | ||
| +import org.bukkit.event.block.BlockEvent; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| + | ||
| +/** | ||
| + * Called when a block tries to dispense an item, but its inventory is empty. | ||
| + */ | ||
| +public class BlockFailedDispenseEvent extends BlockEvent { | ||
| + private static final HandlerList handlers = new HandlerList(); | ||
| + | ||
| + public BlockFailedDispenseEvent(@NotNull Block theBlock) { | ||
| + super(theBlock); | ||
| + } | ||
| + | ||
| + @Override | ||
| + public @NotNull HandlerList getHandlers() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + public static @NotNull HandlerList getHandlerList() { | ||
| + return handlers; | ||
| + } | ||
| +} | ||
| -- | ||
| 2.26.0.windows.1 |
56 changes: 56 additions & 0 deletions
56
Spigot-Server-Patches/0491-Implemented-BlockFailedDispenseEvent.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| From f29037a5d41b3054fd8acb5bb950ab1e801fbbdf Mon Sep 17 00:00:00 2001 | ||
| From: TheViperShow <29604693+TheViperShow@users.noreply.github.com> | ||
| Date: Wed, 22 Apr 2020 09:40:38 +0200 | ||
| Subject: [PATCH] Implemented BlockFailedDispenseEvent | ||
|
|
||
|
|
||
| diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java | ||
| index 91389911..9908c269 100644 | ||
| --- a/src/main/java/net/minecraft/server/BlockDispenser.java | ||
| +++ b/src/main/java/net/minecraft/server/BlockDispenser.java | ||
| @@ -1,5 +1,6 @@ | ||
| package net.minecraft.server; | ||
|
|
||
| +import com.destroystokyo.paper.event.block.BlockFailedDispenseEvent; | ||
| import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; | ||
| import java.util.Map; | ||
| import java.util.Random; | ||
| @@ -54,6 +55,11 @@ public class BlockDispenser extends BlockTileEntity { | ||
|
|
||
| if (i < 0) { | ||
| world.triggerEffect(1001, blockposition, 0); | ||
| + // Paper start - BlockFailedDispenseEvent is called here | ||
| + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.x, blockposition.y, blockposition.z); | ||
| + BlockFailedDispenseEvent blockFailedDispenseEvent = new BlockFailedDispenseEvent(block); | ||
| + blockFailedDispenseEvent.callEvent(); | ||
| + // Paper end | ||
| } else { | ||
| ItemStack itemstack = tileentitydispenser.getItem(i); | ||
| IDispenseBehavior idispensebehavior = this.a(itemstack); | ||
| diff --git a/src/main/java/net/minecraft/server/BlockDropper.java b/src/main/java/net/minecraft/server/BlockDropper.java | ||
| index f244f2d5..fe5555e0 100644 | ||
| --- a/src/main/java/net/minecraft/server/BlockDropper.java | ||
| +++ b/src/main/java/net/minecraft/server/BlockDropper.java | ||
| @@ -1,6 +1,7 @@ | ||
| package net.minecraft.server; | ||
|
|
||
| // CraftBukkit start | ||
| +import com.destroystokyo.paper.event.block.BlockFailedDispenseEvent; | ||
| import org.bukkit.craftbukkit.inventory.CraftItemStack; | ||
| import org.bukkit.event.inventory.InventoryMoveItemEvent; | ||
| // CraftBukkit end | ||
| @@ -31,6 +32,11 @@ public class BlockDropper extends BlockDispenser { | ||
|
|
||
| if (i < 0) { | ||
| world.triggerEffect(1001, blockposition, 0); | ||
| + // Paper start - BlockFailedDispenseEvent is called here | ||
| + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.x, blockposition.y, blockposition.z); | ||
| + BlockFailedDispenseEvent blockFailedDispenseEvent = new BlockFailedDispenseEvent(block); | ||
| + blockFailedDispenseEvent.callEvent(); | ||
| + // Paper end | ||
| } else { | ||
| ItemStack itemstack = tileentitydispenser.getItem(i); | ||
|
|
||
| -- | ||
| 2.26.0.windows.1 | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You inline the
Blockimport, but not this one. Same in the other file.