org.bukkit.event.player.PlayerOnGroundEvent Java Examples

The following examples show how to use org.bukkit.event.player.PlayerOnGroundEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FallTracker.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
/** 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);
    }
  }
}
 
Example #2
Source File: FallTracker.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example #3
Source File: SpleefTracker.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@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));
    }
  }
}
 
Example #4
Source File: SpleefTracker.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@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));
        }
    }
}
 
Example #5
Source File: DoubleJumpKit.java    From CardinalPGM with MIT License 5 votes vote down vote up
@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);
}