-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to get cause in EntityTeleportEvent (#5767) #5861
Changes from all commits
b97705a
232294f
3d667cf
cff6f97
cb1334c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,18 @@ | |
class EntityTeleportEvent extends EntityEvent implements Cancellable{ | ||
use CancellableTrait; | ||
|
||
public const CAUSE_PLUGIN = 0; | ||
public const CAUSE_PROJECTILE = 1; | ||
public const CAUSE_WORLD = 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea what this is supposed to mean. |
||
public const CAUSE_RESPAWN = 3; | ||
public const CAUSE_CHORUS_FRUIT = 4; | ||
public const CAUSE_COMMAND = 5; | ||
|
||
public function __construct( | ||
Entity $entity, | ||
private Position $from, | ||
private Position $to | ||
private Position $to, | ||
private int $cause | ||
){ | ||
$this->entity = $entity; | ||
} | ||
|
@@ -51,6 +59,14 @@ public function getTo() : Position{ | |
return $this->to; | ||
} | ||
|
||
public function getCause() : int{ | ||
return $this->cause; | ||
} | ||
|
||
public function setCause(int $cause) : void{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it can be used for plugin conflicts 🤷♂️ |
||
$this->cause = $cause; | ||
} | ||
|
||
public function setTo(Position $to) : void{ | ||
Utils::checkVector3NotInfOrNaN($to); | ||
$this->to = $to; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CAUSE_PROJECTILE doesn't tell us what type of projectile was used. Maybe CAUSE_ENDER_PEARL would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, I think the cause should be a string so plugins can specify their custom causes like "morepearls:snowball". That way we can be specific while also allowing customization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah agree, with ints its really easy to mess up if someone was to create custom one