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

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

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

Chunk.unload介绍

[英]Unloads and optionally saves the Chunk
[中]卸载并有选择地保存块

代码示例

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
public boolean unloadChunk(Chunk chunk) {
  return chunk.unload();
}

代码示例来源:origin: AddstarMC/Minigames

public static void removeTreasure(Minigame minigame){
  TreasureHuntModule thm = TreasureHuntModule.getMinigameModule(minigame);
  thm.clearHints();
  if(thm.hasTreasureLocation()){
    Location old = thm.getTreasureLocation();
    boolean loaded = false;
    Chunk c = null;
    if(!old.getWorld().isChunkInUse(old.getChunk().getX(), old.getChunk().getZ())){
      old.getChunk().load();
      loaded = true;
      c = old.getChunk();
    }
    
    if(old.getBlock().getState() instanceof Chest){
      Chest chest = (Chest) old.getBlock().getState();
      chest.getInventory().clear();
    }
    
    old.getBlock().setType(Material.AIR);
    if(loaded && !c.getWorld().isChunkInUse(c.getX(), c.getZ())){
      c.unload();
    }
    thm.setTreasureLocation(null);
  }
}

相关文章