Skip to content

Commit

Permalink
Updated to API 3 & Patched index bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonw4331 committed Jan 8, 2020
1 parent 99cda42 commit 2dc8eb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
name: PlayerSelectors
author: Ad5001
version: 1.0
api: [3.0.0-ALPHA9]
main: Ad5001\PlayerSelectors\Main
commands: []
permissions: []
...
author: Ad5001
version: 1.0.0
api:
- 3.0.0
main: Ad5001\PlayerSelectors\Main
6 changes: 3 additions & 3 deletions src/Ad5001/PlayerSelectors/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public function execSelectors(string $m, CommandSender $sender): bool{
$params = self::$selectors[$matches[1][$index]]->acceptsModifiers() ? $this->checkArgParams($matches, $index): [];
// Applying the selector
$newCommandsToExecute = [];
foreach($commandsToExecute as $index => $cmd){
foreach($commandsToExecute as $indexB => $cmd){
// Foreaching the returning commands to push them to the new commands to be executed at the next run.
foreach(self::$selectors[$matches[1][$index]]->applySelector($sender, $params) as $selectorStr){
foreach(self::$selectors[$matches[1][$indexB]]->applySelector($sender, $params) as $selectorStr){
if(strpos($selectorStr, " ") !== -1) $selectorStr = explode(" ", $selectorStr)[count(explode(" ", $selectorStr)) - 1]; // Name w/ spaces. Match the nearest name in the player. Not perfect :/
$newCommandsToExecute[] = substr_replace($cmd, " " . $selectorStr . " ", strpos($cmd, $match), strlen($match));
}
if(count($newCommandsToExecute) == 0) {
$sender->sendMessage("§cYour selector $match (" . self::$selectors[$matches[1][$index]]->getName() . ") did not mactch any player/entity.");
$sender->sendMessage("§cYour selector $match (" . self::$selectors[$matches[1][$indexB]]->getName() . ") did not match any player/entity.");
return true;
}
}
Expand Down

2 comments on commit 2dc8eb7

@kamiinar1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, but please raise API up to 4.0.0+
A lot of servers that use Pocketmine 4.0 will need to use this plugin, and it would be great if it was updated

@jasonw4331
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated repository for poggit is located at https://github.com/poggit-orphanage/PlayerSelectors

Please sign in to comment.