Introduce support for Translatable disconnection messages

this allows localizing disconnection screens (at least, once #4512 has been addressed) and the disconnect reasons shown on the console.

We already had disconnect messages implicitly localized in a few places, so this is just formalizing it.
This does break BC with any code that previously passed translation keys as the disconnect screen message, because they'll no longer be translated (only Translatables will be translatated now).
This commit is contained in:
Dylan K. Taylor
2022-12-27 18:36:07 +00:00
parent 9796dfd4d9
commit f173b91ca1
11 changed files with 86 additions and 55 deletions

View File

@ -23,7 +23,7 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\handler;
use pocketmine\lang\KnownTranslationKeys;
use pocketmine\lang\KnownTranslationFactory;
use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
@ -86,7 +86,7 @@ class ResourcePacksPacketHandler extends PacketHandler{
private function disconnectWithError(string $error) : void{
$this->session->getLogger()->error("Error downloading resource packs: " . $error);
$this->session->disconnect(KnownTranslationKeys::DISCONNECTIONSCREEN_RESOURCEPACK);
$this->session->disconnect(KnownTranslationFactory::disconnectionScreen_resourcePack());
}
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool{