Skip to content

Commit

Permalink
#20230730.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonCaramel committed Jul 29, 2023
1 parent 7ac0bb6 commit 52e912f
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 40 deletions.
115 changes: 110 additions & 5 deletions patches/0006-Add-More-API-for-EntityDamageEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,117 @@ Date: Sun, 8 Aug 2021 03:05:54 +0900
Subject: [PATCH] Add More API for EntityDamageEvent


diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index c661eab343ae76488de701630424e2d589f44fc0..93f4b365d88d95a0f54a55eec4e631166ff84654 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -250,4 +250,9 @@ public interface UnsafeValues {
*/
void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey);
// Paper end
+
+ // Daydream start - Add More API for EntityDamageEvent
+ @Nullable java.util.Map<String, Object> getDamageSourceMetadata(@NotNull Object damageSource);
+ void setDamageSourceMetadata(@NotNull Object damageSource, @Nullable java.util.Map<String, Object> metadata);
+ // Daydream end - Add More API for EntityDamageEvent
}
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
index 461727dc7f06efb3550fc370e0db5bd04ba89711..913747f0b338a4217a7d9c90b6cb03f148abc196 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
@@ -13,16 +13,25 @@ import org.jetbrains.annotations.Nullable;
public class EntityDamageByBlockEvent extends EntityDamageEvent {
private final Block damager;

+ @Deprecated // Daydream - Add More API for EntityDamageEvent
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
super(damagee, cause, damage);
this.damager = damager;
}

+ @Deprecated // Daydream - Add More API for EntityDamageEvent
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
super(damagee, cause, modifiers, modifierFunctions);
this.damager = damager;
}

+ // Daydream start - Add More API for EntityDamageEvent
+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, @NotNull Object damageSource) {
+ super(damagee, cause, modifiers, modifierFunctions, damageSource);
+ this.damager = damager;
+ }
+ // Daydream end - Add More API for EntityDamageEvent
+
/**
* Returns the block that damaged the player.
*
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
index 7ce8f1a26c1b33dd0eb6e6435952fd73abf49879..59d21ad3afce7dfe49ebaec9c0493b49b6653b37 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
@@ -25,9 +25,15 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent {
}

private final boolean critical;
+ @Deprecated // Daydream - Add More API for EntityDamageEvent
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, boolean critical) {
+ // Daydream start - Add More API for EntityDamageEvent
+ this(damager, damagee, cause, modifiers, modifierFunctions, critical, null);
+ }
+ public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, boolean critical, @NotNull Object damageSource) {
+ // Daydream end - Add More API for EntityDamageEvent
// Paper end
- super(damagee, cause, modifiers, modifierFunctions);
+ super(damagee, cause, modifiers, modifierFunctions, damageSource); // Daydream - Add More API for EntityDamageEvent
this.damager = damager;
// Paper start - add critical damage API
this.critical = critical;
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
index 6241f31e7326954b2e704da46bf0115adbcf8671..e87581fae10cef3543b4daad5f319fc8adf0eb70 100644
index 6241f31e7326954b2e704da46bf0115adbcf8671..af580f6f2bff20c4cd7f2e45ec12a9f27ca3776d 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
@@ -44,6 +44,53 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
@@ -27,11 +27,31 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
private boolean cancelled;
private final DamageCause cause;

+ @Deprecated // Daydream - Add More API for EntityDamageEvent
public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
this(damagee, cause, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, ZERO)));
}

+ @Deprecated // Daydream - Add More API for EntityDamageEvent
public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
+ // Daydream start - Add More API for EntityDamageEvent
+ this(damagee, cause, modifiers, modifierFunctions, null);
+ }
+
+ private final Object damageSource;
+
+ /**
+ * Gets the NMS DamageSource.
+ *
+ * @return NMS DamageSource
+ */
+ @NotNull
+ public Object getDamageSource() {
+ return damageSource;
+ }
+
+ public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, @NotNull Object damageSource) {
+ // Daydream end - Add More API for EntityDamageEvent
super(damagee);
Preconditions.checkArgument(modifiers.containsKey(DamageModifier.BASE), "BASE DamageModifier missing");
Preconditions.checkArgument(!modifiers.containsKey(null), "Cannot have null DamageModifier");
@@ -42,6 +62,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
this.cause = cause;
this.modifiers = modifiers;
this.modifierFunctions = modifierFunctions;
+ this.damageSource = damageSource; // Daydream - Add More API for EntityDamageEvent
}

@Override
@@ -54,6 +75,53 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
cancelled = cancel;
}

+ // Daydream start - Add More API for EntityDamageEvent
Expand Down Expand Up @@ -59,6 +164,6 @@ index 6241f31e7326954b2e704da46bf0115adbcf8671..e87581fae10cef3543b4daad5f319fc8
+ }
+ // Daydream end - Add More API for EntityDamageEvent
+
@Override
public boolean isCancelled() {
return cancelled;
/**
* Gets the original damage for the specified modifier, as defined at this
* event's construction.
10 changes: 5 additions & 5 deletions patches/0017-Add-Network-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ index 0000000000000000000000000000000000000000..21fde661e12417b1af155cfcb747140b
+ public abstract MojangByteBuf writeBitSet(@NotNull BitSet bitSet);
+}
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index b04ca98728d2b313b3b4fa057ab81bbefa2c5d84..a6fde8c5295a63e64e026fe2231ca79806f150f6 100644
index 5f36d7d97b89cec8606bfdfc3518fcf2ccde4296..684b674d53a67e5c032ba5b5d6dec031303b840d 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -264,4 +264,15 @@ public interface UnsafeValues {
*/
void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey);
// Paper end
@@ -269,4 +269,15 @@ public interface UnsafeValues {
@Nullable java.util.Map<String, Object> getDamageSourceMetadata(@NotNull Object damageSource);
void setDamageSourceMetadata(@NotNull Object damageSource, @Nullable java.util.Map<String, Object> metadata);
// Daydream end - Add More API for EntityDamageEvent
+
+ // Daydream start
+ /**
Expand Down
4 changes: 2 additions & 2 deletions patches/0029-Add-ItemStack-utility-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Add ItemStack utility API


diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index a6fde8c5295a63e64e026fe2231ca79806f150f6..d94779b775fd0b7c93e5c71b7245339b587b3514 100644
index 684b674d53a67e5c032ba5b5d6dec031303b840d..70c50c7df6538692501446f85960ae43af0de4c6 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -275,4 +275,18 @@ public interface UnsafeValues {
@@ -280,4 +280,18 @@ public interface UnsafeValues {
@org.jetbrains.annotations.NotNull
moe.caramel.daydream.network.MojangByteBuf createByteBuf(@org.jetbrains.annotations.NotNull io.netty.buffer.ByteBuf buf);
// Daydream end
Expand Down
57 changes: 29 additions & 28 deletions patches/0031-Add-More-Explosion-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ index 0000000000000000000000000000000000000000..394159310ec31777c5c423f94405d9ec
+ boolean wasCancelled();
+}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index bff0c417bacda2bbe00fe10b7a4c989046448927..0b600ffe291e15abf0eb373d459031ae1c574a77 100644
index 4866b2f9646058228da74c7f460a1039c45c1dcb..4a8f5882e34ab07b6f628b3c31e239e936735bb6 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -2125,6 +2125,42 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
Expand Down Expand Up @@ -235,52 +235,53 @@ index d8b5362d0cdc3440efe30d619985018509b669e7..3284fd6a227507e0f8542fd52931201f

@Override
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
index 461727dc7f06efb3550fc370e0db5bd04ba89711..6859978cf02925e4f0ff43f3a0234f129783a745 100644
index 913747f0b338a4217a7d9c90b6cb03f148abc196..0dd425f7afab2359b3805095876583f3f04ff6a5 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java
@@ -19,7 +19,12 @@ public class EntityDamageByBlockEvent extends EntityDamageEvent {
@@ -26,8 +26,14 @@ public class EntityDamageByBlockEvent extends EntityDamageEvent {
}

public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
- super(damagee, cause, modifiers, modifierFunctions);
+ this(damager, damagee, cause, modifiers, modifierFunctions, null);
// Daydream start - Add More API for EntityDamageEvent
+ @Deprecated // Daydream - Add More API for EntityDamageEvent
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, @NotNull Object damageSource) {
- super(damagee, cause, modifiers, modifierFunctions, damageSource);
+ // Daydream start - Add More Explosion API
+ this(damager, damagee, cause, modifiers, modifierFunctions, damageSource, null);
+ }
+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, @org.jetbrains.annotations.Nullable moe.caramel.daydream.world.Explosion explosion) {
+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, @NotNull Object damageSource, @org.jetbrains.annotations.Nullable moe.caramel.daydream.world.Explosion explosion) {
+ // Daydream end - Add More Explosion API
+ super(damagee, cause, modifiers, modifierFunctions, explosion); // Daydream - Add More Explosion API
+ super(damagee, cause, modifiers, modifierFunctions, damageSource, explosion); // Daydream - Add More Explosion API
this.damager = damager;
}

// Daydream end - Add More API for EntityDamageEvent
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
index 7ce8f1a26c1b33dd0eb6e6435952fd73abf49879..eb82c88725be6198d465e9243c9208c66192dddb 100644
index 59d21ad3afce7dfe49ebaec9c0493b49b6653b37..0a2a5307896da7f26f7adeffabc1de2990b8e7ed 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java
@@ -26,8 +26,13 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent {

private final boolean critical;
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, boolean critical) {
@@ -33,7 +33,12 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent {
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, boolean critical, @NotNull Object damageSource) {
// Daydream end - Add More API for EntityDamageEvent
// Paper end
- super(damagee, cause, modifiers, modifierFunctions, damageSource); // Daydream - Add More API for EntityDamageEvent
+ // Daydream start - Add More Explosion API
+ this(damager, damagee, cause, modifiers, modifierFunctions, critical, null);
+ this(damager, damagee, cause, modifiers, modifierFunctions, critical, damageSource, null);
+ }
+ public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, boolean critical, @org.jetbrains.annotations.Nullable moe.caramel.daydream.world.Explosion explosion) {
+ public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, boolean critical, @NotNull Object damageSource, @org.jetbrains.annotations.Nullable moe.caramel.daydream.world.Explosion explosion) {
+ // Daydream end - Add More Explosion API
// Paper end
- super(damagee, cause, modifiers, modifierFunctions);
+ super(damagee, cause, modifiers, modifierFunctions, explosion); // Daydream - Add More Explosion API
+ super(damagee, cause, modifiers, modifierFunctions, damageSource, explosion); // Daydream - Add More API for EntityDamageEvent // Daydream - Add More Explosion API
this.damager = damager;
// Paper start - add critical damage API
this.critical = critical;
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
index e87581fae10cef3543b4daad5f319fc8adf0eb70..fc3d8950277e4473f13c0f15d78a419b13fbfade 100644
index af580f6f2bff20c4cd7f2e45ec12a9f27ca3776d..72ea34e8195f9762df4d23330cb12827c99de5e7 100644
--- a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
@@ -32,6 +32,23 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
}
@@ -52,6 +52,23 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {

public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, @NotNull Object damageSource) {
// Daydream end - Add More API for EntityDamageEvent
+ // Daydream start - Add More Explosion API
+ this(damagee, cause, modifiers, modifierFunctions, null);
+ this(damagee, cause, modifiers, modifierFunctions, damageSource, null);
+ }
+ private final moe.caramel.daydream.world.Explosion explosion;
+
Expand All @@ -294,19 +295,19 @@ index e87581fae10cef3543b4daad5f319fc8adf0eb70..fc3d8950277e4473f13c0f15d78a419b
+ return explosion;
+ }
+
+ public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, @org.jetbrains.annotations.Nullable moe.caramel.daydream.world.Explosion explosion) {
+ public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions, @NotNull Object damageSource, @org.jetbrains.annotations.Nullable moe.caramel.daydream.world.Explosion explosion) {
+ // Daydream end - Add More Explosion API
super(damagee);
Preconditions.checkArgument(modifiers.containsKey(DamageModifier.BASE), "BASE DamageModifier missing");
Preconditions.checkArgument(!modifiers.containsKey(null), "Cannot have null DamageModifier");
@@ -42,6 +59,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
this.cause = cause;
@@ -63,6 +80,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
this.modifiers = modifiers;
this.modifierFunctions = modifierFunctions;
this.damageSource = damageSource; // Daydream - Add More API for EntityDamageEvent
+ this.explosion = explosion;// Daydream - Add More Explosion API
}

// Daydream start - Add More API for EntityDamageEvent
@Override
diff --git a/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java b/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java
index 099efafa14c10910e4ed04abb1823f0c1a96b6a6..28ec92d62468d807538864135e3f1394beb446f9 100644
--- a/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java
Expand Down

0 comments on commit 52e912f

Please sign in to comment.