Why do we use multiple files in each plugin, why not just use Main? If I put the code of an entire CORE in 1 main file the server gets less lagged? How would be the best way to program pocketmine plugins to get less lag?
1. For simple plugins, it may be better to place all your code in one file. However, for larger plugins, splitting code up into different files and classes makes your code easier to read and understand. 2. There is no simple way to go about optimizing slow running plugins. Some general suggestions would be to put slow operations into an AsyncTask or cutting down on world I/O.
They are not called "files". They are called "classes". Indeed, there is no reason (except for code organization) to make classes like EventListener; most people do it just because it "sounds cool" without understanding the true impacts [citation needed]. There are also classes that make data structures, or files that declare interfaces and let other classes implement. This is related to object oriented programming, and there are many articles on the Internet if you want to know more. The number of files has almost no impact on performance. Mixing files will have no impact on the server's performance except probably a few milliseconds when the server starts (or even unnecessarily slower because of loading unused classes).