Skip to content

Commit

Permalink
Removed selectors on Player->sendMessage()
Browse files Browse the repository at this point in the history
  • Loading branch information
shoghicp committed Oct 6, 2014
1 parent 35de331 commit b6025e3
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -2220,29 +2220,11 @@ public function kick($reason = ""){
public function sendMessage($message){
$mes = explode("\n", $message);
foreach($mes as $m){
if(preg_match_all('#@([@A-Za-z_]{1,})#', $m, $matches, PREG_OFFSET_CAPTURE) > 0){
$offsetshift = 0;
foreach($matches[1] as $selector){
if($selector[0]{0} === "@"){ //Escape!
$m = substr_replace($m, $selector[0], $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
--$offsetshift;
continue;
}
switch(strtolower($selector[0])){
case "player":
case "username":
$m = substr_replace($m, $this->username, $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
$offsetshift += strlen($selector[0]) - strlen($this->username) + 1;
break;
}
}
}
if($m !== ""){
$pk = new MessagePacket;
$pk->source = ""; //Do not use this ;)
$pk->message = $this->removeFormat === false ? $m : TextFormat::clean($m);
$this->directDataPacket($pk);
$this->dataPacket($pk);
}
}
}
Expand Down

0 comments on commit b6025e3

Please sign in to comment.