mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 00:39:45 +00:00
Merge commit '62ea7c93a9ba1e71bef868efefdd9cc6dcc84a08'
# Conflicts: # resources/vanilla # src/entity/Skin.php # src/item/InvalidSkinException.php
This commit is contained in:
commit
14d3e5ce27
28
src/entity/InvalidSkinException.php
Normal file
28
src/entity/InvalidSkinException.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\entity;
|
||||||
|
|
||||||
|
final class InvalidSkinException extends \InvalidArgumentException{
|
||||||
|
|
||||||
|
}
|
@ -50,20 +50,20 @@ final class Skin{
|
|||||||
|
|
||||||
public function __construct(string $skinId, string $skinData, string $capeData = "", string $geometryName = "", string $geometryData = ""){
|
public function __construct(string $skinId, string $skinData, string $capeData = "", string $geometryName = "", string $geometryData = ""){
|
||||||
if($skinId === ""){
|
if($skinId === ""){
|
||||||
throw new \InvalidArgumentException("Skin ID must not be empty");
|
throw new InvalidSkinException("Skin ID must not be empty");
|
||||||
}
|
}
|
||||||
$len = strlen($skinData);
|
$len = strlen($skinData);
|
||||||
if(!in_array($len, self::ACCEPTED_SKIN_SIZES, true)){
|
if(!in_array($len, self::ACCEPTED_SKIN_SIZES, true)){
|
||||||
throw new \InvalidArgumentException("Invalid skin data size $len bytes (allowed sizes: " . implode(", ", self::ACCEPTED_SKIN_SIZES) . ")");
|
throw new InvalidSkinException("Invalid skin data size $len bytes (allowed sizes: " . implode(", ", self::ACCEPTED_SKIN_SIZES) . ")");
|
||||||
}
|
}
|
||||||
if($capeData !== "" and strlen($capeData) !== 8192){
|
if($capeData !== "" and strlen($capeData) !== 8192){
|
||||||
throw new \InvalidArgumentException("Invalid cape data size " . strlen($capeData) . " bytes (must be exactly 8192 bytes)");
|
throw new InvalidSkinException("Invalid cape data size " . strlen($capeData) . " bytes (must be exactly 8192 bytes)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($geometryData !== ""){
|
if($geometryData !== ""){
|
||||||
$decodedGeometry = (new CommentedJsonDecoder())->decode($geometryData);
|
$decodedGeometry = (new CommentedJsonDecoder())->decode($geometryData);
|
||||||
if($decodedGeometry === false){
|
if($decodedGeometry === false){
|
||||||
throw new \InvalidArgumentException("Invalid geometry data (" . json_last_error_msg() . ")");
|
throw new InvalidSkinException("Invalid geometry data (" . json_last_error_msg() . ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user