mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Added player commands, better console API and implemented future player chat
This commit is contained in:
parent
72388fa3cb
commit
c2e55941d8
6 changed files with 186 additions and 131 deletions
|
|
@ -374,12 +374,19 @@ class Player{
|
|||
}else{
|
||||
$message = (string) $data;
|
||||
}
|
||||
$this->dataPacket(MC_CHAT, array(
|
||||
"message" => str_replace("@username", $this->username, $message),
|
||||
));
|
||||
$this->sendChat($message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function sendChat($message){
|
||||
$mes = explode("\n", $message);
|
||||
foreach($mes as $m){
|
||||
$this->dataPacket(MC_CHAT, array(
|
||||
"message" => str_replace("@username", $this->username, $m),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function handle($pid, $data){
|
||||
if($this->connected === true){
|
||||
|
|
@ -724,6 +731,16 @@ class Player{
|
|||
}
|
||||
}
|
||||
break;
|
||||
case MC_CHAT:
|
||||
$message = $data["message"];
|
||||
if($message{0} === "/"){ //Command
|
||||
$this->server->api->console->run(substr($message, 1), $this);
|
||||
}else{
|
||||
if($this->server->api->dhandle("player.chat", array("player" => $this, "message" => $message)) !== false){
|
||||
$this->server->api->send($this, $message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console("[DEBUG] Unhandled 0x".dechex($data["id"])." Data Packet for Client ID ".$this->clientID.": ".print_r($data, true), true, true, 2);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue