geforkt von Mirrors/Paper
Make EntityUnleashEvent cancellable (#4993)
Dieser Commit ist enthalten in:
Ursprung
037884fc65
Commit
85195961ea
49
patches/api/Make-EntityUnleashEvent-cancellable.patch
Normale Datei
49
patches/api/Make-EntityUnleashEvent-cancellable.patch
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
Date: Sun, 3 Jan 2021 21:25:39 -0800
|
||||||
|
Subject: [PATCH] Make EntityUnleashEvent cancellable
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java b/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java
|
||||||
|
+++ b/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java
|
||||||
|
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called immediately prior to an entity being unleashed.
|
||||||
|
+ * <p>
|
||||||
|
+ * Cancelling this event when either:
|
||||||
|
+ * <ul>
|
||||||
|
+ * <li>the leashed entity dies,</li>
|
||||||
|
+ * <li>the entity changes dimension, or</li>
|
||||||
|
+ * <li>the client has disconnected the leash</li>
|
||||||
|
+ * </ul>
|
||||||
|
+ * will have no effect.
|
||||||
|
*/
|
||||||
|
-public class EntityUnleashEvent extends EntityEvent {
|
||||||
|
+public class EntityUnleashEvent extends EntityEvent implements org.bukkit.event.Cancellable { // Paper
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private final UnleashReason reason;
|
||||||
|
private boolean dropLeash; // Paper
|
||||||
|
+ private boolean cancelled; // Paper
|
||||||
|
|
||||||
|
// Paper start - drop leash variable
|
||||||
|
@Deprecated
|
||||||
|
@@ -0,0 +0,0 @@ public class EntityUnleashEvent extends EntityEvent {
|
||||||
|
public void setDropLeash(boolean dropLeash) {
|
||||||
|
this.dropLeash = dropLeash;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCancelled() {
|
||||||
|
+ return cancelled;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setCancelled(boolean cancel) {
|
||||||
|
+ this.cancelled = cancel;
|
||||||
|
+ }
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
@NotNull
|
41
patches/server/Make-EntityUnleashEvent-cancellable.patch
Normale Datei
41
patches/server/Make-EntityUnleashEvent-cancellable.patch
Normale Datei
@ -0,0 +1,41 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
Date: Sun, 3 Jan 2021 21:25:31 -0800
|
||||||
|
Subject: [PATCH] Make EntityUnleashEvent cancellable
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity {
|
||||||
|
if (flag1 && this.isLeashed()) {
|
||||||
|
// Paper start - drop leash variable
|
||||||
|
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, true);
|
||||||
|
- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||||
|
+ if (!event.callEvent()) { return flag1; }
|
||||||
|
this.dropLeash(true, event.isDropLeash());
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class PathfinderMob extends Mob {
|
||||||
|
if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
|
||||||
|
// Paper start - drop leash variable
|
||||||
|
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||||
|
- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||||
|
+ if (!event.callEvent()) { return; }
|
||||||
|
this.dropLeash(true, event.isDropLeash());
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class PathfinderMob extends Mob {
|
||||||
|
if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
|
||||||
|
// Paper start - drop leash variable
|
||||||
|
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||||
|
- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||||
|
+ if (!event.callEvent()) return;
|
||||||
|
this.dropLeash(true, event.isDropLeash());
|
||||||
|
// Paper end
|
||||||
|
this.goalSelector.disableControlFlag(Goal.Flag.MOVE);
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren