Skip to content

Commit

Permalink
Bug Fixes and a few more Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CortexPE committed Sep 11, 2017
1 parent 9cc7e79 commit d638aa7
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 24 deletions.
15 changes: 11 additions & 4 deletions src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ protected function processMovement($tickDiff){
$revert = false;

if(($distanceSquared / ($tickDiff ** 2)) > 100 and !$this->allowMovementCheats){
$this->server->getLogger()->warning($this->getName() . " moved too fast, reverting movement");
$this->server->getLogger()->customsend($this->getName() . " moved too fast, reverting movement", "AntiCheat", TextFormat::YELLOW);
$revert = true;
}else{
if($this->chunk === null or !$this->chunk->isGenerated()){
Expand Down Expand Up @@ -1854,7 +1854,7 @@ protected function processMovement($tickDiff){

if(!$ev->isCancelled()){
$revert = true;
$this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidMove", [$this->getName()]));
$this->server->getLogger()->customsend($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidMove", [$this->getName()]), "AntiCheat", TextFormat::YELLOW);
}
}

Expand Down Expand Up @@ -3033,7 +3033,8 @@ public function handleDataPacket(DataPacket $packet){
}

if($this->server->isHardcore()){
$this->setBanned(true);
$this->getServer()->getNameBans()->addBan($this->getName(), TextFormat::RED . "Server is in HardCore Mode.", null, $this->getName());
$this->kick(TextFormat::RED . "Server is in HardCore Mode.", false);
break;
}

Expand All @@ -3049,6 +3050,8 @@ public function handleDataPacket(DataPacket $packet){

$this->teleport($ev->getRespawnPosition());

$this->nextChunkOrderRun = 0;

$this->setSprinting(false);
$this->setSneaking(false);
$this->extinguish();
Expand Down Expand Up @@ -4382,7 +4385,7 @@ public function kill(){
break;

default:

break;
}

Entity::kill();
Expand All @@ -4397,6 +4400,10 @@ public function kill(){
$this->level->dropItem($this, $item);
}

if($this->floatingInventory !== null){
$this->floatingInventory->clearAll();
}

if($this->inventory !== null){
$this->inventory->clearAll();
}
Expand Down
1 change: 1 addition & 0 deletions src/pocketmine/PocketMine.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function dummy(){
const API_VERSION = "3.0.0-ALPHA5";
const CODENAME = "NewBeginnings";
const GENISYS_API_VERSION = '2.0.0';
const LEVERYL_API_VERSION = '0.0.1';

/*
* Startup code. Do not look at it, it may harm you.
Expand Down
23 changes: 17 additions & 6 deletions src/pocketmine/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function getCodename(){
* @return string
*/
public function getVersion(){
$version = implode(",", ProtocolInfo::MINECRAFT_VERSION);
$version = implode(", ", ProtocolInfo::MINECRAFT_VERSION);

return $version;
}
Expand Down Expand Up @@ -1535,7 +1535,7 @@ public static function microSleep(int $microseconds){
}, $microseconds);
}

public function about(){
private function about(){
$startupmsg = " §8##§7\§b _ _ §r\n §8##§7 /§b | | _____ _____ _ __ _ _| |§r\n §8##§7 /§b | |/ _ \ \ / / _ \ '__| | | | |§r\n §8##§7 /§b | | __/\ V / __/ | | |_| | |§r\n §8##§7 /§b |_|\___| \_/ \___|_| \__, |_|§r\n §8##§7 /§b |___/ §r\n §8#########§7\ §bGitHub.com/LeverylTeam/Leveryl §r\n §7\________/§r";

if($this->logger instanceof MainLogger){
Expand Down Expand Up @@ -1654,6 +1654,9 @@ public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $
$this->logger = $logger;
$this->filePath = $filePath;
try{

echo "\x1b]0;" . $this->getName() . $this->getFormattedVersion("-") . " // Loading\x07";

if(!file_exists($dataPath . "worlds/")){
mkdir($dataPath . "worlds/", 0777);
}
Expand Down Expand Up @@ -1995,8 +1998,9 @@ public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $
]), $this->dserverConfig["timer"]);

if($cfgVer > $advVer){
$this->logger->notice("Your leveryl.yml needs update");
$this->logger->notice("Current Version: $advVer\tLatest Version: $cfgVer");
$this->logger->customsend(TextFormat::YELLOW . "Your leveryl.yml needs an update.", "ConfigLoader", TextFormat::GREEN);
$this->logger->customsend(TextFormat::AQUA . "Current Version: $advVer", "ConfigLoader", TextFormat::GREEN);
$this->logger->customsend(TextFormat::AQUA . "Latest Version: $cfgVer", "ConfigLoader", TextFormat::GREEN);
}

$this->start();
Expand Down Expand Up @@ -2340,7 +2344,7 @@ public function forceShutdown(){
}

if($this->getProperty("network.upnp-forwarding", false) === true){
$this->logger->info("[UPnP] Removing port forward...");
$this->logger->customsend("Removing port forward...", "UPnP", TextFormat::WHITE);
UPnP::RemovePortForward($this->getPort());
}

Expand Down Expand Up @@ -2410,7 +2414,7 @@ public function start(){


if($this->getProperty("network.upnp-forwarding", false) == true){
$this->logger->info("[UPnP] Trying to port forward...");
$this->logger->customsend("Trying to port forward...", "UPnP", TextFormat::WHITE);
UPnP::PortForward($this->getPort());
}

Expand Down Expand Up @@ -2949,4 +2953,11 @@ private function tick(){

return true;
}

/**
* @return string
*/
public function getLeverylAPIVersion(){
return \pocketmine\LEVERYL_API_VERSION;
}
}
3 changes: 2 additions & 1 deletion src/pocketmine/block/DragonEgg.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use pocketmine\event\block\BlockTeleportEvent;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\level\Position;
use pocketmine\level\sound\GenericSound;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
Expand Down Expand Up @@ -93,7 +94,7 @@ public function onActivate(Item $item, Player $player = null){
$x = $this->getX() + self::RAND_HORIZONTAL[array_rand(self::RAND_HORIZONTAL)];
$y = $this->getY() + self::RAND_VERTICAL[array_rand(self::RAND_VERTICAL)];
$z = $this->getZ() + self::RAND_HORIZONTAL[array_rand(self::RAND_HORIZONTAL)];
if($level->getBlockIdAt($x,$y,$z) == 0){
if($level->getBlockIdAt($x,$y,$z) == 0 && $y < Level::Y_MAX){
$safe = true;
break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pocketmine/block/EnderChest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use pocketmine\item\Item;
use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\StringTag;
Expand Down Expand Up @@ -151,7 +152,7 @@ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy,
*/
public function onActivate(Item $item, Player $player = null){
if($player instanceof Player){
$top = $this->getSide(1);
$top = $this->getSide(Vector3::SIDE_UP);
if($top->isTransparent() !== true){
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/pocketmine/command/CommandExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*
*/

declare(strict_types = 1);

namespace pocketmine\command;


Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/event/server/QueryRegenerateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function __construct(Server $server, $timeout = 5){

$this->gametype = ($server->getGamemode() & 0x01) === 0 ? "SMP" : "CMP";
$this->version = $server->getVersion();
$this->server_engine = $server->getName() . " " . $server->getPocketMineVersion();
$this->server_engine = $server->getName() . " v" . $server->getPocketMineVersion();
$this->map = $server->getDefaultLevel() === null ? "unknown" : $server->getDefaultLevel()->getName();
$this->numPlayers = $poc;
$this->maxPlayers = $pc;
Expand Down
4 changes: 3 additions & 1 deletion src/pocketmine/inventory/WindowHolder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
*
* ____ _ _
* | _ \ _ __(_)___ _ __ ___ __ _ _ __(_)_ __ ___
Expand All @@ -19,6 +19,8 @@
*
*/

declare(strict_types = 1);

namespace pocketmine\inventory;

use pocketmine\math\Vector3;
Expand Down
13 changes: 9 additions & 4 deletions src/pocketmine/inventory/WindowInventory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/**
/*
*
* ____ _ _
* | _ \ _ __(_)___ _ __ ___ __ _ _ __(_)_ __ ___
Expand All @@ -19,6 +19,8 @@
*
*/

declare(strict_types = 1);

namespace pocketmine\inventory;

use pocketmine\block\Block;
Expand All @@ -31,6 +33,7 @@
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
use pocketmine\Player;
use pocketmine\tile\Tile;
use pocketmine\utils\TextFormat;

class WindowInventory extends CustomInventory {

Expand Down Expand Up @@ -75,7 +78,8 @@ public function __construct(Player $player, $size = 27, $name = ""){
$this->block = 117;
break;
default:
$player->getServer()->getLogger()->notice("Unknown window size. If must be one from: 1, 2, 3, 5, 9, 27, 54. Using default size(27).");
$player->getServer()->getLogger()->customsend("Unknown Inventory size. It must be one from: 1, 2, 3, 5, 9, 27, 54. Using default size(27).", "WindowInventory", TextFormat::GRAY);
break;
}
$this->customName = $name;
$holder = new WindowHolder($player->getFloorX(), $player->getFloorY(), $player->getFloorZ(), $this);
Expand Down Expand Up @@ -108,13 +112,14 @@ public function onOpen(Player $who){
$pk->x = $holder->x;
$pk->y = $holder->y;
$pk->z = $holder->z;
$pk->namedtag = $nbt->write();
$pk->namedtag = $nbt->write(true);
$who->dataPacket($pk);
parent::onOpen($who);
$this->sendContents($who);
}

public function onClose(Player $who){
$this->holder = $holder = new WindowHolder($who->getFloorX(), $who->getFloorY(), $who->getFloorZ(), $this);
$holder = $this->holder;
$pk = new UpdateBlockPacket();
$pk->x = $holder->x;
Expand All @@ -125,7 +130,7 @@ public function onClose(Player $who){
$pk->flags = UpdateBlockPacket::FLAG_ALL;
$who->dataPacket($pk);
$who->getLevel()->setBlock(new Vector3($holder->x, $holder->y, $holder->z), $this->oldID[$who->getName()]);
$this->oldID[$who->getName()] = 0;

This comment has been minimized.

Copy link
@Encritary

Encritary Sep 11, 2017

Contributor

WTF is oldID? It does nothing...

This comment has been minimized.

Copy link
@CortexPE

CortexPE Sep 12, 2017

Author Member

Not exactly "nothing"
It's there for a reason.

This comment has been minimized.

Copy link
@XDqrkneZ

XDqrkneZ Sep 12, 2017

don't mind there randies

This comment has been minimized.

Copy link
@XDqrkneZ

XDqrkneZ Sep 12, 2017

these^

unset($this->oldID[$who->getName()]);
parent::onClose($who);
}
}
2 changes: 1 addition & 1 deletion src/pocketmine/resources/leveryl_chs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#配置文件版本
config:
version: 28
version: 30

level:
#设置是否变换天气
Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/resources/leveryl_eng.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#Version of this file
config:
version: 29
version: 30

level:
#Set if weather is enabled (rain may cause lag to older devices)
Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/resources/leveryl_fra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#Version de ce fichier
config:
version: 29
version: 30

level:
#Réglez si la météo est activée (la pluie peut provoquer un retard sur les périphériques plus anciens)
Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/resources/leveryl_jpn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#ファイルのバージョン
config:
version: 29
version: 30

level:
#有効にすると、天候要素が加わります(雨が降ると古い端末の動作が遅くなる場合があります)
Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/resources/leveryl_rus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#Версия этого файла
config:
version: 29
version: 30

level:
#Выберите, включена ли погода (дождь может вызвать лаги на старых устройствах)
Expand Down
8 changes: 7 additions & 1 deletion src/pocketmine/resources/leveryl_zho.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#配置檔案版本
config:
version: 28
version: 30

level:
#設定是否變換天氣
Expand Down Expand Up @@ -138,5 +138,11 @@ inventory:
#如果無法使用鐵砧或附魔台請啟用本項. 將會對背包進行驗證.
allow-cheats: false

always-day:
#LevelName: <Time> / true / false - true will set the time to 0
#Examples:
#LevelName: 1800
#LevelName: true

no-weather:
# - "LevelName"
1 change: 1 addition & 0 deletions src/raklib/server/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ public function handlePacket(Packet $packet){
public function close(){
$data = "\x60\x00\x08\x00\x00\x00\x00\x00\x00\x00\x15";
$this->addEncapsulatedToQueue(EncapsulatedPacket::fromBinary($data)); //CLIENT_DISCONNECT packet 0x15
$this->sendQueue();
$this->sessionManager = null;
}
}

0 comments on commit d638aa7

Please sign in to comment.