public function onChat(PlayerChatEvent $e){
if ($e->isCancelled()) return;
$pw = $e->getPlayer();
// Non players are handled normally
if (!($pw instanceof Player)) return;
$msg = $e->getMessage();
if (substr($msg,0,1) == ":") {
// This messages goes to everybody on the server...
// no need to do much...
if (!$this->access($pw,"localchat.broadcast.server")) {
$e->setCancelled();
return;
}
$e->setMessage(substr($msg,1));
return;
}
how to change the color of the message?
public function onChat(PlayerChatEvent $e){ if ($e->isCancelled()) return; $pw = $e->getPlayer(); // Non players are handled normally if (!($pw instanceof Player)) return; $msg = $e->getMessage(); if (substr($msg,0,1) == ":") { // This messages goes to everybody on the server... // no need to do much... if (!$this->access($pw,"localchat.broadcast.server")) { $e->setCancelled(); return; } $e->setMessage(substr($msg,1)); return; }