org.bukkit.Chunk.getWorld()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(110)

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

Chunk.getWorld介绍

[英]Gets the world containing this chunk
[中]获取包含此块的世界

代码示例

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

protected ChunkEvent(final Chunk chunk) {
  super(chunk.getWorld());
  this.chunk = chunk;
}

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

protected ChunkEvent(final Chunk chunk) {
  super(chunk.getWorld());
  this.chunk = chunk;
}

代码示例来源:origin: webbukkit/dynmap

@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
  public void onChunkPopulate(ChunkPopulateEvent event) {
    Chunk c = event.getChunk();
    ChunkSnapshot cs = c.getChunkSnapshot();
    int ymax = 0;
    for(int i = 0; i < c.getWorld().getMaxHeight() / 16; i++) {
      if(!cs.isSectionEmpty(i)) {
        ymax = (i+1)*16;
      }
    }
    /* Touch extreme corners */
    int x = c.getX() << 4;
    int z = c.getZ() << 4;
    mapManager.touchVolume(getWorld(event.getWorld()).getName(), x, 0, z, x+15, ymax, z+16, "chunkpopulate");
  }
};

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

@Override
public MCWorld getWorld() {
  return new BukkitMCWorld(c.getWorld());
}

代码示例来源:origin: echurchill/CityWorld

public DataContext getContext(Chunk c) throws IllegalArgumentException {
  CityWorldGenerator gen = (CityWorldGenerator) c.getWorld().getGenerator();
  int chunkX = c.getX();
  int chunkZ = c.getZ();
  // Setup info - seams to require this to prevent NPE's when server is restarted.
  gen.initializeWorldInfo(c.getWorld());
  // figure out what everything looks like. Again :/
  PlatMap platmap = gen.getPlatMap(chunkX, chunkZ);
  if (platmap == null)
    throw new IllegalArgumentException("PlatMap not found for specified chunk");
  return platmap.context;
}

代码示例来源:origin: eccentricdevotion/TARDIS

private List<Chunk> getChunks(Chunk c, SCHEMATIC s) {
    List<Chunk> chinks = new ArrayList<>();
    chinks.add(c);
    if (!s.getConsoleSize().equals(ConsoleSize.SMALL)) {
      chinks.add(c.getWorld().getChunkAt(c.getX() + 1, c.getZ()));
      chinks.add(c.getWorld().getChunkAt(c.getX(), c.getZ() + 1));
      chinks.add(c.getWorld().getChunkAt(c.getX() + 1, c.getZ() + 1));
    }
    return chinks;
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

private List<Chunk> getChunks(Chunk c, SCHEMATIC s) {
    List<Chunk> chinks = new ArrayList<>();
    chinks.add(c);
    if (!s.getConsoleSize().equals(ConsoleSize.SMALL)) {
      chinks.add(c.getWorld().getChunkAt(c.getX() + 1, c.getZ()));
      chinks.add(c.getWorld().getChunkAt(c.getX(), c.getZ() + 1));
      chinks.add(c.getWorld().getChunkAt(c.getX() + 1, c.getZ() + 1));
    }
    return chinks;
  }
}

代码示例来源:origin: echurchill/CityWorld

public int getRoadCount(Chunk c) throws IllegalArgumentException {
  CityWorldGenerator gen = (CityWorldGenerator) c.getWorld().getGenerator();
  int chunkX = c.getX();
  int chunkZ = c.getZ();
  // Setup info - seams to require this to prevent NPE's when server is restarted.
  gen.initializeWorldInfo(c.getWorld());
  // figure out what everything looks like. Again :/
  PlatMap platmap = gen.getPlatMap(chunkX, chunkZ);
  if (platmap == null)
    throw new IllegalArgumentException("PlatMap not found for specified chunk");
  return platmap.getNumberOfRoads();
}

代码示例来源:origin: bergerkiller/BKCommonLib

/**
 * Saves a single chunk to disk
 * 
 * @param chunk to save
 */
public static void saveChunk(org.bukkit.Chunk chunk) {
  CommonNMS.getNative(chunk.getWorld()).chunkProviderServer.saveChunk(CommonNMS.getNative(chunk));
}

代码示例来源:origin: bergerkiller/BKCommonLib

/**
 * Checks if this Block Location is within the boundaries of a chunk
 * 
 * @param chunk to check
 * @return True if within, False if not
 */
public boolean isIn(Chunk chunk) {
  if (chunk != null && this.isIn(chunk.getWorld())) {
    return (this.x >> 4) == chunk.getX() && (this.z >> 4) == chunk.getZ();
  }
  return false;
}

代码示例来源:origin: echurchill/CityWorld

public String getContextName(Chunk c) throws IllegalArgumentException {
  CityWorldGenerator gen = (CityWorldGenerator) c.getWorld().getGenerator();
  int chunkX = c.getX();
  int chunkZ = c.getZ();
  // Setup info - seams to require this to prevent NPE's when server is restarted.
  gen.initializeWorldInfo(c.getWorld());
  // figure out what everything looks like. Again :/
  PlatMap platmap = gen.getPlatMap(chunkX, chunkZ);
  if (platmap == null)
    throw new IllegalArgumentException("PlatMap not found for specified chunk");
  return platmap.context.getSchematicFamily().toString();
}

代码示例来源:origin: jiongjionger/NeverLag

public ChunkInfo(Chunk chunk) {
  this.world = chunk.getWorld().getName();
  this.chunkx = chunk.getX();
  this.chunkz = chunk.getZ();
}

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

/**
 * @param chunk
 */
public ChunkVec(Chunk chunk) {
  super(chunk.getX(), 0, chunk.getZ(), chunk.getWorld().getName());
}

代码示例来源:origin: me.lucko/helper

public static ChunkPosition of(Chunk location) {
  Objects.requireNonNull(location, "location");
  return of(location.getX(), location.getZ(), location.getWorld().getName());
}

代码示例来源:origin: lucko/helper

public static ChunkPosition of(Chunk location) {
  Objects.requireNonNull(location, "location");
  return of(location.getX(), location.getZ(), location.getWorld().getName());
}

代码示例来源:origin: eccentricdevotion/TARDIS

private int getChunkX(boolean min, Chunk c) {
  int cx = c.getX();
  int cz = c.getZ();
  if (min) {
    return c.getWorld().getChunkAt(cx - 4, cz).getBlock(0, 64, 0).getX();
  } else {
    return c.getWorld().getChunkAt(cx + 4, cz).getBlock(0, 64, 0).getX();
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

private int getChunkZ(boolean min, Chunk c) {
  int cx = c.getX();
  int cz = c.getZ();
  if (min) {
    return c.getWorld().getChunkAt(cx, cz - 4).getBlock(0, 64, 0).getZ();
  } else {
    return c.getWorld().getChunkAt(cx, cz + 4).getBlock(0, 64, 0).getZ();
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

boolean listChunks(CommandSender sender) {
    if (plugin.getGeneralKeeper().getTardisChunkList().size() > 0) {
      plugin.getGeneralKeeper().getTardisChunkList().forEach((c) -> sender.sendMessage(plugin.getPluginName() + c.getWorld().getName() + ": " + c));
    } else {
      TARDISMessage.send(sender, "NO_CHUNKS");
    }
    return true;
  }
}

代码示例来源:origin: BigScary/GriefPrevention

public void restoreClaim(Claim claim, long delayInTicks)
{
  //admin claims aren't automatically cleaned up when deleted or abandoned
  if(claim.isAdminClaim()) return;
  
  //it's too expensive to do this for huge claims
  if(claim.getArea() > 10000) return;
  
  ArrayList<Chunk> chunks = claim.getChunks();
  for(Chunk chunk : chunks)
  {
    this.restoreChunk(chunk, this.getSeaLevel(chunk.getWorld()) - 15, false, delayInTicks, null);
  }
}

代码示例来源:origin: bergerkiller/BKCommonLib

public static void broadcastChunkPacket(org.bukkit.Chunk chunk, Object packet, boolean throughListeners) {
  if (packet instanceof CommonPacket) {
    packet = ((CommonPacket) packet).getHandle();
  }
  if (chunk == null || packet == null) {
    return;
  }
  for (Player player : WorldUtil.getPlayers(chunk.getWorld())) {
    if (EntityUtil.isNearChunk(player, chunk.getX(), chunk.getZ(), CommonUtil.VIEW)) {
      sendPacket(player, packet, throughListeners);
    }
  }
}

相关文章