CortexPE / Commando

A Command Framework virion for PocketMine-MP
GNU Lesser General Public License v3.0
70 stars 53 forks source link

Selectors #10

Open CortexPE opened 5 years ago

CortexPE commented 5 years ago

How should this work... literally.

The only thing that I can think of that would be "good enough" is a separate SelectableEntityArgument class which would be parsed and the results will be an array of results.

The array will contain entities that satisfied the conditions given by the user... such as name, limit, etc.

This would also involve running onRun several times for each argument that is selectable and for each of its results. Then $args["argumentName"] will contain an entity for every iteration.

This is a simply but effective way of doing it, but I still have some thoughts that it's dirty.

Leave suggestions below...

CortexPE commented 5 years ago

There should also be selectable block positions / vector3 positions... ree

This one should be done on Vector3Argument

lukeeey commented 5 years ago

Why would you run onRun() multiple times? Just return the array of entities in the argument class and the command can loop over them or whatever?

CortexPE commented 5 years ago

Sure, that'd be better

jasonw4331 commented 5 years ago

ad5001 already implemented this sometime ago Maybe his project can provide some answers https://github.com/Ad5001/PlayerSelectors

CortexPE commented 5 years ago

It's unreadable :joy:

https://github.com/Ad5001/PlayerSelectors/blob/master/src/Ad5001/PlayerSelectors/selector/Selector.php#L105-L122 why doesn't github show code snippets smfh

I might implement a way to build your own parsers and selectors... and the default provided TargetArgument will have the vanilla ones. for the sake of customizability and extensibility