本文整理汇总了Java中org.bukkit.event.player.PlayerMoveEvent.getPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerMoveEvent.getPlayer方法的具体用法?Java PlayerMoveEvent.getPlayer怎么用?Java PlayerMoveEvent.getPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerMoveEvent
的用法示例。
在下文中一共展示了PlayerMoveEvent.getPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
final Player player = event.getPlayer();
final Material from = event.getFrom().getBlock().getRelative(BlockFace.DOWN).getType();
final Behaviour behaviour = Profile.getProfile(player.getUniqueId()).getBehaviour();
final long current = System.currentTimeMillis();
if (player.isSprinting()) {
behaviour.getMotion().setLastSprint(current);
}
if (player.isFlying()) {
behaviour.getMotion().setLastFly(current);
}
if (from.isSolid() || behaviour.getMotion().getLastY() == -1.0 || !behaviour.getMotion().isDescending()) {
behaviour.getMotion().setLastY(player.getLocation().getY());
}
if (!behaviour.isOnGround()) {
behaviour.getMotion().setLastYDiff(event.getTo().getY() - event.getFrom().getY());
}
}
示例2: move
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void move(final PlayerMoveEvent event) {
Player player = event.getPlayer();
Location to = event.getTo();
Location from = event.getFrom();
Block toBlock = to.getBlock();
Block fromBlock = from.getBlock();
handleLook(player, to);
if(PORTAL_MATERIALS.contains(toBlock.getType()) && !PORTAL_MATERIALS.contains(fromBlock.getType())) {
nearestSign(event.getTo()).ifPresent(
sign -> sign.connector().teleport(player)
);
}
}
示例3: upElevator
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void upElevator(PlayerMoveEvent e) {
Player p = e.getPlayer();
Block b = e.getTo().getBlock().getRelative(BlockFace.DOWN);
if (e.getFrom().getY() < e.getTo().getY() && b.getType() == elevatorMaterial) { b = b.getRelative(BlockFace.UP, minElevation);
int i = maxElevation;
while (i > 0 && !(b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent())) {
i--;
b = b.getRelative(BlockFace.UP);
}
if (i > 0) {
Location l = p.getLocation();
l.setY(l.getY() + maxElevation + 3 - i);
p.teleport(l);
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
}
}
}
示例4: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerMove(final PlayerMoveEvent event) {
final Location from = event.getFrom();
final Location to = event.getTo();
if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
return;
}
if (!isWithinBorder(to) && isWithinBorder(from)) {
final Player player = event.getPlayer();
player.sendMessage(ChatColor.RED + "You cannot go past the border.");
event.setTo(from);
final Entity vehicle = player.getVehicle();
if (vehicle != null) {
vehicle.eject();
vehicle.teleport(from);
vehicle.setPassenger((Entity)player);
}
}
}
示例5: onPlayerFall
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPlayerFall(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player) || player.isFlying()
|| player.getVehicle() != null) {
return;
}
PlayerWrapper playerWrapper = InventoryManager.get(player);
boolean endFalling = false;
if (!player.isOnGround()) {
if (playerIsSneakOnLadder(player) || isPlayerCanFall(player)) {
playerWrapper.onFall();
} else if (!player.isGliding()) {
endFalling = true;
}
} else if (playerWrapper.isFalling()) {
endFalling = true;
}
if (endFalling) {
playerWrapper.setFalling(false);
}
}
示例6: onMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent event) {
Game game = Chambers.getInstance().getGameManager().getGame();
if (game.getStatus() != GameStatus.INGAME) {
return;
}
Location to = event.getTo();
Location from = event.getFrom();
if (to.getBlockX() != from.getBlockX() || to.getBlockZ() != from.getBlockZ()) {
Player player = event.getPlayer();
Team toTeam = Chambers.getInstance().getClaimManager().getTeamAt(to);
Team fromTeam = Chambers.getInstance().getClaimManager().getTeamAt(from);
if (toTeam != fromTeam) {
Bukkit.getPluginManager().callEvent(new PlayerEnterClaimEvent(player, toTeam.getClaim()));
Bukkit.getPluginManager().callEvent(new PlayerLeaveClaimEvent(player, fromTeam.getClaim()));
if (toTeam.getType() == TeamType.KOTH_CAP || fromTeam.getType() == TeamType.KOTH_CAP) {
return;
}
player.sendMessage(ChatColor.YELLOW + "Now leaving: " + fromTeam.getFormattedName());
player.sendMessage(ChatColor.YELLOW + "Now entering: " + toTeam.getFormattedName());
}
}
}
示例7: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
Player p = event.getPlayer();
IPet pet = EchoPet.getManager().getPet(p);
if(pet != null && pet.isSpawned()){
if (!WorldUtil.allowRegion(event.getTo())) {
pet.removePet(true, true);
Lang.sendTo(p, Lang.ENTER_PET_DISABLED_REGION.toString());
}
}
}
示例8: onMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent event){
Player player = event.getPlayer();
for (Map.Entry<CustomEnchantment, Integer> entry : getValidEnchantments(getItems(player)).entrySet()) {
entry.getKey().passiveEffect(player, event);
}
}
示例9: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
if (p.isInsideVehicle() && p.getVehicle() instanceof ArmorStand){
e.setCancelled(true);
}
}
示例10: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event)
{
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
if (getRemaining(uuid) > 0L)
{
Location from = (Location)this.startedLocations.get(uuid);
checkMovement(player, from, event.getTo());
}
}
示例11: handleMovementHigh
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
private final void handleMovementHigh(final PlayerMoveEvent event) {
Player player = event.getPlayer();
EntityLocation originalFrom = event.getEntityFrom();
EntityLocation originalTo = event.getEntityTo();
EntityLocation oldTo = this.lastToLocation.get(player);
if(oldTo != null && !oldTo.equals(originalFrom)) {
// If this movement does not start where the last known movement ended,
// we have to make up the missing movement. We do that by (potentially) firing
// two coarse events for this one event, a "fake" one for the missing movement
// and a "real" one for the current movement.
// First, modify this event to look like the missing event, and fire
// a coarse event that wraps it.
event.setFrom(oldTo);
event.setTo(originalFrom);
this.updateLastToLocation(event);
if(this.callCoarsePlayerMove(event)) {
// If the fake coarse event was cancelled, we don't need to fire
// the real one, so just return. Note that the wrapped event won't
// actually be cancelled, rather its to location will be modified
// to return the player to the oldTo location. Also note that if
// the original event was already cancelled before the coarse event
// fired, then we will never get here, and both the fake and real
// events will go through.
this.updateLastToLocation(event);
return;
}
// Restore the event to its real state
event.setFrom(originalFrom);
event.setTo(originalTo);
}
this.updateLastToLocation(event);
if(this.callCoarsePlayerMove(event)) {
this.updateLastToLocation(event);
}
}
示例12: callCoarsePlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
/**
* Fire a CoarsePlayerMoveEvent that wraps the given event, only if it crosses
* a block boundary, or the PoseFlags change.
* @param event The movement event to potentially wrap
* @return True if the original event was not cancelled, and a coarse event was fired,
* and that coarse event was cancelled. In this case, the wrapped event won't
* actually be cancelled, but callers should treat it like it is.
*/
private boolean callCoarsePlayerMove(final PlayerMoveEvent event) {
// Don't fire coarse events for teleports that are not "in-game"
// e.g. /jumpto command
if(event instanceof PlayerTeleportEvent) {
PlayerTeleportEvent teleportEvent = (PlayerTeleportEvent) event;
if(teleportEvent.getCause() != TeleportCause.ENDER_PEARL &&
teleportEvent.getCause() != TeleportCause.UNKNOWN) {
return false;
}
}
// If the movement does not cross a block boundary, and no PoseFlags changed, we don't care about it
final EntityLocation from = event.getEntityFrom();
final EntityLocation to = event.getEntityTo();
if(from.position().coarseEquals(to.position()) && from.poseFlags().equals(to.poseFlags())) {
return false;
}
// Remember whether the original event was already cancelled
boolean wasCancelled = event.isCancelled();
CoarsePlayerMoveEvent generalEvent = new CoarsePlayerMoveEvent(event, event.getPlayer(), from, to);
this.eventBus.callEvent(generalEvent);
if(!wasCancelled && generalEvent.isCancelled()) {
// When a coarse event is cancelled, we have our own logic for resetting the
// player's position, so we un-cancel the event and instead modify its
// to location to put the player where we want them.
resetPosition(event);
return true;
} else {
return false;
}
}
示例13: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) {
Location from = event.getFrom();
Location to = event.getTo();
if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
return;
}
Player player = event.getPlayer();
if (getRemaining(player) > 0L) {
player.sendMessage(ChatColor.RED + "You moved a block, " + getDisplayName() + ChatColor.RED + " timer cancelled.");
clearCooldown(player);
}
}
示例14: WaterPower
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void WaterPower(PlayerMoveEvent event) {
Player p = event.getPlayer();
if (Kit.getKit(p).getName().equalsIgnoreCase("poseidon")) {
Material m = p.getLocation().getBlock().getType();
if (m == Material.STATIONARY_WATER || m == Material.WATER) {
p.addPotionEffect(new PotionEffect(
PotionEffectType.INCREASE_DAMAGE, 200, 1));
p.setRemainingAir(300);
}
}
}
示例15: onMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!(player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)) {
if (BlockListener.inMineLocation(player.getLocation())) {
if (player.getGameMode() != GameMode.SURVIVAL) {
player.setGameMode(GameMode.SURVIVAL);
}
} else {
if (player.getGameMode() != GameMode.ADVENTURE) {
player.setGameMode(GameMode.ADVENTURE);
}
}
}
}