-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
c5b8608
commit 8a1055e
Showing
3 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
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
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
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,29 @@ | ||
package minevalley.core.api.gui; | ||
|
||
import minevalley.core.api.Core; | ||
import minevalley.core.api.users.OnlineUser; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.inventory.InventoryClickEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.Consumer; | ||
|
||
public record FillItem(@Nonnull ItemStack itemStack, | ||
@Nullable Consumer<OnlineUser> callback, | ||
@Nullable BiConsumer<OnlineUser, InventoryClickEvent> advancedCallback) { | ||
|
||
public FillItem { | ||
if (itemStack == null) throw new IllegalArgumentException("ItemStack cannot be null"); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public void accept(final @Nonnull InventoryClickEvent event) { | ||
if (!(event.getWhoClicked() instanceof Player player)) return; | ||
final OnlineUser user = Core.getOnlineUser(player); | ||
if (callback != null) callback.accept(user); | ||
if (advancedCallback != null) advancedCallback.accept(user, event); | ||
} | ||
} |