Skip to content
This repository has been archived by the owner on Feb 2, 2018. It is now read-only.

Commit

Permalink
Update to 1.0.3.0
Browse files Browse the repository at this point in the history
1.0.3.0
  • Loading branch information
inxomnyaa authored Feb 11, 2017
2 parents 923d178 + 333c106 commit 2df8a3c
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 5 deletions.
21 changes: 21 additions & 0 deletions src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityShootBowEvent;
use pocketmine\event\player\PlayerTransferEvent;
use pocketmine\event\entity\ProjectileLaunchEvent;
use pocketmine\event\inventory\CraftItemEvent;
use pocketmine\event\inventory\InventoryCloseEvent;
Expand Down Expand Up @@ -132,6 +133,7 @@
use pocketmine\network\protocol\StartGamePacket;
use pocketmine\network\protocol\TakeItemEntityPacket;
use pocketmine\network\protocol\TextPacket;
use pocketmine\network\protocol\TransferPacket;
use pocketmine\network\protocol\UpdateAttributesPacket;
use pocketmine\network\protocol\UpdateBlockPacket;
use pocketmine\network\SourceInterface;
Expand Down Expand Up @@ -1024,6 +1026,25 @@ public function directDataPacket(DataPacket $packet, $needACK = false){
return true;
}

/**
* @param string $address
* @param int $port
* @return bool transferred
*/
public function transferTo(string $address, int $port = 19132) {
$this->server->getPluginManager()->callEvent($ev = new PlayerTransferEvent($this, $address, $port));
if ($ev->isCancelled()) {
return false;
}
$pk = new TransferPacket();
$pk->address = $ev->getAddress();
$pk->port = $ev->getPort();
$this->dataPacket($pk);
Command::broadcastCommandMessage($this, new TranslationContainer("Transferred to {%0}:{%1}", [$ev->getAddress(), $ev->getPort()]));

return true;
}

/**
* @param Vector3 $pos
*
Expand Down
3 changes: 3 additions & 0 deletions src/pocketmine/command/SimpleCommandMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
use pocketmine\command\defaults\TellCommand;
use pocketmine\command\defaults\TimeCommand;
use pocketmine\command\defaults\TimingsCommand;
use pocketmine\command\defaults\TransferCommand;
use pocketmine\command\defaults\TransferserverCommand;
use pocketmine\command\defaults\VanillaCommand;
use pocketmine\command\defaults\VersionCommand;
use pocketmine\command\defaults\WhitelistCommand;
Expand Down Expand Up @@ -114,6 +116,7 @@ private function setDefaultCommands(){
$this->register("pocketmine", new TeleportCommand("tp"));
$this->register("pocketmine", new TimeCommand("time"));
$this->register("pocketmine", new TimingsCommand("timings"));
$this->register("pocketmine", new TransferserverCommand("transferserver"));
$this->register("pocketmine", new ReloadCommand("reload"));

if($this->server->getProperty("debug.commands", false)){
Expand Down
65 changes: 65 additions & 0 deletions src/pocketmine/command/defaults/TransferserverCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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\command\defaults;

use pocketmine\command\CommandSender;
use pocketmine\command\ConsoleCommandSender;
use pocketmine\event\TranslationContainer;
use pocketmine\Player;
use pocketmine\utils\TextFormat;

class TransferserverCommand extends VanillaCommand {

public function __construct($name) {
parent::__construct(
$name,
"Connect to another server",
"transferserver address:string port:short",
["ts"]
);
$this->setPermission("pocketmine.command.transferserver");
}

public function execute(CommandSender $sender, $currentAlias, array $args) {
if (!$this->testPermission($sender)) {
return true;
}
if ($sender instanceof ConsoleCommandSender) {
$sender->sendMessage(TextFormat::RED . 'A console can not be transferred!');
return true;
}

/** @var string $address
* @var int $port
*/
if (count($args) < 2 || !is_string(($address = $args[0])) || !is_numeric(($port = $args[1]))) {
$sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));

return false;
}

/** @var Player $sender */
$success = $sender->transferTo($address, $port);

return $success;
}
}
71 changes: 71 additions & 0 deletions src/pocketmine/event/player/PlayerTransferEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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\Cancellable;
use pocketmine\event\player\PlayerEvent;
use pocketmine\Player;

class PlayerTransferEvent extends PlayerEvent implements Cancellable {
public static $handlerList = null;

/** @var string $address */
private $address;
/** @var int $port */
private $port;

public function __construct(Player $player, string $address, int $port) {
$this->player = $player;
$this->address = $address;
$this->port = $port;
}

/**
* @return string
*/
public function getAddress() {
return $this->address;
}

/**
* @param string $address
*/
public function setAddress(string $address) {
$this->address = $address;
}

/**
* @return int
*/
public function getPort() {
return $this->port;
}

/**
* @param int $port
*/
public function setPort(int $port) {
$this->port = $port;
}


}
7 changes: 4 additions & 3 deletions src/pocketmine/network/protocol/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ interface Info{
/**
* Actual Minecraft: PE protocol version
*/
const CURRENT_PROTOCOL = 100;
const MINECRAFT_VERSION = "v1.0.0.16";
const MINECRAFT_VERSION_NETWORK = "1.0.0.16";
const CURRENT_PROTOCOL = 101;
const MINECRAFT_VERSION = "v1.0.3.0";
const MINECRAFT_VERSION_NETWORK = "1.0.3.0";

const LOGIN_PACKET = 0x01;
const PLAY_STATUS_PACKET = 0x02;
Expand Down Expand Up @@ -115,5 +115,6 @@ interface Info{
const RESOURCE_PACK_DATA_INFO_PACKET = 0x4f;
const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x50;
const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x51;
const TRANSFER_PACKET = 0x52;

}
2 changes: 1 addition & 1 deletion src/pocketmine/network/protocol/StartGamePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function encode(){
$this->putEntityId($this->entityRuntimeId); //EntityRuntimeID
$this->putVector3f($this->x, $this->y, $this->z);
$this->putLFloat(0); //TODO: find out what these are (yaw/pitch?)
$this->putLFloat(0);
$this->putLFloat(0); // Those are a Vector2
$this->putVarInt($this->seed);
$this->putVarInt($this->dimension);
$this->putVarInt($this->generator);
Expand Down
38 changes: 38 additions & 0 deletions src/pocketmine/network/protocol/TransferPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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\network\protocol;

class TransferPacket extends DataPacket {
const NETWORK_ID = Info::TRANSFER_PACKET;

public $address;
public $port;

public function decode() { }

public function encode() {
$this->reset();
$this->putString($this->address);
$this->putLShort($this->port);
}

}
2 changes: 1 addition & 1 deletion src/raklib
Submodule raklib updated 1 files
+14 −18 server/RakLibServer.php

0 comments on commit 2df8a3c

Please sign in to comment.