From 6e74bb7faf7f79d996445445d793aad899fb170c Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Fri, 11 Jul 2014 21:52:57 +0930 Subject: [PATCH 01/10] Kick reason grammar --- src/pocketmine/command/defaults/KickCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/command/defaults/KickCommand.php b/src/pocketmine/command/defaults/KickCommand.php index 26e4c174e..b38207419 100644 --- a/src/pocketmine/command/defaults/KickCommand.php +++ b/src/pocketmine/command/defaults/KickCommand.php @@ -53,7 +53,7 @@ class KickCommand extends VanillaCommand{ if(($player = $sender->getServer()->getPlayer($name)) instanceof Player){ $player->kick($reason); - Command::broadcastCommandMessage($sender, "Kicked player " . $player->getName() . ". With reason: " . $reason); + Command::broadcastCommandMessage($sender, "Kicked player " . $player->getName() . " with reason: " . $reason); }else{ $sender->sendMessage($name . " not found."); } From 53214005cdd489566d7a256f8f98028bdca378a7 Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Fri, 11 Jul 2014 22:05:50 +0930 Subject: [PATCH 02/10] Kick message reflects Vanila MCPC not Bukkit --- src/pocketmine/command/defaults/KickCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/command/defaults/KickCommand.php b/src/pocketmine/command/defaults/KickCommand.php index b38207419..881411d1c 100644 --- a/src/pocketmine/command/defaults/KickCommand.php +++ b/src/pocketmine/command/defaults/KickCommand.php @@ -53,7 +53,7 @@ class KickCommand extends VanillaCommand{ if(($player = $sender->getServer()->getPlayer($name)) instanceof Player){ $player->kick($reason); - Command::broadcastCommandMessage($sender, "Kicked player " . $player->getName() . " with reason: " . $reason); + Command::broadcastCommandMessage($sender, "Kicked " . $player->getName() . " from the game: " . $reason); }else{ $sender->sendMessage($name . " not found."); } From 167ee975691408ccb359cd203cdae1cd9109c4a8 Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Fri, 11 Jul 2014 22:14:57 +0930 Subject: [PATCH 03/10] Fix kick command broadcast message. --- src/pocketmine/command/defaults/KickCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/command/defaults/KickCommand.php b/src/pocketmine/command/defaults/KickCommand.php index 881411d1c..820d429c3 100644 --- a/src/pocketmine/command/defaults/KickCommand.php +++ b/src/pocketmine/command/defaults/KickCommand.php @@ -53,7 +53,7 @@ class KickCommand extends VanillaCommand{ if(($player = $sender->getServer()->getPlayer($name)) instanceof Player){ $player->kick($reason); - Command::broadcastCommandMessage($sender, "Kicked " . $player->getName() . " from the game: " . $reason); + Command::broadcastCommandMessage($sender, "Kicked " . $player->getName() . " from the game: '{$reason}'"); }else{ $sender->sendMessage($name . " not found."); } From a8359f29a81a9cc6836b14535a3256f06853482b Mon Sep 17 00:00:00 2001 From: williamtdr Date: Fri, 11 Jul 2014 09:07:24 -0500 Subject: [PATCH 04/10] Fix #1615 Players in creative cannot die from non-magic (plugin/console) causes. --- src/pocketmine/entity/Living.php | 123 ++++++++++++++++--------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 27bba8bcc..93347507c 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -34,73 +34,76 @@ use pocketmine\item\Item; abstract class Living extends Entity implements Damageable{ - protected $gravity = 0.08; - protected $drag = 0.02; + protected $gravity = 0.08; + protected $drag = 0.02; - protected function initEntity(){ - if(isset($this->namedtag->HealF)){ - $this->namedtag->Health = new Short("Health", (int) $this->namedtag["HealF"]); - unset($this->namedtag->HealF); - } + protected function initEntity(){ + if(isset($this->namedtag->HealF)){ + $this->namedtag->Health = new Short("Health", (int) $this->namedtag["HealF"]); + unset($this->namedtag->HealF); + } - if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof Short)){ - $this->namedtag->Health = new Short("Health", $this->getMaxHealth()); - } + if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof Short)){ + $this->namedtag->Health = new Short("Health", $this->getMaxHealth()); + } - $this->setHealth($this->namedtag["Health"]); - } + $this->setHealth($this->namedtag["Health"]); + } - public function saveNBT(){ - parent::saveNBT(); - $this->namedtag->Health = new Short("Health", $this->getHealth()); - } + public function saveNBT(){ + parent::saveNBT(); + $this->namedtag->Health = new Short("Health", $this->getHealth()); + } - public abstract function getName(); + public abstract function getName(); - public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ - //TODO: attack tick limit - $pk = new EntityEventPacket(); - $pk->eid = $this->getID(); - $pk->event = 2; //Ouch! - Server::broadcastPacket($this->hasSpawned, $pk); - $this->setLastDamageCause($source); - $motion = new Vector3(0, 0, 0); - if($source instanceof EntityDamageByEntityEvent){ - $e = $source->getDamager(); - $deltaX = $this->x - $e->x; - $deltaZ = $this->z - $e->z; - $yaw = atan2($deltaX, $deltaZ); - $motion->x = sin($yaw) * 0.5; - $motion->z = cos($yaw) * 0.5; - } - $this->setMotion($motion); - $this->setHealth($this->getHealth() - $damage); + public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ + //TODO: attack tick limit + if($this instanceof Player && $this->getGamemode() === 1 && $source != EntityDamageEvent::CAUSE_MAGIC) { + return; + } + $pk = new EntityEventPacket(); + $pk->eid = $this->getID(); + $pk->event = 2; //Ouch! + Server::broadcastPacket($this->hasSpawned, $pk); + $this->setLastDamageCause($source); + $motion = new Vector3(0, 0, 0); + if($source instanceof EntityDamageByEntityEvent){ + $e = $source->getDamager(); + $deltaX = $this->x - $e->x; + $deltaZ = $this->z - $e->z; + $yaw = atan2($deltaX, $deltaZ); + $motion->x = sin($yaw) * 0.5; + $motion->z = cos($yaw) * 0.5; + } + $this->setMotion($motion); + $this->setHealth($this->getHealth() - $damage); - } + } - public function heal($amount){ - $this->server->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($this, $amount)); - if($ev->isCancelled()){ - return; - } - $this->setHealth($this->getHealth() + $amount); - } + public function heal($amount){ + $this->server->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($this, $amount)); + if($ev->isCancelled()){ + return; + } + $this->setHealth($this->getHealth() + $amount); + } - public function kill(){ - if($this->dead){ - return; - } - parent::kill(); - $this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops())); - foreach($ev->getDrops() as $item){ - $this->getLevel()->dropItem($this, $item); - } - } + public function kill(){ + if($this->dead){ + return; + } + parent::kill(); + $this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops())); + foreach($ev->getDrops() as $item){ + $this->getLevel()->dropItem($this, $item); + } + } - /** - * @return Item[] - */ - public function getDrops(){ - return []; - } -} \ No newline at end of file + /** + * @return Item[] + */ + public function getDrops(){ + return []; + } +} From 3e882ef40d5dc8d69bc7027497bcc08740a2c29c Mon Sep 17 00:00:00 2001 From: williamtdr Date: Fri, 11 Jul 2014 09:12:19 -0500 Subject: [PATCH 05/10] Revert "Fix #1615" This reverts commit a8359f29a81a9cc6836b14535a3256f06853482b. --- src/pocketmine/entity/Living.php | 123 +++++++++++++++---------------- 1 file changed, 60 insertions(+), 63 deletions(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 93347507c..27bba8bcc 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -34,76 +34,73 @@ use pocketmine\item\Item; abstract class Living extends Entity implements Damageable{ - protected $gravity = 0.08; - protected $drag = 0.02; + protected $gravity = 0.08; + protected $drag = 0.02; - protected function initEntity(){ - if(isset($this->namedtag->HealF)){ - $this->namedtag->Health = new Short("Health", (int) $this->namedtag["HealF"]); - unset($this->namedtag->HealF); - } + protected function initEntity(){ + if(isset($this->namedtag->HealF)){ + $this->namedtag->Health = new Short("Health", (int) $this->namedtag["HealF"]); + unset($this->namedtag->HealF); + } - if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof Short)){ - $this->namedtag->Health = new Short("Health", $this->getMaxHealth()); - } + if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof Short)){ + $this->namedtag->Health = new Short("Health", $this->getMaxHealth()); + } - $this->setHealth($this->namedtag["Health"]); - } + $this->setHealth($this->namedtag["Health"]); + } - public function saveNBT(){ - parent::saveNBT(); - $this->namedtag->Health = new Short("Health", $this->getHealth()); - } + public function saveNBT(){ + parent::saveNBT(); + $this->namedtag->Health = new Short("Health", $this->getHealth()); + } - public abstract function getName(); + public abstract function getName(); - public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ - //TODO: attack tick limit - if($this instanceof Player && $this->getGamemode() === 1 && $source != EntityDamageEvent::CAUSE_MAGIC) { - return; - } - $pk = new EntityEventPacket(); - $pk->eid = $this->getID(); - $pk->event = 2; //Ouch! - Server::broadcastPacket($this->hasSpawned, $pk); - $this->setLastDamageCause($source); - $motion = new Vector3(0, 0, 0); - if($source instanceof EntityDamageByEntityEvent){ - $e = $source->getDamager(); - $deltaX = $this->x - $e->x; - $deltaZ = $this->z - $e->z; - $yaw = atan2($deltaX, $deltaZ); - $motion->x = sin($yaw) * 0.5; - $motion->z = cos($yaw) * 0.5; - } - $this->setMotion($motion); - $this->setHealth($this->getHealth() - $damage); + public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ + //TODO: attack tick limit + $pk = new EntityEventPacket(); + $pk->eid = $this->getID(); + $pk->event = 2; //Ouch! + Server::broadcastPacket($this->hasSpawned, $pk); + $this->setLastDamageCause($source); + $motion = new Vector3(0, 0, 0); + if($source instanceof EntityDamageByEntityEvent){ + $e = $source->getDamager(); + $deltaX = $this->x - $e->x; + $deltaZ = $this->z - $e->z; + $yaw = atan2($deltaX, $deltaZ); + $motion->x = sin($yaw) * 0.5; + $motion->z = cos($yaw) * 0.5; + } + $this->setMotion($motion); + $this->setHealth($this->getHealth() - $damage); - } + } - public function heal($amount){ - $this->server->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($this, $amount)); - if($ev->isCancelled()){ - return; - } - $this->setHealth($this->getHealth() + $amount); - } + public function heal($amount){ + $this->server->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($this, $amount)); + if($ev->isCancelled()){ + return; + } + $this->setHealth($this->getHealth() + $amount); + } - public function kill(){ - if($this->dead){ - return; - } - parent::kill(); - $this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops())); - foreach($ev->getDrops() as $item){ - $this->getLevel()->dropItem($this, $item); - } - } + public function kill(){ + if($this->dead){ + return; + } + parent::kill(); + $this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops())); + foreach($ev->getDrops() as $item){ + $this->getLevel()->dropItem($this, $item); + } + } - /** - * @return Item[] - */ - public function getDrops(){ - return []; - } -} + /** + * @return Item[] + */ + public function getDrops(){ + return []; + } +} \ No newline at end of file From 61043d2e0d80466c14d15822b642f84000632387 Mon Sep 17 00:00:00 2001 From: williamtdr Date: Fri, 11 Jul 2014 09:14:49 -0500 Subject: [PATCH 06/10] Fix #1615 Players in creative cannot die from non-magic (plugin/console) causes. --- src/pocketmine/entity/Living.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 27bba8bcc..dbe4112e3 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -58,6 +58,9 @@ abstract class Living extends Entity implements Damageable{ public abstract function getName(); public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ + if($this instanceof Player and ($this->getGamemode() & 0x01) === 1 and $source != EntityDamageEvent::CAUSE_MAGIC) { + return; + } //TODO: attack tick limit $pk = new EntityEventPacket(); $pk->eid = $this->getID(); @@ -103,4 +106,4 @@ abstract class Living extends Entity implements Damageable{ public function getDrops(){ return []; } -} \ No newline at end of file +} From 5e47dda0a877fe425808d909002d9f913ebca2cd Mon Sep 17 00:00:00 2001 From: williamtdr Date: Fri, 11 Jul 2014 09:18:15 -0500 Subject: [PATCH 07/10] Enable death through void, suicide --- src/pocketmine/entity/Living.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index dbe4112e3..8993eca5d 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -58,7 +58,7 @@ abstract class Living extends Entity implements Damageable{ public abstract function getName(); public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ - if($this instanceof Player and ($this->getGamemode() & 0x01) === 1 and $source != EntityDamageEvent::CAUSE_MAGIC) { + if($this instanceof Player and ($this->getGamemode() & 0x01) === 1 and $source != EntityDamageEvent::CAUSE_MAGIC and $source != EntityDamageEvent::CAUSE_SUICIDE and $source != EntityDamageEvent::CAUSE_VOID) { return; } //TODO: attack tick limit From 7624eda7b12f7b766c48a747efa7b731ab873131 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 11 Jul 2014 16:24:04 +0200 Subject: [PATCH 08/10] Update damage sources for creative mode players --- src/pocketmine/entity/Living.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 8993eca5d..fa20a507d 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -58,9 +58,23 @@ abstract class Living extends Entity implements Damageable{ public abstract function getName(); public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ - if($this instanceof Player and ($this->getGamemode() & 0x01) === 1 and $source != EntityDamageEvent::CAUSE_MAGIC and $source != EntityDamageEvent::CAUSE_SUICIDE and $source != EntityDamageEvent::CAUSE_VOID) { - return; + + if($this instanceof Player and ($this->getGamemode() & 0x01) === 1){ + if($source instanceof EntityDamageEvent){ + $cause = $source->getCause(); + }else{ + $cause = $source; + } + + if( + $cause !== EntityDamageEvent::CAUSE_MAGIC + and $cause !== EntityDamageEvent::CAUSE_SUICIDE + and $cause !== EntityDamageEvent::CAUSE_VOID + ){ + return; + } } + //TODO: attack tick limit $pk = new EntityEventPacket(); $pk->eid = $this->getID(); From a6e22de6a3d58fd5b848a2b211f1b7bbc5778a6b Mon Sep 17 00:00:00 2001 From: williamtdr Date: Fri, 11 Jul 2014 10:19:28 -0500 Subject: [PATCH 09/10] Possible fix for #1628 --- src/pocketmine/command/defaults/SpawnpointCommand.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/command/defaults/SpawnpointCommand.php b/src/pocketmine/command/defaults/SpawnpointCommand.php index 42acf1868..4fbf13c6e 100644 --- a/src/pocketmine/command/defaults/SpawnpointCommand.php +++ b/src/pocketmine/command/defaults/SpawnpointCommand.php @@ -66,9 +66,9 @@ class SpawnpointCommand extends VanillaCommand{ if(count($args) === 4){ if($level !== null){ - $x = (int) $this->getRelativeDouble($sender->x, $sender, $args[1]); - $y = (int) $this->getRelativeDouble($sender->y, $sender, $args[2], 0, 128); - $z = (int) $this->getRelativeDouble($sender->z, $sender, $args[3]); + $x = (int) $this->getRelativeDouble($sender->getX(), $sender, $args[1]); + $y = (int) $this->getRelativeDouble($sender->getY(), $sender, $args[2], 0, 128); + $z = (int) $this->getRelativeDouble($sender->getZ(), $sender, $args[3]); $target->setSpawn(new Position($x, $y, $z, $level)); Command::broadcastCommandMessage($sender, "Set " . $target->getName() . "'s spawnpoint to " . $x . ", " . $y . ", " . $z); @@ -76,7 +76,7 @@ class SpawnpointCommand extends VanillaCommand{ } }elseif(count($args) <= 1){ if($sender instanceof Player){ - $pos = new Position((int) $sender->x, (int) $sender->y, (int) $sender->z, $sender->getLevel()); + $pos = new Position((int) $sender->getX(), (int) $sender->getY(), (int) $sender->getZ(), $sender->getLevel()); $target->setSpawn($pos); Command::broadcastCommandMessage($sender, "Set " . $target->getName() . "'s spawnpoint to " . $pos->x . ", " . $pos->y . ", " . $pos->z); From dd729ced68f91c2682791d8f64262fe7b885cc37 Mon Sep 17 00:00:00 2001 From: williamtdr Date: Fri, 11 Jul 2014 10:21:58 -0500 Subject: [PATCH 10/10] Revert "Possible fix for #1628" This reverts commit a6e22de6a3d58fd5b848a2b211f1b7bbc5778a6b. --- src/pocketmine/command/defaults/SpawnpointCommand.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/command/defaults/SpawnpointCommand.php b/src/pocketmine/command/defaults/SpawnpointCommand.php index 4fbf13c6e..42acf1868 100644 --- a/src/pocketmine/command/defaults/SpawnpointCommand.php +++ b/src/pocketmine/command/defaults/SpawnpointCommand.php @@ -66,9 +66,9 @@ class SpawnpointCommand extends VanillaCommand{ if(count($args) === 4){ if($level !== null){ - $x = (int) $this->getRelativeDouble($sender->getX(), $sender, $args[1]); - $y = (int) $this->getRelativeDouble($sender->getY(), $sender, $args[2], 0, 128); - $z = (int) $this->getRelativeDouble($sender->getZ(), $sender, $args[3]); + $x = (int) $this->getRelativeDouble($sender->x, $sender, $args[1]); + $y = (int) $this->getRelativeDouble($sender->y, $sender, $args[2], 0, 128); + $z = (int) $this->getRelativeDouble($sender->z, $sender, $args[3]); $target->setSpawn(new Position($x, $y, $z, $level)); Command::broadcastCommandMessage($sender, "Set " . $target->getName() . "'s spawnpoint to " . $x . ", " . $y . ", " . $z); @@ -76,7 +76,7 @@ class SpawnpointCommand extends VanillaCommand{ } }elseif(count($args) <= 1){ if($sender instanceof Player){ - $pos = new Position((int) $sender->getX(), (int) $sender->getY(), (int) $sender->getZ(), $sender->getLevel()); + $pos = new Position((int) $sender->x, (int) $sender->y, (int) $sender->z, $sender->getLevel()); $target->setSpawn($pos); Command::broadcastCommandMessage($sender, "Set " . $target->getName() . "'s spawnpoint to " . $pos->x . ", " . $pos->y . ", " . $pos->z);