forked from Ad5001/PlayerSelectors
Fix bug with variable name collisions
This commit is contained in:
parent
c9632dd62c
commit
bba3ec86d2
1 changed files with 3 additions and 3 deletions
|
@ -83,14 +83,14 @@ class Main extends PluginBase implements Listener {
|
||||||
$params = self::$selectors[$matches[1][$index]]->acceptsModifiers() ? $this->checkArgParams($matches, $index): [];
|
$params = self::$selectors[$matches[1][$index]]->acceptsModifiers() ? $this->checkArgParams($matches, $index): [];
|
||||||
// Applying the selector
|
// Applying the selector
|
||||||
$newCommandsToExecute = [];
|
$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.
|
// 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 :/
|
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));
|
$newCommandsToExecute[] = substr_replace($cmd, " " . $selectorStr . " ", strpos($cmd, $match), strlen($match));
|
||||||
}
|
}
|
||||||
if(count($newCommandsToExecute) == 0) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue