Is there any way I can get how many blocks in one world? Ex: I want to know how many blocks of glass have in my world, Any way to do that?
Do a foreach PHP: foreach($whereblocksyouwanttocount as $blocks){ Then, when you are sending a message or anything else, add this : PHP: count($blocks);
If you want to scan the whole world and cause the server to freeze for hours, you could foreach the blocks. You might be better of using an async task with the region files.
Mind thinking before answering? One main point is what to foreach, where you get the $blocks array from. Apparently, it is an enormous bulk of data and you won't want to get them all from a single array.
It seems that it's quite difficult to do this asynchronous. It is possible, but it's either ineffective (such that it's barely better than or even worse than doing it synchronously), or you have to write your own level parser, both bad ideas. I would suggest that you first count the blocks in loaded memory, and then search generated levels in the world (if you want generated but unloaded chunks too), then load and count and then unload them one by one. Don't load everything together, because the server memory may exhaust when all levels are loaded. You may check the time after every operation, and leave the rest to execute in the next tick, but this is quite complicated. See PEMapModder's WorldEditArt plugin for example of separating loops to ticks -- really got him a big head. So if you just want to count the blocks for personal use, I recommend not trying to do it in a plugin, or at least, not try to make it a command that you use frequently