mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-13 04:45:08 +00:00
Compare commits
122 Commits
Alpha_1.4d
...
api/1.11.0
Author | SHA1 | Date | |
---|---|---|---|
891eeff75a | |||
b4f62bf423 | |||
7c76c1e3d7 | |||
37bc1273ee | |||
ffcdf49912 | |||
3e893ed0f7 | |||
bfb7e8bb9e | |||
5067b96184 | |||
cb2157ea80 | |||
5b3e65345f | |||
8aa8ae5094 | |||
220d2b7bee | |||
807107e581 | |||
9158cc4f19 | |||
2cd757d80a | |||
be20f61a93 | |||
59e9446fe5 | |||
4f47dac8ec | |||
b54c0835b7 | |||
9ca3ad8971 | |||
a644b46ec4 | |||
9d3f59fab6 | |||
6309d4abf1 | |||
39291e4061 | |||
bb71a3c4a6 | |||
eb0525e892 | |||
f49db47b2e | |||
3ff5e12302 | |||
99ad65ba44 | |||
5f4f996efe | |||
21e0739845 | |||
3a157d0f02 | |||
8e56782138 | |||
116ede3679 | |||
7c0f5987d3 | |||
547e152e40 | |||
7905fbdd29 | |||
ae65701a23 | |||
9134a69936 | |||
907fe8aff6 | |||
afa9acf22f | |||
9a5afff4ab | |||
2f8c281a2e | |||
2096dace68 | |||
8421985102 | |||
f63e859b3a | |||
c56eb0b9df | |||
3f2e5bbef4 | |||
9886eb4768 | |||
ea44eee5df | |||
9173f930ca | |||
80b6a8ebaf | |||
7c64a33389 | |||
9fac896f28 | |||
5bd76e955c | |||
63f1a50be4 | |||
24c6cca664 | |||
9fac990b19 | |||
e8e7938490 | |||
f6c4a726b3 | |||
8eec5e6b5e | |||
bd7fa71d7f | |||
7d406066a7 | |||
3e9196d224 | |||
f30986d187 | |||
f8c144be31 | |||
c61e4adcf1 | |||
5a55040ab9 | |||
83360187c9 | |||
9d97a940a6 | |||
cd21c28d46 | |||
37fd0372cc | |||
ed02026815 | |||
042a143dd6 | |||
4b73dbd9f8 | |||
d4e4430df0 | |||
469ef84733 | |||
efe75f2836 | |||
53f2f21f2d | |||
9c28f0a5be | |||
5bf5014b60 | |||
f37e79b611 | |||
7a0118820c | |||
c8b5c023cd | |||
f9dd929e04 | |||
87970726e4 | |||
1daf9a96a3 | |||
6c8b33fcc8 | |||
438591bd75 | |||
7ef8edccf4 | |||
074c8b876d | |||
f9762c870a | |||
4039895d3c | |||
d207a5daea | |||
8e3667c95b | |||
0da628deca | |||
04bdb13103 | |||
e8ad828498 | |||
f46473bbe8 | |||
692045d714 | |||
47cbf56725 | |||
3de14d8ba6 | |||
5fffabe05b | |||
3128ae9736 | |||
7be4e2fa81 | |||
95b305ce87 | |||
767800662c | |||
fe32e6f5d0 | |||
2cec0d9f36 | |||
d800a21bd4 | |||
8d9fbec4ce | |||
ab72c32769 | |||
346626305c | |||
fafbd500e1 | |||
2db2e8cfc4 | |||
854479180f | |||
902ba81e02 | |||
1ac17abec0 | |||
714ea54121 | |||
aa992684ba | |||
0c58de86b7 | |||
7ecac019a9 |
@ -42,7 +42,10 @@ class CrashDump{
|
||||
$this->time = time();
|
||||
$this->server = $server;
|
||||
$this->path = $this->server->getDataPath() . "CrashDump_" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
|
||||
$this->fp = fopen($this->path, "wb");
|
||||
$this->fp = @fopen($this->path, "wb");
|
||||
if(!is_resource($this->fp)){
|
||||
throw new \RuntimeException("Could not create Crash Dump");
|
||||
}
|
||||
$this->data["time"] = $this->time;
|
||||
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));
|
||||
$this->addLine();
|
||||
@ -137,7 +140,7 @@ class CrashDump{
|
||||
$error = $lastExceptionError;
|
||||
}else{
|
||||
$error = (array) error_get_last();
|
||||
$error["trace"] = @getTrace(4);
|
||||
$error["trace"] = @getTrace(3);
|
||||
$errorConversion = [
|
||||
E_ERROR => "E_ERROR",
|
||||
E_WARNING => "E_WARNING",
|
||||
|
@ -68,6 +68,7 @@ use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\inventory\SimpleTransactionGroup;
|
||||
use pocketmine\inventory\StonecutterShapelessRecipe;
|
||||
use pocketmine\item\Armor;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\level\format\LevelProvider;
|
||||
@ -147,6 +148,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
protected $moveToSend = [];
|
||||
protected $motionToSend = [];
|
||||
|
||||
/** @var Vector3 */
|
||||
public $speed = null;
|
||||
|
||||
public $blocked = false;
|
||||
public $achievements = [];
|
||||
public $lastCorrect;
|
||||
@ -191,6 +195,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
private $inAction = false;
|
||||
|
||||
protected $inAirTicks = 0;
|
||||
protected $lastSpeedTick = 0;
|
||||
protected $speedTicks = 0;
|
||||
protected $highSpeedTicks = 0;
|
||||
|
||||
|
||||
private $needACK = [];
|
||||
@ -210,6 +217,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
public function setBanned($value){
|
||||
if($value === true){
|
||||
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
|
||||
$this->kick("You have been banned");
|
||||
}else{
|
||||
$this->server->getNameBans()->remove($this->getName());
|
||||
}
|
||||
@ -314,6 +322,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function resetFallDistance(){
|
||||
parent::resetFallDistance();
|
||||
$this->inAirTicks = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@ -660,6 +673,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->server->broadcastMessage($ev->getJoinMessage());
|
||||
}
|
||||
|
||||
$this->noDamageTicks = 60;
|
||||
|
||||
$this->spawnToAll();
|
||||
|
||||
if($this->server->getUpdater()->hasUpdate() and $this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)){
|
||||
@ -1060,6 +1075,13 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
protected function processMovement($currentTick){
|
||||
if($this->dead or !$this->spawned or !($this->newPosition instanceof Vector3)){
|
||||
$diff = ($currentTick - $this->lastSpeedTick);
|
||||
if($diff >= 10){
|
||||
$this->speed = new Vector3(0, 0, 0);
|
||||
}elseif($diff > 5 and $this->speedTicks < 20){
|
||||
++$this->speedTicks;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1067,7 +1089,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
$revert = false;
|
||||
|
||||
if($distanceSquared > 10000){
|
||||
if($distanceSquared > 100){
|
||||
$revert = true;
|
||||
}else{
|
||||
if($this->chunk === null or !$this->chunk->isGenerated()){
|
||||
@ -1089,8 +1111,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$dy = $this->newPosition->y - $this->y;
|
||||
$dz = $this->newPosition->z - $this->z;
|
||||
|
||||
//$this->inBlock = $this->checkObstruction($this->x, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, $this->z);
|
||||
$this->move($dx, $dy, $dz);
|
||||
$this->fastMove($dx, $dy, $dz);
|
||||
|
||||
$diffX = $this->x - $this->newPosition->x;
|
||||
$diffZ = $this->z - $this->newPosition->z;
|
||||
@ -1101,17 +1122,19 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
$diff = $diffX ** 2 + $diffY ** 2 + $diffZ ** 2;
|
||||
|
||||
if(!$revert and !$this->isSleeping() and $this->isSurvival()){
|
||||
if($diff > 0.0625){
|
||||
$revert = true;
|
||||
//$this->server->getLogger()->warning($this->getName()." moved wrongly!");
|
||||
}elseif($diff > 0){
|
||||
$this->x = $this->newPosition->x;
|
||||
$this->y = $this->newPosition->y;
|
||||
$this->z = $this->newPosition->z;
|
||||
$radius = $this->width / 2;
|
||||
$this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius);
|
||||
if($this->isSurvival()){
|
||||
if(!$revert and !$this->isSleeping()){
|
||||
if($diff > 0.0625){
|
||||
$revert = true;
|
||||
$this->server->getLogger()->warning($this->getName()." moved wrongly!");
|
||||
}
|
||||
}
|
||||
}elseif($diff > 0){
|
||||
$this->x = $this->newPosition->x;
|
||||
$this->y = $this->newPosition->y;
|
||||
$this->z = $this->newPosition->z;
|
||||
$radius = $this->width / 2;
|
||||
$this->boundingBox->setBounds($this->x - $radius, $this->y + $this->ySize, $this->z - $radius, $this->x + $radius, $this->y + $this->height + $this->ySize, $this->z + $radius);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1154,6 +1177,20 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ticks = min(20, $currentTick - $this->lastSpeedTick + 0.5);
|
||||
if($this->speedTicks > 0){
|
||||
$ticks += $this->speedTicks;
|
||||
}
|
||||
$this->speed = $from->subtract($to)->divide($ticks);
|
||||
$this->lastSpeedTick = $currentTick;
|
||||
}elseif($distanceSquared == 0){
|
||||
$this->speed = new Vector3(0, 0, 0);
|
||||
$this->lastSpeedTick = $currentTick;
|
||||
}
|
||||
|
||||
if($this->speedTicks > 0){
|
||||
--$this->speedTicks;
|
||||
}
|
||||
|
||||
if($revert){
|
||||
@ -1176,13 +1213,14 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$pk->teleport = true;
|
||||
$this->directDataPacket($pk);
|
||||
$this->forceMovement = new Vector3($from->x, $from->y, $from->z);
|
||||
$this->newPosition = null;
|
||||
}else{
|
||||
$this->forceMovement = null;
|
||||
if($distanceSquared != 0 and $this->nextChunkOrderRun > 20){
|
||||
$this->nextChunkOrderRun = 20;
|
||||
}
|
||||
}
|
||||
|
||||
$this->newPosition = null;
|
||||
}
|
||||
|
||||
public function updateMovement(){
|
||||
@ -1190,6 +1228,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
|
||||
public function onUpdate($currentTick){
|
||||
if(!$this->loggedIn){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->dead === true and $this->spawned){
|
||||
++$this->deadTicks;
|
||||
if($this->deadTicks >= 10){
|
||||
@ -1207,15 +1249,43 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
$this->entityBaseTick(1);
|
||||
|
||||
if($this->speed and $this->forceMovement === null and $this->isSurvival()){
|
||||
$speed = sqrt($this->speed->x ** 2 + $this->speed->z ** 2);
|
||||
if($speed > 0.45){
|
||||
$this->highSpeedTicks += $speed > 3 ? 2 : 1;
|
||||
if($this->highSpeedTicks > 40 and !$this->server->getAllowFlight()){
|
||||
if($this->kick("Flying is not enabled on this server")){
|
||||
return false;
|
||||
}
|
||||
}elseif($this->highSpeedTicks >= 10 and $this->highSpeedTicks % 4 === 0){
|
||||
$this->forceMovement = $this->getPosition();
|
||||
}
|
||||
}elseif($this->highSpeedTicks > 0){
|
||||
if($speed < 22){
|
||||
$this->highSpeedTicks = 0;
|
||||
}else{
|
||||
$this->highSpeedTicks--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this->onGround){
|
||||
$this->inAirTicks = 0;
|
||||
}else{
|
||||
if($this->inAirTicks > 100 and $this->isSurvival() and !$this->isSleeping() and $this->spawned and !$this->server->getAllowFlight()){
|
||||
$this->kick("Flying is not enabled on this server");
|
||||
return false;
|
||||
}else{
|
||||
++$this->inAirTicks;
|
||||
if($this->inAirTicks > 10 and $this->isSurvival() and !$this->isSleeping()){
|
||||
$expectedVelocity = (-$this->gravity) / $this->drag - ((-$this->gravity) / $this->drag) * exp(-$this->drag * ($this->inAirTicks - 2));
|
||||
$diff = sqrt(abs($this->speed->y - $expectedVelocity));
|
||||
|
||||
if($diff > 0.6 and $expectedVelocity < $this->speed->y and !$this->server->getAllowFlight()){
|
||||
if($this->inAirTicks < 100){
|
||||
$this->setMotion(new Vector3(0, $expectedVelocity, 0));
|
||||
}elseif($this->kick("Flying is not enabled on this server")){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++$this->inAirTicks;
|
||||
}
|
||||
|
||||
foreach($this->level->getNearbyEntities($this->boundingBox->grow(1, 0.5, 1), $this) as $entity){
|
||||
@ -1514,6 +1584,13 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
if($this->spawned === false or $this->dead === true){
|
||||
break;
|
||||
}
|
||||
$packet->yaw %= 360;
|
||||
$packet->pitch %= 360;
|
||||
|
||||
if($packet->yaw < 0){
|
||||
$packet->yaw += 360;
|
||||
}
|
||||
|
||||
$this->setRotation($packet->yaw, $this->pitch);
|
||||
break;
|
||||
case ProtocolInfo::MOVE_PLAYER_PACKET:
|
||||
@ -1526,7 +1603,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
if($this->forceMovement instanceof Vector3 and ($revert or $newPos->distanceSquared($this->forceMovement) > 0.04)){
|
||||
if($this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.04 or $revert)){
|
||||
$pk = new MovePlayerPacket();
|
||||
$pk->eid = 0;
|
||||
$pk->x = $this->forceMovement->x;
|
||||
@ -1906,6 +1983,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1,
|
||||
];
|
||||
|
||||
$points = 0;
|
||||
if($this->distance($target) > 8){
|
||||
$cancelled = true;
|
||||
}elseif($target instanceof Player){
|
||||
@ -1915,34 +1993,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$cancelled = true;
|
||||
}
|
||||
|
||||
$armorValues = [
|
||||
Item::LEATHER_CAP => 1,
|
||||
Item::LEATHER_TUNIC => 3,
|
||||
Item::LEATHER_PANTS => 2,
|
||||
Item::LEATHER_BOOTS => 1,
|
||||
Item::CHAIN_HELMET => 1,
|
||||
Item::CHAIN_CHESTPLATE => 5,
|
||||
Item::CHAIN_LEGGINGS => 4,
|
||||
Item::CHAIN_BOOTS => 1,
|
||||
Item::GOLD_HELMET => 1,
|
||||
Item::GOLD_CHESTPLATE => 5,
|
||||
Item::GOLD_LEGGINGS => 3,
|
||||
Item::GOLD_BOOTS => 1,
|
||||
Item::IRON_HELMET => 2,
|
||||
Item::IRON_CHESTPLATE => 6,
|
||||
Item::IRON_LEGGINGS => 5,
|
||||
Item::IRON_BOOTS => 2,
|
||||
Item::DIAMOND_HELMET => 3,
|
||||
Item::DIAMOND_CHESTPLATE => 8,
|
||||
Item::DIAMOND_LEGGINGS => 6,
|
||||
Item::DIAMOND_BOOTS => 3,
|
||||
];
|
||||
$points = 0;
|
||||
foreach($target->getInventory()->getArmorContents() as $index => $i){
|
||||
if(isset($armorValues[$i->getId()])){
|
||||
$points += $armorValues[$i->getId()];
|
||||
}
|
||||
}
|
||||
$points = $target->getInventory()->getArmorPoints();
|
||||
|
||||
$damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
|
||||
}
|
||||
@ -1970,7 +2021,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case ProtocolInfo::ANIMATE_PACKET:
|
||||
if($this->spawned === false or $this->dead === true){
|
||||
@ -2001,6 +2051,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->fireTicks = 0;
|
||||
$this->airTicks = 300;
|
||||
$this->deadTicks = 0;
|
||||
$this->noDamageTicks = 60;
|
||||
|
||||
$this->setHealth(20);
|
||||
$this->dead = false;
|
||||
@ -2569,6 +2620,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
if($ev->getDeathMessage() != ""){
|
||||
$this->server->broadcast($ev->getDeathMessage(), Server::BROADCAST_CHANNEL_USERS);
|
||||
}
|
||||
|
||||
if($this->server->isHardcore()){
|
||||
$this->setBanned(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function setHealth($amount){
|
||||
@ -2607,8 +2662,24 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
parent::attack($damage, $source);
|
||||
|
||||
if($source instanceof EntityDamageEvent and $source->isCancelled()){
|
||||
return;
|
||||
if($source instanceof EntityDamageEvent){
|
||||
if($source->isCancelled()){
|
||||
return;
|
||||
}
|
||||
if($source->getDamage(EntityDamageEvent::MODIFIER_ARMOR) > 0){
|
||||
for($i = 0; $i < 4; $i++){
|
||||
$piece = $this->getInventory()->getArmorItem($i);
|
||||
if($piece instanceof Armor){
|
||||
$damage = $piece->getDamage();
|
||||
if($damage >= $piece->getMaxDurability()){
|
||||
$this->getInventory()->setArmorItem($i, Item::get(Item::AIR));
|
||||
}else{
|
||||
$piece->setDamage($damage + 1);
|
||||
$this->getInventory()->setArmorItem($i, $piece);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this->getLastDamageCause() === $source){
|
||||
@ -2617,6 +2688,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$pk->event = 2;
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getData(){ //TODO
|
||||
@ -2652,7 +2725,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
|
||||
$this->airTicks = 300;
|
||||
$this->fallDistance = 0;
|
||||
$this->resetFallDistance();
|
||||
$this->orderChunks();
|
||||
$this->nextChunkOrderRun = 0;
|
||||
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);
|
||||
|
@ -70,10 +70,10 @@ namespace pocketmine {
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\wizard\Installer;
|
||||
|
||||
const VERSION = "Alpha_1.4dev";
|
||||
const API_VERSION = "1.9.0";
|
||||
const VERSION = "1.4.1";
|
||||
const API_VERSION = "1.11.0";
|
||||
const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
|
||||
const MINECRAFT_VERSION = "v0.10.4 alpha";
|
||||
const MINECRAFT_VERSION = "v0.10.5 alpha";
|
||||
|
||||
/*
|
||||
* Startup code. Do not look at it, it may harm you.
|
||||
@ -95,6 +95,7 @@ namespace pocketmine {
|
||||
}
|
||||
|
||||
if(!class_exists("ClassLoader", false)){
|
||||
require_once(\pocketmine\PATH . "src/spl/ThreadedFactory.php");
|
||||
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
|
||||
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
|
||||
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
|
||||
@ -103,7 +104,6 @@ namespace pocketmine {
|
||||
$autoloader = new CompatibleClassLoader();
|
||||
$autoloader->addPath(\pocketmine\PATH . "src");
|
||||
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
|
||||
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "raklib");
|
||||
$autoloader->register(true);
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ namespace pocketmine {
|
||||
ini_set("display_startup_errors", 1);
|
||||
ini_set("default_charset", "utf-8");
|
||||
|
||||
ini_set("memory_limit", "256M"); //Default
|
||||
ini_set("memory_limit", -1);
|
||||
define("pocketmine\\START_TIME", microtime(true));
|
||||
|
||||
$opts = getopt("", ["enable-ansi", "disable-ansi", "data:", "plugins:", "no-wizard", "enable-profiler"]);
|
||||
@ -127,7 +127,9 @@ namespace pocketmine {
|
||||
define("pocketmine\\ANSI", (Utils::getOS() !== "win" or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"]));
|
||||
|
||||
|
||||
@mkdir(\pocketmine\DATA, 0777, true);
|
||||
if(!file_exists(\pocketmine\DATA)){
|
||||
mkdir(\pocketmine\DATA, 0777, true);
|
||||
}
|
||||
|
||||
//Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
|
||||
date_default_timezone_set("UTC");
|
||||
@ -331,7 +333,7 @@ namespace pocketmine {
|
||||
$args = $trace[$i]["params"];
|
||||
}
|
||||
foreach($args as $name => $value){
|
||||
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . @strval($value)) . ", ";
|
||||
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . (is_array($value) ? "Array()" : @strval($value))) . ", ";
|
||||
}
|
||||
}
|
||||
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . substr($params, 0, -2) . ")";
|
||||
@ -432,7 +434,7 @@ namespace pocketmine {
|
||||
new Installer();
|
||||
}
|
||||
|
||||
if(substr(__FILE__, 0, 7) !== "phar://"){
|
||||
if(\Phar::running(true) === ""){
|
||||
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,7 @@ use pocketmine\plugin\Plugin;
|
||||
use pocketmine\plugin\PluginLoadOrder;
|
||||
use pocketmine\plugin\PluginManager;
|
||||
use pocketmine\scheduler\CallbackTask;
|
||||
use pocketmine\scheduler\GarbageCollectionTask;
|
||||
use pocketmine\scheduler\SendUsageTask;
|
||||
use pocketmine\scheduler\ServerScheduler;
|
||||
use pocketmine\tile\Chest;
|
||||
@ -300,7 +301,7 @@ class Server{
|
||||
* @return int
|
||||
*/
|
||||
public function getViewDistance(){
|
||||
return max(56, $this->getProperty("chunk-sending.max-chunks", 96));
|
||||
return max(56, $this->getProperty("chunk-sending.max-chunks", 256));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -622,6 +623,16 @@ class Server{
|
||||
$this->mainInterface->putRaw($address, $port, $payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks an IP address from the main interface. Setting timeout to -1 will block it forever
|
||||
*
|
||||
* @param string $address
|
||||
* @param int $timeout
|
||||
*/
|
||||
public function blockAddress($address, $timeout = 300){
|
||||
$this->mainInterface->blockAddress($address, $timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
* @param int $port
|
||||
@ -633,9 +644,13 @@ class Server{
|
||||
$this->queryHandler->handle($address, $port, $payload);
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
if($this->logger instanceof MainLogger){
|
||||
$this->logger->logException($e);
|
||||
if(\pocketmine\DEBUG > 1){
|
||||
if($this->logger instanceof MainLogger){
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
}
|
||||
|
||||
$this->blockAddress($address, 600);
|
||||
}
|
||||
//TODO: add raw packet events
|
||||
}
|
||||
@ -668,7 +683,7 @@ class Server{
|
||||
$result = $this->getPlayerExact($name);
|
||||
|
||||
if($result === null){
|
||||
return new OfflinePlayer($this, $name);
|
||||
$result = new OfflinePlayer($this, $name);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@ -796,8 +811,15 @@ class Server{
|
||||
*/
|
||||
public function saveOfflinePlayerData($name, Compound $nbtTag){
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
$nbt->setData($nbtTag);
|
||||
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed());
|
||||
try{
|
||||
$nbt->setData($nbtTag);
|
||||
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed());
|
||||
}catch(\Exception $e){
|
||||
$this->logger->critical("Could not save player " . $name . ": " . $e->getMessage());
|
||||
if(\pocketmine\DEBUG > 1 and $this->logger instanceof MainLogger){
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1117,10 +1139,11 @@ class Server{
|
||||
|
||||
$seed = $seed === null ? Binary::readInt(@Utils::getRandomBytes(4, false)) : (int) $seed;
|
||||
|
||||
if($generator !== null and class_exists($generator) and is_subclass_of($generator, Generator::class)){
|
||||
$generator = new $generator($options);
|
||||
}else{
|
||||
if(!isset($options["presey"])){
|
||||
$options["preset"] = $this->getConfigString("generator-settings", "");
|
||||
}
|
||||
|
||||
if(!($generator !== null and class_exists($generator, true) and is_subclass_of($generator, Generator::class))){
|
||||
$generator = Generator::getGenerator($this->getLevelType());
|
||||
}
|
||||
|
||||
@ -1128,14 +1151,22 @@ class Server{
|
||||
$provider = LevelProviderManager::getProviderByName($providerName = "mcregion");
|
||||
}
|
||||
|
||||
$path = $this->getDataPath() . "worlds/" . $name . "/";
|
||||
/** @var \pocketmine\level\format\LevelProvider $provider */
|
||||
$provider::generate($path, $name, $seed, $generator, $options);
|
||||
try{
|
||||
$path = $this->getDataPath() . "worlds/" . $name . "/";
|
||||
/** @var \pocketmine\level\format\LevelProvider $provider */
|
||||
$provider::generate($path, $name, $seed, $generator, $options);
|
||||
|
||||
$level = new Level($this, $name, $path, $provider);
|
||||
$this->levels[$level->getId()] = $level;
|
||||
$level = new Level($this, $name, $path, $provider);
|
||||
$this->levels[$level->getId()] = $level;
|
||||
|
||||
$level->initLevel();
|
||||
$level->initLevel();
|
||||
}catch(\Exception $e){
|
||||
$this->logger->error("Could not generate level \"" . $name . "\": " . $e->getMessage());
|
||||
if($this->logger instanceof MainLogger){
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->getPluginManager()->callEvent(new LevelInitEvent($level));
|
||||
|
||||
@ -1444,31 +1475,22 @@ class Server{
|
||||
$this->autoloader = $autoloader;
|
||||
$this->logger = $logger;
|
||||
$this->filePath = $filePath;
|
||||
@mkdir($dataPath . "worlds/", 0777);
|
||||
@mkdir($dataPath . "players/", 0777);
|
||||
@mkdir($pluginPath, 0777);
|
||||
if(!file_exists($dataPath . "worlds/")){
|
||||
mkdir($dataPath . "worlds/", 0777);
|
||||
}
|
||||
|
||||
if(!file_exists($dataPath . "players/")){
|
||||
mkdir($dataPath . "players/", 0777);
|
||||
}
|
||||
|
||||
if(!file_exists($pluginPath)){
|
||||
mkdir($pluginPath, 0777);
|
||||
}
|
||||
|
||||
$this->dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR;
|
||||
$this->pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR;
|
||||
|
||||
$this->entityMetadata = new EntityMetadataStore();
|
||||
$this->playerMetadata = new PlayerMetadataStore();
|
||||
$this->levelMetadata = new LevelMetadataStore();
|
||||
|
||||
$this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
|
||||
$this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
|
||||
if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){
|
||||
@rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
|
||||
}
|
||||
@touch($this->dataPath . "banned-players.txt");
|
||||
$this->banByName = new BanList($this->dataPath . "banned-players.txt");
|
||||
$this->banByName->load();
|
||||
@touch($this->dataPath . "banned-ips.txt");
|
||||
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
|
||||
$this->banByIP->load();
|
||||
|
||||
$this->consoleThreaded = new \Threaded();
|
||||
$this->console = new CommandReader($this->consoleThreaded);
|
||||
$this->console = new CommandReader();
|
||||
|
||||
$version = new VersionString($this->getPocketMineVersion());
|
||||
$this->logger->info("Starting Minecraft: PE server version " . TextFormat::AQUA . $this->getVersion());
|
||||
@ -1487,7 +1509,7 @@ class Server{
|
||||
$this->properties = new Config($this->dataPath . "server.properties", Config::PROPERTIES, [
|
||||
"motd" => "Minecraft: PE Server",
|
||||
"server-port" => 19132,
|
||||
"memory-limit" => "256M",
|
||||
"memory-limit" => -1,
|
||||
"white-list" => false,
|
||||
"announce-player-achievements" => true,
|
||||
"spawn-protection" => 16,
|
||||
@ -1518,18 +1540,34 @@ class Server{
|
||||
$this->rcon = new RCON($this, $this->getConfigString("rcon.password", ""), $this->getConfigInt("rcon.port", $this->getPort()), ($ip = $this->getIp()) != "" ? $ip : "0.0.0.0", $this->getConfigInt("rcon.threads", 1), $this->getConfigInt("rcon.clients-per-thread", 50));
|
||||
}
|
||||
|
||||
$this->entityMetadata = new EntityMetadataStore();
|
||||
$this->playerMetadata = new PlayerMetadataStore();
|
||||
$this->levelMetadata = new LevelMetadataStore();
|
||||
|
||||
$this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
|
||||
$this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
|
||||
if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){
|
||||
@rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
|
||||
}
|
||||
@touch($this->dataPath . "banned-players.txt");
|
||||
$this->banByName = new BanList($this->dataPath . "banned-players.txt");
|
||||
$this->banByName->load();
|
||||
@touch($this->dataPath . "banned-ips.txt");
|
||||
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
|
||||
$this->banByIP->load();
|
||||
|
||||
$this->maxPlayers = $this->getConfigInt("max-players", 20);
|
||||
$this->setAutoSave($this->getConfigBoolean("auto-save", true));
|
||||
|
||||
if(($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", "256M")))) !== false){
|
||||
if(($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", -1)))) !== false and $memory > 1){
|
||||
$value = ["M" => 1, "G" => 1024];
|
||||
$real = ((int) substr($memory, 0, -1)) * $value[substr($memory, -1)];
|
||||
if($real < 128){
|
||||
$this->logger->warning($this->getName() . " may not work right with less than 128MB of RAM", true, true, 0);
|
||||
$this->logger->warning($this->getName() . " may not work right with less than 128MB of RAM");
|
||||
}
|
||||
@ini_set("memory_limit", $memory);
|
||||
}else{
|
||||
$this->setConfigString("memory-limit", "256M");
|
||||
$this->setConfigString("memory-limit", -1);
|
||||
}
|
||||
|
||||
if($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3){
|
||||
@ -1658,6 +1696,8 @@ class Server{
|
||||
$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 GarbageCollectionTask(), 900);
|
||||
|
||||
$this->enablePlugins(PluginLoadOrder::POSTWORLD);
|
||||
|
||||
$this->start();
|
||||
@ -1665,7 +1705,7 @@ class Server{
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
* @param Player[]|null $recipients
|
||||
* @param Player[] $recipients
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@ -1673,6 +1713,8 @@ class Server{
|
||||
if(!is_array($recipients)){
|
||||
return $this->broadcast($message, self::BROADCAST_CHANNEL_USERS);
|
||||
}
|
||||
|
||||
/** @var Player[] $recipients */
|
||||
foreach($recipients as $recipient){
|
||||
$recipient->sendMessage($message);
|
||||
}
|
||||
@ -1810,7 +1852,7 @@ class Server{
|
||||
$this->properties->reload();
|
||||
$this->maxPlayers = $this->getConfigInt("max-players", 20);
|
||||
|
||||
if(($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", "256M")))) !== false){
|
||||
if(($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", -1)))) !== false and $memory > 1){
|
||||
$value = ["M" => 1, "G" => 1024];
|
||||
$real = ((int) substr($memory, 0, -1)) * $value[substr($memory, -1)];
|
||||
if($real < 256){
|
||||
@ -1818,7 +1860,7 @@ class Server{
|
||||
}
|
||||
@ini_set("memory_limit", $memory);
|
||||
}else{
|
||||
$this->setConfigString("memory-limit", "256M");
|
||||
$this->setConfigString("memory-limit", -1);
|
||||
}
|
||||
|
||||
if($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3){
|
||||
@ -1830,6 +1872,9 @@ class Server{
|
||||
$this->reloadWhitelist();
|
||||
$this->operators->reload();
|
||||
|
||||
foreach($this->getIPBans()->getEntries() as $entry){
|
||||
$this->blockAddress($entry->getName(), -1);
|
||||
}
|
||||
|
||||
$this->pluginManager->registerInterface(PharPluginLoader::class);
|
||||
$this->pluginManager->loadPlugins($this->pluginPath);
|
||||
@ -1907,6 +1952,9 @@ class Server{
|
||||
|
||||
}
|
||||
|
||||
foreach($this->getIPBans()->getEntries() as $entry){
|
||||
$this->blockAddress($entry->getName(), -1);
|
||||
}
|
||||
|
||||
if($this->getProperty("settings.send-usage", true) !== false){
|
||||
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "sendUsage"]), 6000, 6000);
|
||||
@ -1953,16 +2001,6 @@ class Server{
|
||||
}
|
||||
}
|
||||
|
||||
public function checkMemory(){
|
||||
//TODO
|
||||
$info = $this->debugInfo();
|
||||
$data = $info["memory_usage"] . "," . $info["players"] . "," . $info["entities"];
|
||||
$i = count($this->memoryStats) - 1;
|
||||
if($i < 0 or $this->memoryStats[$i] !== $data){
|
||||
$this->memoryStats[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
public function exceptionHandler(\Exception $e, $trace = null){
|
||||
if($e === null){
|
||||
return;
|
||||
@ -1970,6 +2008,10 @@ class Server{
|
||||
|
||||
global $lastError;
|
||||
|
||||
if($trace === null){
|
||||
$trace = $e->getTrace();
|
||||
}
|
||||
|
||||
$errstr = $e->getMessage();
|
||||
$errfile = $e->getFile();
|
||||
$errno = $e->getCode();
|
||||
@ -1992,7 +2034,7 @@ class Server{
|
||||
"fullFile" => $e->getFile(),
|
||||
"file" => $errfile,
|
||||
"line" => $errline,
|
||||
"trace" => @getTrace($trace === null ? 3 : 0, $trace)
|
||||
"trace" => @getTrace(1, $trace)
|
||||
];
|
||||
|
||||
global $lastExceptionError, $lastError;
|
||||
@ -2010,7 +2052,12 @@ class Server{
|
||||
ini_set("error_reporting", 0);
|
||||
ini_set("memory_limit", -1); //Fix error dump not dumped on memory problems
|
||||
$this->logger->emergency("An unrecoverable error has occurred and the server has crashed. Creating a crash dump");
|
||||
$dump = new CrashDump($this);
|
||||
try{
|
||||
$dump = new CrashDump($this);
|
||||
}catch(\Exception $e){
|
||||
$this->logger->critical("Could not create Crash Dump: " . $e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logger->emergency("Please submit the \"" . $dump->getPath() . "\" file to the Bug Reporting page. Give as much info as you can.");
|
||||
|
||||
@ -2077,7 +2124,7 @@ class Server{
|
||||
$level->doTick($currentTick);
|
||||
}catch(\Exception $e){
|
||||
$this->logger->critical("Could not tick level " . $level->getName() . ": " . $e->getMessage());
|
||||
if($this->logger instanceof MainLogger){
|
||||
if(\pocketmine\DEBUG > 1 and $this->logger instanceof MainLogger){
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
}
|
||||
@ -2110,7 +2157,7 @@ class Server{
|
||||
|
||||
public function sendUsage(){
|
||||
if($this->lastSendUsage instanceof SendUsageTask){
|
||||
if(!$this->lastSendUsage->isFinished()){ //do not call multiple times
|
||||
if(!$this->lastSendUsage->isGarbage()){ //do not call multiple times
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2122,7 +2169,7 @@ class Server{
|
||||
}
|
||||
|
||||
$version = new VersionString();
|
||||
$this->lastSendUsage = new SendUsageTask("http://stats.pocketmine.net/usage.php", [
|
||||
$this->lastSendUsage = new SendUsageTask("https://stats.pocketmine.net/usage.php", [
|
||||
"serverid" => $this->serverID,
|
||||
"port" => $this->getPort(),
|
||||
"os" => Utils::getOS(),
|
||||
|
@ -26,9 +26,13 @@ namespace pocketmine;
|
||||
*/
|
||||
abstract class Thread extends \Thread{
|
||||
|
||||
public final function start($options = PTHREADS_INHERIT_ALL){
|
||||
public function start($options = PTHREADS_INHERIT_ALL){
|
||||
ThreadManager::getInstance()->add($this);
|
||||
|
||||
return parent::start($options);
|
||||
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
|
||||
return parent::start($options);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -26,9 +26,13 @@ namespace pocketmine;
|
||||
*/
|
||||
abstract class Worker extends \Worker{
|
||||
|
||||
public final function start($options = PTHREADS_INHERIT_ALL){
|
||||
public function start($options = PTHREADS_INHERIT_ALL){
|
||||
ThreadManager::getInstance()->add($this);
|
||||
|
||||
return parent::start($options);
|
||||
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated() and !$this->isShutdown()){
|
||||
return parent::start($options);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -144,7 +144,6 @@ class Block extends Position implements Metadatable{
|
||||
const SUGARCANE_BLOCK = 83;
|
||||
|
||||
const FENCE = 85;
|
||||
const FENCE_OAK = 85;
|
||||
const PUMPKIN = 86;
|
||||
const NETHERRACK = 87;
|
||||
const SOUL_SAND = 88;
|
||||
@ -236,11 +235,6 @@ class Block extends Position implements Metadatable{
|
||||
const FENCE_GATE_JUNGLE = 185;
|
||||
const FENCE_GATE_DARK_OAK = 186;
|
||||
const FENCE_GATE_ACACIA = 187;
|
||||
const FENCE_SPRUCE = 188;
|
||||
const FENCE_BIRCH = 189;
|
||||
const FENCE_JUNGLE = 190;
|
||||
const FENCE_DARK_OAK = 191;
|
||||
const FENCE_ACACIA = 192;
|
||||
|
||||
const PODZOL = 243;
|
||||
const BEETROOT_BLOCK = 244;
|
||||
@ -368,10 +362,11 @@ class Block extends Position implements Metadatable{
|
||||
[Item::WOODEN_DOOR, 0],
|
||||
[Item::TRAPDOOR, 0],
|
||||
[Item::FENCE, 0],
|
||||
[Item::FENCE_SPRUCE, 0],
|
||||
[Item::FENCE_BIRCH, 0],
|
||||
[Item::FENCE_DARK_OAK, 0],
|
||||
[Item::FENCE_JUNGLE, 0],
|
||||
[Item::FENCE, 1],
|
||||
[Item::FENCE, 2],
|
||||
[Item::FENCE, 3],
|
||||
[Item::FENCE, 4],
|
||||
[Item::FENCE, 5],
|
||||
[Item::FENCE_GATE, 0],
|
||||
[Item::FENCE_GATE_BIRCH, 0],
|
||||
[Item::FENCE_GATE_SPRUCE, 0],
|
||||
@ -723,11 +718,6 @@ class Block extends Position implements Metadatable{
|
||||
self::$list[self::FENCE_GATE_JUNGLE] = FenceGateJungle::class;
|
||||
self::$list[self::FENCE_GATE_DARK_OAK] = FenceGateDarkOak::class;
|
||||
self::$list[self::FENCE_GATE_ACACIA] = FenceGateAcacia::class;
|
||||
self::$list[self::FENCE_SPRUCE] = FenceSpruce::class;
|
||||
self::$list[self::FENCE_BIRCH] = FenceBirch::class;
|
||||
self::$list[self::FENCE_DARK_OAK] = FenceDarkOak::class;
|
||||
self::$list[self::FENCE_JUNGLE] = FenceJungle::class;
|
||||
self::$list[self::FENCE_ACACIA] = FenceAcacia::class;
|
||||
|
||||
self::$list[self::PODZOL] = Podzol::class;
|
||||
self::$list[self::BEETROOT_BLOCK] = Beetroot::class;
|
||||
@ -987,6 +977,7 @@ class Block extends Position implements Metadatable{
|
||||
$this->y = (int) $v->y;
|
||||
$this->z = (int) $v->z;
|
||||
$this->level = $v->level;
|
||||
$this->boundingBox = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1030,7 +1021,7 @@ class Block extends Position implements Metadatable{
|
||||
return $this->getLevel()->getBlock(Vector3::getSide($side, $step));
|
||||
}
|
||||
|
||||
return Block::get(Item::AIR, 0, new Position($v->x, $v->y, $v->z, null));
|
||||
return Block::get(Item::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1048,7 +1039,7 @@ class Block extends Position implements Metadatable{
|
||||
*/
|
||||
public function collidesWithBB(AxisAlignedBB $bb, &$list = []){
|
||||
$bb2 = $this->getBoundingBox();
|
||||
if($bb2 !== null and $bb2->intersectsWith($bb)){
|
||||
if($bb2 !== null and $bb->intersectsWith($bb2)){
|
||||
$list[] = $bb2;
|
||||
}
|
||||
}
|
||||
@ -1064,11 +1055,10 @@ class Block extends Position implements Metadatable{
|
||||
* @return AxisAlignedBB
|
||||
*/
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}else{
|
||||
return $this->boundingBox = $this->recalculateBoundingBox();
|
||||
if($this->boundingBox === null){
|
||||
$this->boundingBox = $this->recalculateBoundingBox();
|
||||
}
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -25,6 +25,8 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -65,7 +67,14 @@ class Cactus extends Transparent{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
|
||||
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
|
||||
if($entity instanceof InventoryHolder){
|
||||
$inventory = $entity->getInventory();
|
||||
if($inventory instanceof PlayerInventory){
|
||||
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
|
||||
}
|
||||
}
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, $damage);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
|
||||
@ -77,7 +86,7 @@ class Cactus extends Transparent{
|
||||
}else{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
$b = $this->getSide($side);
|
||||
if(!$b->isFlowable){
|
||||
if(!$b->canBeFlowedInto()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
}
|
||||
}
|
||||
@ -128,4 +137,4 @@ class Cactus extends Transparent{
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class Cobweb extends Flowable{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance = 0;
|
||||
$entity->resetFallDistance();
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
|
@ -27,16 +27,27 @@ class Fence extends Transparent{
|
||||
|
||||
protected $id = self::FENCE;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function getHardness(){
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return "Oak Fence";
|
||||
static $names = [
|
||||
0 => "Oak Fence",
|
||||
1 => "Spruce Fence",
|
||||
2 => "Birch Fence",
|
||||
3 => "Jungle Fence",
|
||||
4 => "Acacia Fence",
|
||||
5 => "Dark Oak Fence",
|
||||
"",
|
||||
""
|
||||
];
|
||||
return $names[$this->meta & 0x07];
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
@ -65,4 +76,4 @@ class Fence extends Transparent{
|
||||
return (!($block instanceof Fence) and !($block instanceof FenceGate)) ? $block->isSolid() : true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +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\block;
|
||||
|
||||
class FenceAcacia extends Fence{
|
||||
|
||||
protected $id = self::FENCE_ACACIA;
|
||||
|
||||
public function getName(){
|
||||
return "Acacia Fence";
|
||||
}
|
||||
}
|
@ -1,31 +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\block;
|
||||
|
||||
class FenceDarkOak extends Fence{
|
||||
|
||||
protected $id = self::FENCE_DARK_OAK;
|
||||
|
||||
public function getName(){
|
||||
return "Dark Oak Fence";
|
||||
}
|
||||
}
|
@ -1,31 +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\block;
|
||||
|
||||
class FenceJungle extends Fence{
|
||||
|
||||
protected $id = self::FENCE_JUNGLE;
|
||||
|
||||
public function getName(){
|
||||
return "Jungle Fence";
|
||||
}
|
||||
}
|
@ -1,31 +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\block;
|
||||
|
||||
class FenceSpruce extends Fence{
|
||||
|
||||
protected $id = self::FENCE_SPRUCE;
|
||||
|
||||
public function getName(){
|
||||
return "Spruce Fence";
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -25,6 +25,8 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\Server;
|
||||
@ -58,7 +60,14 @@ class Fire extends Flowable{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
|
||||
if($entity instanceof InventoryHolder){
|
||||
$inventory = $entity->getInventory();
|
||||
if($inventory instanceof PlayerInventory){
|
||||
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
|
||||
}
|
||||
}
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, $damage);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
|
||||
@ -94,4 +103,4 @@ class Fire extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class GlassPane extends Thin{
|
||||
|
||||
protected $id = self::GLASS_PANE;
|
||||
@ -38,4 +40,7 @@ class GlassPane extends Thin{
|
||||
return 1.5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [];
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
class IronBars extends Thin{
|
||||
|
||||
@ -33,5 +34,36 @@ class IronBars extends Thin{
|
||||
public function getName(){
|
||||
return "Iron Bars";
|
||||
}
|
||||
public function getHardness(){
|
||||
return 5;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item){
|
||||
switch($item->isPickaxe()){
|
||||
case 5:
|
||||
return 0.95;
|
||||
case 4:
|
||||
return 1.25;
|
||||
case 3:
|
||||
return 1.9;
|
||||
case 2:
|
||||
return 0.65;
|
||||
case 1:
|
||||
return 3.75;
|
||||
default:
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
if($item->isPickaxe() >= 1){
|
||||
return [
|
||||
[Item::IRON_BARS, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -52,7 +52,7 @@ class Ladder extends Transparent{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance = 0;
|
||||
$entity->resetFallDistance();
|
||||
$entity->onGround = true;
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -25,6 +25,8 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
@ -51,7 +53,14 @@ class Lava extends Liquid{
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance *= 0.5;
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
|
||||
if($entity instanceof InventoryHolder){
|
||||
$inventory = $entity->getInventory();
|
||||
if($inventory instanceof PlayerInventory){
|
||||
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
|
||||
}
|
||||
}
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, $damage);
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 15);
|
||||
|
@ -38,7 +38,7 @@ class Sapling extends Flowable{
|
||||
protected $id = self::SAPLING;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = 0;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
|
||||
public function canBeActivated(){
|
||||
|
@ -48,7 +48,7 @@ class SnowLayer extends Flowable{
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down instanceof Solid){
|
||||
if($down->isSolid()){
|
||||
$this->getLevel()->setBlock($block, $this, true);
|
||||
|
||||
return true;
|
||||
|
@ -50,8 +50,12 @@ class Stonecutter extends Solid{
|
||||
}
|
||||
|
||||
public function getDrops(Item $item){
|
||||
return [
|
||||
[$this->id, 0, 1],
|
||||
];
|
||||
if($item->isPickaxe() >= 1){
|
||||
return [
|
||||
[Item::STONECUTTER, 0, 1],
|
||||
];
|
||||
}else{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\Player;
|
||||
|
||||
class TallGrass extends Flowable{
|
||||
|
||||
@ -45,6 +46,17 @@ class TallGrass extends Flowable{
|
||||
];
|
||||
return $names[$this->meta & 0x03];
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getId() === self::GRASS){
|
||||
$this->getLevel()->setBlock($block, $this, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function onUpdate($type){
|
||||
@ -67,4 +79,4 @@ class TallGrass extends Flowable{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ class Torch extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
$below = $this->getSide(0);
|
||||
$side = $this->getDamage();
|
||||
$faces = [
|
||||
1 => 4,
|
||||
@ -55,7 +56,7 @@ class Torch extends Flowable{
|
||||
0 => 0,
|
||||
];
|
||||
|
||||
if($this->getSide($faces[$side])->isTransparent() === true and !($side === 0 and $this->getSide(0)->getId() === self::FENCE)){
|
||||
if($this->getSide($faces[$side])->isTransparent() === true and !($side === 0 and ($below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL))){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
@ -66,6 +67,8 @@ class Torch extends Flowable{
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$below = $this->getSide(0);
|
||||
|
||||
if($target->isTransparent() === false and $face !== 0){
|
||||
$faces = [
|
||||
1 => 5,
|
||||
@ -78,7 +81,7 @@ class Torch extends Flowable{
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
return true;
|
||||
}elseif($this->getSide(0)->isTransparent() === false or $this->getSide(0)->getId() === self::FENCE){
|
||||
}elseif($below->isTransparent() === false or $below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL){
|
||||
$this->meta = 0;
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
||||
|
@ -53,7 +53,7 @@ class Vine extends Transparent{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance = 0;
|
||||
$entity->resetFallDistance();
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
@ -42,7 +42,7 @@ class Water extends Liquid{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance = 0;
|
||||
$entity->resetFallDistance();
|
||||
if($entity->fireTicks > 0){
|
||||
$entity->extinguish();
|
||||
}
|
||||
|
@ -24,10 +24,6 @@ namespace pocketmine\command;
|
||||
use pocketmine\Thread;
|
||||
|
||||
class CommandReader extends Thread{
|
||||
|
||||
public $stream;
|
||||
/** @var resource */
|
||||
private $fp;
|
||||
private $readline;
|
||||
|
||||
/** @var \Threaded */
|
||||
@ -35,17 +31,15 @@ class CommandReader extends Thread{
|
||||
|
||||
/**
|
||||
* @param \Threaded $threaded
|
||||
* @param string $stream
|
||||
*/
|
||||
public function __construct(\Threaded $threaded, $stream = "php://stdin"){
|
||||
$this->stream = $stream;
|
||||
$this->buffer = $threaded;
|
||||
public function __construct(){
|
||||
$this->buffer = \ThreadedFactory::create();
|
||||
$this->start();
|
||||
}
|
||||
|
||||
private function readLine(){
|
||||
if(!$this->readline){
|
||||
$line = trim(fgets($this->fp));
|
||||
$line = trim(fgets(fopen("php://stdin", "r")));
|
||||
}else{
|
||||
$line = trim(readline("> "));
|
||||
if($line != ""){
|
||||
@ -73,12 +67,10 @@ class CommandReader extends Thread{
|
||||
|
||||
public function run(){
|
||||
$opts = getopt("", ["disable-readline"]);
|
||||
if(extension_loaded("readline") and $this->stream === "php://stdin" and !isset($opts["disable-readline"])){
|
||||
if(extension_loaded("readline") and !isset($opts["disable-readline"])){
|
||||
$this->readline = true;
|
||||
}else{
|
||||
$this->readline = false;
|
||||
$this->fp = fopen($this->stream, "r");
|
||||
stream_set_blocking($this->fp, 1); //Non-blocking STDIN won't work on Windows
|
||||
}
|
||||
|
||||
$lastLine = microtime(true);
|
||||
@ -94,4 +86,4 @@ class CommandReader extends Thread{
|
||||
$lastLine = microtime(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ class FormattedCommandAlias extends Command{
|
||||
$sender->sendMessage(TextFormat::RED . $e->getMessage());
|
||||
}else{
|
||||
$sender->sendMessage(TextFormat::RED . "An internal error occurred while attempting to perform this command");
|
||||
if(($logger = $sender->getServer()->getLogger()) instanceof MainLogger){
|
||||
$logger = $sender->getServer()->getLogger();
|
||||
if($logger instanceof MainLogger){
|
||||
$logger->logException($e);
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,8 @@ class SimpleCommandMap implements CommandMap{
|
||||
$target->execute($sender, $sentCommandLabel, $args);
|
||||
}catch(\Exception $e){
|
||||
$this->server->getLogger()->critical("Unhandled exception executing command '" . $commandLine . "' in " . $target . ": " . $e->getMessage());
|
||||
if(($logger = $sender->getServer()->getLogger()) instanceof MainLogger){
|
||||
$logger = $sender->getServer()->getLogger();
|
||||
if($logger instanceof MainLogger){
|
||||
$logger->logException($e);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class BanIpCommand extends VanillaCommand{
|
||||
parent::__construct(
|
||||
$name,
|
||||
"Prevents the specified IP address from using this server",
|
||||
"/ban <address|player> [reason...]"
|
||||
"/ban-ip <address|player> [reason...]"
|
||||
);
|
||||
$this->setPermission("pocketmine.command.ban.ip");
|
||||
}
|
||||
@ -75,6 +75,8 @@ class BanIpCommand extends VanillaCommand{
|
||||
}
|
||||
}
|
||||
|
||||
$sender->getServer()->blockAddress($ip, -1);
|
||||
|
||||
Command::broadcastCommandMessage($sender, "Banned IP Address " . $ip);
|
||||
}
|
||||
}
|
@ -64,6 +64,7 @@ class HelpCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
if($command === ""){
|
||||
/** @var Command[][] $commands */
|
||||
$commands = [];
|
||||
foreach($sender->getServer()->getCommandMap()->getCommands() as $command){
|
||||
if($command->testPermissionSilent($sender)){
|
||||
@ -86,11 +87,11 @@ class HelpCommand extends VanillaCommand{
|
||||
|
||||
return true;
|
||||
}else{
|
||||
if(($command = $sender->getServer()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){
|
||||
if($command->testPermissionSilent($sender)){
|
||||
$message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $command->getName() . TextFormat::YELLOW . " ---------\n";
|
||||
$message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $command->getDescription() . "\n";
|
||||
$message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $command->getUsage())) . "\n";
|
||||
if(($cmd = $sender->getServer()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){
|
||||
if($cmd->testPermissionSilent($sender)){
|
||||
$message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $cmd->getName() . TextFormat::YELLOW . " ---------\n";
|
||||
$message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $cmd->getDescription() . "\n";
|
||||
$message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $cmd->getUsage())) . "\n";
|
||||
$sender->sendMessage($message);
|
||||
|
||||
return true;
|
||||
|
@ -60,6 +60,7 @@ class TimingsCommand extends VanillaCommand{
|
||||
}elseif($mode === "off"){
|
||||
$sender->getServer()->getPluginManager()->setUseTimings(false);
|
||||
$sender->sendMessage("Disabled Timings");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!$sender->getServer()->getPluginManager()->useTimings()){
|
||||
@ -78,7 +79,10 @@ class TimingsCommand extends VanillaCommand{
|
||||
$sampleTime = microtime(true) - self::$timingStart;
|
||||
$index = 0;
|
||||
$timingFolder = $sender->getServer()->getDataPath() . "timings/";
|
||||
@mkdir($timingFolder, 0777);
|
||||
|
||||
if(!file_exists($timingFolder)){
|
||||
mkdir($timingFolder, 0777);
|
||||
}
|
||||
$timings = $timingFolder . "timings.txt";
|
||||
while(file_exists($timings)){
|
||||
$timings = $timingFolder . "timings" . (++$index) . ".txt";
|
||||
@ -130,4 +134,4 @@ class TimingsCommand extends VanillaCommand{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -33,6 +33,8 @@ use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||
use pocketmine\event\entity\EntitySpawnEvent;
|
||||
use pocketmine\event\entity\EntityTeleportEvent;
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\level\Level;
|
||||
@ -709,6 +711,10 @@ abstract class Entity extends Location implements Metadatable{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function resetFallDistance(){
|
||||
$this->fallDistance = 0;
|
||||
}
|
||||
|
||||
protected function updateFallState($distanceThisTick, $onGround){
|
||||
if($onGround === true){
|
||||
if($this->fallDistance > 0){
|
||||
@ -717,7 +723,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
}
|
||||
|
||||
$this->fall($this->fallDistance);
|
||||
$this->fallDistance = 0;
|
||||
$this->resetFallDistance();
|
||||
}
|
||||
}elseif($distanceThisTick < 0){
|
||||
$this->fallDistance -= $distanceThisTick;
|
||||
@ -731,6 +737,13 @@ abstract class Entity extends Location implements Metadatable{
|
||||
public function fall($fallDistance){
|
||||
$damage = floor($fallDistance - 3);
|
||||
if($damage > 0){
|
||||
$damage = [EntityDamageEvent::MODIFIER_BASE => $damage];
|
||||
if($this instanceof InventoryHolder){
|
||||
$inventory = $this->getInventory();
|
||||
if($inventory instanceof PlayerInventory){
|
||||
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
|
||||
}
|
||||
}
|
||||
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage);
|
||||
$this->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
@ -766,8 +779,6 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$this->despawnFromAll();
|
||||
if($this instanceof Player){
|
||||
foreach($this->usedChunks as $index => $d){
|
||||
$X = null;
|
||||
$Z = null;
|
||||
Level::getXZ($index, $X, $Z);
|
||||
$this->unloadChunk($X, $Z);
|
||||
}
|
||||
@ -817,6 +828,53 @@ abstract class Entity extends Location implements Metadatable{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function fastMove($dx, $dy, $dz){
|
||||
if($dx == 0 and $dz == 0 and $dy == 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
Timings::$entityMoveTimer->startTiming();
|
||||
|
||||
$axisalignedbb = clone $this->boundingBox;
|
||||
|
||||
$newBB = $this->boundingBox->getOffsetBoundingBox($dx, $dy, $dz);
|
||||
|
||||
$list = $this->level->getCollisionCubes($this, $newBB->expand(-0.01, -0.01, -0.01));
|
||||
|
||||
if(count($list) === 0){
|
||||
$this->boundingBox = $newBB;
|
||||
}
|
||||
|
||||
$pos = new Vector3(
|
||||
($this->boundingBox->minX + $this->boundingBox->maxX) / 2,
|
||||
$this->boundingBox->minY + $this->ySize,
|
||||
($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2
|
||||
);
|
||||
|
||||
$result = true;
|
||||
|
||||
if(!$this->setPosition($pos)){
|
||||
$this->boundingBox->setBB($axisalignedbb);
|
||||
$result = false;
|
||||
}else{
|
||||
if(!$this->onGround or $dy != 0){
|
||||
$bb = clone $this->boundingBox;
|
||||
$bb->minY -= 0.75;
|
||||
$this->onGround = false;
|
||||
|
||||
if(count($this->level->getCollisionBlocks($bb)) > 0){
|
||||
$this->onGround = true;
|
||||
}
|
||||
}
|
||||
$this->isCollided = $this->onGround;
|
||||
$this->updateFallState($dy, $this->onGround);
|
||||
}
|
||||
|
||||
Timings::$entityMoveTimer->stopTiming();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function move($dx, $dy, $dz){
|
||||
|
||||
if($dx == 0 and $dz == 0 and $dy == 0){
|
||||
@ -827,6 +885,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$this->boundingBox->offset($dx, $dy, $dz);
|
||||
$this->setPosition(new Vector3(($this->boundingBox->minX + $this->boundingBox->maxX) / 2, $this->boundingBox->minY, ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2));
|
||||
$this->onGround = $this instanceof Player ? true : false;
|
||||
return true;
|
||||
}else{
|
||||
|
||||
Timings::$entityMoveTimer->startTiming();
|
||||
@ -877,7 +936,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
//TODO: big messy loop
|
||||
}*/
|
||||
|
||||
$list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
|
||||
$list = $this->level->getCollisionCubes($this, $this->boundingBox->getOffsetBoundingBox($dx, $dy, $dz));
|
||||
|
||||
|
||||
foreach($list as $bb){
|
||||
@ -931,18 +990,13 @@ abstract class Entity extends Location implements Metadatable{
|
||||
|
||||
$this->boundingBox->setBB($axisalignedbb);
|
||||
|
||||
$list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($movX, $dy, $movZ), false);
|
||||
$list = $this->level->getCollisionCubes($this, $this->boundingBox->getOffsetBoundingBox($dx, $dy, $dz), false);
|
||||
|
||||
foreach($list as $bb){
|
||||
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
||||
}
|
||||
|
||||
$this->boundingBox->offset(0, $dy, 0);
|
||||
if($movY != $dy){
|
||||
$dx = 0;
|
||||
$dy = 0;
|
||||
$dz = 0;
|
||||
}
|
||||
|
||||
foreach($list as $bb){
|
||||
$dx = $bb->calculateXOffset($this->boundingBox, $dx);
|
||||
@ -966,7 +1020,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$dz = 0;
|
||||
}
|
||||
|
||||
if($movY != $dy){
|
||||
if($dy == 0){
|
||||
$dx = 0;
|
||||
$dy = 0;
|
||||
$dz = 0;
|
||||
@ -1009,8 +1063,8 @@ abstract class Entity extends Location implements Metadatable{
|
||||
if($this instanceof Player){
|
||||
if(!$this->onGround or $movY != 0){
|
||||
$bb = clone $this->boundingBox;
|
||||
$bb->maxY = $bb->minY + 1;
|
||||
if(count($this->level->getCollisionBlocks($bb->expand(0.01, 0.01, 0.01))) > 0){
|
||||
$bb->minY -= 1;
|
||||
if(count($this->level->getCollisionBlocks($bb)) > 0){
|
||||
$this->onGround = true;
|
||||
}else{
|
||||
$this->onGround = false;
|
||||
@ -1120,7 +1174,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$this->chunk->removeEntity($this);
|
||||
}
|
||||
$this->level->loadChunk($this->x >> 4, $this->z >> 4);
|
||||
$this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4);
|
||||
$this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4, true);
|
||||
$this->chunkX = $this->chunk->getX();
|
||||
$this->chunkZ = $this->chunk->getZ();
|
||||
|
||||
@ -1206,7 +1260,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
|
||||
$this->setMotion(new Vector3(0, 0, 0));
|
||||
if($this->setPositionAndRotation($pos, $yaw === null ? $this->yaw : $yaw, $pitch === null ? $this->pitch : $pitch, true) !== false){
|
||||
$this->fallDistance = 0;
|
||||
$this->resetFallDistance();
|
||||
$this->onGround = true;
|
||||
|
||||
$this->lastX = $this->x;
|
||||
@ -1248,8 +1302,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
if(!$this->closed){
|
||||
$this->server->getPluginManager()->callEvent(new EntityDespawnEvent($this));
|
||||
$this->closed = true;
|
||||
unset($this->level->updateEntities[$this->id]);
|
||||
if($this->chunk instanceof FullChunk){
|
||||
if($this->chunk !== null){
|
||||
$this->chunk->removeEntity($this);
|
||||
}
|
||||
if($this->level instanceof Level){
|
||||
|
@ -23,6 +23,8 @@ namespace pocketmine\entity;
|
||||
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Flowable;
|
||||
use pocketmine\block\Liquid;
|
||||
use pocketmine\event\entity\EntityBlockChangeEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||
@ -111,7 +113,7 @@ class FallingSand extends Entity{
|
||||
if($this->onGround){
|
||||
$this->kill();
|
||||
$block = $this->level->getBlock($pos);
|
||||
if(!$block->isFullBlock){
|
||||
if($block->getId() > 0 and !$block->isSolid() and !($block instanceof Liquid)){
|
||||
$this->getLevel()->dropItem($this, ItemItem::get($this->getBlock(), $this->getDamage(), 1));
|
||||
}else{
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -28,6 +28,8 @@ use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityDeathEvent;
|
||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\item\Item as ItemItem;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\Short;
|
||||
@ -164,19 +166,35 @@ abstract class Living extends Entity implements Damageable{
|
||||
return $this->deadTicks < 10;
|
||||
}
|
||||
|
||||
parent::entityBaseTick($tickDiff);
|
||||
$hasUpdate = parent::entityBaseTick($tickDiff);
|
||||
|
||||
if($this->dead !== true and $this->isInsideOfSolid()){
|
||||
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
|
||||
$hasUpdate = true;
|
||||
$damage = [EntityDamageEvent::MODIFIER_BASE => 1];
|
||||
if($this instanceof InventoryHolder){
|
||||
$inventory = $this->getInventory();
|
||||
if($inventory instanceof PlayerInventory){
|
||||
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory;
|
||||
}
|
||||
}
|
||||
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, $damage);
|
||||
$this->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
|
||||
if($this->dead !== true and $this->isInsideOfWater()){
|
||||
$hasUpdate = true;
|
||||
$this->airTicks -= $tickDiff;
|
||||
if($this->airTicks <= -20){
|
||||
$this->airTicks = 0;
|
||||
|
||||
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
|
||||
$damage = [EntityDamageEvent::MODIFIER_BASE => 2];
|
||||
if($this instanceof InventoryHolder){
|
||||
$inventory = $this->getInventory();
|
||||
if($inventory instanceof PlayerInventory){
|
||||
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
|
||||
}
|
||||
}
|
||||
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, $damage);
|
||||
$this->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
}else{
|
||||
@ -188,6 +206,8 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
Timings::$timerEntityBaseTick->stopTiming();
|
||||
|
||||
return $hasUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -24,10 +24,11 @@ namespace pocketmine\entity;
|
||||
|
||||
use pocketmine\event\entity\EntityCombustByEntityEvent;
|
||||
use pocketmine\event\entity\EntityDamageByChildEntityEvent;
|
||||
use pocketmine\event\entity\EntityDamageByEntityEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||
use pocketmine\event\entity\ProjectileHitEvent;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\level\MovingObjectPosition;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\Short;
|
||||
@ -136,15 +137,22 @@ abstract class Projectile extends Entity{
|
||||
$this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
|
||||
|
||||
$motion = sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2);
|
||||
$damage = ceil($motion * $this->damage);
|
||||
|
||||
if($this->shootingEntity === null){
|
||||
$ev = new EntityDamageByEntityEvent($this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
|
||||
}else{
|
||||
$ev = new EntityDamageByChildEntityEvent($this->shootingEntity, $this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
|
||||
$damage = [EntityDamageEvent::MODIFIER_BASE => ceil($motion * $this->damage)];
|
||||
$hit = $movingObjectPosition->entityHit;
|
||||
if($hit instanceof InventoryHolder){
|
||||
$inventory = $hit->getInventory();
|
||||
if($inventory instanceof PlayerInventory){
|
||||
$damage[EntityDamageEvent::MODIFIER_ARMOR] = $inventory->getArmorPoints();
|
||||
}
|
||||
}
|
||||
|
||||
$movingObjectPosition->entityHit->attack($ev->getFinalDamage(), $ev);
|
||||
if($this->shootingEntity === null){
|
||||
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
|
||||
}else{
|
||||
$ev = new EntityDamageByChildEntityEvent($this->shootingEntity, $this, $hit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
|
||||
}
|
||||
|
||||
$hit->attack($ev->getFinalDamage(), $ev);
|
||||
|
||||
|
||||
if($this->fireTicks > 0){
|
||||
@ -188,4 +196,4 @@ abstract class Projectile extends Entity{
|
||||
return $hasUpdate;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\Player;
|
||||
|
||||
class BlockBreakEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var \pocketmine\Player */
|
||||
protected $player;
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class BlockFormEvent extends BlockGrowEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
public function __construct(Block $block, Block $newState){
|
||||
parent::__construct($block, $newState);
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class BlockGrowEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Block */
|
||||
private $newState;
|
||||
|
@ -31,8 +31,6 @@ use pocketmine\Player;
|
||||
*/
|
||||
class BlockPlaceEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var \pocketmine\Player */
|
||||
protected $player;
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class BlockSpreadEvent extends BlockFormEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Block */
|
||||
private $source;
|
||||
|
@ -28,7 +28,5 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class BlockUpdateEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
}
|
@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class LeavesDecayEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
public function __construct(Block $block){
|
||||
parent::__construct($block);
|
||||
|
@ -30,8 +30,6 @@ use pocketmine\Player;
|
||||
*/
|
||||
class SignChangeEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var \pocketmine\Player */
|
||||
private $player;
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\item\Item;
|
||||
|
||||
class EntityArmorChangeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $oldItem;
|
||||
private $newItem;
|
||||
|
@ -30,8 +30,6 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class EntityBlockChangeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $from;
|
||||
private $to;
|
||||
|
@ -25,8 +25,6 @@ use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityCombustByBlockEvent extends EntityCombustEvent{
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
protected $combuster;
|
||||
|
||||
|
@ -24,8 +24,6 @@ namespace pocketmine\event\entity;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityCombustByEntityEvent extends EntityCombustEvent{
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
protected $combuster;
|
||||
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class EntityCombustEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
protected $duration;
|
||||
|
||||
|
@ -25,8 +25,6 @@ use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityDamageByBlockEvent extends EntityDamageEvent{
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Block */
|
||||
private $damager;
|
||||
@ -51,4 +49,4 @@ class EntityDamageByBlockEvent extends EntityDamageEvent{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,6 @@ namespace pocketmine\event\entity;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityDamageByChildEntityEvent extends EntityDamageByEntityEvent{
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Entity */
|
||||
private $childEntity;
|
||||
|
@ -24,8 +24,6 @@ namespace pocketmine\event\entity;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityDamageByEntityEvent extends EntityDamageEvent{
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Entity */
|
||||
private $damager;
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class EntityDamageEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
const MODIFIER_BASE = 0;
|
||||
const MODIFIER_ARMOR = 1;
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\item\Item;
|
||||
|
||||
class EntityDeathEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item[] */
|
||||
private $drops = [];
|
||||
|
@ -33,8 +33,6 @@ use pocketmine\entity\Vehicle;
|
||||
*/
|
||||
class EntityDespawnEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $entityType;
|
||||
|
||||
|
@ -31,8 +31,6 @@ use pocketmine\level\Position;
|
||||
*/
|
||||
class EntityExplodeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Position */
|
||||
protected $position;
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\item\Item;
|
||||
|
||||
class EntityInventoryChangeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $oldItem;
|
||||
private $newItem;
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\level\Level;
|
||||
|
||||
class EntityLevelChangeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $originLevel;
|
||||
private $targetLevel;
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\math\Vector3;
|
||||
|
||||
class EntityMotionEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $mot;
|
||||
|
||||
|
@ -31,8 +31,6 @@ use pocketmine\math\Vector3;
|
||||
*/
|
||||
class EntityMoveEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var \pocketmine\math\Vector3 */
|
||||
private $pos;
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class EntityRegainHealthEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
const CAUSE_REGEN = 0;
|
||||
const CAUSE_EATING = 1;
|
||||
|
@ -29,8 +29,6 @@ use pocketmine\item\Item;
|
||||
|
||||
class EntityShootBowEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item */
|
||||
private $bow;
|
||||
|
@ -33,8 +33,6 @@ use pocketmine\entity\Vehicle;
|
||||
*/
|
||||
class EntitySpawnEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $entityType;
|
||||
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\level\Position;
|
||||
|
||||
class EntityTeleportEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Position */
|
||||
private $from;
|
||||
|
@ -29,8 +29,6 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
protected $force;
|
||||
private $blockBreaking;
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class ItemDespawnEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
|
@ -25,8 +25,6 @@ use pocketmine\entity\Item;
|
||||
|
||||
class ItemSpawnEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param Item $item
|
||||
|
@ -25,8 +25,6 @@ use pocketmine\entity\Projectile;
|
||||
|
||||
class ProjectileHitEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param Projectile $entity
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class ProjectileLaunchEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param Projectile $entity
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\inventory\Recipe;
|
||||
|
||||
class CraftItemEvent extends Event implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var CraftingTransactionGroup */
|
||||
private $ts;
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\tile\Furnace;
|
||||
|
||||
class FurnaceBurnEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $furnace;
|
||||
private $fuel;
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\tile\Furnace;
|
||||
|
||||
class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $furnace;
|
||||
private $source;
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\Player;
|
||||
|
||||
class InventoryCloseEvent extends InventoryEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Player */
|
||||
private $who;
|
||||
|
@ -27,8 +27,6 @@ use pocketmine\Player;
|
||||
|
||||
class InventoryOpenEvent extends InventoryEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Player */
|
||||
private $who;
|
||||
|
@ -27,8 +27,6 @@ use pocketmine\inventory\Inventory;
|
||||
|
||||
class InventoryPickupArrowEvent extends InventoryEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Arrow */
|
||||
private $arrow;
|
||||
|
@ -27,8 +27,6 @@ use pocketmine\inventory\Inventory;
|
||||
|
||||
class InventoryPickupItemEvent extends InventoryEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
|
@ -31,8 +31,6 @@ use pocketmine\inventory\TransactionGroup;
|
||||
*/
|
||||
class InventoryTransactionEvent extends Event implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var TransactionGroup */
|
||||
private $ts;
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\level\format\FullChunk;
|
||||
*/
|
||||
class ChunkLoadEvent extends ChunkEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $newChunk;
|
||||
|
||||
|
@ -26,6 +26,4 @@ namespace pocketmine\event\level;
|
||||
*/
|
||||
class ChunkPopulateEvent extends ChunkEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -28,6 +28,4 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class ChunkUnloadEvent extends ChunkEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -26,6 +26,4 @@ namespace pocketmine\event\level;
|
||||
*/
|
||||
class LevelInitEvent extends LevelEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -26,6 +26,4 @@ namespace pocketmine\event\level;
|
||||
*/
|
||||
class LevelLoadEvent extends LevelEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -26,6 +26,4 @@ namespace pocketmine\event\level;
|
||||
*/
|
||||
class LevelSaveEvent extends LevelEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -28,6 +28,4 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class LevelUnloadEvent extends LevelEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -30,8 +30,6 @@ use pocketmine\level\Position;
|
||||
*/
|
||||
class SpawnChangeEvent extends LevelEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Position */
|
||||
private $previousSpawn;
|
||||
|
@ -29,8 +29,6 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerAchievementAwardedEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $achievement;
|
||||
|
@ -29,8 +29,6 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerAnimationEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
const ARM_SWING = 1;
|
||||
|
||||
|
@ -27,8 +27,6 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerBedEnterEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $bed;
|
||||
|
||||
|
@ -26,8 +26,6 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerBedLeaveEvent extends PlayerEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $bed;
|
||||
|
||||
|
@ -27,8 +27,6 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerBucketEmptyEvent extends PlayerBucketEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
public function __construct(Player $who, Block $blockClicked, $blockFace, Item $bucket, Item $itemInHand){
|
||||
parent::__construct($who, $blockClicked, $blockFace, $bucket, $itemInHand);
|
||||
|
@ -27,8 +27,6 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerBucketFillEvent extends PlayerBucketEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
public function __construct(Player $who, Block $blockClicked, $blockFace, Item $bucket, Item $itemInHand){
|
||||
parent::__construct($who, $blockClicked, $blockFace, $bucket, $itemInHand);
|
||||
|
@ -30,8 +30,6 @@ use pocketmine\Server;
|
||||
*/
|
||||
class PlayerChatEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $message;
|
||||
|
@ -34,8 +34,6 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $message;
|
||||
|
139
src/pocketmine/event/player/PlayerCreationEvent.php
Normal file
139
src/pocketmine/event/player/PlayerCreationEvent.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?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\event\player;
|
||||
|
||||
use pocketmine\event\Event;
|
||||
use pocketmine\network\SourceInterface;
|
||||
use pocketmine\Player;
|
||||
|
||||
/**
|
||||
* Allows the creation of players overriding the base Player class
|
||||
*/
|
||||
class PlayerCreationEvent extends Event{
|
||||
public static $handlerList = null;
|
||||
|
||||
/** @var SourceInterface */
|
||||
private $interface;
|
||||
/** @var mixed */
|
||||
private $clientId;
|
||||
/** @var string */
|
||||
private $address;
|
||||
/** @var int */
|
||||
private $port;
|
||||
|
||||
/** @var Player::class */
|
||||
private $baseClass;
|
||||
/** @var Player::class */
|
||||
private $playerClass;
|
||||
|
||||
/**
|
||||
* @param SourceInterface $interface
|
||||
* @param Player::class $baseClass
|
||||
* @param Player::class $playerClass
|
||||
* @param mixed $clientId
|
||||
* @param string $address
|
||||
* @param int $port
|
||||
*/
|
||||
public function __construct(SourceInterface $interface, $baseClass, $playerClass, $clientId, $address, $port){
|
||||
$this->interface = $interface;
|
||||
$this->clientId = $clientId;
|
||||
$this->address = $address;
|
||||
$this->port = $port;
|
||||
|
||||
if(!is_a($baseClass, Player::class, true)){
|
||||
throw new \RuntimeException("Base class $baseClass must extend " . Player::class);
|
||||
}
|
||||
|
||||
$this->baseClass = $baseClass;
|
||||
|
||||
if(!is_a($playerClass, Player::class, true)){
|
||||
throw new \RuntimeException("Class $playerClass must extend " . Player::class);
|
||||
}
|
||||
|
||||
$this->playerClass = $playerClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SourceInterface
|
||||
*/
|
||||
public function getInterface(){
|
||||
return $this->interface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress(){
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPort(){
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getClientId(){
|
||||
return $this->clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player::class
|
||||
*/
|
||||
public function getBaseClass(){
|
||||
return $this->baseClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player::class $class
|
||||
*/
|
||||
public function setBaseClass($class){
|
||||
if(!is_a($class, $this->baseClass, true)){
|
||||
throw new \RuntimeException("Base class $class must extend " . $this->baseClass);
|
||||
}
|
||||
|
||||
$this->baseClass = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player::class
|
||||
*/
|
||||
public function getPlayerClass(){
|
||||
return $this->playerClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player::class $class
|
||||
*/
|
||||
public function setPlayerClass($class){
|
||||
if(!is_a($class, $this->baseClass, true)){
|
||||
throw new \RuntimeException("Class $class must extend " . $this->baseClass);
|
||||
}
|
||||
|
||||
$this->playerClass = $class;
|
||||
}
|
||||
|
||||
}
|
@ -27,8 +27,6 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerDeathEvent extends EntityDeathEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $deathMessage;
|
||||
private $keepInventory = false;
|
||||
|
@ -30,8 +30,6 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerDropItemEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item */
|
||||
private $drop;
|
||||
|
@ -29,8 +29,6 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var int */
|
||||
protected $gamemode;
|
||||
|
@ -31,8 +31,6 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerInteractEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @var \pocketmine\block\Block;
|
||||
|
@ -30,8 +30,6 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
|
@ -28,8 +28,6 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $item;
|
||||
private $slot;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user