mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-04-20 02:08:15 +02:00
switch to JSpecify annotations
This commit is contained in:
@@ -46,10 +46,10 @@ index d0ae8a94db20281d3664d74718c65234eb2e5f83..bf6d13cc6b0566f4076383c8f170dc8c
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/RidableMoveEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/RidableMoveEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a037df01b07af9ffb98b67aca412c1d34fade03b
|
||||
index 0000000000000000000000000000000000000000..c31a656daa3df1ab87302d8f14110a828c920102
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/RidableMoveEvent.java
|
||||
@@ -0,0 +1,103 @@
|
||||
@@ -0,0 +1,100 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
@@ -59,11 +59,13 @@ index 0000000000000000000000000000000000000000..a037df01b07af9ffb98b67aca412c1d3
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Triggered when a ridable mob moves with a rider
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class RidableMoveEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean canceled;
|
||||
@@ -71,7 +73,8 @@ index 0000000000000000000000000000000000000000..a037df01b07af9ffb98b67aca412c1d3
|
||||
+ private Location from;
|
||||
+ private Location to;
|
||||
+
|
||||
+ public RidableMoveEvent(@NotNull Mob entity, @NotNull Player rider, @NotNull Location from, @NotNull Location to) {
|
||||
+ @ApiStatus.Internal
|
||||
+ public RidableMoveEvent(Mob entity, Player rider, Location from, Location to) {
|
||||
+ super(entity);
|
||||
+ this.rider = rider;
|
||||
+ this.from = from;
|
||||
@@ -79,12 +82,10 @@ index 0000000000000000000000000000000000000000..a037df01b07af9ffb98b67aca412c1d3
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public Mob getEntity() {
|
||||
+ return (Mob) entity;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public Player getRider() {
|
||||
+ return rider;
|
||||
+ }
|
||||
@@ -102,7 +103,6 @@ index 0000000000000000000000000000000000000000..a037df01b07af9ffb98b67aca412c1d3
|
||||
+ *
|
||||
+ * @return Location the entity moved from
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getFrom() {
|
||||
+ return from;
|
||||
+ }
|
||||
@@ -112,7 +112,7 @@ index 0000000000000000000000000000000000000000..a037df01b07af9ffb98b67aca412c1d3
|
||||
+ *
|
||||
+ * @param from New location to mark as the entity's previous location
|
||||
+ */
|
||||
+ public void setFrom(@NotNull Location from) {
|
||||
+ public void setFrom(Location from) {
|
||||
+ validateLocation(from);
|
||||
+ this.from = from;
|
||||
+ }
|
||||
@@ -122,7 +122,6 @@ index 0000000000000000000000000000000000000000..a037df01b07af9ffb98b67aca412c1d3
|
||||
+ *
|
||||
+ * @return Location the entity moved to
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getTo() {
|
||||
+ return to;
|
||||
+ }
|
||||
@@ -132,46 +131,47 @@ index 0000000000000000000000000000000000000000..a037df01b07af9ffb98b67aca412c1d3
|
||||
+ *
|
||||
+ * @param to New Location this entity will move to
|
||||
+ */
|
||||
+ public void setTo(@NotNull Location to) {
|
||||
+ public void setTo(Location to) {
|
||||
+ validateLocation(to);
|
||||
+ this.to = to;
|
||||
+ }
|
||||
+
|
||||
+ private void validateLocation(@NotNull Location loc) {
|
||||
+ private void validateLocation(Location loc) {
|
||||
+ Preconditions.checkArgument(loc != null, "Cannot use null location!");
|
||||
+ Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/RidableSpacebarEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/RidableSpacebarEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3d3a7d898e3278ce998d713dafbb4b354dad7fc7
|
||||
index 0000000000000000000000000000000000000000..02de629f066ef7d4898b3053efa957edeea16a3f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/RidableSpacebarEvent.java
|
||||
@@ -0,0 +1,37 @@
|
||||
@@ -0,0 +1,38 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public class RidableSpacebarEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ public RidableSpacebarEvent(@NotNull Entity entity) {
|
||||
+ @ApiStatus.Internal
|
||||
+ public RidableSpacebarEvent(Entity entity) {
|
||||
+ super(entity);
|
||||
+ }
|
||||
+
|
||||
@@ -186,12 +186,10 @@ index 0000000000000000000000000000000000000000..3d3a7d898e3278ce998d713dafbb4b35
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
|
||||
Reference in New Issue
Block a user