[ci skip] Cleanup events (#10202)

This commit is contained in:
Lulu13022002 2024-02-01 10:15:57 +01:00
parent d676979ea0
commit f7e469eb2e
187 changed files with 2415 additions and 2258 deletions

View file

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