本文整理汇总了Java中org.bukkit.event.player.PlayerMoveEvent.setTo方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerMoveEvent.setTo方法的具体用法?Java PlayerMoveEvent.setTo怎么用?Java PlayerMoveEvent.setTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerMoveEvent
的用法示例。
在下文中一共展示了PlayerMoveEvent.setTo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.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());
}
}
}
}
示例3: 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);
}
}
}
示例4: 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);
}
示例5: onPlayerMoveWhenNotLoaded
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onPlayerMoveWhenNotLoaded(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.isAllowedWorld(player.getWorld()) || InventoryManager.playerIsLoaded(player)) {
return;
}
if (PlayerLoader.isPreparedPlayer(player)) {
PlayerLoader.removePlayer(player);
player.kickPlayer(RPGInventory.getLanguage().getMessage("error.rp.denied"));
event.setCancelled(true);
} else {
Location toLocation = event.getTo();
Location newLocation = event.getFrom().clone();
//noinspection deprecation
if (!player.isOnGround()) {
newLocation.setY(toLocation.getY());
}
newLocation.setPitch(toLocation.getPitch());
newLocation.setYaw(toLocation.getYaw());
event.setTo(newLocation);
}
}
示例6: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(this.getAPI().getGameManager().isAlive(event.getPlayer())) {
if(this.getSidebar().getSidebar().getScore(event.getPlayer().getName()).getScore() >= -1) {
this.endGame();
}
if(!this.redLight) return;
if(event.getTo().distance(this.startPosition) <= 3) return;
if(event.getFrom().distance(event.getTo()) > 0.1D) {
event.setTo(this.startPosition);
}
}
}
示例7: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(this.getAPI().getGameManager().isAlive(event.getPlayer())) {
if(this.getSidebar().getSidebar().getScore(event.getPlayer().getName()).getScore() >= -1) {
this.endGame();
}
if(event.getTo().getY() <= Integer.valueOf((String) this.getGameMap().fetchSetting("floorLevel"))) {
event.setTo(startPosition);
}
}
}
示例8: 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.5 && en.getLocation().getY() < e.getTo().getY()) {
if (e.getTo().getY() - en.getLocation().getY() >= 1.2) {
if (getElevatorUp(en, e.getPlayer()) != null) {e.setTo(getElevatorUp(en, e.getPlayer()).getLocation().add(0, 1, 0));}
}
}
}
}
示例9: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event) {
if(freeze.isFrozen(event.getPlayer())) {
Location old = event.getFrom();
old.setPitch(event.getTo().getPitch());
old.setYaw(event.getTo().getYaw());
event.setTo(old);
}
}
示例10: 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);
}
}
示例11: onPlayerMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent evt) {
if (!isPlaying(evt.getPlayer()))
return;
double maxY = MetadataManager.getValue(evt.getPlayer(), "pkMaxY", 0);
if (evt.getTo().clone().subtract(0, .1, 0).getBlock().getType() != Material.AIR) { // If on ground.
MetadataManager.setMetadata(evt.getPlayer(), "pkMaxY", evt.getPlayer().getLocation().getY()); // Update accepted Y levels.
} else if (evt.getTo().getY() <= maxY - 3) { // If they've fallen off
Location checkpoint = checkpoints.get(MetadataManager.getValue(evt.getPlayer(), "pkCheckpoint", 0));
MetadataManager.setMetadata(evt.getPlayer(), "pkMaxY", checkpoint.getY()); // Update accepted Y levels.
evt.setTo(checkpoint); // Teleport them to checkpoint
}
}
示例12: onMove
import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onMove(PlayerMoveEvent evt) {
if (!evt.getPlayer().equals(currentPainter))
return;
if (System.currentTimeMillis() <= penTime)
placeInk();
if (evt.getTo().distance(evt.getFrom()) != 0)
evt.setTo(evt.getFrom()); // Don't allow moving off the plate.
}