mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
added ability to disable emojis on signs
This commit is contained in:
parent
69d3321e16
commit
ccdea98d28
6 changed files with 21 additions and 3 deletions
|
|
@ -36,7 +36,7 @@ class ChatAPI{
|
|||
return "Usage: /say <message>";
|
||||
}
|
||||
$sender = ($issuer instanceof Player) ? "Server" : ucfirst($issuer);
|
||||
if(Utils::hasEmoji($s)) return "Your message contains illegal characters!";
|
||||
if(Player::$disableEmojisInChat && Utils::hasEmoji($s)) return "Your message contains illegal characters!";
|
||||
$this->server->api->chat->broadcast("[$sender] " . $s);
|
||||
break;
|
||||
case "me":
|
||||
|
|
@ -54,7 +54,7 @@ class ChatAPI{
|
|||
$sender = $issuer->username;
|
||||
}
|
||||
$msg = implode(" ", $params);
|
||||
if(Utils::hasEmoji($msg)) return "Your message contains illegal characters!";
|
||||
if(Player::$disableEmojisInChat && Utils::hasEmoji($msg)) return "Your message contains illegal characters!";
|
||||
$this->broadcast("* $sender $msg");
|
||||
break;
|
||||
case "tell":
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ class Player{
|
|||
|
||||
public static $experimentalHotbar = false;
|
||||
public static $allowDroppingSingleItems = true;
|
||||
public static $disableEmojisInChat = true;
|
||||
/** @var Config */
|
||||
public $data;
|
||||
/** @var Entity */
|
||||
|
|
@ -2502,7 +2503,7 @@ class Player{
|
|||
$this->server->api->console->run(substr($message, 1), $this);
|
||||
}else{
|
||||
$data = ["player" => $this, "message" => $message];
|
||||
if(Utils::hasEmoji($data["message"])){
|
||||
if(Player::$disableEmojisInChat && Utils::hasEmoji($data["message"])){
|
||||
$this->sendChat("Your message contains illegal characters");
|
||||
break;
|
||||
}
|
||||
|
|
@ -2712,6 +2713,7 @@ class Player{
|
|||
if($d["id"] !== TILE_SIGN){
|
||||
$t->spawn($this);
|
||||
}else{
|
||||
|
||||
$t->setText($d["Text1"], $d["Text2"], $d["Text3"], $d["Text4"]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,8 +94,12 @@ class PocketMinecraftServer{
|
|||
"keep-chunks-loaded" => self::$KEEP_CHUNKS_LOADED,
|
||||
"use-experimental-hotbar" => Player::$experimentalHotbar,
|
||||
"keep-items-on-death" => Entity::$keepInventory,
|
||||
"disable-emojis-in-chat" => Player::$disableEmojisInChat,
|
||||
"disable-emojis-on-signs" => Level::$disableEmojisOnSigns,
|
||||
//"allow-dropping-single-items" => Player::$allowDroppingSingleItems
|
||||
]);
|
||||
Player::$disableEmojisInChat = $this->extraprops->get("disable-emojis-in-chat");
|
||||
Level::$disableEmojisOnSigns = $this->extraprops->get("disable-emojis-on-signs");
|
||||
Entity::$keepInventory = $this->extraprops->get("keep-items-on-death");
|
||||
Player::$experimentalHotbar = $this->extraprops->get("use-experimental-hotbar");
|
||||
//Player::$allowDroppingSingleItems = $this->extraprops->get("allow-dropping-single-items");
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ class Utils{
|
|||
return preg_match(Utils::emojiRegex, $s);
|
||||
}
|
||||
|
||||
public static function replaceEmoji($s){
|
||||
return preg_replace(Utils::emojiRegex, " ", $s);
|
||||
}
|
||||
|
||||
public static function getCallableIdentifier(callable $variable){
|
||||
if(is_array($variable)){
|
||||
return sha1(strtolower(get_class($variable[0])) . "::" . strtolower($variable[1]));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Level{
|
||||
public static $disableEmojisOnSigns = true;
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -429,6 +429,13 @@ class Tile extends Position{
|
|||
if($this->class !== TILE_SIGN){
|
||||
return false;
|
||||
}
|
||||
if(Level::$disableEmojisOnSigns){
|
||||
$line1 = Utils::replaceEmoji($line1);
|
||||
$line2 = Utils::replaceEmoji($line2);
|
||||
$line3 = Utils::replaceEmoji($line3);
|
||||
$line4 = Utils::replaceEmoji($line4);
|
||||
|
||||
}
|
||||
$this->data["Text1"] = $line1;
|
||||
$this->data["Text2"] = $line2;
|
||||
$this->data["Text3"] = $line3;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue