mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Added small things
This commit is contained in:
parent
9a4ead54e3
commit
a7944502cd
@ -135,7 +135,7 @@ namespace pocketmine {
|
||||
}
|
||||
}
|
||||
|
||||
gc_enable();
|
||||
gc_disable();
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
ini_set("allow_url_fopen", 1);
|
||||
ini_set("display_errors", 1);
|
||||
|
@ -73,6 +73,7 @@ use pocketmine\plugin\Plugin;
|
||||
use pocketmine\plugin\PluginLoadOrder;
|
||||
use pocketmine\plugin\PluginManager;
|
||||
use pocketmine\scheduler\CallbackTask;
|
||||
use pocketmine\scheduler\PHPGarbageCollectionTask;
|
||||
use pocketmine\scheduler\SendUsageTask;
|
||||
use pocketmine\scheduler\ServerScheduler;
|
||||
use pocketmine\tile\Tile;
|
||||
@ -1521,9 +1522,11 @@ class Server{
|
||||
}
|
||||
|
||||
if($this->getProperty("chunk-gc.period-in-ticks", 600) > 0){
|
||||
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask(array($this, "doLevelGC")), $this->getProperty("chunk-gc.period-in-ticks", 600), $this->getProperty("chunk-gc.period-in-ticks", 600));
|
||||
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "doLevelGC"]), $this->getProperty("chunk-gc.period-in-ticks", 600), $this->getProperty("chunk-gc.period-in-ticks", 600));
|
||||
}
|
||||
|
||||
$this->scheduler->scheduleRepeatingTask(new PHPGarbageCollectionTask(), 100);
|
||||
|
||||
$this->enablePlugins(PluginLoadOrder::POSTWORLD);
|
||||
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
*/
|
||||
public function freeAllChunks(Player $player){
|
||||
foreach($this->usedChunks as $i => $c){
|
||||
unset($this->usedChunks[$i][spl_object_hash($player)]);
|
||||
unset($this->usedChunks[$i][$player->getID()]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,7 +354,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @param Player $player
|
||||
*/
|
||||
public function freeChunk($X, $Z, Player $player){
|
||||
unset($this->usedChunks[Level::chunkHash($X, $Z)][$player->getID()]);
|
||||
unset($this->usedChunks[$index = Level::chunkHash($X, $Z)][$player->getID()]);
|
||||
$this->unloadChunkRequest($X, $Z, true);
|
||||
}
|
||||
|
||||
@ -1523,6 +1523,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->timings->doChunkUnload->startTiming();
|
||||
|
||||
$this->provider->unloadChunk($x, $z, $safe);
|
||||
unset($this->usedChunks[Level::chunkHash($x, $z)]);
|
||||
Cache::remove("world:" . $this->getID() . ":$x:$z");
|
||||
|
||||
$this->timings->doChunkUnload->stopTiming();
|
||||
@ -1682,7 +1683,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
public function regenerateChunk($x, $z){
|
||||
$this->unloadChunk($x, $z);
|
||||
$this->unloadChunk($x, $z, false);
|
||||
|
||||
$this->cancelUnloadChunkRequest($x, $z);
|
||||
|
||||
@ -1714,6 +1715,10 @@ class Level implements ChunkManager, Metadatable{
|
||||
if(count($c) === 0){
|
||||
Level::getXZ($i, $X, $Z);
|
||||
if(!$this->isSpawnChunk($X, $Z)){
|
||||
if($this->getAutoSave()){
|
||||
$this->provider->saveChunk($X, $Z);
|
||||
}
|
||||
|
||||
$this->unloadChunk($X, $Z, true);
|
||||
}
|
||||
}
|
||||
|
@ -130,8 +130,8 @@ class Anvil extends BaseLevelProvider{
|
||||
}
|
||||
|
||||
public function unloadChunk($x, $z, $safe = true){
|
||||
$chunk = $this->getChunk($x, $z, false);
|
||||
if($safe === true and $this->isChunkLoaded($x, $z)){
|
||||
$chunk = $this->getChunk($x, $z);
|
||||
foreach($chunk->getEntities() as $entity){
|
||||
if($entity instanceof Player){
|
||||
return false;
|
||||
@ -139,7 +139,17 @@ class Anvil extends BaseLevelProvider{
|
||||
}
|
||||
}
|
||||
|
||||
unset($this->chunks[Level::chunkHash($x, $z)]);
|
||||
foreach($chunk->getEntities() as $entity){
|
||||
$entity->close();
|
||||
}
|
||||
|
||||
foreach($chunk->getTiles() as $tile){
|
||||
$tile->close();
|
||||
}
|
||||
|
||||
$this->chunks[$index = Level::chunkHash($x, $z)] = null;
|
||||
|
||||
unset($this->chunks[$index]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
30
src/pocketmine/scheduler/PHPGarbageCollectionTask.php
Normal file
30
src/pocketmine/scheduler/PHPGarbageCollectionTask.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?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
|
||||
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
class PHPGarbageCollectionTask extends Task{
|
||||
|
||||
public function onRun($currentTicks){
|
||||
gc_collect_cycles();
|
||||
}
|
||||
|
||||
}
|
@ -178,7 +178,7 @@ class ServerScheduler{
|
||||
$period = 1;
|
||||
}
|
||||
|
||||
return $this->handle(new TaskHandler(!($task instanceof PluginTask) ? "Scheduler" : null, $task, $this->nextId(), $delay, $period));
|
||||
return $this->handle(new TaskHandler(get_class($task), $task, $this->nextId(), $delay, $period));
|
||||
}
|
||||
|
||||
private function handle(TaskHandler $handler){
|
||||
|
Loading…
x
Reference in New Issue
Block a user