本文整理了Java中org.bukkit.Chunk.isLoaded()
方法的一些代码示例,展示了Chunk.isLoaded()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Chunk.isLoaded()
方法的具体详情如下:
包路径:org.bukkit.Chunk
类名称:Chunk
方法名:isLoaded
[英]Checks if the chunk is loaded.
[中]检查块是否已加载。
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public boolean isChunkLoaded(Chunk chunk) {
return chunk.isLoaded();
}
代码示例来源:origin: GlowstoneMC/Glowstone
for (int x = cx - 8; x <= cx + 8 && !placed; x++) {
for (int z = cz - 8; z <= cz + 8 && !placed; z++) {
if (!world.getChunkAt(x, z).isLoaded() && !world.getChunkAt(x, z).load(true)) {
continue;
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void run() {
Block block = location.getBlock();
if (block == null) {
cancel();
return;
}
if (!location.getChunk().isLoaded()) {
return;
}
if (block.getType() != originalMaterial) {
cancel();
return;
}
ItemTable table = ItemTable.instance();
BlockType type = table.getBlock(originalMaterial);
if (type != null) {
type.receivePulse((GlowBlock) block);
}
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
if (!getLocation().getChunk().isLoaded()) {
return;
&& this.getLocation().getChunk().isLoaded()) {
GlowLivingEntity entity = (GlowLivingEntity) this;
entity.getTaskManager().pulse();
代码示例来源:origin: elBukkit/MagicPlugin
private static boolean checkSingleChunk(Chunk chunk, boolean load) {
if (!chunk.isLoaded()) {
if (load) {
chunk.load();
}
return false;
}
return isReady(chunk);
}
代码示例来源:origin: BigScary/GriefPrevention
private static void GuaranteeChunkLoaded(Location location)
{
Chunk chunk = location.getChunk();
while(!chunk.isLoaded() || !chunk.load(true));
}
代码示例来源:origin: elBukkit/MagicPlugin
@Override
public boolean isReady() {
if ((mode == BrushMode.CLONE || mode == BrushMode.REPLICATE) && materialTarget != null) {
Block block = materialTarget.getBlock();
return (block.getChunk().isLoaded());
} else if (mode == BrushMode.SCHEMATIC) {
return checkSchematic();
}
return true;
}
代码示例来源:origin: elBukkit/MagicPlugin
public void registerAutomaton(Automaton automaton) {
String chunkId = getChunkKey(automaton.getLocation());
if (chunkId == null) return;
Map<Long, Automaton> chunkAutomata = automata.get(chunkId);
if (chunkAutomata == null) {
chunkAutomata = new HashMap<>();
automata.put(chunkId, chunkAutomata);
}
long id = automaton.getId();
chunkAutomata.put(id, automaton);
if (automaton.getLocation().getChunk().isLoaded()) {
activeAutomata.put(id, automaton);
automaton.resume();
}
}
代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common
public void loadChunks() {
int minX = (int) Math.floor(this.minCorner.getX());
int maxX = (int) Math.ceil(this.maxCorner.getX());
int minZ = (int) Math.floor(this.minCorner.getZ());
int maxZ = (int) Math.ceil(this.maxCorner.getZ());
for (int x = minX; x <= maxX; x += Region.CHUNK_SIZE) {
for (int z = minZ; z <= maxZ; z += Region.CHUNK_SIZE) {
Chunk chunk = this.world.getChunkAt(x, z);
if (!chunk.isLoaded()) {
chunk.load();
}
}
}
}
代码示例来源:origin: BedwarsRel/BedwarsRel
public void loadChunks() {
int minX = (int) Math.floor(this.minCorner.getX());
int maxX = (int) Math.ceil(this.maxCorner.getX());
int minZ = (int) Math.floor(this.minCorner.getZ());
int maxZ = (int) Math.ceil(this.maxCorner.getZ());
for (int x = minX; x <= maxX; x += Region.CHUNK_SIZE) {
for (int z = minZ; z <= maxZ; z += Region.CHUNK_SIZE) {
Chunk chunk = this.world.getChunkAt(x, z);
if (!chunk.isLoaded()) {
chunk.load();
}
}
}
}
代码示例来源:origin: elBukkit/MagicPlugin
@Override
public void prepare() {
if (cloneSource != null && cloneTarget != null) {
Block block = cloneTarget.getBlock();
if (!block.getChunk().isLoaded()) {
block.getChunk().load(true);
}
}
}
代码示例来源:origin: BigScary/GriefPrevention
@SuppressWarnings("deprecation")
@Override
public void run()
{
//for each element (=block) of the visualization
for(int i = 0; i < visualization.elements.size(); i++)
{
VisualizationElement element = visualization.elements.get(i);
//send the player a fake block change event
if(!element.location.getChunk().isLoaded()) continue; //cheap distance check
player.sendBlockChange(element.location, element.visualizedMaterial, element.visualizedData);
}
//remember the visualization applied to this player for later (so it can be inexpensively reverted)
playerData.currentVisualization = visualization;
//schedule automatic visualization reversion in 60 seconds.
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(
GriefPrevention.instance,
new VisualizationReversionTask(player, playerData, visualization),
20L * 60); //60 seconds
}
}
代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common
if (!signChunk.isLoaded()) {
signChunk.load(true);
代码示例来源:origin: filoghost/HolographicDisplays
@EventHandler (priority = EventPriority.MONITOR)
public void onChunkLoad(ChunkLoadEvent event) {
final Chunk chunk = event.getChunk();
// Other plugins could call this event wrongly, check if the chunk is actually loaded.
if (chunk.isLoaded()) {
// In case another plugin loads the chunk asynchronously always make sure to load the holograms on the main thread.
if (Bukkit.isPrimaryThread()) {
processChunkLoad(chunk);
} else {
Bukkit.getScheduler().runTask(HolographicDisplays.getInstance(), new Runnable() {
@Override
public void run() {
processChunkLoad(chunk);
}
});
}
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
public void closeDoors() {
// get door locations
ResultSetDoorBlocks rs = new ResultSetDoorBlocks(plugin, id);
if (rs.resultSet()) {
close(rs.getOuterBlock(), rs.getInnerBlock().getLocation());
// inner
if (!rs.getInnerBlock().getChunk().isLoaded()) {
rs.getInnerBlock().getChunk().load();
}
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> close(rs.getInnerBlock(), null), 5L);
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
public void toggleLamp(int id, boolean on) {
HashMap<String, Object> where = new HashMap<>();
where.put("tardis_id", id);
ResultSetCurrentLocation rs = new ResultSetCurrentLocation(plugin, where);
if (rs.resultSet()) {
Block lamp = new Location(rs.getWorld(), rs.getX(), rs.getY(), rs.getZ()).getBlock().getRelative(BlockFace.UP, 3);
Block redstone = new Location(rs.getWorld(), rs.getX(), rs.getY(), rs.getZ()).getBlock().getRelative(BlockFace.UP, 2);
while (!lamp.getChunk().isLoaded()) {
lamp.getChunk().load();
}
if (lamp.getType().equals(Material.REDSTONE_LAMP)) {
if (on) {
// turn on
redstone.setBlockData(TARDISConstants.POWER);
} else {
// turn off
redstone.setBlockData(Material.BLUE_WOOL.createBlockData());
}
}
}
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
public void openDoors() {
// get door locations
// inner
ResultSetDoorBlocks rs = new ResultSetDoorBlocks(plugin, id);
if (rs.resultSet()) {
open(rs.getInnerBlock(), rs.getOuterBlock(), true);
// outer
if (!rs.getOuterBlock().getChunk().isLoaded()) {
rs.getOuterBlock().getChunk().load();
}
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> open(rs.getOuterBlock(), rs.getInnerBlock(), false), 5L);
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
private Location getRelativeLocation(Player p) {
Location playerLoc = p.getLocation();
double x = vortexJunkLoc.getX() + (playerLoc.getX() - junkLoc.getX());
double y = vortexJunkLoc.getY() + (playerLoc.getY() - junkLoc.getY()) + 0.5d;
double z = vortexJunkLoc.getZ() + (playerLoc.getZ() - junkLoc.getZ());
Location l = new Location(vortexJunkLoc.getWorld(), x, y, z, playerLoc.getYaw(), playerLoc.getPitch());
while (!l.getChunk().isLoaded()) {
l.getChunk().load();
}
return l;
}
代码示例来源:origin: eccentricdevotion/TARDIS
private Location getRelativeLocation(Player p) {
Location playerLoc = p.getLocation();
double x = dd.getFromToLocation().getX() + (playerLoc.getX() - dd.getLocation().getX());
double y = dd.getFromToLocation().getY() + (playerLoc.getY() - dd.getLocation().getY()) + 1.1d;
double z = dd.getFromToLocation().getZ() + (playerLoc.getZ() - dd.getLocation().getZ());
Location l = new Location(dd.getFromToLocation().getWorld(), x, y, z, playerLoc.getYaw(), playerLoc.getPitch());
while (!l.getChunk().isLoaded()) {
l.getChunk().load();
}
return l;
}
代码示例来源:origin: elBukkit/MagicPlugin
public boolean isSafeLocation(Block block)
{
if (!block.getChunk().isLoaded()) {
block.getChunk().load(true);
return false;
}
if (block.getY() > CompatibilityUtils.getMaxHeight(block.getWorld())) {
return false;
}
Block blockOneUp = block.getRelative(BlockFace.UP);
Block blockOneDown = block.getRelative(BlockFace.DOWN);
// Ascend to top of water
if (isUnderwater() && isWater(blockOneDown.getType())
&& blockOneUp.getType() == Material.AIR && block.getType() == Material.AIR) {
return true;
}
Player player = mage.getPlayer();
return (
(isOkToStandOn(blockOneDown) || (player != null && player.isFlying()))
&& isOkToStandIn(blockOneUp)
&& isOkToStandIn(block)
);
}
内容来源于网络,如有侵权,请联系作者删除!