Finish converting all events to jspecify annotations

This commit is contained in:
Jake Potrebic 2024-09-29 16:48:34 -07:00
parent fa97c59a4e
commit 29a25df60e
78 changed files with 757 additions and 883 deletions

View File

@ -15,7 +15,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.checkerframework.checker.nullness.qual.NonNull;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.NullMarked;
+ +

View File

@ -65,6 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -13,30 +13,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.CartographyInventory;
+import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.ClickType;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryAction;
+import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryClickEvent;
+import org.jetbrains.annotations.NotNull; +import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.CartographyInventory;
+import org.bukkit.inventory.InventoryView;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when the recipe of an Item is completed inside a cartography table. + * Called when the recipe of an Item is completed inside a cartography table.
+ */ + */
+@NullMarked
+public class CartographyItemEvent extends InventoryClickEvent { +public class CartographyItemEvent extends InventoryClickEvent {
+
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public CartographyItemEvent(@NotNull InventoryView view, @NotNull InventoryType.SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action) { + public CartographyItemEvent(final InventoryView view, final InventoryType.SlotType type, final int slot, final ClickType click, final InventoryAction action) {
+ super(view, type, slot, click, action); + super(view, type, slot, click, action);
+ } + }
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public CartographyItemEvent(@NotNull InventoryView view, @NotNull InventoryType.SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action, int key) { + public CartographyItemEvent(final InventoryView view, final InventoryType.SlotType type, final int slot, final ClickType click, final InventoryAction action, final int key) {
+ super(view, type, slot, click, action, key); + super(view, type, slot, click, action, key);
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public CartographyInventory getInventory() { + public CartographyInventory getInventory() {
+ return (CartographyInventory) super.getInventory(); + return (CartographyInventory) super.getInventory();

View File

@ -51,6 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The elder guardian + * @return The elder guardian
+ */ + */
+ @Override
+ public ElderGuardian getEntity() { + public ElderGuardian getEntity() {
+ return (ElderGuardian) super.getEntity(); + return (ElderGuardian) super.getEntity();
+ } + }

View File

@ -12,15 +12,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.entity.ai; +package com.destroystokyo.paper.entity.ai;
+ +
+import org.jetbrains.annotations.NotNull;
+
+import java.util.EnumSet; +import java.util.EnumSet;
+
+import org.bukkit.entity.Mob; +import org.bukkit.entity.Mob;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Represents an AI goal of an entity + * Represents an AI goal of an entity
+ */ + */
+@NullMarked
+public interface Goal<T extends Mob> { +public interface Goal<T extends Mob> {
+ +
+ /** + /**
@ -36,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return if this goal should stay active + * @return if this goal should stay active
+ */ + */
+ default boolean shouldStayActive() { + default boolean shouldStayActive() {
+ return shouldActivate(); + return this.shouldActivate();
+ } + }
+ +
+ /** + /**
@ -63,17 +62,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the goal key + * @return the goal key
+ */ + */
+ @NotNull
+ GoalKey<T> getKey(); + GoalKey<T> getKey();
+ +
+ /** + /**
+ * Returns a list of all applicable flags for this goal.<br> + * Returns a list of all applicable flags for this goal.<br>
+ * + * <p>
+ * This method is only called on construction. + * This method is only called on construction.
+ * + *
+ * @return the subtypes. + * @return the subtypes.
+ */ + */
+ @NotNull
+ EnumSet<GoalType> getTypes(); + EnumSet<GoalType> getTypes();
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/GoalKey.java b/src/main/java/com/destroystokyo/paper/entity/ai/GoalKey.java diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/GoalKey.java b/src/main/java/com/destroystokyo/paper/entity/ai/GoalKey.java
@ -85,64 +82,59 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package com.destroystokyo.paper.entity.ai; +package com.destroystokyo.paper.entity.ai;
+ +
+import com.google.common.base.Objects; +import com.google.common.base.Objects;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.StringJoiner; +import java.util.StringJoiner;
+
+import org.bukkit.NamespacedKey; +import org.bukkit.NamespacedKey;
+import org.bukkit.entity.Mob; +import org.bukkit.entity.Mob;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ *
+ * Used to identify a Goal. Consists of a {@link NamespacedKey} and the type of mob the goal can be applied to + * Used to identify a Goal. Consists of a {@link NamespacedKey} and the type of mob the goal can be applied to
+ * + *
+ * @param <T> the type of mob the goal can be applied to + * @param <T> the type of mob the goal can be applied to
+ */ + */
+public class GoalKey<T extends Mob> { +@NullMarked
+public final class GoalKey<T extends Mob> {
+ +
+ private final Class<T> entityClass; + private final Class<T> entityClass;
+ private final NamespacedKey namespacedKey; + private final NamespacedKey namespacedKey;
+ +
+ private GoalKey(@NotNull Class<T> entityClass, @NotNull NamespacedKey namespacedKey) { + private GoalKey(Class<T> entityClass, NamespacedKey namespacedKey) {
+ this.entityClass = entityClass; + this.entityClass = entityClass;
+ this.namespacedKey = namespacedKey; + this.namespacedKey = namespacedKey;
+ } + }
+ +
+ @NotNull
+ public Class<T> getEntityClass() { + public Class<T> getEntityClass() {
+ return entityClass; + return this.entityClass;
+ } + }
+ +
+ @NotNull
+ public NamespacedKey getNamespacedKey() { + public NamespacedKey getNamespacedKey() {
+ return namespacedKey; + return this.namespacedKey;
+ } + }
+ +
+ @Override + @Override
+ public boolean equals(Object o) { + public boolean equals(@Nullable Object o) {
+ if (this == o) return true; + if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false;
+ GoalKey<?> goalKey = (GoalKey<?>) o; + GoalKey<?> goalKey = (GoalKey<?>) o;
+ return Objects.equal(entityClass, goalKey.entityClass) && + return Objects.equal(this.entityClass, goalKey.entityClass) &&
+ Objects.equal(namespacedKey, goalKey.namespacedKey); + Objects.equal(this.namespacedKey, goalKey.namespacedKey);
+ } + }
+ +
+ @Override + @Override
+ public int hashCode() { + public int hashCode() {
+ return Objects.hashCode(entityClass, namespacedKey); + return Objects.hashCode(this.entityClass, this.namespacedKey);
+ } + }
+ +
+ @Override + @Override
+ public String toString() { + public String toString() {
+ return new StringJoiner(", ", GoalKey.class.getSimpleName() + "[", "]") + return new StringJoiner(", ", GoalKey.class.getSimpleName() + "[", "]")
+ .add("entityClass=" + entityClass) + .add("entityClass=" + this.entityClass)
+ .add("namespacedKey=" + namespacedKey) + .add("namespacedKey=" + this.namespacedKey)
+ .toString(); + .toString();
+ } + }
+ +
+ @NotNull + public static <A extends Mob> GoalKey<A> of(Class<A> entityClass, NamespacedKey namespacedKey) {
+ public static <A extends Mob> GoalKey<A> of(@NotNull Class<A> entityClass, @NotNull NamespacedKey namespacedKey) {
+ return new GoalKey<>(entityClass, namespacedKey); + return new GoalKey<>(entityClass, namespacedKey);
+ } + }
+} +}
@ -177,53 +169,45 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.entity.ai; +package com.destroystokyo.paper.entity.ai;
+ +
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+ +
+import java.util.Collection; +import java.util.Collection;
+
+import org.bukkit.entity.Mob; +import org.bukkit.entity.Mob;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Represents a part of the "brain" of a mob. It tracks all tasks (running or not), allows adding and removing goals + * Represents a part of the "brain" of a mob. It tracks all tasks (running or not), allows adding and removing goals
+ */ + */
+@NullMarked
+public interface MobGoals { +public interface MobGoals {
+ +
+ <T extends Mob> void addGoal(@NotNull T mob, int priority, @NotNull Goal<T> goal); + <T extends Mob> void addGoal(T mob, int priority, Goal<T> goal);
+ +
+ <T extends Mob> void removeGoal(@NotNull T mob, @NotNull Goal<T> goal); + <T extends Mob> void removeGoal(T mob, Goal<T> goal);
+ +
+ <T extends Mob> void removeAllGoals(@NotNull T mob); + <T extends Mob> void removeAllGoals(T mob);
+ +
+ <T extends Mob> void removeAllGoals(@NotNull T mob, @NotNull GoalType type); + <T extends Mob> void removeAllGoals(T mob, GoalType type);
+ +
+ <T extends Mob> void removeGoal(@NotNull T mob, @NotNull GoalKey<T> key); + <T extends Mob> void removeGoal(T mob, GoalKey<T> key);
+ +
+ <T extends Mob> boolean hasGoal(@NotNull T mob, @NotNull GoalKey<T> key); + <T extends Mob> boolean hasGoal(T mob, GoalKey<T> key);
+ +
+ @Nullable + <T extends Mob> @Nullable Goal<T> getGoal(T mob, GoalKey<T> key);
+ <T extends Mob> Goal<T> getGoal(@NotNull T mob, @NotNull GoalKey<T> key);
+ +
+ @NotNull + <T extends Mob> Collection<Goal<T>> getGoals(T mob, GoalKey<T> key);
+ <T extends Mob> Collection<Goal<T>> getGoals(@NotNull T mob, @NotNull GoalKey<T> key);
+ +
+ @NotNull + <T extends Mob> Collection<Goal<T>> getAllGoals(T mob);
+ <T extends Mob> Collection<Goal<T>> getAllGoals(@NotNull T mob);
+ +
+ @NotNull + <T extends Mob> Collection<Goal<T>> getAllGoals(T mob, GoalType type);
+ <T extends Mob> Collection<Goal<T>> getAllGoals(@NotNull T mob, @NotNull GoalType type);
+ +
+ @NotNull + <T extends Mob> Collection<Goal<T>> getAllGoalsWithout(T mob, GoalType type);
+ <T extends Mob> Collection<Goal<T>> getAllGoalsWithout(@NotNull T mob, @NotNull GoalType type);
+ +
+ @NotNull + <T extends Mob> Collection<Goal<T>> getRunningGoals(T mob);
+ <T extends Mob> Collection<Goal<T>> getRunningGoals(@NotNull T mob);
+ +
+ @NotNull + <T extends Mob> Collection<Goal<T>> getRunningGoals(T mob, GoalType type);
+ <T extends Mob> Collection<Goal<T>> getRunningGoals(@NotNull T mob, @NotNull GoalType type);
+ +
+ @NotNull + <T extends Mob> Collection<Goal<T>> getRunningGoalsWithout(T mob, GoalType type);
+ <T extends Mob> Collection<Goal<T>> getRunningGoalsWithout(@NotNull T mob, @NotNull GoalType type);
+} +}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View File

@ -51,10 +51,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.ignited = ignited; + this.ignited = ignited;
+ } + }
+ +
+ @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return this.cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override
+ public void setCancelled(final boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }

View File

@ -14,10 +14,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import net.kyori.adventure.translation.Translatable; +import net.kyori.adventure.translation.Translatable;
+import net.kyori.adventure.util.Index; +import net.kyori.adventure.util.Index;
+import org.jetbrains.annotations.NotNull;
+
+import org.bukkit.inventory.MainHand; +import org.bukkit.inventory.MainHand;
+import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public final class ClientOption<T> { +public final class ClientOption<T> {
+ +
+ public static final ClientOption<SkinParts> SKIN_PARTS = new ClientOption<>(SkinParts.class); + public static final ClientOption<SkinParts> SKIN_PARTS = new ClientOption<>(SkinParts.class);
@ -31,13 +31,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ private final Class<T> type; + private final Class<T> type;
+ +
+ private ClientOption(@NotNull Class<T> type) { + private ClientOption(final Class<T> type) {
+ this.type = type; + this.type = type;
+ } + }
+ +
+ @NotNull
+ public Class<T> getType() { + public Class<T> getType() {
+ return type; + return this.type;
+ } + }
+ +
+ public enum ChatVisibility implements Translatable { + public enum ChatVisibility implements Translatable {
@ -46,15 +45,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ HIDDEN("hidden"), + HIDDEN("hidden"),
+ UNKNOWN("unknown"); + UNKNOWN("unknown");
+ +
+ public static Index<String, ChatVisibility> NAMES = Index.create(ChatVisibility.class, chatVisibility -> chatVisibility.name); + public static final Index<String, ChatVisibility> NAMES = Index.create(ChatVisibility.class, chatVisibility -> chatVisibility.name);
+ private final String name; + private final String name;
+ +
+ ChatVisibility(String name) { + ChatVisibility(final String name) {
+ this.name = name; + this.name = name;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull String translationKey() { + public String translationKey() {
+ if (this == UNKNOWN) { + if (this == UNKNOWN) {
+ throw new UnsupportedOperationException(this.name + " doesn't have a translation key"); + throw new UnsupportedOperationException(this.name + " doesn't have a translation key");
+ } + }
@ -99,18 +98,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import com.destroystokyo.paper.ClientOption; +import com.destroystokyo.paper.ClientOption;
+import com.destroystokyo.paper.ClientOption.ChatVisibility; +import com.destroystokyo.paper.ClientOption.ChatVisibility;
+import com.destroystokyo.paper.SkinParts; +import com.destroystokyo.paper.SkinParts;
+import java.util.Map;
+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.inventory.MainHand; +import org.bukkit.inventory.MainHand;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+
+import java.util.Map;
+ +
+/** +/**
+ * Called when the player changes their client settings + * Called when the player changes their client settings
+ */ + */
+@NullMarked
+public class PlayerClientOptionsChangeEvent extends PlayerEvent { +public class PlayerClientOptionsChangeEvent extends PlayerEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -125,7 +124,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final boolean textFilteringEnabled; + private final boolean textFilteringEnabled;
+ +
+ @Deprecated + @Deprecated
+ public PlayerClientOptionsChangeEvent(@NotNull Player player, @NotNull String locale, int viewDistance, @NotNull ChatVisibility chatVisibility, boolean chatColors, @NotNull SkinParts skinParts, @NotNull MainHand mainHand) { + public PlayerClientOptionsChangeEvent(final Player player, final String locale, final int viewDistance, final ChatVisibility chatVisibility, final boolean chatColors, final SkinParts skinParts, final MainHand mainHand) {
+ super(player); + super(player);
+ this.locale = locale; + this.locale = locale;
+ this.viewDistance = viewDistance; + this.viewDistance = viewDistance;
@ -138,7 +137,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerClientOptionsChangeEvent(@NotNull Player player, @NotNull Map<ClientOption<?>, ?> options) { + public PlayerClientOptionsChangeEvent(final Player player, final Map<ClientOption<?>, ?> options) {
+ super(player); + super(player);
+ +
+ this.locale = (String) options.get(ClientOption.LOCALE); + this.locale = (String) options.get(ClientOption.LOCALE);
@ -151,7 +150,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.textFilteringEnabled = (boolean) options.get(ClientOption.TEXT_FILTERING_ENABLED); + this.textFilteringEnabled = (boolean) options.get(ClientOption.TEXT_FILTERING_ENABLED);
+ } + }
+ +
+ @NotNull
+ public String getLocale() { + public String getLocale() {
+ return this.locale; + return this.locale;
+ } + }
@ -168,7 +166,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.viewDistance != this.player.getClientOption(ClientOption.VIEW_DISTANCE); + return this.viewDistance != this.player.getClientOption(ClientOption.VIEW_DISTANCE);
+ } + }
+ +
+ @NotNull
+ public ChatVisibility getChatVisibility() { + public ChatVisibility getChatVisibility() {
+ return this.chatVisibility; + return this.chatVisibility;
+ } + }
@ -185,7 +182,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.chatColors != this.player.getClientOption(ClientOption.CHAT_COLORS_ENABLED); + return this.chatColors != this.player.getClientOption(ClientOption.CHAT_COLORS_ENABLED);
+ } + }
+ +
+ @NotNull
+ public SkinParts getSkinParts() { + public SkinParts getSkinParts() {
+ return this.skinparts; + return this.skinparts;
+ } + }
@ -194,7 +190,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.skinparts.getRaw() != this.player.getClientOption(ClientOption.SKIN_PARTS).getRaw(); + return this.skinparts.getRaw() != this.player.getClientOption(ClientOption.SKIN_PARTS).getRaw();
+ } + }
+ +
+ @NotNull
+ public MainHand getMainHand() { + public MainHand getMainHand() {
+ return this.mainHand; + return this.mainHand;
+ } + }
@ -220,12 +215,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -20,24 +20,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called after a player is granted a criteria in an advancement. + * Called after a player is granted a criteria in an advancement.
+ * If cancelled the criteria will be revoked. + * If cancelled the criteria will be revoked.
+ */ + */
+@NullMarked
+public class PlayerAdvancementCriterionGrantEvent extends PlayerEvent implements Cancellable { +public class PlayerAdvancementCriterionGrantEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Advancement advancement; + private final Advancement advancement;
+ @NotNull private final String criterion; + private final String criterion;
+ @NotNull private final AdvancementProgress advancementProgress; + private final AdvancementProgress advancementProgress;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerAdvancementCriterionGrantEvent(@NotNull Player player, @NotNull Advancement advancement, @NotNull String criterion) { + public PlayerAdvancementCriterionGrantEvent(final Player player, final Advancement advancement, final String criterion) {
+ super(player); + super(player);
+ this.advancement = advancement; + this.advancement = advancement;
+ this.criterion = criterion; + this.criterion = criterion;
@ -49,7 +50,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return affected advancement + * @return affected advancement
+ */ + */
+ @NotNull
+ public Advancement getAdvancement() { + public Advancement getAdvancement() {
+ return this.advancement; + return this.advancement;
+ } + }
@ -59,7 +59,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return granted criterion + * @return granted criterion
+ */ + */
+ @NotNull
+ public String getCriterion() { + public String getCriterion() {
+ return this.criterion; + return this.criterion;
+ } + }
@ -69,7 +68,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return advancement progress + * @return advancement progress
+ */ + */
+ @NotNull
+ public AdvancementProgress getAdvancementProgress() { + public AdvancementProgress getAdvancementProgress() {
+ return this.advancementProgress; + return this.advancementProgress;
+ } + }
@ -80,17 +78,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -12,16 +12,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.player; +package com.destroystokyo.paper.event.player;
+ +
+import java.util.Set;
+import org.bukkit.Material; +import org.bukkit.Material;
+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.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+
+import java.util.Set;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+import static org.bukkit.Material.*; +import static org.bukkit.Material.*;
+ +
@ -30,16 +29,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <p> + * <p>
+ * 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>
+ */ + */
+@NullMarked
+public class PlayerArmorChangeEvent extends PlayerEvent { +public class PlayerArmorChangeEvent extends PlayerEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final SlotType slotType; + private final SlotType slotType;
+ @NotNull private final ItemStack oldItem; + private final ItemStack oldItem;
+ @NotNull private final ItemStack newItem; + private final ItemStack newItem;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerArmorChangeEvent(@NotNull Player player, @NotNull SlotType slotType, @NotNull ItemStack oldItem, @NotNull ItemStack newItem) { + public PlayerArmorChangeEvent(final Player player, final SlotType slotType, final ItemStack oldItem, final ItemStack newItem) {
+ super(player); + super(player);
+ this.slotType = slotType; + this.slotType = slotType;
+ this.oldItem = oldItem; + this.oldItem = oldItem;
@ -51,7 +51,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return type of slot being altered + * @return type of slot being altered
+ */ + */
+ @NotNull
+ public SlotType getSlotType() { + public SlotType getSlotType() {
+ return this.slotType; + return this.slotType;
+ } + }
@ -61,7 +60,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return old item + * @return old item
+ */ + */
+ @NotNull
+ public ItemStack getOldItem() { + public ItemStack getOldItem() {
+ return this.oldItem; + return this.oldItem;
+ } + }
@ -71,18 +69,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return new item + * @return new item
+ */ + */
+ @NotNull
+ public ItemStack getNewItem() { + public ItemStack getNewItem() {
+ return this.newItem; + return this.newItem;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -95,7 +90,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ private final Set<Material> types; + private final Set<Material> types;
+ +
+ SlotType(Material... types) { + SlotType(final Material... types) {
+ this.types = Set.of(types); + this.types = Set.of(types);
+ } + }
+ +
@ -105,7 +100,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return immutable set of material types + * @return immutable set of material types
+ */ + */
+ @NotNull
+ public Set<Material> getTypes() { + public Set<Material> getTypes() {
+ return this.types; + return this.types;
+ } + }
@ -116,9 +110,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param material material to get slot by + * @param material material to get slot by
+ * @return slot type the material will go in, or {@code null} if it won't + * @return slot type the material will go in, or {@code null} if it won't
+ */ + */
+ @Nullable + public static @Nullable SlotType getByMaterial(final Material material) {
+ public static SlotType getByMaterial(@NotNull Material material) { + for (final SlotType slotType : values()) {
+ for (SlotType slotType : values()) {
+ if (slotType.getTypes().contains(material)) { + if (slotType.getTypes().contains(material)) {
+ return slotType; + return slotType;
+ } + }
@ -132,7 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param material material to check + * @param material material to check
+ * @return whether this material can be equipped + * @return whether this material can be equipped
+ */ + */
+ public static boolean isEquipable(@NotNull Material material) { + public static boolean isEquipable(final Material material) {
+ return getByMaterial(material) != null; + return getByMaterial(material) != null;
+ } + }
+ } + }

View File

@ -18,22 +18,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when processing a player's attack on an entity when the player's attack strength cooldown is reset + * Called when processing a player's attack on an entity when the player's attack strength cooldown is reset
+ */ + */
+@NullMarked
+public class PlayerAttackEntityCooldownResetEvent extends PlayerEvent implements Cancellable { +public class PlayerAttackEntityCooldownResetEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Entity attackedEntity; + private final Entity attackedEntity;
+ private final float cooledAttackStrength; + private final float cooledAttackStrength;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerAttackEntityCooldownResetEvent(@NotNull Player player, @NotNull Entity attackedEntity, float cooledAttackStrength) { + public PlayerAttackEntityCooldownResetEvent(final Player player, final Entity attackedEntity, final float cooledAttackStrength) {
+ super(player); + super(player);
+ this.attackedEntity = attackedEntity; + this.attackedEntity = attackedEntity;
+ this.cooledAttackStrength = cooledAttackStrength; + this.cooledAttackStrength = cooledAttackStrength;
@ -53,7 +54,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the entity attacked by the player + * @return the entity attacked by the player
+ */ + */
+ @NotNull
+ public Entity getAttackedEntity() { + public Entity getAttackedEntity() {
+ return this.attackedEntity; + return this.attackedEntity;
+ } + }
@ -74,16 +74,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Cancelling this event will prevent the target player from having their cooldown reset from attacking this entity + * Cancelling this event will prevent the target player from having their cooldown reset from attacking this entity
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NotNull HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+} +}

View File

@ -17,11 +17,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Runs when a player attempts to move, but is prevented from doing so by the server + * Runs when a player attempts to move, but is prevented from doing so by the server
+ */ + */
+@NullMarked
+public class PlayerFailMoveEvent extends PlayerEvent { +public class PlayerFailMoveEvent extends PlayerEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -33,8 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean logWarning; + private boolean logWarning;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerFailMoveEvent(@NotNull Player player, @NotNull FailReason failReason, boolean allowed, + public PlayerFailMoveEvent(final Player player, final FailReason failReason, final boolean allowed, final boolean logWarning, final Location from, final Location to) {
+ boolean logWarning, @NotNull Location from, @NotNull Location to) {
+ super(player); + super(player);
+ this.failReason = failReason; + this.failReason = failReason;
+ this.allowed = allowed; + this.allowed = allowed;
@ -48,7 +48,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The reason the movement was prevented + * @return The reason the movement was prevented
+ */ + */
+ @NotNull
+ public FailReason getFailReason() { + public FailReason getFailReason() {
+ return this.failReason; + return this.failReason;
+ } + }
@ -58,7 +57,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Location the player moved from + * @return Location the player moved from
+ */ + */
+ @NotNull
+ public Location getFrom() { + public Location getFrom() {
+ return this.from.clone(); + return this.from.clone();
+ } + }
@ -68,7 +66,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Location the player tried to move to + * @return Location the player tried to move to
+ */ + */
+ @NotNull
+ public Location getTo() { + public Location getTo() {
+ return this.to.clone(); + return this.to.clone();
+ } + }
@ -87,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param allowed whether to bypass the check + * @param allowed whether to bypass the check
+ */ + */
+ public void setAllowed(boolean allowed) { + public void setAllowed(final boolean allowed) {
+ this.allowed = allowed; + this.allowed = allowed;
+ } + }
+ +
@ -105,17 +102,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param logWarning whether to log warnings + * @param logWarning whether to log warnings
+ */ + */
+ public void setLogWarning(boolean logWarning) { + public void setLogWarning(final boolean logWarning) {
+ this.logWarning = logWarning; + this.logWarning = logWarning;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -19,25 +19,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * 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.
+ */ + */
+@NullMarked
+public class PlayerFlowerPotManipulateEvent extends PlayerEvent implements Cancellable { +public class PlayerFlowerPotManipulateEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull
+ private final Block flowerpot; + private final Block flowerpot;
+ @NotNull
+ private final ItemStack item; + private final ItemStack item;
+ private final boolean placing; + private final boolean placing;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerFlowerPotManipulateEvent(@NotNull final Player player, @NotNull final Block flowerpot, @NotNull final ItemStack item, final boolean placing) { + public PlayerFlowerPotManipulateEvent(final Player player, final Block flowerpot, final ItemStack item, final boolean placing) {
+ super(player); + super(player);
+ this.flowerpot = flowerpot; + this.flowerpot = flowerpot;
+ this.item = item; + this.item = item;
@ -49,7 +48,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the flowerpot that is involved with this event + * @return the flowerpot that is involved with this event
+ */ + */
+ @NotNull
+ public Block getFlowerpot() { + public Block getFlowerpot() {
+ return this.flowerpot; + return this.flowerpot;
+ } + }
@ -60,7 +58,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the item placed, or taken from, the flowerpot + * @return the item placed, or taken from, the flowerpot
+ */ + */
+ @NotNull
+ public ItemStack getItem() { + public ItemStack getItem() {
+ return this.item; + return this.item;
+ } + }
@ -80,17 +77,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -17,11 +17,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a slot contents change in a player's inventory. + * Called when a slot contents change in a player's inventory.
+ */ + */
+@NullMarked
+public class PlayerInventorySlotChangeEvent extends PlayerEvent { +public class PlayerInventorySlotChangeEvent extends PlayerEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -32,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final ItemStack newItemStack; + private final ItemStack newItemStack;
+ private boolean triggerAdvancements = true; + private boolean triggerAdvancements = true;
+ +
+ public PlayerInventorySlotChangeEvent(@NotNull Player player, int rawSlot, @NotNull ItemStack oldItemStack, @NotNull ItemStack newItemStack) { + public PlayerInventorySlotChangeEvent(final Player player, final int rawSlot, final ItemStack oldItemStack, final ItemStack newItemStack) {
+ super(player); + super(player);
+ this.rawSlot = rawSlot; + this.rawSlot = rawSlot;
+ this.slot = player.getOpenInventory().convertSlot(rawSlot); + this.slot = player.getOpenInventory().convertSlot(rawSlot);
@ -67,7 +68,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The old ItemStack in the slot. + * @return The old ItemStack in the slot.
+ */ + */
+ @NotNull
+ public ItemStack getOldItemStack() { + public ItemStack getOldItemStack() {
+ return this.oldItemStack; + return this.oldItemStack;
+ } + }
@ -77,7 +77,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The new ItemStack in the slot. + * @return The new ItemStack in the slot.
+ */ + */
+ @NotNull
+ public ItemStack getNewItemStack() { + public ItemStack getNewItemStack() {
+ return this.newItemStack; + return this.newItemStack;
+ } + }
@ -96,17 +95,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param triggerAdvancements Whether the slot change advancements will be triggered. + * @param triggerAdvancements Whether the slot change advancements will be triggered.
+ */ + */
+ public void setShouldTriggerAdvancements(boolean triggerAdvancements) { + public void setShouldTriggerAdvancements(final boolean triggerAdvancements) {
+ this.triggerAdvancements = triggerAdvancements; + this.triggerAdvancements = triggerAdvancements;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -19,23 +19,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a player receives an item cooldown. + * Fired when a player receives an item cooldown.
+ */ + */
+@NullMarked
+public class PlayerItemCooldownEvent extends PlayerEvent implements Cancellable { +public class PlayerItemCooldownEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull
+ private final Material type; + private final Material type;
+ private int cooldown; + private int cooldown;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerItemCooldownEvent(@NotNull Player player, @NotNull Material type, int cooldown) { + public PlayerItemCooldownEvent(final Player player, final Material type, final int cooldown) {
+ super(player); + super(player);
+ this.type = type; + this.type = type;
+ this.cooldown = cooldown; + this.cooldown = cooldown;
@ -46,7 +46,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return material affected by the cooldown + * @return material affected by the cooldown
+ */ + */
+ @NotNull
+ public Material getType() { + public Material getType() {
+ return this.type; + return this.type;
+ } + }
@ -66,7 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param cooldown cooldown in ticks, has to be a positive number + * @param cooldown cooldown in ticks, has to be a positive number
+ */ + */
+ public void setCooldown(int cooldown) { + public void setCooldown(final int cooldown) {
+ Preconditions.checkArgument(cooldown >= 0, "The cooldown has to be equal to or greater than 0!"); + Preconditions.checkArgument(cooldown >= 0, "The cooldown has to be equal to or greater than 0!");
+ this.cooldown = cooldown; + this.cooldown = cooldown;
+ } + }
@ -77,17 +76,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -19,12 +19,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when an {@link ItemFrame} is having an item rotated, added, or removed from it. + * Called when an {@link ItemFrame} is having an item rotated, added, or removed from it.
+ */ + */
+@NullMarked
+public class PlayerItemFrameChangeEvent extends PlayerEvent implements Cancellable { +public class PlayerItemFrameChangeEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -36,8 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerItemFrameChangeEvent(@NotNull Player player, @NotNull ItemFrame itemFrame, + public PlayerItemFrameChangeEvent(final Player player, final ItemFrame itemFrame, final ItemStack itemStack, final ItemFrameChangeAction action) {
+ @NotNull ItemStack itemStack, @NotNull ItemFrameChangeAction action) {
+ super(player); + super(player);
+ this.itemFrame = itemFrame; + this.itemFrame = itemFrame;
+ this.itemStack = itemStack; + this.itemStack = itemStack;
@ -49,7 +49,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the {@link ItemFrame} + * @return the {@link ItemFrame}
+ */ + */
+ @NotNull
+ public ItemFrame getItemFrame() { + public ItemFrame getItemFrame() {
+ return this.itemFrame; + return this.itemFrame;
+ } + }
@ -62,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the {@link ItemStack} being added, rotated, or removed + * @return the {@link ItemStack} being added, rotated, or removed
+ */ + */
+ @NotNull
+ public ItemStack getItemStack() { + public ItemStack getItemStack() {
+ return this.itemStack; + return this.itemStack;
+ } + }
@ -73,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param itemStack {@link ItemFrame} item + * @param itemStack {@link ItemFrame} item
+ */ + */
+ public void setItemStack(@Nullable ItemStack itemStack) { + public void setItemStack(final @Nullable ItemStack itemStack) {
+ this.itemStack = itemStack == null ? ItemStack.empty() : itemStack; + this.itemStack = itemStack == null ? ItemStack.empty() : itemStack;
+ } + }
+ +
@ -82,7 +80,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return action performed on the item frame in this event + * @return action performed on the item frame in this event
+ */ + */
+ @NotNull
+ public ItemFrameChangeAction getAction() { + public ItemFrameChangeAction getAction() {
+ return this.action; + return this.action;
+ } + }
@ -93,17 +90,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerMoveEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when the server detects the player is jumping. + * Called when the server detects the player is jumping.
@ -29,17 +29,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * when checking for jumps via {@link 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.
+ */ + */
+@NullMarked
+public class PlayerJumpEvent extends PlayerEvent implements Cancellable { +public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Location to; + private final Location to;
+ @NotNull private Location from; + private Location from;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerJumpEvent(@NotNull final Player player, @NotNull final Location from, @NotNull final Location to) { + public PlayerJumpEvent(final Player player, final Location from, final Location to) {
+ super(player); + super(player);
+ this.from = from; + this.from = from;
+ this.to = to; + this.to = to;
@ -54,6 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return {@code true} if this event is cancelled + * @return {@code true} if this event is cancelled
+ */ + */
+ @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return this.cancelled; + return this.cancelled;
+ } + }
@ -67,7 +69,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param cancel {@code true} if you wish to cancel this event + * @param cancel {@code true} if you wish to cancel this event
+ */ + */
+ public void setCancelled(boolean cancel) { + @Override
+ public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
@ -76,7 +79,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Location the player jumped from + * @return Location the player jumped from
+ */ + */
+ @NotNull
+ public Location getFrom() { + public Location getFrom() {
+ return this.from; + return this.from;
+ } + }
@ -86,7 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @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(final Location from) {
+ Preconditions.checkArgument(from != null, "Cannot use null from location!"); + Preconditions.checkArgument(from != null, "Cannot use null from location!");
+ Preconditions.checkArgument(from.getWorld() != null, "Cannot use from location with null world!"); + Preconditions.checkArgument(from.getWorld() != null, "Cannot use from location with null world!");
+ this.from = from; + this.from = from;
@ -100,18 +102,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Location the player jumped to + * @return Location the player jumped to
+ */ + */
+ @NotNull
+ public Location getTo() { + public Location getTo() {
+ return this.to.clone(); + return this.to.clone();
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -18,8 +18,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.Range; +import org.jetbrains.annotations.Range;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Event that is fired when a player uses the pick item functionality (middle-clicking a block to get the appropriate + * Event that is fired when a player uses the pick item functionality (middle-clicking a block to get the appropriate
@ -29,6 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <p> + * <p>
+ * Note: This event will not be fired for players in creative mode. + * Note: This event will not be fired for players in creative mode.
+ */ + */
+@NullMarked
+public class PlayerPickItemEvent extends PlayerEvent implements Cancellable { +public class PlayerPickItemEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -39,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerPickItemEvent(@NotNull Player player, int targetSlot, int sourceSlot) { + public PlayerPickItemEvent(final Player player, final int targetSlot, final int sourceSlot) {
+ super(player); + super(player);
+ this.targetSlot = targetSlot; + this.targetSlot = targetSlot;
+ this.sourceSlot = sourceSlot; + this.sourceSlot = sourceSlot;
@ -50,8 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return hotbar slot (0-8 inclusive) + * @return hotbar slot (0-8 inclusive)
+ */ + */
+ @Range(from = 0, to = 8) + public @Range(from = 0, to = 8) int getTargetSlot() {
+ public int getTargetSlot() {
+ return this.targetSlot; + return this.targetSlot;
+ } + }
+ +
@ -60,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param targetSlot hotbar slot (0-8 inclusive) + * @param targetSlot hotbar slot (0-8 inclusive)
+ */ + */
+ public void setTargetSlot(@Range(from = 0, to = 8) int targetSlot) { + public void setTargetSlot(final @Range(from = 0, to = 8) int targetSlot) {
+ Preconditions.checkArgument(targetSlot >= 0 && targetSlot <= 8, "Target slot must be in range 0 - 8 (inclusive)"); + Preconditions.checkArgument(targetSlot >= 0 && targetSlot <= 8, "Target slot must be in range 0 - 8 (inclusive)");
+ this.targetSlot = targetSlot; + this.targetSlot = targetSlot;
+ } + }
@ -70,8 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return player inventory slot (0-35 inclusive) + * @return player inventory slot (0-35 inclusive)
+ */ + */
+ @Range(from = 0, to = 35) + public @Range(from = 0, to = 35) int getSourceSlot() {
+ public int getSourceSlot() {
+ return this.sourceSlot; + return this.sourceSlot;
+ } + }
+ +
@ -80,7 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param sourceSlot player inventory slot (0-35 inclusive) + * @param sourceSlot player inventory slot (0-35 inclusive)
+ */ + */
+ public void setSourceSlot(@Range(from = 0, to = 35) int sourceSlot) { + public void setSourceSlot(final @Range(from = 0, to = 35) int sourceSlot) {
+ Preconditions.checkArgument(sourceSlot >= 0 && sourceSlot <= 35, "Source slot must be in range of the player's inventory slot"); + Preconditions.checkArgument(sourceSlot >= 0 && sourceSlot <= 35, "Source slot must be in range of the player's inventory slot");
+ this.sourceSlot = sourceSlot; + this.sourceSlot = sourceSlot;
+ } + }
@ -91,17 +90,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -17,20 +17,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired after a player has respawned + * Fired after a player has respawned
+ */ + */
+@NullMarked
+public class PlayerPostRespawnEvent extends PlayerEvent { +public class PlayerPostRespawnEvent extends PlayerEvent {
+ +
+ private final static HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final Location respawnedLocation; + private final Location respawnedLocation;
+ private final boolean isBedSpawn; + private final boolean isBedSpawn;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerPostRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnedLocation, final boolean isBedSpawn) { + public PlayerPostRespawnEvent(final Player respawnPlayer, final Location respawnedLocation, final boolean isBedSpawn) {
+ super(respawnPlayer); + super(respawnPlayer);
+ this.respawnedLocation = respawnedLocation; + this.respawnedLocation = respawnedLocation;
+ this.isBedSpawn = isBedSpawn; + this.isBedSpawn = isBedSpawn;
@ -41,7 +42,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return location of the respawned player + * @return location of the respawned player
+ */ + */
+ @NotNull
+ public Location getRespawnedLocation() { + public Location getRespawnedLocation() {
+ return this.respawnedLocation.clone(); + return this.respawnedLocation.clone();
+ } + }
@ -56,12 +56,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ @NotNull
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -19,28 +19,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when a player's spawn is set, either by themselves or otherwise. + * Called when a player's spawn is set, either by themselves or otherwise.
+ * <br> + * <br>
+ * Cancelling this event will prevent the spawn from being set. + * Cancelling this event will prevent the spawn from being set.
+ */ + */
+@NullMarked
+public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable { +public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final Cause cause; + private final Cause cause;
+ private Location location; + private @Nullable Location location;
+ private boolean forced; + private boolean forced;
+ private boolean notifyPlayer; + private boolean notifyPlayer;
+ private Component notification; + private @Nullable Component notification;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerSetSpawnEvent(@NotNull Player player, @NotNull Cause cause, @Nullable Location location, boolean forced, boolean notifyPlayer, @Nullable Component notification) { + public PlayerSetSpawnEvent(final Player player, final Cause cause, final @Nullable Location location, final boolean forced, final boolean notifyPlayer, final @Nullable Component notification) {
+ super(player); + super(player);
+ this.cause = cause; + this.cause = cause;
+ this.location = location; + this.location = location;
@ -54,7 +55,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the cause + * @return the cause
+ */ + */
+ @NotNull
+ public Cause getCause() { + public Cause getCause() {
+ return this.cause; + return this.cause;
+ } + }
@ -67,8 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the spawn location, or {@code null} if removing the location + * @return the spawn location, or {@code null} if removing the location
+ */ + */
+ @Nullable + public @Nullable Location getLocation() {
+ public Location getLocation() {
+ return this.location; + return this.location;
+ } + }
+ +
@ -78,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param location the spawn location, or {@code 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(final @Nullable Location location) {
+ this.location = location; + this.location = location;
+ } + }
+ +
@ -96,7 +95,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param forced {@code true} to force + * @param forced {@code true} to force
+ */ + */
+ public void setForced(boolean forced) { + public void setForced(final boolean forced) {
+ this.forced = forced; + this.forced = forced;
+ } + }
+ +
@ -116,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param notifyPlayer {@code true} to notify + * @param notifyPlayer {@code true} to notify
+ */ + */
+ public void setNotifyPlayer(boolean notifyPlayer) { + public void setNotifyPlayer(final boolean notifyPlayer) {
+ this.notifyPlayer = notifyPlayer; + this.notifyPlayer = notifyPlayer;
+ } + }
+ +
@ -126,8 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return {@code null} if no notification + * @return {@code null} if no notification
+ */ + */
+ @Nullable + public @Nullable Component getNotification() {
+ public Component getNotification() {
+ return this.notification; + return this.notification;
+ } + }
+ +
@ -136,7 +134,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param notification {@code null} to send no message + * @param notification {@code null} to send no message
+ */ + */
+ public void setNotification(@Nullable Component notification) { + public void setNotification(final @Nullable Component notification) {
+ this.notification = notification; + this.notification = notification;
+ } + }
+ +
@ -146,16 +144,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called whenever a players shield is disabled due to an attack from another entity that was capable of disabling the + * Called whenever a players shield is disabled due to an attack from another entity that was capable of disabling the
@ -41,6 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * It follows that, if this event is cancelled, no {@link PlayerItemCooldownEvent} is called as the shield is never + * It follows that, if this event is cancelled, no {@link PlayerItemCooldownEvent} is called as the shield is never
+ * disabled in the first place. + * disabled in the first place.
+ */ + */
+@NullMarked
+public class PlayerShieldDisableEvent extends PlayerEvent implements Cancellable { +public class PlayerShieldDisableEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -51,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerShieldDisableEvent(@NotNull final Player player, @NotNull final Entity damager, final int cooldown) { + public PlayerShieldDisableEvent(final Player player, final Entity damager, final int cooldown) {
+ super(player); + super(player);
+ this.damager = damager; + this.damager = damager;
+ this.cooldown = cooldown; + this.cooldown = cooldown;
@ -62,7 +63,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the entity instance that damaged the player in a way that caused the shield to be disabled. + * @return the entity instance that damaged the player in a way that caused the shield to be disabled.
+ */ + */
+ @NotNull
+ public Entity getDamager() { + public Entity getDamager() {
+ return this.damager; + return this.damager;
+ } + }
@ -87,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param cooldown cooldown in ticks, has to be a positive number + * @param cooldown cooldown in ticks, has to be a positive number
+ */ + */
+ public void setCooldown(int cooldown) { + public void setCooldown(final int cooldown) {
+ Preconditions.checkArgument(cooldown >= 0, "The cooldown has to be equal to or greater than 0!"); + Preconditions.checkArgument(cooldown >= 0, "The cooldown has to be equal to or greater than 0!");
+ this.cooldown = cooldown; + this.cooldown = cooldown;
+ } + }
@ -102,13 +102,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -12,14 +12,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import java.util.Set;
+import org.bukkit.block.Sign; +import org.bukkit.block.Sign;
+import org.bukkit.block.sign.Side; +import org.bukkit.block.sign.Side;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+
+import java.util.Set;
+ +
+/** +/**
+ * Called when a {@link Player} clicks a side on a sign that causes a command to run. + * Called when a {@link Player} clicks a side on a sign that causes a command to run.
@ -27,13 +26,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This command is run with elevated permissions which allows players to access commands on signs they wouldn't + * This command is run with elevated permissions which allows players to access commands on signs they wouldn't
+ * normally be able to run. + * normally be able to run.
+ */ + */
+@NullMarked
+public class PlayerSignCommandPreprocessEvent extends PlayerCommandPreprocessEvent { +public class PlayerSignCommandPreprocessEvent extends PlayerCommandPreprocessEvent {
+ +
+ private final Sign sign; + private final Sign sign;
+ private final Side side; + private final Side side;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerSignCommandPreprocessEvent(@NotNull Player player, @NotNull String message, @NotNull Set<Player> recipients, @NotNull Sign sign, @NotNull Side side) { + public PlayerSignCommandPreprocessEvent(final Player player, final String message, final Set<Player> recipients, final Sign sign, final Side side) {
+ super(player, message, recipients); + super(player, message, recipients);
+ this.sign = sign; + this.sign = sign;
+ this.side = side; + this.side = side;
@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the sign + * @return the sign
+ */ + */
+ public @NotNull Sign getSign() { + public Sign getSign() {
+ return this.sign; + return this.sign;
+ } + }
+ +
@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the sign side + * @return the sign side
+ */ + */
+ public @NotNull Side getSide() { + public Side getSide() {
+ return this.side; + return this.side;
+ } + }
+} +}

View File

@ -16,20 +16,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when the server detects a player stopping using an item. + * Called when the server detects a player stopping using an item.
+ * Examples of this are letting go of the interact button when holding a bow, an edible item, or a spyglass. + * Examples of this are letting go of the interact button when holding a bow, an edible item, or a spyglass.
+ */ + */
+@NullMarked
+public class PlayerStopUsingItemEvent extends PlayerEvent { +public class PlayerStopUsingItemEvent extends PlayerEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final ItemStack item; + private final ItemStack item;
+ private final int ticksHeldFor; + private final int ticksHeldFor;
+ +
+ public PlayerStopUsingItemEvent(@NotNull final Player player, @NotNull final ItemStack item, final int ticksHeldFor) { + public PlayerStopUsingItemEvent(final Player player, final ItemStack item, final int ticksHeldFor) {
+ super(player); + super(player);
+ this.item = item; + this.item = item;
+ this.ticksHeldFor = ticksHeldFor; + this.ticksHeldFor = ticksHeldFor;
@ -40,7 +41,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return ItemStack the exact item the player released + * @return ItemStack the exact item the player released
+ */ + */
+ @NotNull
+ public ItemStack getItem() { + public ItemStack getItem() {
+ return this.item; + return this.item;
+ } + }
@ -54,13 +54,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.ticksHeldFor; + return this.ticksHeldFor;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -23,8 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Represents an event that is called when a player right-clicks an unknown entity. + * Represents an event that is called when a player right-clicks an unknown entity.
@ -33,17 +33,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * This event may be called multiple times per interaction with different interaction hands + * This event may be called multiple times per interaction with different interaction hands
+ * and with or without the clicked position. + * and with or without the clicked position.
+ */ + */
+@NullMarked
+public class PlayerUseUnknownEntityEvent extends PlayerEvent { +public class PlayerUseUnknownEntityEvent extends PlayerEvent {
+ +
+ private static final HandlerList HANDLER_LIST = 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 EquipmentSlot hand;
+ private final @Nullable Vector clickedPosition; + private final @Nullable Vector clickedPosition;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerUseUnknownEntityEvent(@NotNull Player player, int entityId, boolean attack, @NotNull EquipmentSlot hand, @Nullable Vector clickedPosition) { + public PlayerUseUnknownEntityEvent(final Player player, final int entityId, final boolean attack, final EquipmentSlot hand, final @Nullable Vector clickedPosition) {
+ super(player); + super(player);
+ this.entityId = entityId; + this.entityId = entityId;
+ this.attack = attack; + this.attack = attack;
@ -74,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the hand used to interact + * @return the hand used to interact
+ */ + */
+ public @NotNull EquipmentSlot getHand() { + public EquipmentSlot getHand() {
+ return this.hand; + return this.hand;
+ } + }
+ +
@ -89,13 +90,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.clickedPosition != null ? this.clickedPosition.clone() : null; + return this.clickedPosition != null ? this.clickedPosition.clone() : null;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when the player tries to attack an entity. + * Called when the player tries to attack an entity.
@ -31,18 +31,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <p> + * <p>
+ * Note: there may be other factors (invulnerability, etc.) that will prevent this entity from being attacked that this event will not cover + * Note: there may be other factors (invulnerability, etc.) that will prevent this entity from being attacked that this event will not cover
+ */ + */
+@NullMarked
+public class PrePlayerAttackEntityEvent extends PlayerEvent implements Cancellable { +public class PrePlayerAttackEntityEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull
+ private final Entity attacked; + private final Entity attacked;
+ private final boolean willAttack; + private final boolean willAttack;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PrePlayerAttackEntityEvent(@NotNull Player player, @NotNull Entity attacked, boolean willAttack) { + public PrePlayerAttackEntityEvent(final Player player, final Entity attacked, final boolean willAttack) {
+ super(player); + super(player);
+ this.attacked = attacked; + this.attacked = attacked;
+ this.willAttack = willAttack; + this.willAttack = willAttack;
@ -54,7 +54,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return entity that was attacked + * @return entity that was attacked
+ */ + */
+ @NotNull
+ public Entity getAttacked() { + public Entity getAttacked() {
+ return this.attacked; + return this.attacked;
+ } + }
@ -84,7 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param cancel {@code true} if you wish to cancel this event + * @param cancel {@code true} if you wish to cancel this event
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ if (!this.willAttack) { + if (!this.willAttack) {
+ return; + return;
+ } + }
@ -92,13 +91,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -79,6 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return result item + * @return result item
+ */ + */
+ @Override
+ public @Nullable ItemStack getResult() { + public @Nullable ItemStack getResult() {
+ return super.getResult(); + return super.getResult();
+ } + }
@ -88,6 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param result result item + * @param result result item
+ */ + */
+ @Override
+ public void setResult(final @Nullable ItemStack result) { + public void setResult(final @Nullable ItemStack result) {
+ super.setResult(result); + super.setResult(result);
+ } + }

View File

@ -24,9 +24,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.UnmodifiableView; +import org.jetbrains.annotations.UnmodifiableView;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called <b>before</b> a set of configured structures is located. + * Called <b>before</b> a set of configured structures is located.
@ -41,12 +41,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <li>{@link World#locateNearestStructure(Location, Structure, int, boolean)} is invoked.</li> + * <li>{@link World#locateNearestStructure(Location, Structure, int, boolean)} is invoked.</li>
+ * </ul> + * </ul>
+ */ + */
+@NullMarked
+public class StructuresLocateEvent extends WorldEvent implements Cancellable { +public class StructuresLocateEvent extends WorldEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final Location origin; + private final Location origin;
+ private Result result; + private @Nullable Result result;
+ private List<Structure> structures; + private List<Structure> structures;
+ private int radius; + private int radius;
+ private boolean findUnexplored; + private boolean findUnexplored;
@ -54,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public StructuresLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull List<Structure> structures, int radius, boolean findUnexplored) { + public StructuresLocateEvent(final World world, final Location origin, final List<Structure> structures, final int radius, final boolean findUnexplored) {
+ super(world); + super(world);
+ this.origin = origin; + this.origin = origin;
+ this.structures = structures; + this.structures = structures;
@ -67,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return {@link Location} where search begins + * @return {@link Location} where search begins
+ */ + */
+ public @NotNull Location getOrigin() { + public Location getOrigin() {
+ return this.origin.clone(); + return this.origin.clone();
+ } + }
+ +
@ -90,7 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param result the {@link Location} and {@link Structure} of the search. + * @param result the {@link Location} and {@link Structure} of the search.
+ */ + */
+ public void setResult(@Nullable Result result) { + public void setResult(final @Nullable Result result) {
+ this.result = result; + this.result = result;
+ } + }
+ +
@ -99,7 +100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return an unmodifiable list of Structures + * @return an unmodifiable list of Structures
+ */ + */
+ public @NotNull @UnmodifiableView List<Structure> getStructures() { + public @UnmodifiableView List<Structure> getStructures() {
+ return Collections.unmodifiableList(this.structures); + return Collections.unmodifiableList(this.structures);
+ } + }
+ +
@ -108,7 +109,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param structures a list of Structures targets + * @param structures a list of Structures targets
+ */ + */
+ public void setStructures(final @NotNull List<Structure> structures) { + public void setStructures(final List<Structure> structures) {
+ this.structures = structures; + this.structures = structures;
+ } + }
+ +
@ -130,7 +131,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param radius the search radius (in chunks) + * @param radius the search radius (in chunks)
+ */ + */
+ public void setRadius(int radius) { + public void setRadius(final int radius) {
+ this.radius = radius; + this.radius = radius;
+ } + }
+ +
@ -152,7 +153,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param findUnexplored Whether to search for only unexplored structures. + * @param findUnexplored Whether to search for only unexplored structures.
+ */ + */
+ public void setFindUnexplored(boolean findUnexplored) { + public void setFindUnexplored(final boolean findUnexplored) {
+ this.findUnexplored = findUnexplored; + this.findUnexplored = findUnexplored;
+ } + }
+ +
@ -162,26 +163,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NotNull HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ /** + /**
+ * Result for {@link StructuresLocateEvent}. + * Result for {@link StructuresLocateEvent}.
+ */ + */
+ public record Result(@NotNull Position pos, @NotNull Structure structure) { + public record Result(Position pos, Structure structure) {
+ +
+ @Deprecated(forRemoval = true) + @Deprecated(forRemoval = true)
+ public @NotNull Location position() { + public Location position() {
+ //noinspection DataFlowIssue + //noinspection DataFlowIssue
+ return this.pos.toLocation(null); + return this.pos.toLocation(null);
+ } + }

View File

@ -18,22 +18,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a player clicks a recipe in the recipe book + * Called when a player clicks a recipe in the recipe book
+ */ + */
+@NullMarked
+public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellable { +public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private NamespacedKey recipe; + private NamespacedKey recipe;
+ private boolean makeAll; + private boolean makeAll;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerRecipeBookClickEvent(@NotNull Player player, @NotNull NamespacedKey recipe, boolean makeAll) { + public PlayerRecipeBookClickEvent(final Player player, final NamespacedKey recipe, final boolean makeAll) {
+ super(player); + super(player);
+ this.recipe = recipe; + this.recipe = recipe;
+ this.makeAll = makeAll; + this.makeAll = makeAll;
@ -44,7 +45,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The namespaced key of the recipe + * @return The namespaced key of the recipe
+ */ + */
+ @NotNull
+ public NamespacedKey getRecipe() { + public NamespacedKey getRecipe() {
+ return this.recipe; + return this.recipe;
+ } + }
@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param recipe The key of the recipe that should be requested + * @param recipe The key of the recipe that should be requested
+ */ + */
+ public void setRecipe(@NotNull NamespacedKey recipe) { + public void setRecipe(final NamespacedKey recipe) {
+ this.recipe = recipe; + this.recipe = recipe;
+ } + }
+ +
@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @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
+ */ + */
+ public void setMakeAll(boolean makeAll) { + public void setMakeAll(final boolean makeAll) {
+ this.makeAll = makeAll; + this.makeAll = makeAll;
+ } + }
+ +
@ -84,17 +84,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -20,13 +20,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a player begins editing a sign's text. + * Called when a player begins editing a sign's text.
+ * <p> + * <p>
+ * Cancelling this event stops the sign editing menu from opening. + * Cancelling this event stops the sign editing menu from opening.
+ */ + */
+@NullMarked
+public class PlayerOpenSignEvent extends PlayerEvent implements Cancellable { +public class PlayerOpenSignEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -38,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerOpenSignEvent(final @NotNull Player editor, final @NotNull Sign sign, final @NotNull Side side, final @NotNull Cause cause) { + public PlayerOpenSignEvent(final Player editor, final Sign sign, final Side side, final Cause cause) {
+ super(editor); + super(editor);
+ this.sign = sign; + this.sign = sign;
+ this.side = side; + this.side = side;
@ -50,7 +51,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return {@link Sign} that was clicked + * @return {@link Sign} that was clicked
+ */ + */
+ @NotNull
+ public Sign getSign() { + public Sign getSign() {
+ return this.sign; + return this.sign;
+ } + }
@ -61,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return {@link Side} that was clicked + * @return {@link Side} that was clicked
+ * @see Sign#getSide(Side) + * @see Sign#getSide(Side)
+ */ + */
+ @NotNull
+ public Side getSide() { + public Side getSide() {
+ return this.side; + return this.side;
+ } + }
@ -71,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the cause + * @return the cause
+ */ + */
+ public @NotNull Cause getCause() { + public Cause getCause() {
+ return this.cause; + return this.cause;
+ } + }
+ +
@ -81,17 +80,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -12,24 +12,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.server; +package com.destroystokyo.paper.event.server;
+ +
+import com.destroystokyo.paper.exception.ServerException;
+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 org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * 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.
+ */ + */
+@NullMarked
+public class ServerExceptionEvent extends Event { +public class ServerExceptionEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final ServerException exception; + private final ServerException exception;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ServerExceptionEvent(@NotNull ServerException exception) { + public ServerExceptionEvent(final ServerException exception) {
+ super(!Bukkit.isPrimaryThread()); + super(!Bukkit.isPrimaryThread());
+ this.exception = exception; + this.exception = exception;
+ } + }
@ -39,18 +40,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Exception thrown + * @return Exception thrown
+ */ + */
+ @NotNull
+ public ServerException getException() { + public ServerException getException() {
+ return this.exception; + return this.exception;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * Returns whether the client is using an older version that doesn't + * Returns whether the client is using an older version that doesn't
+ * support all of the features in {@link PaperServerListPingEvent}. + * support all the features in {@link PaperServerListPingEvent}.
+ * + *
+ * <p>For Vanilla, this returns {@code true} for all clients older than 1.7.</p> + * <p>For Vanilla, this returns {@code true} for all clients older than 1.7.</p>
+ * + *

View File

@ -23,21 +23,21 @@ diff --git a/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEv
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java --- a/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
+++ b/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java +++ b/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; @@ -0,0 +0,0 @@ public class MethodHandleEventExecutor implements EventExecutor {
public class MethodHandleEventExecutor implements EventExecutor {
private final Class<? extends Event> eventClass; private final Class<? extends Event> eventClass;
private final MethodHandle handle; private final MethodHandle handle;
+ private final Method method; + private final @Nullable Method method;
public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull MethodHandle handle) { public MethodHandleEventExecutor(final Class<? extends Event> eventClass, final MethodHandle handle) {
this.eventClass = eventClass; this.eventClass = eventClass;
this.handle = handle; this.handle = handle;
+ this.method = null; + this.method = null;
} }
public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) { public MethodHandleEventExecutor(final Class<? extends Event> eventClass, final Method m) {
@@ -0,0 +0,0 @@ public class MethodHandleEventExecutor implements EventExecutor { @@ -0,0 +0,0 @@ public class MethodHandleEventExecutor implements EventExecutor {
} catch (IllegalAccessException e) { } catch (final IllegalAccessException e) {
throw new AssertionError("Unable to set accessible", e); throw new AssertionError("Unable to set accessible", e);
} }
+ this.method = m; + this.method = m;
@ -50,7 +50,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ +
+ @Override + @Override
+ @NotNull
+ public String toString() { + public String toString() {
+ return "MethodHandleEventExecutor['" + this.method + "']"; + return "MethodHandleEventExecutor['" + this.method + "']";
+ } + }
@ -59,16 +58,16 @@ diff --git a/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHa
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java --- a/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
+++ b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java +++ b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; @@ -0,0 +0,0 @@ public class StaticMethodHandleEventExecutor implements EventExecutor {
public class StaticMethodHandleEventExecutor implements EventExecutor {
private final Class<? extends Event> eventClass; private final Class<? extends Event> eventClass;
private final MethodHandle handle; private final MethodHandle handle;
+ private final Method method; + private final Method method;
public StaticMethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) { public StaticMethodHandleEventExecutor(final Class<? extends Event> eventClass, final Method m) {
Preconditions.checkArgument(Modifier.isStatic(m.getModifiers()), "Not a static method: %s", m); Preconditions.checkArgument(Modifier.isStatic(m.getModifiers()), "Not a static method: %s", m);
@@ -0,0 +0,0 @@ public class StaticMethodHandleEventExecutor implements EventExecutor { @@ -0,0 +0,0 @@ public class StaticMethodHandleEventExecutor implements EventExecutor {
} catch (IllegalAccessException e) { } catch (final IllegalAccessException e) {
throw new AssertionError("Unable to set accessible", e); throw new AssertionError("Unable to set accessible", e);
} }
+ this.method = m; + this.method = m;
@ -81,7 +80,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ +
+ @Override + @Override
+ @NotNull
+ public String toString() { + public String toString() {
+ return "StaticMethodHandleEventExecutor['" + this.method + "']"; + return "StaticMethodHandleEventExecutor['" + this.method + "']";
+ } + }

View File

@ -20,22 +20,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Triggered when a player starts spectating an entity in spectator mode. + * Triggered when a player starts spectating an entity in spectator mode.
+ */ + */
+@NullMarked
+public class PlayerStartSpectatingEntityEvent extends PlayerEvent implements Cancellable { +public class PlayerStartSpectatingEntityEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Entity currentSpectatorTarget; + private final Entity currentSpectatorTarget;
+ @NotNull private final Entity newSpectatorTarget; + private final Entity newSpectatorTarget;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerStartSpectatingEntityEvent(@NotNull Player player, @NotNull Entity currentSpectatorTarget, @NotNull Entity newSpectatorTarget) { + public PlayerStartSpectatingEntityEvent(final Player player, final Entity currentSpectatorTarget, final Entity newSpectatorTarget) {
+ super(player); + super(player);
+ this.currentSpectatorTarget = currentSpectatorTarget; + this.currentSpectatorTarget = currentSpectatorTarget;
+ this.newSpectatorTarget = newSpectatorTarget; + this.newSpectatorTarget = newSpectatorTarget;
@ -46,7 +47,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The entity the player is currently spectating (before they start spectating the new target). + * @return The entity the player is currently spectating (before they start spectating the new target).
+ */ + */
+ @NotNull
+ public Entity getCurrentSpectatorTarget() { + public Entity getCurrentSpectatorTarget() {
+ return this.currentSpectatorTarget; + return this.currentSpectatorTarget;
+ } + }
@ -56,7 +56,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The entity the player is now going to be spectating. + * @return The entity the player is now going to be spectating.
+ */ + */
+ @NotNull
+ public Entity getNewSpectatorTarget() { + public Entity getNewSpectatorTarget() {
+ return this.newSpectatorTarget; + return this.newSpectatorTarget;
+ } + }
@ -67,17 +66,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -97,20 +94,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Triggered when a player stops spectating an entity in spectator mode. + * Triggered when a player stops spectating an entity in spectator mode.
+ */ + */
+@NullMarked
+public class PlayerStopSpectatingEntityEvent extends PlayerEvent implements Cancellable { +public class PlayerStopSpectatingEntityEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Entity spectatorTarget; + private final Entity spectatorTarget;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerStopSpectatingEntityEvent(@NotNull Player player, @NotNull Entity spectatorTarget) { + public PlayerStopSpectatingEntityEvent(final Player player, final Entity spectatorTarget) {
+ super(player); + super(player);
+ this.spectatorTarget = spectatorTarget; + this.spectatorTarget = spectatorTarget;
+ } + }
@ -120,7 +118,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The entity the player is currently spectating (before they will stop). + * @return The entity the player is currently spectating (before they will stop).
+ */ + */
+ @NotNull
+ public Entity getSpectatorTarget() { + public Entity getSpectatorTarget() {
+ return this.spectatorTarget; + return this.spectatorTarget;
+ } + }
@ -131,17 +128,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -17,20 +17,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import java.util.EnumMap; +import java.util.EnumMap;
+import java.util.Map; +import java.util.Map;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * A reputation score for a player on a villager. + * A reputation score for a player on a villager.
+ */ + */
+@NullMarked
+public final class Reputation { +public final class Reputation {
+ +
+ @NotNull
+ private final Map<ReputationType, Integer> reputation; + private final Map<ReputationType, Integer> reputation;
+ +
+ public Reputation() { + public Reputation() {
+ this(new EnumMap<>(ReputationType.class)); + this(new EnumMap<>(ReputationType.class));
+ } + }
+ +
+ public Reputation(@NotNull Map<ReputationType, Integer> reputation) { + public Reputation(Map<ReputationType, Integer> reputation) {
+ Preconditions.checkNotNull(reputation, "reputation cannot be null"); + Preconditions.checkNotNull(reputation, "reputation cannot be null");
+ this.reputation = reputation; + this.reputation = reputation;
+ } + }
@ -41,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param type The {@link ReputationType type} of reputation to get. + * @param type The {@link ReputationType type} of reputation to get.
+ * @return The value of the {@link ReputationType type}. + * @return The value of the {@link ReputationType type}.
+ */ + */
+ public int getReputation(@NotNull ReputationType type) { + public int getReputation(ReputationType type) {
+ Preconditions.checkNotNull(type, "the reputation type cannot be null"); + Preconditions.checkNotNull(type, "the reputation type cannot be null");
+ return this.reputation.getOrDefault(type, 0); + return this.reputation.getOrDefault(type, 0);
+ } + }
@ -52,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param type The {@link ReputationType type} of reputation to set. + * @param type The {@link ReputationType type} of reputation to set.
+ * @param value The value of the {@link ReputationType type}. + * @param value The value of the {@link ReputationType type}.
+ */ + */
+ public void setReputation(@NotNull ReputationType type, int value) { + public void setReputation(ReputationType type, int value) {
+ Preconditions.checkNotNull(type, "the reputation type cannot be null"); + Preconditions.checkNotNull(type, "the reputation type cannot be null");
+ this.reputation.put(type, value); + this.reputation.put(type, value);
+ } + }
@ -63,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param type The {@link ReputationType type} to check + * @param type The {@link ReputationType type} to check
+ * @return If there is a value for this {@link ReputationType type} set. + * @return If there is a value for this {@link ReputationType type} set.
+ */ + */
+ public boolean hasReputationSet(@NotNull ReputationType type) { + public boolean hasReputationSet(ReputationType type) {
+ return this.reputation.containsKey(type); + return this.reputation.containsKey(type);
+ } + }
+} +}

View File

@ -21,26 +21,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package com.destroystokyo.paper.utils; +package com.destroystokyo.paper.utils;
+ +
+import io.papermc.paper.plugin.configuration.PluginMeta; +import io.papermc.paper.plugin.configuration.PluginMeta;
+import org.bukkit.plugin.PluginDescriptionFile;
+
+import java.util.logging.Level; +import java.util.logging.Level;
+import java.util.logging.LogManager; +import java.util.logging.LogManager;
+import java.util.logging.Logger; +import java.util.logging.Logger;
+import org.jetbrains.annotations.NotNull; +import org.bukkit.plugin.PluginDescriptionFile;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Prevents plugins (e.g. Essentials) from changing the parent of the plugin logger. + * Prevents plugins (e.g. Essentials) from changing the parent of the plugin logger.
+ */ + */
+@NullMarked
+public class PaperPluginLogger extends Logger { +public class PaperPluginLogger extends Logger {
+ +
+ @Deprecated(forRemoval = true) + @Deprecated(forRemoval = true)
+ @NotNull + public static Logger getLogger(final PluginDescriptionFile description) {
+ public static Logger getLogger(@NotNull PluginDescriptionFile description) {
+ return getLogger((PluginMeta) description); + return getLogger((PluginMeta) description);
+ } + }
+ +
+ @NotNull + public static Logger getLogger(final PluginMeta meta) {
+ public static Logger getLogger(@NotNull PluginMeta meta) {
+ Logger logger = new PaperPluginLogger(meta); + Logger logger = new PaperPluginLogger(meta);
+ if (!LogManager.getLogManager().addLogger(logger)) { + if (!LogManager.getLogManager().addLogger(logger)) {
+ // Disable this if it's going to happen across reloads anyways... + // Disable this if it's going to happen across reloads anyways...
@ -51,14 +49,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return logger; + return logger;
+ } + }
+ +
+ private PaperPluginLogger(@NotNull PluginMeta meta) { + private PaperPluginLogger(final PluginMeta meta) {
+ super(meta.getLoggerPrefix() != null ? meta.getLoggerPrefix() : meta.getName(), null); + super(meta.getLoggerPrefix() != null ? meta.getLoggerPrefix() : meta.getName(), null);
+ } + }
+ +
+ @Override + @Override
+ public void setParent(@NotNull Logger parent) { + public void setParent(final Logger parent) {
+ if (getParent() != null) { + if (this.getParent() != null) {
+ warning("Ignoring attempt to change parent of plugin logger"); + this.warning("Ignoring attempt to change parent of plugin logger");
+ } else { + } else {
+ this.log(Level.FINE, "Setting plugin logger parent to {0}", parent); + this.log(Level.FINE, "Setting plugin logger parent to {0}", parent);
+ super.setParent(parent); + super.setParent(parent);

View File

@ -17,11 +17,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a world border changes its bounds, either over time, or instantly. + * Called when a world border changes its bounds, either over time, or instantly.
+ */ + */
+@NullMarked
+public class WorldBorderBoundsChangeEvent extends WorldBorderEvent implements Cancellable { +public class WorldBorderBoundsChangeEvent extends WorldBorderEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -33,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WorldBorderBoundsChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Type type, double oldSize, double newSize, long duration) { + public WorldBorderBoundsChangeEvent(final World world, final WorldBorder worldBorder, final Type type, final double oldSize, final double newSize, final long duration) {
+ super(world, worldBorder); + super(world, worldBorder);
+ this.type = type; + this.type = type;
+ this.oldSize = oldSize; + this.oldSize = oldSize;
@ -46,7 +47,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the change type + * @return the change type
+ */ + */
+ @NotNull
+ public Type getType() { + public Type getType() {
+ return this.type; + return this.type;
+ } + }
@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param newSize the new size + * @param newSize the new size
+ */ + */
+ public void setNewSize(double newSize) { + public void setNewSize(final double newSize) {
+ this.newSize = Math.min(this.worldBorder.getMaxSize(), Math.max(1.0D, newSize)); + this.newSize = Math.min(this.worldBorder.getMaxSize(), Math.max(1.0D, newSize));
+ } + }
+ +
@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param duration the time in milliseconds for the change + * @param duration the time in milliseconds for the change
+ */ + */
+ public void setDuration(long duration) { + public void setDuration(final 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 && this.type == Type.INSTANT_MOVE) { + if (duration >= 0 && this.type == Type.INSTANT_MOVE) {
@ -107,17 +107,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -139,11 +137,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a moving world border has finished its move. + * Called when a moving world border has finished its move.
+ */ + */
+@NullMarked
+public class WorldBorderBoundsChangeFinishEvent extends WorldBorderEvent { +public class WorldBorderBoundsChangeFinishEvent extends WorldBorderEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -153,7 +152,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final double duration; + private final double duration;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WorldBorderBoundsChangeFinishEvent(@NotNull World world, @NotNull WorldBorder worldBorder, double oldSize, double newSize, double duration) { + public WorldBorderBoundsChangeFinishEvent(final World world, final WorldBorder worldBorder, final double oldSize, final double newSize, final double duration) {
+ super(world, worldBorder); + super(world, worldBorder);
+ this.oldSize = oldSize; + this.oldSize = oldSize;
+ this.newSize = newSize; + this.newSize = newSize;
@ -189,13 +188,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.duration; + return this.duration;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -214,11 +211,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a world border's center is changed. + * Called when a world border's center is changed.
+ */ + */
+@NullMarked
+public class WorldBorderCenterChangeEvent extends WorldBorderEvent implements Cancellable { +public class WorldBorderCenterChangeEvent extends WorldBorderEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -229,7 +227,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WorldBorderCenterChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Location oldCenter, @NotNull Location newCenter) { + public WorldBorderCenterChangeEvent(final World world, final WorldBorder worldBorder, final Location oldCenter, final Location newCenter) {
+ super(world, worldBorder); + super(world, worldBorder);
+ this.oldCenter = oldCenter; + this.oldCenter = oldCenter;
+ this.newCenter = newCenter; + this.newCenter = newCenter;
@ -240,7 +238,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the old center + * @return the old center
+ */ + */
+ @NotNull
+ public Location getOldCenter() { + public Location getOldCenter() {
+ return this.oldCenter.clone(); + return this.oldCenter.clone();
+ } + }
@ -250,7 +247,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the new center + * @return the new center
+ */ + */
+ @NotNull
+ public Location getNewCenter() { + public Location getNewCenter() {
+ return this.newCenter; + return this.newCenter;
+ } + }
@ -260,7 +256,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param newCenter the new center + * @param newCenter the new center
+ */ + */
+ public void setNewCenter(@NotNull Location newCenter) { + public void setNewCenter(final Location newCenter) {
+ this.newCenter = newCenter; + this.newCenter = newCenter;
+ } + }
+ +
@ -270,17 +266,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -297,19 +291,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.WorldBorder; +import org.bukkit.WorldBorder;
+import org.bukkit.event.world.WorldEvent; +import org.bukkit.event.world.WorldEvent;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public abstract class WorldBorderEvent extends WorldEvent { +public abstract class WorldBorderEvent extends WorldEvent {
+ +
+ protected final WorldBorder worldBorder; + protected final WorldBorder worldBorder;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ protected WorldBorderEvent(@NotNull World world, @NotNull WorldBorder worldBorder) { + protected WorldBorderEvent(final World world, final WorldBorder worldBorder) {
+ super(world); + super(world);
+ this.worldBorder = worldBorder; + this.worldBorder = worldBorder;
+ } + }
+ +
+ @NotNull
+ public WorldBorder getWorldBorder() { + public WorldBorder getWorldBorder() {
+ return this.worldBorder; + return this.worldBorder;
+ } + }

View File

@ -19,9 +19,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+@NullMarked
+public class PlayerBedFailEnterEvent extends PlayerEvent implements Cancellable { +public class PlayerBedFailEnterEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -29,12 +30,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final FailReason failReason; + private final FailReason failReason;
+ private final Block bed; + private final Block bed;
+ private boolean willExplode; + private boolean willExplode;
+ private Component message; + private @Nullable Component message;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerBedFailEnterEvent(@NotNull Player player, @NotNull FailReason failReason, @NotNull Block bed, boolean willExplode, @Nullable Component message) { + public PlayerBedFailEnterEvent(final Player player, final FailReason failReason, final Block bed, final boolean willExplode, final @Nullable Component message) {
+ super(player); + super(player);
+ this.failReason = failReason; + this.failReason = failReason;
+ this.bed = bed; + this.bed = bed;
@ -42,12 +43,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.message = message; + this.message = message;
+ } + }
+ +
+ @NotNull
+ public FailReason getFailReason() { + public FailReason getFailReason() {
+ return this.failReason; + return this.failReason;
+ } + }
+ +
+ @NotNull
+ public Block getBed() { + public Block getBed() {
+ return this.bed; + return this.bed;
+ } + }
@ -56,16 +55,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.willExplode; + return this.willExplode;
+ } + }
+ +
+ public void setWillExplode(boolean willExplode) { + public void setWillExplode(final boolean willExplode) {
+ this.willExplode = willExplode; + this.willExplode = willExplode;
+ } + }
+ +
+ @Nullable + public @Nullable Component getMessage() {
+ public Component getMessage() {
+ return this.message; + return this.message;
+ } + }
+ +
+ public void setMessage(@Nullable Component message) { + public void setMessage(final @Nullable Component message) {
+ this.message = message; + this.message = message;
+ } + }
+ +
@ -81,17 +79,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * that may occur because of the interaction. + * that may occur because of the interaction.
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -19,25 +19,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionEffectType;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when a player sets the effect for a beacon + * Called when a player sets the effect for a beacon
+ */ + */
+@NullMarked
+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 final Block beacon;
+ private PotionEffectType primary; + private @Nullable PotionEffectType primary;
+ private PotionEffectType secondary; + private @Nullable PotionEffectType secondary;
+ private boolean consumeItem = true; + private boolean consumeItem = true;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerChangeBeaconEffectEvent(@NotNull Player player, @Nullable PotionEffectType primary, @Nullable PotionEffectType secondary, @NotNull Block beacon) { + public PlayerChangeBeaconEffectEvent(final Player player, final @Nullable PotionEffectType primary, final @Nullable PotionEffectType secondary, final Block beacon) {
+ super(player); + super(player);
+ this.primary = primary; + this.primary = primary;
+ this.secondary = secondary; + this.secondary = secondary;
@ -47,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return the primary effect + * @return the primary effect
+ */ + */
+ @Nullable public PotionEffectType getPrimary() { + public @Nullable PotionEffectType getPrimary() {
+ return this.primary; + return this.primary;
+ } + }
+ +
@ -58,14 +59,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param primary the primary effect + * @param primary the primary effect
+ */ + */
+ public void setPrimary(@Nullable PotionEffectType primary) { + public void setPrimary(final @Nullable PotionEffectType primary) {
+ this.primary = primary; + this.primary = primary;
+ } + }
+ +
+ /** + /**
+ * @return the secondary effect + * @return the secondary effect
+ */ + */
+ @Nullable public PotionEffectType getSecondary() { + public @Nullable PotionEffectType getSecondary() {
+ return this.secondary; + return this.secondary;
+ } + }
+ +
@ -77,14 +78,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param secondary the secondary effect + * @param secondary the secondary effect
+ */ + */
+ public void setSecondary(@Nullable PotionEffectType secondary) { + public void setSecondary(final @Nullable PotionEffectType secondary) {
+ this.secondary = secondary; + this.secondary = secondary;
+ } + }
+ +
+ /** + /**
+ * @return the beacon block associated with this event + * @return the beacon block associated with this event
+ */ + */
+ @NotNull
+ public Block getBeacon() { + public Block getBeacon() {
+ return this.beacon; + return this.beacon;
+ } + }
@ -109,7 +109,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param consumeItem {@code true} if item should be consumed + * @param consumeItem {@code true} if item should be consumed
+ */ + */
+ public void setConsumeItem(boolean consumeItem) { + public void setConsumeItem(final boolean consumeItem) {
+ this.consumeItem = consumeItem; + this.consumeItem = consumeItem;
+ } + }
+ +
@ -133,16 +133,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * or saved. + * or saved.
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a player has slept long enough + * Called when a player has slept long enough
@ -26,6 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Cancelling this event will prevent the player from being counted as deeply sleeping + * Cancelling this event will prevent the player from being counted as deeply sleeping
+ * unless they exit and re-enter the bed. + * unless they exit and re-enter the bed.
+ */ + */
+@NullMarked
+public class PlayerDeepSleepEvent extends PlayerEvent implements Cancellable { +public class PlayerDeepSleepEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -33,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerDeepSleepEvent(@NotNull Player player) { + public PlayerDeepSleepEvent(final Player player) {
+ super(player); + super(player);
+ } + }
+ +
@ -43,17 +44,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -19,8 +19,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+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();
@ -34,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerLecternPageChangeEvent(@NotNull Player player, @NotNull Lectern lectern, @NotNull ItemStack book, @NotNull PageChangeDirection pageChangeDirection, int oldPage, int newPage) { + public PlayerLecternPageChangeEvent(final Player player, final Lectern lectern, final ItemStack book, final PageChangeDirection pageChangeDirection, final int oldPage, final int newPage) {
+ super(player); + super(player);
+ this.lectern = lectern; + this.lectern = lectern;
+ this.book = book; + this.book = book;
@ -48,7 +49,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the Lectern + * @return the Lectern
+ */ + */
+ @NotNull
+ public Lectern getLectern() { + public Lectern getLectern() {
+ return this.lectern; + return this.lectern;
+ } + }
@ -58,7 +58,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the ItemStack on the Lectern + * @return the ItemStack on the Lectern
+ */ + */
+ @NotNull
+ public ItemStack getBook() { + public ItemStack getBook() {
+ return this.book; + return this.book;
+ } + }
@ -68,7 +67,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the page change direction + * @return the page change direction
+ */ + */
+ @NotNull
+ public PageChangeDirection getPageChangeDirection() { + public PageChangeDirection getPageChangeDirection() {
+ return this.pageChangeDirection; + return this.pageChangeDirection;
+ } + }
@ -97,7 +95,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param newPage the new paged changed to + * @param newPage the new paged changed to
+ */ + */
+ public void setNewPage(int newPage) { + public void setNewPage(final int newPage) {
+ this.newPage = newPage; + this.newPage = newPage;
+ } + }
+ +
@ -107,17 +105,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -19,11 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a player selects a banner patten in a loom inventory. + * Called when a player selects a banner patten in a loom inventory.
+ */ + */
+@NullMarked
+public class PlayerLoomPatternSelectEvent extends PlayerEvent implements Cancellable { +public class PlayerLoomPatternSelectEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -34,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerLoomPatternSelectEvent(@NotNull Player player, @NotNull LoomInventory loomInventory, @NotNull PatternType patternType) { + public PlayerLoomPatternSelectEvent(final Player player, final LoomInventory loomInventory, final PatternType patternType) {
+ super(player); + super(player);
+ this.loomInventory = loomInventory; + this.loomInventory = loomInventory;
+ this.patternType = patternType; + this.patternType = patternType;
@ -45,7 +46,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the loom inventory + * @return the loom inventory
+ */ + */
+ @NotNull
+ public LoomInventory getLoomInventory() { + public LoomInventory getLoomInventory() {
+ return this.loomInventory; + return this.loomInventory;
+ } + }
@ -55,7 +55,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the pattern type + * @return the pattern type
+ */ + */
+ @NotNull
+ public PatternType getPatternType() { + public PatternType getPatternType() {
+ return this.patternType; + return this.patternType;
+ } + }
@ -65,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param patternType the pattern type + * @param patternType the pattern type
+ */ + */
+ public void setPatternType(@NotNull PatternType patternType) { + public void setPatternType(final PatternType patternType) {
+ this.patternType = patternType; + this.patternType = patternType;
+ } + }
+ +
@ -75,17 +74,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -18,8 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.inventory.StonecutterInventory; +import org.bukkit.inventory.StonecutterInventory;
+import org.bukkit.inventory.StonecuttingRecipe; +import org.bukkit.inventory.StonecuttingRecipe;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public class PlayerStonecutterRecipeSelectEvent extends PlayerEvent implements Cancellable { +public class PlayerStonecutterRecipeSelectEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -29,23 +30,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ public PlayerStonecutterRecipeSelectEvent(@NotNull Player player, @NotNull StonecutterInventory stonecutterInventory, @NotNull StonecuttingRecipe stonecuttingRecipe) { + public PlayerStonecutterRecipeSelectEvent(final Player player, final StonecutterInventory stonecutterInventory, final StonecuttingRecipe stonecuttingRecipe) {
+ super(player); + super(player);
+ this.stonecutterInventory = stonecutterInventory; + this.stonecutterInventory = stonecutterInventory;
+ this.stonecuttingRecipe = stonecuttingRecipe; + this.stonecuttingRecipe = stonecuttingRecipe;
+ } + }
+ +
+ @NotNull
+ public StonecutterInventory getStonecutterInventory() { + public StonecutterInventory getStonecutterInventory() {
+ return this.stonecutterInventory; + return this.stonecutterInventory;
+ } + }
+ +
+ @NotNull
+ public StonecuttingRecipe getStonecuttingRecipe() { + public StonecuttingRecipe getStonecuttingRecipe() {
+ return this.stonecuttingRecipe; + return this.stonecuttingRecipe;
+ } + }
+ +
+ public void setStonecuttingRecipe(@NotNull StonecuttingRecipe stonecuttingRecipe) { + public void setStonecuttingRecipe(final StonecuttingRecipe stonecuttingRecipe) {
+ this.stonecuttingRecipe = stonecuttingRecipe; + this.stonecuttingRecipe = stonecuttingRecipe;
+ } + }
+ +
@ -55,17 +54,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -26,11 +26,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a player trades with a standalone merchant GUI. + * Called when a player trades with a standalone merchant GUI.
+ */ + */
+@NullMarked
+public class PlayerPurchaseEvent extends PlayerEvent implements Cancellable { +public class PlayerPurchaseEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -42,12 +43,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerPurchaseEvent(@NotNull Player player, + public PlayerPurchaseEvent(final Player player, final MerchantRecipe trade, final boolean rewardExp, final boolean increaseTradeUses) {
+ @NotNull MerchantRecipe trade,
+ boolean rewardExp,
+ boolean increaseTradeUses) {
+ super(player); + super(player);
+ setTrade(trade); + this.trade = trade;
+ this.rewardExp = rewardExp; + this.rewardExp = rewardExp;
+ this.increaseTradeUses = increaseTradeUses; + this.increaseTradeUses = increaseTradeUses;
+ } + }
@ -57,7 +55,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the trade + * @return the trade
+ */ + */
+ @NotNull
+ public MerchantRecipe getTrade() { + public MerchantRecipe getTrade() {
+ return this.trade; + return this.trade;
+ } + }
@ -67,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param trade the trade to use + * @param trade the trade to use
+ */ + */
+ public void setTrade(@NotNull MerchantRecipe trade) { + public void setTrade(final MerchantRecipe trade) {
+ Preconditions.checkArgument(trade != null, "Trade cannot be null!"); + Preconditions.checkArgument(trade != null, "Trade cannot be null!");
+ this.trade = trade; + this.trade = trade;
+ } + }
@ -84,7 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param rewardExp try to reward exp + * @param rewardExp try to reward exp
+ */ + */
+ public void setRewardExp(boolean rewardExp) { + public void setRewardExp(final boolean rewardExp) {
+ this.rewardExp = rewardExp; + this.rewardExp = rewardExp;
+ } + }
+ +
@ -100,7 +97,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param increaseTradeUses {@code true} to count, {@code false} otherwise + * @param increaseTradeUses {@code true} to count, {@code false} otherwise
+ */ + */
+ public void setIncreaseTradeUses(boolean increaseTradeUses) { + public void setIncreaseTradeUses(final boolean increaseTradeUses) {
+ this.increaseTradeUses = increaseTradeUses; + this.increaseTradeUses = increaseTradeUses;
+ } + }
+ +
@ -110,17 +107,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -138,17 +133,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a player trades with a villager or wandering trader + * Called when a player trades with a villager or wandering trader
+ */ + */
+@NullMarked
+public class PlayerTradeEvent extends PlayerPurchaseEvent { +public class PlayerTradeEvent extends PlayerPurchaseEvent {
+ +
+ private final AbstractVillager villager; + private final AbstractVillager villager;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerTradeEvent(@NotNull Player player, @NotNull AbstractVillager villager, @NotNull MerchantRecipe trade, boolean rewardExp, boolean increaseTradeUses) { + public PlayerTradeEvent(final Player player, final AbstractVillager villager, final MerchantRecipe trade, final boolean rewardExp, final boolean increaseTradeUses) {
+ super(player, trade, rewardExp, increaseTradeUses); + super(player, trade, rewardExp, increaseTradeUses);
+ this.villager = villager; + this.villager = villager;
+ } + }
@ -158,7 +154,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the villager or wandering trader + * @return the villager or wandering trader
+ */ + */
+ @NotNull
+ public AbstractVillager getVillager() { + public AbstractVillager getVillager() {
+ return this.villager; + return this.villager;
+ } + }

View File

@ -19,23 +19,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when a world's gamerule is changed, either by command or by api. + * Called when a world's gamerule is changed, either by command or by api.
+ */ + */
+@NullMarked
+public class WorldGameRuleChangeEvent extends WorldEvent implements Cancellable { +public class WorldGameRuleChangeEvent extends WorldEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final CommandSender commandSender; + private final @Nullable CommandSender commandSender;
+ private final GameRule<?> gameRule; + private final GameRule<?> gameRule;
+ private String value; + private String value;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public WorldGameRuleChangeEvent(@NotNull World world, @Nullable CommandSender commandSender, @NotNull GameRule<?> gameRule, @NotNull String value) { + public WorldGameRuleChangeEvent(final World world, final @Nullable CommandSender commandSender, final GameRule<?> gameRule, final String value) {
+ super(world); + super(world);
+ this.commandSender = commandSender; + this.commandSender = commandSender;
+ this.gameRule = gameRule; + this.gameRule = gameRule;
@ -47,8 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return {@code null} if the gamerule was changed via api, otherwise the {@link CommandSender}. + * @return {@code null} if the gamerule was changed via api, otherwise the {@link CommandSender}.
+ */ + */
+ @Nullable + public @Nullable CommandSender getCommandSender() {
+ public CommandSender getCommandSender() {
+ return this.commandSender; + return this.commandSender;
+ } + }
+ +
@ -57,7 +57,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the gamerule being changed. + * @return the gamerule being changed.
+ */ + */
+ @NotNull
+ public GameRule<?> getGameRule() { + public GameRule<?> getGameRule() {
+ return this.gameRule; + return this.gameRule;
+ } + }
@ -67,7 +66,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the new value of the gamerule. + * @return the new value of the gamerule.
+ */ + */
+ @NotNull
+ public String getValue() { + public String getValue() {
+ return this.value; + return this.value;
+ } + }
@ -77,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param value the new value of the gamerule. + * @param value the new value of the gamerule.
+ */ + */
+ public void setValue(@NotNull String value) { + public void setValue(final String value) {
+ this.value = value; + this.value = value;
+ } + }
+ +
@ -87,17 +85,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -17,14 +17,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public class PlayerArmSwingEvent extends PlayerAnimationEvent { +public class PlayerArmSwingEvent extends PlayerAnimationEvent {
+ +
+ private final EquipmentSlot equipmentSlot; + private final EquipmentSlot equipmentSlot;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerArmSwingEvent(@NotNull Player player, @NotNull EquipmentSlot equipmentSlot) { + public PlayerArmSwingEvent(final Player player, final 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;
+ } + }
@ -34,7 +35,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the hand + * @return the hand
+ */ + */
+ @NotNull
+ public EquipmentSlot getHand() { + public EquipmentSlot getHand() {
+ return this.equipmentSlot; + return this.equipmentSlot;
+ } + }

View File

@ -64,6 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper start - add missing javadoc links // Paper start - add missing javadoc links
"https://javadoc.io/doc/org.joml/joml/1.10.5/index.html", "https://javadoc.io/doc/org.joml/joml/1.10.5/index.html",
"https://www.javadoc.io/doc/com.google.code.gson/gson/2.10.1", "https://www.javadoc.io/doc/com.google.code.gson/gson/2.10.1",
"https://jspecify.dev/docs/api/",
// Paper end // Paper end
+ // Paper start + // Paper start
+ "https://jd.advntr.dev/api/$adventureVersion/", + "https://jd.advntr.dev/api/$adventureVersion/",
@ -215,6 +216,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import io.papermc.paper.chat.ChatRenderer; +import io.papermc.paper.chat.ChatRenderer;
+import java.util.Set;
+import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.audience.Audience;
+import net.kyori.adventure.chat.SignedMessage; +import net.kyori.adventure.chat.SignedMessage;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
@ -222,9 +224,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+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.jspecify.annotations.NullMarked;
+
+import java.util.Set;
+ +
+import static java.util.Objects.requireNonNull; +import static java.util.Objects.requireNonNull;
+ +
@ -232,6 +232,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * An abstract implementation of a chat event, handling shared logic. + * An abstract implementation of a chat event, handling shared logic.
+ */ + */
+@ApiStatus.NonExtendable +@ApiStatus.NonExtendable
+@NullMarked
+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;
@ -242,7 +243,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ private boolean cancelled; + 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 Player player, final Set<Audience> viewers, final ChatRenderer renderer, final Component message, final Component originalMessage, final SignedMessage signedMessage) {
+ super(player, async); + super(player, async);
+ this.viewers = viewers; + this.viewers = viewers;
+ this.renderer = renderer; + this.renderer = renderer;
@ -259,7 +260,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return a mutable set of {@link Audience audiences} who will receive the chat message + * @return a mutable set of {@link Audience audiences} who will receive the chat message
+ */ + */
+ @NotNull
+ public final Set<Audience> viewers() { + public final Set<Audience> viewers() {
+ return this.viewers; + return this.viewers;
+ } + }
@ -270,7 +270,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param renderer the chat renderer + * @param renderer the chat renderer
+ * @throws NullPointerException if {@code renderer} is {@code null} + * @throws NullPointerException if {@code renderer} is {@code null}
+ */ + */
+ public final void renderer(final @NotNull ChatRenderer renderer) { + public final void renderer(final ChatRenderer renderer) {
+ this.renderer = requireNonNull(renderer, "renderer"); + this.renderer = requireNonNull(renderer, "renderer");
+ } + }
+ +
@ -279,7 +279,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the chat renderer + * @return the chat renderer
+ */ + */
+ @NotNull
+ public final ChatRenderer renderer() { + public final ChatRenderer renderer() {
+ return this.renderer; + return this.renderer;
+ } + }
@ -290,7 +289,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the user-supplied message + * @return the user-supplied message
+ */ + */
+ @NotNull
+ public final Component message() { + public final Component message() {
+ return this.message; + return this.message;
+ } + }
@ -301,7 +299,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param message the user-supplied message + * @param message the user-supplied message
+ * @throws NullPointerException if {@code message} is {@code null} + * @throws NullPointerException if {@code message} is {@code null}
+ */ + */
+ public final void message(final @NotNull Component message) { + public final void message(final Component message) {
+ this.message = requireNonNull(message, "message"); + this.message = requireNonNull(message, "message");
+ } + }
+ +
@ -312,7 +310,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the original user-supplied message + * @return the original user-supplied message
+ */ + */
+ @NotNull
+ public final Component originalMessage() { + public final Component originalMessage() {
+ return this.originalMessage; + return this.originalMessage;
+ } + }
@ -324,7 +321,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the signed message + * @return the signed message
+ */ + */
+ @NotNull
+ public final SignedMessage signedMessage() { + public final SignedMessage signedMessage() {
+ return this.signedMessage; + return this.signedMessage;
+ } + }
@ -351,25 +347,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+@ApiStatus.Experimental +@ApiStatus.Experimental
+@NullMarked
+public class AsyncChatCommandDecorateEvent extends AsyncChatDecorateEvent { +public class AsyncChatCommandDecorateEvent extends AsyncChatDecorateEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public AsyncChatCommandDecorateEvent(@Nullable Player player, @NotNull Component originalMessage) { + public AsyncChatCommandDecorateEvent(final @Nullable Player player, final Component originalMessage) {
+ super(player, originalMessage); + super(player, originalMessage);
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NotNull HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+} +}
@ -387,9 +384,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.Nullable;
+import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * This event is fired when the server decorates a component for chat purposes. This is called + * This event is fired when the server decorates a component for chat purposes. This is called
@ -401,18 +397,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * See {@link AsyncChatCommandDecorateEvent} for the decoration of messages sent via commands + * See {@link AsyncChatCommandDecorateEvent} for the decoration of messages sent via commands
+ */ + */
+@ApiStatus.Experimental +@ApiStatus.Experimental
+@NullMarked
+public class AsyncChatDecorateEvent extends ServerEvent implements Cancellable { +public class AsyncChatDecorateEvent extends ServerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private final Player player; + private final @Nullable 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
+ public AsyncChatDecorateEvent(final @Nullable Player player, final @NotNull Component originalMessage) { + public AsyncChatDecorateEvent(final @Nullable Player player, final Component originalMessage) {
+ super(true); + super(true);
+ this.player = player; + this.player = player;
+ this.originalMessage = originalMessage; + this.originalMessage = originalMessage;
@ -436,7 +433,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the input + * @return the input
+ */ + */
+ public @NotNull Component originalMessage() { + public Component originalMessage() {
+ return this.originalMessage; + return this.originalMessage;
+ } + }
+ +
@ -447,7 +444,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the result + * @return the result
+ */ + */
+ public @NotNull Component result() { + public Component result() {
+ return this.result; + return this.result;
+ } + }
+ +
@ -456,7 +453,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param result the result + * @param result the result
+ */ + */
+ public void result(@NotNull Component result) { + public void result(final Component result) {
+ this.result = result; + this.result = result;
+ } + }
+ +
@ -471,16 +468,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * component. + * component.
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override + @Override
+ public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ public static @NotNull HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+} +}
@ -492,15 +489,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import java.util.Set;
+import io.papermc.paper.chat.ChatRenderer; +import io.papermc.paper.chat.ChatRenderer;
+import java.util.Set;
+import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.audience.Audience;
+import net.kyori.adventure.chat.SignedMessage; +import net.kyori.adventure.chat.SignedMessage;
+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.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * 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.
@ -515,22 +512,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Care should be taken to check {@link #isAsynchronous()} and treat the event + * Care should be taken to check {@link #isAsynchronous()} and treat the event
+ * appropriately. + * appropriately.
+ */ + */
+@NullMarked
+public final class AsyncChatEvent extends AbstractChatEvent { +public final class AsyncChatEvent extends AbstractChatEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @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 Player player, final Set<Audience> viewers, final ChatRenderer renderer, final Component message, final Component originalMessage, final SignedMessage signedMessage) {
+ super(async, player, viewers, renderer, message, originalMessage, signedMessage); + super(async, player, viewers, renderer, message, originalMessage, signedMessage);
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -543,8 +539,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package io.papermc.paper.event.player; +package io.papermc.paper.event.player;
+ +
+import java.util.Set;
+import io.papermc.paper.chat.ChatRenderer; +import io.papermc.paper.chat.ChatRenderer;
+import java.util.Set;
+import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.audience.Audience;
+import net.kyori.adventure.chat.SignedMessage; +import net.kyori.adventure.chat.SignedMessage;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
@ -552,7 +548,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * 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.
@ -562,22 +558,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+@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.")
+@NullMarked
+public final class ChatEvent extends AbstractChatEvent { +public final class ChatEvent extends AbstractChatEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @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 Player player, final Set<Audience> viewers, final ChatRenderer renderer, final Component message, final Component originalMessage, final SignedMessage signedMessage) {
+ super(false, player, viewers, renderer, message, originalMessage, signedMessage); + super(false, player, viewers, renderer, message, originalMessage, signedMessage);
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -95,6 +95,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -244,6 +244,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -262,7 +262,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+/** +/**
+ * Represents a property on a {@link PlayerProfile} + * Represents a property on a {@link PlayerProfile}
+ */ + */
+public class ProfileProperty { +public final class ProfileProperty {
+ private final String name; + private final String name;
+ private final String value; + private final String value;
+ private final String signature; + private final String signature;

View File

@ -141,7 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+@NullMarked +@NullMarked
+public class AsyncPlayerSendCommandsEvent<S extends CommandSourceStack> extends PlayerEvent { +public class AsyncPlayerSendCommandsEvent<S extends CommandSourceStack> extends PlayerEvent {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ private final RootCommandNode<S> node; + private final RootCommandNode<S> node;
+ private final boolean hasFiredAsync; + private final boolean hasFiredAsync;
+ +
@ -170,12 +170,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.hasFiredAsync; + return this.hasFiredAsync;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java b/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java b/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java
@ -203,7 +204,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+@NullMarked +@NullMarked
+public class AsyncPlayerSendSuggestionsEvent extends PlayerEvent implements Cancellable { +public class AsyncPlayerSendSuggestionsEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ private boolean cancelled = false; + private boolean cancelled = false;
+ +
+ private Suggestions suggestions; + private Suggestions suggestions;
@ -260,12 +261,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+ +
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return handlers; + return HANDLER_LIST;
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java b/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java b/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java

View File

@ -47,6 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - add missing javadoc links + // Paper start - add missing javadoc links
+ "https://javadoc.io/doc/org.joml/joml/1.10.5/index.html", + "https://javadoc.io/doc/org.joml/joml/1.10.5/index.html",
+ "https://www.javadoc.io/doc/com.google.code.gson/gson/2.10.1", + "https://www.javadoc.io/doc/com.google.code.gson/gson/2.10.1",
+ "https://jspecify.dev/docs/api/",
+ // Paper end + // Paper end
) )
options.tags("apiNote:a:API Note:") options.tags("apiNote:a:API Note:")

View File

@ -142,6 +142,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -103,6 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -45,6 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.world; + return this.world;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -92,6 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.world; + return this.world;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -41,10 +41,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return (LivingEntity) super.getEntity(); + return (LivingEntity) super.getEntity();
+ } + }
+ +
+ @Override
+ public boolean isCancelled() { + public boolean isCancelled() {
+ return this.cancelled; + return this.cancelled;
+ } + }
+ +
+ @Override
+ public void setCancelled(final boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }

View File

@ -49,6 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The Entity that is pathfinding. + * @return The Entity that is pathfinding.
+ */ + */
+ @Override
+ public Entity getEntity() { + public Entity getEntity() {
+ return this.entity; + return this.entity;
+ } + }

View File

@ -19,37 +19,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists; +import com.google.common.collect.Lists;
+import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import it.unimi.dsi.fastutil.objects.ObjectArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.bukkit.Color; +import org.bukkit.Color;
+import org.bukkit.Location; +import org.bukkit.Location;
+import org.bukkit.Particle; +import org.bukkit.Particle;
+import org.bukkit.World; +import org.bukkit.World;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.util.NumberConversions; +import org.bukkit.util.NumberConversions;
+ +import org.jspecify.annotations.NullMarked;
+import java.util.Collection; +import org.jspecify.annotations.Nullable;
+import java.util.List;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Helps prepare a particle to be sent to players. + * Helps prepare a particle to be sent to players.
+ * + * <p>
+ * Usage of the builder is preferred over the super long {@link World#spawnParticle(Particle, Location, int, double, double, double, double, Object)} API + * Usage of the builder is preferred over the super long {@link World#spawnParticle(Particle, Location, int, double, double, double, double, Object)} API
+ */ + */
+@NullMarked
+public class ParticleBuilder implements Cloneable { +public class ParticleBuilder implements Cloneable {
+ +
+ private Particle particle; + private Particle particle;
+ private List<Player> receivers; + private @Nullable List<Player> receivers;
+ private Player source; + private @Nullable Player source;
+ private Location location; + private @Nullable Location location;
+ private int count = 1; + private int count = 1;
+ private double offsetX = 0, offsetY = 0, offsetZ = 0; + private double offsetX = 0, offsetY = 0, offsetZ = 0;
+ private double extra = 1; + private double extra = 1;
+ private Object data; + private @Nullable Object data;
+ private boolean force = true; + private boolean force = true;
+ +
+ public ParticleBuilder(@NotNull Particle particle) { + public ParticleBuilder(final Particle particle) {
+ this.particle = particle; + this.particle = particle;
+ } + }
+ +
@ -59,14 +58,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull
+ public ParticleBuilder spawn() { + public ParticleBuilder spawn() {
+ if (this.location == null) { + if (this.location == null) {
+ throw new IllegalStateException("Please specify location for this particle"); + throw new IllegalStateException("Please specify location for this particle");
+ } + }
+ location.getWorld().spawnParticle(particle, receivers, source, + this.location.getWorld().spawnParticle(
+ location.getX(), location.getY(), location.getZ(), + this.particle, this.receivers, this.source,
+ count, offsetX, offsetY, offsetZ, extra, data, force + this.location.getX(), this.location.getY(), this.location.getZ(),
+ this.count, this.offsetX, this.offsetY, this.offsetZ, this.extra, this.data, this.force
+ ); + );
+ return this; + return this;
+ } + }
@ -74,9 +73,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The particle going to be sent + * @return The particle going to be sent
+ */ + */
+ @NotNull
+ public Particle particle() { + public Particle particle() {
+ return particle; + return this.particle;
+ } + }
+ +
+ /** + /**
@ -85,8 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param particle The particle + * @param particle The particle
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder particle(final Particle particle) {
+ public ParticleBuilder particle(@NotNull Particle particle) {
+ this.particle = particle; + this.particle = particle;
+ return this; + return this;
+ } + }
@ -94,32 +91,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return List of players who will receive the particle, or null for all in world + * @return List of players who will receive the particle, or null for all in world
+ */ + */
+ @Nullable + public @Nullable List<Player> receivers() {
+ public List<Player> receivers() { + return this.receivers;
+ return receivers;
+ } + }
+ +
+ /** + /**
+ * Example use: + * Example use:
+ * + * <p>
+ * builder.receivers(16); if (builder.hasReceivers()) { sendParticleAsync(builder); } + * builder.receivers(16); if (builder.hasReceivers()) { sendParticleAsync(builder); }
+ * + *
+ * @return If this particle is going to be sent to someone + * @return If this particle is going to be sent to someone
+ */ + */
+ public boolean hasReceivers() { + public boolean hasReceivers() {
+ return (receivers == null && !location.getWorld().getPlayers().isEmpty()) || ( + return (this.receivers == null && this.location != null && !this.location.getWorld().getPlayers().isEmpty()) || (
+ receivers != null && !receivers.isEmpty()); + this.receivers != null && !this.receivers.isEmpty());
+ } + }
+ +
+ /** + /**
+ * Sends this particle to all players in the world. This is rather silly and you should likely not + * Sends this particle to all players in the world. This is rather silly, and you should likely not
+ * be doing this. + * be doing this.
+ * + * <p>
+ * Just be a logical person and use receivers by radius or collection. + * Just be a logical person and use receivers by radius or collection.
+ * + *
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull
+ public ParticleBuilder allPlayers() { + public ParticleBuilder allPlayers() {
+ this.receivers = null; + this.receivers = null;
+ return this; + return this;
@ -127,11 +122,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ /** + /**
+ * @param receivers List of players to receive this particle, or null for all players in the + * @param receivers List of players to receive this particle, or null for all players in the
+ * world + * world
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder receivers(final @Nullable List<Player> receivers) {
+ public ParticleBuilder receivers(@Nullable List<Player> receivers) {
+ // Had to keep this as we first made API List<> and not Collection, but removing this may break plugins compiled on older jars + // Had to keep this as we first made API List<> and not Collection, but removing this may break plugins compiled on older jars
+ // TODO: deprecate? + // TODO: deprecate?
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null; + this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
@ -140,22 +134,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ /** + /**
+ * @param receivers List of players to receive this particle, or null for all players in the + * @param receivers List of players to receive this particle, or null for all players in the
+ * world + * world
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder receivers(final @Nullable Collection<Player> receivers) {
+ public ParticleBuilder receivers(@Nullable Collection<Player> receivers) {
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null; + this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
+ return this; + return this;
+ } + }
+ +
+ /** + /**
+ * @param receivers List of players to be receive this particle, or null for all players in the + * @param receivers List of players to receive this particle, or null for all players in the
+ * world + * world
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder receivers(final Player @Nullable... receivers) {
+ public ParticleBuilder receivers(@Nullable Player... receivers) {
+ this.receivers = receivers != null ? Lists.newArrayList(receivers) : null; + this.receivers = receivers != null ? Lists.newArrayList(receivers) : null;
+ return this; + return this;
+ } + }
@ -168,9 +160,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param radius amount to add on all axis + * @param radius amount to add on all axis
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder receivers(final int radius) {
+ public ParticleBuilder receivers(int radius) { + return this.receivers(radius, radius);
+ return receivers(radius, radius);
+ } + }
+ +
+ /** + /**
@ -178,22 +169,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * false, behavior uses cuboid selection the same as {@link #receivers(int, int)} If byDistance is + * false, behavior uses cuboid selection the same as {@link #receivers(int, int)} If byDistance is
+ * true, radius is tested by distance in a spherical shape + * true, radius is tested by distance in a spherical shape
+ * + *
+ * @param radius amount to add on each axis + * @param radius amount to add on each axis
+ * @param byDistance true to use a spherical radius, false to use a cuboid + * @param byDistance true to use a spherical radius, false to use a cuboid
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder receivers(final int radius, final boolean byDistance) {
+ public ParticleBuilder receivers(int radius, boolean byDistance) {
+ if (!byDistance) { + if (!byDistance) {
+ return receivers(radius, radius, radius); + return this.receivers(radius, radius, radius);
+ } else { + } else {
+ if (this.location == null) {
+ throw new IllegalStateException("Please set location first");
+ }
+ this.receivers = Lists.newArrayList(); + this.receivers = Lists.newArrayList();
+ for (Player nearbyPlayer : location.getWorld() + for (final Player nearbyPlayer : this.location.getWorld()
+ .getNearbyPlayers(location, radius, radius, radius)) { + .getNearbyPlayers(this.location, radius, radius, radius)) {
+ Location loc = nearbyPlayer.getLocation(); + final Location loc = nearbyPlayer.getLocation();
+ double x = NumberConversions.square(location.getX() - loc.getX()); + final double x = NumberConversions.square(this.location.getX() - loc.getX());
+ double y = NumberConversions.square(location.getY() - loc.getY()); + final double y = NumberConversions.square(this.location.getY() - loc.getY());
+ double z = NumberConversions.square(location.getZ() - loc.getZ()); + final double z = NumberConversions.square(this.location.getZ() - loc.getZ());
+ if (Math.sqrt(x + y + z) > radius) { + if (Math.sqrt(x + y + z) > radius) {
+ continue; + continue;
+ } + }
@ -210,12 +203,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * see {@link #receivers(int, boolean)} + * see {@link #receivers(int, boolean)}
+ * + *
+ * @param xzRadius amount to add on the x/z axis + * @param xzRadius amount to add on the x/z axis
+ * @param yRadius amount to add on the y axis + * @param yRadius amount to add on the y axis
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder receivers(final int xzRadius, final int yRadius) {
+ public ParticleBuilder receivers(int xzRadius, int yRadius) { + return this.receivers(xzRadius, yRadius, xzRadius);
+ return receivers(xzRadius, yRadius, xzRadius);
+ } + }
+ +
+ /** + /**
@ -223,25 +215,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * false, behavior uses cuboid selection the same as {@link #receivers(int, int)} If byDistance is + * false, behavior uses cuboid selection the same as {@link #receivers(int, int)} If byDistance is
+ * true, radius is tested by distance on the y plane and on the x/z plane, in a cylinder shape. + * true, radius is tested by distance on the y plane and on the x/z plane, in a cylinder shape.
+ * + *
+ * @param xzRadius amount to add on the x/z axis + * @param xzRadius amount to add on the x/z axis
+ * @param yRadius amount to add on the y axis + * @param yRadius amount to add on the y axis
+ * @param byDistance true to use a cylinder shape, false to use cuboid + * @param byDistance true to use a cylinder shape, false to use cuboid
+ * @return a reference to this object. + * @return a reference to this object.
+ * @throws IllegalStateException if a location hasn't been specified yet
+ */ + */
+ @NotNull + public ParticleBuilder receivers(final int xzRadius, final int yRadius, final boolean byDistance) {
+ public ParticleBuilder receivers(int xzRadius, int yRadius, boolean byDistance) {
+ if (!byDistance) { + if (!byDistance) {
+ return receivers(xzRadius, yRadius, xzRadius); + return this.receivers(xzRadius, yRadius, xzRadius);
+ } else { + } else {
+ if (this.location == null) {
+ throw new IllegalStateException("Please set location first");
+ }
+ this.receivers = Lists.newArrayList(); + this.receivers = Lists.newArrayList();
+ for (Player nearbyPlayer : location.getWorld() + for (final Player nearbyPlayer : this.location.getWorld()
+ .getNearbyPlayers(location, xzRadius, yRadius, xzRadius)) { + .getNearbyPlayers(this.location, xzRadius, yRadius, xzRadius)) {
+ Location loc = nearbyPlayer.getLocation(); + final Location loc = nearbyPlayer.getLocation();
+ if (Math.abs(loc.getY() - this.location.getY()) > yRadius) { + if (Math.abs(loc.getY() - this.location.getY()) > yRadius) {
+ continue; + continue;
+ } + }
+ double x = NumberConversions.square(location.getX() - loc.getX()); + final double x = NumberConversions.square(this.location.getX() - loc.getX());
+ double z = NumberConversions.square(location.getZ() - loc.getZ()); + final double z = NumberConversions.square(this.location.getZ() - loc.getZ());
+ if (x + z > NumberConversions.square(xzRadius)) { + if (x + z > NumberConversions.square(xzRadius)) {
+ continue; + continue;
+ } + }
@ -261,20 +256,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param zRadius amount to add on the z axis + * @param zRadius amount to add on the z axis
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder receivers(final int xRadius, final int yRadius, final int zRadius) {
+ public ParticleBuilder receivers(int xRadius, int yRadius, int zRadius) { + if (this.location == null) {
+ if (location == null) {
+ throw new IllegalStateException("Please set location first"); + throw new IllegalStateException("Please set location first");
+ } + }
+ return receivers(location.getWorld().getNearbyPlayers(location, xRadius, yRadius, zRadius)); + return this.receivers(this.location.getWorld().getNearbyPlayers(this.location, xRadius, yRadius, zRadius));
+ } + }
+ +
+ /** + /**
+ * @return The player considered the source of this particle (for Visibility concerns), or null + * @return The player considered the source of this particle (for Visibility concerns), or null
+ */ + */
+ @Nullable + public @Nullable Player source() {
+ public Player source() { + return this.source;
+ return source;
+ } + }
+ +
+ /** + /**
@ -283,8 +276,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param source The player who is considered the source + * @param source The player who is considered the source
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder source(final @Nullable Player source) {
+ public ParticleBuilder source(@Nullable Player source) {
+ this.source = source; + this.source = source;
+ return this; + return this;
+ } + }
@ -292,9 +284,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return Location of where the particle will spawn + * @return Location of where the particle will spawn
+ */ + */
+ @Nullable + public @Nullable Location location() {
+ public Location location() { + return this.location;
+ return location;
+ } + }
+ +
+ /** + /**
@ -303,8 +294,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param location The location of the particle + * @param location The location of the particle
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder location(final Location location) {
+ public ParticleBuilder location(@NotNull Location location) {
+ this.location = location.clone(); + this.location = location.clone();
+ return this; + return this;
+ } + }
@ -313,13 +303,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Sets the location of where to spawn the particle + * Sets the location of where to spawn the particle
+ * + *
+ * @param world World to spawn particle in + * @param world World to spawn particle in
+ * @param x X location + * @param x X location
+ * @param y Y location + * @param y Y location
+ * @param z Z location + * @param z Z location
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder location(final World world, final double x, final double y, final double z) {
+ public ParticleBuilder location(@NotNull World world, double x, double y, double z) {
+ this.location = new Location(world, x, y, z); + this.location = new Location(world, x, y, z);
+ return this; + return this;
+ } + }
@ -328,7 +317,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return Number of particles to spawn + * @return Number of particles to spawn
+ */ + */
+ public int count() { + public int count() {
+ return count; + return this.count;
+ } + }
+ +
+ /** + /**
@ -337,8 +326,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param count Number of particles + * @param count Number of particles
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder count(final int count) {
+ public ParticleBuilder count(int count) {
+ this.count = count; + this.count = count;
+ return this; + return this;
+ } + }
@ -349,7 +337,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return Particle offset X. + * @return Particle offset X.
+ */ + */
+ public double offsetX() { + public double offsetX() {
+ return offsetX; + return this.offsetX;
+ } + }
+ +
+ /** + /**
@ -358,7 +346,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return Particle offset Y. + * @return Particle offset Y.
+ */ + */
+ public double offsetY() { + public double offsetY() {
+ return offsetY; + return this.offsetY;
+ } + }
+ +
+ /** + /**
@ -367,7 +355,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return Particle offset Z. + * @return Particle offset Z.
+ */ + */
+ public double offsetZ() { + public double offsetZ() {
+ return offsetZ; + return this.offsetZ;
+ } + }
+ +
+ /** + /**
@ -378,8 +366,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param offsetZ Particle offset Z + * @param offsetZ Particle offset Z
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder offset(final double offsetX, final double offsetY, final double offsetZ) {
+ public ParticleBuilder offset(double offsetX, double offsetY, double offsetZ) {
+ this.offsetX = offsetX; + this.offsetX = offsetX;
+ this.offsetY = offsetY; + this.offsetY = offsetY;
+ this.offsetZ = offsetZ; + this.offsetZ = offsetZ;
@ -392,7 +379,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return the extra particle data + * @return the extra particle data
+ */ + */
+ public double extra() { + public double extra() {
+ return extra; + return this.extra;
+ } + }
+ +
+ /** + /**
@ -401,8 +388,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param extra the extra particle data + * @param extra the extra particle data
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder extra(final double extra) {
+ public ParticleBuilder extra(double extra) {
+ this.extra = extra; + this.extra = extra;
+ return this; + return this;
+ } + }
@ -413,21 +399,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param <T> The Particle data type + * @param <T> The Particle data type
+ * @return the ParticleData for this particle + * @return the ParticleData for this particle
+ */ + */
+ @Nullable + public @Nullable <T> T data() {
+ public <T> T data() {
+ //noinspection unchecked + //noinspection unchecked
+ return (T) data; + return (T) this.data;
+ } + }
+ +
+ /** + /**
+ * Sets the particle custom data. Varies by particle on how this is used + * Sets the particle custom data. Varies by particle on how this is used
+ * + *
+ * @param data The new particle data + * @param data The new particle data
+ * @param <T> The Particle data type + * @param <T> The Particle data type
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public <T> ParticleBuilder data(final @Nullable T data) {
+ public <T> ParticleBuilder data(@Nullable T data) {
+ this.data = data; + this.data = data;
+ return this; + return this;
+ } + }
@ -436,7 +420,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return whether the particle is forcefully shown to players. + * @return whether the particle is forcefully shown to players.
+ */ + */
+ public boolean force() { + public boolean force() {
+ return force; + return this.force;
+ } + }
+ +
+ /** + /**
@ -447,8 +431,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param force true to force, false for normal + * @param force true to force, false for normal
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder force(final boolean force) {
+ public ParticleBuilder force(boolean force) {
+ this.force = force; + this.force = force;
+ return this; + return this;
+ } + }
@ -460,12 +443,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param color the new particle color + * @param color the new particle color
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder color(final @Nullable Color color) {
+ public ParticleBuilder color(@Nullable Color color) { + if (this.particle.getDataType() == Color.class) {
+ if (particle.getDataType() == Color.class) { + return this.data(color);
+ return data(color);
+ } + }
+ return color(color, 1); + return this.color(color, 1);
+ } + }
+ +
+ /** + /**
@ -473,25 +455,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Only valid for particles with a data type of {@link Particle.DustOptions}. + * Only valid for particles with a data type of {@link Particle.DustOptions}.
+ * + *
+ * @param color the new particle color + * @param color the new particle color
+ * @param size the size of the particle + * @param size the size of the particle
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder color(final @Nullable Color color, final float size) {
+ public ParticleBuilder color(@Nullable Color color, float size) { + if (this.particle.getDataType() != Particle.DustOptions.class && color != null) {
+ if (particle.getDataType() != Particle.DustOptions.class && color != null) {
+ throw new IllegalStateException("The combination of Color and size cannot be set on this particle type."); + throw new IllegalStateException("The combination of Color and size cannot be set on this particle type.");
+ } + }
+ +
+ // We don't officially support reusing these objects, but here we go + // We don't officially support reusing these objects, but here we go
+ if (color == null) { + if (color == null) {
+ if (data instanceof Particle.DustOptions) { + if (this.data instanceof Particle.DustOptions) {
+ return data(null); + return this.data(null);
+ } else { + } else {
+ return this; + return this;
+ } + }
+ } + }
+ +
+ return data(new Particle.DustOptions(color, size)); + return this.data(new Particle.DustOptions(color, size));
+ } + }
+ +
+ /** + /**
@ -503,9 +484,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param b blue color component + * @param b blue color component
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull + public ParticleBuilder color(final int r, final int g, final int b) {
+ public ParticleBuilder color(int r, int g, int b) { + return this.color(Color.fromRGB(r, g, b));
+ return color(Color.fromRGB(r, g, b));
+ } + }
+ +
+ /** + /**
@ -519,13 +499,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * the color is treated as RGB. Otherwise, it is treated as ARGB. + * the color is treated as RGB. Otherwise, it is treated as ARGB.
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull
+ public ParticleBuilder color(final int color) { + public ParticleBuilder color(final int color) {
+ int alpha = (color >> 24) & 0xFF; + final int alpha = (color >> 24) & 0xFF;
+ if (alpha == 0) { + if (alpha == 0) {
+ return color(Color.fromRGB(color)); + return this.color(Color.fromRGB(color));
+ } + }
+ return color(Color.fromARGB(color)); + return this.color(Color.fromARGB(color));
+ } + }
+ +
+ /** + /**
@ -538,9 +517,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param b blue color component + * @param b blue color component
+ * @return a reference to this object. + * @return a reference to this object.
+ */ + */
+ @NotNull
+ public ParticleBuilder color(final int a, final int r, final int g, final int b) { + public ParticleBuilder color(final int a, final int r, final int g, final int b) {
+ return color(Color.fromARGB(a, r, g, b)); + return this.color(Color.fromARGB(a, r, g, b));
+ } + }
+ +
+ /** + /**
@ -548,69 +526,64 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Only valid for {@link Particle#DUST_COLOR_TRANSITION}. + * Only valid for {@link Particle#DUST_COLOR_TRANSITION}.
+ * + *
+ * @param fromColor the new particle from color + * @param fromColor the new particle from color
+ * @param toColor the new particle to color + * @param toColor the new particle to color
+ * @return a reference to this object. + * @return a reference to this object.
+ * @throws IllegalArgumentException if the particle builder's {@link #particle()} isn't {@link Particle#DUST_COLOR_TRANSITION}. + * @throws IllegalArgumentException if the particle builder's {@link #particle()} isn't {@link Particle#DUST_COLOR_TRANSITION}.
+ */ + */
+ @NotNull + public ParticleBuilder colorTransition(final Color fromColor, final Color toColor) {
+ public ParticleBuilder colorTransition(@NotNull final Color fromColor, @NotNull final Color toColor) { + return this.colorTransition(fromColor, toColor, 1);
+ return colorTransition(fromColor, toColor, 1);
+ } + }
+ +
+ /** + /**
+ * Sets the particle Color Transition. + * Sets the particle Color Transition.
+ * Only valid for {@link Particle#DUST_COLOR_TRANSITION}. + * Only valid for {@link Particle#DUST_COLOR_TRANSITION}.
+ * + *
+ * @param fromRed red color component for the from color + * @param fromRed red color component for the "from" color
+ * @param fromGreen green color component for the from color + * @param fromGreen green color component for the "from" color
+ * @param fromBlue blue color component for the from color + * @param fromBlue blue color component for the "from" color
+ * @param toRed red color component for the to color + * @param toRed red color component for the to color
+ * @param toGreen green color component for the to color + * @param toGreen green color component for the to color
+ * @param toBlue blue color component for the to color + * @param toBlue blue color component for the to color
+ * @return a reference to this object. + * @return a reference to this object.
+ * @throws IllegalArgumentException if the particle builder's {@link #particle()} isn't {@link Particle#DUST_COLOR_TRANSITION}. + * @throws IllegalArgumentException if the particle builder's {@link #particle()} isn't {@link Particle#DUST_COLOR_TRANSITION}.
+ */ + */
+ @NotNull + public ParticleBuilder colorTransition(
+ public ParticleBuilder colorTransition(final int fromRed, final int fromGreen, final int fromBlue, + final int fromRed, final int fromGreen, final int fromBlue,
+ final int toRed, final int toGreen, final int toBlue) { + final int toRed, final int toGreen, final int toBlue
+ return colorTransition(Color.fromRGB(fromRed, fromGreen, fromBlue), Color.fromRGB(toRed, toGreen, toBlue)); + ) {
+ return this.colorTransition(Color.fromRGB(fromRed, fromGreen, fromBlue), Color.fromRGB(toRed, toGreen, toBlue));
+ } + }
+ +
+ /** + /**
+ * Sets the particle Color Transition. + * Sets the particle Color Transition.
+ * Only valid for {@link Particle#DUST_COLOR_TRANSITION}. + * Only valid for {@link Particle#DUST_COLOR_TRANSITION}.
+ * + *
+ * @param fromRgb an integer representing the red, green, and blue color components for the from color + * @param fromRgb an integer representing the red, green, and blue color components for the "from" color
+ * @param toRgb an integer representing the red, green, and blue color components for the to color + * @param toRgb an integer representing the red, green, and blue color components for the "to" color
+ * @return a reference to this object. + * @return a reference to this object.
+ * @throws IllegalArgumentException if the particle builder's {@link #particle()} isn't {@link Particle#DUST_COLOR_TRANSITION}. + * @throws IllegalArgumentException if the particle builder's {@link #particle()} isn't {@link Particle#DUST_COLOR_TRANSITION}.
+ */ + */
+ @NotNull
+ public ParticleBuilder colorTransition(final int fromRgb, final int toRgb) { + public ParticleBuilder colorTransition(final int fromRgb, final int toRgb) {
+ return colorTransition(Color.fromRGB(fromRgb), Color.fromRGB(toRgb)); + return this.colorTransition(Color.fromRGB(fromRgb), Color.fromRGB(toRgb));
+ } + }
+ +
+ /** + /**
+ * Sets the particle Color Transition and size. + * Sets the particle Color Transition and size.
+ * Only valid for {@link Particle#DUST_COLOR_TRANSITION}. + * Only valid for {@link Particle#DUST_COLOR_TRANSITION}.
+ * + *
+ * @param fromColor the new particle color for the from color. + * @param fromColor the new particle color for the "from" color.
+ * @param toColor the new particle color for the to color. + * @param toColor the new particle color for the "to" color.
+ * @param size the size of the particle + * @param size the size of the particle
+ * @return a reference to this object. + * @return a reference to this object.
+ * @throws IllegalArgumentException if the particle builder's {@link #particle()} isn't {@link Particle#DUST_COLOR_TRANSITION}. + * @throws IllegalArgumentException if the particle builder's {@link #particle()} isn't {@link Particle#DUST_COLOR_TRANSITION}.
+ */ + */
+ @NotNull + public ParticleBuilder colorTransition(final Color fromColor, final Color toColor, final float size) {
+ public ParticleBuilder colorTransition(@NotNull final Color fromColor,
+ @NotNull final Color toColor,
+ final float size) {
+ Preconditions.checkArgument(fromColor != null, "Cannot define color transition with null fromColor."); + Preconditions.checkArgument(fromColor != null, "Cannot define color transition with null fromColor.");
+ Preconditions.checkArgument(toColor != null, "Cannot define color transition with null toColor."); + Preconditions.checkArgument(toColor != null, "Cannot define color transition with null toColor.");
+ Preconditions.checkArgument(this.particle() == Particle.DUST_COLOR_TRANSITION, "Can only define a color transition on particle DUST_COLOR_TRANSITION."); + Preconditions.checkArgument(this.particle() == Particle.DUST_COLOR_TRANSITION, "Can only define a color transition on particle DUST_COLOR_TRANSITION.");
+ return data(new Particle.DustTransition(fromColor, toColor, size)); + return this.data(new Particle.DustTransition(fromColor, toColor, size));
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public ParticleBuilder clone() { + public ParticleBuilder clone() {
+ try { + try {

View File

@ -18,13 +18,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package com.destroystokyo.paper.network; +package com.destroystokyo.paper.network;
+ +
+import java.net.InetSocketAddress; +import java.net.InetSocketAddress;
+ +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.Nullable;
+import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Represents a client connected to the server. + * Represents a client connected to the server.
+ */ + */
+@NullMarked
+public interface NetworkClient { +public interface NetworkClient {
+ +
+ /** + /**
@ -32,7 +32,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The client's socket address + * @return The client's socket address
+ */ + */
+ @NotNull
+ InetSocketAddress getAddress(); + InetSocketAddress getAddress();
+ +
+ /** + /**
@ -52,8 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The client's virtual host, or {@code null} if unknown + * @return The client's virtual host, or {@code null} if unknown
+ */ + */
+ @Nullable + @Nullable InetSocketAddress getVirtualHost();
+ InetSocketAddress getVirtualHost();
+ +
+} +}
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

View File

@ -19,9 +19,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.NamedTextColor;
+import org.bukkit.Bukkit; +import org.bukkit.Bukkit;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public interface VersionFetcher { +public interface VersionFetcher {
+
+ /** + /**
+ * Amount of time to cache results for in milliseconds + * Amount of time to cache results for in milliseconds
+ * <p> + * <p>
@ -39,9 +42,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param serverVersion the current version of the server (will match {@link Bukkit#getVersion()}) + * @param serverVersion the current version of the server (will match {@link Bukkit#getVersion()})
+ * @return the message to show when requesting a version + * @return the message to show when requesting a version
+ */ + */
+ @NotNull + Component getVersionMessage(String serverVersion);
+ Component getVersionMessage(@NotNull String serverVersion);
+ +
+ @ApiStatus.Internal
+ class DummyVersionFetcher implements VersionFetcher { + class DummyVersionFetcher implements VersionFetcher {
+ +
+ @Override + @Override
@ -49,9 +52,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return -1; + return -1;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public Component getVersionMessage(@NotNull String serverVersion) { + public Component getVersionMessage(final String serverVersion) {
+ Bukkit.getLogger().warning("Version provider has not been set, cannot check for updates!"); + Bukkit.getLogger().warning("Version provider has not been set, cannot check for updates!");
+ Bukkit.getLogger().info("Override the default implementation of org.bukkit.UnsafeValues#getVersionFetcher()"); + Bukkit.getLogger().info("Override the default implementation of org.bukkit.UnsafeValues#getVersionFetcher()");
+ new Throwable().printStackTrace(); + new Throwable().printStackTrace();

View File

@ -43,24 +43,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty; +import com.destroystokyo.paper.profile.ProfileProperty;
+import java.util.Set;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+
+import java.util.Set;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired once a profiles additional properties (such as textures) has been filled + * Fired once a profiles additional properties (such as textures) has been filled
+ */ + */
+@NullMarked
+public class FillProfileEvent extends Event { +public class FillProfileEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final PlayerProfile profile; + private final PlayerProfile profile;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public FillProfileEvent(@NotNull PlayerProfile profile) { + public FillProfileEvent(final PlayerProfile profile) {
+ super(!org.bukkit.Bukkit.isPrimaryThread()); + super(!org.bukkit.Bukkit.isPrimaryThread());
+ this.profile = profile; + this.profile = profile;
+ } + }
@ -68,7 +68,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The Profile that had properties filled + * @return The Profile that had properties filled
+ */ + */
+ @NotNull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
+ return this.profile; + return this.profile;
+ } + }
@ -76,21 +75,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * Same as .getPlayerProfile().getProperties() + * Same as .getPlayerProfile().getProperties()
+ * + *
+ * @see PlayerProfile#getProperties()
+ * @return The new properties on the profile. + * @return The new properties on the profile.
+ * @see PlayerProfile#getProperties()
+ */ + */
+ @NotNull
+ public Set<ProfileProperty> getProperties() { + public Set<ProfileProperty> getProperties() {
+ return this.profile.getProperties(); + return this.profile.getProperties();
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -128,26 +124,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty; +import com.destroystokyo.paper.profile.ProfileProperty;
+import java.util.Collection;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+
+import java.util.Collection;
+import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * 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> + * <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
+ */ + */
+@NullMarked
+public class PreFillProfileEvent extends Event { +public class PreFillProfileEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final PlayerProfile profile; + private final PlayerProfile profile;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PreFillProfileEvent(@NotNull PlayerProfile profile) { + public PreFillProfileEvent(final PlayerProfile profile) {
+ super(!org.bukkit.Bukkit.isPrimaryThread()); + super(!org.bukkit.Bukkit.isPrimaryThread());
+ this.profile = profile; + this.profile = profile;
+ } + }
@ -155,7 +151,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The profile that needs its properties filled + * @return The profile that needs its properties filled
+ */ + */
+ @NotNull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
+ return this.profile; + return this.profile;
+ } + }
@ -163,21 +158,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * Sets the properties on the profile, avoiding the call to the Mojang API + * Sets the properties on the profile, avoiding the call to the Mojang API
+ * Same as .getPlayerProfile().setProperties(properties); + * Same as .getPlayerProfile().setProperties(properties);
+ * + *
+ * @see PlayerProfile#setProperties(Collection)
+ * @param properties The properties to set/append + * @param properties The properties to set/append
+ * @see PlayerProfile#setProperties(Collection)
+ */ + */
+ public void setProperties(@NotNull Collection<ProfileProperty> properties) { + public void setProperties(final Collection<ProfileProperty> properties) {
+ this.profile.setProperties(properties); + this.profile.setProperties(properties);
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -20,17 +20,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import org.bukkit.block.Block; +import org.bukkit.block.Block;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Represents an Inventory that can generate loot, such as Chests inside of Fortresses and Mineshafts + * Represents an Inventory that can generate loot, such as Chests inside of Fortresses and Mineshafts
+ */ + */
+@NullMarked
+public interface LootableBlockInventory extends LootableInventory { +public interface LootableBlockInventory extends LootableInventory {
+ +
+ /** + /**
+ * Gets the block that is lootable + * Gets the block that is lootable
+ * @return The Block + * @return The Block
+ */ + */
+ @NotNull
+ Block getBlock(); + Block getBlock();
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableEntityInventory.java b/src/main/java/com/destroystokyo/paper/loottable/LootableEntityInventory.java diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableEntityInventory.java b/src/main/java/com/destroystokyo/paper/loottable/LootableEntityInventory.java
@ -43,17 +44,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import org.bukkit.entity.Entity; +import org.bukkit.entity.Entity;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Represents an Inventory that can generate loot, such as Minecarts inside of Mineshafts + * Represents an Inventory that can generate loot, such as Minecarts inside of Mineshafts
+ */ + */
+@NullMarked
+public interface LootableEntityInventory extends LootableInventory { +public interface LootableEntityInventory extends LootableInventory {
+ +
+ /** + /**
+ * Gets the entity that is lootable + * Gets the entity that is lootable
+ * @return The Entity + * @return The Entity
+ */ + */
+ @NotNull
+ Entity getEntity(); + Entity getEntity();
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java
@ -64,44 +66,46 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.loottable; +package com.destroystokyo.paper.loottable;
+ +
+import java.util.UUID;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.loot.Lootable; +import org.bukkit.loot.Lootable;
+
+import java.util.UUID;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Represents an Inventory that contains a Loot Table associated to it that will + * Represents an Inventory that contains a Loot Table associated to it that will
+ * automatically fill on first open. + * automatically fill on first open.
+ * + * <p>
+ * A new feature and API is provided to support automatically refreshing the contents + * A new feature and API is provided to support automatically refreshing the contents
+ * of the inventory based on that Loot Table after a configurable amount of time has passed. + * of the inventory based on that Loot Table after a configurable amount of time has passed.
+ * + * <p>
+ * The behavior of how the Inventory is filled based on the loot table may vary based + * The behavior of how the Inventory is filled based on the loot table may vary based
+ * on Minecraft versions and the Loot Table feature. + * on Minecraft versions and the Loot Table feature.
+ */ + */
+@NullMarked
+public interface LootableInventory extends Lootable { +public interface LootableInventory extends Lootable {
+ +
+ /** + /**
+ * Server owners have to enable whether or not an object in a world should refill + * Server owners have to enable whether an object in a world should refill
+ * + *
+ * @return If the world this inventory is currently in has Replenishable Lootables enabled + * @return If the world this inventory is currently in has Replenishable Lootables enabled
+ */ + */
+ boolean isRefillEnabled(); + boolean isRefillEnabled();
+ +
+ /** + /**
+ * Whether or not this object has ever been filled + * Whether this object has ever been filled
+ *
+ * @return Has ever been filled + * @return Has ever been filled
+ */ + */
+ boolean hasBeenFilled(); + boolean hasBeenFilled();
+ +
+ /** + /**
+ * Has this player ever looted this block + * Has this player ever looted this block
+ *
+ * @param player The player to check + * @param player The player to check
+ * @return Whether or not this player has looted this block + * @return Whether this player has looted this block
+ */ + */
+ default boolean hasPlayerLooted(final @NotNull Player player) { + default boolean hasPlayerLooted(final Player player) {
+ return this.hasPlayerLooted(player.getUniqueId()); + return this.hasPlayerLooted(player.getUniqueId());
+ } + }
+ +
@ -109,17 +113,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Checks if this player can loot this block. Takes into account the "restrict player reloot" settings + * Checks if this player can loot this block. Takes into account the "restrict player reloot" settings
+ * + *
+ * @param player the player to check + * @param player the player to check
+ *
+ * @return Whether this player can loot this block + * @return Whether this player can loot this block
+ */ + */
+ boolean canPlayerLoot(@NotNull UUID player); + boolean canPlayerLoot(UUID player);
+ +
+ /** + /**
+ * Has this player ever looted this block + * Has this player ever looted this block
+ *
+ * @param player The player to check + * @param player The player to check
+ * @return Whether or not this player has looted this block + * @return Whether this player has looted this block
+ */ + */
+ boolean hasPlayerLooted(@NotNull UUID player); + boolean hasPlayerLooted(UUID player);
+ +
+ /** + /**
+ * Gets the timestamp, in milliseconds, of when the player last looted this object + * Gets the timestamp, in milliseconds, of when the player last looted this object
@ -127,7 +131,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param player The player to check + * @param player The player to check
+ * @return Timestamp last looted, or null if player has not looted this object + * @return Timestamp last looted, or null if player has not looted this object
+ */ + */
+ default @Nullable Long getLastLooted(final @NotNull Player player) { + default @Nullable Long getLastLooted(final Player player) {
+ return this.getLastLooted(player.getUniqueId()); + return this.getLastLooted(player.getUniqueId());
+ } + }
+ +
@ -138,28 +142,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return Timestamp last looted, or null if player has not looted this object + * @return Timestamp last looted, or null if player has not looted this object
+ */ + */
+ @Nullable + @Nullable
+ Long getLastLooted(@NotNull UUID player); + Long getLastLooted(UUID player);
+ +
+ /** + /**
+ * Change the state of whether or not a player has looted this block + * Change the state of whether a player has looted this block
+ *
+ * @param player The player to change state for + * @param player The player to change state for
+ * @param looted true to add player to looted list, false to remove + * @param looted true to add player to looted list, false to remove
+ * @return The previous state of whether the player had looted this or not + * @return The previous state of whether the player had looted this or not
+ */ + */
+ default boolean setHasPlayerLooted(final @NotNull Player player, final boolean looted) { + default boolean setHasPlayerLooted(final Player player, final boolean looted) {
+ return this.setHasPlayerLooted(player.getUniqueId(), looted); + return this.setHasPlayerLooted(player.getUniqueId(), looted);
+ } + }
+ +
+ /** + /**
+ * Change the state of whether or not a player has looted this block + * Change the state of whether a player has looted this block
+ *
+ * @param player The player to change state for + * @param player The player to change state for
+ * @param looted true to add player to looted list, false to remove + * @param looted true to add player to looted list, false to remove
+ * @return The previous state of whether the player had looted this or not + * @return The previous state of whether the player had looted this or not
+ */ + */
+ boolean setHasPlayerLooted(@NotNull UUID player, boolean looted); + boolean setHasPlayerLooted(UUID player, boolean looted);
+ +
+ /** + /**
+ * Returns Whether or not this object has been filled and now has a pending refill + * Returns Whether this object has been filled and now has a pending refill
+ *
+ * @return Has pending refill + * @return Has pending refill
+ */ + */
+ boolean hasPendingRefill(); + boolean hasPendingRefill();
@ -199,22 +206,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public class LootableInventoryReplenishEvent extends PlayerEvent implements Cancellable { +public class LootableInventoryReplenishEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final LootableInventory inventory; + private final LootableInventory inventory;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public LootableInventoryReplenishEvent(@NotNull Player player, @NotNull LootableInventory inventory) { + public LootableInventoryReplenishEvent(final Player player, final LootableInventory inventory) {
+ super(player); + super(player);
+ this.inventory = inventory; + this.inventory = inventory;
+ } + }
+ +
+ @NotNull
+ public LootableInventory getInventory() { + public LootableInventory getInventory() {
+ return this.inventory; + return this.inventory;
+ } + }
@ -225,16 +232,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -19,24 +19,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.entity; +package com.destroystokyo.paper.entity;
+ +
+import java.util.List;
+import org.bukkit.Location; +import org.bukkit.Location;
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Mob; +import org.bukkit.entity.Mob;
+ +import org.jspecify.annotations.NullMarked;
+import java.util.List; +import org.jspecify.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+ +
+/** +/**
+ * Handles pathfinding operations for an Entity + * Handles pathfinding operations for an Entity
+ */ + */
+@NullMarked
+public interface Pathfinder { +public interface Pathfinder {
+ +
+ /** + /**
+ *
+ * @return The entity that is controlled by this pathfinder + * @return The entity that is controlled by this pathfinder
+ */ + */
+ @NotNull
+ Mob getEntity(); + Mob getEntity();
+ +
+ /** + /**
@ -46,6 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ /** + /**
+ * If the entity is currently trying to navigate to a destination, this will return true + * If the entity is currently trying to navigate to a destination, this will return true
+ *
+ * @return true if the entity is navigating to a destination + * @return true if the entity is navigating to a destination
+ */ + */
+ boolean hasPath(); + boolean hasPath();
@ -53,86 +52,88 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return The location the entity is trying to navigate to, or null if there is no destination + * @return The location the entity is trying to navigate to, or null if there is no destination
+ */ + */
+ @Nullable + @Nullable PathResult getCurrentPath();
+ PathResult getCurrentPath();
+ +
+ /** + /**
+ * Calculates a destination for the Entity to navigate to, but does not set it + * Calculates a destination for the Entity to navigate to, but does not set it
+ * as the current target. Useful for calculating what would happen before setting it. + * as the current target. Useful for calculating what would happen before setting it.
+ *
+ * @param loc Location to navigate to + * @param loc Location to navigate to
+ * @return The closest Location the Entity can get to for this navigation, or null if no path could be calculated + * @return The closest Location the Entity can get to for this navigation, or null if no path could be calculated
+ */ + */
+ @Nullable PathResult findPath(@NotNull Location loc); + @Nullable PathResult findPath(Location loc);
+ +
+ /** + /**
+ * Calculates a destination for the Entity to navigate to to reach the target entity, + * Calculates a destination for the Entity to navigate to to reach the target entity,
+ * but does not set it as the current target. + * but does not set it as the current target.
+ * Useful for calculating what would happen before setting it. + * Useful for calculating what would happen before setting it.
+ * + * <p>
+ * The behavior of this PathResult is subject to the games pathfinding rules, and may + * The behavior of this PathResult is subject to the games pathfinding rules, and may
+ * result in the pathfinding automatically updating to follow the target Entity. + * result in the pathfinding automatically updating to follow the target Entity.
+ * + * <p>
+ * However, this behavior is not guaranteed, and is subject to the games behavior. + * However, this behavior is not guaranteed, and is subject to the games behavior.
+ * + *
+ * @param target the Entity to navigate to + * @param target the Entity to navigate to
+ * @return The closest Location the Entity can get to for this navigation, or null if no path could be calculated + * @return The closest Location the Entity can get to for this navigation, or null if no path could be calculated
+ */ + */
+ @Nullable PathResult findPath(@NotNull LivingEntity target); + @Nullable PathResult findPath(LivingEntity target);
+ +
+ /** + /**
+ * Calculates a destination for the Entity to navigate to, and sets it with default speed + * Calculates a destination for the Entity to navigate to, and sets it with default speed
+ * as the current target. + * as the current target.
+ *
+ * @param loc Location to navigate to + * @param loc Location to navigate to
+ * @return If the pathfinding was successfully started + * @return If the pathfinding was successfully started
+ */ + */
+ default boolean moveTo(@NotNull Location loc) { + default boolean moveTo(Location loc) {
+ return moveTo(loc, 1); + return this.moveTo(loc, 1);
+ } + }
+ +
+ /** + /**
+ * Calculates a destination for the Entity to navigate to, with desired speed + * Calculates a destination for the Entity to navigate to, with desired speed
+ * as the current target. + * as the current target.
+ * @param loc Location to navigate to + *
+ * @param loc Location to navigate to
+ * @param speed Speed multiplier to navigate at, where 1 is 'normal' + * @param speed Speed multiplier to navigate at, where 1 is 'normal'
+ * @return If the pathfinding was successfully started + * @return If the pathfinding was successfully started
+ */ + */
+ default boolean moveTo(@NotNull Location loc, double speed) { + default boolean moveTo(Location loc, double speed) {
+ PathResult path = findPath(loc); + PathResult path = this.findPath(loc);
+ return path != null && moveTo(path, speed); + return path != null && this.moveTo(path, speed);
+ } + }
+ +
+ /** + /**
+ * Calculates a destination for the Entity to navigate to to reach the target entity, + * Calculates a destination for the Entity to navigate to to reach the target entity,
+ * and sets it with default speed. + * and sets it with default speed.
+ * + * <p>
+ * The behavior of this PathResult is subject to the games pathfinding rules, and may + * The behavior of this PathResult is subject to the games pathfinding rules, and may
+ * result in the pathfinding automatically updating to follow the target Entity. + * result in the pathfinding automatically updating to follow the target Entity.
+ * + * <p>
+ * However, this behavior is not guaranteed, and is subject to the games behavior. + * However, this behavior is not guaranteed, and is subject to the games behavior.
+ * + *
+ * @param target the Entity to navigate to + * @param target the Entity to navigate to
+ * @return If the pathfinding was successfully started + * @return If the pathfinding was successfully started
+ */ + */
+ default boolean moveTo(@NotNull LivingEntity target) { + default boolean moveTo(LivingEntity target) {
+ return moveTo(target, 1); + return this.moveTo(target, 1);
+ } + }
+ +
+ /** + /**
+ * Calculates a destination for the Entity to navigate to to reach the target entity, + * Calculates a destination for the Entity to navigate to to reach the target entity,
+ * and sets it with specified speed. + * and sets it with specified speed.
+ * + * <p>
+ * The behavior of this PathResult is subject to the games pathfinding rules, and may + * The behavior of this PathResult is subject to the games pathfinding rules, and may
+ * result in the pathfinding automatically updating to follow the target Entity. + * result in the pathfinding automatically updating to follow the target Entity.
+ * + * <p>
+ * However, this behavior is not guaranteed, and is subject to the games behavior. + * However, this behavior is not guaranteed, and is subject to the games behavior.
+ * + *
+ * @param target the Entity to navigate to + * @param target the Entity to navigate to
+ * @param speed Speed multiplier to navigate at, where 1 is 'normal' + * @param speed Speed multiplier to navigate at, where 1 is 'normal'
+ * @return If the pathfinding was successfully started + * @return If the pathfinding was successfully started
+ */ + */
+ default boolean moveTo(@NotNull LivingEntity target, double speed) { + default boolean moveTo(LivingEntity target, double speed) {
+ PathResult path = findPath(target); + PathResult path = this.findPath(target);
+ return path != null && moveTo(path, speed); + return path != null && this.moveTo(path, speed);
+ } + }
+ +
+ /** + /**
@ -142,19 +143,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param path The Path to start following + * @param path The Path to start following
+ * @return If the pathfinding was successfully started + * @return If the pathfinding was successfully started
+ */ + */
+ default boolean moveTo(@NotNull PathResult path) { + default boolean moveTo(PathResult path) {
+ return moveTo(path, 1); + return this.moveTo(path, 1);
+ } + }
+ +
+ /** + /**
+ * Takes the result of a previous pathfinding calculation and sets it + * Takes the result of a previous pathfinding calculation and sets it
+ * as the active pathfinding, + * as the active pathfinding,
+ * + *
+ * @param path The Path to start following + * @param path The Path to start following
+ * @param speed Speed multiplier to navigate at, where 1 is 'normal' + * @param speed Speed multiplier to navigate at, where 1 is 'normal'
+ * @return If the pathfinding was successfully started + * @return If the pathfinding was successfully started
+ */ + */
+ boolean moveTo(@NotNull PathResult path, double speed); + boolean moveTo(PathResult path, double speed);
+ +
+ /** + /**
+ * Checks if this pathfinder allows passing through closed doors. + * Checks if this pathfinder allows passing through closed doors.
@ -205,11 +206,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ /** + /**
+ * All currently calculated points to follow along the path to reach the destination location + * All currently calculated points to follow along the path to reach the destination location
+ * + * <p>
+ * Will return points the entity has already moved past, see {@link #getNextPointIndex()} + * Will return points the entity has already moved past, see {@link #getNextPointIndex()}
+ *
+ * @return List of points + * @return List of points
+ */ + */
+ @NotNull
+ List<Location> getPoints(); + List<Location> getPoints();
+ +
+ /** + /**

View File

@ -12,16 +12,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.util; +package com.destroystokyo.paper.util;
+ +
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+public class SneakyThrow { +@ApiStatus.Internal
+@NullMarked
+public final class SneakyThrow {
+ +
+ public static void sneaky(@NotNull Throwable exception) { + public static void sneaky(final Throwable exception) {
+ SneakyThrow.<RuntimeException>throwSneaky(exception); + SneakyThrow.throwSneaky(exception);
+ } + }
+ +
+ @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked")
+ private static <T extends Throwable> void throwSneaky(@NotNull Throwable exception) throws T { + private static <T extends Throwable> void throwSneaky(final Throwable exception) throws T {
+ throw (T) exception; + throw (T) exception;
+ } + }
+ +

View File

@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Is called when a {@link Player} receives a {@link Chunk} + * Is called when a {@link Player} receives a {@link Chunk}
@ -27,6 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * 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.
+ */ + */
+@NullMarked
+public class PlayerChunkLoadEvent extends ChunkEvent { +public class PlayerChunkLoadEvent extends ChunkEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -34,23 +35,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final Player player; + private final Player player;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerChunkLoadEvent(@NotNull Chunk chunk, @NotNull Player player) { + public PlayerChunkLoadEvent(final Chunk chunk, final Player player) {
+ super(chunk); + super(chunk);
+ this.player = player; + this.player = player;
+ } + }
+ +
+ @NotNull
+ public Player getPlayer() { + public Player getPlayer() {
+ return this.player; + return this.player;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -68,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Is called when a {@link Player} receives a chunk unload packet. + * Is called when a {@link Player} receives a chunk unload packet.
@ -76,6 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * 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.
+ */ + */
+@NullMarked
+public class PlayerChunkUnloadEvent extends ChunkEvent { +public class PlayerChunkUnloadEvent extends ChunkEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -83,23 +82,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final Player player; + private final Player player;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerChunkUnloadEvent(@NotNull Chunk chunk, @NotNull Player player) { + public PlayerChunkUnloadEvent(final Chunk chunk, final Player player) {
+ super(chunk); + super(chunk);
+ this.player = player; + this.player = player;
+ } + }
+ +
+ @NotNull
+ public Player getPlayer() { + public Player getPlayer() {
+ return this.player; + return this.player;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Is called when a {@link Player} tracks an {@link Entity}. + * Is called when a {@link Player} tracks an {@link Entity}.
@ -28,6 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Adding or removing entities from the world at the point in time this event is called is completely + * Adding or removing entities from the world at the point in time this event is called is completely
+ * unsupported and should be avoided. + * unsupported and should be avoided.
+ */ + */
+@NullMarked
+public class PlayerTrackEntityEvent extends PlayerEvent implements Cancellable { +public class PlayerTrackEntityEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -36,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerTrackEntityEvent(@NotNull Player player, @NotNull Entity entity) { + public PlayerTrackEntityEvent(final Player player, final Entity entity) {
+ super(player); + super(player);
+ this.entity = entity; + this.entity = entity;
+ } + }
@ -46,7 +47,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the entity tracked + * @return the entity tracked
+ */ + */
+ @NotNull
+ public Entity getEntity() { + public Entity getEntity() {
+ return this.entity; + return this.entity;
+ } + }
@ -57,16 +57,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
@ -85,7 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Is called when a {@link Player} untracks an {@link Entity}. + * Is called when a {@link Player} untracks an {@link Entity}.
@ -93,6 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Adding or removing entities from the world at the point in time this event is called is completely + * Adding or removing entities from the world at the point in time this event is called is completely
+ * unsupported and should be avoided. + * unsupported and should be avoided.
+ */ + */
+@NullMarked
+public class PlayerUntrackEntityEvent extends PlayerEvent { +public class PlayerUntrackEntityEvent extends PlayerEvent {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
@ -100,7 +99,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final Entity entity; + private final Entity entity;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerUntrackEntityEvent(@NotNull Player player, @NotNull Entity entity) { + public PlayerUntrackEntityEvent(final Player player, final Entity entity) {
+ super(player); + super(player);
+ this.entity = entity; + this.entity = entity;
+ } + }
@ -110,17 +109,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the entity untracked + * @return the entity untracked
+ */ + */
+ @NotNull
+ public Entity getEntity() { + public Entity getEntity() {
+ return this.entity; + return this.entity;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;

View File

@ -20,25 +20,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a player boosts elytra flight with a firework + * Fired when a player boosts elytra flight with a firework
+ */ + */
+@NullMarked
+public class PlayerElytraBoostEvent extends PlayerEvent implements Cancellable { +public class PlayerElytraBoostEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final ItemStack itemStack; + private final ItemStack itemStack;
+ @NotNull private final Firework firework; + private final Firework firework;
+ private boolean consume = true; + private boolean consume = true;
+ @NotNull
+ private final EquipmentSlot hand; + private final EquipmentSlot hand;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerElytraBoostEvent(@NotNull Player player, @NotNull ItemStack itemStack, @NotNull Firework firework, @NotNull EquipmentSlot hand) { + public PlayerElytraBoostEvent(final Player player, final ItemStack itemStack, final Firework firework, final EquipmentSlot hand) {
+ super(player); + super(player);
+ this.itemStack = itemStack; + this.itemStack = itemStack;
+ this.firework = firework; + this.firework = firework;
@ -50,7 +50,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return ItemStack of firework + * @return ItemStack of firework
+ */ + */
+ @NotNull
+ public ItemStack getItemStack() { + public ItemStack getItemStack() {
+ return this.itemStack; + return this.itemStack;
+ } + }
@ -60,7 +59,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return Firework entity + * @return Firework entity
+ */ + */
+ @NotNull
+ public Firework getFirework() { + public Firework getFirework() {
+ return this.firework; + return this.firework;
+ } + }
@ -79,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param consume {@code true} to consume + * @param consume {@code true} to consume
+ */ + */
+ public void setShouldConsume(boolean consume) { + public void setShouldConsume(final boolean consume) {
+ this.consume = consume; + this.consume = consume;
+ } + }
+ +
@ -88,7 +86,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return interaction hand + * @return interaction hand
+ */ + */
+ @NotNull
+ public EquipmentSlot getHand() { + public EquipmentSlot getHand() {
+ return this.hand; + return this.hand;
+ } + }
@ -99,17 +96,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Called when a player shoots a projectile. + * Called when a player shoots a projectile.
@ -29,18 +29,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * of a bow or crossbow. A plugin may listen to {@link EntityShootBowEvent} + * of a bow or crossbow. A plugin may listen to {@link EntityShootBowEvent}
+ * for these actions instead. + * for these actions instead.
+ */ + */
+@NullMarked
+public class PlayerLaunchProjectileEvent extends PlayerEvent implements Cancellable { +public class PlayerLaunchProjectileEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final Projectile projectile; + private final Projectile projectile;
+ @NotNull private final ItemStack itemStack; + private final ItemStack itemStack;
+ private boolean consumeItem = true; + private boolean consumeItem = true;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerLaunchProjectileEvent(@NotNull Player shooter, @NotNull ItemStack itemStack, @NotNull Projectile projectile) { + public PlayerLaunchProjectileEvent(final Player shooter, final ItemStack itemStack, final Projectile projectile) {
+ super(shooter); + super(shooter);
+ this.itemStack = itemStack; + this.itemStack = itemStack;
+ this.projectile = projectile; + this.projectile = projectile;
@ -51,7 +52,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the launched projectile + * @return the launched projectile
+ */ + */
+ @NotNull
+ public Projectile getProjectile() { + public Projectile getProjectile() {
+ return this.projectile; + return this.projectile;
+ } + }
@ -61,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The ItemStack used + * @return The ItemStack used
+ */ + */
+ @NotNull
+ public ItemStack getItemStack() { + public ItemStack getItemStack() {
+ return this.itemStack; + return this.itemStack;
+ } + }
@ -80,7 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param consumeItem {@code true} to consume + * @param consumeItem {@code true} to consume
+ */ + */
+ public void setShouldConsume(boolean consumeItem) { + public void setShouldConsume(final boolean consumeItem) {
+ this.consumeItem = consumeItem; + this.consumeItem = consumeItem;
+ } + }
+ +
@ -90,17 +89,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -42,20 +42,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a player is attempting to pick up an experience orb + * Fired when a player is attempting to pick up an experience orb
+ */ + */
+@NullMarked
+public class PlayerPickupExperienceEvent extends PlayerEvent implements Cancellable { +public class PlayerPickupExperienceEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final ExperienceOrb experienceOrb; + private final ExperienceOrb experienceOrb;
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerPickupExperienceEvent(@NotNull Player player, @NotNull ExperienceOrb experienceOrb) { + public PlayerPickupExperienceEvent(final Player player, final ExperienceOrb experienceOrb) {
+ super(player); + super(player);
+ this.experienceOrb = experienceOrb; + this.experienceOrb = experienceOrb;
+ } + }
@ -63,7 +64,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return Returns the Orb that the player is picking up + * @return Returns the Orb that the player is picking up
+ */ + */
+ @NotNull
+ public ExperienceOrb getExperienceOrb() { + public ExperienceOrb getExperienceOrb() {
+ return this.experienceOrb; + return this.experienceOrb;
+ } + }
@ -79,17 +79,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * If {@code true}, cancels picking up the experience orb, leaving it in the world + * If {@code true}, cancels picking up the experience orb, leaving it in the world
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -42,21 +42,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * 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.
+ */ + */
+@NullMarked
+public class PlayerReadyArrowEvent extends PlayerEvent implements Cancellable { +public class PlayerReadyArrowEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final ItemStack bow; + private final ItemStack bow;
+ @NotNull private final ItemStack arrow; + private final ItemStack arrow;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ public PlayerReadyArrowEvent(@NotNull Player player, @NotNull ItemStack bow, @NotNull ItemStack arrow) { + public PlayerReadyArrowEvent(final Player player, final ItemStack bow, final ItemStack arrow) {
+ super(player); + super(player);
+ this.bow = bow; + this.bow = bow;
+ this.arrow = arrow; + this.arrow = arrow;
@ -65,7 +66,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return the player is using to fire the arrow + * @return the player is using to fire the arrow
+ */ + */
+ @NotNull
+ public ItemStack getBow() { + public ItemStack getBow() {
+ return this.bow; + return this.bow;
+ } + }
@ -73,7 +73,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /** + /**
+ * @return the arrow that is attempting to be used + * @return the arrow that is attempting to be used
+ */ + */
+ @NotNull
+ public ItemStack getArrow() { + public ItemStack getArrow() {
+ return this.arrow; + return this.arrow;
+ } + }
@ -92,16 +91,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * 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.
+ */ + */
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -18,17 +18,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+/** +/**
+ * Fired when a teleport is triggered for an End Gateway + * Fired when a teleport is triggered for an End Gateway
+ */ + */
+@NullMarked
+public class PlayerTeleportEndGatewayEvent extends PlayerTeleportEvent { +public class PlayerTeleportEndGatewayEvent extends PlayerTeleportEvent {
+ +
+ @NotNull private final EndGateway gateway; + private final EndGateway gateway;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerTeleportEndGatewayEvent(@NotNull Player player, @NotNull Location from, @NotNull Location to, @NotNull EndGateway gateway) { + public PlayerTeleportEndGatewayEvent(final Player player, final Location from, final Location to, final EndGateway gateway) {
+ super(player, from, to, PlayerTeleportEvent.TeleportCause.END_GATEWAY); + super(player, from, to, PlayerTeleportEvent.TeleportCause.END_GATEWAY);
+ this.gateway = gateway; + this.gateway = gateway;
+ } + }
@ -38,7 +39,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return EndGateway used + * @return EndGateway used
+ */ + */
+ @NotNull
+ public EndGateway getGateway() { + public EndGateway getGateway() {
+ return this.gateway; + return this.gateway;
+ } + }

View File

@ -44,8 +44,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.ApiStatus;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.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.
@ -53,24 +53,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * 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.
+ */ + */
+@NullMarked
+public class ProfileWhitelistVerifyEvent extends Event { +public class ProfileWhitelistVerifyEvent extends Event {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ @NotNull private final PlayerProfile profile; + private final PlayerProfile profile;
+ private final boolean whitelistEnabled; + private final boolean whitelistEnabled;
+ private final boolean isOp; + private final boolean isOp;
+ private boolean whitelisted; + private boolean whitelisted;
+ @Nullable private Component kickMessage; + private @Nullable Component kickMessage;
+ +
+ @Deprecated + @Deprecated
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable String kickMessage) { + public ProfileWhitelistVerifyEvent(final PlayerProfile profile, final boolean whitelistEnabled, final boolean whitelisted, final boolean isOp, final @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 + @ApiStatus.Internal
+ public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable Component kickMessage) { + public ProfileWhitelistVerifyEvent(final PlayerProfile profile, final boolean whitelistEnabled, final boolean whitelisted, final boolean isOp, final @Nullable Component kickMessage) {
+ this.profile = profile; + this.profile = profile;
+ this.whitelistEnabled = whitelistEnabled; + this.whitelistEnabled = whitelistEnabled;
+ this.whitelisted = whitelisted; + this.whitelisted = whitelisted;
@ -83,8 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @deprecated use {@link #kickMessage()} + * @deprecated use {@link #kickMessage()}
+ */ + */
+ @Deprecated + @Deprecated
+ @Nullable + public @Nullable String getKickMessage() {
+ public String getKickMessage() {
+ return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.kickMessage); + return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.kickMessage);
+ } + }
+ +
@ -93,35 +93,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @deprecated Use {@link #kickMessage(Component)} + * @deprecated Use {@link #kickMessage(Component)}
+ */ + */
+ @Deprecated + @Deprecated
+ public void setKickMessage(@Nullable String kickMessage) { + public void setKickMessage(final @Nullable String kickMessage) {
+ this.kickMessage(kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage)); + this.kickMessage(kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage));
+ } + }
+ +
+ /** + /**
+ * @return the currently planned message to send to the user if they are not whitelisted + * @return the currently planned message to send to the user if they are not whitelisted
+ */ + */
+ @Nullable + public @Nullable Component kickMessage() {
+ public Component kickMessage() {
+ return this.kickMessage; + return this.kickMessage;
+ } + }
+ +
+ /** + /**
+ * @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 + * @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(final @Nullable Component kickMessage) {
+ this.kickMessage = kickMessage; + this.kickMessage = kickMessage;
+ } + }
+ +
+ /** + /**
+ * @return The profile of the player trying to connect + * @return The profile of the player trying to connect
+ */ + */
+ @NotNull
+ public PlayerProfile getPlayerProfile() { + public PlayerProfile getPlayerProfile() {
+ return this.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 it's true)
+ */ + */
+ public boolean isWhitelisted() { + public boolean isWhitelisted() {
+ return this.whitelisted; + return this.whitelisted;
@ -129,9 +127,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ /** + /**
+ * Changes the players whitelisted state. {@code 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(final boolean whitelisted) {
+ this.whitelisted = whitelisted; + this.whitelisted = whitelisted;
+ } + }
+ +
@ -149,13 +148,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.whitelistEnabled; + return this.whitelistEnabled;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -16,8 +16,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Mob; +import org.bukkit.entity.Mob;
+import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public interface RangedEntity extends Mob { +public interface RangedEntity extends Mob {
+ /** + /**
+ * Attack the specified entity using a ranged attack. + * Attack the specified entity using a ranged attack.
@ -26,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param charge How "charged" the attack is (how far back the bow was pulled for Bow attacks). + * @param charge How "charged" the attack is (how far back the bow was pulled for Bow attacks).
+ * This should be a value between 0 and 1, represented as targetDistance/maxDistance. + * This should be a value between 0 and 1, represented as targetDistance/maxDistance.
+ */ + */
+ void rangedAttack(@NotNull LivingEntity target, float charge); + void rangedAttack(LivingEntity target, float charge);
+ +
+ /** + /**
+ * Sets that the Entity is "charging" up an attack, by raising its hands + * Sets that the Entity is "charging" up an attack, by raising its hands
@ -44,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ @Deprecated(since = "1.19.2") + @Deprecated(since = "1.19.2")
+ default boolean isChargingAttack() { + default boolean isChargingAttack() {
+ return isHandRaised(); + return this.isHandRaised();
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/entity/AbstractSkeleton.java b/src/main/java/org/bukkit/entity/AbstractSkeleton.java diff --git a/src/main/java/org/bukkit/entity/AbstractSkeleton.java b/src/main/java/org/bukkit/entity/AbstractSkeleton.java

View File

@ -64,6 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.timeEnd - System.nanoTime(); + return this.timeEnd - System.nanoTime();
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -104,6 +105,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.tickNumber; + return this.tickNumber;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -89,6 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The Slime that is pathfinding. + * @return The Slime that is pathfinding.
+ */ + */
+ @Override
+ public Slime getEntity() { + public Slime getEntity() {
+ return (Slime) super.getEntity(); + return (Slime) super.getEntity();
+ } + }
@ -103,6 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -39,6 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The turtle + * @return The turtle
+ */ + */
+ @Override
+ public Turtle getEntity() { + public Turtle getEntity() {
+ return (Turtle) super.getEntity(); + return (Turtle) super.getEntity();
+ } + }
@ -53,6 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -102,6 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The turtle + * @return The turtle
+ */ + */
+ @Override
+ public Turtle getEntity() { + public Turtle getEntity() {
+ return (Turtle) super.getEntity(); + return (Turtle) super.getEntity();
+ } + }
@ -147,6 +150,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
@ -193,6 +197,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return The turtle + * @return The turtle
+ */ + */
+ @Override
+ public Turtle getEntity() { + public Turtle getEntity() {
+ return (Turtle) super.getEntity(); + return (Turtle) super.getEntity();
+ } + }
@ -216,6 +221,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -27,42 +27,46 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.executor; +package com.destroystokyo.paper.event.executor;
+ +
+import com.destroystokyo.paper.util.SneakyThrow;
+import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Method; +import java.lang.reflect.Method;
+
+import com.destroystokyo.paper.util.SneakyThrow;
+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;
+import org.bukkit.plugin.EventExecutor; +import org.bukkit.plugin.EventExecutor;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+ +
+@ApiStatus.Internal
+@NullMarked
+public class MethodHandleEventExecutor implements EventExecutor { +public class MethodHandleEventExecutor implements EventExecutor {
+
+ private final Class<? extends Event> eventClass; + private final Class<? extends Event> eventClass;
+ private final MethodHandle handle; + private final MethodHandle handle;
+ +
+ public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull MethodHandle handle) { + public MethodHandleEventExecutor(final Class<? extends Event> eventClass, final MethodHandle handle) {
+ this.eventClass = eventClass; + this.eventClass = eventClass;
+ this.handle = handle; + this.handle = handle;
+ } + }
+ +
+ public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) { + public MethodHandleEventExecutor(final Class<? extends Event> eventClass, final Method m) {
+ this.eventClass = eventClass; + this.eventClass = eventClass;
+ try { + try {
+ m.setAccessible(true); + m.setAccessible(true);
+ this.handle = MethodHandles.lookup().unreflect(m); + this.handle = MethodHandles.lookup().unreflect(m);
+ } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) {
+ throw new AssertionError("Unable to set accessible", e); + throw new AssertionError("Unable to set accessible", e);
+ } + }
+ } + }
+ +
+ @Override + @Override
+ public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException { + public void execute(final Listener listener, final Event event) throws EventException {
+ if (!eventClass.isInstance(event)) return; + if (!this.eventClass.isInstance(event)) return;
+ try { + try {
+ handle.invoke(listener, event); + this.handle.invoke(listener, event);
+ } catch (Throwable t) { + } catch (final Throwable t) {
+ SneakyThrow.sneaky(t); + SneakyThrow.sneaky(t);
+ } + }
+ } + }
@ -75,42 +79,44 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.executor; +package com.destroystokyo.paper.event.executor;
+ +
+import com.destroystokyo.paper.util.SneakyThrow;
+import com.google.common.base.Preconditions;
+import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Method; +import java.lang.reflect.Method;
+import java.lang.reflect.Modifier; +import java.lang.reflect.Modifier;
+
+import com.destroystokyo.paper.util.SneakyThrow;
+import com.google.common.base.Preconditions;
+
+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;
+import org.bukkit.plugin.EventExecutor; +import org.bukkit.plugin.EventExecutor;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+@ApiStatus.Internal
+@NullMarked
+public class StaticMethodHandleEventExecutor implements EventExecutor { +public class StaticMethodHandleEventExecutor implements EventExecutor {
+
+ private final Class<? extends Event> eventClass; + private final Class<? extends Event> eventClass;
+ private final MethodHandle handle; + private final MethodHandle handle;
+ +
+ public StaticMethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) { + public StaticMethodHandleEventExecutor(final Class<? extends Event> eventClass, final Method m) {
+ Preconditions.checkArgument(Modifier.isStatic(m.getModifiers()), "Not a static method: %s", m); + Preconditions.checkArgument(Modifier.isStatic(m.getModifiers()), "Not a static method: %s", m);
+ Preconditions.checkArgument(eventClass != null, "eventClass is null"); + Preconditions.checkArgument(eventClass != null, "eventClass is null");
+ this.eventClass = eventClass; + this.eventClass = eventClass;
+ try { + try {
+ m.setAccessible(true); + m.setAccessible(true);
+ this.handle = MethodHandles.lookup().unreflect(m); + this.handle = MethodHandles.lookup().unreflect(m);
+ } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) {
+ throw new AssertionError("Unable to set accessible", e); + throw new AssertionError("Unable to set accessible", e);
+ } + }
+ } + }
+ +
+ @Override + @Override
+ public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException { + public void execute(final Listener listener, final Event event) throws EventException {
+ if (!eventClass.isInstance(event)) return; + if (!this.eventClass.isInstance(event)) return;
+ try { + try {
+ handle.invoke(event); + this.handle.invoke(event);
+ } catch (Throwable throwable) { + } catch (final Throwable throwable) {
+ SneakyThrow.sneaky(throwable); + SneakyThrow.sneaky(throwable);
+ } + }
+ } + }
@ -125,23 +131,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import java.lang.reflect.Method; +import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicInteger;
+
+import org.bukkit.plugin.EventExecutor; +import org.bukkit.plugin.EventExecutor;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Type; +import org.objectweb.asm.Type;
+import org.objectweb.asm.commons.GeneratorAdapter; +import org.objectweb.asm.commons.GeneratorAdapter;
+ +
+import static org.objectweb.asm.Opcodes.*; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
+import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
+import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
+import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
+import static org.objectweb.asm.Opcodes.V1_8;
+ +
+public class ASMEventExecutorGenerator { +@ApiStatus.Internal
+@NullMarked
+public final class ASMEventExecutorGenerator {
+ +
+ private static final String EXECUTE_DESCRIPTOR = "(Lorg/bukkit/event/Listener;Lorg/bukkit/event/Event;)V"; + private static final String EXECUTE_DESCRIPTOR = "(Lorg/bukkit/event/Listener;Lorg/bukkit/event/Event;)V";
+ +
+ @NotNull + public static byte[] generateEventExecutor(final Method m, final String name) {
+ public static byte[] generateEventExecutor(@NotNull Method m, @NotNull String name) { + final ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
+ ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + writer.visit(V1_8, ACC_PUBLIC, name.replace('.', '/'), null, Type.getInternalName(Object.class), new String[]{Type.getInternalName(EventExecutor.class)});
+ writer.visit(V1_8, ACC_PUBLIC, name.replace('.', '/'), null, Type.getInternalName(Object.class), new String[] {Type.getInternalName(EventExecutor.class)});
+ // Generate constructor + // Generate constructor
+ GeneratorAdapter methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null), ACC_PUBLIC, "<init>", "()V"); + GeneratorAdapter methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null), ACC_PUBLIC, "<init>", "()V");
+ methodGenerator.loadThis(); + methodGenerator.loadThis();
@ -169,9 +180,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ public static AtomicInteger NEXT_ID = new AtomicInteger(1); + public static AtomicInteger NEXT_ID = new AtomicInteger(1);
+ @NotNull +
+ public static String generateName() { + public static String generateName() {
+ int id = NEXT_ID.getAndIncrement(); + final int id = NEXT_ID.getAndIncrement();
+ return "com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor" + id; + return "com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor" + id;
+ } + }
+} +}
@ -183,8 +194,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.executor.asm; +package com.destroystokyo.paper.event.executor.asm;
+ +
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+@ApiStatus.Internal
+@NullMarked
+public interface ClassDefiner { +public interface ClassDefiner {
+ +
+ /** + /**
@ -192,7 +206,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return if classes bypass access checks + * @return if classes bypass access checks
+ */ + */
+ public default boolean isBypassAccessChecks() { + default boolean isBypassAccessChecks() {
+ return false; + return false;
+ } + }
+ +
@ -206,11 +220,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @throws ClassFormatError if the class data is invalid + * @throws ClassFormatError if the class data is invalid
+ * @throws NullPointerException if any of the arguments are null + * @throws NullPointerException if any of the arguments are null
+ */ + */
+ @NotNull + Class<?> defineClass(ClassLoader parentLoader, String name, byte[] data);
+ public Class<?> defineClass(@NotNull ClassLoader parentLoader, @NotNull String name, @NotNull byte[] data);
+ +
+ @NotNull + static ClassDefiner getInstance() {
+ public static ClassDefiner getInstance() {
+ return SafeClassDefiner.INSTANCE; + return SafeClassDefiner.INSTANCE;
+ } + }
+ +
@ -223,62 +235,64 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.destroystokyo.paper.event.executor.asm; +package com.destroystokyo.paper.event.executor.asm;
+ +
+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 java.util.concurrent.ConcurrentMap;
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+ +
+@ApiStatus.Internal
+@NullMarked
+public class SafeClassDefiner implements ClassDefiner { +public class SafeClassDefiner implements ClassDefiner {
+
+ /* default */ static final SafeClassDefiner INSTANCE = new SafeClassDefiner(); + /* default */ static final SafeClassDefiner INSTANCE = new SafeClassDefiner();
+ +
+ private SafeClassDefiner() {} + private SafeClassDefiner() {
+ }
+ +
+ private final ConcurrentMap<ClassLoader, GeneratedClassLoader> loaders = new MapMaker().weakKeys().makeMap(); + private final ConcurrentMap<ClassLoader, GeneratedClassLoader> loaders = new MapMaker().weakKeys().makeMap();
+ +
+ @NotNull
+ @Override + @Override
+ public Class<?> defineClass(@NotNull ClassLoader parentLoader, @NotNull String name, @NotNull byte[] data) { + public Class<?> defineClass(final ClassLoader parentLoader, final String name, final byte[] data) {
+ GeneratedClassLoader loader = loaders.computeIfAbsent(parentLoader, GeneratedClassLoader::new); + final GeneratedClassLoader loader = this.loaders.computeIfAbsent(parentLoader, GeneratedClassLoader::new);
+ synchronized (loader.getClassLoadingLock(name)) { + synchronized (loader.getClassLoadingLock(name)) {
+ Preconditions.checkState(!loader.hasClass(name), "%s already defined", name); + Preconditions.checkState(!loader.hasClass(name), "%s already defined", name);
+ Class<?> c = loader.define(name, data); + final Class<?> c = loader.define(name, data);
+ assert c.getName().equals(name); + assert c.getName().equals(name);
+ return c; + return c;
+ } + }
+ } + }
+ +
+ private static class GeneratedClassLoader extends ClassLoader { + private static class GeneratedClassLoader extends ClassLoader {
+
+ static { + static {
+ ClassLoader.registerAsParallelCapable(); + ClassLoader.registerAsParallelCapable();
+ } + }
+ +
+ protected GeneratedClassLoader(@NotNull ClassLoader parent) { + protected GeneratedClassLoader(final ClassLoader parent) {
+ super(parent); + super(parent);
+ } + }
+ +
+ private Class<?> define(@NotNull String name, byte[] data) { + private Class<?> define(final String name, final byte[] data) {
+ synchronized (getClassLoadingLock(name)) { + synchronized (this.getClassLoadingLock(name)) {
+ assert !hasClass(name); + assert !this.hasClass(name);
+ Class<?> c = defineClass(name, data, 0, data.length); + final Class<?> c = this.defineClass(name, data, 0, data.length);
+ resolveClass(c); + this.resolveClass(c);
+ return c; + return c;
+ } + }
+ } + }
+ +
+ @Override + @Override
+ @NotNull + public Object getClassLoadingLock(final String name) {
+ public Object getClassLoadingLock(@NotNull String name) {
+ return super.getClassLoadingLock(name); + return super.getClassLoadingLock(name);
+ } + }
+ +
+ public boolean hasClass(@NotNull String name) { + public boolean hasClass(final String name) {
+ synchronized (getClassLoadingLock(name)) { + synchronized (this.getClassLoadingLock(name)) {
+ try { + try {
+ Class.forName(name); + Class.forName(name);
+ return true; + return true;
+ } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) {
+ return false; + return false;
+ } + }
+ } + }

View File

@ -73,6 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -19,24 +19,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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.jspecify.annotations.NullMarked;
+import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable;
+ +
+/** +/**
+ * Called when the player is attempting to rename a mob + * Called when the player is attempting to rename a mob
+ */ + */
+@NullMarked
+public class PlayerNameEntityEvent extends PlayerEvent implements Cancellable { +public class PlayerNameEntityEvent extends PlayerEvent implements Cancellable {
+ +
+ private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList();
+ +
+ private LivingEntity entity; + private LivingEntity entity;
+ private Component name; + private @Nullable Component name;
+ private boolean persistent; + private boolean persistent;
+ +
+ private boolean cancelled; + private boolean cancelled;
+ +
+ @ApiStatus.Internal + @ApiStatus.Internal
+ public PlayerNameEntityEvent(@NotNull Player player, @NotNull LivingEntity entity, @NotNull Component name, boolean persistent) { + public PlayerNameEntityEvent(final Player player, final LivingEntity entity, final Component name, final boolean persistent) {
+ super(player); + super(player);
+ this.entity = entity; + this.entity = entity;
+ this.name = name; + this.name = name;
@ -48,8 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the name + * @return the name
+ */ + */
+ @Nullable + public @Nullable Component getName() {
+ public Component getName() {
+ return this.name; + return this.name;
+ } + }
+ +
@ -58,7 +58,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param name the name + * @param name the name
+ */ + */
+ public void setName(@Nullable Component name) { + public void setName(final @Nullable Component name) {
+ this.name = name; + this.name = name;
+ } + }
+ +
@ -67,7 +67,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @return the entity + * @return the entity
+ */ + */
+ @NotNull
+ public LivingEntity getEntity() { + public LivingEntity getEntity() {
+ return this.entity; + return this.entity;
+ } + }
@ -77,7 +76,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param entity the entity + * @param entity the entity
+ */ + */
+ public void setEntity(@NotNull LivingEntity entity) { + public void setEntity(final LivingEntity entity) {
+ this.entity = entity; + this.entity = entity;
+ } + }
+ +
@ -95,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * + *
+ * @param persistent persistent + * @param persistent persistent
+ */ + */
+ public void setPersistent(boolean persistent) { + public void setPersistent(final boolean persistent) {
+ this.persistent = persistent; + this.persistent = persistent;
+ } + }
+ +
@ -105,17 +104,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ @Override + @Override
+ public void setCancelled(boolean cancel) { + public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel; + this.cancelled = cancel;
+ } + }
+ +
+ @NotNull
+ @Override + @Override
+ public HandlerList getHandlers() { + public HandlerList getHandlers() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }
+ +
+ @NotNull
+ public static HandlerList getHandlerList() { + public static HandlerList getHandlerList() {
+ return HANDLER_LIST; + return HANDLER_LIST;
+ } + }

View File

@ -476,7 +476,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.minecraft.world.entity.ai.goal.WrappedGoal; +import net.minecraft.world.entity.ai.goal.WrappedGoal;
+import org.bukkit.craftbukkit.entity.CraftMob; +import org.bukkit.craftbukkit.entity.CraftMob;
+import org.bukkit.entity.Mob; +import org.bukkit.entity.Mob;
+import org.jspecify.annotations.NullMarked;
+ +
+@NullMarked
+public class PaperMobGoals implements MobGoals { +public class PaperMobGoals implements MobGoals {
+ +
+ @Override + @Override