mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Remove deprecated stuff
except Permission subscriptions; turns out we still need those perhaps they should be marked @internal
This commit is contained in:
parent
a2a2ec9d8b
commit
3e69ee87e4
@ -123,13 +123,6 @@ class MemoryManager{
|
|||||||
return $this->globalMemoryLimit;
|
return $this->globalMemoryLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function canUseChunkCache() : bool{
|
|
||||||
return !$this->lowMemory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the allowed chunk radius based on the current memory usage.
|
* Returns the allowed chunk radius based on the current memory usage.
|
||||||
*/
|
*/
|
||||||
@ -236,13 +229,4 @@ class MemoryManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Static memory dumper accessible from any thread.
|
|
||||||
* @deprecated
|
|
||||||
* @see MemoryDump
|
|
||||||
*/
|
|
||||||
public static function dumpMemory(mixed $startingObject, string $outputFolder, int $maxNesting, int $maxStringSize, \Logger $logger) : void{
|
|
||||||
MemoryDump::dumpMemory($startingObject, $outputFolder, $maxNesting, $maxStringSize, $logger);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -58,17 +58,10 @@ class SweetBerryBush extends Flowable{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
protected function canBeSupportedBy(Block $block) : bool{
|
|
||||||
return $block->getTypeId() !== BlockTypeIds::FARMLAND && //bedrock-specific thing (bug?)
|
|
||||||
($block->hasTypeTag(BlockTypeTags::DIRT) || $block->hasTypeTag(BlockTypeTags::MUD));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
$supportBlock = $block->getSide(Facing::DOWN);
|
$supportBlock = $block->getSide(Facing::DOWN);
|
||||||
return $this->canBeSupportedBy($supportBlock);
|
return $supportBlock->getTypeId() !== BlockTypeIds::FARMLAND && //bedrock-specific thing (bug?)
|
||||||
|
($supportBlock->hasTypeTag(BlockTypeTags::DIRT) || $supportBlock->hasTypeTag(BlockTypeTags::MUD));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||||
|
@ -35,20 +35,6 @@ abstract class Spawnable extends Tile{
|
|||||||
/** @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>|null */
|
/** @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>|null */
|
||||||
private ?CacheableNbt $spawnCompoundCache = null;
|
private ?CacheableNbt $spawnCompoundCache = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function isDirty() : bool{
|
|
||||||
return $this->spawnCompoundCache === null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function setDirty(bool $dirty = true) : void{
|
|
||||||
$this->clearSpawnCompoundCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function clearSpawnCompoundCache() : void{
|
public function clearSpawnCompoundCache() : void{
|
||||||
$this->spawnCompoundCache = null;
|
$this->spawnCompoundCache = null;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\data\runtime;
|
namespace pocketmine\data\runtime;
|
||||||
|
|
||||||
use pocketmine\block\utils\BrewingStandSlot;
|
|
||||||
use pocketmine\block\utils\WallConnectionType;
|
use pocketmine\block\utils\WallConnectionType;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
|
|
||||||
@ -38,11 +37,6 @@ use pocketmine\math\Facing;
|
|||||||
interface RuntimeDataDescriber{
|
interface RuntimeDataDescriber{
|
||||||
public function int(int $bits, int &$value) : void;
|
public function int(int $bits, int &$value) : void;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link RuntimeDataDescriber::boundedIntAuto()} instead.
|
|
||||||
*/
|
|
||||||
public function boundedInt(int $bits, int $min, int $max, int &$value) : void;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as boundedInt() but automatically calculates the required number of bits from the range.
|
* Same as boundedInt() but automatically calculates the required number of bits from the range.
|
||||||
* The range bounds must be constant.
|
* The range bounds must be constant.
|
||||||
@ -77,14 +71,6 @@ interface RuntimeDataDescriber{
|
|||||||
*/
|
*/
|
||||||
public function wallConnections(array &$connections) : void;
|
public function wallConnections(array &$connections) : void;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BrewingStandSlot[] $slots
|
|
||||||
* @phpstan-param array<int, BrewingStandSlot> $slots
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link enumSet()} instead.
|
|
||||||
*/
|
|
||||||
public function brewingStandSlots(array &$slots) : void;
|
|
||||||
|
|
||||||
public function railShape(int &$railShape) : void;
|
public function railShape(int &$railShape) : void;
|
||||||
|
|
||||||
public function straightOnlyRailShape(int &$railShape) : void;
|
public function straightOnlyRailShape(int &$railShape) : void;
|
||||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\data\runtime;
|
namespace pocketmine\data\runtime;
|
||||||
|
|
||||||
use pocketmine\block\utils\BrewingStandSlot;
|
|
||||||
use pocketmine\block\utils\RailConnectionInfo;
|
use pocketmine\block\utils\RailConnectionInfo;
|
||||||
use pocketmine\block\utils\WallConnectionType;
|
use pocketmine\block\utils\WallConnectionType;
|
||||||
use pocketmine\math\Axis;
|
use pocketmine\math\Axis;
|
||||||
@ -57,18 +56,6 @@ final class RuntimeDataReader implements RuntimeDataDescriber{
|
|||||||
$value = $this->readInt($bits);
|
$value = $this->readInt($bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link self::boundedIntAuto()} instead.
|
|
||||||
*/
|
|
||||||
public function boundedInt(int $bits, int $min, int $max, int &$value) : void{
|
|
||||||
$offset = $this->offset;
|
|
||||||
$this->boundedIntAuto($min, $max, $value);
|
|
||||||
$actualBits = $this->offset - $offset;
|
|
||||||
if($this->offset !== $offset + $bits){
|
|
||||||
throw new \InvalidArgumentException("Bits should be $actualBits for the given bounds, but received $bits. Use boundedIntAuto() for automatic bits calculation.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function readBoundedIntAuto(int $min, int $max) : int{
|
private function readBoundedIntAuto(int $min, int $max) : int{
|
||||||
$bits = ((int) log($max - $min, 2)) + 1;
|
$bits = ((int) log($max - $min, 2)) + 1;
|
||||||
$result = $this->readInt($bits) + $min;
|
$result = $this->readInt($bits) + $min;
|
||||||
@ -190,16 +177,6 @@ final class RuntimeDataReader implements RuntimeDataDescriber{
|
|||||||
$connections = $result;
|
$connections = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BrewingStandSlot[] $slots
|
|
||||||
* @phpstan-param array<int, BrewingStandSlot> $slots
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link enumSet()} instead.
|
|
||||||
*/
|
|
||||||
public function brewingStandSlots(array &$slots) : void{
|
|
||||||
$this->enumSet($slots, BrewingStandSlot::cases());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function railShape(int &$railShape) : void{
|
public function railShape(int &$railShape) : void{
|
||||||
$result = $this->readInt(4);
|
$result = $this->readInt(4);
|
||||||
if(!isset(RailConnectionInfo::CONNECTIONS[$result]) && !isset(RailConnectionInfo::CURVE_CONNECTIONS[$result])){
|
if(!isset(RailConnectionInfo::CONNECTIONS[$result]) && !isset(RailConnectionInfo::CURVE_CONNECTIONS[$result])){
|
||||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\data\runtime;
|
namespace pocketmine\data\runtime;
|
||||||
|
|
||||||
use pocketmine\block\utils\BrewingStandSlot;
|
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
use function count;
|
use function count;
|
||||||
use function log;
|
use function log;
|
||||||
@ -43,18 +42,6 @@ final class RuntimeDataSizeCalculator implements RuntimeDataDescriber{
|
|||||||
$this->addBits($bits);
|
$this->addBits($bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link self::boundedIntAuto()} instead.
|
|
||||||
*/
|
|
||||||
public function boundedInt(int $bits, int $min, int $max, int &$value) : void{
|
|
||||||
$currentBits = $this->bits;
|
|
||||||
$this->boundedIntAuto($min, $max, $value);
|
|
||||||
$actualBits = $this->bits - $currentBits;
|
|
||||||
if($actualBits !== $bits){
|
|
||||||
throw new \InvalidArgumentException("Bits should be $actualBits for the given bounds, but received $bits. Use boundedIntAuto() for automatic bits calculation.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function boundedIntAuto(int $min, int $max, int &$value) : void{
|
public function boundedIntAuto(int $min, int $max, int &$value) : void{
|
||||||
$this->addBits(((int) log($max - $min, 2)) + 1);
|
$this->addBits(((int) log($max - $min, 2)) + 1);
|
||||||
}
|
}
|
||||||
@ -95,10 +82,6 @@ final class RuntimeDataSizeCalculator implements RuntimeDataDescriber{
|
|||||||
$this->addBits(7);
|
$this->addBits(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function brewingStandSlots(array &$slots) : void{
|
|
||||||
$this->addBits(count(BrewingStandSlot::cases()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function railShape(int &$railShape) : void{
|
public function railShape(int &$railShape) : void{
|
||||||
$this->addBits(4);
|
$this->addBits(4);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\data\runtime;
|
namespace pocketmine\data\runtime;
|
||||||
|
|
||||||
use pocketmine\block\utils\BrewingStandSlot;
|
|
||||||
use pocketmine\block\utils\WallConnectionType;
|
use pocketmine\block\utils\WallConnectionType;
|
||||||
use pocketmine\math\Axis;
|
use pocketmine\math\Axis;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
@ -55,18 +54,6 @@ final class RuntimeDataWriter implements RuntimeDataDescriber{
|
|||||||
$this->writeInt($bits, $value);
|
$this->writeInt($bits, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link self::boundedIntAuto()} instead.
|
|
||||||
*/
|
|
||||||
public function boundedInt(int $bits, int $min, int $max, int &$value) : void{
|
|
||||||
$offset = $this->offset;
|
|
||||||
$this->writeBoundedIntAuto($min, $max, $value);
|
|
||||||
$actualBits = $this->offset - $offset;
|
|
||||||
if($actualBits !== $bits){
|
|
||||||
throw new \InvalidArgumentException("Bits should be $actualBits for the given bounds, but received $bits. Use boundedIntAuto() for automatic bits calculation.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function writeBoundedIntAuto(int $min, int $max, int $value) : void{
|
private function writeBoundedIntAuto(int $min, int $max, int $value) : void{
|
||||||
if($value < $min || $value > $max){
|
if($value < $min || $value > $max){
|
||||||
throw new \InvalidArgumentException("Value $value is outside the range $min - $max");
|
throw new \InvalidArgumentException("Value $value is outside the range $min - $max");
|
||||||
@ -168,16 +155,6 @@ final class RuntimeDataWriter implements RuntimeDataDescriber{
|
|||||||
$this->writeBoundedIntAuto(0, (3 ** 4) - 1, $packed);
|
$this->writeBoundedIntAuto(0, (3 ** 4) - 1, $packed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BrewingStandSlot[] $slots
|
|
||||||
* @phpstan-param array<int, BrewingStandSlot> $slots
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link enumSet()} instead.
|
|
||||||
*/
|
|
||||||
public function brewingStandSlots(array &$slots) : void{
|
|
||||||
$this->enumSet($slots, BrewingStandSlot::cases());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function railShape(int &$railShape) : void{
|
public function railShape(int &$railShape) : void{
|
||||||
$this->int(4, $railShape);
|
$this->int(4, $railShape);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,6 @@ class InventoryTransaction{
|
|||||||
public function addAction(InventoryAction $action) : void{
|
public function addAction(InventoryAction $action) : void{
|
||||||
if(!isset($this->actions[$hash = spl_object_id($action)])){
|
if(!isset($this->actions[$hash = spl_object_id($action)])){
|
||||||
$this->actions[$hash] = $action;
|
$this->actions[$hash] = $action;
|
||||||
$action->onAddToTransaction($this);
|
|
||||||
if($action instanceof SlotChangeAction && !isset($this->inventories[$inventoryId = spl_object_id($action->getInventory())])){
|
if($action instanceof SlotChangeAction && !isset($this->inventories[$inventoryId = spl_object_id($action->getInventory())])){
|
||||||
$this->inventories[$inventoryId] = $action->getInventory();
|
$this->inventories[$inventoryId] = $action->getInventory();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\inventory\transaction\action;
|
namespace pocketmine\inventory\transaction\action;
|
||||||
|
|
||||||
use pocketmine\inventory\transaction\InventoryTransaction;
|
|
||||||
use pocketmine\inventory\transaction\TransactionValidationException;
|
use pocketmine\inventory\transaction\TransactionValidationException;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
@ -58,14 +57,6 @@ abstract class InventoryAction{
|
|||||||
*/
|
*/
|
||||||
abstract public function validate(Player $source) : void;
|
abstract public function validate(Player $source) : void;
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the action is added to the specified InventoryTransaction.
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function onAddToTransaction(InventoryTransaction $transaction) : void{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by inventory transactions before any actions are processed. If this returns false, the transaction will
|
* Called by inventory transactions before any actions are processed. If this returns false, the transaction will
|
||||||
* be cancelled.
|
* be cancelled.
|
||||||
|
@ -266,22 +266,11 @@ class AsyncPool{
|
|||||||
$this->checkCrashedWorker($worker, $task);
|
$this->checkCrashedWorker($worker, $task);
|
||||||
throw new AssumptionFailedError("checkCrashedWorker() should have thrown an exception, making this unreachable");
|
throw new AssumptionFailedError("checkCrashedWorker() should have thrown an exception, making this unreachable");
|
||||||
}else{
|
}else{
|
||||||
/*
|
|
||||||
* It's possible for a task to submit a progress update and then finish before the progress
|
|
||||||
* update is detected by the parent thread, so here we consume any missed updates.
|
|
||||||
*
|
|
||||||
* When this happens, it's possible for a progress update to arrive between the previous
|
|
||||||
* checkProgressUpdates() call and the next isGarbage() call, causing progress updates to be
|
|
||||||
* lost. Thus, it's necessary to do one last check here to make sure all progress updates have
|
|
||||||
* been consumed before completing.
|
|
||||||
*/
|
|
||||||
$this->checkTaskProgressUpdates($task);
|
|
||||||
Timings::getAsyncTaskCompletionTimings($task)->time(function() use ($task) : void{
|
Timings::getAsyncTaskCompletionTimings($task)->time(function() use ($task) : void{
|
||||||
$task->onCompletion();
|
$task->onCompletion();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->checkTaskProgressUpdates($task);
|
|
||||||
$more = true;
|
$more = true;
|
||||||
break; //current task is still running, skip to next worker
|
break; //current task is still running, skip to next worker
|
||||||
}
|
}
|
||||||
@ -329,10 +318,4 @@ class AsyncPool{
|
|||||||
}
|
}
|
||||||
$this->workers = [];
|
$this->workers = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkTaskProgressUpdates(AsyncTask $task) : void{
|
|
||||||
Timings::getAsyncTaskProgressUpdateTimings($task)->time(function() use ($task) : void{
|
|
||||||
$task->checkProgressUpdates();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,9 @@ namespace pocketmine\scheduler;
|
|||||||
|
|
||||||
use pmmp\thread\Runnable;
|
use pmmp\thread\Runnable;
|
||||||
use pmmp\thread\ThreadSafe;
|
use pmmp\thread\ThreadSafe;
|
||||||
use pmmp\thread\ThreadSafeArray;
|
|
||||||
use pocketmine\thread\NonThreadSafeValue;
|
use pocketmine\thread\NonThreadSafeValue;
|
||||||
use pocketmine\timings\Timings;
|
use pocketmine\timings\Timings;
|
||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
use function igbinary_serialize;
|
|
||||||
use function igbinary_unserialize;
|
|
||||||
use function is_null;
|
use function is_null;
|
||||||
use function is_scalar;
|
use function is_scalar;
|
||||||
use function spl_object_id;
|
use function spl_object_id;
|
||||||
@ -68,12 +65,6 @@ abstract class AsyncTask extends Runnable{
|
|||||||
*/
|
*/
|
||||||
private static array $threadLocalStorage = [];
|
private static array $threadLocalStorage = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @phpstan-var ThreadSafeArray<int, string>|null
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
private ?ThreadSafeArray $progressUpdates = null;
|
|
||||||
|
|
||||||
private ThreadSafe|string|int|bool|null|float $result = null;
|
private ThreadSafe|string|int|bool|null|float $result = null;
|
||||||
|
|
||||||
private bool $submitted = false;
|
private bool $submitted = false;
|
||||||
@ -143,49 +134,6 @@ abstract class AsyncTask extends Runnable{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*
|
|
||||||
* Call this method from {@link AsyncTask::onRun} (AsyncTask execution thread) to schedule a call to
|
|
||||||
* {@link AsyncTask::onProgressUpdate} from the main thread with the given progress parameter.
|
|
||||||
*
|
|
||||||
* @param mixed $progress A value that can be safely serialize()'ed.
|
|
||||||
*/
|
|
||||||
public function publishProgress(mixed $progress) : void{
|
|
||||||
$progressUpdates = $this->progressUpdates;
|
|
||||||
if($progressUpdates === null){
|
|
||||||
$progressUpdates = $this->progressUpdates = new ThreadSafeArray();
|
|
||||||
}
|
|
||||||
$progressUpdates[] = igbinary_serialize($progress) ?? throw new \InvalidArgumentException("Progress must be serializable");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @internal Only call from AsyncPool.php on the main thread
|
|
||||||
*/
|
|
||||||
public function checkProgressUpdates() : void{
|
|
||||||
$progressUpdates = $this->progressUpdates;
|
|
||||||
if($progressUpdates !== null){
|
|
||||||
while(($progress = $progressUpdates->shift()) !== null){
|
|
||||||
$this->onProgressUpdate(igbinary_unserialize($progress));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*
|
|
||||||
* Called from the main thread after {@link AsyncTask::publishProgress} is called.
|
|
||||||
* All {@link AsyncTask::publishProgress} calls should result in {@link AsyncTask::onProgressUpdate} calls before
|
|
||||||
* {@link AsyncTask::onCompletion} is called.
|
|
||||||
*
|
|
||||||
* @param mixed $progress The parameter passed to {@link AsyncTask#publishProgress}. It is serialize()'ed
|
|
||||||
* and then unserialize()'ed, as if it has been cloned.
|
|
||||||
*/
|
|
||||||
public function onProgressUpdate($progress) : void{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves mixed data in thread-local storage. Data stored using this storage is **only accessible from the thread it
|
* Saves mixed data in thread-local storage. Data stored using this storage is **only accessible from the thread it
|
||||||
* was stored on**. Data stored using this method will **not** be serialized.
|
* was stored on**. Data stored using this method will **not** be serialized.
|
||||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\scheduler;
|
namespace pocketmine\scheduler;
|
||||||
|
|
||||||
use pmmp\thread\Thread as NativeThread;
|
|
||||||
use pocketmine\GarbageCollectorManager;
|
use pocketmine\GarbageCollectorManager;
|
||||||
use pocketmine\snooze\SleeperHandlerEntry;
|
use pocketmine\snooze\SleeperHandlerEntry;
|
||||||
use pocketmine\snooze\SleeperNotifier;
|
use pocketmine\snooze\SleeperNotifier;
|
||||||
@ -34,9 +33,6 @@ use pocketmine\utils\AssumptionFailedError;
|
|||||||
use function ini_set;
|
use function ini_set;
|
||||||
|
|
||||||
class AsyncWorker extends Worker{
|
class AsyncWorker extends Worker{
|
||||||
/** @var mixed[] */
|
|
||||||
private static array $store = [];
|
|
||||||
|
|
||||||
private static ?SleeperNotifier $notifier = null;
|
private static ?SleeperNotifier $notifier = null;
|
||||||
private static ?GarbageCollectorManager $cycleGcManager = null;
|
private static ?GarbageCollectorManager $cycleGcManager = null;
|
||||||
|
|
||||||
@ -88,46 +84,4 @@ class AsyncWorker extends Worker{
|
|||||||
public function getAsyncWorkerId() : int{
|
public function getAsyncWorkerId() : int{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves mixed data into the worker's thread-local object store. This can be used to store objects which you
|
|
||||||
* want to use on this worker thread from multiple AsyncTasks.
|
|
||||||
*
|
|
||||||
* @deprecated Use static class properties instead.
|
|
||||||
*/
|
|
||||||
public function saveToThreadStore(string $identifier, mixed $value) : void{
|
|
||||||
if(NativeThread::getCurrentThread() !== $this){
|
|
||||||
throw new \LogicException("Thread-local data can only be stored in the thread context");
|
|
||||||
}
|
|
||||||
self::$store[$identifier] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves mixed data from the worker's thread-local object store.
|
|
||||||
*
|
|
||||||
* Note that the thread-local object store could be cleared and your data might not exist, so your code should
|
|
||||||
* account for the possibility that what you're trying to retrieve might not exist.
|
|
||||||
*
|
|
||||||
* Objects stored in this storage may ONLY be retrieved while the task is running.
|
|
||||||
*
|
|
||||||
* @deprecated Use static class properties instead.
|
|
||||||
*/
|
|
||||||
public function getFromThreadStore(string $identifier) : mixed{
|
|
||||||
if(NativeThread::getCurrentThread() !== $this){
|
|
||||||
throw new \LogicException("Thread-local data can only be fetched in the thread context");
|
|
||||||
}
|
|
||||||
return self::$store[$identifier] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes previously-stored mixed data from the worker's thread-local object store.
|
|
||||||
*
|
|
||||||
* @deprecated Use static class properties instead.
|
|
||||||
*/
|
|
||||||
public function removeFromThreadStore(string $identifier) : void{
|
|
||||||
if(NativeThread::getCurrentThread() !== $this){
|
|
||||||
throw new \LogicException("Thread-local data can only be removed in the thread context");
|
|
||||||
}
|
|
||||||
unset(self::$store[$identifier]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,6 @@ use function str_starts_with;
|
|||||||
|
|
||||||
abstract class Timings{
|
abstract class Timings{
|
||||||
public const GROUP_MINECRAFT = "Minecraft";
|
public const GROUP_MINECRAFT = "Minecraft";
|
||||||
/** @deprecated No longer used */
|
|
||||||
public const GROUP_BREAKDOWN = "Minecraft - Breakdown";
|
|
||||||
|
|
||||||
private static bool $initialized = false;
|
private static bool $initialized = false;
|
||||||
|
|
||||||
@ -119,17 +117,9 @@ abstract class Timings{
|
|||||||
/** @var TimingsHandler[][] */
|
/** @var TimingsHandler[][] */
|
||||||
private static array $eventHandlers = [];
|
private static array $eventHandlers = [];
|
||||||
|
|
||||||
private static TimingsHandler $asyncTaskProgressUpdateParent;
|
|
||||||
private static TimingsHandler $asyncTaskCompletionParent;
|
private static TimingsHandler $asyncTaskCompletionParent;
|
||||||
private static TimingsHandler $asyncTaskErrorParent;
|
|
||||||
|
|
||||||
/** @var TimingsHandler[] */
|
|
||||||
private static array $asyncTaskProgressUpdate = [];
|
|
||||||
|
|
||||||
/** @var TimingsHandler[] */
|
/** @var TimingsHandler[] */
|
||||||
private static array $asyncTaskCompletion = [];
|
private static array $asyncTaskCompletion = [];
|
||||||
/** @var TimingsHandler[] */
|
|
||||||
private static array $asyncTaskError = [];
|
|
||||||
|
|
||||||
public static TimingsHandler $asyncTaskWorkers;
|
public static TimingsHandler $asyncTaskWorkers;
|
||||||
/** @var TimingsHandler[] */
|
/** @var TimingsHandler[] */
|
||||||
@ -190,9 +180,7 @@ abstract class Timings{
|
|||||||
self::$schedulerSync = new TimingsHandler("Scheduler - Sync Tasks");
|
self::$schedulerSync = new TimingsHandler("Scheduler - Sync Tasks");
|
||||||
|
|
||||||
self::$schedulerAsync = new TimingsHandler("Scheduler - Async Tasks");
|
self::$schedulerAsync = new TimingsHandler("Scheduler - Async Tasks");
|
||||||
self::$asyncTaskProgressUpdateParent = new TimingsHandler("Async Tasks - Progress Updates", self::$schedulerAsync);
|
|
||||||
self::$asyncTaskCompletionParent = new TimingsHandler("Async Tasks - Completion Handlers", self::$schedulerAsync);
|
self::$asyncTaskCompletionParent = new TimingsHandler("Async Tasks - Completion Handlers", self::$schedulerAsync);
|
||||||
self::$asyncTaskErrorParent = new TimingsHandler("Async Tasks - Error Handlers", self::$schedulerAsync);
|
|
||||||
|
|
||||||
self::$asyncTaskWorkers = new TimingsHandler("Async Task Workers");
|
self::$asyncTaskWorkers = new TimingsHandler("Async Task Workers");
|
||||||
|
|
||||||
@ -324,20 +312,6 @@ abstract class Timings{
|
|||||||
return self::$eventHandlers[$event][$handlerName];
|
return self::$eventHandlers[$event][$handlerName];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAsyncTaskProgressUpdateTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
|
|
||||||
$taskClass = $task::class;
|
|
||||||
if(!isset(self::$asyncTaskProgressUpdate[$taskClass])){
|
|
||||||
self::init();
|
|
||||||
self::$asyncTaskProgressUpdate[$taskClass] = new TimingsHandler(
|
|
||||||
"AsyncTask - " . self::shortenCoreClassName($taskClass, "pocketmine\\") . " - Progress Updates",
|
|
||||||
self::$asyncTaskProgressUpdateParent,
|
|
||||||
$group
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$asyncTaskProgressUpdate[$taskClass];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getAsyncTaskCompletionTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
|
public static function getAsyncTaskCompletionTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
|
||||||
$taskClass = $task::class;
|
$taskClass = $task::class;
|
||||||
if(!isset(self::$asyncTaskCompletion[$taskClass])){
|
if(!isset(self::$asyncTaskCompletion[$taskClass])){
|
||||||
@ -352,23 +326,6 @@ abstract class Timings{
|
|||||||
return self::$asyncTaskCompletion[$taskClass];
|
return self::$asyncTaskCompletion[$taskClass];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated No longer used
|
|
||||||
*/
|
|
||||||
public static function getAsyncTaskErrorTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
|
|
||||||
$taskClass = $task::class;
|
|
||||||
if(!isset(self::$asyncTaskError[$taskClass])){
|
|
||||||
self::init();
|
|
||||||
self::$asyncTaskError[$taskClass] = new TimingsHandler(
|
|
||||||
"AsyncTask - " . self::shortenCoreClassName($taskClass, "pocketmine\\") . " - Error Handler",
|
|
||||||
self::$asyncTaskErrorParent,
|
|
||||||
$group
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$asyncTaskError[$taskClass];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getAsyncTaskRunTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
|
public static function getAsyncTaskRunTimings(AsyncTask $task, string $group = self::GROUP_MINECRAFT) : TimingsHandler{
|
||||||
$taskClass = $task::class;
|
$taskClass = $task::class;
|
||||||
if(!isset(self::$asyncTaskRun[$taskClass])){
|
if(!isset(self::$asyncTaskRun[$taskClass])){
|
||||||
|
@ -138,19 +138,6 @@ class TimingsHandler{
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This only collects timings from the main thread. Collecting timings from all threads is an async
|
|
||||||
* operation, so it can't be done synchronously.
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public static function printTimings() : array{
|
|
||||||
$records = self::printCurrentThreadRecords();
|
|
||||||
$footer = self::printFooter();
|
|
||||||
|
|
||||||
return [...$records, ...$footer];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects timings asynchronously, allowing timings from multiple threads to be aggregated into a single report.
|
* Collects timings asynchronously, allowing timings from multiple threads to be aggregated into a single report.
|
||||||
*
|
*
|
||||||
|
@ -106,10 +106,6 @@ abstract class TextFormat{
|
|||||||
|
|
||||||
public const OBFUSCATED = TextFormat::ESCAPE . "k";
|
public const OBFUSCATED = TextFormat::ESCAPE . "k";
|
||||||
public const BOLD = TextFormat::ESCAPE . "l";
|
public const BOLD = TextFormat::ESCAPE . "l";
|
||||||
/** @deprecated */
|
|
||||||
public const STRIKETHROUGH = "";
|
|
||||||
/** @deprecated */
|
|
||||||
public const UNDERLINE = "";
|
|
||||||
public const ITALIC = TextFormat::ESCAPE . "o";
|
public const ITALIC = TextFormat::ESCAPE . "o";
|
||||||
|
|
||||||
public const FORMATS = [
|
public const FORMATS = [
|
||||||
|
@ -48,13 +48,6 @@ use const PHP_EOL;
|
|||||||
use const STDIN;
|
use const STDIN;
|
||||||
|
|
||||||
class SetupWizard{
|
class SetupWizard{
|
||||||
/** @deprecated */
|
|
||||||
public const DEFAULT_NAME = Server::DEFAULT_SERVER_NAME;
|
|
||||||
/** @deprecated */
|
|
||||||
public const DEFAULT_PORT = Server::DEFAULT_PORT_IPV4;
|
|
||||||
/** @deprecated */
|
|
||||||
public const DEFAULT_PLAYERS = Server::DEFAULT_MAX_PLAYERS;
|
|
||||||
|
|
||||||
private Language $lang;
|
private Language $lang;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -1614,25 +1614,6 @@ class World implements ChunkManager{
|
|||||||
return $collides;
|
return $collides;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link World::getBlockCollisionBoxes()} instead (alongside {@link World::getCollidingEntities()}
|
|
||||||
* if entity collision boxes are also required).
|
|
||||||
*
|
|
||||||
* @return AxisAlignedBB[]
|
|
||||||
* @phpstan-return list<AxisAlignedBB>
|
|
||||||
*/
|
|
||||||
public function getCollisionBoxes(Entity $entity, AxisAlignedBB $bb, bool $entities = true) : array{
|
|
||||||
$collides = $this->getBlockCollisionBoxes($bb);
|
|
||||||
|
|
||||||
if($entities){
|
|
||||||
foreach($this->getCollidingEntities($bb->expandedCopy(0.25, 0.25, 0.25), $entity) as $ent){
|
|
||||||
$collides[] = clone $ent->boundingBox;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $collides;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the percentage of a circle away from noon the sun is currently at. This can be multiplied by 2 * M_PI to
|
* Computes the percentage of a circle away from noon the sun is currently at. This can be multiplied by 2 * M_PI to
|
||||||
* get an angle in radians, or by 360 to get an angle in degrees.
|
* get an angle in radians, or by 360 to get an angle in degrees.
|
||||||
|
@ -61,15 +61,6 @@ class AsyncPoolTest extends TestCase{
|
|||||||
self::assertTrue(LeakTestAsyncTask::$destroyed, "Task was not destroyed after 30 seconds");
|
self::assertTrue(LeakTestAsyncTask::$destroyed, "Task was not destroyed after 30 seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPublishProgressRace() : void{
|
|
||||||
$task = new PublishProgressRaceAsyncTask();
|
|
||||||
$this->pool->submitTask($task);
|
|
||||||
while($this->pool->collectTasks()){
|
|
||||||
usleep(50 * 1000);
|
|
||||||
}
|
|
||||||
self::assertTrue(PublishProgressRaceAsyncTask::$success, "Progress was not reported before task completion");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testThreadSafeSetResult() : void{
|
public function testThreadSafeSetResult() : void{
|
||||||
$resolver = new PromiseResolver();
|
$resolver = new PromiseResolver();
|
||||||
$resolver->getPromise()->onCompletion(
|
$resolver->getPromise()->onCompletion(
|
||||||
|
@ -1,40 +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/
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace pocketmine\scheduler;
|
|
||||||
|
|
||||||
class PublishProgressRaceAsyncTask extends AsyncTask{
|
|
||||||
/** @var bool */
|
|
||||||
public static $success = false;
|
|
||||||
|
|
||||||
public function onRun() : void{
|
|
||||||
$this->publishProgress("hello");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onProgressUpdate($progress) : void{
|
|
||||||
if($progress === "hello"){
|
|
||||||
// thread local on main thread
|
|
||||||
self::$success = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user