mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Removed @deprecated classes, methods and properties, added some type hints
This commit is contained in:
@ -1,86 +0,0 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\utils;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class Cache{
|
||||
public static $cached = [];
|
||||
|
||||
/**
|
||||
* Adds something to the cache
|
||||
*
|
||||
* @param string $identifier
|
||||
* @param mixed $blob
|
||||
* @param float|int $minTTL The data will remain cached for at least $minTTL seconds
|
||||
*/
|
||||
public static function add($identifier, $blob, $minTTL = 30){
|
||||
self::$cached[$identifier] = [$blob, microtime(true) + $minTTL, $minTTL];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get something from the cache
|
||||
*
|
||||
* @param $identifier
|
||||
*
|
||||
* @return bool|mixed Returns false if not found, otherwise it returns the data
|
||||
*/
|
||||
public static function get($identifier){
|
||||
if(isset(self::$cached[$identifier])){
|
||||
self::$cached[$identifier][1] = microtime(true) + self::$cached[$identifier][2];
|
||||
|
||||
return self::$cached[$identifier][0];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $identifier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function exists($identifier){
|
||||
return isset(self::$cached[$identifier]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $identifier
|
||||
*/
|
||||
public static function remove($identifier){
|
||||
unset(self::$cached[$identifier]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a cache cleanup
|
||||
*/
|
||||
public static function cleanup(){
|
||||
$time = microtime(true);
|
||||
foreach(self::$cached as $index => $data){
|
||||
if($data[1] < $time){
|
||||
unset(self::$cached[$index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -321,46 +321,6 @@ class Config{
|
||||
return ($this->correct and isset($this->config[$k])) ? $this->config[$k] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPath($path){
|
||||
$currPath =& $this->config;
|
||||
foreach(explode(".", $path) as $component){
|
||||
if(isset($currPath[$component])){
|
||||
$currPath =& $currPath[$component];
|
||||
}else{
|
||||
$currPath = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $currPath;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @param string $path
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setPath($path, $value){
|
||||
$currPath =& $this->config;
|
||||
$components = explode(".", $path);
|
||||
$final = array_pop($components);
|
||||
foreach($components as $component){
|
||||
if(!isset($currPath[$component])){
|
||||
$currPath[$component] = [];
|
||||
}
|
||||
$currPath =& $currPath[$component];
|
||||
}
|
||||
$currPath[$final] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $k key to be set
|
||||
* @param mixed $v value to set key
|
||||
|
@ -1,93 +0,0 @@
|
||||
<?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/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\utils;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
abstract class TextWrapper{
|
||||
|
||||
private static $characterWidths = [
|
||||
4, 2, 5, 6, 6, 6, 6, 3, 5, 5, 5, 6, 2, 6, 2, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 5, 6, 5, 6,
|
||||
7, 6, 6, 6, 6, 6, 6, 6, 6, 4, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 6, 4, 6, 6,
|
||||
6, 6, 6, 6, 6, 5, 6, 6, 2, 6, 5, 3, 6, 6, 6, 6,
|
||||
6, 6, 6, 4, 6, 6, 6, 6, 6, 6, 5, 2, 5, 7
|
||||
];
|
||||
|
||||
const CHAT_WINDOW_WIDTH = 240;
|
||||
const CHAT_STRING_LENGTH = 119;
|
||||
|
||||
private static $allowedChars = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
|
||||
private static $allowedCharsArray = [];
|
||||
|
||||
public static function init(){
|
||||
self::$allowedCharsArray = [];
|
||||
$len = strlen(self::$allowedChars);
|
||||
for($i = 0; $i < $len; ++$i){
|
||||
self::$allowedCharsArray[self::$allowedChars{$i}] = self::$characterWidths[$i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* @param $text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function wrap($text){
|
||||
$result = "";
|
||||
$len = strlen($text);
|
||||
$lineWidth = 0;
|
||||
$lineLength = 0;
|
||||
|
||||
for($i = 0; $i < $len; ++$i){
|
||||
$char = $text{$i};
|
||||
|
||||
if($char === "\n"){
|
||||
$lineLength = 0;
|
||||
$lineWidth = 0;
|
||||
}elseif(isset(self::$allowedCharsArray[$char])){
|
||||
$width = self::$allowedCharsArray[$char];
|
||||
|
||||
if($lineLength + 1 > self::CHAT_STRING_LENGTH or $lineWidth + $width > self::CHAT_WINDOW_WIDTH){
|
||||
$result .= "\n";
|
||||
$lineLength = 0;
|
||||
$lineWidth = 0;
|
||||
}
|
||||
|
||||
++$lineLength;
|
||||
$lineWidth += $width;
|
||||
}else{
|
||||
return $text;
|
||||
}
|
||||
|
||||
$result .= $char;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -49,34 +49,6 @@ class Utils{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static function randomUUID(){
|
||||
return Utils::toUUID(Binary::writeInt(time()) . Binary::writeShort(getmypid()) . Binary::writeShort(getmyuid()) . Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)) . Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static function dataToUUID(...$params){
|
||||
return Utils::toUUID(hash("md5", implode($params), true), 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static function toUUID($data, $version = 2, $fixed = "8"){
|
||||
if(strlen($data) !== 16){
|
||||
throw new \InvalidArgumentException("Data must be 16 bytes");
|
||||
}
|
||||
|
||||
$hex = bin2hex($data);
|
||||
|
||||
//xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx 8-4-4-12
|
||||
return substr($hex, 0, 8) . "-" . substr($hex, 8, 4) . "-" . hexdec($version) . substr($hex, 13, 3) . "-" . $fixed{0} . substr($hex, 17, 3) . "-" . substr($hex, 20, 12);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this machine / server instance unique ID
|
||||
* Returns a hash, the first 32 characters (or 16 if raw)
|
||||
|
@ -54,13 +54,6 @@ class VersionString{
|
||||
return (int) (($this->generation << 9) + ($this->major << 5) + $this->minor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function getStage(){
|
||||
return "final";
|
||||
}
|
||||
|
||||
public function getGeneration(){
|
||||
return $this->generation;
|
||||
}
|
||||
|
Reference in New Issue
Block a user