Archiviert
13
0

[ci skip] Cleanup events (#10202)

Dieser Commit ist enthalten in:
Lulu13022002 2024-02-01 10:15:57 +01:00 committet von GitHub
Ursprung b3c81089ae
Commit 294347bee2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
295 geänderte Dateien mit 3245 neuen und 3088 gelöschten Zeilen

Datei anzeigen

@ -206,10 +206,10 @@ index 0000000000000000000000000000000000000000..2ad76b1751ba707f7ae0d283aa1cbaf6
+} +}
diff --git a/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java b/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java b/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ed8e885f226b02b9875b23ae2294a9056d2e8b29 index 0000000000000000000000000000000000000000..a0fd845bc9b2540c398fe1dbbf821803a7017a28
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java +++ b/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java
@@ -0,0 +1,125 @@ @@ -0,0 +1,127 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import io.papermc.paper.chat.ChatRenderer; +import io.papermc.paper.chat.ChatRenderer;
@ -231,12 +231,14 @@ index 0000000000000000000000000000000000000000..ed8e885f226b02b9875b23ae2294a905
+ */ + */
+@ApiStatus.NonExtendable +@ApiStatus.NonExtendable
+public abstract class AbstractChatEvent extends PlayerEvent implements Cancellable { +public abstract class AbstractChatEvent extends PlayerEvent implements Cancellable {
+
+ private final Set<Audience> viewers; + private final Set<Audience> viewers;
+ private final Component originalMessage; + private final Component originalMessage;
+ private final SignedMessage signedMessage; + private final SignedMessage signedMessage;
+ private ChatRenderer renderer; + private ChatRenderer renderer;
+ private Component message; + private Component message;
+ private boolean cancelled = false; +
+ private boolean cancelled;
+ +
+ AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) { + AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) {
+ super(player, async); + super(player, async);
@ -331,8 +333,8 @@ index 0000000000000000000000000000000000000000..ed8e885f226b02b9875b23ae2294a905
+ } + }
+ +
+ @Override + @Override
+ public final void setCancelled(final boolean cancelled) { + public final void setCancelled(final boolean cancel) {
+ this.cancelled = cancelled; + this.cancelled = cancel;
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatCommandDecorateEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatCommandDecorateEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatCommandDecorateEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatCommandDecorateEvent.java
@ -371,16 +373,17 @@ index 0000000000000000000000000000000000000000..feece00981ebf932e64760e7a10a04ad
+} +}
diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..667bfa6afc35f8a8f475431171ee474af4e10afd index 0000000000000000000000000000000000000000..9e1eb774d841e2c7ffa8bef688d832bdffaa0944
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java +++ b/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java
@@ -0,0 +1,117 @@ @@ -0,0 +1,120 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.AsyncPlayerChatPreviewEvent;
+import org.bukkit.event.server.ServerEvent; +import org.bukkit.event.server.ServerEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Contract;
@ -393,7 +396,8 @@ index 0000000000000000000000000000000000000000..667bfa6afc35f8a8f475431171ee474a
+ * message here, and use the chat events for modifying receivers and later the chat type. If you + * message here, and use the chat events for modifying receivers and later the chat type. If you
+ * want to keep the message as "signed" for the clients who get it, be sure to include the entire + * want to keep the message as "signed" for the clients who get it, be sure to include the entire
+ * original message somewhere in the final message. + * original message somewhere in the final message.
+ * @see AsyncChatCommandDecorateEvent for the decoration of messages sent via commands + * <br>
+ * See {@link AsyncChatCommandDecorateEvent} for the decoration of messages sent via commands
+ */ + */
+@ApiStatus.Experimental +@ApiStatus.Experimental
+public class AsyncChatDecorateEvent extends ServerEvent implements Cancellable { +public class AsyncChatDecorateEvent extends ServerEvent implements Cancellable {
@ -403,6 +407,7 @@ index 0000000000000000000000000000000000000000..667bfa6afc35f8a8f475431171ee474a
+ private final Player player; + private final Player player;
+ private final Component originalMessage; + private final Component originalMessage;
+ private Component result; + private Component result;
+
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
@ -419,7 +424,7 @@ index 0000000000000000000000000000000000000000..667bfa6afc35f8a8f475431171ee474a
+ * Certain commands request decorations without a player context + * Certain commands request decorations without a player context
+ * which is why this is possibly null. + * which is why this is possibly null.
+ * + *
+ * @return the player or null + * @return the player or {@code null}
+ */ + */
+ public @Nullable Player player() { + public @Nullable Player player() {
+ return this.player; + return this.player;
@ -437,7 +442,7 @@ index 0000000000000000000000000000000000000000..667bfa6afc35f8a8f475431171ee474a
+ /** + /**
+ * Gets the decoration result. This may already be different from + * Gets the decoration result. This may already be different from
+ * {@link #originalMessage()} if some other listener to this event + * {@link #originalMessage()} if some other listener to this event
+ * <b>OR</b> the legacy preview event ({@link org.bukkit.event.player.AsyncPlayerChatPreviewEvent} + * <b>OR</b> the legacy preview event ({@link AsyncPlayerChatPreviewEvent})
+ * changed the result. + * changed the result.
+ * + *
+ * @return the result + * @return the result
@ -458,10 +463,10 @@ index 0000000000000000000000000000000000000000..667bfa6afc35f8a8f475431171ee474a
+ /** + /**
+ * If this decorating is part of a preview request/response. + * If this decorating is part of a preview request/response.
+ * + *
+ * @return true if part of previewing + * @return {@code true} if part of previewing
+ * @deprecated chat preview was removed in 1.19.3 + * @deprecated chat preview was removed in 1.19.3
+ */ + */
+ @Deprecated(forRemoval = true) + @Deprecated(forRemoval = true, since = "1.19.3")
+ @ApiStatus.ScheduledForRemoval(inVersion = "1.21") + @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
+ @Contract(value = "-> false", pure = true) + @Contract(value = "-> false", pure = true)
+ public boolean isPreview() { + public boolean isPreview() {
@ -494,10 +499,10 @@ index 0000000000000000000000000000000000000000..667bfa6afc35f8a8f475431171ee474a
+} +}
diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4d2eddba7dc88ba23b241ac7849114a30af968d3 index 0000000000000000000000000000000000000000..4adae8b8a8640ffbd6a86b0908ca21fded737b88
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java +++ b/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java
@@ -0,0 +1,47 @@ @@ -0,0 +1,45 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import java.util.Set; +import java.util.Set;
@ -524,11 +529,9 @@ index 0000000000000000000000000000000000000000..4d2eddba7dc88ba23b241ac7849114a3
+ * appropriately. + * appropriately.
+ */ + */
+public final class AsyncChatEvent extends AbstractChatEvent { +public final class AsyncChatEvent extends AbstractChatEvent {
+ private static final HandlerList HANDLERS = new HandlerList();
+ +
+ /** + private static final HandlerList HANDLER_LIST = new HandlerList();
+ * @param viewers A mutable set of viewers +
+ */
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) { + public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) {
+ super(async, player, viewers, renderer, message, originalMessage, signedMessage); + super(async, player, viewers, renderer, message, originalMessage, signedMessage);
@ -537,20 +540,20 @@ index 0000000000000000000000000000000000000000..4d2eddba7dc88ba23b241ac7849114a3
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/event/player/ChatEvent.java b/src/main/java/io/papermc/paper/event/player/ChatEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/ChatEvent.java b/src/main/java/io/papermc/paper/event/player/ChatEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..af025704e978dc0b11be277ab4646da77eb3a60b index 0000000000000000000000000000000000000000..7411f58f9f36beaadcc47c2264a4af313956ee03
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/ChatEvent.java +++ b/src/main/java/io/papermc/paper/event/player/ChatEvent.java
@@ -0,0 +1,42 @@ @@ -0,0 +1,41 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import java.util.Set; +import java.util.Set;
@ -567,16 +570,15 @@ index 0000000000000000000000000000000000000000..af025704e978dc0b11be277ab4646da7
+/** +/**
+ * An event fired when a {@link Player} sends a chat message to the server. + * An event fired when a {@link Player} sends a chat message to the server.
+ * + *
+ * @deprecated Listening to this event forces chat to wait for the main thread, delaying chat messages. It is recommended to use {@link AsyncChatEvent} instead, wherever possible. + * @deprecated Listening to this event forces chat to wait for the main thread, delaying chat messages.
+ * It is recommended to use {@link AsyncChatEvent} instead, wherever possible.
+ */ + */
+@Deprecated +@Deprecated
+@Warning(reason = "Listening to this event forces chat to wait for the main thread, delaying chat messages.") +@Warning(reason = "Listening to this event forces chat to wait for the main thread, delaying chat messages.")
+public final class ChatEvent extends AbstractChatEvent { +public final class ChatEvent extends AbstractChatEvent {
+ private static final HandlerList HANDLERS = new HandlerList();
+ +
+ /** + private static final HandlerList HANDLER_LIST = new HandlerList();
+ * @param viewers A mutable set of viewers +
+ */
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ChatEvent(final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) { + public ChatEvent(final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) {
+ super(false, player, viewers, renderer, message, originalMessage, signedMessage); + super(false, player, viewers, renderer, message, originalMessage, signedMessage);
@ -585,12 +587,12 @@ index 0000000000000000000000000000000000000000..af025704e978dc0b11be277ab4646da7
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/text/PaperComponents.java b/src/main/java/io/papermc/paper/text/PaperComponents.java diff --git a/src/main/java/io/papermc/paper/text/PaperComponents.java b/src/main/java/io/papermc/paper/text/PaperComponents.java

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Use ASM for event executors.
Uses method handles for private or static methods. Uses method handles for private or static methods.
diff --git a/build.gradle.kts b/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts
index cbe75dc937409af36528e4eef6f257f323cd4d12..7fbb782ccf17e581a759429ffac6db608c08e3cf 100644 index b577114c2b89fe2053123d1a542d37dff7fa8d5a..af6c528ccc4356f5bba3ce0b9bf6de237d77376e 100644
--- a/build.gradle.kts --- a/build.gradle.kts
+++ b/build.gradle.kts +++ b/build.gradle.kts
@@ -47,6 +47,9 @@ dependencies { @@ -47,6 +47,9 @@ dependencies {
@ -69,10 +69,10 @@ index 0000000000000000000000000000000000000000..5b28e9b1daba7834af67dbc193dd656b
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java diff --git a/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..c83672427324bd068ed52916f700b68446a226f6 index 0000000000000000000000000000000000000000..827f2b27f70a7ec0bc11d039305c3e58c02a4ef4
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java +++ b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
@@ -0,0 +1,43 @@ @@ -0,0 +1,42 @@
+package com.destroystokyo.paper.event.executor; +package com.destroystokyo.paper.event.executor;
+ +
+import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandle;
@ -83,7 +83,6 @@ index 0000000000000000000000000000000000000000..c83672427324bd068ed52916f700b684
+import com.destroystokyo.paper.util.SneakyThrow; +import com.destroystokyo.paper.util.SneakyThrow;
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
+ +
+import org.bukkit.Bukkit;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.EventException; +import org.bukkit.event.EventException;
+import org.bukkit.event.Listener; +import org.bukkit.event.Listener;
@ -218,20 +217,18 @@ index 0000000000000000000000000000000000000000..f79685b48bb581277a6891927988b6f7
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java b/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java diff --git a/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java b/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ac99477e9f2c08041aeff31abc1d1edee58d0a67 index 0000000000000000000000000000000000000000..abcc966d8ee01d73c1d1480237ab46fa0ab55fdc
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java +++ b/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java
@@ -0,0 +1,66 @@ @@ -0,0 +1,64 @@
+package com.destroystokyo.paper.event.executor.asm; +package com.destroystokyo.paper.event.executor.asm;
+ +
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentMap;
+ +
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
+ +
+import com.google.common.collect.MapMaker; +import com.google.common.collect.MapMaker;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.objectweb.asm.Type;
+ +
+public class SafeClassDefiner implements ClassDefiner { +public class SafeClassDefiner implements ClassDefiner {
+ /* default */ static final SafeClassDefiner INSTANCE = new SafeClassDefiner(); + /* default */ static final SafeClassDefiner INSTANCE = new SafeClassDefiner();

Datei anzeigen

@ -6,16 +6,18 @@ Subject: [PATCH] Add PlayerLocaleChangeEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..bb7baa91fd4ba763fd8ce216bc9043c5e2c4b7b7 index 0000000000000000000000000000000000000000..57f6c47e4e759abf0af9aa8962551225cc12246c
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java
@@ -0,0 +1,51 @@ @@ -0,0 +1,60 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Called when the locale of the player is changed. + * Called when the locale of the player is changed.
@ -24,11 +26,14 @@ index 0000000000000000000000000000000000000000..bb7baa91fd4ba763fd8ce216bc9043c5
+ */ + */
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21") +@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
+public class PlayerLocaleChangeEvent extends PlayerEvent { +public class PlayerLocaleChangeEvent extends PlayerEvent {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final String oldLocale; + private final String oldLocale;
+ private final String newLocale; + private final String newLocale;
+ +
+ public PlayerLocaleChangeEvent(final Player player, final String oldLocale, final String newLocale) { + @ApiStatus.Internal
+ public PlayerLocaleChangeEvent(final @NotNull Player player, final @Nullable String oldLocale, final @NotNull String newLocale) {
+ super(player); + super(player);
+ this.oldLocale = oldLocale; + this.oldLocale = oldLocale;
+ this.newLocale = newLocale; + this.newLocale = newLocale;
@ -39,8 +44,9 @@ index 0000000000000000000000000000000000000000..bb7baa91fd4ba763fd8ce216bc9043c5
+ * + *
+ * @return player's old locale + * @return player's old locale
+ */ + */
+ @Nullable
+ public String getOldLocale() { + public String getOldLocale() {
+ return oldLocale; + return this.oldLocale;
+ } + }
+ +
+ /** + /**
@ -48,16 +54,19 @@ index 0000000000000000000000000000000000000000..bb7baa91fd4ba763fd8ce216bc9043c5
+ * + *
+ * @return player's new locale + * @return player's new locale
+ */ + */
+ @NotNull
+ public String getNewLocale() { + public String getNewLocale() {
+ return newLocale; + return this.newLocale;
+ } + }
+ +
+ @Override + @Override
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add BeaconEffectEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091a46b56ac index 0000000000000000000000000000000000000000..7270c1feece2dc15a4a0503c4bca93a1288f8f13
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java
@@ -0,0 +1,86 @@ @@ -0,0 +1,91 @@
+package com.destroystokyo.paper.event.block; +package com.destroystokyo.paper.event.block;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
@ -18,18 +18,23 @@ index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffect;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when a beacon effect is being applied to a player. + * Called when a beacon effect is being applied to a player.
+ */ + */
+public class BeaconEffectEvent extends BlockEvent implements Cancellable { +public class BeaconEffectEvent extends BlockEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ private PotionEffect effect;
+ private Player player;
+ private boolean primary;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Player player;
+ private final boolean primary;
+ private PotionEffect effect;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public BeaconEffectEvent(@NotNull Block block, @NotNull PotionEffect effect, @NotNull Player player, boolean primary) { + public BeaconEffectEvent(@NotNull Block block, @NotNull PotionEffect effect, @NotNull Player player, boolean primary) {
+ super(block); + super(block);
+ this.effect = effect; + this.effect = effect;
@ -37,16 +42,6 @@ index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091
+ this.primary = primary; + this.primary = primary;
+ } + }
+ +
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+
+ /** + /**
+ * Gets the potion effect being applied. + * Gets the potion effect being applied.
+ * + *
@ -54,7 +49,7 @@ index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091
+ */ + */
+ @NotNull + @NotNull
+ public PotionEffect getEffect() { + public PotionEffect getEffect() {
+ return effect; + return this.effect;
+ } + }
+ +
+ /** + /**
@ -73,26 +68,36 @@ index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091
+ */ + */
+ @NotNull + @NotNull
+ public Player getPlayer() { + public Player getPlayer() {
+ return player; + return this.player;
+ } + }
+ +
+ /** + /**
+ * Gets whether the effect is a primary beacon effect. + * Gets whether the effect is a primary beacon effect.
+ * + *
+ * @return true if this event represents a primary effect + * @return {@code true} if this event represents a primary effect
+ */ + */
+ public boolean isPrimary() { + public boolean isPrimary() {
+ return primary; + return this.primary;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -7,10 +7,10 @@ For modifying a player's initial spawn location as they join the server
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..febd384b43560d7d55c96bda5b0701a27fc9e18e index 0000000000000000000000000000000000000000..49e97ae79facceca5fc44c84c3d5f342d64cabc2
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java
@@ -0,0 +1,18 @@ @@ -0,0 +1,19 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
@ -25,7 +25,8 @@ index 0000000000000000000000000000000000000000..febd384b43560d7d55c96bda5b0701a2
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21") +@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
+public class PlayerInitialSpawnEvent extends PlayerSpawnLocationEvent { +public class PlayerInitialSpawnEvent extends PlayerSpawnLocationEvent {
+ +
+ public PlayerInitialSpawnEvent(@NotNull Player who, @NotNull Location spawnLocation) { + @ApiStatus.Internal
+ super(who, spawnLocation); + public PlayerInitialSpawnEvent(@NotNull Player player, @NotNull Location spawnLocation) {
+ super(player, spawnLocation);
+ } + }
+} +}

Datei anzeigen

@ -6,29 +6,32 @@ Subject: [PATCH] Add exception reporting event
diff --git a/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java b/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java b/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..306dbd975e9380c22dae0dad526725cc47a36f16 index 0000000000000000000000000000000000000000..9377ee1c2368ce058397037952d17bc010f66957
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java
@@ -0,0 +1,42 @@ @@ -0,0 +1,45 @@
+package com.destroystokyo.paper.event.server; +package com.destroystokyo.paper.event.server;
+ +
+import com.google.common.base.Preconditions;
+import org.bukkit.Bukkit; +import org.bukkit.Bukkit;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import com.destroystokyo.paper.exception.ServerException; +import com.destroystokyo.paper.exception.ServerException;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called whenever an exception is thrown in a recoverable section of the server. + * Called whenever an exception is thrown in a recoverable section of the server.
+ */ + */
+public class ServerExceptionEvent extends Event { +public class ServerExceptionEvent extends Event {
+ private static final HandlerList handlers = new HandlerList();
+ @NotNull private ServerException exception;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final ServerException exception;
+
+ @ApiStatus.Internal
+ public ServerExceptionEvent(@NotNull ServerException exception) { + public ServerExceptionEvent(@NotNull ServerException exception) {
+ super(!Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread());
+ this.exception = Preconditions.checkNotNull(exception, "exception"); + this.exception = exception;
+ } + }
+ +
+ /** + /**
@ -38,18 +41,18 @@ index 0000000000000000000000000000000000000000..306dbd975e9380c22dae0dad526725cc
+ */ + */
+ @NotNull + @NotNull
+ public ServerException getException() { + public ServerException getException() {
+ return exception; + return this.exception;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerCommandException.java b/src/main/java/com/destroystokyo/paper/exception/ServerCommandException.java diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerCommandException.java b/src/main/java/com/destroystokyo/paper/exception/ServerCommandException.java

Datei anzeigen

@ -6,26 +6,32 @@ Subject: [PATCH] Entity AddTo/RemoveFrom World Events
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..982a0abd9a90fcb99f8d7c60a89021a5b1bb8264 index 0000000000000000000000000000000000000000..1d8e3c93a139bba11affca74b742269f24300d2c
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java
@@ -0,0 +1,41 @@ @@ -0,0 +1,45 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.World; +import org.bukkit.World;
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired any time an entity is being added to the world for any reason (including a chunk loading). + * Fired any time an entity is being added to the world for any reason (including a chunk loading).
+ * + * <p>
+ * Not to be confused with {@link org.bukkit.event.entity.CreatureSpawnEvent} + * Not to be confused with {@link CreatureSpawnEvent}
+ */ + */
+public class EntityAddToWorldEvent extends EntityEvent { +public class EntityAddToWorldEvent extends EntityEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final World world; + @NotNull private final World world;
+ +
+ @ApiStatus.Internal
+ public EntityAddToWorldEvent(@NotNull Entity entity, @NotNull World world) { + public EntityAddToWorldEvent(@NotNull Entity entity, @NotNull World world) {
+ super(entity); + super(entity);
+ this.world = world; + this.world = world;
@ -36,33 +42,32 @@ index 0000000000000000000000000000000000000000..982a0abd9a90fcb99f8d7c60a89021a5
+ */ + */
+ @NotNull + @NotNull
+ public World getWorld() { + public World getWorld() {
+ return world; + return this.world;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..b58e2e7b8707c6221773b8f023f58a4eb9c7d4b9 index 0000000000000000000000000000000000000000..d75e6a8334c7408ea8c3f155414fc14dc427f190
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java
@@ -0,0 +1,40 @@ @@ -0,0 +1,43 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.World; +import org.bukkit.World;
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -70,8 +75,12 @@ index 0000000000000000000000000000000000000000..b58e2e7b8707c6221773b8f023f58a4e
+ * Note: The entity is updated prior to this event being called, as such, the entity's world may not be equal to {@link #getWorld()}. + * Note: The entity is updated prior to this event being called, as such, the entity's world may not be equal to {@link #getWorld()}.
+ */ + */
+public class EntityRemoveFromWorldEvent extends EntityEvent { +public class EntityRemoveFromWorldEvent extends EntityEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final World world; + @NotNull private final World world;
+ +
+ @ApiStatus.Internal
+ public EntityRemoveFromWorldEvent(@NotNull Entity entity, @NotNull World world) { + public EntityRemoveFromWorldEvent(@NotNull Entity entity, @NotNull World world) {
+ super(entity); + super(entity);
+ this.world = world; + this.world = world;
@ -82,18 +91,16 @@ index 0000000000000000000000000000000000000000..b58e2e7b8707c6221773b8f023f58a4e
+ */ + */
+ @NotNull + @NotNull
+ public World getWorld() { + public World getWorld() {
+ return world; + return this.world;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -7,10 +7,10 @@ Fires when an Entity decides to start moving to a location.
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..63e46b2fb1b12b36fcb1e98b178cf29dd2e3d1b5 index 0000000000000000000000000000000000000000..5804497f34bac9a9b6b16c6e5decb0119467df7b
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java
@@ -0,0 +1,82 @@ @@ -0,0 +1,87 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
@ -18,78 +18,83 @@ index 0000000000000000000000000000000000000000..63e46b2fb1b12b36fcb1e98b178cf29d
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Fired when an Entity decides to start moving towards a location. + * Fired when an Entity decides to start moving towards a location.
+ * + * <p>
+ * This event does not fire for the entities actual movement. Only when it + * This event does not fire for the entities actual movement. Only when it
+ * is choosing to start moving to a location. + * is choosing to start moving to a location.
+ */ + */
+public class EntityPathfindEvent extends EntityEvent implements Cancellable { +public class EntityPathfindEvent extends EntityEvent implements Cancellable {
+ @Nullable private final Entity targetEntity;
+ @NotNull private final Location loc;
+ +
+ public EntityPathfindEvent(@NotNull Entity entity, @NotNull Location loc, @Nullable Entity targetEntity) { + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @Nullable private final Entity targetEntity;
+ @NotNull private final Location location;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityPathfindEvent(@NotNull Entity entity, @NotNull Location location, @Nullable Entity targetEntity) {
+ super(entity); + super(entity);
+ this.targetEntity = targetEntity; + this.targetEntity = targetEntity;
+ this.loc = loc; + this.location = location;
+ } + }
+ +
+ /** + /**
+ * The Entity that is pathfinding. + * The Entity that is pathfinding.
+ *
+ * @return The Entity that is pathfinding. + * @return The Entity that is pathfinding.
+ */ + */
+ @NotNull + @NotNull
+ public Entity getEntity() { + public Entity getEntity() {
+ return entity; + return this.entity;
+ } + }
+ +
+ /** + /**
+ * If the Entity is trying to pathfind to an entity, this is the entity in relation. + * If the Entity is trying to pathfind to an entity, this is the entity in relation.
+ * <br>
+ * Otherwise this will return {@code null}.
+ * + *
+ * Otherwise this will return null. + * @return The entity target or {@code null}
+ *
+ * @return The entity target or null
+ */ + */
+ @Nullable + @Nullable
+ public Entity getTargetEntity() { + public Entity getTargetEntity() {
+ return targetEntity; + return this.targetEntity;
+ } + }
+ +
+ /** + /**
+ * The Location of where the entity is about to move to. + * The Location of where the entity is about to move to.
+ * + * <br>
+ * Note that if the target happened to of been an entity + * Note that if the target happened to of been an entity
+ *
+ * @return Location of where the entity is trying to pathfind to. + * @return Location of where the entity is trying to pathfind to.
+ */ + */
+ @NotNull + @NotNull
+ public Location getLoc() { + public Location getLoc() {
+ return loc; + return this.location;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -10,17 +10,19 @@ Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..a7228e248e3d8eb2e9f011dfe2c7dd9f3f48000f index 0000000000000000000000000000000000000000..f64b253f1794c7987a32a4313df19d7512bea1bc
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java
@@ -0,0 +1,82 @@ @@ -0,0 +1,86 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.event.player.PlayerInteractAtEntityEvent;
+import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.util.Vector; +import org.bukkit.util.Vector;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -33,14 +35,16 @@ index 0000000000000000000000000000000000000000..a7228e248e3d8eb2e9f011dfe2c7dd9f
+ */ + */
+public class PlayerUseUnknownEntityEvent extends PlayerEvent { +public class PlayerUseUnknownEntityEvent extends PlayerEvent {
+ +
+ private static final HandlerList HANDLERS = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final int entityId; + private final int entityId;
+ private final boolean attack; + private final boolean attack;
+ private final @NotNull EquipmentSlot hand; + private final @NotNull EquipmentSlot hand;
+ private final @Nullable Vector clickedPosition; + private final @Nullable Vector clickedPosition;
+ +
+ public PlayerUseUnknownEntityEvent(@NotNull Player who, int entityId, boolean attack, @NotNull EquipmentSlot hand, @Nullable Vector clickedPosition) { + @ApiStatus.Internal
+ super(who); + public PlayerUseUnknownEntityEvent(@NotNull Player player, int entityId, boolean attack, @NotNull EquipmentSlot hand, @Nullable Vector clickedPosition) {
+ super(player);
+ this.entityId = entityId; + this.entityId = entityId;
+ this.attack = attack; + this.attack = attack;
+ this.hand = hand; + this.hand = hand;
@ -59,7 +63,7 @@ index 0000000000000000000000000000000000000000..a7228e248e3d8eb2e9f011dfe2c7dd9f
+ /** + /**
+ * Returns whether the interaction was an attack. + * Returns whether the interaction was an attack.
+ * + *
+ * @return true if the player is attacking the entity, false if the player is interacting with the entity + * @return {@code true} if the player is attacking the entity, {@code false} if the player is interacting with the entity
+ */ + */
+ public boolean isAttack() { + public boolean isAttack() {
+ return this.attack; + return this.attack;
@ -75,11 +79,11 @@ index 0000000000000000000000000000000000000000..a7228e248e3d8eb2e9f011dfe2c7dd9f
+ } + }
+ +
+ /** + /**
+ * Returns the position relative to the entity that was clicked, or null if not available. + * Returns the position relative to the entity that was clicked, or {@code null} if not available.
+ * See {@link org.bukkit.event.player.PlayerInteractAtEntityEvent} for more details. + * See {@link PlayerInteractAtEntityEvent} for more details.
+ * + *
+ * @return the position relative to the entity that was clicked, or null if not available + * @return the position relative to the entity that was clicked, or {@code null} if not available
+ * @see org.bukkit.event.player.PlayerInteractAtEntityEvent + * @see PlayerInteractAtEntityEvent
+ */ + */
+ public @Nullable Vector getClickedRelativePosition() { + public @Nullable Vector getClickedRelativePosition() {
+ return this.clickedPosition != null ? this.clickedPosition.clone() : null; + return this.clickedPosition != null ? this.clickedPosition.clone() : null;
@ -88,11 +92,11 @@ index 0000000000000000000000000000000000000000..a7228e248e3d8eb2e9f011dfe2c7dd9f
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -7,10 +7,10 @@ Subject: [PATCH] Add handshake event to allow plugins to handle client
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..59ae7bc3a0a2079fe4b3a92d777aca682a58e4e3 index 0000000000000000000000000000000000000000..7c049bad187b94331f42f96833d1cf4ce03ef477
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java
@@ -0,0 +1,277 @@ @@ -0,0 +1,267 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
@ -20,6 +20,7 @@ index 0000000000000000000000000000000000000000..59ae7bc3a0a2079fe4b3a92d777aca68
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -27,18 +28,18 @@ index 0000000000000000000000000000000000000000..59ae7bc3a0a2079fe4b3a92d777aca68
+ +
+/** +/**
+ * This event is fired during a player handshake. + * This event is fired during a player handshake.
+ * + * <p>
+ * <p>If there are no listeners listening to this event, the logic default + * If there are no listeners listening to this event, the logic default
+ * to your server platform will be ran.</p> + * to your server platform will be run.
+ * + *
+ * <p>WARNING: TAMPERING WITH THIS EVENT CAN BE DANGEROUS</p> + * <p>WARNING: TAMPERING WITH THIS EVENT CAN BE DANGEROUS</p>
+ */ + */
+public class PlayerHandshakeEvent extends Event implements Cancellable { +public class PlayerHandshakeEvent extends Event implements Cancellable {
+ +
+ private static final HandlerList HANDLERS = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final String originalHandshake; + @NotNull private final String originalHandshake;
+ @NotNull private final String originalSocketAddressHostname; + @NotNull private final String originalSocketAddressHostname;
+ private boolean cancelled;
+ @Nullable private String serverHostname; + @Nullable private String serverHostname;
+ @Nullable private String socketAddressHostname; + @Nullable private String socketAddressHostname;
+ @Nullable private UUID uniqueId; + @Nullable private UUID uniqueId;
@ -46,26 +47,15 @@ index 0000000000000000000000000000000000000000..59ae7bc3a0a2079fe4b3a92d777aca68
+ private boolean failed; + private boolean failed;
+ private Component failMessage = Component.text("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!", NamedTextColor.YELLOW); + private Component failMessage = Component.text("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!", NamedTextColor.YELLOW);
+ +
+ /** + private boolean cancelled;
+ * Creates a new {@link PlayerHandshakeEvent}. +
+ *
+ * @param originalHandshake the original handshake string
+ * @param cancelled if this event is enabled
+ *
+ * @deprecated in favour of {@link PlayerHandshakeEvent(String, String, boolean)}
+ */
+ @Deprecated + @Deprecated
+ @ApiStatus.Internal
+ public PlayerHandshakeEvent(@NotNull String originalHandshake, boolean cancelled) { + public PlayerHandshakeEvent(@NotNull String originalHandshake, boolean cancelled) {
+ this(originalHandshake, "127.0.0.1", cancelled); + this(originalHandshake, "127.0.0.1", cancelled);
+ } + }
+ +
+ /** + @ApiStatus.Internal
+ * Creates a new {@link PlayerHandshakeEvent}.
+ *
+ * @param originalHandshake the original handshake string
+ * @param originalSocketAddressHostname the original socket address hostname
+ * @param cancelled if this event is enabled
+ */
+ public PlayerHandshakeEvent(@NotNull String originalHandshake, @NotNull String originalSocketAddressHostname, boolean cancelled) { + public PlayerHandshakeEvent(@NotNull String originalHandshake, @NotNull String originalSocketAddressHostname, boolean cancelled) {
+ super(true); + super(true);
+ this.originalHandshake = originalHandshake; + this.originalHandshake = originalHandshake;
@ -75,9 +65,9 @@ index 0000000000000000000000000000000000000000..59ae7bc3a0a2079fe4b3a92d777aca68
+ +
+ /** + /**
+ * Determines if this event is cancelled. + * Determines if this event is cancelled.
+ * + * <p>
+ * <p>When this event is cancelled, custom handshake logic will not + * When this event is cancelled, custom handshake logic will not
+ * be processed.</p> + * be processed.
+ * + *
+ * @return {@code true} if this event is cancelled, {@code false} otherwise + * @return {@code true} if this event is cancelled, {@code false} otherwise
+ */ + */
@ -88,15 +78,15 @@ index 0000000000000000000000000000000000000000..59ae7bc3a0a2079fe4b3a92d777aca68
+ +
+ /** + /**
+ * Sets if this event is cancelled. + * Sets if this event is cancelled.
+ * <p>
+ * When this event is cancelled, custom handshake logic will not
+ * be processed.
+ * + *
+ * <p>When this event is cancelled, custom handshake logic will not + * @param cancel {@code true} if this event is cancelled, {@code false} otherwise
+ * be processed.</p>
+ *
+ * @param cancelled {@code true} if this event is cancelled, {@code false} otherwise
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancelled) { + public void setCancelled(boolean cancel) {
+ this.cancelled = cancelled; + this.cancelled = cancel;
+ } + }
+ +
+ /** + /**
@ -201,9 +191,9 @@ index 0000000000000000000000000000000000000000..59ae7bc3a0a2079fe4b3a92d777aca68
+ +
+ /** + /**
+ * Determines if authentication failed. + * Determines if authentication failed.
+ * + * <p>
+ * <p>When {@code true}, the client connecting will be disconnected + * When {@code true}, the client connecting will be disconnected
+ * with the {@link #getFailMessage() fail message}.</p> + * with the {@link #getFailMessage() fail message}.
+ * + *
+ * @return {@code true} if authentication failed, {@code false} otherwise + * @return {@code true} if authentication failed, {@code false} otherwise
+ */ + */
@ -213,9 +203,9 @@ index 0000000000000000000000000000000000000000..59ae7bc3a0a2079fe4b3a92d777aca68
+ +
+ /** + /**
+ * Sets if authentication failed and the client should be disconnected. + * Sets if authentication failed and the client should be disconnected.
+ * + * <p>
+ * <p>When {@code true}, the client connecting will be disconnected + * When {@code true}, the client connecting will be disconnected
+ * with the {@link #getFailMessage() fail message}.</p> + * with the {@link #getFailMessage() fail message}.
+ * + *
+ * @param failed {@code true} if authentication failed, {@code false} otherwise + * @param failed {@code true} if authentication failed, {@code false} otherwise
+ */ + */
@ -280,11 +270,11 @@ index 0000000000000000000000000000000000000000..59ae7bc3a0a2079fe4b3a92d777aca68
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -189,21 +189,27 @@ index 0000000000000000000000000000000000000000..2b01a50b6e18856f4c9e28340a7a111c
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableInventoryReplenishEvent.java b/src/main/java/com/destroystokyo/paper/loottable/LootableInventoryReplenishEvent.java diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableInventoryReplenishEvent.java b/src/main/java/com/destroystokyo/paper/loottable/LootableInventoryReplenishEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..fd184f13f5e8ee5cf829fff4f44696e1f760430b index 0000000000000000000000000000000000000000..5ee1a04aaaa4ef09559f2cf757811e463e2a1be6
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/loottable/LootableInventoryReplenishEvent.java +++ b/src/main/java/com/destroystokyo/paper/loottable/LootableInventoryReplenishEvent.java
@@ -0,0 +1,45 @@ @@ -0,0 +1,47 @@
+package com.destroystokyo.paper.loottable; +package com.destroystokyo.paper.loottable;
+ +
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+public class LootableInventoryReplenishEvent extends PlayerEvent implements Cancellable { +public class LootableInventoryReplenishEvent extends PlayerEvent implements Cancellable {
+ @NotNull private final LootableInventory inventory;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final LootableInventory inventory;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public LootableInventoryReplenishEvent(@NotNull Player player, @NotNull LootableInventory inventory) { + public LootableInventoryReplenishEvent(@NotNull Player player, @NotNull LootableInventory inventory) {
+ super(player); + super(player);
+ this.inventory = inventory; + this.inventory = inventory;
@ -211,31 +217,27 @@ index 0000000000000000000000000000000000000000..fd184f13f5e8ee5cf829fff4f44696e1
+ +
+ @NotNull + @NotNull
+ public LootableInventory getInventory() { + public LootableInventory getInventory() {
+ return inventory; + return this.inventory;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/block/Barrel.java b/src/main/java/org/bukkit/block/Barrel.java diff --git a/src/main/java/org/bukkit/block/Barrel.java b/src/main/java/org/bukkit/block/Barrel.java

Datei anzeigen

@ -6,13 +6,12 @@ Subject: [PATCH] Add EntityZapEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..1c5fa066c9e5e1b1a06df30842a4c7acc4742df8 index 0000000000000000000000000000000000000000..dc6d15975a47e68c5bd939e68ddd2773028a6ac8
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java
@@ -0,0 +1,64 @@ @@ -0,0 +1,69 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import com.google.common.base.Preconditions;
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.entity.LightningStrike; +import org.bukkit.entity.LightningStrike;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
@ -20,91 +19,89 @@ index 0000000000000000000000000000000000000000..1c5fa066c9e5e1b1a06df30842a4c7ac
+import org.bukkit.event.entity.EntityTransformEvent; +import org.bukkit.event.entity.EntityTransformEvent;
+ +
+import java.util.Collections; +import java.util.Collections;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when lightning strikes an entity + * Fired when lightning strikes an entity
+ */ + */
+public class EntityZapEvent extends EntityTransformEvent implements Cancellable { +public class EntityZapEvent extends EntityTransformEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ @NotNull private final LightningStrike bolt;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final LightningStrike bolt;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityZapEvent(@NotNull final Entity entity, @NotNull final LightningStrike bolt, @NotNull final Entity replacementEntity) { + public EntityZapEvent(@NotNull final Entity entity, @NotNull final LightningStrike bolt, @NotNull final Entity replacementEntity) {
+ super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING); + super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING);
+ Preconditions.checkNotNull(bolt);
+ Preconditions.checkNotNull(replacementEntity);
+ this.bolt = bolt; + this.bolt = bolt;
+ } + }
+ +
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ /** + /**
+ * Gets the lightning bolt that is striking the entity. + * Gets the lightning bolt that is striking the entity.
+ *
+ * @return The lightning bolt responsible for this event + * @return The lightning bolt responsible for this event
+ */ + */
+ @NotNull + @NotNull
+ public LightningStrike getBolt() { + public LightningStrike getBolt() {
+ return bolt; + return this.bolt;
+ } + }
+ +
+ /** + /**
+ * Gets the entity that will replace the struck entity. + * Gets the entity that will replace the struck entity.
+ *
+ * @return The entity that will replace the struck entity + * @return The entity that will replace the struck entity
+ */ + */
+ @NotNull + @NotNull
+ public Entity getReplacementEntity() { + public Entity getReplacementEntity() {
+ return getTransformedEntity(); + return super.getTransformedEntity();
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/src/main/java/org/bukkit/event/entity/PigZapEvent.java diff --git a/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/src/main/java/org/bukkit/event/entity/PigZapEvent.java
index 0e0ed93b568fd2c0d8f6e359c31dc29cb0fa71c2..d3949edfc736b3d67a627ef378748b374769e183 100644 index 0e0ed93b568fd2c0d8f6e359c31dc29cb0fa71c2..085337f3d3d6adef5fd4ecda133c607e4b77bd93 100644
--- a/src/main/java/org/bukkit/event/entity/PigZapEvent.java --- a/src/main/java/org/bukkit/event/entity/PigZapEvent.java
+++ b/src/main/java/org/bukkit/event/entity/PigZapEvent.java +++ b/src/main/java/org/bukkit/event/entity/PigZapEvent.java
@@ -2,6 +2,7 @@ package org.bukkit.event.entity; @@ -12,14 +12,14 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import org.bukkit.entity.Entity;
+import com.destroystokyo.paper.event.entity.EntityZapEvent;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Pig;
import org.bukkit.entity.PigZombie;
@@ -12,14 +13,14 @@ import org.jetbrains.annotations.NotNull;
/** /**
* Stores data for pigs being zapped * Stores data for pigs being zapped
*/ */
-public class PigZapEvent extends EntityTransformEvent implements Cancellable { -public class PigZapEvent extends EntityTransformEvent implements Cancellable {
- private static final HandlerList handlers = new HandlerList(); - private static final HandlerList handlers = new HandlerList();
+public class PigZapEvent extends EntityZapEvent implements Cancellable { +public class PigZapEvent extends com.destroystokyo.paper.event.entity.EntityZapEvent implements Cancellable { // Paper
+ //private static final HandlerList handlers = new HandlerList(); + // private static final HandlerList handlers = new HandlerList(); // Paper - moved in the super class
private boolean canceled; private boolean canceled;
private final PigZombie pigzombie; private final PigZombie pigzombie;
private final LightningStrike bolt; private final LightningStrike bolt;
public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie pigzombie) { public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie pigzombie) {
- super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING); - super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING);
+ super(pig, bolt, pigzombie); + super(pig, bolt, pigzombie); // Paper
this.bolt = bolt; this.bolt = bolt;
this.pigzombie = pigzombie; this.pigzombie = pigzombie;
} }
@@ -63,6 +64,8 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable { @@ -63,6 +63,8 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
return pigzombie; return pigzombie;
} }
@ -113,7 +110,7 @@ index 0e0ed93b568fd2c0d8f6e359c31dc29cb0fa71c2..d3949edfc736b3d67a627ef378748b37
@NotNull @NotNull
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
@@ -73,4 +76,6 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable { @@ -73,4 +75,6 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }

Datei anzeigen

@ -7,41 +7,40 @@ Now deprecated and replaced with ProjectileHitEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..6ae2bc3d952d34f298220738856024e0b6594199 index 0000000000000000000000000000000000000000..3caff9cbb990e03d4331bd601272aec5090affcf
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java
@@ -0,0 +1,69 @@ @@ -0,0 +1,74 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.entity.Projectile; +import org.bukkit.entity.Projectile;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when a projectile collides with an entity + * Called when a projectile collides with an entity
+ * <p> + * <p>
+ * This event is called <b>before</b> {@link org.bukkit.event.entity.EntityDamageByEntityEvent}, and cancelling it will allow the projectile to continue flying + * This event is called <b>before</b> {@link EntityDamageByEntityEvent}, and cancelling it will allow the projectile to continue flying
+ *
+ * @deprecated Deprecated, use {@link org.bukkit.event.entity.ProjectileHitEvent} and check if there is a hit entity + * @deprecated Deprecated, use {@link org.bukkit.event.entity.ProjectileHitEvent} and check if there is a hit entity
+ */ + */
+@Deprecated +@Deprecated
+public class ProjectileCollideEvent extends EntityEvent implements Cancellable { +public class ProjectileCollideEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Entity collidedWith; + @NotNull private final Entity collidedWith;
+ +
+ /** + private boolean cancelled;
+ * Get the entity the projectile collided with
+ *
+ * @return the entity collided with
+ */
+ @NotNull
+ public Entity getCollidedWith() {
+ return collidedWith;
+ }
+ +
+ public ProjectileCollideEvent(@NotNull Projectile what, @NotNull Entity collidedWith) { + @ApiStatus.Internal
+ super(what); + public ProjectileCollideEvent(@NotNull Projectile projectile, @NotNull Entity collidedWith) {
+ super(projectile);
+ this.collidedWith = collidedWith; + this.collidedWith = collidedWith;
+ } + }
+ +
@ -55,28 +54,34 @@ index 0000000000000000000000000000000000000000..6ae2bc3d952d34f298220738856024e0
+ return (Projectile) super.getEntity(); + return (Projectile) super.getEntity();
+ } + }
+ +
+ private static final HandlerList handlerList = new HandlerList(); + /**
+ + * Get the entity the projectile collided with
+ *
+ * @return the entity collided with
+ */
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public Entity getCollidedWith() {
+ return handlerList; + return this.collidedWith;
+ } + }
+ +
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlerList;
+ }
+
+ private boolean cancelled = false;
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+} +}

Datei anzeigen

@ -9,16 +9,16 @@ Lets plugins change the kick message and if it should kick or not.
diff --git a/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..8d8e9b16f2a6707d2af7567c7682dfc5db51a737 index 0000000000000000000000000000000000000000..8dc5971ba441395f7bc13568c5ee88ca34837e95
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java
@@ -0,0 +1,74 @@ @@ -0,0 +1,67 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -27,20 +27,24 @@ index 0000000000000000000000000000000000000000..8d8e9b16f2a6707d2af7567c7682dfc5
+ */ + */
+@Deprecated +@Deprecated
+public class IllegalPacketEvent extends PlayerEvent { +public class IllegalPacketEvent extends PlayerEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @Nullable private final String type; + @Nullable private final String type;
+ @Nullable private final String ex; + @Nullable private final String exceptionMessage;
+ @Nullable private String kickMessage; + @Nullable private String kickMessage;
+ private boolean shouldKick = true; + private boolean shouldKick = true;
+ +
+ @ApiStatus.Internal
+ public IllegalPacketEvent(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception e) { + public IllegalPacketEvent(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception e) {
+ super(player); + super(player);
+ this.type = type; + this.type = type;
+ this.kickMessage = kickMessage; + this.kickMessage = kickMessage;
+ this.ex = e.getMessage(); + this.exceptionMessage = e.getMessage();
+ } + }
+ +
+ public boolean isShouldKick() { + public boolean isShouldKick() {
+ return shouldKick; + return this.shouldKick;
+ } + }
+ +
+ public void setShouldKick(boolean shouldKick) { + public void setShouldKick(boolean shouldKick) {
@ -49,7 +53,7 @@ index 0000000000000000000000000000000000000000..8d8e9b16f2a6707d2af7567c7682dfc5
+ +
+ @Nullable + @Nullable
+ public String getKickMessage() { + public String getKickMessage() {
+ return kickMessage; + return this.kickMessage;
+ } + }
+ +
+ public void setKickMessage(@Nullable String kickMessage) { + public void setKickMessage(@Nullable String kickMessage) {
@ -58,32 +62,21 @@ index 0000000000000000000000000000000000000000..8d8e9b16f2a6707d2af7567c7682dfc5
+ +
+ @Nullable + @Nullable
+ public String getType() { + public String getType() {
+ return type; + return this.type;
+ } + }
+ +
+ @Nullable + @Nullable
+ public String getExceptionMessage() { + public String getExceptionMessage() {
+ return ex; + return this.exceptionMessage;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ }
+
+ public static void process(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception exception) {
+ IllegalPacketEvent event = new IllegalPacketEvent(player, type, kickMessage, exception);
+ event.callEvent();
+ if (event.shouldKick) {
+ player.kickPlayer(kickMessage);
+ }
+ Bukkit.getLogger().severe(player.getName() + "/" + type + ": " + exception.getMessage());
+ } + }
+} +}

Datei anzeigen

@ -7,24 +7,27 @@ Allows you to access the Gateway being used in a teleport event
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerTeleportEndGatewayEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerTeleportEndGatewayEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerTeleportEndGatewayEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerTeleportEndGatewayEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..b64ab6eecd8bc4ca9c109b9d83c82861d6260793 index 0000000000000000000000000000000000000000..40bd79fbe30f19bc93e34da52d2b2bf0768be974
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerTeleportEndGatewayEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerTeleportEndGatewayEvent.java
@@ -0,0 +1,29 @@ @@ -0,0 +1,32 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
+import org.bukkit.block.EndGateway; +import org.bukkit.block.EndGateway;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when a teleport is triggered for an End Gateway + * Fired when a teleport is triggered for an End Gateway
+ */ + */
+public class PlayerTeleportEndGatewayEvent extends PlayerTeleportEvent { +public class PlayerTeleportEndGatewayEvent extends PlayerTeleportEvent {
+
+ @NotNull private final EndGateway gateway; + @NotNull private final EndGateway gateway;
+ +
+ @ApiStatus.Internal
+ public PlayerTeleportEndGatewayEvent(@NotNull Player player, @NotNull Location from, @NotNull Location to, @NotNull EndGateway gateway) { + public PlayerTeleportEndGatewayEvent(@NotNull Player player, @NotNull Location from, @NotNull Location to, @NotNull EndGateway gateway) {
+ super(player, from, to, PlayerTeleportEvent.TeleportCause.END_GATEWAY); + super(player, from, to, PlayerTeleportEvent.TeleportCause.END_GATEWAY);
+ this.gateway = gateway; + this.gateway = gateway;
@ -37,6 +40,6 @@ index 0000000000000000000000000000000000000000..b64ab6eecd8bc4ca9c109b9d83c82861
+ */ + */
+ @NotNull + @NotNull
+ public EndGateway getGateway() { + public EndGateway getGateway() {
+ return gateway; + return this.gateway;
+ } + }
+} +}

Datei anzeigen

@ -6,33 +6,39 @@ Subject: [PATCH] PlayerAttemptPickupItemEvent
diff --git a/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..0788153a9641e75da565d2e6eee37eeee1cbc61e index 0000000000000000000000000000000000000000..13e4b1309ea9965a07fc8b276d5a7e606e205824
--- /dev/null --- /dev/null
+++ b/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java
@@ -0,0 +1,90 @@ @@ -0,0 +1,96 @@
+package org.bukkit.event.player; +package org.bukkit.event.player;
+ +
+import org.bukkit.entity.Item; +import org.bukkit.entity.Item;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Thrown when a player attempts to pick an item up from the ground + * Thrown when a player attempts to pick an item up from the ground
+ */ + */
+public class PlayerAttemptPickupItemEvent extends PlayerEvent implements Cancellable { +public class PlayerAttemptPickupItemEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Item item; + @NotNull private final Item item;
+ private final int remaining; + private final int remaining;
+ private boolean flyAtPlayer = true; + private boolean flyAtPlayer = true;
+ private boolean isCancelled = false; +
+ private boolean cancelled;
+ +
+ @Deprecated // Remove in 1.13 // Remove in 1.14? + @Deprecated // Remove in 1.13 // Remove in 1.14?
+ @ApiStatus.Internal
+ public PlayerAttemptPickupItemEvent(@NotNull final Player player, @NotNull final Item item) { + public PlayerAttemptPickupItemEvent(@NotNull final Player player, @NotNull final Item item) {
+ this(player, item, 0); + this(player, item, 0);
+ } + }
+ +
+ @ApiStatus.Internal
+ public PlayerAttemptPickupItemEvent(@NotNull final Player player, @NotNull final Item item, final int remaining) { + public PlayerAttemptPickupItemEvent(@NotNull final Player player, @NotNull final Item item, final int remaining) {
+ super(player); + super(player);
+ this.item = item; + this.item = item;
@ -46,7 +52,7 @@ index 0000000000000000000000000000000000000000..0788153a9641e75da565d2e6eee37eee
+ */ + */
+ @NotNull + @NotNull
+ public Item getItem() { + public Item getItem() {
+ return item; + return this.item;
+ } + }
+ +
+ /** + /**
@ -55,14 +61,14 @@ index 0000000000000000000000000000000000000000..0788153a9641e75da565d2e6eee37eee
+ * @return amount that will remain on the ground + * @return amount that will remain on the ground
+ */ + */
+ public int getRemaining() { + public int getRemaining() {
+ return remaining; + return this.remaining;
+ } + }
+ +
+ /** + /**
+ * Set if the item will fly at the player + * Set if the item will fly at the player
+ * <p>Cancelling the event will set this value to false.</p> + * <p>Cancelling the event will set this value to false.</p>
+ * + *
+ * @param flyAtPlayer True for item to fly at player + * @param flyAtPlayer {@code true} for item to fly at player
+ */ + */
+ public void setFlyAtPlayer(boolean flyAtPlayer) { + public void setFlyAtPlayer(boolean flyAtPlayer) {
+ this.flyAtPlayer = flyAtPlayer; + this.flyAtPlayer = flyAtPlayer;
@ -71,7 +77,7 @@ index 0000000000000000000000000000000000000000..0788153a9641e75da565d2e6eee37eee
+ /** + /**
+ * Gets if the item will fly at the player + * Gets if the item will fly at the player
+ * + *
+ * @return True if the item will fly at the player + * @return {@code true} if the item will fly at the player
+ */ + */
+ public boolean getFlyAtPlayer() { + public boolean getFlyAtPlayer() {
+ return this.flyAtPlayer; + return this.flyAtPlayer;
@ -80,23 +86,23 @@ index 0000000000000000000000000000000000000000..0788153a9641e75da565d2e6eee37eee
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return this.isCancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.isCancelled = cancel; + this.cancelled = cancel;
+ this.flyAtPlayer = !cancel; + this.flyAtPlayer = !cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Add UnknownCommandEvent
diff --git a/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java b/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java diff --git a/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java b/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..e4f8a0d14ae66468bbb0a5d6bf9c1ee417dc866c index 0000000000000000000000000000000000000000..9bdeeecdb6021d61fd9141270011e56b06a58a76
--- /dev/null --- /dev/null
+++ b/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java +++ b/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java
@@ -0,0 +1,110 @@ @@ -0,0 +1,110 @@
@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..e4f8a0d14ae66468bbb0a5d6bf9c1ee4
+import org.bukkit.command.CommandSender; +import org.bukkit.command.CommandSender;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
@ -25,11 +26,14 @@ index 0000000000000000000000000000000000000000..e4f8a0d14ae66468bbb0a5d6bf9c1ee4
+ * Thrown when a player executes a command that is not defined + * Thrown when a player executes a command that is not defined
+ */ + */
+public class UnknownCommandEvent extends Event { +public class UnknownCommandEvent extends Event {
+ private static final HandlerList handlers = new HandlerList(); +
+ @NotNull private CommandSender sender; + private static final HandlerList HANDLER_LIST = new HandlerList();
+ @NotNull private String commandLine; +
+ @NotNull private final CommandSender sender;
+ @NotNull private final String commandLine;
+ @Nullable private Component message; + @Nullable private Component message;
+ +
+ @ApiStatus.Internal
+ public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final Component message) { + public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final Component message) {
+ super(false); + super(false);
+ this.sender = sender; + this.sender = sender;
@ -39,29 +43,26 @@ index 0000000000000000000000000000000000000000..e4f8a0d14ae66468bbb0a5d6bf9c1ee4
+ +
+ /** + /**
+ * Gets the CommandSender or ConsoleCommandSender + * Gets the CommandSender or ConsoleCommandSender
+ * <p>
+ * + *
+ * @return Sender of the command + * @return Sender of the command
+ */ + */
+ @NotNull + @NotNull
+ public CommandSender getSender() { + public CommandSender getSender() {
+ return sender; + return this.sender;
+ } + }
+ +
+ /** + /**
+ * Gets the command that was send + * Gets the command that was sent
+ * <p>
+ * + *
+ * @return Command sent + * @return Command sent
+ */ + */
+ @NotNull + @NotNull
+ public String getCommandLine() { + public String getCommandLine() {
+ return commandLine; + return this.commandLine;
+ } + }
+ +
+ /** + /**
+ * Gets message that will be returned + * Gets message that will be returned
+ * <p>
+ * + *
+ * @return Unknown command message + * @return Unknown command message
+ * @deprecated use {@link #message()} + * @deprecated use {@link #message()}
@ -75,9 +76,9 @@ index 0000000000000000000000000000000000000000..e4f8a0d14ae66468bbb0a5d6bf9c1ee4
+ /** + /**
+ * Sets message that will be returned + * Sets message that will be returned
+ * <p> + * <p>
+ * Set to null to avoid any message being sent + * Set to {@code null} to avoid any message being sent
+ * + *
+ * @param message the message to be returned, or null + * @param message the message to be returned, or {@code null}
+ * @deprecated use {@link #message(Component)} + * @deprecated use {@link #message(Component)}
+ */ + */
+ @Deprecated + @Deprecated
@ -87,7 +88,6 @@ index 0000000000000000000000000000000000000000..e4f8a0d14ae66468bbb0a5d6bf9c1ee4
+ +
+ /** + /**
+ * Gets message that will be returned + * Gets message that will be returned
+ * <p>
+ * + *
+ * @return Unknown command message + * @return Unknown command message
+ */ + */
@ -100,9 +100,9 @@ index 0000000000000000000000000000000000000000..e4f8a0d14ae66468bbb0a5d6bf9c1ee4
+ /** + /**
+ * Sets message that will be returned + * Sets message that will be returned
+ * <p> + * <p>
+ * Set to null to avoid any message being sent + * Set to {@code null} to avoid any message being sent
+ * + *
+ * @param message the message to be returned, or null + * @param message the message to be returned, or {@code null}
+ */ + */
+ public void message(@Nullable Component message) { + public void message(@Nullable Component message) {
+ this.message = message; + this.message = message;
@ -111,12 +111,12 @@ index 0000000000000000000000000000000000000000..e4f8a0d14ae66468bbb0a5d6bf9c1ee4
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
+ +

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] PlayerPickupItemEvent#setFlyAtPlayer
diff --git a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
index 951ea2cc763973655beedcba3c75332d3f297313..26383597cb0bdcf81035b571998332090b785730 100644 index 951ea2cc763973655beedcba3c75332d3f297313..e528d811f651696069dbd2fd21c5ffad294b26af 100644
--- a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java --- a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
@@ -17,6 +17,7 @@ import org.jetbrains.annotations.NotNull; @@ -17,6 +17,7 @@ import org.jetbrains.annotations.NotNull;
@ -16,16 +16,17 @@ index 951ea2cc763973655beedcba3c75332d3f297313..26383597cb0bdcf81035b57199833209
private boolean cancel = false; private boolean cancel = false;
private final int remaining; private final int remaining;
@@ -45,6 +46,27 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { @@ -45,6 +46,28 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
return remaining; return remaining;
} }
+ // Paper start + // Paper start
+ /** + /**
+ * Set if the item will fly at the player + * Set if the item will fly at the player
+ * <p>Cancelling the event will set this value to false.</p> + * <p>
+ * Cancelling the event will set this value to false.
+ * + *
+ * @param flyAtPlayer True for item to fly at player + * @param flyAtPlayer true for item to fly at player
+ */ + */
+ public void setFlyAtPlayer(boolean flyAtPlayer) { + public void setFlyAtPlayer(boolean flyAtPlayer) {
+ this.flyAtPlayer = flyAtPlayer; + this.flyAtPlayer = flyAtPlayer;
@ -34,7 +35,7 @@ index 951ea2cc763973655beedcba3c75332d3f297313..26383597cb0bdcf81035b57199833209
+ /** + /**
+ * Gets if the item will fly at the player + * Gets if the item will fly at the player
+ * + *
+ * @return True if the item will fly at the player + * @return true if the item will fly at the player
+ */ + */
+ public boolean getFlyAtPlayer() { + public boolean getFlyAtPlayer() {
+ return flyAtPlayer; + return flyAtPlayer;
@ -44,7 +45,7 @@ index 951ea2cc763973655beedcba3c75332d3f297313..26383597cb0bdcf81035b57199833209
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancel; return cancel;
@@ -53,6 +75,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { @@ -53,6 +76,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
@Override @Override
public void setCancelled(boolean cancel) { public void setCancelled(boolean cancel) {
this.cancel = cancel; this.cancel = cancel;

Datei anzeigen

@ -8,10 +8,10 @@ profiles that had to be looked up.
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..8df37c07cd55ddf110d1dd68183d7b697f7a6756 index 0000000000000000000000000000000000000000..2ad2782aafe76f8b10565c0f0419d6b9c665b267
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/LookupProfileEvent.java
@@ -0,0 +1,46 @@ @@ -0,0 +1,48 @@
+package com.destroystokyo.paper.event.profile; +package com.destroystokyo.paper.event.profile;
+ +
+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile;
@ -19,21 +19,23 @@ index 0000000000000000000000000000000000000000..8df37c07cd55ddf110d1dd68183d7b69
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+ +
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Allows a plugin to be notified anytime AFTER a Profile has been looked up from the Mojang API + * Allows a plugin to be notified anytime AFTER a Profile has been looked up from the Mojang API
+ * This is an opportunity to view the response and potentially cache things. + * This is an opportunity to view the response and potentially cache things.
+ * + * <p>
+ * No guarantees are made about thread execution context for this event. If you need to know, check + * No guarantees are made about thread execution context for this event. If you need to know, check
+ * event.isAsync() + * {@link Event#isAsynchronous()}
+ */ + */
+public class LookupProfileEvent extends Event { +public class LookupProfileEvent extends Event {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final PlayerProfile profile; + @NotNull private final PlayerProfile profile;
+ +
+ @ApiStatus.Internal
+ public LookupProfileEvent(@NotNull PlayerProfile profile) { + public LookupProfileEvent(@NotNull PlayerProfile profile) {
+ super(!Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread());
+ this.profile = profile; + this.profile = profile;
@ -44,31 +46,29 @@ index 0000000000000000000000000000000000000000..8df37c07cd55ddf110d1dd68183d7b69
+ */ + */
+ @NotNull + @NotNull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
+ return profile; + return this.profile;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4dcf6242c9acc62d030a94f67b78729ed29f8c85 index 0000000000000000000000000000000000000000..3f73ec52f9b581001bef3a19a5f1533dfa474356
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.java
@@ -0,0 +1,108 @@ @@ -0,0 +1,112 @@
+package com.destroystokyo.paper.event.profile; +package com.destroystokyo.paper.event.profile;
+ +
+import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty; +import com.destroystokyo.paper.profile.ProfileProperty;
+import com.google.common.collect.ArrayListMultimap;
+import org.bukkit.Bukkit; +import org.bukkit.Bukkit;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
@ -76,26 +76,30 @@ index 0000000000000000000000000000000000000000..4dcf6242c9acc62d030a94f67b78729e
+import java.util.HashSet; +import java.util.HashSet;
+import java.util.Set; +import java.util.Set;
+import java.util.UUID; +import java.util.UUID;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Allows a plugin to intercept a Profile Lookup for a Profile by name + * Allows a plugin to intercept a Profile Lookup for a Profile by name
+ * + * <p>
+ * At the point of event fire, the UUID and properties are unset. + * At the point of event fire, the UUID and properties are unset.
+ * + * <p>
+ * If a plugin sets the UUID, and optionally the properties, the API call to look up the profile may be skipped. + * If a plugin sets the UUID, and optionally the properties, the API call to look up the profile may be skipped.
+ * + * <p>
+ * No guarantees are made about thread execution context for this event. If you need to know, check + * No guarantees are made about thread execution context for this event. If you need to know, check
+ * event.isAsync() + * {@link Event#isAsynchronous()}
+ */ + */
+public class PreLookupProfileEvent extends Event { +public class PreLookupProfileEvent extends Event {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final String name; + @NotNull private final String name;
+
+ private UUID uuid; + private UUID uuid;
+ @NotNull private Set<ProfileProperty> properties = new HashSet<>(); + @NotNull private Set<ProfileProperty> properties = new HashSet<>();
+ +
+ @ApiStatus.Internal
+ public PreLookupProfileEvent(@NotNull String name) { + public PreLookupProfileEvent(@NotNull String name) {
+ super(!Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread());
+ this.name = name; + this.name = name;
@ -106,11 +110,11 @@ index 0000000000000000000000000000000000000000..4dcf6242c9acc62d030a94f67b78729e
+ */ + */
+ @NotNull + @NotNull
+ public String getName() { + public String getName() {
+ return name; + return this.name;
+ } + }
+ +
+ /** + /**
+ * If this value is left null by the completion of the event call, then the server will + * If this value is left {@code null} by the completion of the event call, then the server will
+ * trigger a call to the Mojang API to look up the UUID (Network Request), and subsequently, fire a + * trigger a call to the Mojang API to look up the UUID (Network Request), and subsequently, fire a
+ * {@link LookupProfileEvent} + * {@link LookupProfileEvent}
+ * + *
@ -118,22 +122,22 @@ index 0000000000000000000000000000000000000000..4dcf6242c9acc62d030a94f67b78729e
+ */ + */
+ @Nullable + @Nullable
+ public UUID getUUID() { + public UUID getUUID() {
+ return uuid; + return this.uuid;
+ } + }
+ +
+ /** + /**
+ * Sets the UUID for this player name. This will skip the initial API call to find the players UUID. + * Sets the UUID for this player name. This will skip the initial API call to find the players UUID.
+ * + * <p>
+ * However, if Profile Properties are needed by the server, you must also set them or else an API call might still be made. + * However, if Profile Properties are needed by the server, you must also set them or else an API call might still be made.
+ * + *
+ * @param uuid the UUID to set for the profile or null to reset + * @param uuid the UUID to set for the profile or {@code null} to reset
+ */ + */
+ public void setUUID(@Nullable UUID uuid) { + public void setUUID(@Nullable UUID uuid) {
+ this.uuid = uuid; + this.uuid = uuid;
+ } + }
+ +
+ /** + /**
+ * @return The currently pending prepopulated properties. + * @return The currently pending pre-populated properties.
+ * Any property in this Set will be automatically prefilled on this Profile + * Any property in this Set will be automatically prefilled on this Profile
+ */ + */
+ @NotNull + @NotNull
@ -142,8 +146,9 @@ index 0000000000000000000000000000000000000000..4dcf6242c9acc62d030a94f67b78729e
+ } + }
+ +
+ /** + /**
+ * Clears any existing prepopulated properties and uses the supplied properties + * Clears any existing pre-populated properties and uses the supplied properties
+ * Any property in this Set will be automatically prefilled on this Profile + * Any property in this Set will be automatically prefilled on this Profile
+ *
+ * @param properties The properties to add + * @param properties The properties to add
+ */ + */
+ public void setProfileProperties(@NotNull Set<ProfileProperty> properties) { + public void setProfileProperties(@NotNull Set<ProfileProperty> properties) {
@ -152,8 +157,9 @@ index 0000000000000000000000000000000000000000..4dcf6242c9acc62d030a94f67b78729e
+ } + }
+ +
+ /** + /**
+ * Adds any properties currently missing to the prepopulated properties set, replacing any that already were set. + * Adds any properties currently missing to the pre-populated properties set, replacing any that already were set.
+ * Any property in this Set will be automatically prefilled on this Profile + * Any property in this Set will be automatically prefilled on this Profile
+ *
+ * @param properties The properties to add + * @param properties The properties to add
+ */ + */
+ public void addProfileProperties(@NotNull Set<ProfileProperty> properties) { + public void addProfileProperties(@NotNull Set<ProfileProperty> properties) {
@ -163,12 +169,12 @@ index 0000000000000000000000000000000000000000..4dcf6242c9acc62d030a94f67b78729e
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+} +}

Datei anzeigen

@ -9,10 +9,10 @@ Allows you to do dynamic whitelisting and change of kick message
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..c6f5e2b5459368ad1e4db9929ca14568a25793fa index 0000000000000000000000000000000000000000..52959c2d19c5b73ccd85afce6b2ab8133478f7c6
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
@@ -0,0 +1,142 @@ @@ -0,0 +1,147 @@
+/* +/*
+ * Copyright (c) 2017 - Daniel Ennis (Aikar) - MIT License + * Copyright (c) 2017 - Daniel Ennis (Aikar) - MIT License
+ * + *
@ -43,28 +43,33 @@ index 0000000000000000000000000000000000000000..c6f5e2b5459368ad1e4db9929ca14568
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Fires when the server needs to verify if a player is whitelisted. + * Fires when the server needs to verify if a player is whitelisted.
+ * + * <p>
+ * Plugins may override/control the servers whitelist with this event, + * Plugins may override/control the servers whitelist with this event,
+ * and dynamically change the kick message. + * and dynamically change the kick message.
+ */ + */
+public class ProfileWhitelistVerifyEvent extends Event { +public class ProfileWhitelistVerifyEvent extends Event {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final PlayerProfile profile; + @NotNull private final PlayerProfile profile;
+ private final boolean whitelistEnabled; + private final boolean whitelistEnabled;
+ private boolean whitelisted;
+ private final boolean isOp; + private final boolean isOp;
+ private boolean whitelisted;
+ @Nullable private Component kickMessage; + @Nullable private Component kickMessage;
+ +
+ @Deprecated + @Deprecated
+ @ApiStatus.Internal
+ public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable String kickMessage) { + public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable String kickMessage) {
+ this(profile, whitelistEnabled, whitelisted, isOp, kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage)); + this(profile, whitelistEnabled, whitelisted, isOp, kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage));
+ } + }
+ +
+ @ApiStatus.Internal
+ public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable Component kickMessage) { + public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable Component kickMessage) {
+ this.profile = profile; + this.profile = profile;
+ this.whitelistEnabled = whitelistEnabled; + this.whitelistEnabled = whitelistEnabled;
@ -80,11 +85,11 @@ index 0000000000000000000000000000000000000000..c6f5e2b5459368ad1e4db9929ca14568
+ @Deprecated + @Deprecated
+ @Nullable + @Nullable
+ public String getKickMessage() { + public String getKickMessage() {
+ return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(kickMessage); + return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.kickMessage);
+ } + }
+ +
+ /** + /**
+ * @param kickMessage The message to send to the player on kick if not whitelisted. May set to null to use the server configured default + * @param kickMessage The message to send to the player on kick if not whitelisted. May set to {@code null} to use the server configured default
+ * @deprecated Use {@link #kickMessage(Component)} + * @deprecated Use {@link #kickMessage(Component)}
+ */ + */
+ @Deprecated + @Deprecated
@ -101,7 +106,7 @@ index 0000000000000000000000000000000000000000..c6f5e2b5459368ad1e4db9929ca14568
+ } + }
+ +
+ /** + /**
+ * @param kickMessage The message to send to the player on kick if not whitelisted. May set to null to use the server configured default + * @param kickMessage The message to send to the player on kick if not whitelisted. May set to {@code null} to use the server configured default
+ */ + */
+ public void kickMessage(@Nullable Component kickMessage) { + public void kickMessage(@Nullable Component kickMessage) {
+ this.kickMessage = kickMessage; + this.kickMessage = kickMessage;
@ -112,18 +117,18 @@ index 0000000000000000000000000000000000000000..c6f5e2b5459368ad1e4db9929ca14568
+ */ + */
+ @NotNull + @NotNull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
+ return profile; + return this.profile;
+ } + }
+ +
+ /** + /**
+ * @return Whether the player is whitelisted to play on this server (whitelist may be off is why its true) + * @return Whether the player is whitelisted to play on this server (whitelist may be off is why its true)
+ */ + */
+ public boolean isWhitelisted() { + public boolean isWhitelisted() {
+ return whitelisted; + return this.whitelisted;
+ } + }
+ +
+ /** + /**
+ * Changes the players whitelisted state. false will deny the login + * Changes the players whitelisted state. {@code false} will deny the login
+ * @param whitelisted The new whitelisted state + * @param whitelisted The new whitelisted state
+ */ + */
+ public void setWhitelisted(boolean whitelisted) { + public void setWhitelisted(boolean whitelisted) {
@ -134,24 +139,24 @@ index 0000000000000000000000000000000000000000..c6f5e2b5459368ad1e4db9929ca14568
+ * @return if the player obtained whitelist status by having op + * @return if the player obtained whitelist status by having op
+ */ + */
+ public boolean isOp() { + public boolean isOp() {
+ return isOp; + return this.isOp;
+ } + }
+ +
+ /** + /**
+ * @return if the server even has whitelist on + * @return if the server even has whitelist on
+ */ + */
+ public boolean isWhitelistEnabled() { + public boolean isWhitelistEnabled() {
+ return whitelistEnabled; + return this.whitelistEnabled;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Add PlayerJumpEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..289a0d784a3c74caf8a7231b4dd166096b1849a1 index 0000000000000000000000000000000000000000..d3c319298d360967b853cf0168c0a1833f094779
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java
@@ -0,0 +1,106 @@ @@ -0,0 +1,106 @@
@ -18,21 +18,27 @@ index 0000000000000000000000000000000000000000..289a0d784a3c74caf8a7231b4dd16609
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when the server detects the player is jumping. + * Called when the server detects the player is jumping.
+ * <p> + * <p>
+ * Added to avoid the overhead and special case logic that many plugins use + * Added to avoid the overhead and special case logic that many plugins use
+ * when checking for jumps via PlayerMoveEvent, this event is fired whenever + * when checking for jumps via {@link PlayerMoveEvent}, this event is fired whenever
+ * the server detects that the player is jumping. + * the server detects that the player is jumping.
+ */ + */
+public class PlayerJumpEvent extends PlayerEvent implements Cancellable { +public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancel = false;
+ @NotNull private Location from;
+ @NotNull private Location to;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Location to;
+ @NotNull private Location from;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerJumpEvent(@NotNull final Player player, @NotNull final Location from, @NotNull final Location to) { + public PlayerJumpEvent(@NotNull final Player player, @NotNull final Location from, @NotNull final Location to) {
+ super(player); + super(player);
+ this.from = from; + this.from = from;
@ -40,31 +46,29 @@ index 0000000000000000000000000000000000000000..289a0d784a3c74caf8a7231b4dd16609
+ } + }
+ +
+ /** + /**
+ * Gets the cancellation state of this event. A cancelled event will not + * {@inheritDoc}
+ * be executed in the server, but will still pass to other plugins
+ * <p> + * <p>
+ * If a jump event is cancelled, the player will be moved or + * If a jump event is cancelled, the player will be moved or
+ * teleported back to the Location as defined by getFrom(). This will not + * teleported back to the Location as defined by {@link #getFrom()}. This will not
+ * fire an event + * fire an event
+ * + *
+ * @return true if this event is cancelled + * @return {@code true} if this event is cancelled
+ */ + */
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancel; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * Sets the cancellation state of this event. A cancelled event will not + * {@inheritDoc}
+ * be executed in the server, but will still pass to other plugins
+ * <p> + * <p>
+ * If a jump event is cancelled, the player will be moved or + * If a jump event is cancelled, the player will be moved or
+ * teleported back to the Location as defined by getFrom(). This will not + * teleported back to the Location as defined by {@link #getFrom()}. This will not
+ * fire an event + * fire an event
+ * + *
+ * @param cancel true if you wish to cancel this event + * @param cancel {@code true} if you wish to cancel this event
+ */ + */
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancel = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ /** + /**
@ -74,7 +78,7 @@ index 0000000000000000000000000000000000000000..289a0d784a3c74caf8a7231b4dd16609
+ */ + */
+ @NotNull + @NotNull
+ public Location getFrom() { + public Location getFrom() {
+ return from; + return this.from;
+ } + }
+ +
+ /** + /**
@ -83,13 +87,14 @@ index 0000000000000000000000000000000000000000..289a0d784a3c74caf8a7231b4dd16609
+ * @param from New location to mark as the players previous location + * @param from New location to mark as the players previous location
+ */ + */
+ public void setFrom(@NotNull Location from) { + public void setFrom(@NotNull Location from) {
+ validateLocation(from); + Preconditions.checkArgument(from != null, "Cannot use null from location!");
+ Preconditions.checkArgument(from.getWorld() != null, "Cannot use from location with null world!");
+ this.from = from; + this.from = from;
+ } + }
+ +
+ /** + /**
+ * Gets the location this player jumped to + * Gets the location this player jumped to
+ * + * <p>
+ * This information is based on what the client sends, it typically + * This information is based on what the client sends, it typically
+ * has little relation to the arc of the jump at any given point. + * has little relation to the arc of the jump at any given point.
+ * + *
@ -97,22 +102,17 @@ index 0000000000000000000000000000000000000000..289a0d784a3c74caf8a7231b4dd16609
+ */ + */
+ @NotNull + @NotNull
+ public Location getTo() { + public Location getTo() {
+ return to; + return this.to;
+ }
+
+ private void validateLocation(Location loc) {
+ Preconditions.checkArgument(loc != null, "Cannot use null location!");
+ Preconditions.checkArgument(loc.getWorld() != null, "Cannot use location with null world!");
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerArmorChangeEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..57521010ff0574f1bbc96727948a6185fd37e9ee index 0000000000000000000000000000000000000000..ab08219497f7e362f113321c4bcfd180b335bf20
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerArmorChangeEvent.java
@@ -0,0 +1,139 @@ @@ -0,0 +1,127 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.Material; +import org.bukkit.Material;
@ -18,9 +18,6 @@ index 0000000000000000000000000000000000000000..57521010ff0574f1bbc96727948a6185
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+ +
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set; +import java.util.Set;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
@ -34,7 +31,8 @@ index 0000000000000000000000000000000000000000..57521010ff0574f1bbc96727948a6185
+ * Not currently called for environmental factors though it <strong>MAY BE IN THE FUTURE</strong> + * Not currently called for environmental factors though it <strong>MAY BE IN THE FUTURE</strong>
+ */ + */
+public class PlayerArmorChangeEvent extends PlayerEvent { +public class PlayerArmorChangeEvent extends PlayerEvent {
+ private static final HandlerList HANDLERS = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final SlotType slotType; + @NotNull private final SlotType slotType;
+ @NotNull private final ItemStack oldItem; + @NotNull private final ItemStack oldItem;
@ -78,20 +76,15 @@ index 0000000000000000000000000000000000000000..57521010ff0574f1bbc96727948a6185
+ return this.newItem; + return this.newItem;
+ } + }
+ +
+ @Override
+ public String toString() {
+ return "ArmorChangeEvent{" + "player=" + player + ", slotType=" + slotType + ", oldItem=" + oldItem + ", newItem=" + newItem + '}';
+ }
+
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+ +
+ public enum SlotType { + public enum SlotType {
@ -100,11 +93,10 @@ index 0000000000000000000000000000000000000000..57521010ff0574f1bbc96727948a6185
+ LEGS(NETHERITE_LEGGINGS, DIAMOND_LEGGINGS, GOLDEN_LEGGINGS, IRON_LEGGINGS, CHAINMAIL_LEGGINGS, LEATHER_LEGGINGS), + LEGS(NETHERITE_LEGGINGS, DIAMOND_LEGGINGS, GOLDEN_LEGGINGS, IRON_LEGGINGS, CHAINMAIL_LEGGINGS, LEATHER_LEGGINGS),
+ FEET(NETHERITE_BOOTS, DIAMOND_BOOTS, GOLDEN_BOOTS, IRON_BOOTS, CHAINMAIL_BOOTS, LEATHER_BOOTS); + FEET(NETHERITE_BOOTS, DIAMOND_BOOTS, GOLDEN_BOOTS, IRON_BOOTS, CHAINMAIL_BOOTS, LEATHER_BOOTS);
+ +
+ private final Set<Material> mutableTypes = new HashSet<>(); + private final Set<Material> types;
+ private Set<Material> immutableTypes;
+ +
+ SlotType(Material... types) { + SlotType(Material... types) {
+ this.mutableTypes.addAll(Arrays.asList(types)); + this.types = Set.of(types);
+ } + }
+ +
+ /** + /**
@ -115,18 +107,14 @@ index 0000000000000000000000000000000000000000..57521010ff0574f1bbc96727948a6185
+ */ + */
+ @NotNull + @NotNull
+ public Set<Material> getTypes() { + public Set<Material> getTypes() {
+ if (immutableTypes == null) { + return this.types;
+ immutableTypes = Collections.unmodifiableSet(mutableTypes);
+ }
+
+ return immutableTypes;
+ } + }
+ +
+ /** + /**
+ * Gets the type of slot via the specified material + * Gets the type of slot via the specified material
+ * + *
+ * @param material material to get slot by + * @param material material to get slot by
+ * @return slot type the material will go in, or null if it won't + * @return slot type the material will go in, or {@code null} if it won't
+ */ + */
+ @Nullable + @Nullable
+ public static SlotType getByMaterial(@NotNull Material material) { + public static SlotType getByMaterial(@NotNull Material material) {

Datei anzeigen

@ -15,10 +15,10 @@ Co-authored-by: Aikar <aikar@aikar.co>
diff --git a/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077dedadcef9f5d index 0000000000000000000000000000000000000000..e0847b6f0202bd8267c537f72a5e8c8cb7c6b1db
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/AsyncTabCompleteEvent.java
@@ -0,0 +1,328 @@ @@ -0,0 +1,339 @@
+/* +/*
+ * Copyright (c) 2017 Daniel Ennis (Aikar) MIT License + * Copyright (c) 2017 Daniel Ennis (Aikar) MIT License
+ * + *
@ -59,47 +59,57 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ +
+import java.util.ArrayList; +import java.util.ArrayList;
+import java.util.List; +import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream; +import java.util.stream.Stream;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Allows plugins to compute tab completion results asynchronously. If this event provides completions, then the standard synchronous process will not be fired to populate the results. However, the synchronous TabCompleteEvent will fire with the Async results. + * Allows plugins to compute tab completion results asynchronously.
+ * + * <p>
+ * If this event provides completions, then the standard synchronous process
+ * will not be fired to populate the results.
+ * However, the synchronous TabCompleteEvent will fire with the Async results.
+ * <p>
+ * Only 1 process will be allowed to provide completions, the Async Event, or the standard process. + * Only 1 process will be allowed to provide completions, the Async Event, or the standard process.
+ */ + */
+public class AsyncTabCompleteEvent extends Event implements Cancellable { +public class AsyncTabCompleteEvent extends Event implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final CommandSender sender; + @NotNull private final CommandSender sender;
+ @NotNull private final String buffer; + @NotNull private final String buffer;
+ private final boolean isCommand; + private final boolean isCommand;
+ @Nullable + @Nullable
+ private final Location loc; + private final Location location;
+ private final List<Completion> completions = new ArrayList<>(); + private final List<Completion> completions = new ArrayList<>();
+ private final List<String> stringCompletions = new TransformingRandomAccessList<>( + private final List<String> stringCompletions = new TransformingRandomAccessList<>(
+ this.completions, + this.completions,
+ Completion::suggestion, + Completion::suggestion,
+ Completion::completion + Completion::completion
+ ); + );
+ private boolean handled;
+ private boolean cancelled; + private boolean cancelled;
+ private boolean handled = false;
+ private boolean fireSyncHandler = true;
+ +
+ @ApiStatus.Internal
+ public AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, boolean isCommand, @Nullable Location loc) { + public AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, boolean isCommand, @Nullable Location loc) {
+ super(true); + super(true);
+ this.sender = sender; + this.sender = sender;
+ this.buffer = buffer; + this.buffer = buffer;
+ this.isCommand = isCommand; + this.isCommand = isCommand;
+ this.loc = loc; + this.location = loc;
+ } + }
+ +
+ @Deprecated + @Deprecated
+ @ApiStatus.Internal
+ public AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull List<String> completions, @NotNull String buffer, boolean isCommand, @Nullable Location loc) { + public AsyncTabCompleteEvent(@NotNull CommandSender sender, @NotNull List<String> completions, @NotNull String buffer, boolean isCommand, @Nullable Location loc) {
+ super(true); + super(true);
+ this.sender = sender; + this.sender = sender;
+ this.completions.addAll(fromStrings(completions)); + this.completions.addAll(fromStrings(completions));
+ this.buffer = buffer; + this.buffer = buffer;
+ this.isCommand = isCommand; + this.isCommand = isCommand;
+ this.loc = loc; + this.location = loc;
+ } + }
+ +
+ /** + /**
@ -109,13 +119,13 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ */ + */
+ @NotNull + @NotNull
+ public CommandSender getSender() { + public CommandSender getSender() {
+ return sender; + return this.sender;
+ } + }
+ +
+ /** + /**
+ * The list of completions which will be offered to the sender, in order. + * The list of completions which will be offered to the sender, in order.
+ * This list is mutable and reflects what will be offered. + * This list is mutable and reflects what will be offered.
+ * + * <p>
+ * If this collection is not empty after the event is fired, then + * If this collection is not empty after the event is fired, then
+ * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])}
+ * or current player names will not be called. + * or current player names will not be called.
@ -132,16 +142,16 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ * If this collection is not empty after the event is fired, then + * If this collection is not empty after the event is fired, then
+ * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])}
+ * or current player names will not be called. + * or current player names will not be called.
+ * + * <p>
+ * The passed collection will be cloned to a new List. You must call {{@link #getCompletions()}} to mutate from here + * The passed collection will be cloned to a new {@code List}. You must call {{@link #getCompletions()}} to mutate from here
+ * + *
+ * @param completions the new completions + * @param completions the new completions
+ */ + */
+ public void setCompletions(@NotNull List<String> completions) { + public void setCompletions(@NotNull List<String> completions) {
+ Preconditions.checkArgument(completions != null, "Completions list cannot be null");
+ if (completions == this.stringCompletions) { + if (completions == this.stringCompletions) {
+ return; + return;
+ } + }
+ Preconditions.checkNotNull(completions);
+ this.completions.clear(); + this.completions.clear();
+ this.completions.addAll(fromStrings(completions)); + this.completions.addAll(fromStrings(completions));
+ } + }
@ -166,12 +176,12 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])}
+ * or current player names will not be called. + * or current player names will not be called.
+ * <p> + * <p>
+ * The passed collection will be cloned to a new List. You must call {{@link #completions()}} to mutate from here + * The passed collection will be cloned to a new {@code List}. You must call {@link #completions()} to mutate from here
+ * + *
+ * @param newCompletions the new completions + * @param newCompletions the new completions
+ */ + */
+ public void completions(final @NotNull List<Completion> newCompletions) { + public void completions(final @NotNull List<Completion> newCompletions) {
+ Preconditions.checkNotNull(newCompletions, "new completions"); + Preconditions.checkArgument(newCompletions != null, "new completions cannot be null");
+ this.completions.clear(); + this.completions.clear();
+ this.completions.addAll(newCompletions); + this.completions.addAll(newCompletions);
+ } + }
@ -183,37 +193,37 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ */ + */
+ @NotNull + @NotNull
+ public String getBuffer() { + public String getBuffer() {
+ return buffer; + return this.buffer;
+ } + }
+ +
+ /** + /**
+ * @return True if it is a command being tab completed, false if it is a chat message. + * @return {@code true} if it is a command being tab completed, {@code false} if it is a chat message.
+ */ + */
+ public boolean isCommand() { + public boolean isCommand() {
+ return isCommand; + return this.isCommand;
+ } + }
+ +
+ /** + /**
+ * @return The position looked at by the sender, or null if none + * @return The position looked at by the sender, or {@code null} if none
+ */ + */
+ @Nullable + @Nullable
+ public Location getLocation() { + public Location getLocation() {
+ return loc; + return this.location;
+ } + }
+ +
+ /** + /**
+ * If true, the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * If {@code true}, the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])}
+ * or current player names will not be called. + * or current player names will not be called.
+ * + *
+ * @return Is completions considered handled. Always true if completions is not empty. + * @return Is completions considered handled. Always {@code true} if completions is not empty.
+ */ + */
+ public boolean isHandled() { + public boolean isHandled() {
+ return !completions.isEmpty() || handled; + return !this.completions.isEmpty() || this.handled;
+ } + }
+ +
+ /** + /**
+ * Sets whether or not to consider the completion request handled. + * Sets whether to consider the completion request handled.
+ * If true, the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])} + * If {@code true}, the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])}
+ * or current player names will not be called. + * or current player names will not be called.
+ * + *
+ * @param handled if this completion should be marked as being handled + * @param handled if this completion should be marked as being handled
@ -222,37 +232,35 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ this.handled = handled; + this.handled = handled;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * {@inheritDoc}
+ * <br>
+ * Will provide no completions, and will not fire the synchronous process + * Will provide no completions, and will not fire the synchronous process
+ * @param cancelled true if you wish to cancel this event
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancelled) { + public void setCancelled(boolean cancel) {
+ this.cancelled = cancelled; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ private static @NotNull List<Completion> fromStrings(final @NotNull List<String> strings) { + private static @NotNull List<Completion> fromStrings(final @NotNull List<String> suggestions) {
+ final List<Completion> list = new ArrayList<>(); + final List<Completion> list = new ArrayList<>(suggestions.size());
+ for (final String it : strings) { + for (final String suggestion : suggestions) {
+ list.add(new CompletionImpl(it, null)); + list.add(new CompletionImpl(suggestion, null));
+ } + }
+ return list; + return list;
+ } + }
@ -261,6 +269,7 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ * A rich tab completion, consisting of a string suggestion, and a nullable {@link Component} tooltip. + * A rich tab completion, consisting of a string suggestion, and a nullable {@link Component} tooltip.
+ */ + */
+ public interface Completion extends Examinable { + public interface Completion extends Examinable {
+
+ /** + /**
+ * Get the suggestion string for this {@link Completion}. + * Get the suggestion string for this {@link Completion}.
+ * + *
@ -292,11 +301,11 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ +
+ /** + /**
+ * Create a new {@link Completion} from a suggestion string and a tooltip {@link Component}. + * Create a new {@link Completion} from a suggestion string and a tooltip {@link Component}.
+ * + * <p>
+ * <p>If the provided component is null, the suggestion will not have a tooltip.</p> + * If the provided component is {@code null}, the suggestion will not have a tooltip.
+ * + *
+ * @param suggestion suggestion string + * @param suggestion suggestion string
+ * @param tooltip tooltip component, or null + * @param tooltip tooltip component, or {@code null}
+ * @return new completion instance + * @return new completion instance
+ */ + */
+ static @NotNull Completion completion(final @NotNull String suggestion, final @Nullable Component tooltip) { + static @NotNull Completion completion(final @NotNull String suggestion, final @Nullable Component tooltip) {
@ -304,7 +313,9 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ } + }
+ } + }
+ +
+ @ApiStatus.Internal
+ static final class CompletionImpl implements Completion { + static final class CompletionImpl implements Completion {
+
+ private final String suggestion; + private final String suggestion;
+ private final Component tooltip; + private final Component tooltip;
+ +
@ -333,12 +344,12 @@ index 0000000000000000000000000000000000000000..9be64a95c2345433b6142d611077deda
+ } + }
+ final CompletionImpl that = (CompletionImpl) o; + final CompletionImpl that = (CompletionImpl) o;
+ return this.suggestion.equals(that.suggestion) + return this.suggestion.equals(that.suggestion)
+ && java.util.Objects.equals(this.tooltip, that.tooltip); + && Objects.equals(this.tooltip, that.tooltip);
+ } + }
+ +
+ @Override + @Override
+ public int hashCode() { + public int hashCode() {
+ return java.util.Objects.hash(this.suggestion, this.tooltip); + return Objects.hash(this.suggestion, this.tooltip);
+ } + }
+ +
+ @Override + @Override

Datei anzeigen

@ -7,10 +7,10 @@ Allows plugins to cancel a player picking up an experience orb
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerPickupExperienceEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerPickupExperienceEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerPickupExperienceEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerPickupExperienceEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..f7beb22d5105157940b39efe594ace9d4cb153f5 index 0000000000000000000000000000000000000000..0ef10ac6bac990837e21520c800d89420a18e3d4
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerPickupExperienceEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerPickupExperienceEvent.java
@@ -0,0 +1,80 @@ @@ -0,0 +1,83 @@
+/* +/*
+ * Copyright (c) 2017 Daniel Ennis (Aikar) MIT License + * Copyright (c) 2017 Daniel Ennis (Aikar) MIT License
+ * + *
@ -39,17 +39,22 @@ index 0000000000000000000000000000000000000000..f7beb22d5105157940b39efe594ace9d
+import org.bukkit.entity.ExperienceOrb; +import org.bukkit.entity.ExperienceOrb;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when a player is attempting to pick up an experience orb + * Fired when a player is attempting to pick up an experience orb
+ */ + */
+public class PlayerPickupExperienceEvent extends PlayerEvent implements Cancellable { +public class PlayerPickupExperienceEvent extends PlayerEvent implements Cancellable {
+ @NotNull private final ExperienceOrb experienceOrb;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final ExperienceOrb experienceOrb;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerPickupExperienceEvent(@NotNull Player player, @NotNull ExperienceOrb experienceOrb) { + public PlayerPickupExperienceEvent(@NotNull Player player, @NotNull ExperienceOrb experienceOrb) {
+ super(player); + super(player);
+ this.experienceOrb = experienceOrb; + this.experienceOrb = experienceOrb;
@ -60,34 +65,32 @@ index 0000000000000000000000000000000000000000..f7beb22d5105157940b39efe594ace9d
+ */ + */
+ @NotNull + @NotNull
+ public ExperienceOrb getExperienceOrb() { + public ExperienceOrb getExperienceOrb() {
+ return experienceOrb; + return this.experienceOrb;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList(); + @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <br>
+ * If {@code true}, cancels picking up the experience orb, leaving it in the world
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+ +
+ @NotNull + @NotNull
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ }
+
+ private boolean cancelled = false;
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ /**
+ * If true, Cancels picking up the experience orb, leaving it in the world
+ * @param cancel true if you wish to cancel this event
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ } + }
+} +}

Datei anzeigen

@ -9,10 +9,10 @@ metadata such as spawn reason, or conditionally move data from source to target.
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ExperienceOrbMergeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ExperienceOrbMergeEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ExperienceOrbMergeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ExperienceOrbMergeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..0ce3e397716c28c30ed05e153babd0bfb9dd354a index 0000000000000000000000000000000000000000..c520e5517861c4686806df233d1ef5e6bfb76ad3
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/ExperienceOrbMergeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/ExperienceOrbMergeEvent.java
@@ -0,0 +1,87 @@ @@ -0,0 +1,91 @@
+/* +/*
+ * Copyright (c) 2017 Daniel Ennis (Aikar) MIT License + * Copyright (c) 2017 Daniel Ennis (Aikar) MIT License
+ * + *
@ -42,15 +42,22 @@ index 0000000000000000000000000000000000000000..0ce3e397716c28c30ed05e153babd0bf
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired anytime the server is about to merge 2 experience orbs into one + * Fired anytime the server is about to merge 2 experience orbs into one
+ */ + */
+public class ExperienceOrbMergeEvent extends EntityEvent implements Cancellable { +public class ExperienceOrbMergeEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final ExperienceOrb mergeTarget; + @NotNull private final ExperienceOrb mergeTarget;
+ @NotNull private final ExperienceOrb mergeSource; + @NotNull private final ExperienceOrb mergeSource;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public ExperienceOrbMergeEvent(@NotNull ExperienceOrb mergeTarget, @NotNull ExperienceOrb mergeSource) { + public ExperienceOrbMergeEvent(@NotNull ExperienceOrb mergeTarget, @NotNull ExperienceOrb mergeSource) {
+ super(mergeTarget); + super(mergeTarget);
+ this.mergeTarget = mergeTarget; + this.mergeTarget = mergeTarget;
@ -62,7 +69,7 @@ index 0000000000000000000000000000000000000000..0ce3e397716c28c30ed05e153babd0bf
+ */ + */
+ @NotNull + @NotNull
+ public ExperienceOrb getMergeTarget() { + public ExperienceOrb getMergeTarget() {
+ return mergeTarget; + return this.mergeTarget;
+ } + }
+ +
+ /** + /**
@ -70,33 +77,30 @@ index 0000000000000000000000000000000000000000..0ce3e397716c28c30ed05e153babd0bf
+ */ + */
+ @NotNull + @NotNull
+ public ExperienceOrb getMergeSource() { + public ExperienceOrb getMergeSource() {
+ return mergeSource; + return this.mergeSource;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList(); + @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ /**
+ * @param cancel {@code true} if you wish to cancel this event, and prevent the orbs from merging
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+ +
+ @NotNull + @NotNull
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ }
+
+ private boolean cancelled = false;
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ /**
+ * @param cancel true if you wish to cancel this event, and prevent the orbs from merging
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ } + }
+} +}

Datei anzeigen

@ -16,41 +16,47 @@ See: https://github.com/PaperMC/Paper/issues/917
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PreCreatureSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PreCreatureSpawnEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PreCreatureSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PreCreatureSpawnEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..8b48759bf6f4fcef0847d9a2461993e3f2fdc9aa index 0000000000000000000000000000000000000000..1d582118f19a41b499ee73b5e27ddb66ed34f06b
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/PreCreatureSpawnEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/PreCreatureSpawnEvent.java
@@ -0,0 +1,105 @@ @@ -0,0 +1,109 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import com.google.common.base.Preconditions;
+import org.bukkit.Location; +import org.bukkit.Location;
+import org.bukkit.entity.EntityType; +import org.bukkit.entity.EntityType;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * WARNING: This event only fires for a limited number of cases, and not for every case that CreatureSpawnEvent does. + * WARNING: This event only fires for a limited number of cases, and not for every case that {@link CreatureSpawnEvent} does.
+ * + * <p>
+ * You should still listen to CreatureSpawnEvent as a backup, and only use this event as an "enhancement". + * You should still listen to {@link CreatureSpawnEvent} as a backup, and only use this event as an "enhancement".
+ * The intent of this event is to improve server performance, so it fires even if the spawning might fail later, for + * The intent of this event is to improve server performance, so it fires even if the spawning might fail later, for
+ * example when the entity would be unable to spawn due to limited space or lighting. + * example when the entity would be unable to spawn due to limited space or lighting.
+ * + * <p>
+ * Currently: NATURAL and SPAWNER based reasons. Please submit a Pull Request for future additions. + * Currently: NATURAL and SPAWNER based reasons. <!-- Please submit a Pull Request for future additions. -->
+ * Also, Plugins that replace Entity Registrations with their own custom entities might not fire this event. + * Also, Plugins that replace Entity Registrations with their own custom entities might not fire this event.
+ */ + */
+public class PreCreatureSpawnEvent extends Event implements Cancellable { +public class PreCreatureSpawnEvent extends Event implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Location location; + @NotNull private final Location location;
+ @NotNull private final EntityType type; + @NotNull private final EntityType type;
+ @NotNull private final CreatureSpawnEvent.SpawnReason reason; + @NotNull private final CreatureSpawnEvent.SpawnReason reason;
+ private boolean shouldAbortSpawn; + private boolean shouldAbortSpawn;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PreCreatureSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull CreatureSpawnEvent.SpawnReason reason) { + public PreCreatureSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull CreatureSpawnEvent.SpawnReason reason) {
+ this.location = Preconditions.checkNotNull(location, "Location may not be null"); + this.location = location;
+ this.type = Preconditions.checkNotNull(type, "Type may not be null"); + this.type = type;
+ this.reason = Preconditions.checkNotNull(reason, "Reason may not be null"); + this.reason = reason;
+ } + }
+ +
+ /** + /**
@ -58,7 +64,7 @@ index 0000000000000000000000000000000000000000..8b48759bf6f4fcef0847d9a2461993e3
+ */ + */
+ @NotNull + @NotNull
+ public Location getSpawnLocation() { + public Location getSpawnLocation() {
+ return location; + return this.location;
+ } + }
+ +
+ /** + /**
@ -66,7 +72,7 @@ index 0000000000000000000000000000000000000000..8b48759bf6f4fcef0847d9a2461993e3
+ */ + */
+ @NotNull + @NotNull
+ public EntityType getType() { + public EntityType getType() {
+ return type; + return this.type;
+ } + }
+ +
+ /** + /**
@ -74,14 +80,14 @@ index 0000000000000000000000000000000000000000..8b48759bf6f4fcef0847d9a2461993e3
+ */ + */
+ @NotNull + @NotNull
+ public CreatureSpawnEvent.SpawnReason getReason() { + public CreatureSpawnEvent.SpawnReason getReason() {
+ return reason; + return this.reason;
+ } + }
+ +
+ /** + /**
+ * @return If the spawn process should be aborted vs trying more attempts + * @return If the spawn process should be aborted vs trying more attempts
+ */ + */
+ public boolean shouldAbortSpawn() { + public boolean shouldAbortSpawn() {
+ return shouldAbortSpawn; + return this.shouldAbortSpawn;
+ } + }
+ +
+ /** + /**
@ -94,34 +100,32 @@ index 0000000000000000000000000000000000000000..8b48759bf6f4fcef0847d9a2461993e3
+ this.shouldAbortSpawn = shouldAbortSpawn; + this.shouldAbortSpawn = shouldAbortSpawn;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ /** + /**
+ * @return If the spawn of this creature is cancelled or not + * @return If the spawn of this creature is cancelled or not
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * Cancelling this event is more efficient than cancelling CreatureSpawnEvent + * Cancelling this event is more efficient than cancelling {@link CreatureSpawnEvent}
+ * @param cancel true if you wish to cancel this event, and abort the spawn of this creature + *
+ * @param cancel {@code true} if you wish to cancel this event, and abort the spawn of this creature
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -10,25 +10,30 @@ Also a highly more effecient way to blanket block spawns in a world
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PlayerNaturallySpawnCreaturesEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PlayerNaturallySpawnCreaturesEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PlayerNaturallySpawnCreaturesEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PlayerNaturallySpawnCreaturesEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..112a0dbf522b8e74ce882678434923814e6b187f index 0000000000000000000000000000000000000000..7fcee73d61347165cefef7b92f0e63e0bed8ad73
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/PlayerNaturallySpawnCreaturesEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/PlayerNaturallySpawnCreaturesEvent.java
@@ -0,0 +1,64 @@ @@ -0,0 +1,66 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when the server is calculating what chunks to try to spawn monsters in every Monster Spawn Tick event + * Fired when the server is calculating what chunks to try to spawn monsters in every Monster Spawn Tick event
+ */ + */
+public class PlayerNaturallySpawnCreaturesEvent extends PlayerEvent implements Cancellable { +public class PlayerNaturallySpawnCreaturesEvent extends PlayerEvent implements Cancellable {
+ private byte radius;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private byte radius;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerNaturallySpawnCreaturesEvent(@NotNull Player player, byte radius) { + public PlayerNaturallySpawnCreaturesEvent(@NotNull Player player, byte radius) {
+ super(player); + super(player);
+ this.radius = radius; + this.radius = radius;
@ -38,7 +43,7 @@ index 0000000000000000000000000000000000000000..112a0dbf522b8e74ce88267843492381
+ * @return The radius of chunks around this player to be included in natural spawn selection + * @return The radius of chunks around this player to be included in natural spawn selection
+ */ + */
+ public byte getSpawnRadius() { + public byte getSpawnRadius() {
+ return radius; + return this.radius;
+ } + }
+ +
+ /** + /**
@ -48,33 +53,30 @@ index 0000000000000000000000000000000000000000..112a0dbf522b8e74ce88267843492381
+ this.radius = radius; + this.radius = radius;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ /** + /**
+ * @return If this players chunks will be excluded from natural spawns + * @return If this players chunks will be excluded from natural spawns
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * @param cancel true if you wish to cancel this event, and not include this players chunks for natural spawning + * @param cancel {@code true} if you wish to cancel this event, and not include this players chunks for natural spawning
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -7,10 +7,10 @@ Co-authored-by: The456gamer <the456gamer@the456gamer.dev>
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerAdvancementCriterionGrantEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerAdvancementCriterionGrantEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerAdvancementCriterionGrantEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerAdvancementCriterionGrantEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..99dac77befbf7c0c067f50150e62fe6d6ddaec7c index 0000000000000000000000000000000000000000..9502f94b3567fc22c4b61fea5aa251d738dde7ae
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerAdvancementCriterionGrantEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerAdvancementCriterionGrantEvent.java
@@ -0,0 +1,78 @@ @@ -0,0 +1,84 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.advancement.Advancement; +import org.bukkit.advancement.Advancement;
@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..99dac77befbf7c0c067f50150e62fe6d
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -26,17 +27,21 @@ index 0000000000000000000000000000000000000000..99dac77befbf7c0c067f50150e62fe6d
+ * If cancelled the criteria will be revoked. + * If cancelled the criteria will be revoked.
+ */ + */
+public class PlayerAdvancementCriterionGrantEvent extends PlayerEvent implements Cancellable { +public class PlayerAdvancementCriterionGrantEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Advancement advancement; + @NotNull private final Advancement advancement;
+ @NotNull private final String criterion; + @NotNull private final String criterion;
+ @NotNull private final AdvancementProgress advancementProgress; + @NotNull private final AdvancementProgress advancementProgress;
+ private boolean cancel = false;
+ +
+ public PlayerAdvancementCriterionGrantEvent(@NotNull Player who, @NotNull Advancement advancement, @NotNull String criterion) { + private boolean cancelled;
+ super(who); +
+ @ApiStatus.Internal
+ public PlayerAdvancementCriterionGrantEvent(@NotNull Player player, @NotNull Advancement advancement, @NotNull String criterion) {
+ super(player);
+ this.advancement = advancement; + this.advancement = advancement;
+ this.criterion = criterion; + this.criterion = criterion;
+ this.advancementProgress = who.getAdvancementProgress(advancement); + this.advancementProgress = player.getAdvancementProgress(advancement);
+ } + }
+ +
+ /** + /**
@ -46,7 +51,7 @@ index 0000000000000000000000000000000000000000..99dac77befbf7c0c067f50150e62fe6d
+ */ + */
+ @NotNull + @NotNull
+ public Advancement getAdvancement() { + public Advancement getAdvancement() {
+ return advancement; + return this.advancement;
+ } + }
+ +
+ /** + /**
@ -56,36 +61,37 @@ index 0000000000000000000000000000000000000000..99dac77befbf7c0c067f50150e62fe6d
+ */ + */
+ @NotNull + @NotNull
+ public String getCriterion() { + public String getCriterion() {
+ return criterion; + return this.criterion;
+ }
+
+ public boolean isCancelled() {
+ return cancel;
+ } + }
+ +
+ /** + /**
+ * Gets the current AdvancementProgress. + * Gets the current AdvancementProgress.
+ * See {@link PlayerAdvancementCriterionGrantEvent}
+ * + *
+ * @return advancement progress + * @return advancement progress
+ */ + */
+ @NotNull + @NotNull
+ public AdvancementProgress getAdvancementProgress() { + public AdvancementProgress getAdvancementProgress() {
+ return advancementProgress; + return this.advancementProgress;
+ } + }
+ +
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancel = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -12,10 +12,10 @@ This is useful for implementing a ProfileCache for Player Skulls
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/FillProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/FillProfileEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/profile/FillProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/FillProfileEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..71f36e9cae209ec6861835a5e76e018de959040a index 0000000000000000000000000000000000000000..c97ded9f9ef1c550cca7d0a3a3b09a85e5999cdf
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/profile/FillProfileEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/FillProfileEvent.java
@@ -0,0 +1,75 @@ @@ -0,0 +1,79 @@
+/* +/*
+ * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License + * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
+ * + *
@ -47,14 +47,19 @@ index 0000000000000000000000000000000000000000..71f36e9cae209ec6861835a5e76e018d
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+ +
+import java.util.Set; +import java.util.Set;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired once a profiles additional properties (such as textures) has been filled + * Fired once a profiles additional properties (such as textures) has been filled
+ */ + */
+public class FillProfileEvent extends Event { +public class FillProfileEvent extends Event {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final PlayerProfile profile; + @NotNull private final PlayerProfile profile;
+ +
+ @ApiStatus.Internal
+ public FillProfileEvent(@NotNull PlayerProfile profile) { + public FillProfileEvent(@NotNull PlayerProfile profile) {
+ super(!org.bukkit.Bukkit.isPrimaryThread()); + super(!org.bukkit.Bukkit.isPrimaryThread());
+ this.profile = profile; + this.profile = profile;
@ -65,7 +70,7 @@ index 0000000000000000000000000000000000000000..71f36e9cae209ec6861835a5e76e018d
+ */ + */
+ @NotNull + @NotNull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
+ return profile; + return this.profile;
+ } + }
+ +
+ /** + /**
@ -76,27 +81,26 @@ index 0000000000000000000000000000000000000000..71f36e9cae209ec6861835a5e76e018d
+ */ + */
+ @NotNull + @NotNull
+ public Set<ProfileProperty> getProperties() { + public Set<ProfileProperty> getProperties() {
+ return profile.getProperties(); + return this.profile.getProperties();
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull + @NotNull
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/PreFillProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/PreFillProfileEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/profile/PreFillProfileEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/PreFillProfileEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..021bc86310a06f84b39459e0eb8927802726399c index 0000000000000000000000000000000000000000..e2a47c4af2c368a361e4a370a01111abe8e48062
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/profile/PreFillProfileEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/PreFillProfileEvent.java
@@ -0,0 +1,77 @@ @@ -0,0 +1,81 @@
+/* +/*
+ * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License + * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
+ * + *
@ -128,16 +132,21 @@ index 0000000000000000000000000000000000000000..021bc86310a06f84b39459e0eb892780
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+ +
+import java.util.Collection; +import java.util.Collection;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when the server is requesting to fill in properties of an incomplete profile, such as textures. + * Fired when the server is requesting to fill in properties of an incomplete profile, such as textures.
+ * + * <p>
+ * Allows plugins to pre populate cached properties and avoid a call to the Mojang API + * Allows plugins to pre-populate cached properties and avoid a call to the Mojang API
+ */ + */
+public class PreFillProfileEvent extends Event { +public class PreFillProfileEvent extends Event {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final PlayerProfile profile; + @NotNull private final PlayerProfile profile;
+ +
+ @ApiStatus.Internal
+ public PreFillProfileEvent(@NotNull PlayerProfile profile) { + public PreFillProfileEvent(@NotNull PlayerProfile profile) {
+ super(!org.bukkit.Bukkit.isPrimaryThread()); + super(!org.bukkit.Bukkit.isPrimaryThread());
+ this.profile = profile; + this.profile = profile;
@ -148,7 +157,7 @@ index 0000000000000000000000000000000000000000..021bc86310a06f84b39459e0eb892780
+ */ + */
+ @NotNull + @NotNull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
+ return profile; + return this.profile;
+ } + }
+ +
+ /** + /**
@ -159,18 +168,17 @@ index 0000000000000000000000000000000000000000..021bc86310a06f84b39459e0eb892780
+ * @param properties The properties to set/append + * @param properties The properties to set/append
+ */ + */
+ public void setProperties(@NotNull Collection<ProfileProperty> properties) { + public void setProperties(@NotNull Collection<ProfileProperty> properties) {
+ profile.setProperties(properties); + this.profile.setProperties(properties);
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull + @NotNull
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -7,20 +7,19 @@ Co-authored-by: Connor Linfoot <connorlinfoot@me.com>
Co-authored-by: MCMDEV <john-m.1@gmx.de> Co-authored-by: MCMDEV <john-m.1@gmx.de>
diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
index 3432872303aa0df97b5d9090fe98b269ef3cb9f4..f8b69b52ec8efa103e4e78e1b5c6a015e73d2a75 100644 index 3432872303aa0df97b5d9090fe98b269ef3cb9f4..bdb7d2345e7d3a48a2f0561832ce126a16781e89 100644
--- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java --- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
+++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
@@ -2,6 +2,9 @@ package org.bukkit.event.player; @@ -2,6 +2,8 @@ package org.bukkit.event.player;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.UUID; import java.util.UUID;
+
+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile;
+import org.bukkit.Bukkit; +import org.bukkit.Bukkit;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -22,9 +25,10 @@ public class AsyncPlayerPreLoginEvent extends Event { @@ -22,9 +24,10 @@ public class AsyncPlayerPreLoginEvent extends Event {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private Result result; private Result result;
private net.kyori.adventure.text.Component message; // Paper private net.kyori.adventure.text.Component message; // Paper
@ -33,7 +32,7 @@ index 3432872303aa0df97b5d9090fe98b269ef3cb9f4..f8b69b52ec8efa103e4e78e1b5c6a015
@Deprecated @Deprecated
public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress) { public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress) {
@@ -32,12 +36,29 @@ public class AsyncPlayerPreLoginEvent extends Event { @@ -32,12 +35,29 @@ public class AsyncPlayerPreLoginEvent extends Event {
} }
public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) { public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) {
@ -65,7 +64,7 @@ index 3432872303aa0df97b5d9090fe98b269ef3cb9f4..f8b69b52ec8efa103e4e78e1b5c6a015
} }
/** /**
@@ -200,7 +221,7 @@ public class AsyncPlayerPreLoginEvent extends Event { @@ -200,7 +220,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
*/ */
@NotNull @NotNull
public String getName() { public String getName() {
@ -74,14 +73,14 @@ index 3432872303aa0df97b5d9090fe98b269ef3cb9f4..f8b69b52ec8efa103e4e78e1b5c6a015
} }
/** /**
@@ -220,9 +241,48 @@ public class AsyncPlayerPreLoginEvent extends Event { @@ -220,9 +240,48 @@ public class AsyncPlayerPreLoginEvent extends Event {
*/ */
@NotNull @NotNull
public UUID getUniqueId() { public UUID getUniqueId() {
- return uniqueId; - return uniqueId;
+ return profile.getId(); // Paper + return profile.getId(); // Paper
} + }
+
+ // Paper start + // Paper start
+ /** + /**
+ * Gets the PlayerProfile of the player logging in + * Gets the PlayerProfile of the player logging in
@ -107,8 +106,8 @@ index 3432872303aa0df97b5d9090fe98b269ef3cb9f4..f8b69b52ec8efa103e4e78e1b5c6a015
+ @NotNull + @NotNull
+ public InetAddress getRawAddress() { + public InetAddress getRawAddress() {
+ return rawAddress; + return rawAddress;
+ } }
+
+ /** + /**
+ * Gets the hostname that the player used to connect to the server, or + * Gets the hostname that the player used to connect to the server, or
+ * blank if unknown + * blank if unknown

Datei anzeigen

@ -8,10 +8,10 @@ and allows full control of the response sent to the client.
diff --git a/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96ec5b3b9dc index 0000000000000000000000000000000000000000..0bb6fdbdd05ae6a8fb413e0f6b8d84302d697267
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java
@@ -0,0 +1,334 @@ @@ -0,0 +1,338 @@
+package com.destroystokyo.paper.event.server; +package com.destroystokyo.paper.event.server;
+ +
+import static java.util.Objects.requireNonNull; +import static java.util.Objects.requireNonNull;
@ -30,6 +30,7 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+import java.util.NoSuchElementException; +import java.util.NoSuchElementException;
+import java.util.UUID; +import java.util.UUID;
+ +
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -56,6 +57,7 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ private Object[] players; + private Object[] players;
+ +
+ @Deprecated + @Deprecated
+ @ApiStatus.Internal
+ public PaperServerListPingEvent(@NotNull StatusClient client, @NotNull String motd, int numPlayers, int maxPlayers, + public PaperServerListPingEvent(@NotNull StatusClient client, @NotNull String motd, int numPlayers, int maxPlayers,
+ @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) { + @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) {
+ super("", client.getAddress().getAddress(), motd, numPlayers, maxPlayers); + super("", client.getAddress().getAddress(), motd, numPlayers, maxPlayers);
@ -66,6 +68,7 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ setServerIcon(favicon); + setServerIcon(favicon);
+ } + }
+ +
+ @ApiStatus.Internal
+ public PaperServerListPingEvent(@NotNull StatusClient client, @NotNull net.kyori.adventure.text.Component motd, int numPlayers, int maxPlayers, + public PaperServerListPingEvent(@NotNull StatusClient client, @NotNull net.kyori.adventure.text.Component motd, int numPlayers, int maxPlayers,
+ @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) { + @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) {
+ super("", client.getAddress().getAddress(), motd, numPlayers, maxPlayers); + super("", client.getAddress().getAddress(), motd, numPlayers, maxPlayers);
@ -103,9 +106,9 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ +
+ /** + /**
+ * Sets the number of players displayed in the server list. + * Sets the number of players displayed in the server list.
+ * + * <p>
+ * <p>Note that this won't have any effect if {@link #shouldHidePlayers()} + * Note that this won't have any effect if {@link #shouldHidePlayers()}
+ * is enabled.</p> + * is enabled.
+ * + *
+ * @param numPlayers The number of online players + * @param numPlayers The number of online players
+ */ + */
@ -118,9 +121,9 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ +
+ /** + /**
+ * {@inheritDoc} + * {@inheritDoc}
+ * + * <p>
+ * <p>Returns {@code -1} if players are hidden using + * Returns {@code -1} if players are hidden using
+ * {@link #shouldHidePlayers()}.</p> + * {@link #shouldHidePlayers()}.
+ */ + */
+ @Override + @Override
+ public int getMaxPlayers() { + public int getMaxPlayers() {
@ -135,23 +138,23 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ * Returns whether all player related information is hidden in the server + * Returns whether all player related information is hidden in the server
+ * list. This will cause {@link #getNumPlayers()}, {@link #getMaxPlayers()} + * list. This will cause {@link #getNumPlayers()}, {@link #getMaxPlayers()}
+ * and {@link #getPlayerSample()} to be skipped in the response. + * and {@link #getPlayerSample()} to be skipped in the response.
+ * + * <p>
+ * <p>The Vanilla Minecraft client will display the player count as {@code ???} + * The Vanilla Minecraft client will display the player count as {@code ???}
+ * when this option is enabled.</p> + * when this option is enabled.
+ * + *
+ * @return {@code true} if the player count is hidden + * @return {@code true} if the player count is hidden
+ */ + */
+ public boolean shouldHidePlayers() { + public boolean shouldHidePlayers() {
+ return hidePlayers; + return this.hidePlayers;
+ } + }
+ +
+ /** + /**
+ * Sets whether all player related information is hidden in the server + * Sets whether all player related information is hidden in the server
+ * list. This will cause {@link #getNumPlayers()}, {@link #getMaxPlayers()} + * list. This will cause {@link #getNumPlayers()}, {@link #getMaxPlayers()}
+ * and {@link #getPlayerSample()} to be skipped in the response. + * and {@link #getPlayerSample()} to be skipped in the response.
+ * + * <p>
+ * <p>The Vanilla Minecraft client will display the player count as {@code ???} + * The Vanilla Minecraft client will display the player count as {@code ???}
+ * when this option is enabled.</p> + * when this option is enabled.
+ * + *
+ * @param hidePlayers {@code true} if the player count should be hidden + * @param hidePlayers {@code true} if the player count should be hidden
+ */ + */
@ -162,9 +165,9 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ /** + /**
+ * Returns a mutable list of {@link PlayerProfile} that will be displayed + * Returns a mutable list of {@link PlayerProfile} that will be displayed
+ * as online players on the client. + * as online players on the client.
+ * + * <p>
+ * <p>The Vanilla Minecraft client will display them when hovering the + * The Vanilla Minecraft client will display them when hovering the
+ * player count with the mouse.</p> + * player count with the mouse.
+ * + *
+ * @return The mutable player sample list + * @return The mutable player sample list
+ */ + */
@ -180,7 +183,7 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ */ + */
+ @NotNull + @NotNull
+ public String getVersion() { + public String getVersion() {
+ return version; + return this.version;
+ } + }
+ +
+ /** + /**
@ -200,7 +203,7 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ * has not finished initialization yet + * has not finished initialization yet
+ */ + */
+ public int getProtocolVersion() { + public int getProtocolVersion() {
+ return protocolVersion; + return this.protocolVersion;
+ } + }
+ +
+ /** + /**
@ -240,9 +243,9 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ +
+ /** + /**
+ * {@inheritDoc} + * {@inheritDoc}
+ * + * <p>
+ * <p>Cancelling this event will cause the connection to be closed immediately, + * Cancelling this event will cause the connection to be closed immediately,
+ * without sending a response to the client.</p> + * without sending a response to the client.
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
@ -251,9 +254,9 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ +
+ /** + /**
+ * {@inheritDoc} + * {@inheritDoc}
+ * + * <p>
+ * <p>Cancelling this event will cause the connection to be closed immediately, + * Cancelling this event will cause the connection to be closed immediately,
+ * without sending a response to the client.</p> + * without sending a response to the client.
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
@ -262,10 +265,10 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ +
+ /** + /**
+ * {@inheritDoc} + * {@inheritDoc}
+ * + * <p>
+ * <p><b>Note:</b> For compatibility reasons, this method will return all + * <b>Note:</b> For compatibility reasons, this method will return all
+ * online players, not just the ones referenced in {@link #getPlayerSample()}. + * online players, not just the ones referenced in {@link #getPlayerSample()}.
+ * Removing a player will:</p> + * Removing a player will:
+ * + *
+ * <ul> + * <ul>
+ * <li>Decrement the online player count (if and only if) the player + * <li>Decrement the online player count (if and only if) the player
@ -294,6 +297,7 @@ index 0000000000000000000000000000000000000000..e886ac04c0c14ae5dfb87212e262b96e
+ return (Player) player; + return (Player) player;
+ } + }
+ +
+ @ApiStatus.Internal
+ private final class PlayerIterator implements Iterator<Player> { + private final class PlayerIterator implements Iterator<Player> {
+ +
+ private int next; + private int next;

Datei anzeigen

@ -9,23 +9,27 @@ You may cancel this, enabling ranged attacks to damage the enderman for example.
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EndermanEscapeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EndermanEscapeEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EndermanEscapeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EndermanEscapeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..806112a8b5a7ce31166675f5b074ceaf42e364b6 index 0000000000000000000000000000000000000000..f6be848c44d5efaca3fbc03c3be7451411943c24
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EndermanEscapeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EndermanEscapeEvent.java
@@ -0,0 +1,87 @@ @@ -0,0 +1,86 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Enderman; +import org.bukkit.entity.Enderman;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+public class EndermanEscapeEvent extends EntityEvent implements Cancellable { +public class EndermanEscapeEvent extends EntityEvent implements Cancellable {
+ @NotNull private final Reason reason;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Reason reason;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EndermanEscapeEvent(@NotNull Enderman entity, @NotNull Reason reason) { + public EndermanEscapeEvent(@NotNull Enderman entity, @NotNull Reason reason) {
+ super(entity); + super(entity);
+ this.reason = reason; + this.reason = reason;
@ -42,39 +46,34 @@ index 0000000000000000000000000000000000000000..806112a8b5a7ce31166675f5b074ceaf
+ */ + */
+ @NotNull + @NotNull
+ public Reason getReason() { + public Reason getReason() {
+ return reason; + return this.reason;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * Cancels the escape. + * Cancels the escape.
+ * + * <p>
+ * If this escape normally would of resulted in damage avoidance such as indirect, + * If this escape normally would of resulted in damage avoidance such as indirect,
+ * the enderman will now take damage. + * the enderman will now take damage.
+ *
+ * @param cancel true if you wish to cancel this event
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+ +
+ public enum Reason { + public enum Reason {
@ -95,7 +94,7 @@ index 0000000000000000000000000000000000000000..806112a8b5a7ce31166675f5b074ceaf
+ */ + */
+ STARE, + STARE,
+ /** + /**
+ * Specific case for CRITICAL_HIT where the enderman is taking rain damage + * Specific case for {@link #CRITICAL_HIT} where the enderman is taking rain damage
+ */ + */
+ DROWN + DROWN
+ } + }

Datei anzeigen

@ -9,7 +9,7 @@ This allows you to override/extend the pumpkin/stare logic.
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..f530a3d9314e17d1da896cac633f6a422258d9a9 index 0000000000000000000000000000000000000000..ae34e679723a2ef436da04c116038272743a8f35
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EndermanAttackPlayerEvent.java
@@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
@ -39,23 +39,27 @@ index 0000000000000000000000000000000000000000..f530a3d9314e17d1da896cac633f6a42
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Enderman; +import org.bukkit.entity.Enderman;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when an Enderman determines if it should attack a player or not. + * Fired when an Enderman determines if it should attack a player or not.
+ * <p>
+ * Starts off cancelled if the player is wearing a pumpkin head or is not looking + * Starts off cancelled if the player is wearing a pumpkin head or is not looking
+ * at the Enderman, according to Vanilla rules. + * at the Enderman, according to Vanilla rules.
+ *
+ */ + */
+public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellable { +public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellable {
+ @NotNull private final Player player;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Player player;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EndermanAttackPlayerEvent(@NotNull Enderman entity, @NotNull Player player) { + public EndermanAttackPlayerEvent(@NotNull Enderman entity, @NotNull Player player) {
+ super(entity); + super(entity);
+ this.player = player; + this.player = player;
@ -79,38 +83,34 @@ index 0000000000000000000000000000000000000000..f530a3d9314e17d1da896cac633f6a42
+ */ + */
+ @NotNull + @NotNull
+ public Player getPlayer() { + public Player getPlayer() {
+ return player; + return this.player;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ /** + /**
+ *
+ * @return If cancelled, the enderman will not attack + * @return If cancelled, the enderman will not attack
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * {@inheritDoc}
+ * <br>
+ * Cancels if the Enderman will attack this player + * Cancels if the Enderman will attack this player
+ * @param cancel true if you wish to cancel this event
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -7,10 +7,10 @@ Fires when a witch consumes the potion in their hand
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..fbbace36d69373046a7f3618ed5c1c1318b489b9 index 0000000000000000000000000000000000000000..773079aa92280bb97e9b4c0e62d9ead08135610a
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchConsumePotionEvent.java
@@ -0,0 +1,70 @@ @@ -0,0 +1,73 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Witch; +import org.bukkit.entity.Witch;
@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..fbbace36d69373046a7f3618ed5c1c13
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -25,8 +26,13 @@ index 0000000000000000000000000000000000000000..fbbace36d69373046a7f3618ed5c1c13
+ * Fired when a witch consumes the potion in their hand to buff themselves. + * Fired when a witch consumes the potion in their hand to buff themselves.
+ */ + */
+public class WitchConsumePotionEvent extends EntityEvent implements Cancellable { +public class WitchConsumePotionEvent extends EntityEvent implements Cancellable {
+ @Nullable private ItemStack potion;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @Nullable private ItemStack potion;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public WitchConsumePotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) { + public WitchConsumePotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) {
+ super(witch); + super(witch);
+ this.potion = potion; + this.potion = potion;
@ -43,80 +49,38 @@ index 0000000000000000000000000000000000000000..fbbace36d69373046a7f3618ed5c1c13
+ */ + */
+ @Nullable + @Nullable
+ public ItemStack getPotion() { + public ItemStack getPotion() {
+ return potion; + return this.potion;
+ } + }
+ +
+ /** + /**
+ * Sets the potion to be consumed and applied to the witch. + * Sets the potion to be consumed and applied to the witch.
+ *
+ * @param potion The potion + * @param potion The potion
+ */ + */
+ public void setPotion(@Nullable ItemStack potion) { + public void setPotion(@Nullable ItemStack potion) {
+ this.potion = potion != null ? potion.clone() : null; + this.potion = potion != null ? potion.clone() : null;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ /** + /**
+ * @return Event was cancelled or potion was null + * @return Event was cancelled or potion was {@code null}
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled || potion == null; + return this.cancelled || this.potion == null;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..6ef6367b67261c2b653a97322b9703a9409b3499
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java
@@ -0,0 +1,33 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class WitchThrowPotionEvent extends Event implements Cancellable {
+ public WitchThrowPotionEvent() {
+ } + }
+ +
+ + @NotNull
+ private static final HandlerList handlers = new HandlerList();
+
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ }
+
+ private boolean cancelled = false;
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ } + }
+} +}

Datei anzeigen

@ -6,37 +6,41 @@ Subject: [PATCH] WitchThrowPotionEvent
Fired when a witch throws a potion at a player Fired when a witch throws a potion at a player
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java
index 6ef6367b67261c2b653a97322b9703a9409b3499..688a596aa2b925651a92bf092e1ef4d77a47258c 100644 new file mode 100644
--- a/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java index 0000000000000000000000000000000000000000..f1d546a3576a170ecb3608e07befa0f621ea043a
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchThrowPotionEvent.java
@@ -1,29 +1,77 @@ @@ -0,0 +1,85 @@
package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Witch; +import org.bukkit.entity.Witch;
import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
-import org.bukkit.event.Event; +import org.bukkit.event.HandlerList;
import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+
-public class WitchThrowPotionEvent extends Event implements Cancellable {
- public WitchThrowPotionEvent() {
+/** +/**
+ * Fired when a witch throws a potion at a player + * Fired when a witch throws a potion at a player
+ */ + */
+public class WitchThrowPotionEvent extends EntityEvent implements Cancellable { +public class WitchThrowPotionEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final LivingEntity target; + @NotNull private final LivingEntity target;
+ @Nullable private ItemStack potion; + @Nullable private ItemStack potion;
+ private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public WitchThrowPotionEvent(@NotNull Witch witch, @NotNull LivingEntity target, @Nullable ItemStack potion) { + public WitchThrowPotionEvent(@NotNull Witch witch, @NotNull LivingEntity target, @Nullable ItemStack potion) {
+ super(witch); + super(witch);
+ this.target = target; + this.target = target;
+ this.potion = potion; + this.potion = potion;
} + }
+
+ @NotNull + @NotNull
+ @Override + @Override
+ public Witch getEntity() { + public Witch getEntity() {
@ -48,7 +52,7 @@ index 6ef6367b67261c2b653a97322b9703a9409b3499..688a596aa2b925651a92bf092e1ef4d7
+ */ + */
+ @NotNull + @NotNull
+ public LivingEntity getTarget() { + public LivingEntity getTarget() {
+ return target; + return this.target;
+ } + }
+ +
+ /** + /**
@ -56,38 +60,39 @@ index 6ef6367b67261c2b653a97322b9703a9409b3499..688a596aa2b925651a92bf092e1ef4d7
+ */ + */
+ @Nullable + @Nullable
+ public ItemStack getPotion() { + public ItemStack getPotion() {
+ return potion; + return this.potion;
+ } + }
+ +
+ /** + /**
+ * Sets the potion to be thrown at a player + * Sets the potion to be thrown at a player
+ *
+ * @param potion The potion + * @param potion The potion
+ */ + */
+ public void setPotion(@Nullable ItemStack potion) { + public void setPotion(@Nullable ItemStack potion) {
+ this.potion = potion != null ? potion.clone() : null; + this.potion = potion != null ? potion.clone() : null;
+ } + }
+
private static final HandlerList handlers = new HandlerList();
+ @NotNull
public HandlerList getHandlers() {
return handlers;
}
+ @NotNull
public static HandlerList getHandlerList() {
return handlers;
}
private boolean cancelled = false;
+ /** + /**
+ * @return Event was cancelled or potion was null + * @return Event was cancelled or potion was {@code null}
+ */ + */
@Override + @Override
public boolean isCancelled() { + public boolean isCancelled() {
- return cancelled; + return this.cancelled || this.potion == null;
+ return cancelled || potion == null; + }
} +
+ @Override
@Override + public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}

Datei anzeigen

@ -7,44 +7,34 @@ Control what potion the witch readies to use
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..57f93af14acc6346c5a343e05fe8f5d44d6adbc6 index 0000000000000000000000000000000000000000..7feca06e72bd585bbfa219df38a2161b77e8d4c4
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/WitchReadyPotionEvent.java
@@ -0,0 +1,80 @@ @@ -0,0 +1,68 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.Material;
+import org.bukkit.entity.Witch; +import org.bukkit.entity.Witch;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+public class WitchReadyPotionEvent extends EntityEvent implements Cancellable { +public class WitchReadyPotionEvent extends EntityEvent implements Cancellable {
+ private ItemStack potion;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private ItemStack potion;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public WitchReadyPotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) { + public WitchReadyPotionEvent(@NotNull Witch witch, @Nullable ItemStack potion) {
+ super(witch); + super(witch);
+ this.potion = potion; + this.potion = potion;
+ } + }
+ +
+ /**
+ * Fires the event, returning the desired potion, or air of cancelled
+ * @param witch the witch whom is readying to use a potion
+ * @param potion the potion to be used
+ * @return The ItemStack to be used
+ */
+ @Nullable
+ public static ItemStack process(@NotNull Witch witch, @Nullable ItemStack potion) {
+ WitchReadyPotionEvent event = new WitchReadyPotionEvent(witch, potion);
+ if (!event.callEvent() || event.getPotion() == null) {
+ return new ItemStack(Material.AIR);
+ }
+ return event.getPotion();
+ }
+
+ @NotNull + @NotNull
+ @Override + @Override
+ public Witch getEntity() { + public Witch getEntity() {
@ -56,38 +46,36 @@ index 0000000000000000000000000000000000000000..57f93af14acc6346c5a343e05fe8f5d4
+ */ + */
+ @Nullable + @Nullable
+ public ItemStack getPotion() { + public ItemStack getPotion() {
+ return potion; + return this.potion;
+ } + }
+ +
+ /** + /**
+ * Sets the potion the which is going to hold and use + * Sets the potion the which is going to hold and use
+ *
+ * @param potion The potion + * @param potion The potion
+ */ + */
+ public void setPotion(@Nullable ItemStack potion) { + public void setPotion(@Nullable ItemStack potion) {
+ this.potion = potion != null ? potion.clone() : null; + this.potion = potion != null ? potion.clone() : null;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,16 +6,17 @@ Subject: [PATCH] Add EntityTeleportEndGatewayEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityTeleportEndGatewayEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityTeleportEndGatewayEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityTeleportEndGatewayEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityTeleportEndGatewayEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..bfc69a43c291fbed91b9d0387e4ef18b0ed1b9de index 0000000000000000000000000000000000000000..88b9c059f9d66877260c66496443ad0aefaf8f47
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTeleportEndGatewayEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTeleportEndGatewayEvent.java
@@ -0,0 +1,31 @@ @@ -0,0 +1,33 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
+import org.bukkit.block.EndGateway; +import org.bukkit.block.EndGateway;
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.event.entity.EntityTeleportEvent; +import org.bukkit.event.entity.EntityTeleportEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -25,8 +26,9 @@ index 0000000000000000000000000000000000000000..bfc69a43c291fbed91b9d0387e4ef18b
+ +
+ @NotNull private final EndGateway gateway; + @NotNull private final EndGateway gateway;
+ +
+ public EntityTeleportEndGatewayEvent(@NotNull Entity what, @NotNull Location from, @NotNull Location to, @NotNull EndGateway gateway) { + @ApiStatus.Internal
+ super(what, from, to); + public EntityTeleportEndGatewayEvent(@NotNull Entity entity, @NotNull Location from, @NotNull Location to, @NotNull EndGateway gateway) {
+ super(entity, from, to);
+ this.gateway = gateway; + this.gateway = gateway;
+ } + }
+ +
@ -37,7 +39,7 @@ index 0000000000000000000000000000000000000000..bfc69a43c291fbed91b9d0387e4ef18b
+ */ + */
+ @NotNull + @NotNull
+ public EndGateway getGateway() { + public EndGateway getGateway() {
+ return gateway; + return this.gateway;
+ } + }
+ +
+} +}

Datei anzeigen

@ -8,10 +8,10 @@ Plugins can skip selection of certain arrows and control which is used.
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerReadyArrowEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerReadyArrowEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerReadyArrowEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerReadyArrowEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..5d04a22fd6964d8d44a2aa069c9629722893b1f4 index 0000000000000000000000000000000000000000..f30c4c372c92a79fb6c3fe80c4b51b5c8c0d4d3b
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerReadyArrowEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerReadyArrowEvent.java
@@ -0,0 +1,93 @@ @@ -0,0 +1,94 @@
+/* +/*
+ * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License + * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
+ * + *
@ -39,7 +39,6 @@ index 0000000000000000000000000000000000000000..5d04a22fd6964d8d44a2aa069c962972
+ +
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
@ -49,9 +48,14 @@ index 0000000000000000000000000000000000000000..5d04a22fd6964d8d44a2aa069c962972
+ * Called when a player is firing a bow and the server is choosing an arrow to use. + * Called when a player is firing a bow and the server is choosing an arrow to use.
+ */ + */
+public class PlayerReadyArrowEvent extends PlayerEvent implements Cancellable { +public class PlayerReadyArrowEvent extends PlayerEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final ItemStack bow; + @NotNull private final ItemStack bow;
+ @NotNull private final ItemStack arrow; + @NotNull private final ItemStack arrow;
+ +
+ private boolean cancelled;
+
+ public PlayerReadyArrowEvent(@NotNull Player player, @NotNull ItemStack bow, @NotNull ItemStack arrow) { + public PlayerReadyArrowEvent(@NotNull Player player, @NotNull ItemStack bow, @NotNull ItemStack arrow) {
+ super(player); + super(player);
+ this.bow = bow; + this.bow = bow;
@ -63,7 +67,7 @@ index 0000000000000000000000000000000000000000..5d04a22fd6964d8d44a2aa069c962972
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getBow() { + public ItemStack getBow() {
+ return bow; + return this.bow;
+ } + }
+ +
+ /** + /**
@ -71,37 +75,34 @@ index 0000000000000000000000000000000000000000..5d04a22fd6964d8d44a2aa069c962972
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getArrow() { + public ItemStack getArrow() {
+ return arrow; + return this.arrow;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ /** + /**
+ * Whether or not use of this arrow is cancelled. On cancel, the server will try the next arrow available and fire another event. + * {@inheritDoc}
+ * <br>
+ * Whether use of this arrow is cancelled. On cancel, the server will try the next arrow available and fire another event.
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * Cancel use of this arrow. On cancel, the server will try the next arrow available and fire another event. + * Cancel use of this arrow. On cancel, the server will try the next arrow available and fire another event.
+ * @param cancel true if you wish to cancel this event
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -8,26 +8,28 @@ Co-authored-by: aerulion <aerulion@gmail.com>
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..42fdf7a5bfab99a61ff2fbf562f2872ac360bef2 index 0000000000000000000000000000000000000000..e0ba692c9b107f2b042a9c06549185e1c4777e27
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityKnockbackByEntityEvent.java
@@ -0,0 +1,46 @@ @@ -0,0 +1,48 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent; +import io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent;
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.util.Vector; +import org.bukkit.util.Vector;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when an Entity is knocked back by the hit of another Entity. The acceleration + * Fired when an Entity is knocked back by the hit of another Entity. The acceleration
+ * vector can be modified. If this event is cancelled, the entity is not knocked back. + * vector can be modified. If this event is cancelled, the entity is not knocked back.
+ *
+ */ + */
+public class EntityKnockbackByEntityEvent extends EntityPushedByEntityAttackEvent { +public class EntityKnockbackByEntityEvent extends EntityPushedByEntityAttackEvent {
+
+ private final float knockbackStrength; + private final float knockbackStrength;
+ +
+ @ApiStatus.Internal
+ public EntityKnockbackByEntityEvent(@NotNull LivingEntity entity, @NotNull Entity hitBy, float knockbackStrength, @NotNull Vector acceleration) { + public EntityKnockbackByEntityEvent(@NotNull LivingEntity entity, @NotNull Entity hitBy, float knockbackStrength, @NotNull Vector acceleration) {
+ super(entity, hitBy, acceleration); + super(entity, hitBy, acceleration);
+ this.knockbackStrength = knockbackStrength; + this.knockbackStrength = knockbackStrength;
@ -46,7 +48,7 @@ index 0000000000000000000000000000000000000000..42fdf7a5bfab99a61ff2fbf562f2872a
+ * @return the original knockback strength. + * @return the original knockback strength.
+ */ + */
+ public float getKnockbackStrength() { + public float getKnockbackStrength() {
+ return knockbackStrength; + return this.knockbackStrength;
+ } + }
+ +
+ /** + /**
@ -60,10 +62,10 @@ index 0000000000000000000000000000000000000000..42fdf7a5bfab99a61ff2fbf562f2872a
+} +}
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityPushedByEntityAttackEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityPushedByEntityAttackEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/EntityPushedByEntityAttackEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityPushedByEntityAttackEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..c15401cd206eb9e1a7a8b7154aba0247e2da1e19 index 0000000000000000000000000000000000000000..70d6e72d4dc0c040c8bccf7acc383e84db472514
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityPushedByEntityAttackEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/EntityPushedByEntityAttackEvent.java
@@ -0,0 +1,70 @@ @@ -0,0 +1,74 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
@ -71,6 +73,7 @@ index 0000000000000000000000000000000000000000..c15401cd206eb9e1a7a8b7154aba0247
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.util.Vector; +import org.bukkit.util.Vector;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -82,38 +85,20 @@ index 0000000000000000000000000000000000000000..c15401cd206eb9e1a7a8b7154aba0247
+ */ + */
+public class EntityPushedByEntityAttackEvent extends EntityEvent implements Cancellable { +public class EntityPushedByEntityAttackEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final @NotNull Entity pushedBy; + private final @NotNull Entity pushedBy;
+ private final @NotNull Vector acceleration; + private final @NotNull Vector acceleration;
+ private boolean cancelled = false;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityPushedByEntityAttackEvent(@NotNull Entity entity, @NotNull Entity pushedBy, @NotNull Vector acceleration) { + public EntityPushedByEntityAttackEvent(@NotNull Entity entity, @NotNull Entity pushedBy, @NotNull Vector acceleration) {
+ super(entity); + super(entity);
+ this.pushedBy = pushedBy; + this.pushedBy = pushedBy;
+ this.acceleration = acceleration; + this.acceleration = acceleration;
+ } + }
+ +
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ }
+
+ /** + /**
+ * Gets the entity which pushed the affected entity. + * Gets the entity which pushed the affected entity.
+ * + *
@ -121,7 +106,7 @@ index 0000000000000000000000000000000000000000..c15401cd206eb9e1a7a8b7154aba0247
+ */ + */
+ @NotNull + @NotNull
+ public Entity getPushedBy() { + public Entity getPushedBy() {
+ return pushedBy; + return this.pushedBy;
+ } + }
+ +
+ /** + /**
@ -131,6 +116,27 @@ index 0000000000000000000000000000000000000000..c15401cd206eb9e1a7a8b7154aba0247
+ */ + */
+ @NotNull + @NotNull
+ public Vector getAcceleration() { + public Vector getAcceleration() {
+ return acceleration; + return this.acceleration;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] EnderDragon Events
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..615bc4c973ff371d87f996e981207fc15b70275b index 0000000000000000000000000000000000000000..bf5f82c8ba36bd245e1536fd4f654487aa8f6e21
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFireballHitEvent.java
@@ -0,0 +1,77 @@ @@ -0,0 +1,79 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.AreaEffectCloud; +import org.bukkit.entity.AreaEffectCloud;
@ -27,11 +27,12 @@ index 0000000000000000000000000000000000000000..615bc4c973ff371d87f996e981207fc1
+ * Fired when a DragonFireball collides with a block/entity and spawns an AreaEffectCloud + * Fired when a DragonFireball collides with a block/entity and spawns an AreaEffectCloud
+ */ + */
+public class EnderDragonFireballHitEvent extends EntityEvent implements Cancellable { +public class EnderDragonFireballHitEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Collection<LivingEntity> targets; + @NotNull private final Collection<LivingEntity> targets;
+ @NotNull private final AreaEffectCloud areaEffectCloud; + @NotNull private final AreaEffectCloud areaEffectCloud;
+ private boolean cancelled = false; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EnderDragonFireballHitEvent(@NotNull DragonFireball fireball, @NotNull Collection<LivingEntity> targets, @NotNull AreaEffectCloud areaEffectCloud) { + public EnderDragonFireballHitEvent(@NotNull DragonFireball fireball, @NotNull Collection<LivingEntity> targets, @NotNull AreaEffectCloud areaEffectCloud) {
@ -56,7 +57,7 @@ index 0000000000000000000000000000000000000000..615bc4c973ff371d87f996e981207fc1
+ */ + */
+ @NotNull + @NotNull
+ public Collection<LivingEntity> getTargets() { + public Collection<LivingEntity> getTargets() {
+ return targets; + return this.targets;
+ } + }
+ +
+ /** + /**
@ -64,20 +65,21 @@ index 0000000000000000000000000000000000000000..615bc4c973ff371d87f996e981207fc1
+ */ + */
+ @NotNull + @NotNull
+ public AreaEffectCloud getAreaEffectCloud() { + public AreaEffectCloud getAreaEffectCloud() {
+ return areaEffectCloud; + return this.areaEffectCloud;
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -89,10 +91,10 @@ index 0000000000000000000000000000000000000000..615bc4c973ff371d87f996e981207fc1
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..1915177f4b8f8013656fbdb41240f6c5c88f95d7 index 0000000000000000000000000000000000000000..4a61878152c95a07160f4216e78b042ca45d24b3
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java
@@ -0,0 +1,61 @@ @@ -0,0 +1,63 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.AreaEffectCloud; +import org.bukkit.entity.AreaEffectCloud;
@ -100,14 +102,20 @@ index 0000000000000000000000000000000000000000..1915177f4b8f8013656fbdb41240f6c5
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when an EnderDragon spawns an AreaEffectCloud by shooting flames + * Fired when an EnderDragon spawns an AreaEffectCloud by shooting flames
+ */ + */
+public class EnderDragonFlameEvent extends EntityEvent implements Cancellable { +public class EnderDragonFlameEvent extends EntityEvent implements Cancellable {
+ @NotNull private final AreaEffectCloud areaEffectCloud;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final AreaEffectCloud areaEffectCloud;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EnderDragonFlameEvent(@NotNull EnderDragon enderDragon, @NotNull AreaEffectCloud areaEffectCloud) { + public EnderDragonFlameEvent(@NotNull EnderDragon enderDragon, @NotNull AreaEffectCloud areaEffectCloud) {
+ super(enderDragon); + super(enderDragon);
+ this.areaEffectCloud = areaEffectCloud; + this.areaEffectCloud = areaEffectCloud;
@ -127,39 +135,35 @@ index 0000000000000000000000000000000000000000..1915177f4b8f8013656fbdb41240f6c5
+ */ + */
+ @NotNull + @NotNull
+ public AreaEffectCloud getAreaEffectCloud() { + public AreaEffectCloud getAreaEffectCloud() {
+ return areaEffectCloud; + return this.areaEffectCloud;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..8414bd805ec68d7b305fbf645c59f8d5b762c9ce index 0000000000000000000000000000000000000000..3c6c3db37d91aad3638aef107a3bf8ca1d4f7085
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonShootFireballEvent.java
@@ -0,0 +1,61 @@ @@ -0,0 +1,64 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.DragonFireball; +import org.bukkit.entity.DragonFireball;
@ -167,14 +171,20 @@ index 0000000000000000000000000000000000000000..8414bd805ec68d7b305fbf645c59f8d5
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when an EnderDragon shoots a fireball + * Fired when an EnderDragon shoots a fireball
+ */ + */
+public class EnderDragonShootFireballEvent extends EntityEvent implements Cancellable { +public class EnderDragonShootFireballEvent extends EntityEvent implements Cancellable {
+ @NotNull private final DragonFireball fireball;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final DragonFireball fireball;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EnderDragonShootFireballEvent(@NotNull EnderDragon entity, @NotNull DragonFireball fireball) { + public EnderDragonShootFireballEvent(@NotNull EnderDragon entity, @NotNull DragonFireball fireball) {
+ super(entity); + super(entity);
+ this.fireball = fireball; + this.fireball = fireball;
@ -194,30 +204,27 @@ index 0000000000000000000000000000000000000000..8414bd805ec68d7b305fbf645c59f8d5
+ */ + */
+ @NotNull + @NotNull
+ public DragonFireball getFireball() { + public DragonFireball getFireball() {
+ return fireball; + return this.fireball;
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] PlayerElytraBoostEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerElytraBoostEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerElytraBoostEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerElytraBoostEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerElytraBoostEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..e9a76a25fa5445905a09dbc2fd5b35bff56d80b3 index 0000000000000000000000000000000000000000..42375d44ed0db457b96165414e9b45a557bac1ab
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerElytraBoostEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerElytraBoostEvent.java
@@ -0,0 +1,85 @@ @@ -0,0 +1,90 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.entity.Firework; +import org.bukkit.entity.Firework;
@ -18,18 +18,23 @@ index 0000000000000000000000000000000000000000..e9a76a25fa5445905a09dbc2fd5b35bf
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when a player boosts elytra flight with a firework + * Fired when a player boosts elytra flight with a firework
+ */ + */
+public class PlayerElytraBoostEvent extends PlayerEvent implements Cancellable { +public class PlayerElytraBoostEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final ItemStack itemStack; + @NotNull private final ItemStack itemStack;
+ @NotNull private Firework firework; + @NotNull private final Firework firework;
+ private boolean consume = true; + private boolean consume = true;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerElytraBoostEvent(@NotNull Player player, @NotNull ItemStack itemStack, @NotNull Firework firework) { + public PlayerElytraBoostEvent(@NotNull Player player, @NotNull ItemStack itemStack, @NotNull Firework firework) {
+ super(player); + super(player);
+ this.itemStack = itemStack; + this.itemStack = itemStack;
@ -43,7 +48,7 @@ index 0000000000000000000000000000000000000000..e9a76a25fa5445905a09dbc2fd5b35bf
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getItemStack() { + public ItemStack getItemStack() {
+ return itemStack; + return this.itemStack;
+ } + }
+ +
+ /** + /**
@ -53,45 +58,45 @@ index 0000000000000000000000000000000000000000..e9a76a25fa5445905a09dbc2fd5b35bf
+ */ + */
+ @NotNull + @NotNull
+ public Firework getFirework() { + public Firework getFirework() {
+ return firework; + return this.firework;
+ } + }
+ +
+ /** + /**
+ * Get whether to consume the firework or not + * Get whether to consume the firework or not
+ * + *
+ * @return True to consume + * @return {@code true} to consume
+ */ + */
+ public boolean shouldConsume() { + public boolean shouldConsume() {
+ return consume; + return this.consume;
+ } + }
+ +
+ /** + /**
+ * Set whether to consume the firework or not + * Set whether to consume the firework or not
+ * + *
+ * @param consume True to consume + * @param consume {@code true} to consume
+ */ + */
+ public void setShouldConsume(boolean consume) { + public void setShouldConsume(boolean consume) {
+ this.consume = consume; + this.consume = consume;
+ } + }
+ +
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,34 +6,40 @@ Subject: [PATCH] PlayerLaunchProjectileEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLaunchProjectileEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLaunchProjectileEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLaunchProjectileEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLaunchProjectileEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..5450575459f2d95be93db5a8c6d4d88c69deb2ec index 0000000000000000000000000000000000000000..efd947eb0aa0633891d9c6a8bde66d33e29020d7
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLaunchProjectileEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLaunchProjectileEvent.java
@@ -0,0 +1,87 @@ @@ -0,0 +1,95 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.entity.Projectile; +import org.bukkit.entity.Projectile;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityShootBowEvent;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when a player shoots a projectile. + * Called when a player shoots a projectile.
+ * <p> + * <p>
+ * Notably this event is not called for arrows as the player does not launch them, rather shoots them with the help + * Notably this event is not called for arrows as the player does not launch them, rather shoots them with the help
+ * of a bow or crossbow. A plugin may listen to {@link org.bukkit.event.entity.EntityShootBowEvent} for these actions + * of a bow or crossbow. A plugin may listen to {@link EntityShootBowEvent}
+ * instead. + * for these actions instead.
+ */ + */
+public class PlayerLaunchProjectileEvent extends PlayerEvent implements Cancellable { +public class PlayerLaunchProjectileEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Projectile projectile; + @NotNull private final Projectile projectile;
+ @NotNull private final ItemStack itemStack; + @NotNull private final ItemStack itemStack;
+ private boolean consumeItem = true; + private boolean consumeItem = true;
+
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public PlayerLaunchProjectileEvent(@NotNull Player shooter, @NotNull ItemStack itemStack, @NotNull Projectile projectile) { + public PlayerLaunchProjectileEvent(@NotNull Player shooter, @NotNull ItemStack itemStack, @NotNull Projectile projectile) {
+ super(shooter); + super(shooter);
+ this.itemStack = itemStack; + this.itemStack = itemStack;
@ -47,7 +53,7 @@ index 0000000000000000000000000000000000000000..5450575459f2d95be93db5a8c6d4d88c
+ */ + */
+ @NotNull + @NotNull
+ public Projectile getProjectile() { + public Projectile getProjectile() {
+ return projectile; + return this.projectile;
+ } + }
+ +
+ /** + /**
@ -57,43 +63,45 @@ index 0000000000000000000000000000000000000000..5450575459f2d95be93db5a8c6d4d88c
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getItemStack() { + public ItemStack getItemStack() {
+ return itemStack; + return this.itemStack;
+ } + }
+ +
+ /** + /**
+ * Get whether to consume the ItemStack or not + * Get whether to consume the ItemStack or not
+ * + *
+ * @return True to consume + * @return {@code true} to consume
+ */ + */
+ public boolean shouldConsume() { + public boolean shouldConsume() {
+ return consumeItem; + return this.consumeItem;
+ } + }
+ +
+ /** + /**
+ * Set whether to consume the ItemStack or not + * Set whether to consume the ItemStack or not
+ * + *
+ * @param consumeItem True to consume + * @param consumeItem {@code true} to consume
+ */ + */
+ public void setShouldConsume(boolean consumeItem) { + public void setShouldConsume(boolean consumeItem) {
+ this.consumeItem = consumeItem; + this.consumeItem = consumeItem;
+ } + }
+ +
+ @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,34 +6,38 @@ Subject: [PATCH] EntityTransformedEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..c6802ca6acad1b841c01284eef0a601774486f55 index 0000000000000000000000000000000000000000..9ce2638aeec5745f1a2b88e1cc125f57f8c8debe
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
@@ -0,0 +1,93 @@ @@ -0,0 +1,95 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.event.entity.EntityTransformEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when an entity transforms into another entity + * Fired when an entity transforms into another entity
+ * <p> + * <p>
+ * If the event is cancelled, the entity will not transform + * If the event is cancelled, the entity will not transform
+ * @deprecated Bukkit has added {@link EntityTransformEvent}, you should start using that + *
+ * @deprecated Bukkit has added {@link org.bukkit.event.entity.EntityTransformEvent}, you should start using that
+ */ + */
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21") +@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
+public class EntityTransformedEvent extends EntityEvent implements Cancellable { +public class EntityTransformedEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Entity transformed; + private final Entity transformed;
+ private final TransformedReason reason; + private final TransformedReason reason;
+ +
+ public EntityTransformedEvent(Entity entity, Entity transformed, TransformedReason reason) { + private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityTransformedEvent(@NotNull Entity entity, @NotNull Entity transformed, @NotNull TransformedReason reason) {
+ super(entity); + super(entity);
+ this.transformed = transformed; + this.transformed = transformed;
+ this.reason = reason; + this.reason = reason;
@ -43,40 +47,39 @@ index 0000000000000000000000000000000000000000..c6802ca6acad1b841c01284eef0a6017
+ * The entity after it has transformed + * The entity after it has transformed
+ * + *
+ * @return Transformed entity + * @return Transformed entity
+ * @deprecated see {@link EntityTransformEvent#getTransformedEntity()}
+ */ + */
+ @Deprecated + @NotNull
+ public Entity getTransformed() { + public Entity getTransformed() {
+ return transformed; + return this.transformed;
+ } + }
+ +
+ /** + /**
+ * @return The reason for the transformation + * @return The reason for the transformation
+ * @deprecated see {@link EntityTransformEvent#getTransformReason()}
+ */ + */
+ @Deprecated + @NotNull
+ public TransformedReason getReason() { + public TransformedReason getReason() {
+ return reason; + return this.reason;
+ }
+
+
+ @Override
+ public HandlerList getHandlers(){
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList(){
+ return handlers;
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled(){ + public boolean isCancelled(){
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel){ + public void setCancelled(boolean cancel){
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @Override
+ @NotNull
+ public HandlerList getHandlers(){
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList(){
+ return HANDLER_LIST;
+ } + }
+ +
+ public enum TransformedReason { + public enum TransformedReason {
@ -97,9 +100,8 @@ index 0000000000000000000000000000000000000000..c6802ca6acad1b841c01284eef0a6017
+ */ + */
+ SHEARED, + SHEARED,
+ /** + /**
+ * When a pig turns to a zombiepigman + * When a pig turns to a zombified piglin
+ */ + */
+ LIGHTNING + LIGHTNING
+
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] SkeletonHorse Additions
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SkeletonHorseTrapEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SkeletonHorseTrapEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SkeletonHorseTrapEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SkeletonHorseTrapEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..9ce2948dfaa56d0adf53fe9b6117a90d7773b771 index 0000000000000000000000000000000000000000..f6724e6e5754996ac10888aaa92baf2dcc6134d3
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SkeletonHorseTrapEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/SkeletonHorseTrapEvent.java
@@ -0,0 +1,62 @@ @@ -0,0 +1,68 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList;
@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..9ce2948dfaa56d0adf53fe9b6117a90d
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+import java.util.List; +import java.util.List;
@ -26,14 +27,19 @@ index 0000000000000000000000000000000000000000..9ce2948dfaa56d0adf53fe9b6117a90d
+ * Event called when a player gets close to a skeleton horse and triggers the lightning trap + * Event called when a player gets close to a skeleton horse and triggers the lightning trap
+ */ + */
+public class SkeletonHorseTrapEvent extends EntityEvent implements Cancellable { +public class SkeletonHorseTrapEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ private final List<HumanEntity> eligibleHumans;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final List<HumanEntity> eligibleHumans;
+ private boolean cancelled;
+
+ @Deprecated
+ @ApiStatus.Internal
+ public SkeletonHorseTrapEvent(@NotNull SkeletonHorse horse) { + public SkeletonHorseTrapEvent(@NotNull SkeletonHorse horse) {
+ this(horse, ImmutableList.of()); + this(horse, ImmutableList.of());
+ } + }
+ +
+ @ApiStatus.Internal
+ public SkeletonHorseTrapEvent(@NotNull SkeletonHorse horse, @NotNull List<HumanEntity> eligibleHumans) { + public SkeletonHorseTrapEvent(@NotNull SkeletonHorse horse, @NotNull List<HumanEntity> eligibleHumans) {
+ super(horse); + super(horse);
+ this.eligibleHumans = eligibleHumans; + this.eligibleHumans = eligibleHumans;
@ -45,9 +51,14 @@ index 0000000000000000000000000000000000000000..9ce2948dfaa56d0adf53fe9b6117a90d
+ return (SkeletonHorse) super.getEntity(); + return (SkeletonHorse) super.getEntity();
+ } + }
+ +
+ @NotNull
+ public List<HumanEntity> getEligibleHumans() {
+ return this.eligibleHumans;
+ }
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
@ -56,19 +67,14 @@ index 0000000000000000000000000000000000000000..9ce2948dfaa56d0adf53fe9b6117a90d
+ } + }
+ +
+ @NotNull + @NotNull
+ public List<HumanEntity> getEligibleHumans() {
+ return eligibleHumans;
+ }
+
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
+ +

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] AnvilDamageEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..aa5c3690fb898a7560a9551df91588a0cdc69fe2 index 0000000000000000000000000000000000000000..4f88c101d81e5c3a8a065260304d5816337666d7
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
@@ -0,0 +1,151 @@ @@ -0,0 +1,154 @@
+package com.destroystokyo.paper.event.block; +package com.destroystokyo.paper.event.block;
+ +
+import org.bukkit.Material; +import org.bukkit.Material;
@ -27,10 +27,11 @@ index 0000000000000000000000000000000000000000..aa5c3690fb898a7560a9551df91588a0
+ * Called when an anvil is damaged from being used + * Called when an anvil is damaged from being used
+ */ + */
+public class AnvilDamagedEvent extends InventoryEvent implements Cancellable { +public class AnvilDamagedEvent extends InventoryEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private boolean cancel;
+ private DamageState damageState; + private DamageState damageState;
+ private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public AnvilDamagedEvent(@NotNull InventoryView inventory, @Nullable BlockData blockData) { + public AnvilDamagedEvent(@NotNull InventoryView inventory, @Nullable BlockData blockData) {
@ -51,7 +52,7 @@ index 0000000000000000000000000000000000000000..aa5c3690fb898a7560a9551df91588a0
+ */ + */
+ @NotNull + @NotNull
+ public DamageState getDamageState() { + public DamageState getDamageState() {
+ return damageState; + return this.damageState;
+ } + }
+ +
+ /** + /**
@ -66,31 +67,33 @@ index 0000000000000000000000000000000000000000..aa5c3690fb898a7560a9551df91588a0
+ /** + /**
+ * Gets if anvil is breaking on this use + * Gets if anvil is breaking on this use
+ * + *
+ * @return True if breaking + * @return {@code true} if breaking
+ */ + */
+ public boolean isBreaking() { + public boolean isBreaking() {
+ return damageState == DamageState.BROKEN; + return this.damageState == DamageState.BROKEN;
+ } + }
+ +
+ /** + /**
+ * Sets if anvil is breaking on this use + * Sets if anvil is breaking on this use
+ * + *
+ * @param breaking True if breaking + * @param breaking {@code true} if breaking
+ */ + */
+ public void setBreaking(boolean breaking) { + public void setBreaking(boolean breaking) {
+ if (breaking) { + if (breaking) {
+ damageState = DamageState.BROKEN; + this.damageState = DamageState.BROKEN;
+ } else if (damageState == DamageState.BROKEN) { + } else if (this.damageState == DamageState.BROKEN) {
+ damageState = DamageState.DAMAGED; + this.damageState = DamageState.DAMAGED;
+ } + }
+ } + }
+ +
+ @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancel; + return this.cancelled;
+ } + }
+ +
+ @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancel = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
@ -125,7 +128,7 @@ index 0000000000000000000000000000000000000000..aa5c3690fb898a7560a9551df91588a0
+ */ + */
+ @NotNull + @NotNull
+ public Material getMaterial() { + public Material getMaterial() {
+ return material; + return this.material;
+ } + }
+ +
+ /** + /**
@ -153,7 +156,7 @@ index 0000000000000000000000000000000000000000..aa5c3690fb898a7560a9551df91588a0
+ return BROKEN; + return BROKEN;
+ } + }
+ for (DamageState state : values()) { + for (DamageState state : values()) {
+ if (state.material == material) { + if (state.getMaterial() == material) {
+ return state; + return state;
+ } + }
+ } + }

Datei anzeigen

@ -6,24 +6,29 @@ Subject: [PATCH] Add TNTPrimeEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java b/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java b/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..9d7221583454dc922b20af6c233897c0b2ec47da index 0000000000000000000000000000000000000000..d8de7332b63feb16c855bf7ea1986fd229489c7c
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java
@@ -0,0 +1,116 @@ @@ -0,0 +1,125 @@
+package com.destroystokyo.paper.event.block; +package com.destroystokyo.paper.event.block;
+ +
+import org.bukkit.Material;
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.enchantments.Enchantment;
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.TNTPrimed;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Called when TNT block is about to turn into {@link org.bukkit.entity.TNTPrimed} + * Called when TNT block is about to turn into {@link TNTPrimed}
+ * <p> + * <p>
+ * Cancelling it won't turn TNT into {@link org.bukkit.entity.TNTPrimed} and leaves + * Cancelling it won't turn TNT into {@link TNTPrimed} and leaves
+ * the TNT block as-is + * the TNT block as-is
+ * + *
+ * @author Mark Vainomaa + * @author Mark Vainomaa
@ -31,11 +36,15 @@ index 0000000000000000000000000000000000000000..9d7221583454dc922b20af6c233897c0
+ */ + */
+@Deprecated(forRemoval = true) +@Deprecated(forRemoval = true)
+public class TNTPrimeEvent extends BlockEvent implements Cancellable { +public class TNTPrimeEvent extends BlockEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ @NotNull private PrimeReason reason;
+ @Nullable private Entity primerEntity;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final PrimeReason reason;
+ @Nullable private final Entity primerEntity;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public TNTPrimeEvent(@NotNull Block theBlock, @NotNull PrimeReason reason, @Nullable Entity primerEntity) { + public TNTPrimeEvent(@NotNull Block theBlock, @NotNull PrimeReason reason, @Nullable Entity primerEntity) {
+ super(theBlock); + super(theBlock);
+ this.reason = reason; + this.reason = reason;
@ -54,10 +63,10 @@ index 0000000000000000000000000000000000000000..9d7221583454dc922b20af6c233897c0
+ +
+ /** + /**
+ * Gets the TNT primer {@link Entity}. + * Gets the TNT primer {@link Entity}.
+ * + * <p>
+ * It's null if {@link #getReason()} is {@link PrimeReason#REDSTONE} or {@link PrimeReason#FIRE}. + * It's {@code null} if {@link #getReason()} is {@link PrimeReason#REDSTONE} or {@link PrimeReason#FIRE}.
+ * It's not null if {@link #getReason()} is {@link PrimeReason#ITEM} or {@link PrimeReason#PROJECTILE} + * It's not {@code null} if {@link #getReason()} is {@link PrimeReason#ITEM} or {@link PrimeReason#PROJECTILE}
+ * It might be null if {@link #getReason()} is {@link PrimeReason#EXPLOSION} + * It might be {@code null} if {@link #getReason()} is {@link PrimeReason#EXPLOSION}
+ * + *
+ * @return The {@link Entity} who primed the TNT + * @return The {@link Entity} who primed the TNT
+ */ + */
@ -67,9 +76,9 @@ index 0000000000000000000000000000000000000000..9d7221583454dc922b20af6c233897c0
+ } + }
+ +
+ /** + /**
+ * Gets whether spawning {@link org.bukkit.entity.TNTPrimed} should be cancelled or not + * Gets whether spawning {@link TNTPrimed} should be cancelled or not
+ * + *
+ * @return Whether spawning {@link org.bukkit.entity.TNTPrimed} should be cancelled or not + * @return Whether spawning {@link TNTPrimed} should be cancelled or not
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
@ -77,24 +86,24 @@ index 0000000000000000000000000000000000000000..9d7221583454dc922b20af6c233897c0
+ } + }
+ +
+ /** + /**
+ * Sets whether to cancel spawning {@link org.bukkit.entity.TNTPrimed} or not + * Sets whether to cancel spawning {@link TNTPrimed} or not
+ * + *
+ * @param cancel whether spawning {@link org.bukkit.entity.TNTPrimed} should be cancelled or not + * @param cancel whether spawning {@link TNTPrimed} should be cancelled or not
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Nullable + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @Nullable + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ public enum PrimeReason { + public enum PrimeReason {
@ -109,14 +118,14 @@ index 0000000000000000000000000000000000000000..9d7221583454dc922b20af6c233897c0
+ FIRE, + FIRE,
+ +
+ /** + /**
+ * When {@link org.bukkit.entity.Player} used {@link org.bukkit.Material#FLINT_AND_STEEL} or + * When {@link Player} used {@link Material#FLINT_AND_STEEL} or
+ * {@link org.bukkit.Material#FIRE_CHARGE} on given TNT block + * {@link Material#FIRE_CHARGE} on given TNT block
+ */ + */
+ ITEM, + ITEM,
+ +
+ /** + /**
+ * When TNT prime was caused by an {@link Entity} shooting TNT + * When TNT prime was caused by an {@link Entity} shooting TNT
+ * using a bow with {@link org.bukkit.enchantments.Enchantment#ARROW_FIRE} enchantment + * using a bow with {@link Enchantment#ARROW_FIRE} enchantment
+ */ + */
+ PROJECTILE, + PROJECTILE,
+ +

Datei anzeigen

@ -6,14 +6,14 @@ Subject: [PATCH] Slime Pathfinder Events
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..473fbded8ab534308f2c0bd0b87512fcce5c9e58 index 0000000000000000000000000000000000000000..30864539574e23bbe9e4c5dc73ad6614de782ac2
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeChangeDirectionEvent.java
@@ -0,0 +1,38 @@ @@ -0,0 +1,40 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Slime; +import org.bukkit.entity.Slime;
+import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -22,9 +22,11 @@ index 0000000000000000000000000000000000000000..473fbded8ab534308f2c0bd0b87512fc
+ * This event does not fire for the entity's actual movement. Only when it + * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to change direction. + * is choosing to change direction.
+ */ + */
+public class SlimeChangeDirectionEvent extends SlimePathfindEvent implements Cancellable { +public class SlimeChangeDirectionEvent extends SlimePathfindEvent {
+
+ private float yaw; + private float yaw;
+ +
+ @ApiStatus.Internal
+ public SlimeChangeDirectionEvent(@NotNull Slime slime, float yaw) { + public SlimeChangeDirectionEvent(@NotNull Slime slime, float yaw) {
+ super(slime); + super(slime);
+ this.yaw = yaw; + this.yaw = yaw;
@ -36,7 +38,7 @@ index 0000000000000000000000000000000000000000..473fbded8ab534308f2c0bd0b87512fc
+ * @return Chosen yaw + * @return Chosen yaw
+ */ + */
+ public float getNewYaw() { + public float getNewYaw() {
+ return yaw; + return this.yaw;
+ } + }
+ +
+ /** + /**
@ -50,16 +52,17 @@ index 0000000000000000000000000000000000000000..473fbded8ab534308f2c0bd0b87512fc
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..14b67da109321ae6521eab2ac6f6945f05d02db5 index 0000000000000000000000000000000000000000..706ed85a5415d688aaa5f138cbf583b9e2bab27d
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimePathfindEvent.java
@@ -0,0 +1,53 @@ @@ -0,0 +1,56 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Slime; +import org.bukkit.entity.Slime;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -69,6 +72,12 @@ index 0000000000000000000000000000000000000000..14b67da109321ae6521eab2ac6f6945f
+ * is choosing to start moving. + * is choosing to start moving.
+ */ + */
+public class SlimePathfindEvent extends EntityEvent implements Cancellable { +public class SlimePathfindEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public SlimePathfindEvent(@NotNull Slime slime) { + public SlimePathfindEvent(@NotNull Slime slime) {
+ super(slime); + super(slime);
+ } + }
@ -80,43 +89,39 @@ index 0000000000000000000000000000000000000000..14b67da109321ae6521eab2ac6f6945f
+ */ + */
+ @NotNull + @NotNull
+ public Slime getEntity() { + public Slime getEntity() {
+ return (Slime) entity; + return (Slime) super.getEntity();
+ } + }
+ +
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..c8dd49d11da5a90a1bac965a75f2b65fd825f3f7 index 0000000000000000000000000000000000000000..65e8a29751e338b0f0acda7bef9e014852a73e6e
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeSwimEvent.java
@@ -0,0 +1,17 @@ @@ -0,0 +1,19 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Slime; +import org.bukkit.entity.Slime;
+import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -125,22 +130,24 @@ index 0000000000000000000000000000000000000000..c8dd49d11da5a90a1bac965a75f2b65f
+ * This event does not fire for the entity's actual movement. Only when it + * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start jumping. + * is choosing to start jumping.
+ */ + */
+public class SlimeSwimEvent extends SlimeWanderEvent implements Cancellable { +public class SlimeSwimEvent extends SlimeWanderEvent {
+
+ @ApiStatus.Internal
+ public SlimeSwimEvent(@NotNull Slime slime) { + public SlimeSwimEvent(@NotNull Slime slime) {
+ super(slime); + super(slime);
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..e9ba32799ed838779e49cd4c5011b7515b3363cb index 0000000000000000000000000000000000000000..87c64b04dfec232e98361c3ec29da7664498c65b
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeTargetLivingEntityEvent.java
@@ -0,0 +1,31 @@ @@ -0,0 +1,33 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Slime; +import org.bukkit.entity.Slime;
+import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -149,9 +156,11 @@ index 0000000000000000000000000000000000000000..e9ba32799ed838779e49cd4c5011b751
+ * This event does not fire for the entity's actual movement. Only when it + * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving. + * is choosing to start moving.
+ */ + */
+public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent implements Cancellable { +public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent {
+
+ @NotNull private final LivingEntity target; + @NotNull private final LivingEntity target;
+ +
+ @ApiStatus.Internal
+ public SlimeTargetLivingEntityEvent(@NotNull Slime slime, @NotNull LivingEntity target) { + public SlimeTargetLivingEntityEvent(@NotNull Slime slime, @NotNull LivingEntity target) {
+ super(slime); + super(slime);
+ this.target = target; + this.target = target;
@ -164,19 +173,19 @@ index 0000000000000000000000000000000000000000..e9ba32799ed838779e49cd4c5011b751
+ */ + */
+ @NotNull + @NotNull
+ public LivingEntity getTarget() { + public LivingEntity getTarget() {
+ return target; + return this.target;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4683a7237d2ed527fc85b9b4e5b2eaaf5ae3d797 index 0000000000000000000000000000000000000000..2ad9cc1673ffbb8b48349e461d1154d1d4ec2874
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/SlimeWanderEvent.java
@@ -0,0 +1,17 @@ @@ -0,0 +1,19 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Slime; +import org.bukkit.entity.Slime;
+import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -185,7 +194,9 @@ index 0000000000000000000000000000000000000000..4683a7237d2ed527fc85b9b4e5b2eaaf
+ * This event does not fire for the entity's actual movement. Only when it + * This event does not fire for the entity's actual movement. Only when it
+ * is choosing to start moving. + * is choosing to start moving.
+ */ + */
+public class SlimeWanderEvent extends SlimePathfindEvent implements Cancellable { +public class SlimeWanderEvent extends SlimePathfindEvent {
+
+ @ApiStatus.Internal
+ public SlimeWanderEvent(@NotNull Slime slime) { + public SlimeWanderEvent(@NotNull Slime slime) {
+ super(slime); + super(slime);
+ } + }

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add PhantomPreSpawnEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..d8f3f1c354331bc5e6fc1d9aa013476baf2daf05 index 0000000000000000000000000000000000000000..ff7d9ff618ab821eeece6923a694a9a4eea8585d
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/PhantomPreSpawnEvent.java
@@ -0,0 +1,33 @@ @@ -0,0 +1,32 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
@ -18,13 +18,12 @@ index 0000000000000000000000000000000000000000..d8f3f1c354331bc5e6fc1d9aa013476b
+import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+ +
+/** +/**
+ * Called when a phantom is spawned for an exhausted player + * Called when a phantom is spawned for an exhausted player
+ */ + */
+public class PhantomPreSpawnEvent extends PreCreatureSpawnEvent { +public class PhantomPreSpawnEvent extends PreCreatureSpawnEvent {
+
+ @NotNull private final Entity entity; + @NotNull private final Entity entity;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
@ -36,11 +35,11 @@ index 0000000000000000000000000000000000000000..d8f3f1c354331bc5e6fc1d9aa013476b
+ /** + /**
+ * Get the entity this phantom is spawning for + * Get the entity this phantom is spawning for
+ * + *
+ * @return Entity + * @return the Entity
+ */ + */
+ @NotNull + @NotNull
+ public Entity getSpawningEntity() { + public Entity getSpawningEntity() {
+ return entity; + return this.entity;
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/entity/Phantom.java b/src/main/java/org/bukkit/entity/Phantom.java diff --git a/src/main/java/org/bukkit/entity/Phantom.java b/src/main/java/org/bukkit/entity/Phantom.java

Datei anzeigen

@ -6,16 +6,17 @@ Subject: [PATCH] Add More Creeper API
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..e9768c919a1860881802ab68eff559874590ac1c index 0000000000000000000000000000000000000000..e86500337f26fcb6bb04545c68c67df32021ce25
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/CreeperIgniteEvent.java
@@ -0,0 +1,56 @@ @@ -0,0 +1,60 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Creeper; +import org.bukkit.entity.Creeper;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -24,10 +25,13 @@ index 0000000000000000000000000000000000000000..e9768c919a1860881802ab68eff55987
+ * {@link Creeper#setIgnited(boolean)}. + * {@link Creeper#setIgnited(boolean)}.
+ */ + */
+public class CreeperIgniteEvent extends EntityEvent implements Cancellable { +public class CreeperIgniteEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean canceled;
+ private boolean ignited;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean ignited;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public CreeperIgniteEvent(@NotNull Creeper creeper, boolean ignited) { + public CreeperIgniteEvent(@NotNull Creeper creeper, boolean ignited) {
+ super(creeper); + super(creeper);
+ this.ignited = ignited; + this.ignited = ignited;
@ -36,11 +40,11 @@ index 0000000000000000000000000000000000000000..e9768c919a1860881802ab68eff55987
+ @NotNull + @NotNull
+ @Override + @Override
+ public Creeper getEntity() { + public Creeper getEntity() {
+ return (Creeper) entity; + return (Creeper) super.getEntity();
+ } + }
+ +
+ public boolean isIgnited() { + public boolean isIgnited() {
+ return ignited; + return this.ignited;
+ } + }
+ +
+ public void setIgnited(boolean ignited) { + public void setIgnited(boolean ignited) {
@ -48,22 +52,22 @@ index 0000000000000000000000000000000000000000..e9768c919a1860881802ab68eff55987
+ } + }
+ +
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return canceled; + return this.cancelled;
+ } + }
+ +
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ canceled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/entity/Creeper.java b/src/main/java/org/bukkit/entity/Creeper.java diff --git a/src/main/java/org/bukkit/entity/Creeper.java b/src/main/java/org/bukkit/entity/Creeper.java

Datei anzeigen

@ -12,36 +12,36 @@ Dropped as it does not apply due to the earlier PreCreatureSpawnEvent patch not
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..48cff063594840a07aeaf35513780e28ea019a76 index 0000000000000000000000000000000000000000..9a450a0095ed0aa9c92655c2f4e5732bccdd59c9
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+
+import com.google.common.base.Preconditions;
+import org.bukkit.Location; +import org.bukkit.Location;
+import org.bukkit.entity.EntityType; +import org.bukkit.entity.EntityType;
+import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called before an entity is spawned into a world by a spawner. + * Called before an entity is spawned into a world by a spawner.
+ * + * <p>
+ * This only includes the spawner's location and not the full BlockState snapshot for performance reasons. + * This only includes the spawner's location and not the full BlockState snapshot for performance reasons.
+ * If you really need it you have to get the spawner yourself. + * If you really need it you have to get the spawner yourself.
+ */ + */
+
+public class PreSpawnerSpawnEvent extends PreCreatureSpawnEvent { +public class PreSpawnerSpawnEvent extends PreCreatureSpawnEvent {
+
+ @NotNull private final Location spawnerLocation; + @NotNull private final Location spawnerLocation;
+ +
+ @ApiStatus.Internal
+ public PreSpawnerSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull Location spawnerLocation) { + public PreSpawnerSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull Location spawnerLocation) {
+ super(location, type, CreatureSpawnEvent.SpawnReason.SPAWNER); + super(location, type, CreatureSpawnEvent.SpawnReason.SPAWNER);
+ this.spawnerLocation = Preconditions.checkNotNull(spawnerLocation, "Spawner location may not be null"); + this.spawnerLocation = spawnerLocation;
+ } + }
+ +
+ @NotNull + @NotNull
+ public Location getSpawnerLocation() { + public Location getSpawnerLocation() {
+ return spawnerLocation; + return this.spawnerLocation;
+ } + }
+} +}

Datei anzeigen

@ -6,25 +6,29 @@ Subject: [PATCH] Turtle API
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..021356d151ed638068e3e89b8cc77b3795883233 index 0000000000000000000000000000000000000000..cfbc8aaf862ac90e794ee38bf8a6cb9ea414b13e
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java
@@ -0,0 +1,49 @@ @@ -0,0 +1,53 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.Turtle; +import org.bukkit.entity.Turtle;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when a Turtle decides to go home + * Fired when a Turtle decides to go home
+ */ + */
+public class TurtleGoHomeEvent extends EntityEvent implements Cancellable { +public class TurtleGoHomeEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled = false;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public TurtleGoHomeEvent(@NotNull Turtle turtle) { + public TurtleGoHomeEvent(@NotNull Turtle turtle) {
+ super(turtle); + super(turtle);
+ } + }
@ -36,35 +40,35 @@ index 0000000000000000000000000000000000000000..021356d151ed638068e3e89b8cc77b37
+ */ + */
+ @NotNull + @NotNull
+ public Turtle getEntity() { + public Turtle getEntity() {
+ return (Turtle) entity; + return (Turtle) super.getEntity();
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..bcc8dba50e3a3df0206c4827bb468bf884837b8b index 0000000000000000000000000000000000000000..e917e64e8ea266a3fc7387c42aad95927f0f0501
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java
@@ -0,0 +1,87 @@ @@ -0,0 +1,92 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
@ -72,18 +76,23 @@ index 0000000000000000000000000000000000000000..bcc8dba50e3a3df0206c4827bb468bf8
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when a Turtle lays eggs + * Fired when a Turtle lays eggs
+ */ + */
+public class TurtleLayEggEvent extends EntityEvent implements Cancellable { +public class TurtleLayEggEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull + @NotNull
+ private final Location location; + private final Location location;
+ private int eggCount; + private int eggCount;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public TurtleLayEggEvent(@NotNull Turtle turtle, @NotNull Location location, int eggCount) { + public TurtleLayEggEvent(@NotNull Turtle turtle, @NotNull Location location, int eggCount) {
+ super(turtle); + super(turtle);
+ this.location = location; + this.location = location;
@ -97,7 +106,7 @@ index 0000000000000000000000000000000000000000..bcc8dba50e3a3df0206c4827bb468bf8
+ */ + */
+ @NotNull + @NotNull
+ public Turtle getEntity() { + public Turtle getEntity() {
+ return (Turtle) entity; + return (Turtle) super.getEntity();
+ } + }
+ +
+ /** + /**
@ -107,7 +116,7 @@ index 0000000000000000000000000000000000000000..bcc8dba50e3a3df0206c4827bb468bf8
+ */ + */
+ @NotNull + @NotNull
+ public Location getLocation() { + public Location getLocation() {
+ return location; + return this.location;
+ } + }
+ +
+ /** + /**
@ -116,7 +125,7 @@ index 0000000000000000000000000000000000000000..bcc8dba50e3a3df0206c4827bb468bf8
+ * @return Number of eggs + * @return Number of eggs
+ */ + */
+ public int getEggCount() { + public int getEggCount() {
+ return eggCount; + return this.eggCount;
+ } + }
+ +
+ /** + /**
@ -126,7 +135,7 @@ index 0000000000000000000000000000000000000000..bcc8dba50e3a3df0206c4827bb468bf8
+ */ + */
+ public void setEggCount(int eggCount) { + public void setEggCount(int eggCount) {
+ if (eggCount < 1) { + if (eggCount < 1) {
+ cancelled = true; + this.cancelled = true;
+ return; + return;
+ } + }
+ this.eggCount = Math.min(eggCount, 4); + this.eggCount = Math.min(eggCount, 4);
@ -134,30 +143,30 @@ index 0000000000000000000000000000000000000000..bcc8dba50e3a3df0206c4827bb468bf8
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..abeb24fccda2acfdb0dfdadacb8fe688bd97cf78 index 0000000000000000000000000000000000000000..5cdc6b0c3db43279e2bb8043922b31f750ddb3f5
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java
@@ -0,0 +1,62 @@ @@ -0,0 +1,66 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
@ -165,16 +174,20 @@ index 0000000000000000000000000000000000000000..abeb24fccda2acfdb0dfdadacb8fe688
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when a Turtle starts digging to lay eggs + * Fired when a Turtle starts digging to lay eggs
+ */ + */
+public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable { +public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled = false;
+ @NotNull private final Location location;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private final Location location;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public TurtleStartDiggingEvent(@NotNull Turtle turtle, @NotNull Location location) { + public TurtleStartDiggingEvent(@NotNull Turtle turtle, @NotNull Location location) {
+ super(turtle); + super(turtle);
+ this.location = location; + this.location = location;
@ -187,7 +200,7 @@ index 0000000000000000000000000000000000000000..abeb24fccda2acfdb0dfdadacb8fe688
+ */ + */
+ @NotNull + @NotNull
+ public Turtle getEntity() { + public Turtle getEntity() {
+ return (Turtle) entity; + return (Turtle) super.getEntity();
+ } + }
+ +
+ /** + /**
@ -197,27 +210,27 @@ index 0000000000000000000000000000000000000000..abeb24fccda2acfdb0dfdadacb8fe688
+ */ + */
+ @NotNull + @NotNull
+ public Location getLocation() { + public Location getLocation() {
+ return location; + return this.location;
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/entity/Turtle.java b/src/main/java/org/bukkit/entity/Turtle.java diff --git a/src/main/java/org/bukkit/entity/Turtle.java b/src/main/java/org/bukkit/entity/Turtle.java

Datei anzeigen

@ -8,10 +8,10 @@ Subject: [PATCH] Add spectator target events
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..b8ec7ef2d4ef0683cc0d6ca86885dd9a01f47e16 index 0000000000000000000000000000000000000000..a70a64d2273414d95d77e601a41a208cce78e345
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerStartSpectatingEntityEvent.java
@@ -0,0 +1,67 @@ @@ -0,0 +1,71 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..b8ec7ef2d4ef0683cc0d6ca86885dd9a
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -26,11 +27,14 @@ index 0000000000000000000000000000000000000000..b8ec7ef2d4ef0683cc0d6ca86885dd9a
+ */ + */
+public class PlayerStartSpectatingEntityEvent extends PlayerEvent implements Cancellable { +public class PlayerStartSpectatingEntityEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ private boolean cancelled; +
+ @NotNull private final Entity currentSpectatorTarget; + @NotNull private final Entity currentSpectatorTarget;
+ @NotNull private final Entity newSpectatorTarget; + @NotNull private final Entity newSpectatorTarget;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerStartSpectatingEntityEvent(@NotNull Player player, @NotNull Entity currentSpectatorTarget, @NotNull Entity newSpectatorTarget) { + public PlayerStartSpectatingEntityEvent(@NotNull Player player, @NotNull Entity currentSpectatorTarget, @NotNull Entity newSpectatorTarget) {
+ super(player); + super(player);
+ this.currentSpectatorTarget = currentSpectatorTarget; + this.currentSpectatorTarget = currentSpectatorTarget;
@ -44,7 +48,7 @@ index 0000000000000000000000000000000000000000..b8ec7ef2d4ef0683cc0d6ca86885dd9a
+ */ + */
+ @NotNull + @NotNull
+ public Entity getCurrentSpectatorTarget() { + public Entity getCurrentSpectatorTarget() {
+ return currentSpectatorTarget; + return this.currentSpectatorTarget;
+ } + }
+ +
+ /** + /**
@ -54,12 +58,12 @@ index 0000000000000000000000000000000000000000..b8ec7ef2d4ef0683cc0d6ca86885dd9a
+ */ + */
+ @NotNull + @NotNull
+ public Entity getNewSpectatorTarget() { + public Entity getNewSpectatorTarget() {
+ return newSpectatorTarget; + return this.newSpectatorTarget;
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
@ -70,21 +74,21 @@ index 0000000000000000000000000000000000000000..b8ec7ef2d4ef0683cc0d6ca86885dd9a
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
+ +
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..693d119ab920a1bd0d1b5a0feb092631715ec0ad index 0000000000000000000000000000000000000000..a6a5ebc534cc380740ba42790149c8b85f52aabb
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerStopSpectatingEntityEvent.java
@@ -0,0 +1,54 @@ @@ -0,0 +1,57 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
@ -92,6 +96,7 @@ index 0000000000000000000000000000000000000000..693d119ab920a1bd0d1b5a0feb092631
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -99,10 +104,12 @@ index 0000000000000000000000000000000000000000..693d119ab920a1bd0d1b5a0feb092631
+ */ + */
+public class PlayerStopSpectatingEntityEvent extends PlayerEvent implements Cancellable { +public class PlayerStopSpectatingEntityEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ private boolean cancelled;
+ @NotNull private final Entity spectatorTarget;
+ +
+ @NotNull private final Entity spectatorTarget;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerStopSpectatingEntityEvent(@NotNull Player player, @NotNull Entity spectatorTarget) { + public PlayerStopSpectatingEntityEvent(@NotNull Player player, @NotNull Entity spectatorTarget) {
+ super(player); + super(player);
+ this.spectatorTarget = spectatorTarget; + this.spectatorTarget = spectatorTarget;
@ -115,12 +122,12 @@ index 0000000000000000000000000000000000000000..693d119ab920a1bd0d1b5a0feb092631
+ */ + */
+ @NotNull + @NotNull
+ public Entity getSpectatorTarget() { + public Entity getSpectatorTarget() {
+ return spectatorTarget; + return this.spectatorTarget;
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
@ -131,11 +138,11 @@ index 0000000000000000000000000000000000000000..693d119ab920a1bd0d1b5a0feb092631
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -35,10 +35,10 @@ is undefined.
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..12c1c6fe9dc8dc5f5faf6dcf99f6857219ef22b8 index 0000000000000000000000000000000000000000..d0fb13adc140f1ca74d0c3448f92baa60684f3e2
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java
@@ -0,0 +1,95 @@ @@ -0,0 +1,88 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
@ -46,6 +46,9 @@ index 0000000000000000000000000000000000000000..12c1c6fe9dc8dc5f5faf6dcf99f68572
+ +
+import java.net.InetAddress; +import java.net.InetAddress;
+import java.util.UUID; +import java.util.UUID;
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -53,45 +56,35 @@ index 0000000000000000000000000000000000000000..12c1c6fe9dc8dc5f5faf6dcf99f68572
+ * This event is invoked when a player has disconnected. It is guaranteed that, + * This event is invoked when a player has disconnected. It is guaranteed that,
+ * if the server is in online-mode, that the provided uuid and username have been + * if the server is in online-mode, that the provided uuid and username have been
+ * validated. + * validated.
+ * </p>
+ *
+ * <p> + * <p>
+ * The event is invoked for players who have not yet logged into the world, whereas + * The event is invoked for players who have not yet logged into the world, whereas
+ * {@link org.bukkit.event.player.PlayerQuitEvent} is only invoked on players who have logged into the world. + * {@link PlayerQuitEvent} is only invoked on players who have logged into the world.
+ * </p>
+ *
+ * <p> + * <p>
+ * The event is invoked for players who have already logged into the world, + * The event is invoked for players who have already logged into the world,
+ * although whether or not the player exists in the world at the time of + * although whether or not the player exists in the world at the time of
+ * firing is undefined. (That is, whether the plugin can retrieve a Player object + * firing is undefined. (That is, whether the plugin can retrieve a Player object
+ * using the event parameters is undefined). However, it is guaranteed that this + * using the event parameters is undefined). However, it is guaranteed that this
+ * event is invoked AFTER {@link org.bukkit.event.player.PlayerQuitEvent}, if the player has already logged into the world. + * event is invoked AFTER {@link PlayerQuitEvent}, if the player has already logged into the world.
+ * </p>
+ *
+ * <p> + * <p>
+ * This event is guaranteed to never fire unless {@link org.bukkit.event.player.AsyncPlayerPreLoginEvent} has + * This event is guaranteed to never fire unless {@link AsyncPlayerPreLoginEvent} has
+ * been fired beforehand, and this event may not be called in parallel with + * been fired beforehand, and this event may not be called in parallel with
+ * {@link org.bukkit.event.player.AsyncPlayerPreLoginEvent} for the same connection. + * {@link AsyncPlayerPreLoginEvent} for the same connection.
+ * </p>
+ *
+ * <p> + * <p>
+ * Cancelling the {@link org.bukkit.event.player.AsyncPlayerPreLoginEvent} guarantees the corresponding + * Cancelling the {@link AsyncPlayerPreLoginEvent} guarantees the corresponding
+ * {@code PlayerConnectionCloseEvent} is never called. + * {@code PlayerConnectionCloseEvent} is never called.
+ * </p>
+ *
+ * <p> + * <p>
+ * The event may be invoked asynchronously or synchronously. Plugins should check + * The event may be invoked asynchronously or synchronously. Plugins should check
+ * {@link Event#isAsynchronous()} and handle accordingly. + * {@link Event#isAsynchronous()} and handle accordingly.
+ * </p>
+ */ + */
+public class PlayerConnectionCloseEvent extends Event { +public class PlayerConnectionCloseEvent extends Event {
+ +
+ private static final HandlerList HANDLERS = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final UUID playerUniqueId; + @NotNull private final UUID playerUniqueId;
+ @NotNull private final String playerName; + @NotNull private final String playerName;
+ @NotNull private final InetAddress ipAddress; + @NotNull private final InetAddress ipAddress;
+ +
+ @ApiStatus.Internal
+ public PlayerConnectionCloseEvent(@NotNull final UUID playerUniqueId, @NotNull final String playerName, @NotNull final InetAddress ipAddress, final boolean async) { + public PlayerConnectionCloseEvent(@NotNull final UUID playerUniqueId, @NotNull final String playerName, @NotNull final InetAddress ipAddress, final boolean async) {
+ super(async); + super(async);
+ this.playerUniqueId = playerUniqueId; + this.playerUniqueId = playerUniqueId;
@ -126,11 +119,11 @@ index 0000000000000000000000000000000000000000..12c1c6fe9dc8dc5f5faf6dcf99f68572
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -12,7 +12,7 @@ This can replace many uses of BlockPhysicsEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..278f26bed374fe79ff3cd135a76f019bd21906e4 index 0000000000000000000000000000000000000000..d0421a4cbcb672cc06b40ad41fc06a67f6d2dbbb
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java
@@ -0,0 +1,123 @@ @@ -0,0 +1,123 @@
@ -30,23 +30,22 @@ index 0000000000000000000000000000000000000000..278f26bed374fe79ff3cd135a76f019b
+ * Fired anytime the server intends to 'destroy' a block through some triggering reason. + * Fired anytime the server intends to 'destroy' a block through some triggering reason.
+ * This does not fire anytime a block is set to air, but only with more direct triggers such + * This does not fire anytime a block is set to air, but only with more direct triggers such
+ * as physics updates, pistons, Entities changing blocks, commands set to "Destroy". + * as physics updates, pistons, Entities changing blocks, commands set to "Destroy".
+ * + * <p>
+ * This event is associated with the game playing a sound effect at the block in question, when + * This event is associated with the game playing a sound effect at the block in question, when
+ * something can be described as "intend to destroy what is there", + * something can be described as "intend to destroy what is there",
+ * + * <p>
+ * Events such as leaves decaying, pistons retracting (where the block is moving), does NOT fire this event. + * Events such as leaves decaying, pistons retracting (where the block is moving), does NOT fire this event.
+ *
+ */ + */
+public class BlockDestroyEvent extends BlockExpEvent implements Cancellable { +public class BlockDestroyEvent extends BlockExpEvent implements Cancellable {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final BlockData newState; + @NotNull private final BlockData newState;
+ private boolean willDrop; + private boolean willDrop;
+ private boolean playEffect = true; + private boolean playEffect = true;
+ private BlockData effectBlock; + private BlockData effectBlock;
+ +
+ private boolean cancelled = false; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, @NotNull BlockData effectBlock, int xp, boolean willDrop) { + public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, @NotNull BlockData effectBlock, int xp, boolean willDrop) {
@ -58,6 +57,7 @@ index 0000000000000000000000000000000000000000..278f26bed374fe79ff3cd135a76f019b
+ +
+ /** + /**
+ * Get the effect that will be played when the block is broken. + * Get the effect that will be played when the block is broken.
+ *
+ * @return block break effect + * @return block break effect
+ */ + */
+ @NotNull + @NotNull
@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..278f26bed374fe79ff3cd135a76f019b
+ +
+ /** + /**
+ * Sets the effect that will be played when the block is broken. + * Sets the effect that will be played when the block is broken.
+ * Note: {@link BlockDestroyEvent#playEffect()} must be true in order for this effect to be + * Note: {@link BlockDestroyEvent#playEffect()} must be {@code true} in order for this effect to be
+ * played. + * played.
+ * + *
+ * @param effectBlock block effect + * @param effectBlock block effect
@ -81,7 +81,7 @@ index 0000000000000000000000000000000000000000..278f26bed374fe79ff3cd135a76f019b
+ */ + */
+ @NotNull + @NotNull
+ public BlockData getNewState() { + public BlockData getNewState() {
+ return newState; + return this.newState;
+ } + }
+ +
+ /** + /**
@ -117,25 +117,25 @@ index 0000000000000000000000000000000000000000..278f26bed374fe79ff3cd135a76f019b
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * If the event is cancelled, the block will remain in its previous state. + * If the event is cancelled, the block will remain in its previous state.
+ * @param cancel true if you wish to cancel this event
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,14 +6,15 @@ Subject: [PATCH] Add WhitelistToggleEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/server/WhitelistToggleEvent.java b/src/main/java/com/destroystokyo/paper/event/server/WhitelistToggleEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/server/WhitelistToggleEvent.java b/src/main/java/com/destroystokyo/paper/event/server/WhitelistToggleEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..fdd5eedb2b7401439912a3a4343a920f32edc860 index 0000000000000000000000000000000000000000..22fa169c278639f31aec2695259963038de0af8a
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/server/WhitelistToggleEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/WhitelistToggleEvent.java
@@ -0,0 +1,40 @@ @@ -0,0 +1,43 @@
+package com.destroystokyo.paper.event.server; +package com.destroystokyo.paper.event.server;
+ +
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -22,10 +23,12 @@ index 0000000000000000000000000000000000000000..fdd5eedb2b7401439912a3a4343a920f
+ * @author Mark Vainomaa + * @author Mark Vainomaa
+ */ + */
+public class WhitelistToggleEvent extends Event { +public class WhitelistToggleEvent extends Event {
+ private static final HandlerList handlers = new HandlerList();
+ +
+ private boolean enabled; + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final boolean enabled;
+
+ @ApiStatus.Internal
+ public WhitelistToggleEvent(boolean enabled) { + public WhitelistToggleEvent(boolean enabled) {
+ this.enabled = enabled; + this.enabled = enabled;
+ } + }
@ -36,17 +39,17 @@ index 0000000000000000000000000000000000000000..fdd5eedb2b7401439912a3a4343a920f
+ * @return Whether whitelist is going to be enabled or not + * @return Whether whitelist is going to be enabled or not
+ */ + */
+ public boolean isEnabled() { + public boolean isEnabled() {
+ return enabled; + return this.enabled;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,16 +6,18 @@ Subject: [PATCH] Add GS4 Query event
diff --git a/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java b/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java b/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda0f42df5b index 0000000000000000000000000000000000000000..8edc33bde29e967cec488d0f5e2f1097291978a6
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java
@@ -0,0 +1,412 @@ @@ -0,0 +1,424 @@
+package com.destroystokyo.paper.event.server; +package com.destroystokyo.paper.event.server;
+ +
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList;
+import org.bukkit.Server;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+import java.net.InetAddress; +import java.net.InetAddress;
@ -25,79 +27,76 @@ index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda
+import java.util.List; +import java.util.List;
+ +
+/** +/**
+ * This event is fired if server is getting queried over GS4 Query protocol + * This event is fired if server is getting queried over GS4 Query protocol.
+ * + * <br>
+ * Adapted from Velocity's ProxyQueryEvent + * Adapted from Velocity's ProxyQueryEvent
+ * + *
+ * @author Mark Vainomaa + * @author Mark Vainomaa
+ */ + */
+public final class GS4QueryEvent extends Event { +public final class GS4QueryEvent extends Event {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final QueryType queryType; + private final QueryType queryType;
+ private final InetAddress querierAddress; + private final InetAddress querierAddress;
+ private QueryResponse response; + private QueryResponse response;
+ +
+ @ApiStatus.Internal
+ public GS4QueryEvent(@NotNull QueryType queryType, @NotNull InetAddress querierAddress, @NotNull QueryResponse response) { + public GS4QueryEvent(@NotNull QueryType queryType, @NotNull InetAddress querierAddress, @NotNull QueryResponse response) {
+ super(true); // should always be called async + super(true); // should always be called async
+ this.queryType = Preconditions.checkNotNull(queryType, "queryType"); + this.queryType = queryType;
+ this.querierAddress = Preconditions.checkNotNull(querierAddress, "querierAddress"); + this.querierAddress = querierAddress;
+ this.response = Preconditions.checkNotNull(response, "response"); + this.response = response;
+ } + }
+ +
+ /** + /**
+ * Get query type + * Get query type
+ *
+ * @return query type + * @return query type
+ */ + */
+ @NotNull + @NotNull
+ public QueryType getQueryType() { + public QueryType getQueryType() {
+ return queryType; + return this.queryType;
+ } + }
+ +
+ /** + /**
+ * Get querier address + * Get querier address
+ *
+ * @return querier address + * @return querier address
+ */ + */
+ @NotNull + @NotNull
+ public InetAddress getQuerierAddress() { + public InetAddress getQuerierAddress() {
+ return querierAddress; + return this.querierAddress;
+ } + }
+ +
+ /** + /**
+ * Get query response + * Get query response
+ *
+ * @return query response + * @return query response
+ */ + */
+ @NotNull + @NotNull
+ public QueryResponse getResponse() { + public QueryResponse getResponse() {
+ return response; + return this.response;
+ } + }
+ +
+ /** + /**
+ * Set query response + * Set query response
+ *
+ * @param response query response + * @param response query response
+ */ + */
+ public void setResponse(@NotNull QueryResponse response) { + public void setResponse(@NotNull QueryResponse response) {
+ this.response = Preconditions.checkNotNull(response, "response"); + this.response = Preconditions.checkNotNull(response, "response");
+ } + }
+ +
+ @Override
+ public String toString() {
+ return "GS4QueryEvent{" +
+ "queryType=" + queryType +
+ ", querierAddress=" + querierAddress +
+ ", response=" + response +
+ '}';
+ }
+
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ /** + /**
@ -114,10 +113,10 @@ index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda
+ * Full query asks pretty much everything present on this event (only hardcoded values cannot be modified here). + * Full query asks pretty much everything present on this event (only hardcoded values cannot be modified here).
+ */ + */
+ FULL + FULL
+ ;
+ } + }
+ +
+ public final static class QueryResponse { + public final static class QueryResponse {
+
+ private final String motd; + private final String motd;
+ private final String gameVersion; + private final String gameVersion;
+ private final String map; + private final String map;
@ -143,95 +142,105 @@ index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda
+ } + }
+ +
+ /** + /**
+ * Get motd which will be used to reply to the query. By default it is {@link org.bukkit.Server#getMotd()}. + * Get motd which will be used to reply to the query. By default it is {@link Server#getMotd()}.
+ *
+ * @return motd + * @return motd
+ */ + */
+ @NotNull + @NotNull
+ public String getMotd() { + public String getMotd() {
+ return motd; + return this.motd;
+ } + }
+ +
+ /** + /**
+ * Get game version which will be used to reply to the query. By default supported Minecraft versions range is sent. + * Get game version which will be used to reply to the query. By default supported Minecraft versions range is sent.
+ *
+ * @return game version + * @return game version
+ */ + */
+ @NotNull + @NotNull
+ public String getGameVersion() { + public String getGameVersion() {
+ return gameVersion; + return this.gameVersion;
+ } + }
+ +
+ /** + /**
+ * Get map name which will be used to reply to the query. By default {@code world} is sent. + * Get map name which will be used to reply to the query. By default {@code world} is sent.
+ *
+ * @return map name + * @return map name
+ */ + */
+ @NotNull + @NotNull
+ public String getMap() { + public String getMap() {
+ return map; + return this.map;
+ } + }
+ +
+ /** + /**
+ * Get current online player count which will be used to reply to the query. + * Get current online player count which will be used to reply to the query.
+ *
+ * @return online player count + * @return online player count
+ */ + */
+ public int getCurrentPlayers() { + public int getCurrentPlayers() {
+ return currentPlayers; + return this.currentPlayers;
+ } + }
+ +
+ /** + /**
+ * Get max player count which will be used to reply to the query. + * Get max player count which will be used to reply to the query.
+ *
+ * @return max player count + * @return max player count
+ */ + */
+ public int getMaxPlayers() { + public int getMaxPlayers() {
+ return maxPlayers; + return this.maxPlayers;
+ } + }
+ +
+ /** + /**
+ * Get server (public facing) hostname + * Get server (public facing) hostname.
+ *
+ * @return server hostname + * @return server hostname
+ */ + */
+ @NotNull + @NotNull
+ public String getHostname() { + public String getHostname() {
+ return hostname; + return this.hostname;
+ } + }
+ +
+ /** + /**
+ * Get server (public facing) port + * Get server (public facing) port.
+ *
+ * @return server port + * @return server port
+ */ + */
+ public int getPort() { + public int getPort() {
+ return port; + return this.port;
+ } + }
+ +
+ /** + /**
+ * Get collection of players which will be used to reply to the query. + * Get collection of players which will be used to reply to the query.
+ *
+ * @return collection of players + * @return collection of players
+ */ + */
+ @NotNull + @NotNull
+ public Collection<String> getPlayers() { + public Collection<String> getPlayers() {
+ return players; + return this.players;
+ } + }
+ +
+ /** + /**
+ * Get server software (name and version) which will be used to reply to the query. + * Get server software (name and version) which will be used to reply to the query.
+ *
+ * @return server software + * @return server software
+ */ + */
+ @NotNull + @NotNull
+ public String getServerVersion() { + public String getServerVersion() {
+ return serverVersion; + return this.serverVersion;
+ } + }
+ +
+ /** + /**
+ * Get list of plugins which will be used to reply to the query. + * Get list of plugins which will be used to reply to the query.
+ *
+ * @return collection of plugins + * @return collection of plugins
+ */ + */
+ @NotNull + @NotNull
+ public Collection<PluginInformation> getPlugins() { + public Collection<PluginInformation> getPlugins() {
+ return plugins; + return this.plugins;
+ } + }
+ +
+
+ /** + /**
+ * Creates a new {@link Builder} instance from data represented by this response + * Creates a new {@link Builder} instance from data represented by this response.
+ *
+ * @return {@link QueryResponse} builder + * @return {@link QueryResponse} builder
+ */ + */
+ @NotNull + @NotNull
@ -250,7 +259,8 @@ index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda
+ } + }
+ +
+ /** + /**
+ * Creates a new {@link Builder} instance + * Creates a new {@link Builder} instance.
+ *
+ * @return {@link QueryResponse} builder + * @return {@link QueryResponse} builder
+ */ + */
+ @NotNull + @NotNull
@ -272,8 +282,8 @@ index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda
+ private int maxPlayers; + private int maxPlayers;
+ private int port; + private int port;
+ +
+ private List<String> players = new ArrayList<>(); + private final List<String> players = new ArrayList<>();
+ private List<PluginInformation> plugins = new ArrayList<>(); + private final List<PluginInformation> plugins = new ArrayList<>();
+ +
+ private Builder() {} + private Builder() {}
+ +
@ -365,7 +375,8 @@ index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda
+ } + }
+ +
+ /** + /**
+ * Builds new {@link QueryResponse} with supplied data + * Builds new {@link QueryResponse} with supplied data.
+ *
+ * @return response + * @return response
+ */ + */
+ @NotNull + @NotNull
@ -389,6 +400,7 @@ index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda
+ * Plugin information + * Plugin information
+ */ + */
+ public static class PluginInformation { + public static class PluginInformation {
+
+ private String name; + private String name;
+ private String version; + private String version;
+ +
@ -399,7 +411,7 @@ index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda
+ +
+ @NotNull + @NotNull
+ public String getName() { + public String getName() {
+ return name; + return this.name;
+ } + }
+ +
+ public void setName(@NotNull String name) { + public void setName(@NotNull String name) {
@ -412,7 +424,7 @@ index 0000000000000000000000000000000000000000..77a19995f6792a182c5a43d6714e7bda
+ +
+ @NotNull + @NotNull
+ public String getVersion() { + public String getVersion() {
+ return version; + return this.version;
+ } + }
+ +
+ @NotNull + @NotNull

Datei anzeigen

@ -6,26 +6,30 @@ Subject: [PATCH] Add PlayerPostRespawnEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerPostRespawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerPostRespawnEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerPostRespawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerPostRespawnEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..31f34b54801f6699ce43355fa2a0a51f1ad0c997 index 0000000000000000000000000000000000000000..16961aac061e78fb84029f8435ab5f7c493b1362
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerPostRespawnEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerPostRespawnEvent.java
@@ -0,0 +1,52 @@ @@ -0,0 +1,56 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired after a player has respawned + * Fired after a player has respawned
+ */ + */
+public class PlayerPostRespawnEvent extends PlayerEvent { +public class PlayerPostRespawnEvent extends PlayerEvent {
+ private final static HandlerList handlers = new HandlerList(); +
+ private final static HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Location respawnedLocation; + private final Location respawnedLocation;
+ private final boolean isBedSpawn; + private final boolean isBedSpawn;
+ +
+ @ApiStatus.Internal
+ public PlayerPostRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnedLocation, final boolean isBedSpawn) { + public PlayerPostRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnedLocation, final boolean isBedSpawn) {
+ super(respawnPlayer); + super(respawnPlayer);
+ this.respawnedLocation = respawnedLocation; + this.respawnedLocation = respawnedLocation;
@ -39,7 +43,7 @@ index 0000000000000000000000000000000000000000..31f34b54801f6699ce43355fa2a0a51f
+ */ + */
+ @NotNull + @NotNull
+ public Location getRespawnedLocation() { + public Location getRespawnedLocation() {
+ return respawnedLocation.clone(); + return this.respawnedLocation.clone();
+ } + }
+ +
+ /** + /**
@ -48,18 +52,18 @@ index 0000000000000000000000000000000000000000..31f34b54801f6699ce43355fa2a0a51f
+ * @return whether the player respawned to their bed + * @return whether the player respawned to their bed
+ */ + */
+ public boolean isBedSpawn() { + public boolean isBedSpawn() {
+ return isBedSpawn; + return this.isBedSpawn;
+ } + }
+ +
+ @Override + @Override
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java b/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java b/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java

Datei anzeigen

@ -7,14 +7,15 @@ Fires event at start and end of a server tick
diff --git a/src/main/java/com/destroystokyo/paper/event/server/ServerTickEndEvent.java b/src/main/java/com/destroystokyo/paper/event/server/ServerTickEndEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/server/ServerTickEndEvent.java b/src/main/java/com/destroystokyo/paper/event/server/ServerTickEndEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..dd7327c70fb72089dec6552317ba28961236db56 index 0000000000000000000000000000000000000000..17e9f39ce1cc7489e936c96f95b8b0579528b222
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/server/ServerTickEndEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/ServerTickEndEvent.java
@@ -0,0 +1,59 @@ @@ -0,0 +1,62 @@
+package com.destroystokyo.paper.event.server; +package com.destroystokyo.paper.event.server;
+ +
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -22,11 +23,13 @@ index 0000000000000000000000000000000000000000..dd7327c70fb72089dec6552317ba2896
+ */ + */
+public class ServerTickEndEvent extends Event { +public class ServerTickEndEvent extends Event {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final int tickNumber; + private final int tickNumber;
+ private final double tickDuration; + private final double tickDuration;
+ private final long timeEnd; + private final long timeEnd;
+ +
+ @ApiStatus.Internal
+ public ServerTickEndEvent(int tickNumber, double tickDuration, long timeRemaining) { + public ServerTickEndEvent(int tickNumber, double tickDuration, long timeRemaining) {
+ this.tickNumber = tickNumber; + this.tickNumber = tickNumber;
+ this.tickDuration = tickDuration; + this.tickDuration = tickDuration;
@ -37,21 +40,21 @@ index 0000000000000000000000000000000000000000..dd7327c70fb72089dec6552317ba2896
+ * @return What tick this was since start (first tick = 1) + * @return What tick this was since start (first tick = 1)
+ */ + */
+ public int getTickNumber() { + public int getTickNumber() {
+ return tickNumber; + return this.tickNumber;
+ } + }
+ +
+ /** + /**
+ * @return Time in milliseconds of how long this tick took + * @return Time in milliseconds of how long this tick took
+ */ + */
+ public double getTickDuration() { + public double getTickDuration() {
+ return tickDuration; + return this.tickDuration;
+ } + }
+ +
+ /** + /**
+ * Amount of nanoseconds remaining before the next tick should start. + * Amount of nanoseconds remaining before the next tick should start.
+ * + * <p>
+ * If this value is negative, then that means the server has exceeded the tick time limit and TPS has been lost. + * If this value is negative, then that means the server has exceeded the tick time limit and TPS has been lost.
+ * + * <p>
+ * Method will continuously return the updated time remaining value. (return value is not static) + * Method will continuously return the updated time remaining value. (return value is not static)
+ * + *
+ * @return Amount of nanoseconds remaining before the next tick should start + * @return Amount of nanoseconds remaining before the next tick should start
@ -62,31 +65,34 @@ index 0000000000000000000000000000000000000000..dd7327c70fb72089dec6552317ba2896
+ +
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/server/ServerTickStartEvent.java b/src/main/java/com/destroystokyo/paper/event/server/ServerTickStartEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/server/ServerTickStartEvent.java b/src/main/java/com/destroystokyo/paper/event/server/ServerTickStartEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..eac85f1f49088bb71afb01eff4d5f53887306461 index 0000000000000000000000000000000000000000..fb5bbfffea8b883e4c8769484a2b64dd895cb617
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/server/ServerTickStartEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/ServerTickStartEvent.java
@@ -0,0 +1,32 @@ @@ -0,0 +1,35 @@
+package com.destroystokyo.paper.event.server; +package com.destroystokyo.paper.event.server;
+ +
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+public class ServerTickStartEvent extends Event { +public class ServerTickStartEvent extends Event {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final int tickNumber; + private final int tickNumber;
+ +
+ @ApiStatus.Internal
+ public ServerTickStartEvent(int tickNumber) { + public ServerTickStartEvent(int tickNumber) {
+ this.tickNumber = tickNumber; + this.tickNumber = tickNumber;
+ } + }
@ -95,16 +101,16 @@ index 0000000000000000000000000000000000000000..eac85f1f49088bb71afb01eff4d5f538
+ * @return What tick this is going be since start (first tick = 1) + * @return What tick this is going be since start (first tick = 1)
+ */ + */
+ public int getTickNumber() { + public int getTickNumber() {
+ return tickNumber; + return this.tickNumber;
+ } + }
+ +
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -8,16 +8,18 @@ Adds a new event similar to PlayerEggThrowEvent, but without the Player requirem
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ThrownEggHatchEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ThrownEggHatchEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ThrownEggHatchEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ThrownEggHatchEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..085d77dde83d6ed13eb83f23cf3e51d380187c9c index 0000000000000000000000000000000000000000..092bab9be36acc0f04c7ea5b3510879169a0a125
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/ThrownEggHatchEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/ThrownEggHatchEvent.java
@@ -0,0 +1,115 @@ @@ -0,0 +1,120 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import com.google.common.base.Preconditions;
+import org.bukkit.entity.Egg; +import org.bukkit.entity.Egg;
+import org.bukkit.entity.EntityType; +import org.bukkit.entity.EntityType;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -26,12 +28,15 @@ index 0000000000000000000000000000000000000000..085d77dde83d6ed13eb83f23cf3e51d3
+ * This event fires for all thrown eggs that may hatch, players, dispensers, etc. + * This event fires for all thrown eggs that may hatch, players, dispensers, etc.
+ */ + */
+public class ThrownEggHatchEvent extends Event { +public class ThrownEggHatchEvent extends Event {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Egg egg; + private final Egg egg;
+ private boolean hatching; + private boolean hatching;
+ private EntityType hatchType;
+ private byte numHatches; + private byte numHatches;
+ private EntityType hatchType;
+ +
+ @ApiStatus.Internal
+ public ThrownEggHatchEvent(@NotNull final Egg egg, final boolean hatching, final byte numHatches, @NotNull final EntityType hatchingType) { + public ThrownEggHatchEvent(@NotNull final Egg egg, final boolean hatching, final byte numHatches, @NotNull final EntityType hatchingType) {
+ this.egg = egg; + this.egg = egg;
+ this.hatching = hatching; + this.hatching = hatching;
@ -46,7 +51,7 @@ index 0000000000000000000000000000000000000000..085d77dde83d6ed13eb83f23cf3e51d3
+ */ + */
+ @NotNull + @NotNull
+ public Egg getEgg() { + public Egg getEgg() {
+ return egg; + return this.egg;
+ } + }
+ +
+ /** + /**
@ -56,13 +61,13 @@ index 0000000000000000000000000000000000000000..085d77dde83d6ed13eb83f23cf3e51d3
+ * @return boolean Whether the egg is going to hatch or not + * @return boolean Whether the egg is going to hatch or not
+ */ + */
+ public boolean isHatching() { + public boolean isHatching() {
+ return hatching; + return this.hatching;
+ } + }
+ +
+ /** + /**
+ * Sets whether the egg will hatch or not. + * Sets whether the egg will hatch or not.
+ * + *
+ * @param hatching true if you want the egg to hatch, false if you want it + * @param hatching {@code true} if you want the egg to hatch, {@code false} if you want it
+ * not to + * not to
+ */ + */
+ public void setHatching(boolean hatching) { + public void setHatching(boolean hatching) {
@ -70,13 +75,13 @@ index 0000000000000000000000000000000000000000..085d77dde83d6ed13eb83f23cf3e51d3
+ } + }
+ +
+ /** + /**
+ * Get the type of the mob being hatched (EntityType.CHICKEN by default) + * Get the type of the mob being hatched ({@link EntityType#CHICKEN} by default)
+ * + *
+ * @return The type of the mob being hatched by the egg + * @return The type of the mob being hatched by the egg
+ */ + */
+ @NotNull + @NotNull
+ public EntityType getHatchingType() { + public EntityType getHatchingType() {
+ return hatchType; + return this.hatchType;
+ } + }
+ +
+ /** + /**
@ -85,7 +90,7 @@ index 0000000000000000000000000000000000000000..085d77dde83d6ed13eb83f23cf3e51d3
+ * @param hatchType The type of the mob being hatched by the egg + * @param hatchType The type of the mob being hatched by the egg
+ */ + */
+ public void setHatchingType(@NotNull EntityType hatchType) { + public void setHatchingType(@NotNull EntityType hatchType) {
+ if (!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!"); + Preconditions.checkArgument(hatchType.isSpawnable(), "Can't spawn that entity type from an egg!");
+ this.hatchType = hatchType; + this.hatchType = hatchType;
+ } + }
+ +
@ -93,22 +98,22 @@ index 0000000000000000000000000000000000000000..085d77dde83d6ed13eb83f23cf3e51d3
+ * Get the number of mob hatches from the egg. By default the number will + * Get the number of mob hatches from the egg. By default the number will
+ * be the number the server would've done + * be the number the server would've done
+ * <ul> + * <ul>
+ * <li>7/8 chance of being 0 + * <li>7/8 chance of being 0
+ * <li>31/256 ~= 1/8 chance to be 1 + * <li>31/256 ~= 1/8 chance to be 1
+ * <li>1/256 chance to be 4 + * <li>1/256 chance to be 4
+ * </ul> + * </ul>
+ * + *
+ * @return The number of mobs going to be hatched by the egg + * @return The number of mobs going to be hatched by the egg
+ */ + */
+ public byte getNumHatches() { + public byte getNumHatches() {
+ return numHatches; + return this.numHatches;
+ } + }
+ +
+ /** + /**
+ * Change the number of mobs coming out of the hatched egg + * Change the number of mobs coming out of the hatched egg
+ * <p> + * <p>
+ * The boolean hatching will override this number. Ie. If hatching = + * The boolean hatching will override this number. I.e. If hatching is
+ * false, this number will not matter + * {@code false}, this number will not matter
+ * + *
+ * @param numHatches The number of mobs coming out of the egg + * @param numHatches The number of mobs coming out of the egg
+ */ + */
@ -119,11 +124,11 @@ index 0000000000000000000000000000000000000000..085d77dde83d6ed13eb83f23cf3e51d3
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,16 +6,17 @@ Subject: [PATCH] Entity Jump API
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityJumpEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityJumpEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityJumpEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityJumpEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..f0067c2e953d18e1a33536980071ba3f0152ecb4 index 0000000000000000000000000000000000000000..a6306c957fcacdcbcc8037b4ee33a167d21ff29e
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityJumpEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityJumpEvent.java
@@ -0,0 +1,46 @@ @@ -0,0 +1,50 @@
+package com.destroystokyo.paper.event.entity; +package com.destroystokyo.paper.event.entity;
+ +
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -24,9 +25,12 @@ index 0000000000000000000000000000000000000000..f0067c2e953d18e1a33536980071ba3f
+ * Cancelling the event will stop the entity from jumping + * Cancelling the event will stop the entity from jumping
+ */ + */
+public class EntityJumpEvent extends EntityEvent implements Cancellable { +public class EntityJumpEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean canceled;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityJumpEvent(@NotNull LivingEntity entity) { + public EntityJumpEvent(@NotNull LivingEntity entity) {
+ super(entity); + super(entity);
+ } + }
@ -34,26 +38,26 @@ index 0000000000000000000000000000000000000000..f0067c2e953d18e1a33536980071ba3f
+ @NotNull + @NotNull
+ @Override + @Override
+ public LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return (LivingEntity) entity; + return (LivingEntity) super.getEntity();
+ } + }
+ +
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return canceled; + return this.cancelled;
+ } + }
+ +
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ canceled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java

Datei anzeigen

@ -90,10 +90,10 @@ index 0000000000000000000000000000000000000000..4a0c39405d4fbed457787e3c6ded4cc6
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerClientOptionsChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerClientOptionsChangeEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerClientOptionsChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerClientOptionsChangeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..cf67dc7d465223710adbf2b798109f525d3b057d index 0000000000000000000000000000000000000000..1757055d821d9ec7c728aa6c1b52fa6aea591ae5
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerClientOptionsChangeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerClientOptionsChangeEvent.java
@@ -0,0 +1,134 @@ @@ -0,0 +1,136 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import com.destroystokyo.paper.ClientOption; +import com.destroystokyo.paper.ClientOption;
@ -103,6 +103,7 @@ index 0000000000000000000000000000000000000000..cf67dc7d465223710adbf2b798109f52
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.MainHand; +import org.bukkit.inventory.MainHand;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+import java.util.Map; +import java.util.Map;
@ -112,7 +113,7 @@ index 0000000000000000000000000000000000000000..cf67dc7d465223710adbf2b798109f52
+ */ + */
+public class PlayerClientOptionsChangeEvent extends PlayerEvent { +public class PlayerClientOptionsChangeEvent extends PlayerEvent {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final String locale; + private final String locale;
+ private final int viewDistance; + private final int viewDistance;
@ -136,6 +137,7 @@ index 0000000000000000000000000000000000000000..cf67dc7d465223710adbf2b798109f52
+ this.textFilteringEnabled = false; + this.textFilteringEnabled = false;
+ } + }
+ +
+ @ApiStatus.Internal
+ public PlayerClientOptionsChangeEvent(@NotNull Player player, @NotNull Map<ClientOption<?>, ?> options) { + public PlayerClientOptionsChangeEvent(@NotNull Player player, @NotNull Map<ClientOption<?>, ?> options) {
+ super(player); + super(player);
+ +
@ -151,81 +153,81 @@ index 0000000000000000000000000000000000000000..cf67dc7d465223710adbf2b798109f52
+ +
+ @NotNull + @NotNull
+ public String getLocale() { + public String getLocale() {
+ return locale; + return this.locale;
+ } + }
+ +
+ public boolean hasLocaleChanged() { + public boolean hasLocaleChanged() {
+ return !locale.equals(player.getClientOption(ClientOption.LOCALE)); + return !this.locale.equals(this.player.getClientOption(ClientOption.LOCALE));
+ } + }
+ +
+ public int getViewDistance() { + public int getViewDistance() {
+ return viewDistance; + return this.viewDistance;
+ } + }
+ +
+ public boolean hasViewDistanceChanged() { + public boolean hasViewDistanceChanged() {
+ return viewDistance != player.getClientOption(ClientOption.VIEW_DISTANCE); + return this.viewDistance != this.player.getClientOption(ClientOption.VIEW_DISTANCE);
+ } + }
+ +
+ @NotNull + @NotNull
+ public ChatVisibility getChatVisibility() { + public ChatVisibility getChatVisibility() {
+ return chatVisibility; + return this.chatVisibility;
+ } + }
+ +
+ public boolean hasChatVisibilityChanged() { + public boolean hasChatVisibilityChanged() {
+ return chatVisibility != player.getClientOption(ClientOption.CHAT_VISIBILITY); + return this.chatVisibility != this.player.getClientOption(ClientOption.CHAT_VISIBILITY);
+ } + }
+ +
+ public boolean hasChatColorsEnabled() { + public boolean hasChatColorsEnabled() {
+ return chatColors; + return this.chatColors;
+ } + }
+ +
+ public boolean hasChatColorsEnabledChanged() { + public boolean hasChatColorsEnabledChanged() {
+ return chatColors != player.getClientOption(ClientOption.CHAT_COLORS_ENABLED); + return this.chatColors != this.player.getClientOption(ClientOption.CHAT_COLORS_ENABLED);
+ } + }
+ +
+ @NotNull + @NotNull
+ public SkinParts getSkinParts() { + public SkinParts getSkinParts() {
+ return skinparts; + return this.skinparts;
+ } + }
+ +
+ public boolean hasSkinPartsChanged() { + public boolean hasSkinPartsChanged() {
+ return skinparts.getRaw() != player.getClientOption(ClientOption.SKIN_PARTS).getRaw(); + return this.skinparts.getRaw() != this.player.getClientOption(ClientOption.SKIN_PARTS).getRaw();
+ } + }
+ +
+ @NotNull + @NotNull
+ public MainHand getMainHand() { + public MainHand getMainHand() {
+ return mainHand; + return this.mainHand;
+ } + }
+ +
+ public boolean hasMainHandChanged() { + public boolean hasMainHandChanged() {
+ return mainHand != player.getClientOption(ClientOption.MAIN_HAND); + return this.mainHand != this.player.getClientOption(ClientOption.MAIN_HAND);
+ } + }
+ +
+ public boolean allowsServerListings() { + public boolean allowsServerListings() {
+ return allowsServerListings; + return this.allowsServerListings;
+ } + }
+ +
+ public boolean hasAllowServerListingsChanged() { + public boolean hasAllowServerListingsChanged() {
+ return allowsServerListings != player.getClientOption(ClientOption.ALLOW_SERVER_LISTINGS); + return this.allowsServerListings != this.player.getClientOption(ClientOption.ALLOW_SERVER_LISTINGS);
+ } + }
+ +
+ public boolean hasTextFilteringEnabled() { + public boolean hasTextFilteringEnabled() {
+ return textFilteringEnabled; + return this.textFilteringEnabled;
+ } + }
+ +
+ public boolean hasTextFilteringChanged() { + public boolean hasTextFilteringChanged() {
+ return textFilteringEnabled != player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED); + return this.textFilteringEnabled != this.player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED);
+ } + }
+ +
+ @Override + @Override
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerAttackEntityCooldownResetEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerAttackEntityCooldownResetEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerAttackEntityCooldownResetEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerAttackEntityCooldownResetEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerAttackEntityCooldownResetEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ebdebe7b6ec6ed5aadc7ee925ba0147e61e6bc84 index 0000000000000000000000000000000000000000..5ceaff1a499d08575ddcdcbead8e2cef6cfbea47
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerAttackEntityCooldownResetEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerAttackEntityCooldownResetEvent.java
@@ -0,0 +1,76 @@ @@ -0,0 +1,77 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..ebdebe7b6ec6ed5aadc7ee925ba0147e
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -24,56 +25,27 @@ index 0000000000000000000000000000000000000000..ebdebe7b6ec6ed5aadc7ee925ba0147e
+ */ + */
+public class PlayerAttackEntityCooldownResetEvent extends PlayerEvent implements Cancellable { +public class PlayerAttackEntityCooldownResetEvent extends PlayerEvent implements Cancellable {
+ +
+ private final float cooledAttackStrength; + private static final HandlerList HANDLER_LIST = new HandlerList();
+ private boolean cancel = false;
+ private static final HandlerList handlers = new HandlerList();
+ @NotNull private final Entity attackedEntity;
+ +
+ public PlayerAttackEntityCooldownResetEvent(@NotNull Player who, @NotNull Entity attackedEntity, float cooledAttackStrength) { + @NotNull private final Entity attackedEntity;
+ super(who); + private final float cooledAttackStrength;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerAttackEntityCooldownResetEvent(@NotNull Player player, @NotNull Entity attackedEntity, float cooledAttackStrength) {
+ super(player);
+ this.attackedEntity = attackedEntity; + this.attackedEntity = attackedEntity;
+ this.cooledAttackStrength = cooledAttackStrength; + this.cooledAttackStrength = cooledAttackStrength;
+ } + }
+ +
+ @Override
+ public @NotNull HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static @NotNull HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ /**
+ * Gets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ * <p>
+ * If an attack cooldown event is cancelled, the players attack strength will remain at the same value instead of being reset.
+ *
+ * @return true if this event is cancelled
+ */
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ /**
+ * Cancelling this event will prevent the target player from having their cooldown reset from attacking this entity
+ *
+ * @param cancel true if you wish to cancel this event
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ /** + /**
+ * Get the value of the players cooldown attack strength when they initiated the attack + * Get the value of the players cooldown attack strength when they initiated the attack
+ * + *
+ * @return returns the original player cooldown value + * @return returns the original player cooldown value
+ */ + */
+ public float getCooledAttackStrength() { + public float getCooledAttackStrength() {
+ return cooledAttackStrength; + return this.cooledAttackStrength;
+ } + }
+ +
+ /** + /**
@ -83,6 +55,35 @@ index 0000000000000000000000000000000000000000..ebdebe7b6ec6ed5aadc7ee925ba0147e
+ */ + */
+ @NotNull + @NotNull
+ public Entity getAttackedEntity() { + public Entity getAttackedEntity() {
+ return attackedEntity; + return this.attackedEntity;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * If an attack cooldown event is cancelled, the players attack strength will remain at the same value instead of being reset.
+ */
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Cancelling this event will prevent the target player from having their cooldown reset from attacking this entity
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @Override
+ public @NotNull HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static @NotNull HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add and implement PlayerRecipeBookClickEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..7fa937d339ee98ad308deebb523fead6522eb262 index 0000000000000000000000000000000000000000..c38ac6d0e0ac4ecbdc73d2bedd7731ff34c9d192
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java
@@ -0,0 +1,84 @@ @@ -0,0 +1,89 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import org.bukkit.NamespacedKey; +import org.bukkit.NamespacedKey;
@ -17,17 +17,22 @@ index 0000000000000000000000000000000000000000..7fa937d339ee98ad308deebb523fead6
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when a player clicks a recipe in the recipe book + * Called when a player clicks a recipe in the recipe book
+ */ + */
+public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellable { +public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull private NamespacedKey recipe; + @NotNull private NamespacedKey recipe;
+ private boolean makeAll; + private boolean makeAll;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerRecipeBookClickEvent(@NotNull Player player, @NotNull NamespacedKey recipe, boolean makeAll) { + public PlayerRecipeBookClickEvent(@NotNull Player player, @NotNull NamespacedKey recipe, boolean makeAll) {
+ super(player); + super(player);
+ this.recipe = recipe; + this.recipe = recipe;
@ -41,7 +46,7 @@ index 0000000000000000000000000000000000000000..7fa937d339ee98ad308deebb523fead6
+ */ + */
+ @NotNull + @NotNull
+ public NamespacedKey getRecipe() { + public NamespacedKey getRecipe() {
+ return recipe; + return this.recipe;
+ } + }
+ +
+ /** + /**
@ -54,17 +59,17 @@ index 0000000000000000000000000000000000000000..7fa937d339ee98ad308deebb523fead6
+ } + }
+ +
+ /** + /**
+ * Gets a boolean which indicates whether or not the player requested to make the maximum amount of results. This is + * Gets a boolean which indicates whether the player requested to make the maximum amount of results. This is
+ * true if shift is pressed while the recipe is clicked in the recipe book + * {@code true} if shift is pressed while the recipe is clicked in the recipe book
+ * + *
+ * @return {@code true} if shift is pressed while the recipe is clicked + * @return {@code true} if shift is pressed while the recipe is clicked
+ */ + */
+ public boolean isMakeAll() { + public boolean isMakeAll() {
+ return makeAll; + return this.makeAll;
+ } + }
+ +
+ /** + /**
+ * Sets whether or not the maximum amount of results should be made. If this is true, the request is handled as if + * Sets whether the maximum amount of results should be made. If this is {@code true}, the request is handled as if
+ * the player had pressed shift while clicking on the recipe + * the player had pressed shift while clicking on the recipe
+ * + *
+ * @param makeAll {@code true} if the request should attempt to make the maximum amount of results + * @param makeAll {@code true} if the request should attempt to make the maximum amount of results
@ -75,23 +80,23 @@ index 0000000000000000000000000000000000000000..7fa937d339ee98ad308deebb523fead6
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancel; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancel = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java b/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java b/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java

Datei anzeigen

@ -11,27 +11,30 @@ Grindstone is a backwards compat from a previous PrepareGrindstoneEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..83bfb7276b458bae1e21cb7ba9f4f7c4c2acf76f index 0000000000000000000000000000000000000000..b31e6777f5d163c61309da9ff204ad5773ba7f54
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java
@@ -0,0 +1,28 @@ @@ -0,0 +1,31 @@
+package com.destroystokyo.paper.event.inventory; +package com.destroystokyo.paper.event.inventory;
+ +
+import org.bukkit.Warning; +import org.bukkit.Warning;
+import org.bukkit.inventory.GrindstoneInventory; +import org.bukkit.inventory.GrindstoneInventory;
+import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Called when an item is put in a slot for grinding in a Grindstone + * Called when an item is put in a slot for grinding in a Grindstone
+ *
+ * @deprecated use {@link org.bukkit.event.inventory.PrepareGrindstoneEvent} + * @deprecated use {@link org.bukkit.event.inventory.PrepareGrindstoneEvent}
+ */ + */
+@Deprecated +@Deprecated
+@Warning(false) +@Warning
+public class PrepareGrindstoneEvent extends PrepareResultEvent { +public class PrepareGrindstoneEvent extends PrepareResultEvent {
+ +
+ @ApiStatus.Internal
+ public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { + public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
+ super(inventory, result); + super(inventory, result);
+ } + }
@ -45,15 +48,16 @@ index 0000000000000000000000000000000000000000..83bfb7276b458bae1e21cb7ba9f4f7c4
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..25e5f0354b3b65c656d6c173ec108825f1e8b1be index 0000000000000000000000000000000000000000..c305c606bef93866993095cec5f50e191c5a382a
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareResultEvent.java
@@ -0,0 +1,37 @@ @@ -0,0 +1,40 @@
+package com.destroystokyo.paper.event.inventory; +package com.destroystokyo.paper.event.inventory;
+ +
+import org.bukkit.event.inventory.PrepareInventoryResultEvent; +import org.bukkit.event.inventory.PrepareInventoryResultEvent;
+import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -63,12 +67,14 @@ index 0000000000000000000000000000000000000000..25e5f0354b3b65c656d6c173ec108825
+public class PrepareResultEvent extends PrepareInventoryResultEvent { +public class PrepareResultEvent extends PrepareInventoryResultEvent {
+ +
+ // HandlerList on PrepareInventoryResultEvent to ensure api compat + // HandlerList on PrepareInventoryResultEvent to ensure api compat
+
+ @ApiStatus.Internal
+ public PrepareResultEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { + public PrepareResultEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
+ super(inventory, result); + super(inventory, result);
+ } + }
+ +
+ /** + /**
+ * Get result item, may be null. + * Get result item, may be {@code null}.
+ * + *
+ * @return result item + * @return result item
+ */ + */
@ -78,7 +84,7 @@ index 0000000000000000000000000000000000000000..25e5f0354b3b65c656d6c173ec108825
+ } + }
+ +
+ /** + /**
+ * Set result item, may be null. + * Set result item, may be {@code null}.
+ * + *
+ * @param result result item + * @param result result item
+ */ + */

Datei anzeigen

@ -8,26 +8,28 @@ village bell. Passes along the bell block and the player who rang it.
diff --git a/src/main/java/io/papermc/paper/event/block/BellRingEvent.java b/src/main/java/io/papermc/paper/event/block/BellRingEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/BellRingEvent.java b/src/main/java/io/papermc/paper/event/block/BellRingEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..548aeeab7d45173f36616a4a2f215f5838696089 index 0000000000000000000000000000000000000000..7d3f04d5ab620f37d2253b575ae370d95ecf21ef
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BellRingEvent.java +++ b/src/main/java/io/papermc/paper/event/block/BellRingEvent.java
@@ -0,0 +1,20 @@ @@ -0,0 +1,22 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockFace;
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Called when a bell is rung. + * Called when a bell is rung.
+ *
+ * @deprecated use {@link org.bukkit.event.block.BellRingEvent} + * @deprecated use {@link org.bukkit.event.block.BellRingEvent}
+ */ + */
+@Deprecated +@Deprecated
+public class BellRingEvent extends org.bukkit.event.block.BellRingEvent implements Cancellable { +public class BellRingEvent extends org.bukkit.event.block.BellRingEvent {
+ +
+ @ApiStatus.Internal
+ public BellRingEvent(@NotNull Block block, @NotNull BlockFace direction, @Nullable Entity entity) { + public BellRingEvent(@NotNull Block block, @NotNull BlockFace direction, @Nullable Entity entity) {
+ super(block, direction, entity); + super(block, direction, entity);
+ } + }

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerItemCooldownEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..58d18f05af13d836ddc62fcd30befcb06f07c57c index 0000000000000000000000000000000000000000..c2764ffd51831351b934568e1301b2e4073dc0c4
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerItemCooldownEvent.java
@@ -0,0 +1,77 @@ @@ -0,0 +1,82 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
@ -18,18 +18,23 @@ index 0000000000000000000000000000000000000000..58d18f05af13d836ddc62fcd30befcb0
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Fired when a player receives an item cooldown. + * Fired when a player receives an item cooldown.
+ */ + */
+public class PlayerItemCooldownEvent extends PlayerEvent implements Cancellable { +public class PlayerItemCooldownEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull + @NotNull
+ private final Material type; + private final Material type;
+ private boolean cancelled;
+ private int cooldown; + private int cooldown;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerItemCooldownEvent(@NotNull Player player, @NotNull Material type, int cooldown) { + public PlayerItemCooldownEvent(@NotNull Player player, @NotNull Material type, int cooldown) {
+ super(player); + super(player);
+ this.type = type; + this.type = type;
@ -43,7 +48,7 @@ index 0000000000000000000000000000000000000000..58d18f05af13d836ddc62fcd30befcb0
+ */ + */
+ @NotNull + @NotNull
+ public Material getType() { + public Material getType() {
+ return type; + return this.type;
+ } + }
+ +
+ /** + /**
@ -52,7 +57,7 @@ index 0000000000000000000000000000000000000000..58d18f05af13d836ddc62fcd30befcb0
+ * @return cooldown in ticks + * @return cooldown in ticks
+ */ + */
+ public int getCooldown() { + public int getCooldown() {
+ return cooldown; + return this.cooldown;
+ } + }
+ +
+ /** + /**
@ -68,7 +73,7 @@ index 0000000000000000000000000000000000000000..58d18f05af13d836ddc62fcd30befcb0
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
@ -79,11 +84,11 @@ index 0000000000000000000000000000000000000000..58d18f05af13d836ddc62fcd30befcb0
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerShearBlockEvent
diff --git a/src/main/java/io/papermc/paper/event/block/PlayerShearBlockEvent.java b/src/main/java/io/papermc/paper/event/block/PlayerShearBlockEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/PlayerShearBlockEvent.java b/src/main/java/io/papermc/paper/event/block/PlayerShearBlockEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..aa7d440b797eac9e62678d03cc87f42838758bfd index 0000000000000000000000000000000000000000..9bb4a79320eac7d662d9d04765664b6a7e955a4f
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/PlayerShearBlockEvent.java +++ b/src/main/java/io/papermc/paper/event/block/PlayerShearBlockEvent.java
@@ -0,0 +1,108 @@ @@ -0,0 +1,113 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..aa7d440b797eac9e62678d03cc87f428
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+import java.util.List; +import java.util.List;
@ -32,15 +33,19 @@ index 0000000000000000000000000000000000000000..aa7d440b797eac9e62678d03cc87f428
+ * Examples include shearing a pumpkin to turn it into a carved pumpkin or shearing a beehive to get honeycomb. + * Examples include shearing a pumpkin to turn it into a carved pumpkin or shearing a beehive to get honeycomb.
+ */ + */
+public class PlayerShearBlockEvent extends PlayerEvent implements Cancellable { +public class PlayerShearBlockEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Block block; + private final Block block;
+ private final ItemStack item; + private final ItemStack item;
+ private final EquipmentSlot hand; + private final EquipmentSlot hand;
+ private final List<ItemStack> drops; + private final List<ItemStack> drops;
+ +
+ public PlayerShearBlockEvent(@NotNull Player who, @NotNull Block block, @NotNull ItemStack item, @NotNull EquipmentSlot hand, @NotNull List<ItemStack> drops) { + private boolean cancelled;
+ super(who); +
+ @ApiStatus.Internal
+ public PlayerShearBlockEvent(@NotNull Player player, @NotNull Block block, @NotNull ItemStack item, @NotNull EquipmentSlot hand, @NotNull List<ItemStack> drops) {
+ super(player);
+ this.block = block; + this.block = block;
+ this.item = item; + this.item = item;
+ this.hand = hand; + this.hand = hand;
@ -54,7 +59,7 @@ index 0000000000000000000000000000000000000000..aa7d440b797eac9e62678d03cc87f428
+ */ + */
+ @NotNull + @NotNull
+ public Block getBlock() { + public Block getBlock() {
+ return block; + return this.block;
+ } + }
+ +
+ /** + /**
@ -64,7 +69,7 @@ index 0000000000000000000000000000000000000000..aa7d440b797eac9e62678d03cc87f428
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getItem() { + public ItemStack getItem() {
+ return item; + return this.item;
+ } + }
+ +
+ /** + /**
@ -74,7 +79,7 @@ index 0000000000000000000000000000000000000000..aa7d440b797eac9e62678d03cc87f428
+ */ + */
+ @NotNull + @NotNull
+ public EquipmentSlot getHand() { + public EquipmentSlot getHand() {
+ return hand; + return this.hand;
+ } + }
+ +
+ /** + /**
@ -84,7 +89,7 @@ index 0000000000000000000000000000000000000000..aa7d440b797eac9e62678d03cc87f428
+ */ + */
+ @NotNull + @NotNull
+ public List<ItemStack> getDrops() { + public List<ItemStack> getDrops() {
+ return drops; + return this.drops;
+ } + }
+ +
+ /** + /**
@ -94,7 +99,7 @@ index 0000000000000000000000000000000000000000..aa7d440b797eac9e62678d03cc87f428
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
@ -110,11 +115,11 @@ index 0000000000000000000000000000000000000000..aa7d440b797eac9e62678d03cc87f428
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,95 +6,101 @@ Subject: [PATCH] Player Chunk Load/Unload Events
diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..2c1cda1126e577a88f19071e958eddb5a38785af index 0000000000000000000000000000000000000000..3ddbc099a13df939b3912f30b54e7635840ba5a4
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java +++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java
@@ -0,0 +1,42 @@ @@ -0,0 +1,45 @@
+package io.papermc.paper.event.packet; +package io.papermc.paper.event.packet;
+ +
+import org.bukkit.Chunk; +import org.bukkit.Chunk;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.world.ChunkEvent; +import org.bukkit.event.world.ChunkEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Is called when a {@link org.bukkit.entity.Player} receives a {@link org.bukkit.Chunk} + * Is called when a {@link Player} receives a {@link Chunk}
+ * <p> + * <p>
+ * Can for example be used for spawning a fake entity when the player receives a chunk. + * Can for example be used for spawning a fake entity when the player receives a chunk.
+ * + * <p>
+ * Should only be used for packet/clientside related stuff. + * Should only be used for packet/clientside related stuff.
+ * Not intended for modifying server side state. + * Not intended for modifying server side state.
+ */ + */
+public class PlayerChunkLoadEvent extends ChunkEvent { +public class PlayerChunkLoadEvent extends ChunkEvent {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Player player; + private final Player player;
+ +
+ @ApiStatus.Internal
+ public PlayerChunkLoadEvent(@NotNull Chunk chunk, @NotNull Player player) { + public PlayerChunkLoadEvent(@NotNull Chunk chunk, @NotNull Player player) {
+ super(chunk); + super(chunk);
+ this.player = player; + this.player = player;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + public Player getPlayer() {
+ public HandlerList getHandlers() { + return this.player;
+ return handlers;
+ } + }
+ +
+ @NotNull + @NotNull
+ public Player getPlayer() { + @Override
+ return player; + public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..12163a7b0591a7d022dc7eb9ee6608a1b6c39d9b index 0000000000000000000000000000000000000000..2cac7e27991c04a9ced261f2dd8ad8657ccddf6b
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java +++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java
@@ -0,0 +1,40 @@ @@ -0,0 +1,43 @@
+package io.papermc.paper.event.packet; +package io.papermc.paper.event.packet;
+ +
+import org.bukkit.Chunk; +import org.bukkit.Chunk;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.world.ChunkEvent; +import org.bukkit.event.world.ChunkEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Is called when a {@link Player} receives a chunk unload packet. + * Is called when a {@link Player} receives a chunk unload packet.
+ * + * <p>
+ * Should only be used for packet/clientside related stuff. + * Should only be used for packet/clientside related stuff.
+ * Not intended for modifying server side. + * Not intended for modifying server side.
+ */ + */
+public class PlayerChunkUnloadEvent extends ChunkEvent { +public class PlayerChunkUnloadEvent extends ChunkEvent {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Player player; + private final Player player;
+ +
+ @ApiStatus.Internal
+ public PlayerChunkUnloadEvent(@NotNull Chunk chunk, @NotNull Player player) { + public PlayerChunkUnloadEvent(@NotNull Chunk chunk, @NotNull Player player) {
+ super(chunk); + super(chunk);
+ this.player = player; + this.player = player;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + public Player getPlayer() {
+ public HandlerList getHandlers() { + return this.player;
+ return handlers;
+ } + }
+ +
+ @NotNull + @NotNull
+ public Player getPlayer() { + @Override
+ return player; + public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -13,36 +13,40 @@ event being about villager trades.
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerPurchaseEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerPurchaseEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerPurchaseEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerPurchaseEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..c5648055c5e815474bf1e564a5c192ff5c0624fb index 0000000000000000000000000000000000000000..61c62877c38e27eacc20aa43ef02dc43e9b50bfc
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerPurchaseEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerPurchaseEvent.java
@@ -0,0 +1,112 @@ @@ -0,0 +1,109 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import java.util.Objects; +import com.google.common.base.Preconditions;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.MerchantRecipe; +import org.bukkit.inventory.MerchantRecipe;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when a player trades with a standalone merchant GUI. + * Called when a player trades with a standalone merchant GUI.
+ */ + */
+public class PlayerPurchaseEvent extends PlayerEvent implements Cancellable { +public class PlayerPurchaseEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ +
+ private boolean increaseTradeUses; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean rewardExp; + private boolean rewardExp;
+ private boolean increaseTradeUses;
+ private MerchantRecipe trade; + private MerchantRecipe trade;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerPurchaseEvent(@NotNull Player player, + public PlayerPurchaseEvent(@NotNull Player player,
+ @NotNull MerchantRecipe trade, + @NotNull MerchantRecipe trade,
+ boolean rewardExp, + boolean rewardExp,
+ boolean increaseTradeUses) { + boolean increaseTradeUses) {
+ super(Objects.requireNonNull(player, "Player cannot be null!")); + super(player);
+ setTrade(trade); + setTrade(trade);
+ this.rewardExp = rewardExp; + this.rewardExp = rewardExp;
+ this.increaseTradeUses = increaseTradeUses; + this.increaseTradeUses = increaseTradeUses;
@ -50,6 +54,7 @@ index 0000000000000000000000000000000000000000..c5648055c5e815474bf1e564a5c192ff
+ +
+ /** + /**
+ * Gets the associated trade with this event + * Gets the associated trade with this event
+ *
+ * @return the trade + * @return the trade
+ */ + */
+ @NotNull + @NotNull
@ -59,10 +64,12 @@ index 0000000000000000000000000000000000000000..c5648055c5e815474bf1e564a5c192ff
+ +
+ /** + /**
+ * Sets the trade. This is then used to determine the next prices + * Sets the trade. This is then used to determine the next prices
+ *
+ * @param trade the trade to use + * @param trade the trade to use
+ */ + */
+ public void setTrade(@NotNull MerchantRecipe trade) { + public void setTrade(@NotNull MerchantRecipe trade) {
+ this.trade = Objects.requireNonNull(trade, "Trade cannot be null!"); + Preconditions.checkArgument(trade != null, "Trade cannot be null!");
+ this.trade = trade;
+ } + }
+ +
+ /** + /**
@ -74,6 +81,7 @@ index 0000000000000000000000000000000000000000..c5648055c5e815474bf1e564a5c192ff
+ +
+ /** + /**
+ * Sets whether the trade will try to reward exp + * Sets whether the trade will try to reward exp
+ *
+ * @param rewardExp try to reward exp + * @param rewardExp try to reward exp
+ */ + */
+ public void setRewardExp(boolean rewardExp) { + public void setRewardExp(boolean rewardExp) {
@ -81,37 +89,26 @@ index 0000000000000000000000000000000000000000..c5648055c5e815474bf1e564a5c192ff
+ } + }
+ +
+ /** + /**
+ * @return whether or not the trade will count as a use of the trade + * @return whether the trade will count as a use of the trade
+ */ + */
+ public boolean willIncreaseTradeUses() { + public boolean willIncreaseTradeUses() {
+ return this.increaseTradeUses; + return this.increaseTradeUses;
+ } + }
+ +
+ /** + /**
+ * Sets whether or not the trade will count as a use + * Sets whether the trade will count as a use
+ * @param increaseTradeUses true to count/false to not count + *
+ * @param increaseTradeUses {@code true} to count, {@code false} otherwise
+ */ + */
+ public void setIncreaseTradeUses(boolean increaseTradeUses) { + public void setIncreaseTradeUses(boolean increaseTradeUses) {
+ this.increaseTradeUses = increaseTradeUses; + this.increaseTradeUses = increaseTradeUses;
+ } + }
+ +
+ /**
+ * Gets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @return true if this event is cancelled
+ */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return this.cancelled; + return this.cancelled;
+ } + }
+ +
+ /**
+ * Sets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins.
+ *
+ * @param cancel true if you wish to cancel this event
+ */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
@ -120,26 +117,27 @@ index 0000000000000000000000000000000000000000..c5648055c5e815474bf1e564a5c192ff
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+} +}
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerTradeEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerTradeEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerTradeEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerTradeEvent.java
new file mode 100755 new file mode 100755
index 0000000000000000000000000000000000000000..a41fc186746b87f76347dfcc1f80d0969398322b index 0000000000000000000000000000000000000000..559d1a3c783e6c726f48d1c88b2ff8c0888890ac
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerTradeEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerTradeEvent.java
@@ -0,0 +1,29 @@ @@ -0,0 +1,32 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.entity.AbstractVillager; +import org.bukkit.entity.AbstractVillager;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.inventory.MerchantRecipe; +import org.bukkit.inventory.MerchantRecipe;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -149,6 +147,7 @@ index 0000000000000000000000000000000000000000..a41fc186746b87f76347dfcc1f80d096
+ +
+ private final AbstractVillager villager; + private final AbstractVillager villager;
+ +
+ @ApiStatus.Internal
+ public PlayerTradeEvent(@NotNull Player player, @NotNull AbstractVillager villager, @NotNull MerchantRecipe trade, boolean rewardExp, boolean increaseTradeUses) { + public PlayerTradeEvent(@NotNull Player player, @NotNull AbstractVillager villager, @NotNull MerchantRecipe trade, boolean rewardExp, boolean increaseTradeUses) {
+ super(player, trade, rewardExp, increaseTradeUses); + super(player, trade, rewardExp, increaseTradeUses);
+ this.villager = villager; + this.villager = villager;
@ -156,6 +155,7 @@ index 0000000000000000000000000000000000000000..a41fc186746b87f76347dfcc1f80d096
+ +
+ /** + /**
+ * Gets the Villager or Wandering trader associated with this event + * Gets the Villager or Wandering trader associated with this event
+ *
+ * @return the villager or wandering trader + * @return the villager or wandering trader
+ */ + */
+ @NotNull + @NotNull

Datei anzeigen

@ -6,19 +6,21 @@ Subject: [PATCH] Add TargetHitEvent API
diff --git a/src/main/java/io/papermc/paper/event/block/TargetHitEvent.java b/src/main/java/io/papermc/paper/event/block/TargetHitEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/TargetHitEvent.java b/src/main/java/io/papermc/paper/event/block/TargetHitEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..cc067ae118af9957b1b9f5c8d45f63f9154f4942 index 0000000000000000000000000000000000000000..5247e7f78e0076089c1e1bdea2afbb455c43732a
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/TargetHitEvent.java +++ b/src/main/java/io/papermc/paper/event/block/TargetHitEvent.java
@@ -0,0 +1,69 @@ @@ -0,0 +1,61 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import com.google.common.base.Preconditions;
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockFace;
+import org.bukkit.entity.Projectile; +import org.bukkit.entity.Projectile;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.ProjectileHitEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Range;
+ +
+/** +/**
+ * Called when a Target Block is hit by a projectile. + * Called when a Target Block is hit by a projectile.
@ -27,44 +29,25 @@ index 0000000000000000000000000000000000000000..cc067ae118af9957b1b9f5c8d45f63f9
+ * and in the case that the shooter is a player, will stop them from receiving + * and in the case that the shooter is a player, will stop them from receiving
+ * advancement criteria. + * advancement criteria.
+ */ + */
+public class TargetHitEvent extends ProjectileHitEvent implements Cancellable { +public class TargetHitEvent extends ProjectileHitEvent {
+ private static final HandlerList handlers = new HandlerList(); +
+ private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private int signalStrength; + private int signalStrength;
+ +
+ @ApiStatus.Internal
+ public TargetHitEvent(@NotNull Projectile projectile, @NotNull Block block, @NotNull BlockFace blockFace, int signalStrength) { + public TargetHitEvent(@NotNull Projectile projectile, @NotNull Block block, @NotNull BlockFace blockFace, int signalStrength) {
+ super(projectile, null, block, blockFace); + super(projectile, null, block, blockFace);
+ this.signalStrength = signalStrength; + this.signalStrength = signalStrength;
+ } + }
+ +
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ /** + /**
+ * Gets the strength of the redstone signal to be emitted by the Target block + * Gets the strength of the redstone signal to be emitted by the Target block
+ * + *
+ * @return the strength of the redstone signal to be emitted + * @return the strength of the redstone signal to be emitted
+ */ + */
+ public int getSignalStrength() { + public @Range(from = 0, to = 15) int getSignalStrength() {
+ return signalStrength; + return this.signalStrength;
+ } + }
+ +
+ /** + /**
@ -72,10 +55,19 @@ index 0000000000000000000000000000000000000000..cc067ae118af9957b1b9f5c8d45f63f9
+ * + *
+ * @param signalStrength the strength of the redstone signal to be emitted + * @param signalStrength the strength of the redstone signal to be emitted
+ */ + */
+ public void setSignalStrength(int signalStrength) { + public void setSignalStrength(@Range(from = 0, to = 15) int signalStrength) {
+ if (signalStrength < 0 || signalStrength > 15) { + Preconditions.checkArgument(signalStrength >= 0 && signalStrength <= 15, "Signal strength out of range (%s), must be in range [0,15]", signalStrength);
+ throw new IllegalArgumentException("Signal strength out of range (" + signalStrength + "), must be in range [0,15]");
+ }
+ this.signalStrength = signalStrength; + this.signalStrength = signalStrength;
+ } + }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerFlowerPotManipulateEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerFlowerPotManipulateEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerFlowerPotManipulateEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerFlowerPotManipulateEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerFlowerPotManipulateEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4c141f3d8f668cdf9c75865a8e3ecbd012d9e521 index 0000000000000000000000000000000000000000..373a6ec68fb575b82b06bf250768c1a6909efe38
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerFlowerPotManipulateEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerFlowerPotManipulateEvent.java
@@ -0,0 +1,82 @@ @@ -0,0 +1,85 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
@ -18,13 +18,15 @@ index 0000000000000000000000000000000000000000..4c141f3d8f668cdf9c75865a8e3ecbd0
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when a player places an item in or takes an item out of a flowerpot. + * Called when a player places an item in or takes an item out of a flowerpot.
+ */ + */
+public class PlayerFlowerPotManipulateEvent extends PlayerEvent implements Cancellable { +public class PlayerFlowerPotManipulateEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull + @NotNull
+ private final Block flowerpot; + private final Block flowerpot;
@ -32,8 +34,9 @@ index 0000000000000000000000000000000000000000..4c141f3d8f668cdf9c75865a8e3ecbd0
+ private final ItemStack item; + private final ItemStack item;
+ private final boolean placing; + private final boolean placing;
+ +
+ private boolean cancel = false; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public PlayerFlowerPotManipulateEvent(@NotNull final Player player, @NotNull final Block flowerpot, @NotNull final ItemStack item, final boolean placing) { + public PlayerFlowerPotManipulateEvent(@NotNull final Player player, @NotNull final Block flowerpot, @NotNull final ItemStack item, final boolean placing) {
+ super(player); + super(player);
+ this.flowerpot = flowerpot; + this.flowerpot = flowerpot;
@ -41,16 +44,6 @@ index 0000000000000000000000000000000000000000..4c141f3d8f668cdf9c75865a8e3ecbd0
+ this.placing = placing; + this.placing = placing;
+ } + }
+ +
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ /** + /**
+ * Gets the flowerpot that is involved in this event. + * Gets the flowerpot that is involved in this event.
+ * + *
@ -58,7 +51,7 @@ index 0000000000000000000000000000000000000000..4c141f3d8f668cdf9c75865a8e3ecbd0
+ */ + */
+ @NotNull + @NotNull
+ public Block getFlowerpot() { + public Block getFlowerpot() {
+ return flowerpot; + return this.flowerpot;
+ } + }
+ +
+ /** + /**
@ -69,7 +62,7 @@ index 0000000000000000000000000000000000000000..4c141f3d8f668cdf9c75865a8e3ecbd0
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getItem() { + public ItemStack getItem() {
+ return item; + return this.item;
+ } + }
+ +
+ /** + /**
@ -78,17 +71,27 @@ index 0000000000000000000000000000000000000000..4c141f3d8f668cdf9c75865a8e3ecbd0
+ * @return if the item is being placed into the flowerpot + * @return if the item is being placed into the flowerpot
+ */ + */
+ public boolean isPlacing() { + public boolean isPlacing() {
+ return placing; + return this.placing;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add EntityLoadCrossbowEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityLoadCrossbowEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityLoadCrossbowEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/EntityLoadCrossbowEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityLoadCrossbowEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..66e41bfe89f35d3947ea47aedcd36ac8f01ac5b6 index 0000000000000000000000000000000000000000..8434ea803e3135380f9351c82a414ccb65c478a9
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityLoadCrossbowEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/EntityLoadCrossbowEvent.java
@@ -0,0 +1,98 @@ @@ -0,0 +1,96 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
@ -25,12 +25,14 @@ index 0000000000000000000000000000000000000000..66e41bfe89f35d3947ea47aedcd36ac8
+ * Called when a LivingEntity loads a crossbow with a projectile. + * Called when a LivingEntity loads a crossbow with a projectile.
+ */ + */
+public class EntityLoadCrossbowEvent extends EntityEvent implements Cancellable { +public class EntityLoadCrossbowEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final ItemStack crossbow; + private final ItemStack crossbow;
+ private final EquipmentSlot hand; + private final EquipmentSlot hand;
+ private boolean cancelled; +
+ private boolean consumeItem = true; + private boolean consumeItem = true;
+ private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public EntityLoadCrossbowEvent(@NotNull LivingEntity entity, @NotNull ItemStack crossbow, @NotNull EquipmentSlot hand) { + public EntityLoadCrossbowEvent(@NotNull LivingEntity entity, @NotNull ItemStack crossbow, @NotNull EquipmentSlot hand) {
@ -42,7 +44,7 @@ index 0000000000000000000000000000000000000000..66e41bfe89f35d3947ea47aedcd36ac8
+ @NotNull + @NotNull
+ @Override + @Override
+ public LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return (LivingEntity) entity; + return (LivingEntity) super.getEntity();
+ } + }
+ +
+ /** + /**
@ -52,7 +54,7 @@ index 0000000000000000000000000000000000000000..66e41bfe89f35d3947ea47aedcd36ac8
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getCrossbow() { + public ItemStack getCrossbow() {
+ return crossbow; + return this.crossbow;
+ } + }
+ +
+ /** + /**
@ -62,19 +64,17 @@ index 0000000000000000000000000000000000000000..66e41bfe89f35d3947ea47aedcd36ac8
+ */ + */
+ @NotNull + @NotNull
+ public EquipmentSlot getHand() { + public EquipmentSlot getHand() {
+ return hand; + return this.hand;
+ } + }
+ +
+ /** + /**
+ *
+ * @return should the itemstack be consumed + * @return should the itemstack be consumed
+ */ + */
+ public boolean shouldConsumeItem() { + public boolean shouldConsumeItem() {
+ return consumeItem; + return this.consumeItem;
+ } + }
+ +
+ /** + /**
+ *
+ * @param consume should the item be consumed + * @param consume should the item be consumed
+ */ + */
+ public void setConsumeItem(boolean consume) { + public void setConsumeItem(boolean consume) {
@ -83,14 +83,12 @@ index 0000000000000000000000000000000000000000..66e41bfe89f35d3947ea47aedcd36ac8
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * Set whether or not to cancel the crossbow being loaded. If canceled, the + * Set whether to cancel the crossbow being loaded. If canceled, the
+ * projectile that would be loaded into the crossbow will not be consumed. + * projectile that would be loaded into the crossbow will not be consumed.
+ *
+ * @param cancel true if you wish to cancel this event
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {

Datei anzeigen

@ -6,19 +6,19 @@ Subject: [PATCH] Added WorldGameRuleChangeEvent
diff --git a/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java b/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java diff --git a/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java b/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..20c25a0f9d65188402e8bb3981348bc6462904bf index 0000000000000000000000000000000000000000..2831fb8ad22e457f85523f65be9cba2432109f01
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java +++ b/src/main/java/io/papermc/paper/event/world/WorldGameRuleChangeEvent.java
@@ -0,0 +1,91 @@ @@ -0,0 +1,92 @@
+package io.papermc.paper.event.world; +package io.papermc.paper.event.world;
+ +
+import org.bukkit.GameRule; +import org.bukkit.GameRule;
+import org.bukkit.World; +import org.bukkit.World;
+import org.bukkit.command.CommandSender; +import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.world.WorldEvent; +import org.bukkit.event.world.WorldEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -34,6 +34,7 @@ index 0000000000000000000000000000000000000000..20c25a0f9d65188402e8bb3981348bc6
+ private String value; + private String value;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public WorldGameRuleChangeEvent(@NotNull World world, @Nullable CommandSender commandSender, @NotNull GameRule<?> gameRule, @NotNull String value) { + public WorldGameRuleChangeEvent(@NotNull World world, @Nullable CommandSender commandSender, @NotNull GameRule<?> gameRule, @NotNull String value) {
+ super(world); + super(world);
+ this.commandSender = commandSender; + this.commandSender = commandSender;
@ -48,7 +49,7 @@ index 0000000000000000000000000000000000000000..20c25a0f9d65188402e8bb3981348bc6
+ */ + */
+ @Nullable + @Nullable
+ public CommandSender getCommandSender() { + public CommandSender getCommandSender() {
+ return commandSender; + return this.commandSender;
+ } + }
+ +
+ /** + /**
@ -58,7 +59,7 @@ index 0000000000000000000000000000000000000000..20c25a0f9d65188402e8bb3981348bc6
+ */ + */
+ @NotNull + @NotNull
+ public GameRule<?> getGameRule() { + public GameRule<?> getGameRule() {
+ return gameRule; + return this.gameRule;
+ } + }
+ +
+ /** + /**
@ -68,7 +69,7 @@ index 0000000000000000000000000000000000000000..20c25a0f9d65188402e8bb3981348bc6
+ */ + */
+ @NotNull + @NotNull
+ public String getValue() { + public String getValue() {
+ return value; + return this.value;
+ } + }
+ +
+ /** + /**
@ -82,7 +83,7 @@ index 0000000000000000000000000000000000000000..20c25a0f9d65188402e8bb3981348bc6
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override

Datei anzeigen

@ -6,21 +6,21 @@ Subject: [PATCH] Added ServerResourcesReloadedEvent
diff --git a/src/main/java/io/papermc/paper/event/server/ServerResourcesReloadedEvent.java b/src/main/java/io/papermc/paper/event/server/ServerResourcesReloadedEvent.java diff --git a/src/main/java/io/papermc/paper/event/server/ServerResourcesReloadedEvent.java b/src/main/java/io/papermc/paper/event/server/ServerResourcesReloadedEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..7a8d6815c17a107039399298f7ac9f0612faee02 index 0000000000000000000000000000000000000000..a7ed7d6b6469e175d3949ffa9c502cbfde609215
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/server/ServerResourcesReloadedEvent.java +++ b/src/main/java/io/papermc/paper/event/server/ServerResourcesReloadedEvent.java
@@ -0,0 +1,48 @@ @@ -0,0 +1,49 @@
+package io.papermc.paper.event.server; +package io.papermc.paper.event.server;
+ +
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.server.ServerEvent; +import org.bukkit.event.server.ServerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when resources such as datapacks are reloaded (e.g. /minecraft:reload) + * Called when resources such as datapacks are reloaded (e.g. /minecraft:reload)
+ * <p> + * <p>
+ * Intended for use to re-register custom recipes, advancements that may be lost during a reload like this. + * Intended for use to re-register custom recipes, advancements that may be lost during a reload like this.
+ * </p>
+ */ + */
+public class ServerResourcesReloadedEvent extends ServerEvent { +public class ServerResourcesReloadedEvent extends ServerEvent {
+ +
@ -28,6 +28,7 @@ index 0000000000000000000000000000000000000000..7a8d6815c17a107039399298f7ac9f06
+ +
+ private final Cause cause; + private final Cause cause;
+ +
+ @ApiStatus.Internal
+ public ServerResourcesReloadedEvent(@NotNull Cause cause) { + public ServerResourcesReloadedEvent(@NotNull Cause cause) {
+ this.cause = cause; + this.cause = cause;
+ } + }
@ -39,7 +40,7 @@ index 0000000000000000000000000000000000000000..7a8d6815c17a107039399298f7ac9f06
+ */ + */
+ @NotNull + @NotNull
+ public Cause getCause() { + public Cause getCause() {
+ return cause; + return this.cause;
+ } + }
+ +
+ @NotNull + @NotNull

Datei anzeigen

@ -6,25 +6,28 @@ Subject: [PATCH] Add BlockFailedDispenseEvent
diff --git a/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java b/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java b/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..dab794341170ed10d5a05c1b4c180d164e0f70e2 index 0000000000000000000000000000000000000000..d531b034b49b163e5095e840a5c9c4fe5eb73319
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java +++ b/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java
@@ -0,0 +1,57 @@ @@ -0,0 +1,56 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when a block tries to dispense an item, but its inventory is empty. + * Called when a block tries to dispense an item, but its inventory is empty.
+ */ + */
+public class BlockFailedDispenseEvent extends BlockEvent { +public class BlockFailedDispenseEvent extends BlockEvent {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private boolean shouldPlayEffect = true; + private boolean shouldPlayEffect = true;
+ +
+ @ApiStatus.Internal
+ public BlockFailedDispenseEvent(@NotNull Block theBlock) { + public BlockFailedDispenseEvent(@NotNull Block theBlock) {
+ super(theBlock); + super(theBlock);
+ } + }
@ -46,8 +49,6 @@ index 0000000000000000000000000000000000000000..dab794341170ed10d5a05c1b4c180d16
+ } + }
+ +
+ /** + /**
+ * {@inheritDoc}
+ *
+ * @return {@link #shouldPlayEffect()} + * @return {@link #shouldPlayEffect()}
+ */ + */
+ @Override + @Override
@ -57,13 +58,11 @@ index 0000000000000000000000000000000000000000..dab794341170ed10d5a05c1b4c180d16
+ } + }
+ +
+ @Override + @Override
+ public @NotNull + public @NotNull HandlerList getHandlers() {
+ HandlerList getHandlers() { + return HANDLER_LIST;
+ return handlers;
+ } + }
+ +
+ public static @NotNull + public static @NotNull HandlerList getHandlerList() {
+ HandlerList getHandlerList() { + return HANDLER_LIST;
+ return handlers;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Added PlayerLecternPageChangeEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerLecternPageChangeEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerLecternPageChangeEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerLecternPageChangeEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerLecternPageChangeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..26370e46e4a12e3470e9bb747fac5786a7305810 index 0000000000000000000000000000000000000000..6ed2a6c8c033937d933b6d4834953b8112a98bb3
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerLecternPageChangeEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerLecternPageChangeEvent.java
@@ -0,0 +1,115 @@ @@ -0,0 +1,117 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.block.Lectern; +import org.bukkit.block.Lectern;
@ -18,20 +18,22 @@ index 0000000000000000000000000000000000000000..26370e46e4a12e3470e9bb747fac5786
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+ +
+public class PlayerLecternPageChangeEvent extends PlayerEvent implements Cancellable { +public class PlayerLecternPageChangeEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private boolean cancelled;
+ private final Lectern lectern; + private final Lectern lectern;
+ private final ItemStack book; + private final ItemStack book;
+ private final PageChangeDirection pageChangeDirection; + private final PageChangeDirection pageChangeDirection;
+ private final int oldPage; + private final int oldPage;
+ private int newPage; + private int newPage;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerLecternPageChangeEvent(@NotNull Player player, @NotNull Lectern lectern, @NotNull ItemStack book, @NotNull PageChangeDirection pageChangeDirection, int oldPage, int newPage) { + public PlayerLecternPageChangeEvent(@NotNull Player player, @NotNull Lectern lectern, @NotNull ItemStack book, @NotNull PageChangeDirection pageChangeDirection, int oldPage, int newPage) {
+ super(player); + super(player);
+ this.lectern = lectern; + this.lectern = lectern;
@ -48,7 +50,7 @@ index 0000000000000000000000000000000000000000..26370e46e4a12e3470e9bb747fac5786
+ */ + */
+ @NotNull + @NotNull
+ public Lectern getLectern() { + public Lectern getLectern() {
+ return lectern; + return this.lectern;
+ } + }
+ +
+ /** + /**
@ -68,7 +70,7 @@ index 0000000000000000000000000000000000000000..26370e46e4a12e3470e9bb747fac5786
+ */ + */
+ @NotNull + @NotNull
+ public PageChangeDirection getPageChangeDirection() { + public PageChangeDirection getPageChangeDirection() {
+ return pageChangeDirection; + return this.pageChangeDirection;
+ } + }
+ +
+ /** + /**
@ -77,7 +79,7 @@ index 0000000000000000000000000000000000000000..26370e46e4a12e3470e9bb747fac5786
+ * @return the page changed from + * @return the page changed from
+ */ + */
+ public int getOldPage() { + public int getOldPage() {
+ return oldPage; + return this.oldPage;
+ } + }
+ +
+ /** + /**
@ -86,7 +88,7 @@ index 0000000000000000000000000000000000000000..26370e46e4a12e3470e9bb747fac5786
+ * @return the page changed to + * @return the page changed to
+ */ + */
+ public int getNewPage() { + public int getNewPage() {
+ return newPage; + return this.newPage;
+ } + }
+ +
+ /** + /**
@ -101,7 +103,7 @@ index 0000000000000000000000000000000000000000..26370e46e4a12e3470e9bb747fac5786
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Added PlayerLoomPatternSelectEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerLoomPatternSelectEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerLoomPatternSelectEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerLoomPatternSelectEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerLoomPatternSelectEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..8cb05709f7cb5dee993ff6fea1626c41b90a7d8b index 0000000000000000000000000000000000000000..c614bd1a725adee0c434a9331099d0c35d7411f6
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerLoomPatternSelectEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerLoomPatternSelectEvent.java
@@ -0,0 +1,77 @@ @@ -0,0 +1,80 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.block.banner.PatternType; +import org.bukkit.block.banner.PatternType;
@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..8cb05709f7cb5dee993ff6fea1626c41
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.LoomInventory; +import org.bukkit.inventory.LoomInventory;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -27,10 +28,12 @@ index 0000000000000000000000000000000000000000..8cb05709f7cb5dee993ff6fea1626c41
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private boolean cancelled;
+ private final LoomInventory loomInventory; + private final LoomInventory loomInventory;
+ private PatternType patternType; + private PatternType patternType;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerLoomPatternSelectEvent(@NotNull Player player, @NotNull LoomInventory loomInventory, @NotNull PatternType patternType) { + public PlayerLoomPatternSelectEvent(@NotNull Player player, @NotNull LoomInventory loomInventory, @NotNull PatternType patternType) {
+ super(player); + super(player);
+ this.loomInventory = loomInventory; + this.loomInventory = loomInventory;
@ -44,7 +47,7 @@ index 0000000000000000000000000000000000000000..8cb05709f7cb5dee993ff6fea1626c41
+ */ + */
+ @NotNull + @NotNull
+ public LoomInventory getLoomInventory() { + public LoomInventory getLoomInventory() {
+ return loomInventory; + return this.loomInventory;
+ } + }
+ +
+ /** + /**
@ -54,7 +57,7 @@ index 0000000000000000000000000000000000000000..8cb05709f7cb5dee993ff6fea1626c41
+ */ + */
+ @NotNull + @NotNull
+ public PatternType getPatternType() { + public PatternType getPatternType() {
+ return patternType; + return this.patternType;
+ } + }
+ +
+ /** + /**
@ -68,7 +71,7 @@ index 0000000000000000000000000000000000000000..8cb05709f7cb5dee993ff6fea1626c41
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override

Datei anzeigen

@ -7,10 +7,10 @@ Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java b/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java diff --git a/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java b/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..679677cf6a889ee23822b728b882e741c500df81 index 0000000000000000000000000000000000000000..1ac3369455972aeb1ade5dc023d1f818cd3535fa
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java +++ b/src/main/java/io/papermc/paper/event/world/StructureLocateEvent.java
@@ -0,0 +1,158 @@ @@ -0,0 +1,163 @@
+package io.papermc.paper.event.world; +package io.papermc.paper.event.world;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
@ -32,18 +32,23 @@ index 0000000000000000000000000000000000000000..679677cf6a889ee23822b728b882e741
+ * <li>An Explorer/Treasure Map is activated.</li> + * <li>An Explorer/Treasure Map is activated.</li>
+ * <li>{@link World#locateNearestStructure(Location, StructureType, int, boolean)} is invoked.</li> + * <li>{@link World#locateNearestStructure(Location, StructureType, int, boolean)} is invoked.</li>
+ * </ul> + * </ul>
+ *
+ * @deprecated no longer used, see {@link StructuresLocateEvent} + * @deprecated no longer used, see {@link StructuresLocateEvent}
+ */ + */
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21") +@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
+public class StructureLocateEvent extends WorldEvent implements Cancellable { +public class StructureLocateEvent extends WorldEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Location origin; + private final Location origin;
+ private Location result = null; + private Location result = null;
+ private StructureType type; + private StructureType type;
+ private int radius; + private int radius;
+ private boolean findUnexplored; + private boolean findUnexplored;
+ private boolean cancelled = false;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public StructureLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) { + public StructureLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) {
+ super(world); + super(world);
+ this.origin = origin; + this.origin = origin;
@ -52,29 +57,18 @@ index 0000000000000000000000000000000000000000..679677cf6a889ee23822b728b882e741
+ this.findUnexplored = findUnexplored; + this.findUnexplored = findUnexplored;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ /** + /**
+ * Gets the location set as the structure location, if it was defined. + * Gets the location set as the structure location, if it was defined.
+ * <p> + * <p>
+ * Returns {@code null} if it has not been set by {@link StructureLocateEvent#setResult(Location)}. + * Returns {@code null} if it has not been set by {@link StructureLocateEvent#setResult(Location)}.
+ * Since this event fires <i>before</i> the search is done, the actual location is unknown at this point. + * Since this event fires <i>before</i> the search is done, the actual location is unknown at this point.
+ * + *
+ * @return The result location, if it has been set. null if it has not. + * @return The result location, if it has been set. {@code null} if it has not.
+ * @see World#locateNearestStructure(Location, StructureType, int, boolean) + * @see World#locateNearestStructure(Location, StructureType, int, boolean)
+ */ + */
+ @Nullable + @Nullable
+ public Location getResult() { + public Location getResult() {
+ return result; + return this.result;
+ } + }
+ +
+ /** + /**
@ -93,7 +87,7 @@ index 0000000000000000000000000000000000000000..679677cf6a889ee23822b728b882e741
+ */ + */
+ @NotNull + @NotNull
+ public StructureType getType() { + public StructureType getType() {
+ return type; + return this.type;
+ } + }
+ +
+ /** + /**
@ -112,7 +106,7 @@ index 0000000000000000000000000000000000000000..679677cf6a889ee23822b728b882e741
+ */ + */
+ @NotNull + @NotNull
+ public Location getOrigin() { + public Location getOrigin() {
+ return origin; + return this.origin;
+ } + }
+ +
+ /** + /**
@ -123,7 +117,7 @@ index 0000000000000000000000000000000000000000..679677cf6a889ee23822b728b882e741
+ * @return the search radius. + * @return the search radius.
+ */ + */
+ public int getRadius() { + public int getRadius() {
+ return radius; + return this.radius;
+ } + }
+ +
+ /** + /**
@ -145,7 +139,7 @@ index 0000000000000000000000000000000000000000..679677cf6a889ee23822b728b882e741
+ * @return Whether to search for only unexplored structures. + * @return Whether to search for only unexplored structures.
+ */ + */
+ public boolean shouldFindUnexplored() { + public boolean shouldFindUnexplored() {
+ return findUnexplored; + return this.findUnexplored;
+ } + }
+ +
+ /** + /**
@ -161,20 +155,31 @@ index 0000000000000000000000000000000000000000..679677cf6a889ee23822b728b882e741
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+} +}
diff --git a/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java b/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java diff --git a/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java b/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4342b162f69b6509503e9772ddd2c5ac6659545a index 0000000000000000000000000000000000000000..be86894561ff808d911e123b09bda72c9ed09185
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java +++ b/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java
@@ -0,0 +1,210 @@ @@ -0,0 +1,213 @@
+package io.papermc.paper.event.world; +package io.papermc.paper.event.world;
+ +
+import io.papermc.paper.math.Position; +import io.papermc.paper.math.Position;
@ -190,6 +195,7 @@ index 0000000000000000000000000000000000000000..4342b162f69b6509503e9772ddd2c5ac
+import org.bukkit.event.world.WorldEvent; +import org.bukkit.event.world.WorldEvent;
+import org.bukkit.generator.structure.Structure; +import org.bukkit.generator.structure.Structure;
+import org.bukkit.generator.structure.StructureType; +import org.bukkit.generator.structure.StructureType;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.UnmodifiableView; +import org.jetbrains.annotations.UnmodifiableView;
@ -217,8 +223,10 @@ index 0000000000000000000000000000000000000000..4342b162f69b6509503e9772ddd2c5ac
+ private List<ConfiguredStructure> legacy$structures; + private List<ConfiguredStructure> legacy$structures;
+ private int radius; + private int radius;
+ private boolean findUnexplored; + private boolean findUnexplored;
+
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public StructuresLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull List<Structure> structures, int radius, boolean findUnexplored) { + public StructuresLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull List<Structure> structures, int radius, boolean findUnexplored) {
+ super(world); + super(world);
+ this.origin = origin; + this.origin = origin;
@ -242,8 +250,8 @@ index 0000000000000000000000000000000000000000..4342b162f69b6509503e9772ddd2c5ac
+ * Returns {@code null} if it has not been set by {@link StructuresLocateEvent#setResult(Result)}. + * Returns {@code null} if it has not been set by {@link StructuresLocateEvent#setResult(Result)}.
+ * Since this event fires <i>before</i> the search is done, the actual result is unknown at this point. + * Since this event fires <i>before</i> the search is done, the actual result is unknown at this point.
+ * + *
+ * @return The result location and structure, if it has been set. null if it has not. + * @return The result location and structure, if it has been set. {@code null} if it has not.
+ * @see World#locateNearestStructure(Location, org.bukkit.generator.structure.StructureType, int, boolean) + * @see World#locateNearestStructure(Location, StructureType, int, boolean)
+ */ + */
+ public @Nullable Result getResult() { + public @Nullable Result getResult() {
+ return this.result; + return this.result;

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add BlockPreDispenseEvent
diff --git a/src/main/java/io/papermc/paper/event/block/BlockPreDispenseEvent.java b/src/main/java/io/papermc/paper/event/block/BlockPreDispenseEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/BlockPreDispenseEvent.java b/src/main/java/io/papermc/paper/event/block/BlockPreDispenseEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..07aad3f4ff60a6a6de69634b0d31926e9c00e77b index 0000000000000000000000000000000000000000..62547d5853e7355a805fa1e7f1e5f56d06fca4ba
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BlockPreDispenseEvent.java +++ b/src/main/java/io/papermc/paper/event/block/BlockPreDispenseEvent.java
@@ -0,0 +1,60 @@ @@ -0,0 +1,65 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
@ -17,14 +17,19 @@ index 0000000000000000000000000000000000000000..07aad3f4ff60a6a6de69634b0d31926e
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+public class BlockPreDispenseEvent extends BlockEvent implements Cancellable { +public class BlockPreDispenseEvent extends BlockEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final ItemStack itemStack; + private final ItemStack itemStack;
+ private final int slot; + private final int slot;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public BlockPreDispenseEvent(@NotNull Block block, @NotNull ItemStack itemStack, int slot) { + public BlockPreDispenseEvent(@NotNull Block block, @NotNull ItemStack itemStack, int slot) {
+ super(block); + super(block);
+ this.itemStack = itemStack; + this.itemStack = itemStack;
@ -38,7 +43,7 @@ index 0000000000000000000000000000000000000000..07aad3f4ff60a6a6de69634b0d31926e
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getItemStack() { + public ItemStack getItemStack() {
+ return itemStack; + return this.itemStack;
+ } + }
+ +
+ /** + /**
@ -47,17 +52,7 @@ index 0000000000000000000000000000000000000000..07aad3f4ff60a6a6de69634b0d31926e
+ * @return The inventory slot + * @return The inventory slot
+ */ + */
+ public int getSlot() { + public int getSlot() {
+ return slot; + return this.slot;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ } + }
+ +
+ @Override + @Override
@ -69,4 +64,14 @@ index 0000000000000000000000000000000000000000..07aad3f4ff60a6a6de69634b0d31926e
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Added PlayerChangeBeaconEffectEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerChangeBeaconEffectEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerChangeBeaconEffectEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerChangeBeaconEffectEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerChangeBeaconEffectEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..812712b3b233c454dfab039fb9f16d6becca2d93 index 0000000000000000000000000000000000000000..1cc5dfb6d31f312f07acb1d5fb4719d6f4c2c4ff
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerChangeBeaconEffectEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerChangeBeaconEffectEvent.java
@@ -0,0 +1,143 @@ @@ -0,0 +1,137 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
@ -26,21 +26,21 @@ index 0000000000000000000000000000000000000000..812712b3b233c454dfab039fb9f16d6b
+ * Called when a player sets the effect for a beacon + * Called when a player sets the effect for a beacon
+ */ + */
+public class PlayerChangeBeaconEffectEvent extends PlayerEvent implements Cancellable { +public class PlayerChangeBeaconEffectEvent extends PlayerEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final Block beacon;
+ private PotionEffectType primary; + private PotionEffectType primary;
+ private PotionEffectType secondary; + private PotionEffectType secondary;
+ private final Block beacon;
+ private boolean consumeItem = true; + private boolean consumeItem = true;
+ +
+ private boolean isCancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerChangeBeaconEffectEvent(@NotNull Player player, @Nullable PotionEffectType primary, @Nullable PotionEffectType secondary, @NotNull Block beacon) { + public PlayerChangeBeaconEffectEvent(@NotNull Player player, @Nullable PotionEffectType primary, @Nullable PotionEffectType secondary, @NotNull Block beacon) {
+ super(player); + super(player);
+ this.primary = primary; + this.primary = primary;
+ this.secondary = secondary; + this.secondary = secondary;
+ this.isCancelled = false;
+ this.beacon = beacon; + this.beacon = beacon;
+ } + }
+ +
@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..812712b3b233c454dfab039fb9f16d6b
+ * @return the primary effect + * @return the primary effect
+ */ + */
+ @Nullable public PotionEffectType getPrimary() { + @Nullable public PotionEffectType getPrimary() {
+ return primary; + return this.primary;
+ } + }
+ +
+ /** + /**
@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..812712b3b233c454dfab039fb9f16d6b
+ * @return the secondary effect + * @return the secondary effect
+ */ + */
+ @Nullable public PotionEffectType getSecondary() { + @Nullable public PotionEffectType getSecondary() {
+ return secondary; + return this.secondary;
+ } + }
+ +
+ /** + /**
@ -86,7 +86,7 @@ index 0000000000000000000000000000000000000000..812712b3b233c454dfab039fb9f16d6b
+ */ + */
+ @NotNull + @NotNull
+ public Block getBeacon() { + public Block getBeacon() {
+ return beacon; + return this.beacon;
+ } + }
+ +
+ /** + /**
@ -95,10 +95,10 @@ index 0000000000000000000000000000000000000000..812712b3b233c454dfab039fb9f16d6b
+ * Independent of {@link #isCancelled()}. If the event is cancelled + * Independent of {@link #isCancelled()}. If the event is cancelled
+ * the item will <b>NOT</b> be consumed. + * the item will <b>NOT</b> be consumed.
+ * + *
+ * @return true if item will be consumed + * @return {@code true} if item will be consumed
+ */ + */
+ public boolean willConsumeItem() { + public boolean willConsumeItem() {
+ return consumeItem; + return this.consumeItem;
+ } + }
+ +
+ /** + /**
@ -107,40 +107,34 @@ index 0000000000000000000000000000000000000000..812712b3b233c454dfab039fb9f16d6b
+ * Independent of {@link #isCancelled()}. If the event is cancelled + * Independent of {@link #isCancelled()}. If the event is cancelled
+ * the item will <b>NOT</b> be consumed. + * the item will <b>NOT</b> be consumed.
+ * + *
+ * @param consumeItem true if item should be consumed + * @param consumeItem {@code true} if item should be consumed
+ */ + */
+ public void setConsumeItem(boolean consumeItem) { + public void setConsumeItem(boolean consumeItem) {
+ this.consumeItem = consumeItem; + this.consumeItem = consumeItem;
+ } + }
+ +
+ /** + /**
+ * Gets the cancellation state of this event. A cancelled event will not + * {@inheritDoc}
+ * be executed in the server, but will still pass to other plugins
+ * <p> + * <p>
+ * If a {@link PlayerChangeBeaconEffectEvent} is cancelled, the changes will + * If a {@link PlayerChangeBeaconEffectEvent} is cancelled, the changes will
+ * not take effect + * not take effect
+ *
+ * @return true if this event is cancelled
+ */ + */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return this.isCancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * Sets the cancellation state of this event. A cancelled event will not + * {@inheritDoc}
+ * be executed in the server, but will still pass to other plugins
+ * <p> + * <p>
+ * If cancelled, the item will <b>NOT</b> be consumed regardless of what {@link #willConsumeItem()} says + * If cancelled, the item will <b>NOT</b> be consumed regardless of what {@link #willConsumeItem()} says
+ * <p> + * <p>
+ * If a {@link PlayerChangeBeaconEffectEvent} is cancelled, the changes will not be applied + * If a {@link PlayerChangeBeaconEffectEvent} is cancelled, the changes will not be applied
+ * or saved. + * or saved.
+ *
+ * @param cancel true if you wish to cancel this event
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.isCancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Added PlayerStonecutterRecipeSelectEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerStonecutterRecipeSelectEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerStonecutterRecipeSelectEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerStonecutterRecipeSelectEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerStonecutterRecipeSelectEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..fb1bca3a9d12096c9a2b2663f466a8ff5f2b4319 index 0000000000000000000000000000000000000000..8a7e1cb49ace104af3f9571fbc36b80687141736
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerStonecutterRecipeSelectEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerStonecutterRecipeSelectEvent.java
@@ -0,0 +1,59 @@ @@ -0,0 +1,60 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
@ -24,10 +24,11 @@ index 0000000000000000000000000000000000000000..fb1bca3a9d12096c9a2b2663f466a8ff
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private boolean cancelled;
+ private final StonecutterInventory stonecutterInventory; + private final StonecutterInventory stonecutterInventory;
+ private StonecuttingRecipe stonecuttingRecipe; + private StonecuttingRecipe stonecuttingRecipe;
+ +
+ private boolean cancelled;
+
+ public PlayerStonecutterRecipeSelectEvent(@NotNull Player player, @NotNull StonecutterInventory stonecutterInventory, @NotNull StonecuttingRecipe stonecuttingRecipe) { + public PlayerStonecutterRecipeSelectEvent(@NotNull Player player, @NotNull StonecutterInventory stonecutterInventory, @NotNull StonecuttingRecipe stonecuttingRecipe) {
+ super(player); + super(player);
+ this.stonecutterInventory = stonecutterInventory; + this.stonecutterInventory = stonecutterInventory;
@ -36,12 +37,12 @@ index 0000000000000000000000000000000000000000..fb1bca3a9d12096c9a2b2663f466a8ff
+ +
+ @NotNull + @NotNull
+ public StonecutterInventory getStonecutterInventory() { + public StonecutterInventory getStonecutterInventory() {
+ return stonecutterInventory; + return this.stonecutterInventory;
+ } + }
+ +
+ @NotNull + @NotNull
+ public StonecuttingRecipe getStonecuttingRecipe() { + public StonecuttingRecipe getStonecuttingRecipe() {
+ return stonecuttingRecipe; + return this.stonecuttingRecipe;
+ } + }
+ +
+ public void setStonecuttingRecipe(@NotNull StonecuttingRecipe stonecuttingRecipe) { + public void setStonecuttingRecipe(@NotNull StonecuttingRecipe stonecuttingRecipe) {
@ -50,7 +51,7 @@ index 0000000000000000000000000000000000000000..fb1bca3a9d12096c9a2b2663f466a8ff
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] add DragonEggFormEvent
diff --git a/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java b/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java b/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..5495b87330518363498e1ac5d8f0a832be35fefb index 0000000000000000000000000000000000000000..695c21a296c6d12e1204eba33b92c44e7c2d98b8
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java +++ b/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java
@@ -0,0 +1,63 @@ @@ -0,0 +1,55 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import org.bukkit.Material; +import org.bukkit.Material;
@ -17,59 +17,51 @@ index 0000000000000000000000000000000000000000..5495b87330518363498e1ac5d8f0a832
+import org.bukkit.block.BlockState; +import org.bukkit.block.BlockState;
+import org.bukkit.boss.DragonBattle; +import org.bukkit.boss.DragonBattle;
+import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.EnderDragon;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockFormEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when the {@link EnderDragon} is defeated (killed) in a {@link DragonBattle}, + * Called when the {@link EnderDragon} is defeated (killed) in a {@link DragonBattle},
+ * causing a {@link Material#DRAGON_EGG} (more formally: {@link #getNewState()}) + * causing a {@link Material#DRAGON_EGG} (more formally: {@link #getNewState()})
+ * to possibly appear depending on {@link #isCancelled()}. + * to possibly appear depending on {@link #isCancelled()}.
+ * <p>
+ * <b>This event might be cancelled by default depending on + * <b>This event might be cancelled by default depending on
+ * eg. {@link DragonBattle#hasBeenPreviouslyKilled()} and server configuration.</b> + * e.g. {@link DragonBattle#hasBeenPreviouslyKilled()} and server configuration.</b>
+ */ + */
+public class DragonEggFormEvent extends BlockFormEvent implements Cancellable { +public class DragonEggFormEvent extends BlockFormEvent {
+ private static final HandlerList handlers = new HandlerList(); +
+ private final DragonBattle dragonBattle; + private static final HandlerList HANDLER_LIST = new HandlerList();
+ private boolean cancelled; +
+ + private final DragonBattle dragonBattle;
+ public DragonEggFormEvent(@NotNull Block block, @NotNull BlockState newState, +
+ @NotNull DragonBattle dragonBattle) { + @ApiStatus.Internal
+ super(block, newState); + public DragonEggFormEvent(@NotNull Block block, @NotNull BlockState newState, @NotNull DragonBattle dragonBattle) {
+ this.dragonBattle = dragonBattle; + super(block, newState);
+ } + this.dragonBattle = dragonBattle;
+ + }
+ @Override +
+ public boolean isCancelled() { + /**
+ return cancelled; + * Gets the {@link DragonBattle} associated with this event.
+ } + * Keep in mind that the {@link EnderDragon} is already dead
+ + * when this event is called.
+ @Override + *
+ public void setCancelled(boolean cancelled) { + * @return the dragon battle
+ this.cancelled = cancelled; + */
+ } + @NotNull
+ + public DragonBattle getDragonBattle() {
+ /** + return this.dragonBattle;
+ * Gets the {@link DragonBattle} associated with this event. + }
+ * Keep in mind that the {@link EnderDragon} is already dead +
+ * when this event is called. + @NotNull
+ * + @Override
+ * @return the dragon battle + public HandlerList getHandlers() {
+ */ + return HANDLER_LIST;
+ @NotNull + }
+ public DragonBattle getDragonBattle() { +
+ return dragonBattle; + @NotNull
+ } + public static HandlerList getHandlerList() {
+ + return HANDLER_LIST;
+ @NotNull + }
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] EntityMoveEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc663897f62b index 0000000000000000000000000000000000000000..46990a220f70b04218b14aec1e9efbd46c2ad77c
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java
@@ -0,0 +1,143 @@ @@ -0,0 +1,150 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerMoveEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -27,11 +28,15 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+ * Does not fire for players; use {@link PlayerMoveEvent} for player movement. + * Does not fire for players; use {@link PlayerMoveEvent} for player movement.
+ */ + */
+public class EntityMoveEvent extends EntityEvent implements Cancellable { +public class EntityMoveEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList(); +
+ private boolean canceled; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private Location from; + private Location from;
+ private Location to; + private Location to;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityMoveEvent(@NotNull LivingEntity entity, @NotNull Location from, @NotNull Location to) { + public EntityMoveEvent(@NotNull LivingEntity entity, @NotNull Location from, @NotNull Location to) {
+ super(entity); + super(entity);
+ this.from = from; + this.from = from;
@ -41,15 +46,7 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+ @Override + @Override
+ @NotNull + @NotNull
+ public LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return (LivingEntity) entity; + return (LivingEntity) super.getEntity();
+ }
+
+ public boolean isCancelled() {
+ return canceled;
+ }
+
+ public void setCancelled(boolean cancel) {
+ canceled = cancel;
+ } + }
+ +
+ /** + /**
@ -59,7 +56,7 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+ */ + */
+ @NotNull + @NotNull
+ public Location getFrom() { + public Location getFrom() {
+ return from; + return this.from;
+ } + }
+ +
+ /** + /**
@ -79,7 +76,7 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+ */ + */
+ @NotNull + @NotNull
+ public Location getTo() { + public Location getTo() {
+ return to; + return this.to;
+ } + }
+ +
+ /** + /**
@ -98,7 +95,7 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+ * @return whether the entity has changed position or not + * @return whether the entity has changed position or not
+ */ + */
+ public boolean hasChangedPosition() { + public boolean hasChangedPosition() {
+ return hasExplicitlyChangedPosition() || !from.getWorld().equals(to.getWorld()); + return hasExplicitlyChangedPosition() || !this.from.getWorld().equals(this.to.getWorld());
+ } + }
+ +
+ /** + /**
@ -107,7 +104,7 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+ * @return whether the entity has changed position or not + * @return whether the entity has changed position or not
+ */ + */
+ public boolean hasExplicitlyChangedPosition() { + public boolean hasExplicitlyChangedPosition() {
+ return from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ(); + return this.from.getX() != this.to.getX() || this.from.getY() != this.to.getY() || this.from.getZ() != this.to.getZ();
+ } + }
+ +
+ /** + /**
@ -125,7 +122,7 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+ * @return whether the entity has moved to a new block or not + * @return whether the entity has moved to a new block or not
+ */ + */
+ public boolean hasExplicitlyChangedBlock() { + public boolean hasExplicitlyChangedBlock() {
+ return from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ(); + return this.from.getBlockX() != this.to.getBlockX() || this.from.getBlockY() != this.to.getBlockY() || this.from.getBlockZ() != this.to.getBlockZ();
+ } + }
+ +
+ /** + /**
@ -134,7 +131,7 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+ * @return whether the entity has changed orientation or not + * @return whether the entity has changed orientation or not
+ */ + */
+ public boolean hasChangedOrientation() { + public boolean hasChangedOrientation() {
+ return from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw(); + return this.from.getPitch() != this.to.getPitch() || this.from.getYaw() != this.to.getYaw();
+ } + }
+ +
+ private void validateLocation(@NotNull Location loc) { + private void validateLocation(@NotNull Location loc) {
@ -143,13 +140,23 @@ index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc66
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @Override
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,16 +6,17 @@ Subject: [PATCH] Add worldborder events
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..126fe50b519a8d7cd158f799058cb235f9c4cbdb index 0000000000000000000000000000000000000000..02ac479840c137ca5afcec149ef884e5a5d62928
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java +++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java
@@ -0,0 +1,114 @@ @@ -0,0 +1,117 @@
+package io.papermc.paper.event.world.border; +package io.papermc.paper.event.world.border;
+ +
+import org.bukkit.World; +import org.bukkit.World;
+import org.bukkit.WorldBorder; +import org.bukkit.WorldBorder;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -31,6 +32,7 @@ index 0000000000000000000000000000000000000000..126fe50b519a8d7cd158f799058cb235
+ private long duration; + private long duration;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public WorldBorderBoundsChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Type type, double oldSize, double newSize, long duration) { + public WorldBorderBoundsChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Type type, double oldSize, double newSize, long duration) {
+ super(world, worldBorder); + super(world, worldBorder);
+ this.type = type; + this.type = type;
@ -46,7 +48,7 @@ index 0000000000000000000000000000000000000000..126fe50b519a8d7cd158f799058cb235
+ */ + */
+ @NotNull + @NotNull
+ public Type getType() { + public Type getType() {
+ return type; + return this.type;
+ } + }
+ +
+ /** + /**
@ -55,7 +57,7 @@ index 0000000000000000000000000000000000000000..126fe50b519a8d7cd158f799058cb235
+ * @return the old size + * @return the old size
+ */ + */
+ public double getOldSize() { + public double getOldSize() {
+ return oldSize; + return this.oldSize;
+ } + }
+ +
+ /** + /**
@ -64,7 +66,7 @@ index 0000000000000000000000000000000000000000..126fe50b519a8d7cd158f799058cb235
+ * @return the new size + * @return the new size
+ */ + */
+ public double getNewSize() { + public double getNewSize() {
+ return newSize; + return this.newSize;
+ } + }
+ +
+ /** + /**
@ -73,8 +75,7 @@ index 0000000000000000000000000000000000000000..126fe50b519a8d7cd158f799058cb235
+ * @param newSize the new size + * @param newSize the new size
+ */ + */
+ public void setNewSize(double newSize) { + public void setNewSize(double newSize) {
+ // PAIL: TODO: Magic Values + this.newSize = Math.min(this.worldBorder.getMaxSize(), Math.max(1.0D, newSize));
+ this.newSize = Math.min(6.0E7D, Math.max(1.0D, newSize));
+ } + }
+ +
+ /** + /**
@ -83,7 +84,7 @@ index 0000000000000000000000000000000000000000..126fe50b519a8d7cd158f799058cb235
+ * @return the time in milliseconds for the change + * @return the time in milliseconds for the change
+ */ + */
+ public long getDuration() { + public long getDuration() {
+ return duration; + return this.duration;
+ } + }
+ +
+ /** + /**
@ -95,12 +96,14 @@ index 0000000000000000000000000000000000000000..126fe50b519a8d7cd158f799058cb235
+ public void setDuration(long duration) { + public void setDuration(long duration) {
+ // PAIL: TODO: Magic Values + // PAIL: TODO: Magic Values
+ this.duration = Math.min(9223372036854775L, Math.max(0L, duration)); + this.duration = Math.min(9223372036854775L, Math.max(0L, duration));
+ if (duration >= 0 && type == Type.INSTANT_MOVE) type = Type.STARTED_MOVE; + if (duration >= 0 && this.type == Type.INSTANT_MOVE) {
+ this.type = Type.STARTED_MOVE;
+ }
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
@ -126,15 +129,16 @@ index 0000000000000000000000000000000000000000..126fe50b519a8d7cd158f799058cb235
+} +}
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..60eabed056ee9b9cdd6f5d13307b9be38705330f index 0000000000000000000000000000000000000000..a44964593b7f78c5086dc4928e75ad892e624671
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java +++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java
@@ -0,0 +1,65 @@ @@ -0,0 +1,67 @@
+package io.papermc.paper.event.world.border; +package io.papermc.paper.event.world.border;
+ +
+import org.bukkit.World; +import org.bukkit.World;
+import org.bukkit.WorldBorder; +import org.bukkit.WorldBorder;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -148,6 +152,7 @@ index 0000000000000000000000000000000000000000..60eabed056ee9b9cdd6f5d13307b9be3
+ private final double newSize; + private final double newSize;
+ private final double duration; + private final double duration;
+ +
+ @ApiStatus.Internal
+ public WorldBorderBoundsChangeFinishEvent(@NotNull World world, @NotNull WorldBorder worldBorder, double oldSize, double newSize, double duration) { + public WorldBorderBoundsChangeFinishEvent(@NotNull World world, @NotNull WorldBorder worldBorder, double oldSize, double newSize, double duration) {
+ super(world, worldBorder); + super(world, worldBorder);
+ this.oldSize = oldSize; + this.oldSize = oldSize;
@ -161,7 +166,7 @@ index 0000000000000000000000000000000000000000..60eabed056ee9b9cdd6f5d13307b9be3
+ * @return the old size + * @return the old size
+ */ + */
+ public double getOldSize() { + public double getOldSize() {
+ return oldSize; + return this.oldSize;
+ } + }
+ +
+ /** + /**
@ -170,18 +175,18 @@ index 0000000000000000000000000000000000000000..60eabed056ee9b9cdd6f5d13307b9be3
+ * @return the new size + * @return the new size
+ */ + */
+ public double getNewSize() { + public double getNewSize() {
+ return newSize; + return this.newSize;
+ } + }
+ +
+ /** + /**
+ * Gets the duration this worldborder took to make the change. + * Gets the duration this worldborder took to make the change.
+ * <p> + * <p>
+ * Can be 0 if handlers for {@link io.papermc.paper.event.world.border.WorldBorderCenterChangeEvent} set the duration to 0. + * Can be 0 if handlers for {@link WorldBorderCenterChangeEvent} set the duration to 0.
+ * + *
+ * @return the duration of the transition + * @return the duration of the transition
+ */ + */
+ public double getDuration() { + public double getDuration() {
+ return duration; + return this.duration;
+ } + }
+ +
+ @NotNull + @NotNull
@ -197,10 +202,10 @@ index 0000000000000000000000000000000000000000..60eabed056ee9b9cdd6f5d13307b9be3
+} +}
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4a10c773a8d05a596066e63306dead74c1363fd7 index 0000000000000000000000000000000000000000..a90f67e902c6ae35b2399e6f72a3ff8a5c15d05a
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java +++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java
@@ -0,0 +1,77 @@ @@ -0,0 +1,79 @@
+package io.papermc.paper.event.world.border; +package io.papermc.paper.event.world.border;
+ +
+import org.bukkit.Location; +import org.bukkit.Location;
@ -208,7 +213,7 @@ index 0000000000000000000000000000000000000000..4a10c773a8d05a596066e63306dead74
+import org.bukkit.WorldBorder; +import org.bukkit.WorldBorder;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.world.WorldEvent; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -220,8 +225,10 @@ index 0000000000000000000000000000000000000000..4a10c773a8d05a596066e63306dead74
+ +
+ private final Location oldCenter; + private final Location oldCenter;
+ private Location newCenter; + private Location newCenter;
+
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public WorldBorderCenterChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Location oldCenter, @NotNull Location newCenter) { + public WorldBorderCenterChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Location oldCenter, @NotNull Location newCenter) {
+ super(world, worldBorder); + super(world, worldBorder);
+ this.oldCenter = oldCenter; + this.oldCenter = oldCenter;
@ -235,7 +242,7 @@ index 0000000000000000000000000000000000000000..4a10c773a8d05a596066e63306dead74
+ */ + */
+ @NotNull + @NotNull
+ public Location getOldCenter() { + public Location getOldCenter() {
+ return oldCenter; + return this.oldCenter;
+ } + }
+ +
+ /** + /**
@ -245,7 +252,7 @@ index 0000000000000000000000000000000000000000..4a10c773a8d05a596066e63306dead74
+ */ + */
+ @NotNull + @NotNull
+ public Location getNewCenter() { + public Location getNewCenter() {
+ return newCenter; + return this.newCenter;
+ } + }
+ +
+ /** + /**
@ -259,7 +266,7 @@ index 0000000000000000000000000000000000000000..4a10c773a8d05a596066e63306dead74
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
@ -280,29 +287,30 @@ index 0000000000000000000000000000000000000000..4a10c773a8d05a596066e63306dead74
+} +}
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..67bd469d3680c9554ce6c1d5493826a252682835 index 0000000000000000000000000000000000000000..adb244f9be35c43ff99dbc3a771e1fdfb21da68c
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java +++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java
@@ -0,0 +1,22 @@ @@ -0,0 +1,23 @@
+package io.papermc.paper.event.world.border; +package io.papermc.paper.event.world.border;
+ +
+import org.bukkit.World; +import org.bukkit.World;
+import org.bukkit.WorldBorder; +import org.bukkit.WorldBorder;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.world.WorldEvent; +import org.bukkit.event.world.WorldEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+public abstract class WorldBorderEvent extends WorldEvent { +public abstract class WorldBorderEvent extends WorldEvent {
+ +
+ private final WorldBorder worldBorder; + protected final WorldBorder worldBorder;
+ +
+ public WorldBorderEvent(@NotNull World world, @NotNull WorldBorder worldBorder) { + @ApiStatus.Internal
+ protected WorldBorderEvent(@NotNull World world, @NotNull WorldBorder worldBorder) {
+ super(world); + super(world);
+ this.worldBorder = worldBorder; + this.worldBorder = worldBorder;
+ } + }
+ +
+ @NotNull + @NotNull
+ public WorldBorder getWorldBorder() { + public WorldBorder getWorldBorder() {
+ return worldBorder; + return this.worldBorder;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] added PlayerNameEntityEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java
new file mode 100755 new file mode 100755
index 0000000000000000000000000000000000000000..ef9e53a73eff469bbaa8fb20c634297acb9d1986 index 0000000000000000000000000000000000000000..84736d4a438e9023fbdeac1aea4d8b741cc39b61
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java
@@ -0,0 +1,118 @@ @@ -0,0 +1,110 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..ef9e53a73eff469bbaa8fb20c634297a
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -26,11 +27,15 @@ index 0000000000000000000000000000000000000000..ef9e53a73eff469bbaa8fb20c634297a
+ */ + */
+public class PlayerNameEntityEvent extends PlayerEvent implements Cancellable { +public class PlayerNameEntityEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private LivingEntity entity; + private LivingEntity entity;
+ private Component name; + private Component name;
+ private boolean persistent; + private boolean persistent;
+
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public PlayerNameEntityEvent(@NotNull Player player, @NotNull LivingEntity entity, @NotNull Component name, boolean persistent) { + public PlayerNameEntityEvent(@NotNull Player player, @NotNull LivingEntity entity, @NotNull Component name, boolean persistent) {
+ super(player); + super(player);
+ this.entity = entity; + this.entity = entity;
@ -40,11 +45,12 @@ index 0000000000000000000000000000000000000000..ef9e53a73eff469bbaa8fb20c634297a
+ +
+ /** + /**
+ * Gets the name to be given to the entity. + * Gets the name to be given to the entity.
+ *
+ * @return the name + * @return the name
+ */ + */
+ @Nullable + @Nullable
+ public Component getName() { + public Component getName() {
+ return name; + return this.name;
+ } + }
+ +
+ /** + /**
@ -63,7 +69,7 @@ index 0000000000000000000000000000000000000000..ef9e53a73eff469bbaa8fb20c634297a
+ */ + */
+ @NotNull + @NotNull
+ public LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return entity; + return this.entity;
+ } + }
+ +
+ /** + /**
@ -81,7 +87,7 @@ index 0000000000000000000000000000000000000000..ef9e53a73eff469bbaa8fb20c634297a
+ * @return persistent + * @return persistent
+ */ + */
+ public boolean isPersistent() { + public boolean isPersistent() {
+ return persistent; + return this.persistent;
+ } + }
+ +
+ /** + /**
@ -93,30 +99,16 @@ index 0000000000000000000000000000000000000000..ef9e53a73eff469bbaa8fb20c634297a
+ this.persistent = persistent; + this.persistent = persistent;
+ } + }
+ +
+ /**
+ * Gets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @return true if this event is cancelled
+ */
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /**
+ * Sets the cancellation state of this event. A cancelled event will not
+ * be executed in the server, but will still pass to other plugins.
+ *
+ * @param cancel true if you wish to cancel this event
+ */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {

Datei anzeigen

@ -6,16 +6,17 @@ Subject: [PATCH] Added PlayerDeepSleepEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerDeepSleepEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerDeepSleepEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerDeepSleepEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerDeepSleepEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..e3ee540bb0a5bc578b148fbcf8b5e39ab9c8575c index 0000000000000000000000000000000000000000..54cf2ec5e025fac9a0c8f151ff4f8c83a62b8405
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerDeepSleepEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerDeepSleepEvent.java
@@ -0,0 +1,46 @@ @@ -0,0 +1,48 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -31,13 +32,14 @@ index 0000000000000000000000000000000000000000..e3ee540bb0a5bc578b148fbcf8b5e39a
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public PlayerDeepSleepEvent(@NotNull Player player) { + public PlayerDeepSleepEvent(@NotNull Player player) {
+ super(player); + super(player);
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Added PlayerBedFailEnterEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..e0028733615ddc9e34359f673ca1c3cadb133948 index 0000000000000000000000000000000000000000..6cd803e108dc2e6c0b8afda123123450403ef729
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerBedFailEnterEvent.java
@@ -0,0 +1,119 @@ @@ -0,0 +1,119 @@
@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..e0028733615ddc9e34359f673ca1c3ca
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -29,8 +30,10 @@ index 0000000000000000000000000000000000000000..e0028733615ddc9e34359f673ca1c3ca
+ private final Block bed; + private final Block bed;
+ private boolean willExplode; + private boolean willExplode;
+ private Component message; + private Component message;
+
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public PlayerBedFailEnterEvent(@NotNull Player player, @NotNull FailReason failReason, @NotNull Block bed, boolean willExplode, @Nullable Component message) { + public PlayerBedFailEnterEvent(@NotNull Player player, @NotNull FailReason failReason, @NotNull Block bed, boolean willExplode, @Nullable Component message) {
+ super(player); + super(player);
+ this.failReason = failReason; + this.failReason = failReason;
@ -41,16 +44,16 @@ index 0000000000000000000000000000000000000000..e0028733615ddc9e34359f673ca1c3ca
+ +
+ @NotNull + @NotNull
+ public FailReason getFailReason() { + public FailReason getFailReason() {
+ return failReason; + return this.failReason;
+ } + }
+ +
+ @NotNull + @NotNull
+ public Block getBed() { + public Block getBed() {
+ return bed; + return this.bed;
+ } + }
+ +
+ public boolean getWillExplode() { + public boolean getWillExplode() {
+ return willExplode; + return this.willExplode;
+ } + }
+ +
+ public void setWillExplode(boolean willExplode) { + public void setWillExplode(boolean willExplode) {
@ -59,7 +62,7 @@ index 0000000000000000000000000000000000000000..e0028733615ddc9e34359f673ca1c3ca
+ +
+ @Nullable + @Nullable
+ public Component getMessage() { + public Component getMessage() {
+ return message; + return this.message;
+ } + }
+ +
+ public void setMessage(@Nullable Component message) { + public void setMessage(@Nullable Component message) {
@ -68,19 +71,18 @@ index 0000000000000000000000000000000000000000..e0028733615ddc9e34359f673ca1c3ca
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
+ * Cancel this event. + * {@inheritDoc}
+ * <p> + * <p>
+ * <b>NOTE: This does not cancel the player getting in the bed, but any messages/explosions + * <b>NOTE</b>: This does not cancel the player getting in the bed, but any messages/explosions
+ * that may occur because of the interaction.</b> + * that may occur because of the interaction.
+ * @param cancel true if you wish to cancel this event
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull
@ -94,7 +96,7 @@ index 0000000000000000000000000000000000000000..e0028733615ddc9e34359f673ca1c3ca
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static enum FailReason { + public enum FailReason {
+ /** + /**
+ * The world doesn't allow sleeping (ex. Nether or The End). Entering + * The world doesn't allow sleeping (ex. Nether or The End). Entering
+ * the bed is prevented and the bed explodes. + * the bed is prevented and the bed explodes.
@ -124,8 +126,6 @@ index 0000000000000000000000000000000000000000..e0028733615ddc9e34359f673ca1c3ca
+ /** + /**
+ * Entering the bed is prevented due to there being monsters nearby. + * Entering the bed is prevented due to there being monsters nearby.
+ */ + */
+ NOT_SAFE; + NOT_SAFE
+
+ public static final FailReason[] VALUES = values();
+ } + }
+} +}

Datei anzeigen

@ -6,16 +6,17 @@ Subject: [PATCH] Introduce beacon activation/deactivation events
diff --git a/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java b/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java b/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..7575ca7dd84dee89528ec2e5e5f99f97d8a10f58 index 0000000000000000000000000000000000000000..05609ec9df637c9aa53528218cbc8cda30f0aea1
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java +++ b/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java
@@ -0,0 +1,40 @@ @@ -0,0 +1,43 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import org.bukkit.block.Beacon; +import org.bukkit.block.Beacon;
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -23,8 +24,10 @@ index 0000000000000000000000000000000000000000..7575ca7dd84dee89528ec2e5e5f99f97
+ * Activation occurs when the beacon beam becomes visible. + * Activation occurs when the beacon beam becomes visible.
+ */ + */
+public class BeaconActivatedEvent extends BlockEvent { +public class BeaconActivatedEvent extends BlockEvent {
+ private static final HandlerList handlers = new HandlerList();
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @ApiStatus.Internal
+ public BeaconActivatedEvent(@NotNull Block block) { + public BeaconActivatedEvent(@NotNull Block block) {
+ super(block); + super(block);
+ } + }
@ -36,26 +39,26 @@ index 0000000000000000000000000000000000000000..7575ca7dd84dee89528ec2e5e5f99f97
+ */ + */
+ @NotNull + @NotNull
+ public Beacon getBeacon() { + public Beacon getBeacon() {
+ return (Beacon) block.getState(); + return (Beacon) this.block.getState();
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java b/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java b/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..34f18468b4cfc08717cc3442778c9e85124e5a22 index 0000000000000000000000000000000000000000..dc106d6bfbd9d0ab84b17597d71381a5c0b07d64
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java +++ b/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java
@@ -0,0 +1,43 @@ @@ -0,0 +1,46 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import org.bukkit.Material; +import org.bukkit.Material;
@ -63,6 +66,7 @@ index 0000000000000000000000000000000000000000..34f18468b4cfc08717cc3442778c9e85
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -70,32 +74,34 @@ index 0000000000000000000000000000000000000000..34f18468b4cfc08717cc3442778c9e85
+ * Called when a beacon is deactivated, either because its base block(s) or itself were destroyed. + * Called when a beacon is deactivated, either because its base block(s) or itself were destroyed.
+ */ + */
+public class BeaconDeactivatedEvent extends BlockEvent { +public class BeaconDeactivatedEvent extends BlockEvent {
+ private static final HandlerList handlers = new HandlerList();
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ @ApiStatus.Internal
+ public BeaconDeactivatedEvent(@NotNull Block block) { + public BeaconDeactivatedEvent(@NotNull Block block) {
+ super(block); + super(block);
+ } + }
+ +
+ /** + /**
+ * Returns the beacon that was deactivated. + * Returns the beacon that was deactivated.
+ * This will return null if the beacon does not exist. + * This will return {@code null} if the beacon does not exist.
+ * (which can occur after the deactivation of a now broken beacon) + * (which can occur after the deactivation of a now broken beacon)
+ * + *
+ * @return The beacon that got deactivated, or null if it does not exist. + * @return The beacon that got deactivated, or {@code null} if it does not exist.
+ */ + */
+ @Nullable + @Nullable
+ public Beacon getBeacon() { + public Beacon getBeacon() {
+ return block.getType() == Material.BEACON ? (Beacon) block.getState() : null; + return this.block.getType() == Material.BEACON ? (Beacon) this.block.getState() : null;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add EntityInsideBlockEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityInsideBlockEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityInsideBlockEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/EntityInsideBlockEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityInsideBlockEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..109dd7e6d0e7bb0a83fc4c5230f7d5dc122f2bb5 index 0000000000000000000000000000000000000000..3e98db83060e614c606de41dcd4b4ac4f242edc9
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityInsideBlockEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/EntityInsideBlockEvent.java
@@ -0,0 +1,84 @@ @@ -0,0 +1,86 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..109dd7e6d0e7bb0a83fc4c5230f7d5dc
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -58,6 +59,7 @@ index 0000000000000000000000000000000000000000..109dd7e6d0e7bb0a83fc4c5230f7d5dc
+ private final Block block; + private final Block block;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public EntityInsideBlockEvent(@NotNull Entity entity, @NotNull Block block) { + public EntityInsideBlockEvent(@NotNull Entity entity, @NotNull Block block) {
+ super(entity); + super(entity);
+ this.block = block; + this.block = block;
@ -70,12 +72,12 @@ index 0000000000000000000000000000000000000000..109dd7e6d0e7bb0a83fc4c5230f7d5dc
+ */ + */
+ @NotNull + @NotNull
+ public Block getBlock() { + public Block getBlock() {
+ return block; + return this.block;
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override

Datei anzeigen

@ -6,26 +6,30 @@ Subject: [PATCH] Add PufferFishStateChangeEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/PufferFishStateChangeEvent.java b/src/main/java/io/papermc/paper/event/entity/PufferFishStateChangeEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/PufferFishStateChangeEvent.java b/src/main/java/io/papermc/paper/event/entity/PufferFishStateChangeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..3585457b21aca2a2f1779868a0fa91f8011ad3c9 index 0000000000000000000000000000000000000000..4e04b49c1e2bc2a965c9be2388539d9ed5a58f89
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/PufferFishStateChangeEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/PufferFishStateChangeEvent.java
@@ -0,0 +1,80 @@ @@ -0,0 +1,87 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import org.bukkit.entity.PufferFish; +import org.bukkit.entity.PufferFish;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called just before a {@link PufferFish} inflates or deflates. + * Called just before a {@link PufferFish} inflates or deflates.
+ */ + */
+public class PufferFishStateChangeEvent extends EntityEvent implements Cancellable { +public class PufferFishStateChangeEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ private int newPuffState;
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final int newPuffState;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PufferFishStateChangeEvent(@NotNull PufferFish entity, int newPuffState) { + public PufferFishStateChangeEvent(@NotNull PufferFish entity, int newPuffState) {
+ super(entity); + super(entity);
+ this.newPuffState = newPuffState; + this.newPuffState = newPuffState;
@ -34,7 +38,7 @@ index 0000000000000000000000000000000000000000..3585457b21aca2a2f1779868a0fa91f8
+ @NotNull + @NotNull
+ @Override + @Override
+ public PufferFish getEntity() { + public PufferFish getEntity() {
+ return (PufferFish) entity; + return (PufferFish) super.getEntity();
+ } + }
+ +
+ /** + /**
@ -42,6 +46,7 @@ index 0000000000000000000000000000000000000000..3585457b21aca2a2f1779868a0fa91f8
+ * <p> + * <p>
+ * This is what the {@link PufferFish}'s new puff state will be after this event if it isn't cancelled.<br> + * This is what the {@link PufferFish}'s new puff state will be after this event if it isn't cancelled.<br>
+ * Refer to {@link PufferFish#getPuffState()} to get the current puff state. + * Refer to {@link PufferFish#getPuffState()} to get the current puff state.
+ *
+ * @return The <strong>new</strong> puff state, 0 being not inflated, 1 being slightly inflated and 2 being fully inflated + * @return The <strong>new</strong> puff state, 0 being not inflated, 1 being slightly inflated and 2 being fully inflated
+ */ + */
+ public int getNewPuffState() { + public int getNewPuffState() {
@ -50,24 +55,26 @@ index 0000000000000000000000000000000000000000..3585457b21aca2a2f1779868a0fa91f8
+ +
+ /** + /**
+ * Get if the {@link PufferFish} is going to inflate. + * Get if the {@link PufferFish} is going to inflate.
+ * @return If its going to inflate + *
+ * @return If it's going to inflate
+ */ + */
+ public boolean isInflating() { + public boolean isInflating() {
+ return getNewPuffState() > getEntity().getPuffState(); + return this.newPuffState > this.getEntity().getPuffState();
+ } + }
+ +
+ /** + /**
+ * Get if the {@link PufferFish} is going to deflate. + * Get if the {@link PufferFish} is going to deflate.
+ * @return If its going to deflate + *
+ * @return If it's going to deflate
+ */ + */
+ public boolean isDeflating() { + public boolean isDeflating() {
+ return getNewPuffState() < getEntity().getPuffState(); + return this.newPuffState < this.getEntity().getPuffState();
+ } + }
+ +
+ /** + /**
+ * Set whether or not to cancel the {@link PufferFish} (in/de)flating. + * Set whether to cancel the {@link PufferFish} (in/de)flating.
+ * + *
+ * @param cancel true if you wish to cancel the (in/de)flation + * @param cancel {@code true} if you wish to cancel the (in/de)flation
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
@ -76,17 +83,17 @@ index 0000000000000000000000000000000000000000..3585457b21aca2a2f1779868a0fa91f8
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,34 +6,37 @@ Subject: [PATCH] Add BellRevealRaiderEvent
diff --git a/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java b/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java b/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ac14cb18fe29391899f6adeb00beacb755a556c7 index 0000000000000000000000000000000000000000..e41599405514cd7eea93d842243f6c5c938b93f1
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java +++ b/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java
@@ -0,0 +1,60 @@ @@ -0,0 +1,63 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Raider; +import org.bukkit.entity.Raider;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
+ * Called when a {@link org.bukkit.entity.Raider} is revealed by a bell. + * Called when a {@link Raider} is revealed by a bell.
+ *
+ * @deprecated use {@link org.bukkit.event.block.BellResonateEvent} + * @deprecated use {@link org.bukkit.event.block.BellResonateEvent}
+ */ + */
+@Deprecated +@Deprecated
+public class BellRevealRaiderEvent extends BlockEvent implements Cancellable { +public class BellRevealRaiderEvent extends BlockEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ +
+ private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Raider raider; + private final Raider raider;
+ private boolean cancelled;
+ +
+ public BellRevealRaiderEvent(@NotNull Block theBlock, @NotNull Entity raider) { + @ApiStatus.Internal
+ public BellRevealRaiderEvent(@NotNull Block theBlock, @NotNull Raider raider) {
+ super(theBlock); + super(theBlock);
+ this.raider = (Raider) raider; + this.raider = raider;
+ } + }
+ +
+ /** + /**
@ -43,12 +46,12 @@ index 0000000000000000000000000000000000000000..ac14cb18fe29391899f6adeb00beacb7
+ */ + */
+ @NotNull + @NotNull
+ public Raider getEntity() { + public Raider getEntity() {
+ return raider; + return this.raider;
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ /** + /**
@ -63,10 +66,10 @@ index 0000000000000000000000000000000000000000..ac14cb18fe29391899f6adeb00beacb7
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NotNull HandlerList getHandlerList() { + public static @NotNull HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,35 +6,33 @@ Subject: [PATCH] Add ElderGuardianAppearanceEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/ElderGuardianAppearanceEvent.java b/src/main/java/io/papermc/paper/event/entity/ElderGuardianAppearanceEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/ElderGuardianAppearanceEvent.java b/src/main/java/io/papermc/paper/event/entity/ElderGuardianAppearanceEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4cd551c8311ff8f7321ed2dc6a4efc87162dadfe index 0000000000000000000000000000000000000000..47eabdc8b1a3a3207f197eeca00f3ca5c9940b89
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/ElderGuardianAppearanceEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/ElderGuardianAppearanceEvent.java
@@ -0,0 +1,69 @@ @@ -0,0 +1,67 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import org.bukkit.entity.ElderGuardian; +import org.bukkit.entity.ElderGuardian;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+import java.util.Collections;
+import java.util.List;
+
+/** +/**
+ * Is called when an {@link org.bukkit.entity.ElderGuardian} appears in front of a {@link org.bukkit.entity.Player}. + * Is called when an {@link ElderGuardian} appears in front of a {@link Player}.
+ */ + */
+public class ElderGuardianAppearanceEvent extends EntityEvent implements Cancellable { +public class ElderGuardianAppearanceEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private boolean cancelled;
+ private final Player affectedPlayer; + private final Player affectedPlayer;
+ private boolean cancelled;
+ +
+ public ElderGuardianAppearanceEvent(@NotNull Entity what, @NotNull Player affectedPlayer) { + @ApiStatus.Internal
+ super(what); + public ElderGuardianAppearanceEvent(@NotNull ElderGuardian guardian, @NotNull Player affectedPlayer) {
+ super(guardian);
+ this.affectedPlayer = affectedPlayer; + this.affectedPlayer = affectedPlayer;
+ } + }
+ +
@ -45,7 +43,7 @@ index 0000000000000000000000000000000000000000..4cd551c8311ff8f7321ed2dc6a4efc87
+ */ + */
+ @NotNull + @NotNull
+ public Player getAffectedPlayer() { + public Player getAffectedPlayer() {
+ return affectedPlayer; + return this.affectedPlayer;
+ } + }
+ +
+ /** + /**
@ -55,12 +53,12 @@ index 0000000000000000000000000000000000000000..4cd551c8311ff8f7321ed2dc6a4efc87
+ */ + */
+ @NotNull + @NotNull
+ public ElderGuardian getEntity() { + public ElderGuardian getEntity() {
+ return (ElderGuardian) entity; + return (ElderGuardian) super.getEntity();
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
@ -71,11 +69,11 @@ index 0000000000000000000000000000000000000000..4cd551c8311ff8f7321ed2dc6a4efc87
+ @NotNull + @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add WaterBottleSplashEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/WaterBottleSplashEvent.java b/src/main/java/io/papermc/paper/event/entity/WaterBottleSplashEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/WaterBottleSplashEvent.java b/src/main/java/io/papermc/paper/event/entity/WaterBottleSplashEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4c4c645a1597b5afb62f78dc1cfae62c5fe60fcf index 0000000000000000000000000000000000000000..749d37256b9298fe866852e2d00cee99d8079f07
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/WaterBottleSplashEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/WaterBottleSplashEvent.java
@@ -0,0 +1,125 @@ @@ -0,0 +1,130 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import java.util.Collection; +import java.util.Collection;
@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..4c4c645a1597b5afb62f78dc1cfae62c
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.ThrownPotion; +import org.bukkit.entity.ThrownPotion;
+import org.bukkit.event.entity.PotionSplashEvent; +import org.bukkit.event.entity.PotionSplashEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Unmodifiable; +import org.jetbrains.annotations.Unmodifiable;
+ +
@ -27,9 +28,11 @@ index 0000000000000000000000000000000000000000..4c4c645a1597b5afb62f78dc1cfae62c
+ * different entities in different ways. + * different entities in different ways.
+ */ + */
+public class WaterBottleSplashEvent extends PotionSplashEvent { +public class WaterBottleSplashEvent extends PotionSplashEvent {
+
+ private final @NotNull Set<LivingEntity> rehydrate; + private final @NotNull Set<LivingEntity> rehydrate;
+ private final @NotNull Set<LivingEntity> extinguish; + private final @NotNull Set<LivingEntity> extinguish;
+ +
+ @ApiStatus.Internal
+ public WaterBottleSplashEvent( + public WaterBottleSplashEvent(
+ final @NotNull ThrownPotion potion, + final @NotNull ThrownPotion potion,
+ final @NotNull Map<LivingEntity, Double> affectedEntities, + final @NotNull Map<LivingEntity, Double> affectedEntities,
@ -114,6 +117,7 @@ index 0000000000000000000000000000000000000000..4c4c645a1597b5afb62f78dc1cfae62c
+ +
+ /** + /**
+ * Doesn't make sense for this event as intensity doesn't vary. + * Doesn't make sense for this event as intensity doesn't vary.
+ *
+ * @return a confusing value + * @return a confusing value
+ * @deprecated check if {@link #getToDamage()} contains an entity + * @deprecated check if {@link #getToDamage()} contains an entity
+ */ + */
@ -125,6 +129,7 @@ index 0000000000000000000000000000000000000000..4c4c645a1597b5afb62f78dc1cfae62c
+ +
+ /** + /**
+ * Doesn't make sense for this event as intensity doesn't vary. + * Doesn't make sense for this event as intensity doesn't vary.
+ *
+ * @deprecated use {@link #damageAsWaterSensitive(LivingEntity)} + * @deprecated use {@link #damageAsWaterSensitive(LivingEntity)}
+ * or {@link #doNotDamageAsWaterSensitive(LivingEntity)} to change which entities are + * or {@link #doNotDamageAsWaterSensitive(LivingEntity)} to change which entities are
+ * damaged + * damaged

Datei anzeigen

@ -6,22 +6,24 @@ Subject: [PATCH] Adds PlayerArmSwingEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ce76b07cfaa9173c78e2844add2bc5bb437b1106 index 0000000000000000000000000000000000000000..3e8cbd13eb16e0926130bb8b07e2101602b19565
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java
@@ -0,0 +1,27 @@ @@ -0,0 +1,29 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerAnimationEvent; +import org.bukkit.event.player.PlayerAnimationEvent;
+import org.bukkit.event.player.PlayerAnimationType; +import org.bukkit.event.player.PlayerAnimationType;
+import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.EquipmentSlot;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+public class PlayerArmSwingEvent extends PlayerAnimationEvent { +public class PlayerArmSwingEvent extends PlayerAnimationEvent {
+ +
+ private final EquipmentSlot equipmentSlot; + private final EquipmentSlot equipmentSlot;
+ +
+ @ApiStatus.Internal
+ public PlayerArmSwingEvent(@NotNull Player player, @NotNull EquipmentSlot equipmentSlot) { + public PlayerArmSwingEvent(@NotNull Player player, @NotNull EquipmentSlot equipmentSlot) {
+ super(player, equipmentSlot == EquipmentSlot.HAND ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING); + super(player, equipmentSlot == EquipmentSlot.HAND ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING);
+ this.equipmentSlot = equipmentSlot; + this.equipmentSlot = equipmentSlot;

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerSetSpawnEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..c615dbe6ca1289bb090b8e28e98b9ad7b0af8b2a index 0000000000000000000000000000000000000000..6a823008deaf26f751e598bc967f19c15525acce
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java
@@ -0,0 +1,175 @@ @@ -0,0 +1,178 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
@ -18,11 +18,13 @@ index 0000000000000000000000000000000000000000..c615dbe6ca1289bb090b8e28e98b9ad7
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Called when a player's spawn is set, either by themselves or otherwise.<br> + * Called when a player's spawn is set, either by themselves or otherwise.
+ * <br>
+ * Cancelling this event will prevent the spawn from being set. + * Cancelling this event will prevent the spawn from being set.
+ */ + */
+public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable { +public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable {
@ -37,8 +39,9 @@ index 0000000000000000000000000000000000000000..c615dbe6ca1289bb090b8e28e98b9ad7
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ public PlayerSetSpawnEvent(@NotNull Player who, @NotNull Cause cause, @Nullable Location location, boolean forced, boolean notifyPlayer, @Nullable Component notification) { + @ApiStatus.Internal
+ super(who); + public PlayerSetSpawnEvent(@NotNull Player player, @NotNull Cause cause, @Nullable Location location, boolean forced, boolean notifyPlayer, @Nullable Component notification) {
+ super(player);
+ this.cause = cause; + this.cause = cause;
+ this.location = location; + this.location = location;
+ this.forced = forced; + this.forced = forced;
@ -53,7 +56,7 @@ index 0000000000000000000000000000000000000000..c615dbe6ca1289bb090b8e28e98b9ad7
+ */ + */
+ @NotNull + @NotNull
+ public Cause getCause() { + public Cause getCause() {
+ return cause; + return this.cause;
+ } + }
+ +
+ /** + /**
@ -62,18 +65,18 @@ index 0000000000000000000000000000000000000000..c615dbe6ca1289bb090b8e28e98b9ad7
+ * will change the resulting spawn point of the player. Use + * will change the resulting spawn point of the player. Use
+ * {@link Location#clone()} to get a copy of this location. + * {@link Location#clone()} to get a copy of this location.
+ * + *
+ * @return the spawn location, or null if removing the location + * @return the spawn location, or {@code null} if removing the location
+ */ + */
+ @Nullable + @Nullable
+ public Location getLocation() { + public Location getLocation() {
+ return location; + return this.location;
+ } + }
+ +
+ /** + /**
+ * Sets the location to be set as the spawn location. The yaw + * Sets the location to be set as the spawn location. The yaw
+ * of this location is the spawn angle. + * of this location is the spawn angle.
+ * + *
+ * @param location the spawn location, or null to remove the spawn location + * @param location the spawn location, or {@code null} to remove the spawn location
+ */ + */
+ public void setLocation(@Nullable Location location) { + public void setLocation(@Nullable Location location) {
+ this.location = location; + this.location = location;
@ -82,16 +85,16 @@ index 0000000000000000000000000000000000000000..c615dbe6ca1289bb090b8e28e98b9ad7
+ /** + /**
+ * Gets if this is a force spawn location + * Gets if this is a force spawn location
+ * + *
+ * @return true if forced + * @return {@code true} if forced
+ */ + */
+ public boolean isForced() { + public boolean isForced() {
+ return forced; + return this.forced;
+ } + }
+ +
+ /** + /**
+ * Sets if this is a forced spawn location + * Sets if this is a forced spawn location
+ * + *
+ * @param forced true to force + * @param forced {@code true} to force
+ */ + */
+ public void setForced(boolean forced) { + public void setForced(boolean forced) {
+ this.forced = forced; + this.forced = forced;
@ -101,17 +104,17 @@ index 0000000000000000000000000000000000000000..c615dbe6ca1289bb090b8e28e98b9ad7
+ * Gets if this action will notify the player their spawn + * Gets if this action will notify the player their spawn
+ * has been set. + * has been set.
+ * + *
+ * @return true to notify + * @return {@code true} to notify
+ */ + */
+ public boolean willNotifyPlayer() { + public boolean willNotifyPlayer() {
+ return notifyPlayer; + return this.notifyPlayer;
+ } + }
+ +
+ /** + /**
+ * Sets if this action will notify the player that their spawn + * Sets if this action will notify the player that their spawn
+ * has been set. + * has been set.
+ * + *
+ * @param notifyPlayer true to notify + * @param notifyPlayer {@code true} to notify
+ */ + */
+ public void setNotifyPlayer(boolean notifyPlayer) { + public void setNotifyPlayer(boolean notifyPlayer) {
+ this.notifyPlayer = notifyPlayer; + this.notifyPlayer = notifyPlayer;
@ -121,17 +124,17 @@ index 0000000000000000000000000000000000000000..c615dbe6ca1289bb090b8e28e98b9ad7
+ * Gets the notification message that will be sent to the player + * Gets the notification message that will be sent to the player
+ * if {@link #willNotifyPlayer()} returns true. + * if {@link #willNotifyPlayer()} returns true.
+ * + *
+ * @return null if no notification + * @return {@code null} if no notification
+ */ + */
+ @Nullable + @Nullable
+ public Component getNotification() { + public Component getNotification() {
+ return notification; + return this.notification;
+ } + }
+ +
+ /** + /**
+ * Sets the notification message that will be sent to the player. + * Sets the notification message that will be sent to the player.
+ * + *
+ * @param notification null to send no message + * @param notification {@code null} to send no message
+ */ + */
+ public void setNotification(@Nullable Component notification) { + public void setNotification(@Nullable Component notification) {
+ this.notification = notification; + this.notification = notification;
@ -175,8 +178,8 @@ index 0000000000000000000000000000000000000000..c615dbe6ca1289bb090b8e28e98b9ad7
+ */ + */
+ COMMAND, + COMMAND,
+ /** + /**
+ * When a plugin uses {@link Player#setBedSpawnLocation(Location)} or + * When a plugin uses {@link Player#setRespawnLocation(Location)} or
+ * {@link Player#setBedSpawnLocation(Location, boolean)}. + * {@link Player#setRespawnLocation(Location, boolean)}.
+ */ + */
+ PLUGIN, + PLUGIN,
+ /** + /**

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Added EntityDamageItemEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityDamageItemEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityDamageItemEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/EntityDamageItemEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityDamageItemEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..13862939d7b633f08d5c70bfd2097c47278efcce index 0000000000000000000000000000000000000000..72ac972dea684a3ffac3bd48726746be0620af2e
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityDamageItemEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/EntityDamageItemEvent.java
@@ -0,0 +1,77 @@ @@ -0,0 +1,81 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..13862939d7b633f08d5c70bfd2097c47
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -28,10 +29,13 @@ index 0000000000000000000000000000000000000000..13862939d7b633f08d5c70bfd2097c47
+public class EntityDamageItemEvent extends EntityEvent implements Cancellable { +public class EntityDamageItemEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final ItemStack item; + private final ItemStack item;
+ private int damage; + private int damage;
+
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal
+ public EntityDamageItemEvent(@NotNull Entity entity, @NotNull ItemStack item, int damage) { + public EntityDamageItemEvent(@NotNull Entity entity, @NotNull ItemStack item, int damage) {
+ super(entity); + super(entity);
+ this.item = item; + this.item = item;
@ -45,7 +49,7 @@ index 0000000000000000000000000000000000000000..13862939d7b633f08d5c70bfd2097c47
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getItem() { + public ItemStack getItem() {
+ return item; + return this.item;
+ } + }
+ +
+ /** + /**
@ -54,7 +58,7 @@ index 0000000000000000000000000000000000000000..13862939d7b633f08d5c70bfd2097c47
+ * @return durability change + * @return durability change
+ */ + */
+ public int getDamage() { + public int getDamage() {
+ return damage; + return this.damage;
+ } + }
+ +
+ /** + /**
@ -68,12 +72,12 @@ index 0000000000000000000000000000000000000000..13862939d7b633f08d5c70bfd2097c47
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @NotNull

Datei anzeigen

@ -6,17 +6,17 @@ Subject: [PATCH] Add BlockBreakBlockEvent
diff --git a/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java b/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java diff --git a/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java b/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..51129c5c90dafdba08b7f533a71448ace56381d5 index 0000000000000000000000000000000000000000..4f7535daf0d9967fadb0c6f8afbd3993eace410d
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java +++ b/src/main/java/io/papermc/paper/event/block/BlockBreakBlockEvent.java
@@ -0,0 +1,60 @@ @@ -0,0 +1,61 @@
+package io.papermc.paper.event.block; +package io.papermc.paper.event.block;
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent;
+import org.bukkit.event.block.BlockExpEvent; +import org.bukkit.event.block.BlockExpEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+import java.util.List; +import java.util.List;
@ -30,9 +30,10 @@ index 0000000000000000000000000000000000000000..51129c5c90dafdba08b7f533a71448ac
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final List<ItemStack> drops;
+ private final Block source; + private final Block source;
+ private final List<ItemStack> drops;
+ +
+ @ApiStatus.Internal
+ public BlockBreakBlockEvent(@NotNull Block block, @NotNull Block source, @NotNull List<ItemStack> drops) { + public BlockBreakBlockEvent(@NotNull Block block, @NotNull Block source, @NotNull List<ItemStack> drops) {
+ super(block, 0); + super(block, 0);
+ this.source = source; + this.source = source;
@ -40,13 +41,13 @@ index 0000000000000000000000000000000000000000..51129c5c90dafdba08b7f533a71448ac
+ } + }
+ +
+ /** + /**
+ * Get the drops of this event + * Gets the drops of this event
+ * + *
+ * @return the drops + * @return the drops
+ */ + */
+ @NotNull + @NotNull
+ public List<ItemStack> getDrops() { + public List<ItemStack> getDrops() {
+ return drops; + return this.drops;
+ } + }
+ +
+ /** + /**
@ -56,7 +57,7 @@ index 0000000000000000000000000000000000000000..51129c5c90dafdba08b7f533a71448ac
+ */ + */
+ @NotNull + @NotNull
+ public Block getSource() { + public Block getSource() {
+ return source; + return this.source;
+ } + }
+ +
+ @NotNull + @NotNull

Datei anzeigen

@ -6,19 +6,19 @@ Subject: [PATCH] Add PlayerItemFrameChangeEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerItemFrameChangeEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerItemFrameChangeEvent.java diff --git a/src/main/java/io/papermc/paper/event/player/PlayerItemFrameChangeEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerItemFrameChangeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..451fb94a5802755c255e04aebb40f178bbfbf996 index 0000000000000000000000000000000000000000..7bd61b66db42ecc8c9a3a16f563552414488079e
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerItemFrameChangeEvent.java +++ b/src/main/java/io/papermc/paper/event/player/PlayerItemFrameChangeEvent.java
@@ -0,0 +1,97 @@ @@ -0,0 +1,104 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.Material;
+import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.ItemFrame;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -27,12 +27,15 @@ index 0000000000000000000000000000000000000000..451fb94a5802755c255e04aebb40f178
+ */ + */
+public class PlayerItemFrameChangeEvent extends PlayerEvent implements Cancellable { +public class PlayerItemFrameChangeEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLERS = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ private boolean cancelled;
+ private final ItemFrame itemFrame;
+ private ItemStack itemStack;
+ private final ItemFrameChangeAction action;
+ +
+ private final ItemFrame itemFrame;
+ private final ItemFrameChangeAction action;
+ private ItemStack itemStack;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public PlayerItemFrameChangeEvent(@NotNull Player player, @NotNull ItemFrame itemFrame, + public PlayerItemFrameChangeEvent(@NotNull Player player, @NotNull ItemFrame itemFrame,
+ @NotNull ItemStack itemStack, @NotNull ItemFrameChangeAction action) { + @NotNull ItemStack itemStack, @NotNull ItemFrameChangeAction action) {
+ super(player); + super(player);
@ -43,46 +46,50 @@ index 0000000000000000000000000000000000000000..451fb94a5802755c255e04aebb40f178
+ +
+ /** + /**
+ * Gets the {@link ItemFrame} involved in this event. + * Gets the {@link ItemFrame} involved in this event.
+ *
+ * @return the {@link ItemFrame} + * @return the {@link ItemFrame}
+ */ + */
+ @NotNull + @NotNull
+ public ItemFrame getItemFrame() { + public ItemFrame getItemFrame() {
+ return itemFrame; + return this.itemFrame;
+ } + }
+ +
+ /** + /**
+ * Gets the {@link ItemStack} involved in this event. + * Gets the {@link ItemStack} involved in this event.
+ * This is the item being added, rotated, or removed from the {@link ItemFrame}. + * This is the item being added, rotated, or removed from the {@link ItemFrame}.
+ * <p>If this method returns air, then the resulting item in the ItemFrame will be empty.</p> + * <p>
+ * If this method returns air, then the resulting item in the ItemFrame will be empty.
+ *
+ * @return the {@link ItemStack} being added, rotated, or removed + * @return the {@link ItemStack} being added, rotated, or removed
+ */ + */
+ @NotNull + @NotNull
+ public ItemStack getItemStack() { + public ItemStack getItemStack() {
+ return itemStack; + return this.itemStack;
+ } + }
+ +
+ /** + /**
+ * Sets the {@link ItemStack} that this {@link ItemFrame} holds. + * Sets the {@link ItemStack} that this {@link ItemFrame} holds.
+ * If null is provided, the ItemStack will become air and the result in the ItemFrame will be empty. + * If {@code null} is provided, the ItemStack will become air and the result in the ItemFrame will be empty.
+ *
+ * @param itemStack {@link ItemFrame} item + * @param itemStack {@link ItemFrame} item
+ */ + */
+ public void setItemStack(@Nullable ItemStack itemStack) { + public void setItemStack(@Nullable ItemStack itemStack) {
+ this.itemStack = itemStack == null ? new ItemStack(Material.AIR) : itemStack; + this.itemStack = itemStack == null ? ItemStack.empty() : itemStack;
+ } + }
+ +
+ /** + /**
+ * Gets the action that was performed on this {@link ItemFrame}. + * Gets the action that was performed on this {@link ItemFrame}.
+ * @see ItemFrameChangeAction + *
+ * @return action performed on the item frame in this event + * @return action performed on the item frame in this event
+ */ + */
+ @NotNull + @NotNull
+ public ItemFrameChangeAction getAction() { + public ItemFrameChangeAction getAction() {
+ return action; + return this.action;
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
@ -93,12 +100,12 @@ index 0000000000000000000000000000000000000000..451fb94a5802755c255e04aebb40f178
+ @Override + @Override
+ @NotNull + @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLERS; + return HANDLER_LIST;
+ } + }
+ +
+ public enum ItemFrameChangeAction { + public enum ItemFrameChangeAction {

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add TameableDeathMessageEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/TameableDeathMessageEvent.java b/src/main/java/io/papermc/paper/event/entity/TameableDeathMessageEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/TameableDeathMessageEvent.java b/src/main/java/io/papermc/paper/event/entity/TameableDeathMessageEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..70cd37aefbd5d64c798ab2fc3b6d502134690348 index 0000000000000000000000000000000000000000..5d449b90829bca7a6ff3060b637561d8f99dc156
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/TameableDeathMessageEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/TameableDeathMessageEvent.java
@@ -0,0 +1,69 @@ @@ -0,0 +1,72 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..70cd37aefbd5d64c798ab2fc3b6d5021
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+ +
+/** +/**
@ -24,12 +25,14 @@ index 0000000000000000000000000000000000000000..70cd37aefbd5d64c798ab2fc3b6d5021
+ */ + */
+public class TameableDeathMessageEvent extends EntityEvent implements Cancellable { +public class TameableDeathMessageEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ private boolean cancelled;
+ private Component deathMessage;
+ +
+ public TameableDeathMessageEvent(@NotNull Tameable what, @NotNull Component deathMessage) { + private Component deathMessage;
+ super(what); + private boolean cancelled;
+
+ @ApiStatus.Internal
+ public TameableDeathMessageEvent(@NotNull Tameable tameable, @NotNull Component deathMessage) {
+ super(tameable);
+ this.deathMessage = deathMessage; + this.deathMessage = deathMessage;
+ } + }
+ +
@ -49,12 +52,18 @@ index 0000000000000000000000000000000000000000..70cd37aefbd5d64c798ab2fc3b6d5021
+ */ + */
+ @NotNull + @NotNull
+ public Component deathMessage() { + public Component deathMessage() {
+ return deathMessage; + return this.deathMessage;
+ }
+
+ @NotNull
+ @Override
+ public Tameable getEntity() {
+ return (Tameable) super.getEntity();
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
@ -64,18 +73,12 @@ index 0000000000000000000000000000000000000000..70cd37aefbd5d64c798ab2fc3b6d5021
+ +
+ @NotNull + @NotNull
+ @Override + @Override
+ public Tameable getEntity() {
+ return (Tameable) super.getEntity();
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull + @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}

Datei anzeigen

@ -37,33 +37,39 @@ index 0000000000000000000000000000000000000000..bb68e6a2528eee81eb3f26f22b9c3550
+} +}
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityDyeEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityDyeEvent.java diff --git a/src/main/java/io/papermc/paper/event/entity/EntityDyeEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityDyeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..aefbaccd32f1ab25a4da63bdc878922e0c220478 index 0000000000000000000000000000000000000000..c43a3ad32902dbb13287e801375213745ce07b3c
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityDyeEvent.java +++ b/src/main/java/io/papermc/paper/event/entity/EntityDyeEvent.java
@@ -0,0 +1,75 @@ @@ -0,0 +1,81 @@
+package io.papermc.paper.event.entity; +package io.papermc.paper.event.entity;
+ +
+import org.bukkit.DyeColor; +import org.bukkit.DyeColor;
+import org.bukkit.entity.Cat;
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.entity.Sheep;
+import org.bukkit.entity.Wolf;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Called when an entity is dyed. Currently, this is called for {@link org.bukkit.entity.Sheep} + * Called when an entity is dyed. Currently, this is called for {@link Sheep}
+ * being dyed, and {@link org.bukkit.entity.Wolf}/{@link org.bukkit.entity.Cat} collars being dyed. + * being dyed, and {@link Wolf}/{@link Cat} collars being dyed.
+ */ + */
+public class EntityDyeEvent extends EntityEvent implements Cancellable { +public class EntityDyeEvent extends EntityEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private DyeColor dyeColor;
+ private final Player player; + private final Player player;
+ private boolean cancel; + private DyeColor dyeColor;
+ +
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityDyeEvent(@NotNull Entity entity, @NotNull DyeColor dyeColor, @Nullable Player player) { + public EntityDyeEvent(@NotNull Entity entity, @NotNull DyeColor dyeColor, @Nullable Player player) {
+ super(entity); + super(entity);
+ this.dyeColor = dyeColor; + this.dyeColor = dyeColor;
@ -91,20 +97,20 @@ index 0000000000000000000000000000000000000000..aefbaccd32f1ab25a4da63bdc878922e
+ /** + /**
+ * Returns the player dyeing the entity, if available. + * Returns the player dyeing the entity, if available.
+ * + *
+ * @return player or null + * @return player or {@code null}
+ */ + */
+ public @Nullable Player getPlayer() { + public @Nullable Player getPlayer() {
+ return player; + return this.player;
+ } + }
+ +
+ @Override + @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return this.cancel; + return this.cancelled;
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(boolean cancel) {
+ this.cancel = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override
@ -117,7 +123,7 @@ index 0000000000000000000000000000000000000000..aefbaccd32f1ab25a4da63bdc878922e
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/entity/Cat.java b/src/main/java/org/bukkit/entity/Cat.java diff --git a/src/main/java/org/bukkit/entity/Cat.java b/src/main/java/org/bukkit/entity/Cat.java
index 9bc385682472418c787481bbc809f238194d5918..4ea1027c8540cdba82acf829d0720846b3a13e3e 100644 index 0534fbc228f64cf3b361ab097d9b88212bdb0f36..d03adfaa4176617ef2ace2754fe02b63860e3aee 100644
--- a/src/main/java/org/bukkit/entity/Cat.java --- a/src/main/java/org/bukkit/entity/Cat.java
+++ b/src/main/java/org/bukkit/entity/Cat.java +++ b/src/main/java/org/bukkit/entity/Cat.java
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull; @@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen