Files
Purpur/patches/api/0033-PlayerBookTooLargeEvent.patch
William Blake Galbreath 17368d1aa9 Updated Upstream (Paper & Tuinity)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
12dec20 Bump paerweight to 1.1.7
e33ed89 Get short commit ref using a more proper method
7d6147d Remove now unneeded patch due to paperweight 1.1.7
e72fa41 Update task dependency for includeMappings so the new task isn't skipped
0ad5526 Trim whitspace off of git hash (oops)

Tuinity Changes:
e878ba9 Update paper
2bd2849 Bring back fix codec spam patch
2021-06-27 00:42:39 -05:00

78 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Wed, 23 Dec 2020 00:43:27 -0600
Subject: [PATCH] PlayerBookTooLargeEvent
diff --git a/src/main/java/net/pl3x/purpur/event/player/PlayerBookTooLargeEvent.java b/src/main/java/net/pl3x/purpur/event/player/PlayerBookTooLargeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..39378ee2bfadf42ff358cc7b42dd75ac61615e15
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/event/player/PlayerBookTooLargeEvent.java
@@ -0,0 +1,65 @@
+package net.pl3x.purpur.event.player;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when a player tries to bypass book limitations
+ */
+public class PlayerBookTooLargeEvent extends PlayerEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private final ItemStack book;
+ private boolean kickPlayer = true;
+
+ /**
+ * @param player The player
+ * @param book The book
+ */
+ public PlayerBookTooLargeEvent(@NotNull Player player, @NotNull ItemStack book) {
+ super(player, !Bukkit.isPrimaryThread());
+ this.book = book;
+ }
+
+ /**
+ * Get the book containing the wanted edits
+ *
+ * @return The book
+ */
+ @NotNull
+ public ItemStack getBook() {
+ return book;
+ }
+
+ /**
+ * Whether server should kick the player or not
+ *
+ * @return True to kick player
+ */
+ public boolean shouldKickPlayer() {
+ return kickPlayer;
+ }
+
+ /**
+ * Whether server should kick the player or not
+ *
+ * @param kickPlayer True to kick player
+ */
+ public void setShouldKickPlayer(boolean kickPlayer) {
+ this.kickPlayer = kickPlayer;
+ }
+
+ @Override
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}