13
0
geforkt von Mirrors/Paper

Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5601)

Dieser Commit ist enthalten in:
Jake Potrebic 2021-05-09 13:50:09 -07:00
Ursprung bb125aaccf
Commit 4d8954ef25
11 geänderte Dateien mit 31 neuen und 118 gelöschten Zeilen

Datei anzeigen

@ -1580,7 +1580,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @NotNull java.util.Locale locale();
+ // Paper end
/**
* Gets the player's current locale.
* Gets the player's estimated ping in milliseconds.
*
@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* they wish.

Datei anzeigen

@ -1,49 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 16 Jan 2021 14:00:16 -0500
Subject: [PATCH] Make ProjectileHitEvent Cancellable
Allows cancelling things like detonating TNT from Fire Arrows
diff --git a/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java b/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java
+++ b/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java
@@ -0,0 +0,0 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Projectile;
+import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
/**
* Called when a projectile hits an object
*/
-public class ProjectileHitEvent extends EntityEvent {
+public class ProjectileHitEvent extends EntityEvent implements Cancellable { // Paper
private static final HandlerList handlers = new HandlerList();
private final Entity hitEntity;
private final Block hitBlock;
private final BlockFace hitFace;
+ // Paper start - make cancellable
+ private boolean canceled;
+ /**
+ * @return If the arrow activating a block should be cancelled
+ */
+ public boolean isCancelled() {
+ return canceled;
+ }
+
+ /**
+ * Whether or not to cancel any behavior that would occur from the arrow hitting the block
+ * @param cancel true if you wish to cancel this event
+ */
+ public void setCancelled(boolean cancel) {
+ canceled = cancel;
+ }
+ // Paper end
public ProjectileHitEvent(@NotNull final Projectile projectile) {
this(projectile, null, null);

Datei anzeigen

@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
+
if (object != null && !flag) {
this.a((MovingObjectPosition) object);
this.preOnHit((MovingObjectPosition) object); // CraftBukkit - projectile hit event
this.impulse = true;
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java b/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
+
+ if (movingobjectposition != null && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { // Paper - add null check in case cancelled
this.a(movingobjectposition);
this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event
// CraftBukkit start - Fire ProjectileHitEvent
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/EntityProjectile.java
@ -81,7 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ if (movingobjectposition != null) {
+ // Paper end
this.a(movingobjectposition);
this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event
+ } // Paper
}

Datei anzeigen

@ -2249,8 +2249,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end
@Override
public String getLocale() {
return getHandle().locale;
public int getPing() {
return getHandle().ping;
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getInventory().setItemInMainHand(hand);
}

Datei anzeigen

@ -50,4 +50,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (!entity.world.paperConfig.disableRelativeProjectileVelocity) this.setMot(this.getMot().add(vec3d.x, entity.isOnGround() ? 0.0D : vec3d.y, vec3d.z)); // Paper - allow disabling relative velocity
}
protected void a(MovingObjectPosition movingobjectposition) {
// CraftBukkit start - call projectile hit event

Datei anzeigen

@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper end
@Override
public String getLocale() {
- return getHandle().locale;

Datei anzeigen

@ -1,58 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 16 Jan 2021 14:30:12 -0500
Subject: [PATCH] Make ProjectileHitEvent Cancellable
Allows cancelling things like detonating TNT from Fire Arrows
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java b/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
@@ -0,0 +0,0 @@ public abstract class EntityFireball extends IProjectile {
// CraftBukkit start - Fire ProjectileHitEvent
if (this.dead) {
- CraftEventFactory.callProjectileHitEvent(this, movingobjectposition);
+ if (!CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) return; // Paper - this is an undesired duplicate event, but make cancellable
}
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/world/entity/projectile/IProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/IProjectile.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/IProjectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/IProjectile.java
@@ -0,0 +0,0 @@ public abstract class IProjectile extends Entity {
}
protected void a(MovingObjectPosition movingobjectposition) {
- org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition)) return; // CraftBukkit - Call event // Paper - make cancellable
MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType();
if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -0,0 +0,0 @@ public class CraftEventFactory {
return event;
}
- public static void callProjectileHitEvent(Entity entity, MovingObjectPosition position) {
+ public static boolean callProjectileHitEvent(Entity entity, MovingObjectPosition position) { // Paper - make cancellable
if (position.getType() == MovingObjectPosition.EnumMovingObjectType.MISS) {
- return;
+ return false; // Paper - make cancellable
}
Block hitBlock = null;
@@ -0,0 +0,0 @@ public class CraftEventFactory {
}
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), hitEntity, hitBlock, hitFace);
- entity.world.getServer().getPluginManager().callEvent(event);
+ return event.callEvent(); // Paper
}
public static ExpBottleEvent callExpBottleEvent(Entity entity, int exp) {

Datei anzeigen

@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 16 Jan 2021 14:30:12 -0500
Subject: [PATCH] Respect ProjectileHitEvent cancel where missing
The duplicate ProjectileHitEvent in EntityFireball was not cancelled
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java b/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/EntityFireball.java
@@ -0,0 +0,0 @@ public abstract class EntityFireball extends IProjectile {
// CraftBukkit start - Fire ProjectileHitEvent
if (this.dead) {
- CraftEventFactory.callProjectileHitEvent(this, movingobjectposition);
+ if (CraftEventFactory.callProjectileHitEvent(this, movingobjectposition).isCancelled()) return; // Paper - this is an undesired duplicate event, but make cancellable
}
// CraftBukkit end
}

@ -1 +1 @@
Subproject commit 5eece9f8580658aff45ba851b79059c0e16b921a
Subproject commit b9ef9229d4c10b4068d9fbdce8845cfd4a9f8fc5

@ -1 +1 @@
Subproject commit 7ea8b96b4a9a168723d1eb109c5abc6fe91b78d6
Subproject commit d28f36c68405c1815857139e613a1098f4168029

@ -1 +1 @@
Subproject commit 4225eac084af31c8b9dca9eed3f7d146f3bc3625
Subproject commit bd6b56689828d8bb08f6b5f46935162f9cc43d87