mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 23:37:45 +00:00
Merge branch 'stable' into next-minor
This commit is contained in:
@@ -75,7 +75,7 @@ class BanIpCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
private function processIPBan(string $ip, CommandSender $sender, string $reason){
|
||||
private function processIPBan(string $ip, CommandSender $sender, string $reason) : void{
|
||||
$sender->getServer()->getIPBans()->addBan($ip, $reason, null, $sender->getName());
|
||||
|
||||
foreach($sender->getServer()->getOnlinePlayers() as $player){
|
||||
|
@@ -63,7 +63,7 @@ class BanListCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
$list = $list->getEntries();
|
||||
$message = implode(", ", array_map(function(BanEntry $entry){
|
||||
$message = implode(", ", array_map(function(BanEntry $entry) : string{
|
||||
return $entry->getName();
|
||||
}, $list));
|
||||
|
||||
|
@@ -76,7 +76,7 @@ class EffectCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
if($effect === null){
|
||||
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.effect.notFound", [(string) $args[1]]));
|
||||
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.effect.notFound", [$args[1]]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,6 @@ class EffectCommand extends VanillaCommand{
|
||||
self::broadcastCommandMessage($sender, new TranslationContainer("%commands.effect.success", [$effect->getName(), $instance->getAmplifier(), $player->getDisplayName(), $instance->getDuration() / 20, $effect->getId()]));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -88,7 +88,6 @@ class EnchantCommand extends VanillaCommand{
|
||||
$item->addEnchantment(new EnchantmentInstance($enchantment, $level));
|
||||
$player->getInventory()->setItemInHand($item);
|
||||
|
||||
|
||||
self::broadcastCommandMessage($sender, new TranslationContainer("%commands.enchant.success", [$player->getName()]));
|
||||
return true;
|
||||
}
|
||||
|
@@ -57,22 +57,22 @@ class HelpCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
if(count($args) === 0){
|
||||
$command = "";
|
||||
$commandName = "";
|
||||
$pageNumber = 1;
|
||||
}elseif(is_numeric($args[count($args) - 1])){
|
||||
$pageNumber = (int) array_pop($args);
|
||||
if($pageNumber <= 0){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$command = implode(" ", $args);
|
||||
$commandName = implode(" ", $args);
|
||||
}else{
|
||||
$command = implode(" ", $args);
|
||||
$commandName = implode(" ", $args);
|
||||
$pageNumber = 1;
|
||||
}
|
||||
|
||||
$pageHeight = $sender->getScreenLineHeight();
|
||||
|
||||
if($command === ""){
|
||||
if($commandName === ""){
|
||||
/** @var Command[][] $commands */
|
||||
$commands = [];
|
||||
foreach($sender->getServer()->getCommandMap()->getCommands() as $command){
|
||||
@@ -82,7 +82,7 @@ class HelpCommand extends VanillaCommand{
|
||||
}
|
||||
ksort($commands, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
$commands = array_chunk($commands, $pageHeight);
|
||||
$pageNumber = (int) min(count($commands), $pageNumber);
|
||||
$pageNumber = min(count($commands), $pageNumber);
|
||||
if($pageNumber < 1){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class HelpCommand extends VanillaCommand{
|
||||
|
||||
return true;
|
||||
}else{
|
||||
if(($cmd = $sender->getServer()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){
|
||||
if(($cmd = $sender->getServer()->getCommandMap()->getCommand(strtolower($commandName))) instanceof Command){
|
||||
if($cmd->testPermissionSilent($sender)){
|
||||
$message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $cmd->getName() . TextFormat::YELLOW . " ---------\n";
|
||||
$message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $cmd->getDescription() . "\n";
|
||||
@@ -105,7 +105,7 @@ class HelpCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$sender->sendMessage(TextFormat::RED . "No help for " . strtolower($command));
|
||||
$sender->sendMessage(TextFormat::RED . "No help for " . strtolower($commandName));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -68,7 +68,6 @@ class KickCommand extends VanillaCommand{
|
||||
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.player.notFound"));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -47,9 +47,9 @@ class ListCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
$playerNames = array_map(function(Player $player){
|
||||
$playerNames = array_map(function(Player $player) : string{
|
||||
return $player->getName();
|
||||
}, array_filter($sender->getServer()->getOnlinePlayers(), function(Player $player) use ($sender){
|
||||
}, array_filter($sender->getServer()->getOnlinePlayers(), function(Player $player) use ($sender) : bool{
|
||||
return $player->isOnline() and (!($sender instanceof Player) or $sender->canSee($player));
|
||||
}));
|
||||
|
||||
|
@@ -119,7 +119,6 @@ class ParticleCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$sender->sendMessage(new TranslationContainer("commands.particle.success", [$name, $count]));
|
||||
|
||||
$random = new Random((int) (microtime(true) * 1000) + mt_rand());
|
||||
@@ -137,13 +136,6 @@ class ParticleCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param Vector3 $pos
|
||||
* @param float $xd
|
||||
* @param float $yd
|
||||
* @param float $zd
|
||||
* @param int|null $data
|
||||
*
|
||||
* @return Particle|null
|
||||
*/
|
||||
private function getParticle(string $name, Vector3 $pos, float $xd, float $yd, float $zd, int $data = null){
|
||||
|
@@ -52,7 +52,7 @@ class TeleportCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
$args = array_values(array_filter($args, function($arg){
|
||||
$args = array_values(array_filter($args, function(string $arg) : bool{
|
||||
return $arg !== "";
|
||||
}));
|
||||
if(count($args) < 1 or count($args) > 6){
|
||||
|
@@ -85,7 +85,6 @@ class TimeCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(count($args) < 2){
|
||||
throw new InvalidCommandSyntaxException();
|
||||
}
|
||||
|
@@ -126,18 +126,25 @@ class TimingsCommand extends VanillaCommand{
|
||||
/** @var string */
|
||||
private $host;
|
||||
|
||||
/**
|
||||
* @param string[] $data
|
||||
* @phpstan-param array<string, string> $data
|
||||
*/
|
||||
public function __construct(CommandSender $sender, string $host, string $agent, array $data){
|
||||
parent::__construct([
|
||||
["page" => "https://$host?upload=true", "extraOpts" => [
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"User-Agent: $agent",
|
||||
"Content-Type: application/x-www-form-urlencoded"
|
||||
],
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => http_build_query($data),
|
||||
CURLOPT_AUTOREFERER => false,
|
||||
CURLOPT_FOLLOWLOCATION => false
|
||||
]]
|
||||
[
|
||||
"page" => "https://$host?upload=true",
|
||||
"extraOpts" => [
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"User-Agent: $agent",
|
||||
"Content-Type: application/x-www-form-urlencoded"
|
||||
],
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => http_build_query($data),
|
||||
CURLOPT_AUTOREFERER => false,
|
||||
CURLOPT_FOLLOWLOCATION => false
|
||||
]
|
||||
]
|
||||
], $sender);
|
||||
$this->host = $host;
|
||||
}
|
||||
|
@@ -21,10 +21,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace pocketmine\command\defaults;
|
||||
|
||||
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||
use pocketmine\Player;
|
||||
|
@@ -36,12 +36,7 @@ abstract class VanillaCommand extends Command{
|
||||
public const MIN_COORD = -30000000;
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param mixed $value
|
||||
* @param int $min
|
||||
* @param int $max
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getInteger(CommandSender $sender, $value, int $min = self::MIN_COORD, int $max = self::MAX_COORD) : int{
|
||||
$i = (int) $value;
|
||||
@@ -55,15 +50,6 @@ abstract class VanillaCommand extends Command{
|
||||
return $i;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $original
|
||||
* @param CommandSender $sender
|
||||
* @param string $input
|
||||
* @param float $min
|
||||
* @param float $max
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
protected function getRelativeDouble(float $original, CommandSender $sender, string $input, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
|
||||
if($input[0] === "~"){
|
||||
$value = $this->getDouble($sender, substr($input, 1));
|
||||
@@ -75,12 +61,7 @@ abstract class VanillaCommand extends Command{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param mixed $value
|
||||
* @param float $min
|
||||
* @param float $max
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
protected function getDouble(CommandSender $sender, $value, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
|
||||
$i = (double) $value;
|
||||
|
@@ -84,7 +84,7 @@ class VersionCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
private function describeToSender(Plugin $plugin, CommandSender $sender){
|
||||
private function describeToSender(Plugin $plugin, CommandSender $sender) : void{
|
||||
$desc = $plugin->getDescription();
|
||||
$sender->sendMessage(TextFormat::DARK_GREEN . $desc->getName() . TextFormat::WHITE . " version " . TextFormat::DARK_GREEN . $desc->getVersion());
|
||||
|
||||
|
Reference in New Issue
Block a user