-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrated pre-hard-fork patches 0002-added-ProjectileAllowCollideWithP…
…layerEvent.patch and 0004-added-ProjectileAllowCollideWithPlayerEvent.patch
- Loading branch information
1 parent
10824b0
commit 99c4d72
Showing
5 changed files
with
117 additions
and
139 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...src/main/java/net/gommehd/cheetah/event/entity/ProjectileAllowCollideWithPlayerEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package net.gommehd.cheetah.event.entity; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.entity.Projectile; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.entity.EntityEvent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Called when a projectile collides with a player | ||
* | ||
* @author TrainmasterHD | Jendrik E. | ||
* @since 18.10.2022 | ||
*/ | ||
public class ProjectileAllowCollideWithPlayerEvent extends EntityEvent { | ||
private static final HandlerList handlerList = new HandlerList(); | ||
private final Player collidedWith; | ||
private boolean allowCollide = false; | ||
|
||
public ProjectileAllowCollideWithPlayerEvent(@NotNull Projectile what, @NotNull Player collidedWith) { | ||
super(what); | ||
this.collidedWith = collidedWith; | ||
} | ||
|
||
/** | ||
* Get the projectile that collided | ||
* | ||
* @return the projectile that collided | ||
*/ | ||
@NotNull | ||
public Projectile getEntity() { | ||
return (Projectile) super.getEntity(); | ||
} | ||
|
||
/** | ||
* Get the entity the projectile collided with | ||
* | ||
* @return the entity collided with | ||
*/ | ||
@NotNull | ||
public Player getCollidedWith() { | ||
return collidedWith; | ||
} | ||
|
||
/** | ||
* Set if the projectile should be allowed to collide with the player | ||
* | ||
* @param allowCollide true if the projectile should be allowed to collide with the player, otherwise false | ||
*/ | ||
public void setAllowCollide(final boolean allowCollide) { | ||
this.allowCollide = allowCollide; | ||
} | ||
|
||
/** | ||
* If colliding with the player is allowed | ||
* | ||
* @return true if it is allowed, otherwise false | ||
*/ | ||
public boolean isAllowCollide() { | ||
return allowCollide; | ||
} | ||
|
||
@NotNull | ||
public static HandlerList getHandlerList() { | ||
return handlerList; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return handlerList; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ver/minecraft-patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- a/net/minecraft/world/entity/projectile/Projectile.java | ||
+++ b/net/minecraft/world/entity/projectile/Projectile.java | ||
@@ -409,7 +_,10 @@ | ||
if (owner instanceof net.minecraft.server.level.ServerPlayer && target instanceof net.minecraft.server.level.ServerPlayer) { | ||
org.bukkit.entity.Player collided = (org.bukkit.entity.Player) target.getBukkitEntity(); | ||
org.bukkit.entity.Player shooter = (org.bukkit.entity.Player) owner.getBukkitEntity(); | ||
- if (!shooter.canSee(collided)) { | ||
+ // Cheetah start - Added ProjectileAllowCollideWithPlayerEvent | ||
+ net.gommehd.cheetah.event.entity.ProjectileAllowCollideWithPlayerEvent allowCollideEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileAllowCollideWithPlayerEvent(this, target); | ||
+ if (!allowCollideEvent.isAllowCollide() && !shooter.canSee(collided)) { | ||
+ // Cheetah end | ||
return false; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...per-patches/files/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | ||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | ||
@@ -1479,7 +_,10 @@ | ||
com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided); | ||
|
||
if (projectile.getShooter() instanceof Player && collided instanceof Player) { | ||
- if (!((Player) projectile.getShooter()).canSee((Player) collided)) { | ||
+ // Cheetah start - Added ProjectileAllowCollideWithPlayerEvent | ||
+ net.gommehd.cheetah.event.entity.ProjectileAllowCollideWithPlayerEvent allowCollideEvent = callProjectileAllowCollideWithPlayerEvent(entity, position.getEntity()); | ||
+ if (!allowCollideEvent.isAllowCollide() && !((Player) projectile.getShooter()).canSee((Player) collided)) { | ||
+ // Cheetah end | ||
event.setCancelled(true); | ||
return event; | ||
} | ||
@@ -1489,6 +_,15 @@ | ||
return event; | ||
} | ||
// Paper end | ||
+ | ||
+ // Cheetah start - Added ProjectileAllowCollideWithPlayerEvent | ||
+ public static net.gommehd.cheetah.event.entity.ProjectileAllowCollideWithPlayerEvent callProjectileAllowCollideWithPlayerEvent(Entity entity, Entity player) { | ||
+ Projectile projectile = (Projectile) entity.getBukkitEntity(); | ||
+ net.gommehd.cheetah.event.entity.ProjectileAllowCollideWithPlayerEvent event = new net.gommehd.cheetah.event.entity.ProjectileAllowCollideWithPlayerEvent(projectile, (Player) player.getBukkitEntity()); | ||
+ event.callEvent(); | ||
+ return event; | ||
+ } | ||
+ // Cheetah end | ||
|
||
public static ProjectileLaunchEvent callProjectileLaunchEvent(Entity entity) { | ||
Projectile bukkitEntity = (Projectile) entity.getBukkitEntity(); |
85 changes: 0 additions & 85 deletions
85
patches/api/0002-added-ProjectileAllowCollideWithPlayerEvent.patch
This file was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
patches/server/0004-added-ProjectileAllowCollideWithPlayerEvent.patch
This file was deleted.
Oops, something went wrong.