mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-16 22:35:06 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
d33acc4fd0 | |||
f7de6eb59f | |||
75a0627bf2 | |||
8752e363c9 | |||
9ed1b5ca7f | |||
1cbb31f1db | |||
1393b4c4e2 | |||
2921c86b3c | |||
9c3a929b65 |
@ -327,6 +327,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
/** @var Form[] */
|
/** @var Form[] */
|
||||||
protected $forms = [];
|
protected $forms = [];
|
||||||
|
|
||||||
|
/** @var float */
|
||||||
|
protected $lastRightClickTime = 0.0;
|
||||||
|
/** @var Vector3|null */
|
||||||
|
protected $lastRightClickPos = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TranslationContainer|string
|
* @return TranslationContainer|string
|
||||||
*/
|
*/
|
||||||
@ -671,7 +676,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
public function sendCommandData(){
|
public function sendCommandData(){
|
||||||
$pk = new AvailableCommandsPacket();
|
$pk = new AvailableCommandsPacket();
|
||||||
foreach($this->server->getCommandMap()->getCommands() as $name => $command){
|
foreach($this->server->getCommandMap()->getCommands() as $name => $command){
|
||||||
if(isset($pk->commandData[$command->getName()]) or $command->getName() === "help"){
|
if(isset($pk->commandData[$command->getName()]) or $command->getName() === "help" or !$command->testPermissionSilent($this)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2333,6 +2338,19 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$type = $packet->trData->actionType;
|
$type = $packet->trData->actionType;
|
||||||
switch($type){
|
switch($type){
|
||||||
case InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK:
|
case InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK:
|
||||||
|
//TODO: start hack for client spam bug
|
||||||
|
$spamBug = ($this->lastRightClickPos !== null and
|
||||||
|
microtime(true) - $this->lastRightClickTime < 0.1 and //100ms
|
||||||
|
$this->lastRightClickPos->distanceSquared($packet->trData->clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error
|
||||||
|
);
|
||||||
|
//get rid of continued spam if the player clicks and holds right-click
|
||||||
|
$this->lastRightClickPos = clone $packet->trData->clickPos;
|
||||||
|
$this->lastRightClickTime = microtime(true);
|
||||||
|
if($spamBug){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//TODO: end hack for client spam bug
|
||||||
|
|
||||||
$this->setUsingItem(false);
|
$this->setUsingItem(false);
|
||||||
|
|
||||||
if(!$this->canInteract($blockVector->add(0.5, 0.5, 0.5), 13) or $this->isSpectator()){
|
if(!$this->canInteract($blockVector->add(0.5, 0.5, 0.5), 13) or $this->isSpectator()){
|
||||||
|
@ -37,7 +37,7 @@ namespace pocketmine {
|
|||||||
use pocketmine\wizard\SetupWizard;
|
use pocketmine\wizard\SetupWizard;
|
||||||
|
|
||||||
const NAME = "PocketMine-MP";
|
const NAME = "PocketMine-MP";
|
||||||
const BASE_VERSION = "3.5.3";
|
const BASE_VERSION = "3.5.4";
|
||||||
const IS_DEVELOPMENT_BUILD = false;
|
const IS_DEVELOPMENT_BUILD = false;
|
||||||
const BUILD_NUMBER = 0;
|
const BUILD_NUMBER = 0;
|
||||||
|
|
||||||
|
@ -2491,9 +2491,7 @@ class Server{
|
|||||||
$this->logger->debug("Unhandled raw packet from $address $port: " . bin2hex($payload));
|
$this->logger->debug("Unhandled raw packet from $address $port: " . bin2hex($payload));
|
||||||
}
|
}
|
||||||
}catch(\Throwable $e){
|
}catch(\Throwable $e){
|
||||||
if(\pocketmine\DEBUG > 1){
|
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
}
|
|
||||||
|
|
||||||
$this->getNetwork()->blockAddress($address, 600);
|
$this->getNetwork()->blockAddress($address, 600);
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ class Torch extends Flowable{
|
|||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
$below = $this->getSide(Vector3::SIDE_DOWN);
|
$below = $this->getSide(Vector3::SIDE_DOWN);
|
||||||
$side = $this->getDamage();
|
$meta = $this->getDamage();
|
||||||
$faces = [
|
static $faces = [
|
||||||
0 => Vector3::SIDE_DOWN,
|
0 => Vector3::SIDE_DOWN,
|
||||||
1 => Vector3::SIDE_WEST,
|
1 => Vector3::SIDE_WEST,
|
||||||
2 => Vector3::SIDE_EAST,
|
2 => Vector3::SIDE_EAST,
|
||||||
@ -54,8 +54,9 @@ class Torch extends Flowable{
|
|||||||
4 => Vector3::SIDE_SOUTH,
|
4 => Vector3::SIDE_SOUTH,
|
||||||
5 => Vector3::SIDE_DOWN
|
5 => Vector3::SIDE_DOWN
|
||||||
];
|
];
|
||||||
|
$face = $faces[$meta] ?? Vector3::SIDE_DOWN;
|
||||||
|
|
||||||
if($this->getSide($faces[$side])->isTransparent() and !($faces[$side] === Vector3::SIDE_DOWN and ($below->getId() === self::FENCE or $below->getId() === self::COBBLESTONE_WALL))){
|
if($this->getSide($face)->isTransparent() and !($face === Vector3::SIDE_DOWN and ($below->getId() === self::FENCE or $below->getId() === self::COBBLESTONE_WALL))){
|
||||||
$this->getLevel()->useBreakOn($this);
|
$this->getLevel()->useBreakOn($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ abstract class Event{
|
|||||||
*/
|
*/
|
||||||
public function isCancelled() : bool{
|
public function isCancelled() : bool{
|
||||||
if(!($this instanceof Cancellable)){
|
if(!($this instanceof Cancellable)){
|
||||||
throw new \BadMethodCallException("Event is not Cancellable");
|
throw new \BadMethodCallException(get_class($this) . " is not Cancellable");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Event $this */
|
/** @var Event $this */
|
||||||
@ -64,7 +64,7 @@ abstract class Event{
|
|||||||
*/
|
*/
|
||||||
public function setCancelled(bool $value = true) : void{
|
public function setCancelled(bool $value = true) : void{
|
||||||
if(!($this instanceof Cancellable)){
|
if(!($this instanceof Cancellable)){
|
||||||
throw new \BadMethodCallException("Event is not Cancellable");
|
throw new \BadMethodCallException(get_class($this) . " is not Cancellable");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Event $this */
|
/** @var Event $this */
|
||||||
|
@ -26,7 +26,8 @@ namespace pocketmine\event\server;
|
|||||||
use pocketmine\network\SourceInterface;
|
use pocketmine\network\SourceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a network interface crashes, with relevant crash information.
|
* Never called. Should never have come into this world. Nothing to see here.
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
class NetworkInterfaceCrashEvent extends NetworkInterfaceEvent{
|
class NetworkInterfaceCrashEvent extends NetworkInterfaceEvent{
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,6 @@ declare(strict_types=1);
|
|||||||
*/
|
*/
|
||||||
namespace pocketmine\network;
|
namespace pocketmine\network;
|
||||||
|
|
||||||
use pocketmine\event\server\NetworkInterfaceCrashEvent;
|
|
||||||
use pocketmine\event\server\NetworkInterfaceRegisterEvent;
|
use pocketmine\event\server\NetworkInterfaceRegisterEvent;
|
||||||
use pocketmine\event\server\NetworkInterfaceUnregisterEvent;
|
use pocketmine\event\server\NetworkInterfaceUnregisterEvent;
|
||||||
use pocketmine\network\mcpe\protocol\PacketPool;
|
use pocketmine\network\mcpe\protocol\PacketPool;
|
||||||
@ -85,25 +84,16 @@ class Network{
|
|||||||
|
|
||||||
public function processInterfaces(){
|
public function processInterfaces(){
|
||||||
foreach($this->interfaces as $interface){
|
foreach($this->interfaces as $interface){
|
||||||
$this->processInterface($interface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processInterface(SourceInterface $interface) : void{
|
|
||||||
try{
|
|
||||||
$interface->process();
|
$interface->process();
|
||||||
}catch(\Throwable $e){
|
}
|
||||||
$logger = $this->server->getLogger();
|
|
||||||
if(\pocketmine\DEBUG > 1){
|
|
||||||
$logger->logException($e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(new NetworkInterfaceCrashEvent($interface, $e))->call();
|
/**
|
||||||
|
* @deprecated
|
||||||
$interface->emergencyShutdown();
|
* @param SourceInterface $interface
|
||||||
$this->unregisterInterface($interface);
|
*/
|
||||||
$logger->critical($this->server->getLanguage()->translateString("pocketmine.server.networkError", [get_class($interface), $e->getMessage()]));
|
public function processInterface(SourceInterface $interface) : void{
|
||||||
}
|
$interface->process();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,6 +71,9 @@ interface SourceInterface{
|
|||||||
|
|
||||||
public function shutdown();
|
public function shutdown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
public function emergencyShutdown();
|
public function emergencyShutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
|||||||
|
|
||||||
public function start(){
|
public function start(){
|
||||||
$this->server->getTickSleeper()->addNotifier($this->sleeper, function() : void{
|
$this->server->getTickSleeper()->addNotifier($this->sleeper, function() : void{
|
||||||
$this->server->getNetwork()->processInterface($this);
|
$this->process();
|
||||||
});
|
});
|
||||||
$this->rakLib->start(PTHREADS_INHERIT_CONSTANTS); //HACK: MainLogger needs constants for exception logging
|
$this->rakLib->start(PTHREADS_INHERIT_CONSTANTS); //HACK: MainLogger needs constants for exception logging
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user