Added the ability of chunk loaders to load more than one chunk at a time

This commit is contained in:
OmerBenGera 2020-09-27 19:09:21 +03:00
parent 1468eda8c1
commit 019ae2492c
26 changed files with 366 additions and 233 deletions

View File

@ -1,6 +1,7 @@
package com.bgsoftware.wildloaders.api.loaders;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
@ -29,6 +30,11 @@ public interface ChunkLoader {
*/
Location getLocation();
/**
* Get the chunks that this chunk-loader is loading.
*/
Chunk[] getLoadedChunks();
/**
* Get the NPC of this chunk loader.
*/

View File

@ -19,4 +19,19 @@ public interface LoaderData {
*/
ItemStack getLoaderItem();
/**
* Set the radius of chunks that the chunk loader will load.
* If the radius is 0, it means only one chunk is loaded. A radius of 1, will load 3x3 chunks, etc.
* Please note: In some versions, when loading one chunk, the nearby chunks are also being loaded!
* @param chunksRadius The chunk radius to set.
*/
void setChunksRadius(int chunksRadius);
/**
* Get the radius of chunks that the chunk loader will load.
* If the radius is 0, it means only one chunk is loaded. A radius of 1, will load 3x3 chunks, etc.
* Please note: In some versions, when loading one chunk, the nearby chunks are also being loaded!
*/
int getChunksRadius();
}

View File

@ -62,7 +62,7 @@ public interface LoadersManager {
* @param timeLeft The default amount of time to run.
* @param itemStack The item stack to drop upon break.
*/
void createLoaderData(String name, long timeLeft, ItemStack itemStack);
LoaderData createLoaderData(String name, long timeLeft, ItemStack itemStack);
/**
* Remove all the chunk loaders data from cache.

View File

@ -72,9 +72,11 @@ public final class LoadersHandler implements LoadersManager {
}
public WChunkLoader addChunkLoader(LoaderData loaderData, UUID placer, Location location, long timeLeft){
WChunkLoader chunkLoader = new WChunkLoader(loaderData.getName(), placer, location, timeLeft);
WChunkLoader chunkLoader = new WChunkLoader(loaderData, placer, location, timeLeft);
chunkLoaders.put(location, chunkLoader);
chunkLoadersByChunks.put(ChunkPosition.of(location), chunkLoader);
for (Chunk loadedChunk : chunkLoader.getLoadedChunks()) {
chunkLoadersByChunks.put(ChunkPosition.of(loadedChunk), chunkLoader);
}
plugin.getNPCs().createNPC(location);
return chunkLoader;
}
@ -83,7 +85,9 @@ public final class LoadersHandler implements LoadersManager {
public void removeChunkLoader(ChunkLoader chunkLoader) {
Location location = chunkLoader.getLocation();
chunkLoaders.remove(location);
chunkLoadersByChunks.remove(ChunkPosition.of(location));
for (Chunk loadedChunk : chunkLoader.getLoadedChunks()) {
chunkLoadersByChunks.remove(ChunkPosition.of(loadedChunk));
}
chunkLoader.getNPC().ifPresent(npc -> plugin.getNPCs().killNPC(npc));
Query.DELETE_CHUNK_LOADER.insertParameters()
@ -92,9 +96,10 @@ public final class LoadersHandler implements LoadersManager {
}
@Override
public void createLoaderData(String name, long timeLeft, ItemStack itemStack) {
public LoaderData createLoaderData(String name, long timeLeft, ItemStack itemStack) {
LoaderData loaderData = new WLoaderData(name, timeLeft, itemStack);
loadersData.put(name, loaderData);
return loaderData;
}
@Override

View File

@ -1,14 +1,15 @@
package com.bgsoftware.wildloaders.handlers;
import com.bgsoftware.wildloaders.WildLoadersPlugin;
import com.bgsoftware.wildloaders.api.loaders.LoaderData;
import com.bgsoftware.wildloaders.utils.items.ItemBuilder;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -34,39 +35,40 @@ public final class SettingsHandler {
plugin.getLoaders().removeLoadersData();
for (String name : cfg.getConfigurationSection("chunkloaders").getKeys(false)) {
long timeLeft = cfg.getLong("chunkloaders." + name + ".time", 0);
ConfigurationSection loaderSection = cfg.getConfigurationSection("chunkloaders." + name);
long timeLeft = loaderSection.getLong("time", 0);
ItemBuilder itemBuilder = null;
try{
Material type = Material.valueOf(cfg.getString("chunkloaders." + name + ".type", ""));
short data = (short) cfg.getInt("chunkloaders." + name + ".data", 0);
Material type = Material.valueOf(loaderSection.getString("type", ""));
short data = (short) loaderSection.getInt("data", 0);
itemBuilder = new ItemBuilder(type, data);
if(cfg.contains("chunkloaders." + name + ".name"))
itemBuilder.setDisplayName(ChatColor.translateAlternateColorCodes('&',
cfg.getString("chunkloaders." + name + ".name")));
if(loaderSection.contains("name"))
itemBuilder.setDisplayName(ChatColor.translateAlternateColorCodes('&', loaderSection.getString("name")));
if(cfg.contains("chunkloaders." + name + ".lore")) {
if(loaderSection.contains("lore")) {
List<String> lore = new ArrayList<>();
cfg.getStringList("chunkloaders." + name + ".lore")
.forEach(line -> lore.add(ChatColor.translateAlternateColorCodes('&', line)));
loaderSection.getStringList("lore").forEach(line ->
lore.add(ChatColor.translateAlternateColorCodes('&', line)));
itemBuilder.setLore(lore);
}
if(cfg.contains("chunkloaders." + name + ".enchants")) {
for(String line : cfg.getStringList("chunkloaders." + name + ".enchants")){
if(loaderSection.contains("enchants")) {
for(String line : loaderSection.getStringList("enchants")){
Enchantment enchantment = Enchantment.getByName(line.split(":")[0]);
int level = Integer.parseInt(line.split(":")[1]);
itemBuilder.addEnchant(enchantment, level);
}
}
if(cfg.contains("chunkloaders." + name + ".skull")) {
itemBuilder.setTexture(cfg.getString("chunkloaders." + name + ".skull"));
if(loaderSection.contains("skull")) {
itemBuilder.setTexture(loaderSection.getString("skull"));
}
} catch(Exception ignored){}
@ -75,7 +77,11 @@ public final class SettingsHandler {
continue;
}
plugin.getLoaders().createLoaderData(name, timeLeft, itemBuilder.build());
LoaderData loaderData = plugin.getLoaders().createLoaderData(name, timeLeft, itemBuilder.build());
if(loaderSection.contains("chunks-radius"))
loaderData.setChunksRadius(loaderSection.getInt("chunks-radius"));
loadersAmount++;
}
@ -83,15 +89,4 @@ public final class SettingsHandler {
WildLoadersPlugin.log("Loading configuration done (Took " + (System.currentTimeMillis() - startTime) + "ms)");
}
public static void reload(){
try{
WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
Field settings = WildLoadersPlugin.class.getDeclaredField("settingsHandler");
settings.setAccessible(true);
settings.set(plugin, new SettingsHandler(plugin));
} catch(NoSuchFieldException | IllegalAccessException ex){
ex.printStackTrace();
}
}
}

View File

@ -7,11 +7,14 @@ import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import com.bgsoftware.wildloaders.utils.database.Query;
import com.bgsoftware.wildloaders.utils.threads.Executor;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@ -21,15 +24,17 @@ public final class WChunkLoader implements ChunkLoader {
private final UUID whoPlaced;
private final Location location;
private final Chunk[] loadedChunks;
private final String loaderName;
private boolean active = true;
private long timeLeft;
public WChunkLoader(String loaderName, UUID whoPlaced, Location location, long timeLeft){
this.loaderName = loaderName;
public WChunkLoader(LoaderData loaderData, UUID whoPlaced, Location location, long timeLeft){
this.loaderName = loaderData.getName();
this.whoPlaced = whoPlaced;
this.location = location.clone();
this.loadedChunks = calculateChunks(loaderData, this.location);
this.timeLeft = timeLeft;
plugin.getNMSAdapter().createLoader(this);
}
@ -73,6 +78,11 @@ public final class WChunkLoader implements ChunkLoader {
return location.clone();
}
@Override
public Chunk[] getLoadedChunks() {
return loadedChunks;
}
@Override
public Optional<ChunkLoaderNPC> getNPC() {
return plugin.getNPCs().getNPC(location);
@ -97,4 +107,16 @@ public final class WChunkLoader implements ChunkLoader {
return plugin.getNMSAdapter().setTag(itemStack, "loader-time", getTimeLeft());
}
private static Chunk[] calculateChunks(LoaderData loaderData, Location original){
List<Chunk> chunkList = new ArrayList<>();
int chunkX = original.getBlockX() >> 4, chunkZ = original.getBlockZ() >> 4;
for(int x = -loaderData.getChunksRadius(); x <= loaderData.getChunksRadius(); x++)
for(int z = -loaderData.getChunksRadius(); z <= loaderData.getChunksRadius(); z++)
chunkList.add(original.getWorld().getChunkAt(chunkX + x, chunkZ + z));
return chunkList.toArray(new Chunk[0]);
}
}

View File

@ -12,10 +12,13 @@ public final class WLoaderData implements LoaderData {
private final long timeLeft;
private final ItemStack loaderItem;
private int chunksRadius;
public WLoaderData(String name, long timeLeft, ItemStack loaderItem){
this.name = name;
this.timeLeft = timeLeft;
this.loaderItem = plugin.getNMSAdapter().setTag(loaderItem, "loader-name", name);
this.chunksRadius = 0;
}
@Override
@ -32,4 +35,15 @@ public final class WLoaderData implements LoaderData {
public ItemStack getLoaderItem() {
return loaderItem.clone();
}
@Override
public void setChunksRadius(int chunksRadius) {
this.chunksRadius = chunksRadius;
}
@Override
public int getChunksRadius() {
return chunksRadius;
}
}

View File

@ -2,7 +2,6 @@ package com.bgsoftware.wildloaders.nms;
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;

View File

@ -2,6 +2,7 @@ package com.bgsoftware.wildloaders.utils.chunks;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import java.util.Objects;
@ -56,4 +57,8 @@ public final class ChunkPosition {
return new ChunkPosition(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
}
public static ChunkPosition of(World world, int chunkX, int chunkZ){
return new ChunkPosition(world.getName(), chunkX, chunkZ);
}
}

View File

@ -18,4 +18,12 @@ chunkloaders:
name: '&6Chunk Loader &7(Place to load)'
lore:
- '&7Place this chunk loader to keep'
- '&7the chunk loaded in the next 24 hours!'
- '&7the chunk loaded in the next 24 hours!'
large_loader:
time: 86400
type: BEACON
chunks-radius: 2 # This will load all chunks in a radius of 2, aka 5x5 chunks
name: '&6Large Chunk Loader &7(Place to load)'
lore:
- '&7Place this chunk loader to keep all chunks'
- '&7in a radius of 2 loaded in the next 24 hours!'

View File

@ -123,13 +123,15 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
}
}
@Override
@ -149,13 +151,15 @@ public final class NMSAdapter_v1_10_R1 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
}
}
@Override

View File

@ -123,13 +123,15 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
}
}
@Override
@ -149,13 +151,15 @@ public final class NMSAdapter_v1_11_R1 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
}
}
@Override

View File

@ -132,18 +132,20 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
try {
compoundLoadMethod.invoke(tileEntity, nbtTagCompound);
}catch (Throwable ex){
tileEntity.a(nbtTagCompound);
}
});
try {
compoundLoadMethod.invoke(tileEntity, nbtTagCompound);
} catch (Throwable ex) {
tileEntity.a(nbtTagCompound);
}
});
}
}
@Override
@ -163,18 +165,20 @@ public final class NMSAdapter_v1_12_R1 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
try {
compoundLoadMethod.invoke(tileEntity, nbtTagCompound);
}catch (Throwable ex){
tileEntity.a(nbtTagCompound);
}
});
try {
compoundLoadMethod.invoke(tileEntity, nbtTagCompound);
} catch (Throwable ex) {
tileEntity.a(nbtTagCompound);
}
});
}
}
@Override

View File

@ -125,9 +125,11 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
}
}
@Override
@ -147,9 +149,11 @@ public final class NMSAdapter_v1_13_R1 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
}
}
@Override

View File

@ -125,9 +125,11 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
}
}
@Override
@ -147,9 +149,11 @@ public final class NMSAdapter_v1_13_R2 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
}
}
@Override

View File

@ -128,11 +128,13 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
}
}
@Override
@ -153,11 +155,13 @@ public final class NMSAdapter_v1_14_R1 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
}
}
@Override

View File

@ -128,11 +128,13 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
}
}
@Override
@ -153,11 +155,13 @@ public final class NMSAdapter_v1_15_R1 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, false);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, false);
}
}
@Override

View File

@ -129,11 +129,13 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
}
}
@Override
@ -154,11 +156,13 @@ public final class NMSAdapter_v1_16_R1 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, false);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, false);
}
}
@Override

View File

@ -129,11 +129,13 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
}
}
@Override
@ -154,11 +156,13 @@ public final class NMSAdapter_v1_16_R2 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
}
}
@Override

View File

@ -118,14 +118,16 @@ public final class NMSAdapter_v1_7_R3 implements NMSAdapter {
//noinspection unchecked
world.tileEntityList.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
((TileEntity) tileEntity).a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()){
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
((TileEntity) tileEntity).a(nbtTagCompound);
});
}
}
@Override
@ -144,14 +146,16 @@ public final class NMSAdapter_v1_7_R3 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, x, y, z, Block.b(world.getType(x, y, z)) + (world.getData(x, y, z) << 12));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
((TileEntity) tileEntity).a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()){
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
((TileEntity) tileEntity).a(nbtTagCompound);
});
}
}
@Override

View File

@ -118,14 +118,16 @@ public final class NMSAdapter_v1_7_R4 implements NMSAdapter {
//noinspection unchecked
world.tileEntityList.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
((TileEntity) tileEntity).a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
((TileEntity) tileEntity).a(nbtTagCompound);
});
}
}
@Override
@ -144,14 +146,16 @@ public final class NMSAdapter_v1_7_R4 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, x, y, z, Block.getId(world.getType(x, y, z)) + (world.getData(x, y, z) << 12));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
((TileEntity) tileEntity).a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
((TileEntity) tileEntity).a(nbtTagCompound);
});
}
}
@Override

View File

@ -124,14 +124,16 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter {
//noinspection unchecked
world.tileEntityList.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
((TileEntity) tileEntity).a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
((TileEntity) tileEntity).a(nbtTagCompound);
});
}
}
@Override
@ -151,14 +153,16 @@ public final class NMSAdapter_v1_8_R1 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
((TileEntity) tileEntity).a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
//noinspection unchecked
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
((TileEntity) tileEntity).b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
((TileEntity) tileEntity).a(nbtTagCompound);
});
}
}
@Override

View File

@ -123,13 +123,15 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityList.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
}
}
@Override
@ -149,13 +151,15 @@ public final class NMSAdapter_v1_8_R2 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
}
}
@Override

View File

@ -123,13 +123,15 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityList.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
}
}
@Override
@ -149,13 +151,15 @@ public final class NMSAdapter_v1_8_R3 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
}
}
@Override

View File

@ -123,13 +123,15 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
}
}
@Override
@ -149,13 +151,15 @@ public final class NMSAdapter_v1_9_R1 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
}
}
@Override

View File

@ -123,13 +123,15 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter {
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
world.tileEntityListTick.add(tileEntityChunkLoader);
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) -1);
tileEntity.a(nbtTagCompound);
});
}
}
@Override
@ -149,13 +151,15 @@ public final class NMSAdapter_v1_9_R2 implements NMSAdapter {
if(spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
Chunk chunk = ((CraftChunk) loaderLoc.getChunk()).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.save(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
}
}
@Override