下面列出了怎么用org.bukkit.event.player.PlayerOnGroundEvent的API类实例代码及写法,或者点击链接到github查看源代码。
/** Called when the player touches or leaves the ground */
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerOnGroundChanged(final PlayerOnGroundEvent event) {
MatchPlayer player = match.getParticipant(event.getPlayer());
if (player == null) return;
FallState fall = this.falls.get(player);
if (fall != null) {
if (event.getOnGround()) {
// Falling player landed on the ground, cancel the fall if they are still there after
// MAX_ON_GROUND_TIME
fall.onGroundTick = match.getTick().tick;
fall.groundTouchCount++;
this.scheduleCheckFallTimeout(fall, FallState.MAX_ON_GROUND_TICKS + 1);
} else {
// Falling player left the ground, check if it was caused by the attack
this.playerBecameUnsupported(fall);
}
}
}
/**
* Called when the player touches or leaves the ground
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerOnGroundChanged(final PlayerOnGroundEvent event) {
MatchPlayer player = match.getParticipant(event.getPlayer());
if(player == null) return;
FallState fall = this.falls.get(player);
if(fall != null) {
if(event.getOnGround()) {
// Falling player landed on the ground, cancel the fall if they are still there after MAX_ON_GROUND_TIME
fall.onGroundTick = match.getClock().now().tick;
fall.groundTouchCount++;
this.scheduleCheckFallTimeout(fall, FallState.MAX_ON_GROUND_TICKS + 1);
} else {
// Falling player left the ground, check if it was caused by the attack
this.playerBecameUnsupported(fall);
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerOnGroundChanged(final PlayerOnGroundEvent event) {
MatchPlayer player = match.getParticipant(event.getPlayer());
if (player == null) return;
Block block = this.lastBlockBrokenUnderPlayer(player);
if (block != null) {
SpleefInfo info = brokenBlocks.get(block);
if (match.getTick().tick - info.getTime().tick <= MAX_SPLEEF_TICKS) {
match.callEvent(new PlayerSpleefEvent(player, block, info));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerOnGroundChanged(final PlayerOnGroundEvent event) {
MatchPlayer player = match.getParticipant(event.getPlayer());
if(player == null) return;
Block block = this.lastBlockBrokenUnderPlayer(player);
if(block != null) {
SpleefInfo info = brokenBlocks.get(block);
if(match.getClock().now().tick - info.getTime().tick <= MAX_SPLEEF_TICKS) {
match.callEvent(new PlayerSpleefEvent(player, block, info));
}
}
}
@EventHandler
public void onPlayerGround(PlayerOnGroundEvent event) {
if (!enabled || rechargeBeforeLanding) return;
UUID id = event.getPlayer().getUniqueId();
if (!players.contains(id) || landed.contains(id)) return;
if (event.getOnGround()) landed.add(id);
}