当前位置: 首页>>代码示例>>Java>>正文


Java PlayerMoveEvent.getTo方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerMoveEvent.getTo方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerMoveEvent.getTo方法的具体用法?Java PlayerMoveEvent.getTo怎么用?Java PlayerMoveEvent.getTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerMoveEvent的用法示例。


在下文中一共展示了PlayerMoveEvent.getTo方法的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);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:BorderListener.java

示例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());
            }
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:25,代码来源:SpectatorListener.java

示例3: 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)
        );
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:SignUpdater.java

示例4: onChunkChange

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
    public void onChunkChange(PlayerMoveEvent event) {
        Location to = event.getTo();
        Location from = event.getFrom();
        if (to.getBlockX() == from.getBlockX() && to.getBlockZ() == from.getBlockZ()) {
            return;
        }
        Chunk toChunk = to.getChunk();
        Chunk fromChunk = from.getChunk();
        if (toChunk.getX() == fromChunk.getX() && toChunk.getZ() == fromChunk.getZ()) {
            return;
        }
        
		PlayerModule.getInstance().getPlayer(event.getPlayer()).handleViewDistance(); 
		}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:17,代码来源:ChunkChangeEvent.java

示例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);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:26,代码来源:PlayerListener.java

示例6: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public final void onPlayerMove(final PlayerMoveEvent event) {
    final Location from = event.getFrom();
    final Location to = event.getTo();
    // If the player didn't move a complete block, ignore.
    if (from.getBlockX() == to.getBlockX()
            && from.getBlockY() == to.getBlockY()
            && from.getBlockZ() == to.getBlockZ()) {
        return;
    }

    final double origX = to.getX();
    final double origZ = to.getZ();
    this.adjustToPos(to, wbHandler.getBorder(to.getWorld()));
    if (Double.compare(origX, to.getX()) != 0
            || Double.compare(origZ, to.getZ()) != 0) {
        event.getPlayer().sendMessage(DENY_ENTRY);
    }
}
 
开发者ID:Mystiflow,项目名称:WorldBorder,代码行数:20,代码来源:WorldBorderListener.java

示例7: 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());
		}
	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:24,代码来源:ClaimMoveListener.java

示例8: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
  public void onPlayerMove(PlayerMoveEvent event) {
Player p = event.getPlayer();
      Location to = event.getTo();
      Location from = event.getFrom();
      World world = to.getWorld();

      if (to.clone().add(0, -1, 0).getBlock().getType() != Material.REDSTONE_LAMP_ON)
      	return;
      
      if (from.clone().add(0, -1, 0).getBlock().getType() == Material.REDSTONE_LAMP_ON)
      	return;
      
      for (Block block : getPortalNear(world, to.getBlockX(), to.getBlockY(), to.getBlockZ())) {
          for (BlockFace bf : BlockFace.values()) {
              Block relative = block.getRelative(bf);
              if (relative.getTypeId() == SIGN) {
              	
              	// Specific server
              	Sign sign = (Sign) relative.getState();
              	Portal portal = null;
              	for (Portal po : Portal.getList()) {
              		if (WorldUtil.sameBlock(po.getSign().getBlock(), sign.getBlock())) {
              			portal = po;
              			break;
              		}
              	}
              	if (portal == null)
              		return;	
              	
              	if (portal.getCurrent().getStatus() == Status.CLOSED)
              		Chat.player(p, "&cThat server is currently unavailable!");
              	else                	
              		portal.getCurrent().connect(event.getPlayer());
              	
              	portal.updateSign();
              }
          }
      }
  }
 
开发者ID:thekeenant,项目名称:mczone,代码行数:41,代码来源:GameEvents.java

示例9: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) {
    if (this.useTaskInstead)
        return;
    Location to = event.getTo();
    int toX = to.getBlockX();
    int toY = to.getBlockY();
    int toZ = to.getBlockZ();

    Location from = event.getFrom();
    if (from.getBlockX() != toX || from.getBlockY() != toY || from.getBlockZ() != toZ) {
        this.handlePositionChanged(event.getPlayer(), to.getWorld(), toX, toY, toZ);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:15,代码来源:WallBorderListener.java

示例10: 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();
    // Player didn't move a block.
    if (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ()) {
        return;
    }

    cancelTeleport(event.getPlayer(), ChatColor.YELLOW + "You moved a block, therefore cancelling your teleport.");
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:TeleportTimer.java

示例11: 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);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:15,代码来源:LogoutTimer.java

示例12: onMove

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onMove(PlayerMoveEvent event) {
    Location from = event.getFrom();
    Location to = event.getTo();
    if (from.toVector().equals(to.toVector()))
        return;

    PlayerWalkEvent custom = new PlayerWalkEvent(event);
    Bukkit.getPluginManager().callEvent(custom);
    if (event.isCancelled() != custom.isCancelled()) {
        event.setCancelled(custom.isCancelled());
    }
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:14,代码来源:EventCaller.java

示例13: onPlayerMove

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
	final Player player = event.getPlayer();

	final Location from = event.getFrom(), to = event.getTo();

	if (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY()
			&& from.getBlockZ() == to.getBlockZ()) {
		// If the player has only moved their head.

		getCheckVersion(player, CheckType.SPEED, "A").call(event);

		getCheckVersion(player, CheckType.FLY, "A").call(event);

		getCheckVersion(player, CheckType.ANTIGRAVITY, "A").call(event);

		getCheckVersion(player, CheckType.WATERWALK, "A").call(event);

		getCheckVersion(player, CheckType.NOFALL, "A").call(event);

		getCheckVersion(player, CheckType.SNEAK, "A").call(event);
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:24,代码来源:DetectionListener.java

示例14: PlayerWalkEvent

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
public PlayerWalkEvent(PlayerMoveEvent event) {
    this(event.getPlayer(), event.getFrom(), event.getTo());
    setCancelled(event.isCancelled());
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:5,代码来源:PlayerWalkEvent.java

示例15: onMove

import org.bukkit.event.player.PlayerMoveEvent; //导入方法依赖的package包/类
@EventHandler
public void onMove(PlayerMoveEvent e) {
	if (haulted) {
		if (!e.getPlayer().isOp()) {
			e.getPlayer().sendMessage(TAG + ChatColor.RED + "Server Haulted!");
			e.getPlayer().teleport(e.getFrom());
			return;
		}
	}
	if (getConfig().getStringList("frozen").contains(e.getPlayer().getUniqueId().toString())) {
		e.getPlayer().teleport(e.getFrom());
		e.getPlayer().sendMessage(TAG + ChatColor.RED + "You have been frozen!");
		return;
	}
	// all important variables
	Location from = e.getFrom();
	Location to = e.getTo();
	Player p = e.getPlayer();
	// stops headroll and headless hacks
	if (to.getPitch() < -90 || to.getPitch() > 90) {
		p.kickPlayer(TAG + ChatColor.RED + "You seem to have headRoll!");
	}
	if (from.getPitch() < -90 || from.getPitch() > 90) {
		p.kickPlayer(TAG + ChatColor.RED + "You seem to have headRoll!");
		Bukkit.getServer().broadcastMessage(TAG + ChatColor.RED + " member \u00A76" + p.getName() + ChatColor.RED + " has been auto kicked for definet hacks!");
	}
	// anti speed
	// anti fly
	if (!p.isFlying()) {
		if (from.getY() + 0.75 < to.getY()) {
			p.kickPlayer(TAG + ChatColor.RED + "Possible fly/step hacks");
			getLogger().info(ChatColor.RED + p.getName() + " Was kicked for hacks (fly/step upwards)");
			return;
		}
		/*
		 * if(from.getY() == to.getY()){ Location uf = new
		 * Location(p.getWorld(), from.getBlockX(),
		 * from.getBlockY()-1,from.getBlockZ()); Location ut = new
		 * Location(p.getWorld(), to.getBlockX(), to.getBlockY()-1,
		 * to.getBlockZ()); if((uf.getBlock().getType() ==
		 * Material.AIR)&&(ut.getBlock().getType() == Material.AIR)){
		 * p.kickPlayer(TAG + ChatColor.RED + "Possible fly hacks");
		 * getLogger().info(ChatColor.RED + " " + p.getName() +
		 * " Was kicked for fly (across)"); return; } }
		 */
	}
	// ANTI BUNNY HOP
	// END OF ONMOVE
}
 
开发者ID:OverloadedCore,项目名称:behave,代码行数:50,代码来源:MainPart.java


注:本文中的org.bukkit.event.player.PlayerMoveEvent.getTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。