forked from PaperMC/Paper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
paper-api/src/main/java/io/papermc/paper/entity/PlayerGiveResult.java
This file contains 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,39 @@ | ||
package io.papermc.paper.entity; | ||
|
||
import java.util.Collection; | ||
import org.bukkit.entity.Item; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.Unmodifiable; | ||
import org.jspecify.annotations.NullMarked; | ||
|
||
/** | ||
* A result type used by {@link org.bukkit.entity.Player#give(ItemStack...)} and its overloads. | ||
*/ | ||
@NullMarked | ||
public interface PlayerGiveResult { | ||
|
||
/** | ||
* A collection of itemstacks that were not added to the player's inventory as they did not fit. | ||
* The collection is derived from the collections of items to add by creating copies of each stack that was not | ||
* fully added to the inventory and assigning the non-added count as their amount. | ||
* <p> | ||
* Itemstacks found here *may* also be found as item entities in the {@link #drops()} collection, as the | ||
* give logic may have dropped them. | ||
* | ||
* @return the unmodifiable collection of itemstacks that are leftover as they could not be added. Each element is a | ||
* copy of the input stack they are derived from. | ||
*/ | ||
@Unmodifiable | ||
Collection<ItemStack> leftovers(); | ||
|
||
/** | ||
* A collection of item entities dropped as a result of this call to {@link org.bukkit.entity.Player#give(ItemStack...)}. | ||
* The item entities contained here are not guaranteed to match the {@link #leftovers()} as plugins may cancel the | ||
* spawning of item entities. | ||
* | ||
* @return the unmodifiable collection of dropped item entities. | ||
*/ | ||
@Unmodifiable | ||
Collection<Item> drops(); | ||
|
||
} |
This file contains 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
20 changes: 20 additions & 0 deletions
20
paper-server/src/main/java/io/papermc/paper/entity/PaperPlayerGiveResult.java
This file contains 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,20 @@ | ||
package io.papermc.paper.entity; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import org.bukkit.entity.Item; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.Unmodifiable; | ||
import org.jspecify.annotations.NullMarked; | ||
|
||
@NullMarked | ||
public record PaperPlayerGiveResult( | ||
@Unmodifiable Collection<ItemStack> leftovers, | ||
@Unmodifiable Collection<Item> drops | ||
) implements PlayerGiveResult { | ||
|
||
public static final PlayerGiveResult EMPTY = new PaperPlayerGiveResult( | ||
Collections.emptyList(), Collections.emptyList() | ||
); | ||
|
||
} |
This file contains 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