Merge branch 'master' into mcpe-1.0

This commit is contained in:
Dylan K. Taylor 2016-12-06 12:04:42 +00:00
commit adabd7ef65
8 changed files with 105 additions and 23 deletions

View File

@ -12,7 +12,6 @@ before_script:
script:
- ./tests/lint.sh && ./tests/run.sh
notifications:
email: false
#webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0
email: false

View File

@ -34,8 +34,6 @@ __PocketMine-MP is a free, open-source software that creates Minecraft: Pocket E
* [Official Doxygen-generated documentation](http://docs.pocketmine.net/)
* [Latest Doxygen generated from development](https://jenkins.pmmp.io/job/PocketMine-MP%20Docs/doxygen/)
### [Twitter @PocketMine](https://twitter.com/PocketMine)
### IRC Chat #pmmp (or #pocketmine) @ irc.freenode.net
[#pmmp + #pocketmine channel WebIRC](http://webchat.freenode.net/?channels=pmmp,pocketmine)

View File

@ -2557,6 +2557,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$packet->message = TextFormat::clean($packet->message, $this->removeFormat);
foreach(explode("\n", $packet->message) as $message){
if(trim($message) != "" and strlen($message) <= 255 and $this->messageCounter-- > 0){
if(substr($message, 0, 2) === "./"){ //Command (./ = fast hack for old plugins post 0.16)
$message = substr($message, 1);
}
$ev = new PlayerCommandPreprocessEvent($this, $message);
if(mb_strlen($ev->getMessage(), "UTF-8") > 320){
@ -2567,9 +2571,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
if($ev->isCancelled()){
break;
}
if(substr($ev->getMessage(), 0, 2) === "./"){ //Command (./ = fast hack for old plugins post 0.16)
if(substr($ev->getMessage(), 0, 1) === "/"){
Timings::$playerCommandTimer->startTiming();
$this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 2));
$this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
Timings::$playerCommandTimer->stopTiming();
}else{
$this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
@ -3114,9 +3119,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
parent::saveNBT();
if($this->level instanceof Level){
$this->namedtag->Level = new StringTag("Level", $this->level->getName());
$this->namedtag->Level = new StringTag("Level", $this->level->getFolderName());
if($this->hasValidSpawnPosition()){
$this->namedtag["SpawnLevel"] = $this->spawnPosition->getLevel()->getName();
$this->namedtag["SpawnLevel"] = $this->spawnPosition->getLevel()->getFolderName();
$this->namedtag["SpawnX"] = (int) $this->spawnPosition->x;
$this->namedtag["SpawnY"] = (int) $this->spawnPosition->y;
$this->namedtag["SpawnZ"] = (int) $this->spawnPosition->z;

View File

@ -22,6 +22,8 @@
namespace pocketmine\entity;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityEffectAddEvent;
use pocketmine\event\entity\EntityEffectRemoveEvent;
use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\player\PlayerExhaustEvent;
use pocketmine\network\protocol\MobEffectPacket;
@ -251,6 +253,10 @@ class Effect{
}
public function add(Entity $entity, $modify = false, Effect $oldEffect = null){
$entity->getLevel()->getServer()->getPluginManager()->callEvent($ev = new EntityEffectAddEvent($entity, $this, $modify, $oldEffect));
if($ev->isCancelled()){
return;
}
if($entity instanceof Player){
$pk = new MobEffectPacket();
$pk->eid = 0;
@ -258,7 +264,7 @@ class Effect{
$pk->amplifier = $this->getAmplifier();
$pk->particles = $this->isVisible();
$pk->duration = $this->getDuration();
if($modify){
if($ev->willModify()){
$pk->eventId = MobEffectPacket::EVENT_MODIFY;
}else{
$pk->eventId = MobEffectPacket::EVENT_ADD;
@ -272,7 +278,7 @@ class Effect{
$entity->setNameTagVisible(false);
}elseif($this->id === Effect::SPEED){
$attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
if($modify and $oldEffect !== null){
if($ev->willModify() and $oldEffect !== null){
$speed = $attr->getValue() / (1 + 0.2 * $oldEffect->getAmplifier());
}else{
$speed = $attr->getValue();
@ -281,7 +287,7 @@ class Effect{
$attr->setValue($speed);
}elseif($this->id === Effect::SLOWNESS){
$attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
if($modify and $oldEffect !== null){
if($ev->willModify() and $oldEffect !== null){
$speed = $attr->getValue() / (1 - 0.15 * $oldEffect->getAmplifier());
}else{
$speed = $attr->getValue();
@ -292,6 +298,10 @@ class Effect{
}
public function remove(Entity $entity){
$entity->getLevel()->getServer()->getPluginManager()->callEvent($ev = new EntityEffectRemoveEvent($entity, $this));
if($ev->isCancelled()){
return;
}
if($entity instanceof Player){
$pk = new MobEffectPacket();
$pk->eid = 0;

View File

@ -0,0 +1,61 @@
<?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\entity;
use pocketmine\entity\Effect;
use pocketmine\entity\Entity;
class EntityEffectAddEvent extends EntityEffectEvent{
public static $handlerList = null;
/** @var bool */
private $modify;
/** @var Effect */
private $oldEffect;
public function __construct(Entity $entity, Effect $effect, $modify, $oldEffect){
parent::__construct($entity, $effect);
$this->modify = $modify;
$this->oldEffect = $oldEffect;
}
public function willModify() : bool{
return $this->modify;
}
public function setWillModify(bool $modify){
$this->modify = $modify;
}
public function hasOldEffect() : bool{
return $this->oldEffect instanceof Effect;
}
/**
* @return Effect|null
*/
public function getOldEffect(){
return $this->oldEffect;
}
}

View File

@ -19,13 +19,23 @@
*
*/
namespace pocketmine\utils;
namespace pocketmine\event\entity;
use pocketmine\entity\Effect;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
/**
* All classes or interfaces (including plugins) that want to be able to be patched in runtime
* need to implement this interface
*/
interface Patchable{
class EntityEffectEvent extends EntityEvent implements Cancellable{
/** @var Effect */
private $effect;
public function __construct(Entity $entity, Effect $effect){
$this->entity = $entity;
$this->effect = $effect;
}
public function getEffect() : Effect{
return $this->effect;
}
}

View File

@ -19,10 +19,9 @@
*
*/
namespace pocketmine\utils;
namespace pocketmine\event\entity;
class MonkeyPatch{
public function __construct(){
class EntityEffectRemoveEvent extends EntityEffectEvent{
public static $handlerList = null;
}
}

View File

@ -22,7 +22,7 @@ if exist PocketMine-MP.phar (
)
if exist bin\mintty.exe (
start "" bin\mintty.exe -o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o Font="DejaVu Sans Mono" -o FontHeight=10 -o CursorType=0 -o CursorBlinks=1 -h error -t "PocketMine-MP" -i bin/pocketmine.ico -w max %PHP_BINARY% %POCKETMINE_FILE% --enable-ansi %*
start "" bin\mintty.exe -o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o Font="Consolas" -o FontHeight=10 -o CursorType=0 -o CursorBlinks=1 -h error -t "PocketMine-MP" -i bin/pocketmine.ico -w max %PHP_BINARY% %POCKETMINE_FILE% --enable-ansi %*
) else (
%PHP_BINARY% -c bin\php %POCKETMINE_FILE% %*
)