org.bukkit.Server.getViewDistance()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中org.bukkit.Server.getViewDistance()方法的一些代码示例,展示了Server.getViewDistance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.getViewDistance()方法的具体详情如下:
包路径:org.bukkit.Server
类名称:Server
方法名:getViewDistance

Server.getViewDistance介绍

[英]Get the view distance from this server.
[中]获取与此服务器的视图距离。

代码示例

代码示例来源:origin: Bukkit/Bukkit

/**
 * @see Server#getViewDistance()
 */
public static int getViewDistance() {
  return server.getViewDistance();
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#getViewDistance()
 */
public static int getViewDistance() {
  return server.getViewDistance();
}

代码示例来源:origin: EngineHub/CommandHelper

@Override
public int getViewDistance() {
  return s.getViewDistance();
}

代码示例来源:origin: elBukkit/MagicPlugin

protected static void sendPacket(Server server, Location source, Collection<? extends Player> players, Object packet) throws Exception  {
  players = ((players != null && players.size() > 0) ? players : server.getOnlinePlayers());
  int viewDistance = Bukkit.getServer().getViewDistance() * 16;
  int viewDistanceSquared =  viewDistance * viewDistance;
  World sourceWorld = source.getWorld();
  for (Player player : players) {
    Location location = player.getLocation();
    if (!location.getWorld().equals(sourceWorld)) continue;
    if (location.distanceSquared(source) <= viewDistanceSquared) {
      sendPacket(player, packet);
    }
  }
}

代码示例来源:origin: BentoBoxWorld/BentoBox

/**
 * Spawn particles to the player.
 * They are only displayed if they are within the server's view distance.
 * @param particle Particle to display.
 * @param dustOptions Particle.DustOptions for the particle to display.
 *                    Cannot be null when particle is {@link Particle#REDSTONE}.
 * @param x X coordinate of the particle to display.
 * @param y Y coordinate of the particle to display.
 * @param z Z coordinate of the particle to display.
 */
public void spawnParticle(Particle particle, Particle.DustOptions dustOptions, double x, double y, double z) {
  if (particle.equals(Particle.REDSTONE) && dustOptions == null) {
    // Security check that will avoid later unexpected exceptions.
    throw new IllegalArgumentException("A non-null Particle.DustOptions must be provided when using Particle.REDSTONE as particle.");
  }
  // Check if this particle is beyond the viewing distance of the server
  if (player.getLocation().toVector().distanceSquared(new Vector(x,y,z)) < (Bukkit.getServer().getViewDistance()*256*Bukkit.getServer().getViewDistance())) {
    if (particle.equals(Particle.REDSTONE)) {
      player.spawnParticle(particle, x, y, z, 1, 0, 0, 0, 1, dustOptions);
    } else {
      player.spawnParticle(particle, x, y, z, 1);
    }
  }
}

代码示例来源:origin: confuser/BarAPI

private static Location getDragonLocation(Location loc) {
 if (Util.isBelowGround) {
  loc.subtract(0, 300, 0);
  return loc;
 }
 float pitch = loc.getPitch();
 if (pitch >= 55) {
  loc.add(0, -300, 0);
 } else if (pitch <= -55) {
  loc.add(0, 300, 0);
 } else {
  loc = loc.getBlock().getRelative(getDirection(loc), plugin.getServer().getViewDistance() * 16).getLocation();
 }
 return loc;
}

代码示例来源:origin: EngineHub/WorldGuard

config.append("Default Game Mode", server.getDefaultGameMode());
config.append("Main World Type", server.getWorldType());
config.append("View Distance", server.getViewDistance());
append(config.getTitle(), config);

代码示例来源:origin: marcelo-mason/PreciousStones

if (plugin.getPermissionsManager().has(player, "preciousstones.benefit.visualize")) {
    if (args.length == 1 && Helper.isInteger(args[0])) {
      int radius = Math.min(Integer.parseInt(args[0]), plugin.getServer().getViewDistance());
if (!plugin.getVisualizationManager().pendingVisualization(player)) {
  if (plugin.getPermissionsManager().has(player, "preciousstones.admin.mark")) {
    Set<Field> fieldsInArea = plugin.getForceFieldManager().getFieldsInCustomArea(player.getLocation(), plugin.getServer().getViewDistance(), FieldFlag.ALL);
    Set<Field> fieldsInArea = plugin.getForceFieldManager().getFieldsInCustomArea(player.getLocation(), plugin.getServer().getViewDistance(), FieldFlag.ALL);

相关文章

Server类方法