Add missing blocks

This commit is contained in:
mathiascode 2019-10-03 19:30:18 +03:00
parent 1796124bc1
commit 9ec1c32b17
3 changed files with 62 additions and 15 deletions

View file

@ -514,7 +514,28 @@ public class Main extends JavaPlugin {
Material.HORN_CORAL,
Material.TUBE_CORAL,
Material.SEA_PICKLE,
Material.KELP
Material.KELP,
Material.POTTED_ACACIA_SAPLING,
Material.POTTED_ALLIUM,
Material.POTTED_AZURE_BLUET,
Material.POTTED_BIRCH_SAPLING,
Material.POTTED_BLUE_ORCHID,
Material.POTTED_BROWN_MUSHROOM,
Material.POTTED_CACTUS,
Material.POTTED_DANDELION,
Material.POTTED_DARK_OAK_SAPLING,
Material.POTTED_DEAD_BUSH,
Material.POTTED_FERN,
Material.POTTED_JUNGLE_SAPLING,
Material.POTTED_OAK_SAPLING,
Material.POTTED_ORANGE_TULIP,
Material.POTTED_OXEYE_DAISY,
Material.POTTED_PINK_TULIP,
Material.POTTED_POPPY,
Material.POTTED_RED_MUSHROOM,
Material.POTTED_RED_TULIP,
Material.POTTED_SPRUCE_SAPLING,
Material.POTTED_WHITE_TULIP
);
Collections.addAll(

View file

@ -76,6 +76,32 @@ class BlockPhysics implements Listener {
if (material == Material.FARMLAND) {
event.setCancelled(true);
} else if (material == Material.LAVA ||
material == Material.WATER) {
final Block block = event.getBlock();
final World world = block.getWorld();
final int radius = 5;
int blockCount = 0;
for (int x = -radius; x <= radius; x++) {
for (int y = -radius; y <= radius; y++) {
for (int z = -radius; z <= radius; z++) {
if (blockCount < 500) {
final Location blockLocation = new Location(world, block.getX() + x, block.getY() + y, block.getZ() + z);
final Block coordBlock = world.getBlockAt(blockLocation);
if (coordBlock.getType() == Material.LAVA ||
coordBlock.getType() == Material.WATER ||
coordBlock.getType() == Material.OBSIDIAN) {
blockCount++;
}
continue;
}
break;
}
}
}
} else if (Main.nonSolidWallMountedBlockList.contains(material)) {
final Block block = event.getBlock();
final World world = block.getWorld();

View file

@ -25,6 +25,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
@ -48,20 +49,6 @@ class PlayerConnection implements Listener {
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username can't be longer than 16 characters");
return;
}
/*for (final World world : Bukkit.getWorlds()) {
for (final Chunk chunk : world.getLoadedChunks()) {
try {
chunk.getTileEntities(false);
} catch (Exception exception) {
new BukkitRunnable() {
public void run() {
world.regenerateChunk(chunk.getX(), chunk.getZ());
}
}.runTask(main);
}
}
}*/
}
@EventHandler
@ -154,4 +141,17 @@ class PlayerConnection implements Listener {
}
});
}
@EventHandler
void onPlayerQuit(PlayerQuitEvent event) {
final World world = event.getPlayer().getWorld();
for (final Chunk chunk : world.getLoadedChunks()) {
try {
if (chunk.getTileEntities(false).length == 0);
} catch (Exception exception) {
world.regenerateChunk(chunk.getX(), chunk.getZ());
}
}
}
}