本文整理汇总了Java中org.bukkit.event.player.PlayerMoveEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerMoveEvent类的具体用法?Java PlayerMoveEvent怎么用?Java PlayerMoveEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerMoveEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerMoveEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if (!event.getFrom().getWorld().getName().equalsIgnoreCase("cave")) {
return;
}
if (event.getTo().getBlock().getLightFromSky() == 0) {
return;
}
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
return;
}
event.getPlayer().setHealth(0.0D);
TextComponent message = new TextComponent("DU VOLLIDIOT! SONNE IST GEFÄHRLICH! HOFFE DU LERNST DARAUS");
message.setColor(ChatColor.DARK_RED);
event.getPlayer().spigot().sendMessage(message);
}
示例3: call
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@Override
public void call(Event event) {
final Player player = profile.getPlayer();
if (event instanceof PlayerMoveEvent) {
if ((player.isSprinting() || player.isBlocking() || player.isConversing()) && player.isSneaking()) {
callback(true);
return;
}
callback(false);
} else if (event instanceof AsyncPlayerChatEvent) {
if ((player.isBlocking() || player.isSprinting() || player.isSneaking())) {
callback(true);
return;
}
callback(false);
}
}
示例4: 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());
}
}
示例5: 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());
}
}
}
示例6: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(this.getAPI().getGameManager().isAlive(event.getPlayer())) {
if(event.getTo().getY() <= Integer.valueOf((String) this.getGameMap().fetchSetting("floorLevel"))) {
this.getAPI().getGameManager().setAlive(event.getPlayer(), false);
} else {
final Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
if(block.getType() != Material.AIR) {
if(!pendingDeletion.contains(block)) {
pendingDeletion.add(block);
new BukkitRunnable() {
public void run() {
if(pendingDeletion.contains(block)) {
block.setType(Material.AIR);
pendingDeletion.remove(block);
}
}
}.runTaskLater(this.getAPI().getPlugin(), 3L);
}
}
}
}
}
示例7: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(this.getAPI().getGameManager().isAlive(event.getPlayer())) {
if(event.getTo().getBlock().getType() == Material.STONE_PLATE) {
event.getTo().getBlock().setType(Material.AIR);
event.getTo().getWorld().spigot().playEffect(event.getTo(), Effect.FLAME,
0, 0, 1, 1, 1, 0, 5, 15);
event.getTo().getWorld().spigot().playEffect(event.getTo(), Effect.EXPLOSION,
0, 0, 1, 1, 1, 0, 6, 15);
event.getTo().getWorld().playSound(event.getTo(), Sound.ENTITY_GENERIC_EXPLODE, 5f, 1f);
event.getPlayer().teleport(startPosition);
return;
}
if(this.getSidebar().getSidebar().getScore(event.getPlayer().getName()).getScore() >= -1) {
this.endGame();
}
}
}
示例8: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(!event.getTo().getWorld().getName().equalsIgnoreCase(event.getFrom().getWorld().getName())) return;
if(event.getTo().getWorld().getName().equalsIgnoreCase("world")) return;
ArcadiaAPI api = Arcadia.getPlugin(Arcadia.class).getAPI();
if(!api.getGameManager().isAlive(event.getPlayer())) {
double yLevel = Utils.parseLocation((String) api.getGameManager().getCurrentGame()
.getGameMap().fetchSetting("spectatorLocation")).getY();
double yDif = Math.abs(event.getTo().getY() - yLevel);
Location newLocation = event.getTo();
newLocation.setY(yLevel);
if(yDif >= 0.5) event.setTo(newLocation);
}
if(api.getMapRegistry().getMapBounds() != null) {
if(!api.getMapRegistry().getMapBounds().contains(event.getTo())) {
if(api.getGameManager().isAlive(event.getPlayer())
&& api.getGameManager().getCurrentGame().killOnMapExit) {
api.getGameManager().setAlive(event.getPlayer(), false);
} else {
event.setTo(event.getFrom());
}
}
}
}
示例9: 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 (p.hasPermission("ironelevators.use") && 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);
}
}
}
示例10: onPlayerMoveEvent
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent e) {
for (Entity en : e.getPlayer().getWorld().getEntities()) {
if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().distance(e.getTo()) <= 1) {
Location l = en.getLocation();
//e.getPlayer().sendMessage(getPlayerDirection(e.getPlayer()));
if (getPlayerDirection(e.getPlayer()).equals("north")) {
l.add(-1.2, 0, 0);
}
else if (getPlayerDirection(e.getPlayer()).equals("south")) {
l.add(1.2, 0, 0);
}
else if (getPlayerDirection(e.getPlayer()).equals("east")) {
l.add(0, 0, -1.2);
}
else if (getPlayerDirection(e.getPlayer()).equals("west")) {
l.add(0, 0, 1.2);
}
else {
l = e.getPlayer().getLocation();
}
l.setDirection(e.getPlayer().getLocation().getDirection());
e.setTo(l);
}
}
}
示例11: onPlayerMoveEvent
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent e) {
/*if (e.getPlayer().getTargetBlock((HashSet<Byte>) null, 100).getType() != Material.AIR) {
e.getPlayer().teleport(e.getPlayer().getLocation().add(0, 1, 0));
}*/
/*for (Entity en : e.getPlayer().getWorld().getEntities()) {
for (int i = 0; i < en.getScoreboardTags().toArray().length; i++) {
String tag = en.getScoreboardTags().toString().replace('[', ' ').replace(']', ' ').trim().split(",")[i];
//System.out.println(tag);
if (tag.startsWith("p:")) {
//System.out.println(tag.substring(2, tag.length()));
if (tag.substring(2, tag.length()).equalsIgnoreCase(e.getPlayer().getName())) {
en.teleport(e.getPlayer().getLocation().add(0, -0.2, 0));
e.setFrom(en.getLocation());
}
}
}
}*/
}
示例12: onMove
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) {
if(!isSpawned()) return;
MatchPlayer player = match.getPlayer(event.getPlayer());
if(player != null) {
CooldownPlayerFacet cooler = player.facet(CooldownPlayerFacet.class);
if(player.canInteract() &&
cooler.isNotCooling(this) &&
Capsule.fromEndpointsAndRadius(event.getFrom().position(),
event.getTo().position(),
0.5)
.intersects(Sphere.fromCircumscribedCuboid(entity.get().getBoundingBox())) &&
data.pickup().query(player).isAllowed()) {
cooler.coolFor(this, data.cooldown());
despawn(true);
player.facet(KitPlayerFacet.class).applyKit(data.kit(), false);
}
}
}
示例13: 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)
);
}
}
示例14: resetPosition
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
/**
* Modify the to location of the given event to prevent the movement and
* move the player so they are standing on the center of the block at the
* from location.
*/
private static void resetPosition(final PlayerMoveEvent event) {
Location newLoc;
double yValue = event.getFrom().getY();
if(yValue <= 0 || event instanceof PlayerTeleportEvent) {
newLoc = event.getFrom();
} else {
newLoc = BlockUtils.center(event.getFrom()).subtract(new Vector(0, 0.5, 0));
if(newLoc.getBlock() != null) {
switch(newLoc.getBlock().getType()) {
case STEP:
case WOOD_STEP:
newLoc.add(new Vector(0, 0.5, 0));
break;
default: break;
}
}
}
newLoc.setPitch(event.getTo().getPitch());
newLoc.setYaw(event.getTo().getYaw());
event.setCancelled(false);
event.setTo(newLoc);
}
示例15: onMove
import org.bukkit.event.player.PlayerMoveEvent; //导入依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent e) {
KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
double xfrom = e.getFrom().getX();
double yfrom = e.getFrom().getY();
double zfrom = e.getFrom().getZ();
double xto = e.getTo().getX();
double yto = e.getTo().getY();
double zto = e.getTo().getZ();
if (!(xfrom == xto && yfrom == yto && zfrom == zto)) {
if (p.hasAction()) {
if (p.getAction() instanceof TeleportationAction) {
((TeleportationAction) p.getAction()).notifyPlayerOnMovement();
} else if(p.getAction() instanceof LogoutAction) {
p.getAction().cancel();
p.sendMessage(Messages.getInstance().getPrefix() + "Je bewoog! Je uitlog actie is geannuleerd!");
}
}
}
}