13
0
geforkt von Mirrors/Paper

SPIGOT-4753: Add Pose API

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2019-04-27 10:26:35 +10:00
Ursprung bd15f6a4bc
Commit c118b02278
3 geänderte Dateien mit 93 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -571,4 +571,16 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
*/
@NotNull
BlockFace getFacing();
/**
* Gets the entity's current pose.
*
* <b>Note that the pose is only updated at the end of a tick, so may be
* inconsistent with other methods. eg {@link Player#isSneaking()} being
* true does not imply the current pose will be {@link Pose#SNEAKING}</b>
*
* @return current pose
*/
@NotNull
Pose getPose();
}

Datei anzeigen

@ -0,0 +1,37 @@
package org.bukkit.entity;
/**
* Represents an entity body pose.
*/
public enum Pose {
/**
* Entity is standing normally.
*
*/
STANDING,
/**
* Entity is gliding.
*/
FALL_FLYING,
/**
* Entity is sleeping.
*/
SLEEPING,
/**
* Entity is swimming.
*/
SWIMMING,
/**
* Entity is riptiding with a trident.
*/
SPIN_ATTACK,
/**
* Entity is sneaking.
*/
SNEAKING,
/**
* Entity is dead.
*/
DYING;
}

Datei anzeigen

@ -0,0 +1,44 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Pose;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity changes its pose.
*
* @see Entity#getPose()
*/
public class EntityPoseChangeEvent extends EntityEvent {
private static final HandlerList handlers = new HandlerList();
//
private final Pose pose;
public EntityPoseChangeEvent(@NotNull Entity who, @NotNull Pose pose) {
super(who);
this.pose = pose;
}
/**
* Gets the entity's new pose.
*
* @return the new pose
*/
@NotNull
public Pose getPose() {
return pose;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}