Java 类org.bukkit.Chunk 实例源码
项目:Yasui
文件:Main.java
public void disableAI() {
for (World world : getServer().getWorlds()) {
if (config.ignored_world.contains(world.getName())) {
continue;
}
if (world.getLivingEntities().size() >= this.config.world_entity) {
if (!disableAIWorlds.contains(world.getName())) {
disableAIWorlds.add(world.getName());
getLogger().info("disable entity ai in " + world.getName());
}
for (Chunk chunk : world.getLoadedChunks()) {
int entityCount = getLivingEntityCount(chunk);
if (entityCount >= this.config.chunk_entity) {
for (Entity entity : chunk.getEntities()) {
if (entity instanceof LivingEntity) {
setFromMobSpawner((LivingEntity) entity, true);
}
}
}
}
}
}
}
项目:Yasui
文件:Main.java
public void enableAI() {
for (World world : getServer().getWorlds()) {
if (!disableAIWorlds.contains(world.getName())) {
continue;
} else {
disableAIWorlds.remove(world.getName());
}
getLogger().info("enable entity ai in " + world.getName());
for (Chunk chunk : world.getLoadedChunks()) {
for (Entity entity : chunk.getEntities()) {
if (entity instanceof LivingEntity) {
setFromMobSpawner((LivingEntity) entity, false);
}
}
}
}
}
项目:SurvivalAPI
文件:ChunkListener.java
/**
* Clean the cache
*/
@Override
public void run()
{
long currentTime = System.currentTimeMillis();
List<Map.Entry<Chunk, Long>> temp = new ArrayList<>();
temp.addAll(this.lastChunkCleanUp.entrySet());
for (Map.Entry<Chunk, Long> entry : temp)
{
Chunk chunk = entry.getKey();
if (!chunk.isLoaded() || (currentTime - entry.getValue() <= 60000))
continue;
for (Entity entity : chunk.getEntities())
if (!(entity instanceof Item || entity instanceof HumanEntity || entity instanceof Minecart))
entity.remove();
this.lastChunkCleanUp.remove(chunk);
}
}
项目:Uranium
文件:CraftWorld.java
public void setBiome(int x, int z, Biome bio) {
net.minecraft.world.biome.BiomeGenBase bb = CraftBlock.biomeToBiomeBase(bio);
if (this.world.blockExists(x, 0, z)) {
net.minecraft.world.chunk.Chunk chunk = this.world.getChunkFromBlockCoords(x, z);
if (chunk != null) {
byte[] biomevals = chunk.getBiomeArray();
biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.biomeID;
}
}
}
项目:Transport-Pipes
文件:ContainerBlockUtils.java
public void handleChunkLoadSync(Chunk loadedChunk) {
if (loadedChunk.getTileEntities() != null) {
for (BlockState bs : loadedChunk.getTileEntities()) {
if (isIdContainerBlock(bs.getTypeId())) {
updateDuctNeighborBlockSync(bs.getBlock(), true);
Map<BlockLoc, TransportPipesContainer> containerMap = TransportPipes.instance.getContainerMap(loadedChunk.getWorld());
synchronized (containerMap) {
BlockLoc bl = BlockLoc.convertBlockLoc(bs.getLocation());
TransportPipesContainer tpc = containerMap.get(bl);
if (tpc instanceof BlockContainer) {
((BlockContainer) tpc).updateBlock();
}
}
}
}
}
}
项目:Uranium
文件:CraftChunk.java
public net.minecraft.world.chunk.Chunk getHandle() {
net.minecraft.world.chunk.Chunk c = null;
if (weakChunk != null) {
c = weakChunk.get();
}
if (c == null) {
c = worldServer.getChunkFromChunkCoords(x, z);
if (!(c instanceof net.minecraft.world.chunk.EmptyChunk)) {
weakChunk = new WeakReference<net.minecraft.world.chunk.Chunk>(c);
}
}
return c;
}
项目:Uranium
文件:CraftChunk.java
public Entity[] getEntities() {
int count = 0, index = 0;
net.minecraft.world.chunk.Chunk chunk = getHandle();
for (int i = 0; i < 16; i++) {
count += chunk.entityLists[i].size();
}
Entity[] entities = new Entity[count];
for (int i = 0; i < 16; i++) {
for (Object obj : chunk.entityLists[i].toArray()) {
if (!(obj instanceof net.minecraft.entity.Entity)) {
continue;
}
entities[index++] = ((net.minecraft.entity.Entity) obj).getBukkitEntity();
}
}
return entities;
}
项目:SurvivalAPI
文件:FortressPopulator.java
@Override
public void populate(World world, Random random, Chunk chunk)
{
if (this.bukkitWorld == null)
{
this.bukkitWorld = new BukkitWorld(world);
this.es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(this.bukkitWorld, -1);
this.es.setFastMode(false);
}
if (MathHelper.nextInt(random, 0, 100) == 0)
{
int xFortress = chunk.getX() * 16 + random.nextInt(15);
int zFortress = chunk.getZ() * 16 + random.nextInt(15);
this.generateBlazeFortress(world, xFortress, zFortress);
}
}
项目:EscapeLag
文件:NoCrowdEntity.java
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
if (ConfigOptimize.NoCrowdedEntityenable) {
Chunk chunk = event.getEntity().getLocation().getChunk();
Entity[] entities = chunk.getEntities();
for (Entity e : entities) {
EntityType type = e.getType();
int count = 0;
if (ConfigOptimize.NoCrowdedEntityTypeList.contains("*")
|| ConfigOptimize.NoCrowdedEntityTypeList.contains(type.name())) {
count++;
if (count > ConfigOptimize.NoCrowdedEntityPerChunkLimit && e.getType() != EntityType.PLAYER) {
e.remove();
}
}
}
}
}
项目:EscapeLag
文件:WaterFlowLimitor.java
@EventHandler
public void WaterFowLimitor(BlockFromToEvent event) {
if(ConfigOptimize.WaterFlowLimitorenable == true){
Block block = event.getBlock();
Chunk chunk = block.getChunk();
if (block.getType() == Material.STATIONARY_WATER || block.getType() == Material.STATIONARY_LAVA) {
if(CheckFast(block.getChunk())){
if(CheckedTimes.get(chunk) == null){
CheckedTimes.put(chunk, 0);
}
CheckedTimes.put(chunk, CheckedTimes.get(chunk) + 1);
if(CheckedTimes.get(chunk) > ConfigOptimize.WaterFlowLimitorPerChunkTimes){
event.setCancelled(true);
}
}else{
ChunkLastTime.put(block.getChunk(), System.currentTimeMillis());
}
}
}
}
项目:ZorahPractice
文件:Cuboid.java
/**
* Get a list of the chunks which are fully or partially contained in this cuboid.
*
* @return A list of Chunk objects
*/
public List<Chunk> getChunks() {
List<Chunk> res = new ArrayList<Chunk>();
World w = this.getWorld();
int x1 = this.getLowerX() & ~0xf;
int x2 = this.getUpperX() & ~0xf;
int z1 = this.getLowerZ() & ~0xf;
int z2 = this.getUpperZ() & ~0xf;
for (int x = x1; x <= x2; x += 16) {
for (int z = z1; z <= z2; z += 16) {
res.add(w.getChunkAt(x >> 4, z >> 4));
}
}
return res;
}
项目:Slimefun4-Chinese-Version
文件:BlockStorage.java
private static void refreshCache(BlockStorage storage, Location l, String key, String value, boolean updateTicker) {
Config cfg = storage.cache_blocks.containsKey(key) ? storage.cache_blocks.get(key): new Config(path_blocks + l.getWorld().getName() + "/" + key + ".sfb");
cfg.setValue(serializeLocation(l), value);
storage.cache_blocks.put(key, cfg);
if (updateTicker) {
SlimefunItem item = SlimefunItem.getByID(key);
if (item != null && item.isTicking()) {
Chunk chunk = l.getChunk();
if (value != null) {
Set<Block> blocks = ticking_chunks.containsKey(chunk.toString()) ? ticking_chunks.get(chunk.toString()): new HashSet<Block>();
blocks.add(l.getBlock());
ticking_chunks.put(chunk.toString(), blocks);
if (!loaded_tickers.contains(chunk.toString())) loaded_tickers.add(chunk.toString());
}
}
}
}
项目:SurvivalAPI
文件:OrePopulator.java
@Override
public void populate(World world, Random random, Chunk chunk)
{
if (chunk == null)
return;
CraftWorld handle = (CraftWorld) world;
int xr = this.randInt(random, -200, 200);
if (xr >= 50)
new WorldGenCaves().a(handle.getHandle().chunkProviderServer, handle.getHandle(), chunk.getX(), chunk.getZ(), new ChunkSnapshot());
else if (xr <= -50)
new WorldGenCanyon().a(handle.getHandle().chunkProviderServer, handle.getHandle(), chunk.getX(), chunk.getZ(), new ChunkSnapshot());
for (Rule bloc : this.rules)
{
for (int i = 0; i < bloc.round; i++)
{
int x = chunk.getX() * 16 + random.nextInt(16);
int y = bloc.minY + random.nextInt(bloc.maxY - bloc.minY);
int z = chunk.getZ() * 16 + random.nextInt(16);
this.generate(world, random, x, y, z, bloc.size, bloc);
}
}
}
项目:NeverLag
文件:AutoCleanIllegalTypeSpawner.java
private void autoClean(Chunk chunk) {
if (chunk == null) {
return;
}
for (BlockState tiles : chunk.getTileEntities()) {
if (tiles instanceof CreatureSpawner) {
CreatureSpawner spawner = (CreatureSpawner) tiles;
// 非法类型检测
if (cm.illegalSpawnerType.contains(spawner.getCreatureTypeName().toLowerCase())) {
switch (cm.illegalTypeSpawnerCleanMode) {
case 0:
spawner.getBlock().setType(Material.AIR);
break;
case 1:
spawner.setCreatureType(RND_ENTITYTYPE[(int) (Math.random() * RND_ENTITYTYPE.length)]);
break;
default:
break;
}
}
}
}
}
项目:CropControl
文件:WorldChunk.java
public static void unloadChunk(Chunk chunk) {
long chunk_id = ((long) chunk.getX() << 32L) + (long) chunk.getZ();
UUID world_uuid = chunk.getWorld().getUID();
//CropControl.getPlugin().debug("Registering unload for chunk {0}:{1}", world_uuid, chunk_id);
Map<Long, WorldChunk> chunks = chunkCacheLoc.get(world_uuid);
if (chunks == null) {
return;
}
WorldChunk cacheChunk = chunks.get(chunk_id);
if (cacheChunk != null) {
unloadQueue.offer(cacheChunk);
}
// note we do not actually remove it here.
}
项目:SkyWarsReloaded
文件:Game.java
private void setWeather() {
String weather = getWeather();
final World world = SkyWarsReloaded.get().getServer().getWorld(mapName + "_" + gameNumber);
if (weather.equalsIgnoreCase("sunny")) {
world.setStorm(false);
world.setWeatherDuration(Integer.MAX_VALUE);
} else if (weather.equalsIgnoreCase("rain")) {
world.setStorm(true);
world.setWeatherDuration(Integer.MAX_VALUE);
} else if (weather.equalsIgnoreCase("thunder storm")) {
world.setStorm(true);
world.setThundering(true);
world.setThunderDuration(Integer.MAX_VALUE);
world.setWeatherDuration(Integer.MAX_VALUE);
thunderStorm = true;
} else if (weather.equalsIgnoreCase("snow")) {
for (int x = min; x < max; x++) {
for (int z = min; z < max; z++) {
world.setBiome(x, z, Biome.ICE_PLAINS);
}
}
world.setStorm(true);
world.setWeatherDuration(Integer.MAX_VALUE);
List<Chunk> chunks = getChunks();
SkyWarsReloaded.getNMS().updateChunks(mapWorld, chunks);
world.setStorm(true);
world.setWeatherDuration(Integer.MAX_VALUE);
}
}
项目:SkyWarsReloaded
文件:NMSHandler.java
public void updateChunks(World world, List<Chunk> chunks) {
for (Chunk currentChunk: chunks) {
net.minecraft.server.v1_8_R2.World mcWorld = ((CraftChunk) currentChunk).getHandle().world;
for (EntityHuman eh : (List<EntityHuman>) mcWorld.players) {
EntityPlayer ep = (EntityPlayer) eh;
ep.chunkCoordIntPairQueue.add(new ChunkCoordIntPair(currentChunk.getX(), currentChunk.getZ()));
}
}
}
项目:CropControl
文件:CropControlEventHandler.java
/**
* This is where we pre-load data for each chunk. If it's already in the loaded cache, nothing happens. If it was previously
* staged for unload, this cancels that.
*
* @param e The chunk to load.
*/
@EventHandler(ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent e) {
Chunk chunk = e.getChunk();
CropControl.getDAO().getChunk(chunk);
}
项目:CropControl
文件:CropControlEventHandler.java
/**
* Marks a loaded chunk as pending unload. It'll be unloaded later en-masse.
*
* @param e The chunk to unload.
*/
@EventHandler(ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent e) {
Chunk chunk = e.getChunk();
CropControl.getDAO().unloadChunk(chunk);
}
项目:ClaimChunk
文件:MainHandler.java
public static void unclaimChunk(Player p) throws IOException {
if (!Utils.hasPerm(p, "claimchunk.unclaim")) {
Utils.toPlayer(p, Config.getColor("errorColor"), Utils.getMsg("unclaimNoPerm"));
return;
}
ChunkHandler ch = ClaimChunk.getInstance().getChunkHandler();
Chunk loc = p.getLocation().getChunk();
if(!ch.isClaimed(loc.getWorld(), loc.getX(), loc.getZ())) {
Utils.toPlayer(p, Config.getColor("errorColor"), Utils.getMsg("unclaimNotOwned"));
return;
}
if(!ch.isOwner(loc.getWorld(), loc.getX(), loc.getZ(), p)) {
Utils.toPlayer(p, Config.getColor("errorColor"), Utils.getMsg("unclaimNotOwner"));
return;
}
boolean refund = false;
if (ClaimChunk.getInstance().useEconomy()) {
Econ e = ClaimChunk.getInstance().getEconomy();
double reward = Config.getDouble("economy", "unclaimReward");
if (reward > 0) {
e.addMoney(p.getUniqueId(), reward);
Utils.toPlayer(p, Config.getColor("errorColor"), Utils.getMsg("unclaimRefund").replaceAll("%%AMT%%", e.format(reward)));
refund = true;
}
}
ch.unclaimChunk(loc.getWorld(), loc.getX(), loc.getZ());
if (!refund) {
Utils.toPlayer(p, Config.getColor("successColor"), Utils.getMsg("unclaimSuccess"));
}
}
项目:Yasui
文件:Main.java
public int getLivingEntityCount(Chunk chunk) {
int entityCount = 0;
for (Entity entity : chunk.getEntities()) {
if (entity instanceof LivingEntity && !(entity instanceof ArmorStand)) {
entityCount++;
}
}
return entityCount;
}
项目:HCFCore
文件:VisualiseHandler.java
public LinkedHashMap<Location, VisualBlockData> generateAsync(Player player, Iterable<Location> locations, VisualType visualType, boolean canOverwrite) {
synchronized (storedVisualises) {
LinkedHashMap<Location, VisualBlockData> results = new LinkedHashMap<>();
ArrayList<VisualBlockData> filled = visualType.blockFiller().bulkGenerate(player, locations);
if (filled != null) {
for (Location location : locations) {
if (!canOverwrite && storedVisualises.contains(player.getUniqueId(), location)) {
continue;
}
location.getWorld().getChunkAtAsync(location, new World.ChunkLoadCallback() {
int count = 0;
@Override
public void onLoad(Chunk chunk) {
Material previousType = CraftMagicNumbers.getMaterial(((CraftChunk) chunk).getHandle().getType(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
if (previousType.isSolid() || previousType != Material.AIR) {
return;
}
VisualBlockData visualBlockData = filled.get(count++);
results.put(location, visualBlockData);
player.sendBlockChange(location, visualBlockData.getBlockType(), visualBlockData.getData());
storedVisualises.put(player.getUniqueId(), location, new VisualBlock(visualType, visualBlockData, location));
}
});
}
}
return results;
}
}
项目:Uranium
文件:CraftWorld.java
public Chunk[] getLoadedChunks() {
List tLoadedChunk = world.theChunkProviderServer.loadedChunks;
final org.bukkit.Chunk[] craftChunks = new CraftChunk[tLoadedChunk.size()];
int i = 0;
for(Object sObj : tLoadedChunk){
craftChunks[i++]=((net.minecraft.world.chunk.Chunk) sObj).bukkitChunk;
}
return craftChunks;
}
项目:Uranium
文件:CraftChunk.java
public CraftChunk(net.minecraft.world.chunk.Chunk chunk) {
if (!(chunk instanceof net.minecraft.world.chunk.EmptyChunk)) {
this.weakChunk = new WeakReference<net.minecraft.world.chunk.Chunk>(chunk);
}
worldServer = getHandle().worldObj instanceof net.minecraft.world.WorldServer ? (net.minecraft.world.WorldServer) getHandle().worldObj : null;
x = getHandle().xPosition;
z = getHandle().zPosition;
}
项目:Uranium
文件:CraftChunk.java
public BlockState[] getTileEntities() {
int index = 0;
net.minecraft.world.chunk.Chunk chunk = getHandle();
BlockState[] entities = new BlockState[chunk.chunkTileEntityMap.size()];
for (Object obj : chunk.chunkTileEntityMap.keySet().toArray()) {
if (!(obj instanceof net.minecraft.world.ChunkPosition)) {
continue;
}
net.minecraft.world.ChunkPosition position = (net.minecraft.world.ChunkPosition) obj;
entities[index++] = worldServer.getWorld().getBlockAt(position.chunkPosX + (chunk.xPosition << 4), position.chunkPosY, position.chunkPosZ + (chunk.zPosition << 4)).getState();
}
return entities;
}
项目:ClaimChunk
文件:PlayerMovementHandler.java
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
if (e != null && e.getPlayer() != null && !e.isCancelled()) {
Chunk prev = e.getFrom().getChunk();
Chunk to = e.getTo().getChunk();
if (prev != to) {
if (AutoClaimHandler.inList(e.getPlayer())) {
MainHandler.claimChunk(e.getPlayer(), to);
}
ChunkHandler ch = ClaimChunk.getInstance().getChunkHandler();
boolean lastClaimed = ch.isClaimed(prev.getWorld(), prev.getX(), prev.getZ());
if (ch.isClaimed(to.getWorld(), to.getX(), to.getZ())) {
if (lastClaimed) {
UUID prevOwner = ch.getOwner(prev.getWorld(), prev.getX(), prev.getZ());
UUID newOwner = ch.getOwner(to.getWorld(), to.getX(), to.getZ());
if (!prevOwner.equals(newOwner)) {
showTitle(e.getPlayer(), to);
}
} else {
showTitle(e.getPlayer(), to);
}
} else {
if (lastClaimed) {
Utils.toPlayer(e.getPlayer(), Config.getColor("infoColor"), Utils.getMsg("chunkLeave"));
}
}
}
}
}
项目:AntiCheat
文件:OrebfuscatorChunkListener.java
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
Chunk chunk = event.getChunk();
ChunkReloader.addLoadedChunk(event.getWorld(), chunk.getX(), chunk.getZ());
//Orebfuscator.log("Chunk x = " + chunk.getX() + ", z = " + chunk.getZ() + " is loaded");/*debug*/
}
项目:AntiCheat
文件:OrebfuscatorChunkListener.java
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
Chunk chunk = event.getChunk();
ChunkReloader.addUnloadedChunk(event.getWorld(), chunk.getX(), chunk.getZ());
//Orebfuscator.log("Chunk x = " + chunk.getX() + ", z = " + chunk.getZ() + " is unloaded");/*debug*/
}
项目:ZentrelaRPG
文件:EnvironmentManager.java
public static void handleChunk(Chunk chunk) {
RScheduler.schedule(plugin, new Runnable() {
public void run() {
if (chunk.isLoaded())
despawnEntities(chunk.getEntities());
}
}, 10);
}
项目:ZentrelaRPG
文件:HologramManager.java
public static void handleChunk(Chunk chunk) {
final ChunkWrapper cw = new ChunkWrapper(chunk);
if (!hologramsPerChunk.containsKey(cw))
return;
RScheduler.schedule(plugin, new Runnable() {
public void run() {
ArrayList<Hologram> holos = hologramsPerChunk.get(cw);
for (Hologram h : holos)
h.spawn();
}
}, RTicks.seconds(2));
}
项目:ZentrelaRPG
文件:DungeonManager.java
public static void handleChunk(Chunk chunk) {
final ChunkWrapper cw = new ChunkWrapper(chunk);
if (!bossPerChunk.containsKey(cw))
return;
RScheduler.schedule(plugin, new Runnable() {
public void run() {
HashSet<DungeonBoss> bosses = bossPerChunk.get(cw);
for (DungeonBoss db : bosses)
if (!db.isStillSpawned())
db.spawnSpawner();
}
}, RTicks.seconds(2));
}
项目:SkyWarsReloaded
文件:NMSHandler.java
@SuppressWarnings("unchecked")
public void updateChunks(World world, List<Chunk> chunks) {
for (Chunk currentChunk: chunks) {
net.minecraft.server.v1_7_R3.World mcWorld = ((CraftChunk) currentChunk).getHandle().world;
for (EntityPlayer ep : (List<EntityPlayer>) mcWorld.players) {
ep.chunkCoordIntPairQueue.add(new ChunkCoordIntPair(currentChunk.getX(), currentChunk.getZ()));
}
}
}
项目:ZentrelaRPG
文件:NPCManager.java
public static void handleChunk(Chunk chunk) {
final ChunkWrapper cw = new ChunkWrapper(chunk);
if (!villagersPerChunk.containsKey(cw))
return;
RScheduler.schedule(plugin, new Runnable() {
public void run() {
HashSet<NPCEntity> vils = villagersPerChunk.get(cw);
for (NPCEntity v : vils)
v.register();
}
}, RTicks.seconds(2));
}
项目:EscapeLag
文件:UnloadClear.java
@EventHandler
public void DeathNoClear(PlayerDeathEvent event) {
if (ConfigOptimize.UnloadClearDROPPED_ITEMNoCleatDeath != true) {
return;
}
Player player = event.getEntity();
Chunk chunk = player.getLocation().getChunk();
DeathChunk.add(chunk);
}
项目:NeverLag
文件:CommandChunkInfo.java
@Override
public void onCommand(CommandSender sender, String[] args) {
List<Chunk> chunks = this.getAllChunk();
if (chunks.isEmpty()) {
sender.sendMessage(i18n.tr("chunkListEmpty"));
return;
}
if (sender instanceof Player) {
Player p = (Player) sender;
} else {
throw new UnsupportedOperationException();
}
}
项目:EscapeLag
文件:AutoSave.java
@EventHandler
public void JoinTaskGiver(PlayerJoinEvent e) {
if (ConfigOptimize.AutoSaveenable == false) {
return;
}
final Player p = e.getPlayer();
TaskId.put(p, Bukkit.getScheduler().scheduleSyncRepeatingTask(EscapeLag.MainThis, new Runnable() {
@Override
public void run() {
Chunk chunk = p.getLocation().getChunk();
Chunk LastChunk = PlayerInChunkMap.get(p);
if (LastChunk != chunk) {
if (LastChunk == null) {
PlayerInChunkMap.put(p, chunk);
return;
}
if (PlayerClickedMap.containsValue(LastChunk)) {
return;
}
World world = LastChunk.getWorld();
if (LastChunk.isLoaded() == true) {
world.unloadChunk(LastChunk.getX(), LastChunk.getZ(), true);
LastChunk.load();
} else {
LastChunk.load();
world.unloadChunk(LastChunk.getX(), LastChunk.getZ(), true);
}
}
PlayerInChunkMap.put(p, chunk);
p.saveData();
}
}, ConfigOptimize.AutoSaveInterval * 20, ConfigOptimize.AutoSaveInterval * 20));
}
项目:EscapeLag
文件:ChunkUnloader.java
@EventHandler
public void LeaveWorldCheck(PlayerChangedWorldEvent event) {
if (ConfigOptimize.chunkUnloader == true && event.getFrom().getPlayers().isEmpty()) {
Chunk[] loadedChunks = event.getFrom().getLoadedChunks();
int lcl = loadedChunks.length;
for (int i = 0; i < lcl; i++) {
Chunk chunk = loadedChunks[i];
if (chunk.isLoaded() == true & ChunkKeeper.ShouldKeepList.contains(chunk) == false) {
chunk.unload();
ChunkUnloaderTimes++;
}
}
}
}
项目:HCFCore
文件:VisualiseHandler.java
public LinkedHashMap<Location, VisualBlockData> generateAsync(Player player, Iterable<Location> locations, VisualType visualType, boolean canOverwrite) {
synchronized (storedVisualises) {
LinkedHashMap<Location, VisualBlockData> results = new LinkedHashMap<>();
ArrayList<VisualBlockData> filled = visualType.blockFiller().bulkGenerate(player, locations);
if (filled != null) {
for (Location location : locations) {
if (!canOverwrite && storedVisualises.contains(player.getUniqueId(), location)) {
continue;
}
location.getWorld().getChunkAtAsync(location, new World.ChunkLoadCallback() {
int count = 0;
@Override
public void onLoad(Chunk chunk) {
Material previousType = CraftMagicNumbers.getMaterial(((CraftChunk) chunk).getHandle().getType(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
if (previousType.isSolid() || previousType != Material.AIR) {
return;
}
VisualBlockData visualBlockData = filled.get(count++);
results.put(location, visualBlockData);
player.sendBlockChange(location, visualBlockData.getBlockType(), visualBlockData.getData());
storedVisualises.put(player.getUniqueId(), location, new VisualBlock(visualType, visualBlockData, location));
}
});
}
}
return results;
}
}
项目:SkyWarsReloaded
文件:NMSHandler.java
@SuppressWarnings("deprecation")
public void updateChunks(org.bukkit.World world, List<org.bukkit.Chunk> chunks)
{
Iterator<EntityHuman> localIterator2;
for (Iterator<Chunk> localIterator1 = chunks.iterator(); localIterator1.hasNext(); localIterator2.hasNext())
{
org.bukkit.Chunk currentChunk = (org.bukkit.Chunk)localIterator1.next();
net.minecraft.server.v1_12_R1.World mcWorld = ((CraftChunk)currentChunk).getHandle().world;
localIterator2 = mcWorld.players.iterator(); EntityHuman eh = (EntityHuman)localIterator2.next();
EntityPlayer ep = (EntityPlayer)eh;
Player p = (Player)ep;
p.getWorld().refreshChunk(currentChunk.getX(), currentChunk.getZ());
continue;
}
}
项目:Slimefun4-Chinese-Version
文件:BlockStorage.java
@SuppressWarnings("unchecked")
public static void setChunkInfo(Chunk chunk, String key, String value) {
Config cfg = new Config("data-storage/Slimefun/temp.yml");
if (hasChunkInfo(chunk)) cfg = getChunkInfo(chunk);
cfg.setValue(key, value);
JSONObject json = new JSONObject();
for (String path: cfg.getKeys()) {
json.put(path, cfg.getString(path));
}
map_chunks.put(serializeChunk(chunk), json.toJSONString());
chunk_changes++;
}