ColinHDev / CPlot

Land and world management plugin for PocketMine-MP
https://discord.gg/cAYKEtaqnp
GNU General Public License v3.0
29 stars 12 forks source link

Participating in Hacktoberfest #62

Closed ColinHDev closed 2 years ago

ColinHDev commented 2 years ago

I added the Hacktoberfest topic to the repository, so if anybody is interested in that, feel free to contribute.

inxomnyaa commented 2 years ago

The event is almost over, haven't discovered the repo on time. Yet i wanted to ask if you would mind MagicWE2 integration in CPlot. I've created something similar for MyPlot a long time ago: MWEEMyPlot As i am not familiar with the code of CPlot yet, i'd like to ask about some things first:

ColinHDev commented 2 years ago
inxomnyaa commented 2 years ago

The async methods might cause issues with MWE2's event handling, as it is not "waiting" for a method outcome Does the plot merging combine multiple plots into one Plot object? I guess for a basic version i could just copy the code from the BlockPlaceListener in order to handle selections. Having no distinct allowed shapes might complicate things

ColinHDev commented 2 years ago

That would be up to you whether you want to allow multi-plot edits. It would be up to you to check if the player has build permissions inside all areas of the selection.

Since I also needed to handle PocketMine-MP's events, I had to figure something out to make the async database design work with the sync event handling:

$plot = $this->getAPI()->getOrLoadPlotAtPosition($position)->getResult();

While getOrLoadPlotAtPosition() returns a Promise, it might already have a result if data about the plot is cached. If this is the case, the getResult() method returns the cached data or null otherwise. If no data is cached, the event is cancelled. (A query is run in the background, so the next time the event is called, the data might be already in the cache.) This is used in all the event listeners, so you could use the same.

When plots are merged, one plot is the "origin plot", while all others are only considered "merge plots". So, if you call e.g. the isOnPlot() method on a plot instance, you can be sure that it also checks all the merged plots and the roads in between.

I didn't put a lot of thought into this, but I'm not sure if it really complicates things. The only thing you would have to do is verify if a player has build permissions throughout all areas of the selection and skip sections if otherwise.