emoji checks for say, tell and me

This commit is contained in:
GameHerobrine 2025-05-09 10:09:41 +03:00
parent 1370ccf6b4
commit 21fc67cf1a

View file

@ -35,6 +35,7 @@ class ChatAPI{
break; break;
} }
$sender = ($issuer instanceof Player) ? "Server" : ucfirst($issuer); $sender = ($issuer instanceof Player) ? "Server" : ucfirst($issuer);
if(Utils::hasEmoji($s)) return "Your message contains illegal characters!";
$this->server->api->chat->broadcast("[$sender] " . $s); $this->server->api->chat->broadcast("[$sender] " . $s);
break; break;
case "me": case "me":
@ -52,7 +53,9 @@ class ChatAPI{
}else{ }else{
$sender = $issuer->username; $sender = $issuer->username;
} }
$this->broadcast("* $sender " . implode(" ", $params)); $msg = implode(" ", $params);
if(Utils::hasEmoji($msg)) return "Your message contains illegal characters!";
$this->broadcast("* $sender $msg");
break; break;
case "tell": case "tell":
if(!isset($params[0]) or !isset($params[1])){ if(!isset($params[0]) or !isset($params[1])){
@ -80,6 +83,7 @@ class ChatAPI{
return "You can't send message to yourself."; return "You can't send message to yourself.";
} }
$mes = implode(" ", $params); $mes = implode(" ", $params);
if(Utils::hasEmoji($mes)) return "Your message contains illegal characters!";
$output .= "You're whispering to " . $target . ": " . $mes . "\n"; $output .= "You're whispering to " . $target . ": " . $mes . "\n";
if($target !== "Console" and $target !== "Rcon"){ if($target !== "Console" and $target !== "Rcon"){
$this->sendTo(false, $sender . " whispers to you: " . $mes, $target); $this->sendTo(false, $sender . " whispers to you: " . $mes, $target);